linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: blk_queue_bounce_limits can actually sleep
@ 2008-05-20  3:24 Arjan van de Ven
  2008-05-20 19:29 ` Jens Axboe
  0 siblings, 1 reply; 6+ messages in thread
From: Arjan van de Ven @ 2008-05-20  3:24 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, akpm

From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] block: blk_queue_bounce_limits can actually sleep

blk_queue_bounce_limit can call init_emergency_isa_pool, which
does sleeping allocations... document it as such by adding might_sleep() to the driver

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 block/blk-settings.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 8dd8641..c420a67 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -148,6 +148,7 @@ void blk_queue_bounce_limit(struct request_queue *q, u64 dma_addr)
 	q->bounce_pfn = b_pfn;
 #endif
 	if (dma) {
+		might_sleep();
 		init_emergency_isa_pool();
 		q->bounce_gfp = GFP_NOIO | GFP_DMA;
 		q->bounce_pfn = b_pfn;
-- 
1.5.4.5


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

* Re: [PATCH] block: blk_queue_bounce_limits can actually sleep
  2008-05-20  3:24 [PATCH] block: blk_queue_bounce_limits can actually sleep Arjan van de Ven
@ 2008-05-20 19:29 ` Jens Axboe
  2008-05-20 19:45   ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2008-05-20 19:29 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: linux-kernel, akpm

On Mon, May 19 2008, Arjan van de Ven wrote:
> From: Arjan van de Ven <arjan@linux.intel.com>
> Subject: [PATCH] block: blk_queue_bounce_limits can actually sleep
> 
> blk_queue_bounce_limit can call init_emergency_isa_pool, which
> does sleeping allocations... document it as such by adding
> might_sleep() to the driver

Isn't that superflous, as mempool_create() -> kmalloc(..., __GFP_WAIT)
ends up spewing that warning anyway?

-- 
Jens Axboe


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

* Re: [PATCH] block: blk_queue_bounce_limits can actually sleep
  2008-05-20 19:29 ` Jens Axboe
@ 2008-05-20 19:45   ` Andrew Morton
  2008-05-20 19:58     ` Jens Axboe
  2008-05-20 20:03     ` Arjan van de Ven
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2008-05-20 19:45 UTC (permalink / raw)
  To: Jens Axboe; +Cc: arjan, linux-kernel

On Tue, 20 May 2008 21:29:59 +0200
Jens Axboe <jens.axboe@oracle.com> wrote:

> On Mon, May 19 2008, Arjan van de Ven wrote:
> > From: Arjan van de Ven <arjan@linux.intel.com>
> > Subject: [PATCH] block: blk_queue_bounce_limits can actually sleep
> > 
> > blk_queue_bounce_limit can call init_emergency_isa_pool, which
> > does sleeping allocations... document it as such by adding
> > might_sleep() to the driver
> 
> Isn't that superflous, as mempool_create() -> kmalloc(..., __GFP_WAIT)
> ends up spewing that warning anyway?

It's largely superfluous given the way in which Arjan implemented it.

One situation which we regularly hit is:

foo()
{
	...
	if (some_unlikely_condition())
		do_something_which_sleeps();
	...
}

and then we go and call that code under spinlock and ship it out, when
of course a handful of testers hit the unlikely condition.

The solution to that is to add a might_sleep() _outside_ the test of
some_unlikely_condition().  ie:

--- a/block/blk-settings.c~a
+++ a/block/blk-settings.c
@@ -140,6 +140,8 @@ void blk_queue_bounce_limit(struct reque
 	unsigned long b_pfn = dma_addr >> PAGE_SHIFT;
 	int dma = 0;
 
+	might_sleep();
+
 	q->bounce_gfp = GFP_NOIO;
 #if BITS_PER_LONG == 64
 	/* Assume anything <= 4GB can be handled by IOMMU.
_

but it's all vague and waffly because Arjan forgot to tell us why he's
bothering to patch this code at all???

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

* Re: [PATCH] block: blk_queue_bounce_limits can actually sleep
  2008-05-20 19:45   ` Andrew Morton
@ 2008-05-20 19:58     ` Jens Axboe
  2008-05-20 21:02       ` Arjan van de Ven
  2008-05-20 20:03     ` Arjan van de Ven
  1 sibling, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2008-05-20 19:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: arjan, linux-kernel

On Tue, May 20 2008, Andrew Morton wrote:
> On Tue, 20 May 2008 21:29:59 +0200
> Jens Axboe <jens.axboe@oracle.com> wrote:
> 
> > On Mon, May 19 2008, Arjan van de Ven wrote:
> > > From: Arjan van de Ven <arjan@linux.intel.com>
> > > Subject: [PATCH] block: blk_queue_bounce_limits can actually sleep
> > > 
> > > blk_queue_bounce_limit can call init_emergency_isa_pool, which
> > > does sleeping allocations... document it as such by adding
> > > might_sleep() to the driver
> > 
> > Isn't that superflous, as mempool_create() -> kmalloc(..., __GFP_WAIT)
> > ends up spewing that warning anyway?
> 
> It's largely superfluous given the way in which Arjan implemented it.
> 
> One situation which we regularly hit is:
> 
> foo()
> {
> 	...
> 	if (some_unlikely_condition())
> 		do_something_which_sleeps();
> 	...
> }
> 
> and then we go and call that code under spinlock and ship it out, when
> of course a handful of testers hit the unlikely condition.
> 
> The solution to that is to add a might_sleep() _outside_ the test of
> some_unlikely_condition().  ie:
> 
> --- a/block/blk-settings.c~a
> +++ a/block/blk-settings.c
> @@ -140,6 +140,8 @@ void blk_queue_bounce_limit(struct reque
>  	unsigned long b_pfn = dma_addr >> PAGE_SHIFT;
>  	int dma = 0;
>  
> +	might_sleep();
> +
>  	q->bounce_gfp = GFP_NOIO;
>  #if BITS_PER_LONG == 64
>  	/* Assume anything <= 4GB can be handled by IOMMU.

Yeah, THAT I agree with in general, but it's probably too much here
since most callers will not block and probably do call it under the
queue lock already (just guessing here, didn't audit any callers).

> but it's all vague and waffly because Arjan forgot to tell us why he's
> bothering to patch this code at all???

Probably the math still isn't quite correct, so it ends up setting up
the isa pool for no good reason :-(

-- 
Jens Axboe


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

* Re: [PATCH] block: blk_queue_bounce_limits can actually sleep
  2008-05-20 19:45   ` Andrew Morton
  2008-05-20 19:58     ` Jens Axboe
@ 2008-05-20 20:03     ` Arjan van de Ven
  1 sibling, 0 replies; 6+ messages in thread
From: Arjan van de Ven @ 2008-05-20 20:03 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jens Axboe, linux-kernel

On Tue, 20 May 2008 12:45:56 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Tue, 20 May 2008 21:29:59 +0200
> Jens Axboe <jens.axboe@oracle.com> wrote:
> 
> > On Mon, May 19 2008, Arjan van de Ven wrote:
> > > From: Arjan van de Ven <arjan@linux.intel.com>
> > > Subject: [PATCH] block: blk_queue_bounce_limits can actually sleep
> > > 
> > > blk_queue_bounce_limit can call init_emergency_isa_pool, which
> > > does sleeping allocations... document it as such by adding
> > > might_sleep() to the driver
> > 
> > Isn't that superflous, as mempool_create() -> kmalloc(...,
> > __GFP_WAIT) ends up spewing that warning anyway?
> 
> It's largely superfluous given the way in which Arjan implemented it.
> 
> One situation which we regularly hit is:
> 
> foo()
> {
> 	...
> 	if (some_unlikely_condition())
> 		do_something_which_sleeps();
> 	...
> }
> 
> and then we go and call that code under spinlock and ship it out, when
> of course a handful of testers hit the unlikely condition.
> 
> The solution to that is to add a might_sleep() _outside_ the test of
> some_unlikely_condition().  ie:
> 
> --- a/block/blk-settings.c~a
> +++ a/block/blk-settings.c
> @@ -140,6 +140,8 @@ void blk_queue_bounce_limit(struct reque
>  	unsigned long b_pfn = dma_addr >> PAGE_SHIFT;
>  	int dma = 0;
>  
> +	might_sleep();
> +
>  	q->bounce_gfp = GFP_NOIO;
>  #if BITS_PER_LONG == 64
>  	/* Assume anything <= 4GB can be handled by IOMMU.
> _
> 
> but it's all vague and waffly because Arjan forgot to tell us why he's
> bothering to patch this code at all???

the sata_nv driver calls this from an invalid context ... and spews a
ton of warnings as a result... made me think this is a common mistake
to make.

I'd love to make it do your version instead, but I was afraid it would
trigger too often....


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

* Re: [PATCH] block: blk_queue_bounce_limits can actually sleep
  2008-05-20 19:58     ` Jens Axboe
@ 2008-05-20 21:02       ` Arjan van de Ven
  0 siblings, 0 replies; 6+ messages in thread
From: Arjan van de Ven @ 2008-05-20 21:02 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Andrew Morton, linux-kernel

On Tue, 20 May 2008 21:58:57 +0200
> Yeah, THAT I agree with in genereal, but it's probably too much here
> since most callers will not block and probably do call it under the
> queue lock already (just guessing here, didn't audit any callers).
> 
> > but it's all vague and waffly because Arjan forgot to tell us why
> > he's bothering to patch this code at all???
> 
> Probably the math still isn't quite correct, so it ends up setting up
> the isa pool for no good reason :-(
> 

well either it sleeps or it doesn't.....
if this guy should sleep (and right now it does) we shouldn't call it
from such contexts.
If we do the right thing and allocate the isa pools in a sane context,
it wouldn't ever sleep and the patch isn't needed...

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

end of thread, other threads:[~2008-05-20 21:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-20  3:24 [PATCH] block: blk_queue_bounce_limits can actually sleep Arjan van de Ven
2008-05-20 19:29 ` Jens Axboe
2008-05-20 19:45   ` Andrew Morton
2008-05-20 19:58     ` Jens Axboe
2008-05-20 21:02       ` Arjan van de Ven
2008-05-20 20:03     ` Arjan van de Ven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).