]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.arch/ppc-spufs-03-sputrace-Only-enable-logging-on-open.patch
Updated xen patches taken from suse.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.arch / ppc-spufs-03-sputrace-Only-enable-logging-on-open.patch
1 Subject: Only enable logging on open(), prevent multiple openers
2 From: Jeremy Kerr <jk@ozlabs.org>
3 References: 447133 - LTC50070
4
5 Currently, sputrace will start logging to the event buffer before the
6 log buffer has been open()ed. This results in a heap of "lost samples"
7 warnings if the sputrace file hasn't yet been opened.
8
9 Since the buffer is reset on open() anyway, there's no need to enable
10 logging when no-one has opened the log.
11
12 Because open clears the log, make it return EBUSY for mutliple open
13 calls.
14
15 Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
16 Signed-off-by: Olaf Hering <olh@suse.de>
17 ---
18 arch/powerpc/platforms/cell/spufs/sputrace.c | 32 ++++++++++++++++++++++++---
19 1 file changed, 29 insertions(+), 3 deletions(-)
20
21 --- a/arch/powerpc/platforms/cell/spufs/sputrace.c
22 +++ b/arch/powerpc/platforms/cell/spufs/sputrace.c
23 @@ -40,6 +40,7 @@ static DECLARE_WAIT_QUEUE_HEAD(sputrace_
24 static ktime_t sputrace_start;
25 static unsigned long sputrace_head, sputrace_tail;
26 static struct sputrace *sputrace_log;
27 +static int sputrace_logging;
28
29 static int sputrace_used(void)
30 {
31 @@ -109,24 +110,49 @@ static ssize_t sputrace_read(struct file
32
33 static int sputrace_open(struct inode *inode, struct file *file)
34 {
35 + int rc;
36 +
37 spin_lock(&sputrace_lock);
38 + if (sputrace_logging) {
39 + rc = -EBUSY;
40 + goto out;
41 + }
42 +
43 + sputrace_logging = 1;
44 sputrace_head = sputrace_tail = 0;
45 sputrace_start = ktime_get();
46 + rc = 0;
47 +
48 +out:
49 spin_unlock(&sputrace_lock);
50 + return rc;
51 +}
52
53 +static int sputrace_release(struct inode *inode, struct file *file)
54 +{
55 + spin_lock(&sputrace_lock);
56 + sputrace_logging = 0;
57 + spin_unlock(&sputrace_lock);
58 return 0;
59 }
60
61 static const struct file_operations sputrace_fops = {
62 - .owner = THIS_MODULE,
63 - .open = sputrace_open,
64 - .read = sputrace_read,
65 + .owner = THIS_MODULE,
66 + .open = sputrace_open,
67 + .read = sputrace_read,
68 + .release = sputrace_release,
69 };
70
71 static void sputrace_log_item(const char *name, struct spu_context *ctx,
72 struct spu *spu)
73 {
74 spin_lock(&sputrace_lock);
75 +
76 + if (!sputrace_logging) {
77 + spin_unlock(&sputrace_lock);
78 + return;
79 + }
80 +
81 if (sputrace_avail() > 1) {
82 struct sputrace *t = sputrace_log + sputrace_head;
83