]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | Subject: Don't spu_acquire_saved unnecessarily in regs read |
2 | From: Jeremy Kerr <jk@ozlabs.org> | |
3 | References: 447133 - LTC50070 | |
4 | ||
5 | With most file readers (eg cat, dd), reading a context's regs file will | |
6 | result in two reads: the first to read the data, and the second to | |
7 | return EOF. Because each read performs a spu_acquire_saved, we end up | |
8 | descheduling and re-scheduling the context twice. | |
9 | ||
10 | This change does a simple check to see if we'd return EOF before | |
11 | calling spu_acquire_saved(), saving the extra schedule operation. | |
12 | ||
13 | Signed-off-by: Jeremy Kerr <jk@ozlabs.org> | |
14 | Signed-off-by: Olaf Hering <olh@suse.de> | |
15 | --- | |
16 | arch/powerpc/platforms/cell/spufs/file.c | 5 +++++ | |
17 | 1 file changed, 5 insertions(+) | |
18 | ||
19 | --- a/arch/powerpc/platforms/cell/spufs/file.c | |
20 | +++ b/arch/powerpc/platforms/cell/spufs/file.c | |
21 | @@ -551,6 +551,11 @@ spufs_regs_read(struct file *file, char | |
22 | int ret; | |
23 | struct spu_context *ctx = file->private_data; | |
24 | ||
25 | + /* pre-check for file position: if we'd return EOF, there's no point | |
26 | + * causing a deschedule */ | |
27 | + if (*pos >= sizeof(ctx->csa.lscsa->gprs)) | |
28 | + return 0; | |
29 | + | |
30 | ret = spu_acquire_saved(ctx); | |
31 | if (ret) | |
32 | return ret; |