]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dm-verity: use softirq context only when !need_resched()
authorEric Biggers <ebiggers@google.com>
Tue, 22 Apr 2025 20:22:05 +0000 (13:22 -0700)
committerMikulas Patocka <mpatocka@redhat.com>
Sun, 4 May 2025 09:35:05 +0000 (11:35 +0200)
Further limit verification in softirq (a.k.a. BH) context to cases where
rescheduling of the interrupted task is not pending.

This helps prevent the CPU from spending too long in softirq context.

Note that handle_softirqs() in kernel/softirq.c already stops running
softirqs in this same case.  However, that check is too coarse-grained,
since many I/O requests can be processed in a single BLOCK_SOFTIRQ.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-verity-target.c

index 3c427f18a04b336b95e895209c9fad39c1407cb9..4de2c226ac9db7805ade7c894d087ac419445f50 100644 (file)
@@ -682,7 +682,8 @@ static void verity_bh_work(struct work_struct *w)
 static inline bool verity_use_bh(unsigned int bytes, unsigned short ioprio)
 {
        return ioprio <= IOPRIO_CLASS_IDLE &&
-               bytes <= READ_ONCE(dm_verity_use_bh_bytes[ioprio]);
+               bytes <= READ_ONCE(dm_verity_use_bh_bytes[ioprio]) &&
+               !need_resched();
 }
 
 static void verity_end_io(struct bio *bio)