xfs: check that per-cpu inodegc workers actually run on that cpu
authorDarrick J. Wong <djwong@kernel.org>
Mon, 1 May 2023 23:16:12 +0000 (09:16 +1000)
committerDave Chinner <dchinner@redhat.com>
Mon, 1 May 2023 23:16:12 +0000 (09:16 +1000)
Now that we've allegedly worked out the problem of the per-cpu inodegc
workers being scheduled on the wrong cpu, let's put in a debugging knob
to let us know if a worker ever gets mis-scheduled again.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_icache.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_super.c

index 58712113d5d6c37897e9448384af03aea16d4c3c..4b63c065ef19e64a78cb2aee55410724ddc5c09a 100644 (file)
@@ -1856,6 +1856,8 @@ xfs_inodegc_worker(
        struct xfs_inode        *ip, *n;
        unsigned int            nofs_flag;
 
+       ASSERT(gc->cpu == smp_processor_id());
+
        WRITE_ONCE(gc->items, 0);
 
        if (!node)
index f3269c0626f0576b669d8881572f1e45ba5cfb80..aaaf5ec13492d2f0b09ae9165be574ba20d80bfd 100644 (file)
@@ -66,6 +66,9 @@ struct xfs_inodegc {
        /* approximate count of inodes in the list */
        unsigned int            items;
        unsigned int            shrinker_hits;
+#if defined(DEBUG) || defined(XFS_WARN)
+       unsigned int            cpu;
+#endif
 };
 
 /*
index 4d2e87462ac4a19499ad45ea17f2246379beb577..7e706255f165027c2c6e161f2878673ac89dad23 100644 (file)
@@ -1095,6 +1095,9 @@ xfs_inodegc_init_percpu(
 
        for_each_possible_cpu(cpu) {
                gc = per_cpu_ptr(mp->m_inodegc, cpu);
+#if defined(DEBUG) || defined(XFS_WARN)
+               gc->cpu = cpu;
+#endif
                init_llist_head(&gc->list);
                gc->items = 0;
                INIT_DELAYED_WORK(&gc->work, xfs_inodegc_worker);