All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] block: nr_sects_write(): Disable preemption on seqcount write" failed to apply to 5.4-stable tree
@ 2020-06-19 13:43 gregkh
  2020-06-23  0:35 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2020-06-19 13:43 UTC (permalink / raw)
  To: a.darwish, axboe, bigeasy, stable; +Cc: stable


The patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 15b81ce5abdc4b502aa31dff2d415b79d2349d2f Mon Sep 17 00:00:00 2001
From: "Ahmed S. Darwish" <a.darwish@linutronix.de>
Date: Wed, 3 Jun 2020 16:49:48 +0200
Subject: [PATCH] block: nr_sects_write(): Disable preemption on seqcount write

For optimized block readers not holding a mutex, the "number of sectors"
64-bit value is protected from tearing on 32-bit architectures by a
sequence counter.

Disable preemption before entering that sequence counter's write side
critical section. Otherwise, the read side can preempt the write side
section and spin for the entire scheduler tick. If the reader belongs to
a real-time scheduling class, it can spin forever and the kernel will
livelock.

Fixes: c83f6bf98dc1 ("block: add partition resize function to blkpg ioctl")
Cc: <stable@vger.kernel.org>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

diff --git a/block/blk.h b/block/blk.h
index aa16e524dc35..b5d1f0fc6547 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -420,9 +420,11 @@ static inline sector_t part_nr_sects_read(struct hd_struct *part)
 static inline void part_nr_sects_write(struct hd_struct *part, sector_t size)
 {
 #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
+	preempt_disable();
 	write_seqcount_begin(&part->nr_sects_seq);
 	part->nr_sects = size;
 	write_seqcount_end(&part->nr_sects_seq);
+	preempt_enable();
 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
 	preempt_disable();
 	part->nr_sects = size;


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

* Re: FAILED: patch "[PATCH] block: nr_sects_write(): Disable preemption on seqcount write" failed to apply to 5.4-stable tree
  2020-06-19 13:43 FAILED: patch "[PATCH] block: nr_sects_write(): Disable preemption on seqcount write" failed to apply to 5.4-stable tree gregkh
@ 2020-06-23  0:35 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2020-06-23  0:35 UTC (permalink / raw)
  To: gregkh; +Cc: a.darwish, axboe, bigeasy, stable

On Fri, Jun 19, 2020 at 03:43:39PM +0200, gregkh@linuxfoundation.org wrote:
>
>The patch below does not apply to the 5.4-stable tree.
>If someone wants it applied there, or to any other stable or longterm
>tree, then please email the backport, including the original git commit
>id to <stable@vger.kernel.org>.
>
>thanks,
>
>greg k-h
>
>------------------ original commit in Linus's tree ------------------
>
>From 15b81ce5abdc4b502aa31dff2d415b79d2349d2f Mon Sep 17 00:00:00 2001
>From: "Ahmed S. Darwish" <a.darwish@linutronix.de>
>Date: Wed, 3 Jun 2020 16:49:48 +0200
>Subject: [PATCH] block: nr_sects_write(): Disable preemption on seqcount write
>
>For optimized block readers not holding a mutex, the "number of sectors"
>64-bit value is protected from tearing on 32-bit architectures by a
>sequence counter.
>
>Disable preemption before entering that sequence counter's write side
>critical section. Otherwise, the read side can preempt the write side
>section and spin for the entire scheduler tick. If the reader belongs to
>a real-time scheduling class, it can spin forever and the kernel will
>livelock.
>
>Fixes: c83f6bf98dc1 ("block: add partition resize function to blkpg ioctl")
>Cc: <stable@vger.kernel.org>
>Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
>Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>Signed-off-by: Jens Axboe <axboe@kernel.dk>

part_nr_sects_write() was in include/linux/genhd.h before 581e26004a09
("block: move block layer internals out of include/linux/genhd.h").
Fixed and queued for all branched.

-- 
Thanks,
Sasha

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

end of thread, other threads:[~2020-06-23  0:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19 13:43 FAILED: patch "[PATCH] block: nr_sects_write(): Disable preemption on seqcount write" failed to apply to 5.4-stable tree gregkh
2020-06-23  0:35 ` Sasha Levin

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.