jfs: wrap statistics counters with data_race()
PATCH 1/1 jfs: wrap statistics counters with data_race()
JFS uses global statistics counters (lmStat, mpStat, xtStat, TxStat) that are incremented from multiple contexts (writeback workqueue, IO kthread, syscall paths) without any lock. The INCREMENT()/DECREMENT()/ HIGHWATERMARK() macros expand to plain C read-modify-write operations:
#define INCREMENT(x) ((x)++)
These counters are purely informational and only read via /proc for diagnostic purposes. A concurrent lost increment is acceptable for approximate statistics. However, the plain C accesses are formally undefined under LKMM.
Wrap the statistics macro definitions with data_race() to document that these races are intentional and benign. Also annotate the proc_show read sides for completeness.
Signed-off-by Cen Zhang <[email protected]>
--- fs/jfs/jfs_debug.h | 8 ++++---- fs/jfs/jfs_logmgr.c | 10 +++++----- fs/jfs/jfs_metapage.c | 6 +++--- fs/jfs/jfs_txnmgr.c | 18 +++++++++--------- fs/jfs/jfs_xtree.c | 6 +++--- 5 files changed, 24 insertions(+), 24 deletions(-)
fs/jfs/jfs_debug.h +4 -4
@@ -97,13 +97,13 @@ int jfs_txstats_proc_show(struct seq_file *m, void *v);int jfs_mpstat_proc_show (struct seq_file *m,void *v);int jfs_xtstat_proc_show (struct seq_file *m,void *v); -#define INCREMENT (x) ((x)++) -#define DECREMENT (x) ((x)--) -#define HIGHWATERMARK (x,y) ((x) = max((x), (y))) +#define INCREMENT (x) (data_race((x)++)) +#define DECREMENT (x) (data_race((x)--)) +#define HIGHWATERMARK (x, y) (data_race((x) = max(data_race(x), (y))))#else #define INCREMENT (x)#define DECREMENT (x) -#define HIGHWATERMARK (x,y) +#define HIGHWATERMARK (x, y)#endif /* CONFIG_JFS_STATISTICS */ #endif /* _H_JFS_DEBUG */
fs/jfs/jfs_logmgr.c +5 -5
@@ -2481,11 +2481,11 @@ int jfs_lmstats_proc_show(struct seq_file *m, void *v)"writes completed = %d\n" "full pages submitted = %d\n" "partial pages submitted = %d\n" , - lmStat.commit, - lmStat.submitted, - lmStat.pagedone, - lmStat.full_page, - lmStat.partial_page); +data_race (lmStat.commit), +data_race (lmStat.submitted), +data_race (lmStat.pagedone), +data_race (lmStat.full_page), + data_race(lmStat.partial_page)); return 0; }#endif /* CONFIG_JFS_STATISTICS */
fs/jfs/jfs_metapage.c +3 -3
@@ -944,9 +944,9 @@ int jfs_mpstat_proc_show(struct seq_file *m, void *v)"page allocations = %d\n" "page frees = %d\n" "lock waits = %d\n" , - mpStat.pagealloc, - mpStat.pagefree, - mpStat.lockwait); +data_race (mpStat.pagealloc), +data_race (mpStat.pagefree), + data_race(mpStat.lockwait)); return 0; }#endif
fs/jfs/jfs_txnmgr.c +9 -9
@@ -3006,15 +3006,15 @@ int jfs_txstats_proc_show(struct seq_file *m, void *v)"txBeginAnon blocked by tlocks low = %d\n" "calls to txLockAlloc = %d\n" "tLockAlloc blocked by no free lock = %d\n" , - TxStat.txBegin, - TxStat.txBegin_barrier, - TxStat.txBegin_lockslow, - TxStat.txBegin_freetid, - TxStat.txBeginAnon, - TxStat.txBeginAnon_barrier, - TxStat.txBeginAnon_lockslow, - TxStat.txLockAlloc, - TxStat.txLockAlloc_freelock); +data_race (TxStat.txBegin), +data_race (TxStat.txBegin_barrier), +data_race (TxStat.txBegin_lockslow), +data_race (TxStat.txBegin_freetid), +data_race (TxStat.txBeginAnon), +data_race (TxStat.txBeginAnon_barrier), +data_race (TxStat.txBeginAnon_lockslow), +data_race (TxStat.txLockAlloc), + data_race(TxStat.txLockAlloc_freelock)); return 0; }#endif
fs/jfs/jfs_xtree.c +3 -3
@@ -2922,9 +2922,9 @@ int jfs_xtstat_proc_show(struct seq_file *m, void *v)"searches = %d\n" "fast searches = %d\n" "splits = %d\n" , - xtStat.search, - xtStat.fastSearch, - xtStat.split); +data_race (xtStat.search), +data_race (xtStat.fastSearch), + data_race(xtStat.split)); return 0; }#endif
Signature · 1 line
2.34.1