Re: Preempt & Xfs Question

From: Matthias-Christian Ott
Date: Thu Jan 27 2005 - 11:27:26 EST


Chris Wedgwood wrote:

On Thu, Jan 27, 2005 at 05:46:54PM +0000, Matthias-Christian Ott wrote:



How did you fix it?



I suggested:

===== fs/xfs/linux-2.6/xfs_stats.h 1.9 vs edited =====
Index: cw-current/fs/xfs/linux-2.6/xfs_stats.h
===================================================================
--- cw-current.orig/fs/xfs/linux-2.6/xfs_stats.h 2005-01-17 16:03:59.656946818 -0800
+++ cw-current/fs/xfs/linux-2.6/xfs_stats.h 2005-01-17 16:06:50.692361597 -0800
@@ -142,9 +142,9 @@

/* We don't disable preempt, not too worried about poking the
* wrong cpu's stat for now */
-#define XFS_STATS_INC(count) (__get_cpu_var(xfsstats).count++)
-#define XFS_STATS_DEC(count) (__get_cpu_var(xfsstats).count--)
-#define XFS_STATS_ADD(count, inc) (__get_cpu_var(xfsstats).count += (inc))
+#define XFS_STATS_INC(count) (per_cpu(xfsstats, __smp_processor_id()).count++)
+#define XFS_STATS_DEC(count) (per_cpu(xfsstats, __smp_processor_id()).count--)
+#define XFS_STATS_ADD(count, inc) (per_cpu(xfsstats, __smp_processor_id()).count += (inc))

extern void xfs_init_procfs(void);
extern void xfs_cleanup_procfs(void);

but what was checked in was a bit cleaner.



Well calling such a internal function (__function) is not a cleaning coding style but works best :-) .
Combined with the current_cpu() fixes I mentioned, it looks like this:

diff -Nru linux-2.6.11-rc2/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.11-rc2-ott/fs/xfs/linux-2.6/xfs_linux.h
--- linux-2.6.11-rc2/fs/xfs/linux-2.6/xfs_linux.h 2004-12-24 21:35:50.000000000 +0000
+++ linux-2.6.11-rc2-ott/fs/xfs/linux-2.6/xfs_linux.h 2005-01-27 18:13:09.000000000 +0000
@@ -144,7 +144,7 @@
#define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val
#define xfs_rotorstep xfs_params.rotorstep.val

-#define current_cpu() smp_processor_id()
+#define current_cpu() __smp_processor_id()
#define current_pid() (current->pid)
#define current_fsuid(cred) (current->fsuid)
#define current_fsgid(cred) (current->fsgid)
diff -Nru linux-2.6.11-rc2/fs/xfs/linux-2.6/xfs_stats.h linux-2.6.11-rc2-ott/fs/xfs/linux-2.6/xfs_stats.h
--- linux-2.6.11-rc2/fs/xfs/linux-2.6/xfs_stats.h 2004-12-24 21:34:29.000000000 +0000
+++ linux-2.6.11-rc2-ott/fs/xfs/linux-2.6/xfs_stats.h 2005-01-27 18:13:44.000000000 +0000
@@ -142,9 +142,9 @@

/* We don't disable preempt, not too worried about poking the
* wrong cpu's stat for now */
-#define XFS_STATS_INC(count) (__get_cpu_var(xfsstats).count++)
-#define XFS_STATS_DEC(count) (__get_cpu_var(xfsstats).count--)
-#define XFS_STATS_ADD(count, inc) (__get_cpu_var(xfsstats).count += (inc))
+#define XFS_STATS_INC(count) (per_cpu(xfsstats, __smp_processor_id()).count++)
+#define XFS_STATS_DEC(count) (per_cpu(xfsstats, __smp_processor_id()).count--)
+#define XFS_STATS_ADD(count, inc) (per_cpu(xfsstats, __smp_processor_id()).count += (inc))

extern void xfs_init_procfs(void);
extern void xfs_cleanup_procfs(void);

I'll submit it to the mailinglist as a seperate patch, so Linus can apply it to the current Kernel.

Matthias-Christian Ott

--
http://unixforge.org/~matthias-christian-ott/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/