All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-verity: use softirq context only when !need_resched()
@ 2025-04-22 20:22 Eric Biggers
  2025-04-23 11:33 ` Mikulas Patocka
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2025-04-22 20:22 UTC (permalink / raw)
  To: dm-devel, Alasdair Kergon, Mike Snitzer, Mikulas Patocka
  Cc: LongPing Wei, Eran Messeri, Sami Tolvanen

From: Eric Biggers <ebiggers@google.com>

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>
---
 drivers/md/dm-verity-target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index 3c427f18a04b3..4de2c226ac9db 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -680,11 +680,12 @@ 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)
 {
 	struct dm_verity_io *io = bio->bi_private;

base-commit: a33b5a08cbbdd7aadff95f40cbb45ab86841679e
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dm-verity: use softirq context only when !need_resched()
  2025-04-22 20:22 [PATCH] dm-verity: use softirq context only when !need_resched() Eric Biggers
@ 2025-04-23 11:33 ` Mikulas Patocka
  0 siblings, 0 replies; 2+ messages in thread
From: Mikulas Patocka @ 2025-04-23 11:33 UTC (permalink / raw)
  To: Eric Biggers
  Cc: dm-devel, Alasdair Kergon, Mike Snitzer, LongPing Wei,
	Eran Messeri, Sami Tolvanen

OK, Accepted.

Mikulas



On Tue, 22 Apr 2025, Eric Biggers wrote:

> From: Eric Biggers <ebiggers@google.com>
> 
> 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>
> ---
>  drivers/md/dm-verity-target.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
> index 3c427f18a04b3..4de2c226ac9db 100644
> --- a/drivers/md/dm-verity-target.c
> +++ b/drivers/md/dm-verity-target.c
> @@ -680,11 +680,12 @@ 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)
>  {
>  	struct dm_verity_io *io = bio->bi_private;
> 
> base-commit: a33b5a08cbbdd7aadff95f40cbb45ab86841679e
> -- 
> 2.49.0
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-23 11:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22 20:22 [PATCH] dm-verity: use softirq context only when !need_resched() Eric Biggers
2025-04-23 11:33 ` Mikulas Patocka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.