From f027faa231f38c02e949352735eac76f29090809 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Thu, 16 Oct 2008 11:11:12 +1100 Subject: [PATCH] powerpc/spufs: Don't spu_acquire_saved unnecessarily in regs read With most file readers (eg cat, dd), reading a context's regs file will result in two reads: the first to read the data, and the second to return EOF. Because each read performs a spu_acquire_saved, we end up descheduling and re-scheduling the context twice. This change does a simple check to see if we'd return EOF before calling spu_acquire_saved(), saving the extra schedule operation. Signed-off-by: Jeremy Kerr --- arch/powerpc/platforms/cell/spufs/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c index f139cd8b594d..b6f7b917b56c 100644 --- a/arch/powerpc/platforms/cell/spufs/file.c +++ b/arch/powerpc/platforms/cell/spufs/file.c @@ -548,6 +548,11 @@ spufs_regs_read(struct file *file, char __user *buffer, int ret; struct spu_context *ctx = file->private_data; + /* pre-check for file position: if we'd return EOF, there's no point + * causing a deschedule */ + if (*pos >= sizeof(ctx->csa.lscsa->gprs)) + return 0; + ret = spu_acquire_saved(ctx); if (ret) return ret; -- 2.20.1