linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/15] Extract the file descriptor search logic in SPU coredump code
@ 2007-09-12  7:43 Michael Ellerman
  2007-09-12  7:43 ` [PATCH 02/15] Remove ctx_info and ctx_info_list Michael Ellerman
                   ` (14 more replies)
  0 siblings, 15 replies; 27+ messages in thread
From: Michael Ellerman @ 2007-09-12  7:43 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Jeremy Kerr, linux-kernel

Extract the logic for searching through the file descriptors for spu contexts
into a separate routine, coredump_next_context(), so we can use it elsewhere
in future. In the process we flatten the for loop, and move the NOSCHED test
into coredump_next_context().

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/platforms/cell/spufs/coredump.c |   58 +++++++++++++++++---------
 1 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c
index 5e31799..99f8e0b 100644
--- a/arch/powerpc/platforms/cell/spufs/coredump.c
+++ b/arch/powerpc/platforms/cell/spufs/coredump.c
@@ -109,16 +109,11 @@ static int spufs_ctx_note_size(struct spufs_ctx_info *ctx_info)
 	return total;
 }
 
-static int spufs_add_one_context(struct file *file, int dfd)
+static int spufs_add_one_context(struct spu_context *ctx, int dfd)
 {
-	struct spu_context *ctx;
 	struct spufs_ctx_info *ctx_info;
 	int size;
 
-	ctx = SPUFS_I(file->f_dentry->d_inode)->i_ctx;
-	if (ctx->flags & SPU_CREATE_NOSCHED)
-		return 0;
-
 	ctx_info = kzalloc(sizeof(*ctx_info), GFP_KERNEL);
 	if (unlikely(!ctx_info))
 		return -ENOMEM;
@@ -142,22 +137,45 @@ static int spufs_add_one_context(struct file *file, int dfd)
  * internal functionality to dump them without needing to actually
  * open the files.
  */
-static int spufs_arch_notes_size(void)
+static struct spu_context *coredump_next_context(int *fd)
 {
 	struct fdtable *fdt = files_fdtable(current->files);
-	int size = 0, fd;
-
-	for (fd = 0; fd < fdt->max_fds; fd++) {
-		if (FD_ISSET(fd, fdt->open_fds)) {
-			struct file *file = fcheck(fd);
-
-			if (file && file->f_op == &spufs_context_fops) {
-				int rval = spufs_add_one_context(file, fd);
-				if (rval < 0)
-					break;
-				size += rval;
-			}
-		}
+	struct file *file;
+	struct spu_context *ctx = NULL;
+
+	for (; *fd < fdt->max_fds; (*fd)++) {
+		if (!FD_ISSET(*fd, fdt->open_fds))
+			continue;
+
+		file = fcheck(*fd);
+
+		if (!file || file->f_op != &spufs_context_fops)
+			continue;
+
+		ctx = SPUFS_I(file->f_dentry->d_inode)->i_ctx;
+		if (ctx->flags & SPU_CREATE_NOSCHED)
+			continue;
+
+		/* start searching the next fd next time we're called */
+		(*fd)++;
+		break;
+	}
+
+	return ctx;
+}
+
+static int spufs_arch_notes_size(void)
+{
+	struct spu_context *ctx;
+	int size = 0, rc, fd;
+
+	fd = 0;
+	while ((ctx = coredump_next_context(&fd)) != NULL) {
+		rc = spufs_add_one_context(ctx, fd);
+		if (rc < 0)
+			break;
+
+		size += rc;
 	}
 
 	return size;
-- 
1.5.1.3.g7a33b

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2007-09-13 12:17 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-12  7:43 [PATCH 01/15] Extract the file descriptor search logic in SPU coredump code Michael Ellerman
2007-09-12  7:43 ` [PATCH 02/15] Remove ctx_info and ctx_info_list Michael Ellerman
2007-09-12  7:43 ` [PATCH 04/15] Use computed sizes/#defines rather than literals in SPU coredump code Michael Ellerman
2007-09-12  7:43 ` [PATCH 03/15] Call spu_acquire_saved() before calculating the SPU note sizes Michael Ellerman
2007-09-12  7:43 ` [PATCH 05/15] Write some SPU coredump values as ASCII Michael Ellerman
2007-09-12  7:43 ` [PATCH 06/15] Correctly calculate the size of the local-store to dump Michael Ellerman
2007-09-12 11:31   ` Arnd Bergmann
2007-09-12  7:43 ` [PATCH 07/15] Don't return -ENOSYS as extra notes size if spufs is not loaded Michael Ellerman
2007-09-12 11:04   ` Arnd Bergmann
2007-09-12  7:43 ` [PATCH 08/15] Use spufs_coredump_num_notes everywhere, and don't NULL terminate Michael Ellerman
2007-09-12  8:55   ` Arnd Bergmann
2007-09-12  7:43 ` [PATCH 09/15] Internal __spufs_get_foo() routines should take a spu_context * Michael Ellerman
2007-09-12  8:53   ` Arnd Bergmann
2007-09-12  7:43 ` [PATCH 10/15] Add contents of npc file to SPU coredumps Michael Ellerman
2007-09-12  8:52   ` Arnd Bergmann
2007-09-12  7:43 ` [PATCH 11/15] Combine spufs_coredump_calls with spufs_calls Michael Ellerman
2007-09-12  8:51   ` Arnd Bergmann
2007-09-12  7:43 ` [PATCH 12/15] Cleanup ELF coredump extra notes logic Michael Ellerman
2007-09-12  7:43 ` [PATCH 13/15] Handle errors in SPU coredump code, and support coredump to a pipe Michael Ellerman
2007-09-12  7:43 ` [PATCH 14/15] Respect RLIMIT_CORE in spu coredump code Michael Ellerman
2007-09-12  7:43 ` [PATCH 15/15] Add DEFINE_SPUFS_ATTRIBUTE() Michael Ellerman
2007-09-12  7:49   ` Michael Ellerman
2007-09-12  8:47     ` Arnd Bergmann
2007-09-13  2:05       ` Michael Ellerman
2007-09-13 12:17         ` Arnd Bergmann
2007-09-12  8:17 ` [PATCH 01/15] Extract the file descriptor search logic in SPU coredump code Jeremy Kerr
2007-09-12  8:35   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).