Fix preemptible warning in aggsum_add()
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 7 Jun 2018 22:55:11 +0000 (15:55 -0700)
committerGitHub <noreply@github.com>
Thu, 7 Jun 2018 22:55:11 +0000 (15:55 -0700)
In the new aggsum counters the CPU_SEQID macro should be surrounded by
kpreempt_disable)() and kpreempt_enable() calls to prevent a Linux
kernel BUG warning.  The addsum_add() function use the cpuid to
minimize lock contention when selecting a bucket, after selection
the bucket is protected by a mutex and it is safe to reschedule the
process to a different processor at any time.

Reviewed-by: Matthew Thode <prometheanfire@gentoo.org>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #7609
Closes #7610

module/zfs/aggsum.c

index 171d0ff55dc5cd73881c278234c7c73c1de128ca..8d310e0043fe4b85a9cf6176a2decb2efd93a26c 100644 (file)
@@ -183,8 +183,11 @@ aggsum_borrow(aggsum_t *as, int64_t delta, struct aggsum_bucket *asb)
 void
 aggsum_add(aggsum_t *as, int64_t delta)
 {
-       struct aggsum_bucket *asb =
-           &as->as_buckets[CPU_SEQID % as->as_numbuckets];
+       struct aggsum_bucket *asb;
+
+       kpreempt_disable();
+       asb = &as->as_buckets[CPU_SEQID % as->as_numbuckets];
+       kpreempt_enable();
 
        for (;;) {
                mutex_enter(&asb->asc_lock);