All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] block: don't disable interrupts during kmap_atomic()
@ 2018-05-04 14:32 Sebastian Andrzej Siewior
  2018-05-04 14:32 ` [PATCH 2/3] block: Remove redundant WARN_ON() Sebastian Andrzej Siewior
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-05-04 14:32 UTC (permalink / raw)
  To: linux-block; +Cc: Thomas Gleixner, Jens Axboe, Sebastian Andrzej Siewior

bounce_copy_vec() disables interrupts around kmap_atomic(). This is a
leftover from the old kmap_atomic() implementation which relied on fixed
mapping slots, so the caller had to make sure that the same slot could not
be reused from an interrupting context.

kmap_atomic() was changed to dynamic slots long ago and commit 1ec9c5ddc17a
("include/linux/highmem.h: remove the second argument of k[un]map_atomic()")
removed the slot assignements, but the callers were not checked for now
redundant interrupt disabling.

Remove the conditional interrupt disable.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 block/bounce.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/block/bounce.c b/block/bounce.c
index dd0b93f2a871..fea9c8146d82 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -63,14 +63,11 @@ __initcall(init_emergency_pool);
  */
 static void bounce_copy_vec(struct bio_vec *to, unsigned char *vfrom)
 {
-	unsigned long flags;
 	unsigned char *vto;
=20
-	local_irq_save(flags);
 	vto =3D kmap_atomic(to->bv_page);
 	memcpy(vto + to->bv_offset, vfrom, to->bv_len);
 	kunmap_atomic(vto);
-	local_irq_restore(flags);
 }
=20
 #else /* CONFIG_HIGHMEM */
--=20
2.17.0

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

* [PATCH 2/3] block: Remove redundant WARN_ON()
  2018-05-04 14:32 [PATCH 1/3] block: don't disable interrupts during kmap_atomic() Sebastian Andrzej Siewior
@ 2018-05-04 14:32 ` Sebastian Andrzej Siewior
  2018-05-04 14:32 ` [PATCH 3/3] block: Shorten interrupt disabled regions Sebastian Andrzej Siewior
  2018-05-04 14:36 ` [PATCH 1/3] block: don't disable interrupts during kmap_atomic() Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-05-04 14:32 UTC (permalink / raw)
  To: linux-block
  Cc: Thomas Gleixner, Jens Axboe, Anna-Maria Gleixner,
	Sebastian Andrzej Siewior

From: Anna-Maria Gleixner <anna-maria@linutronix.de>

Commit 2fff8a924d4c ("block: Check locking assumptions at runtime") added a
lockdep_assert_held(q->queue_lock) which makes the WARN_ON() redundant
because lockdep will detect and warn about context violations.

The unconditional WARN_ON() does not provide real additional value, so it
can be removed.

Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 block/blk-core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 85909b431eb0..a3caccaa7d1f 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -360,7 +360,6 @@ EXPORT_SYMBOL(blk_start_queue_async);
 void blk_start_queue(struct request_queue *q)
 {
 	lockdep_assert_held(q->queue_lock);
-	WARN_ON(!in_interrupt() && !irqs_disabled());
 	WARN_ON_ONCE(q->mq_ops);
=20
 	queue_flag_clear(QUEUE_FLAG_STOPPED, q);
--=20
2.17.0

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

* [PATCH 3/3] block: Shorten interrupt disabled regions
  2018-05-04 14:32 [PATCH 1/3] block: don't disable interrupts during kmap_atomic() Sebastian Andrzej Siewior
  2018-05-04 14:32 ` [PATCH 2/3] block: Remove redundant WARN_ON() Sebastian Andrzej Siewior
@ 2018-05-04 14:32 ` Sebastian Andrzej Siewior
  2018-05-04 14:36 ` [PATCH 1/3] block: don't disable interrupts during kmap_atomic() Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-05-04 14:32 UTC (permalink / raw)
  To: linux-block
  Cc: Thomas Gleixner, Jens Axboe, Peter Zijlstra, Tejun Heo,
	Linus Torvalds, Sebastian Andrzej Siewior

From: Thomas Gleixner <tglx@linutronix.de>

Commit 9c40cef2b799 ("sched: Move blk_schedule_flush_plug() out of
__schedule()") moved the blk_schedule_flush_plug() call out of the
interrupt/preempt disabled region in the scheduler. This allows to replace
local_irq_save/restore(flags) by local_irq_disable/enable() in
blk_flush_plug_list().

But it makes more sense to disable interrupts explicitly when the request
queue is locked end reenable them when the request to is unlocked. This
shortens the interrupt disabled section which is important when the plug
list contains requests for more than one queue. The comment which claims
that disabling interrupts around the loop is misleading as the called
functions can reenable interrupts unconditionally anyway and obfuscates the
scope badly:

 local_irq_save(flags);
   spin_lock(q->queue_lock);
   ...
   queue_unplugged(q...);
     scsi_request_fn();
       spin_unlock_irq(q->queue_lock);

-------------------^^^ ????

       spin_lock_irq(q->queue_lock);
     spin_unlock(q->queue_lock);
 local_irq_restore(flags);

Aside of that the detached interrupt disabling is a constant pain for
PREEMPT_RT as it requires patching and special casing when RT is enabled
while with the spin_*_irq() variants this happens automatically.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20110622174919.025446432@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 block/blk-core.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index a3caccaa7d1f..0573f9226c2d 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3629,7 +3629,7 @@ static void queue_unplugged(struct request_queue *q, =
unsigned int depth,
 		blk_run_queue_async(q);
 	else
 		__blk_run_queue(q);
-	spin_unlock(q->queue_lock);
+	spin_unlock_irq(q->queue_lock);
 }
=20
 static void flush_plug_callbacks(struct blk_plug *plug, bool from_schedule)
@@ -3677,7 +3677,6 @@ EXPORT_SYMBOL(blk_check_plugged);
 void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
 {
 	struct request_queue *q;
-	unsigned long flags;
 	struct request *rq;
 	LIST_HEAD(list);
 	unsigned int depth;
@@ -3697,11 +3696,6 @@ void blk_flush_plug_list(struct blk_plug *plug, bool=
 from_schedule)
 	q =3D NULL;
 	depth =3D 0;
=20
-	/*
-	 * Save and disable interrupts here, to avoid doing it for every
-	 * queue lock we have to take.
-	 */
-	local_irq_save(flags);
 	while (!list_empty(&list)) {
 		rq =3D list_entry_rq(list.next);
 		list_del_init(&rq->queuelist);
@@ -3714,7 +3708,7 @@ void blk_flush_plug_list(struct blk_plug *plug, bool =
from_schedule)
 				queue_unplugged(q, depth, from_schedule);
 			q =3D rq->q;
 			depth =3D 0;
-			spin_lock(q->queue_lock);
+			spin_lock_irq(q->queue_lock);
 		}
=20
 		/*
@@ -3741,8 +3735,6 @@ void blk_flush_plug_list(struct blk_plug *plug, bool =
from_schedule)
 	 */
 	if (q)
 		queue_unplugged(q, depth, from_schedule);
-
-	local_irq_restore(flags);
 }
=20
 void blk_finish_plug(struct blk_plug *plug)
--=20
2.17.0

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

* Re: [PATCH 1/3] block: don't disable interrupts during kmap_atomic()
  2018-05-04 14:32 [PATCH 1/3] block: don't disable interrupts during kmap_atomic() Sebastian Andrzej Siewior
  2018-05-04 14:32 ` [PATCH 2/3] block: Remove redundant WARN_ON() Sebastian Andrzej Siewior
  2018-05-04 14:32 ` [PATCH 3/3] block: Shorten interrupt disabled regions Sebastian Andrzej Siewior
@ 2018-05-04 14:36 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2018-05-04 14:36 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, linux-block; +Cc: Thomas Gleixner

On 5/4/18 8:32 AM, Sebastian Andrzej Siewior wrote:
> bounce_copy_vec() disables interrupts around kmap_atomic(). This is a
> leftover from the old kmap_atomic() implementation which relied on fixed
> mapping slots, so the caller had to make sure that the same slot could not
> be reused from an interrupting context.
> 
> kmap_atomic() was changed to dynamic slots long ago and commit 1ec9c5ddc17a
> ("include/linux/highmem.h: remove the second argument of k[un]map_atomic()")
> removed the slot assignements, but the callers were not checked for now
> redundant interrupt disabling.
> 
> Remove the conditional interrupt disable.

All three patches look fine to me, I'll queue them up for 4.18. In
the future, please include a cover letter for block patches when
sending > 1 patch. Makes it easier to reply to the series as a whole.

-- 
Jens Axboe

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

end of thread, other threads:[~2018-05-04 14:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 14:32 [PATCH 1/3] block: don't disable interrupts during kmap_atomic() Sebastian Andrzej Siewior
2018-05-04 14:32 ` [PATCH 2/3] block: Remove redundant WARN_ON() Sebastian Andrzej Siewior
2018-05-04 14:32 ` [PATCH 3/3] block: Shorten interrupt disabled regions Sebastian Andrzej Siewior
2018-05-04 14:36 ` [PATCH 1/3] block: don't disable interrupts during kmap_atomic() Jens Axboe

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.