public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib:  Replace calls to __get_free_pages() with __get_dma_pages().
@ 2007-06-05 20:58 Robert P. J. Day
  2007-06-06  0:06 ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: Robert P. J. Day @ 2007-06-05 20:58 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Andrew Morton


Replace a couple calls to __get_free_pages() with the corresponding
calls to __get_dma_pages().

Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>

---

  that's the lot of them.

diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 10c13ad..8fc38dc 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -201,8 +201,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
 	bytes = io_tlb_nslabs << IO_TLB_SHIFT;

 	while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
-		io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
-		                                        order);
+		io_tlb_start = (char *)__get_dma_pages(__GFP_NOWARN, order);
 		if (io_tlb_start)
 			break;
 		order--;
@@ -244,7 +243,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
 	/*
 	 * Get the overflow emergency buffer
 	 */
-	io_tlb_overflow_buffer = (void *)__get_free_pages(GFP_DMA,
+	io_tlb_overflow_buffer = (void *)__get_dma_pages(0,
 	                                          get_order(io_tlb_overflow));
 	if (!io_tlb_overflow_buffer)
 		goto cleanup4;
@@ -449,9 +448,8 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
 	 * instead, or use ZONE_DMA32 (ia64 overloads ZONE_DMA to be a ~32
 	 * bit range instead of a 16MB one).
 	 */
-	flags |= GFP_DMA;

-	ret = (void *)__get_free_pages(flags, order);
+	ret = (void *)__get_dma_pages(flags, order);
 	if (ret && address_needs_mapping(hwdev, virt_to_bus(ret))) {
 		/*
 		 * The allocated memory isn't reachable by the device.
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

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

* Re: [PATCH] lib:  Replace calls to __get_free_pages() with __get_dma_pages().
  2007-06-05 20:58 [PATCH] lib: Replace calls to __get_free_pages() with __get_dma_pages() Robert P. J. Day
@ 2007-06-06  0:06 ` Andrew Morton
  2007-06-06  7:18   ` Robert P. J. Day
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andrew Morton @ 2007-06-06  0:06 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Linux Kernel Mailing List

On Tue, 5 Jun 2007 16:58:57 -0400 (EDT)
"Robert P. J. Day" <rpjday@mindspring.com> wrote:

> Replace a couple calls to __get_free_pages() with the corresponding
> calls to __get_dma_pages().
> 
> Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
> 
> ---
> 
>   that's the lot of them.
> 
> diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> index 10c13ad..8fc38dc 100644
> --- a/lib/swiotlb.c
> +++ b/lib/swiotlb.c
> @@ -201,8 +201,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
>  	bytes = io_tlb_nslabs << IO_TLB_SHIFT;
> 
>  	while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
> -		io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
> -		                                        order);
> +		io_tlb_start = (char *)__get_dma_pages(__GFP_NOWARN, order);

__get_dma_pages() is just pointless obfuscation.  I think it'd be better to
go the other way: open-code the GFP_DMA at all callsites then send
__get_dma_pages() bitbucketwards.


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

* Re: [PATCH] lib:  Replace calls to __get_free_pages() with __get_dma_pages().
  2007-06-06  0:06 ` Andrew Morton
@ 2007-06-06  7:18   ` Robert P. J. Day
  2007-06-06  7:34   ` rae l
  2007-06-06  7:56   ` Robert P. J. Day
  2 siblings, 0 replies; 7+ messages in thread
From: Robert P. J. Day @ 2007-06-06  7:18 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel Mailing List

On Tue, 5 Jun 2007, Andrew Morton wrote:

> On Tue, 5 Jun 2007 16:58:57 -0400 (EDT)
> "Robert P. J. Day" <rpjday@mindspring.com> wrote:
>
> > Replace a couple calls to __get_free_pages() with the corresponding
> > calls to __get_dma_pages().
> >
> > Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
> >
> > ---
> >
> >   that's the lot of them.
> >
> > diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> > index 10c13ad..8fc38dc 100644
> > --- a/lib/swiotlb.c
> > +++ b/lib/swiotlb.c
> > @@ -201,8 +201,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
> >  	bytes = io_tlb_nslabs << IO_TLB_SHIFT;
> >
> >  	while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
> > -		io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
> > -		                                        order);
> > +		io_tlb_start = (char *)__get_dma_pages(__GFP_NOWARN, order);
>
> __get_dma_pages() is just pointless obfuscation.  I think it'd be better to
> go the other way: open-code the GFP_DMA at all callsites then send
> __get_dma_pages() bitbucketwards.

i have no objection to that.  it just seemed silly to have some calls
using one form and some using the other.

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

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

* Re: [PATCH] lib: Replace calls to __get_free_pages() with __get_dma_pages().
  2007-06-06  0:06 ` Andrew Morton
  2007-06-06  7:18   ` Robert P. J. Day
@ 2007-06-06  7:34   ` rae l
  2007-06-06  7:56   ` Robert P. J. Day
  2 siblings, 0 replies; 7+ messages in thread
From: rae l @ 2007-06-06  7:34 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Robert P. J. Day, Linux Kernel Mailing List

On 6/6/07, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Tue, 5 Jun 2007 16:58:57 -0400 (EDT)
> "Robert P. J. Day" <rpjday@mindspring.com> wrote:
>
> > Replace a couple calls to __get_free_pages() with the corresponding
> > calls to __get_dma_pages().
> >
> > Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
> >
> > ---
> >
> >   that's the lot of them.
> >
> > diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> > index 10c13ad..8fc38dc 100644
> > --- a/lib/swiotlb.c
> > +++ b/lib/swiotlb.c
> > @@ -201,8 +201,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
> >       bytes = io_tlb_nslabs << IO_TLB_SHIFT;
> >
> >       while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
> > -             io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
> > -                                                     order);
> > +             io_tlb_start = (char *)__get_dma_pages(__GFP_NOWARN, order);
>
> __get_dma_pages() is just pointless obfuscation.  I think it'd be better to
> go the other way: open-code the GFP_DMA at all callsites then send
> __get_dma_pages() bitbucketwards.
thus __get_free_pages(GFP_DMA ...) can do better, I don't think
__get_dma_pages is needed.

-- 
Denis Cheng
Linux Application Developer

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

* Re: [PATCH] lib:  Replace calls to __get_free_pages() with __get_dma_pages().
  2007-06-06  0:06 ` Andrew Morton
  2007-06-06  7:18   ` Robert P. J. Day
  2007-06-06  7:34   ` rae l
@ 2007-06-06  7:56   ` Robert P. J. Day
  2007-06-06  8:24     ` Peter Zijlstra
  2 siblings, 1 reply; 7+ messages in thread
From: Robert P. J. Day @ 2007-06-06  7:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel Mailing List

On Tue, 5 Jun 2007, Andrew Morton wrote:

> On Tue, 5 Jun 2007 16:58:57 -0400 (EDT)
> "Robert P. J. Day" <rpjday@mindspring.com> wrote:
>
> > Replace a couple calls to __get_free_pages() with the corresponding
> > calls to __get_dma_pages().
> >
> > Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
> >
> > ---
> >
> >   that's the lot of them.
> >
> > diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> > index 10c13ad..8fc38dc 100644
> > --- a/lib/swiotlb.c
> > +++ b/lib/swiotlb.c
> > @@ -201,8 +201,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
> >  	bytes = io_tlb_nslabs << IO_TLB_SHIFT;
> >
> >  	while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
> > -		io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
> > -		                                        order);
> > +		io_tlb_start = (char *)__get_dma_pages(__GFP_NOWARN, order);
>
> __get_dma_pages() is just pointless obfuscation.  I think it'd be better to
> go the other way: open-code the GFP_DMA at all callsites then send
> __get_dma_pages() bitbucketwards.

ok, it's easy enough to put together a patch that rids the tree of the
superfluous __get_dma_pages() call.  but in converting back to a call
to __get_free_pages(), which of the two zone modifiers should be added
-- "GFP_DMA" or "__GFP_DMA" -- since they're currently defined
equivalently in include/linux/gfp.h.  and there's definitely a mixture
of usage in the tree at the moment:

$ grep -r "get_free.*GFP_DMA" *
arch/s390/kernel/smp.c:                 __get_free_pages(GFP_KERNEL | GFP_DMA,
drivers/net/arm/ep93xx_eth.c:           page = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
drivers/net/arm/ep93xx_eth.c:           page = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
drivers/s390/net/qeth_main.c:                   ptr = (void *) __get_free_page(GFP_KERNEL|GFP_DMA);
drivers/s390/net/claw.c:                        (void *)__get_free_pages(__GFP_DMA,
drivers/s390/net/claw.c:                        (void *)__get_free_pages(__GFP_DMA,
drivers/s390/net/claw.c:                   p_buff=(void *)__get_free_pages(__GFP_DMA,
drivers/s390/net/claw.c:                        (void *)__get_free_pages(__GFP_DMA,
drivers/s390/net/claw.c:                        p_buff = (void *)__get_free_pages(__GFP_DMA,
drivers/s390/block/dasd.c:      device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1);
drivers/s390/char/tty3270.c:                    __get_free_pages(GFP_KERNEL|GFP_DMA, 0);
drivers/s390/char/sclp_cpi.c:   sccb = (struct cpi_sccb *) __get_free_page(GFP_KERNEL | GFP_DMA);
drivers/s390/cio/cmf.c:         mem = (void*)__get_free_pages(GFP_KERNEL | GFP_DMA,
include/linux/gfp.h:            __get_free_pages((gfp_mask) | GFP_DMA,(order))
lib/swiotlb.c:          io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
lib/swiotlb.c:  io_tlb_overflow_buffer = (void *)__get_free_pages(GFP_DMA,

  i'm guessing "GFP_DMA" would be the right choice, which means that,
for consistency, the calls using __GFP_DMA should be switched over as
well.  guidance, anyone?

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

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

* Re: [PATCH] lib:  Replace calls to __get_free_pages() with __get_dma_pages().
  2007-06-06  7:56   ` Robert P. J. Day
@ 2007-06-06  8:24     ` Peter Zijlstra
  2007-06-07  7:47       ` Robert P. J. Day
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Zijlstra @ 2007-06-06  8:24 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Andrew Morton, Linux Kernel Mailing List

On Wed, 2007-06-06 at 03:56 -0400, Robert P. J. Day wrote:
> On Tue, 5 Jun 2007, Andrew Morton wrote:
> 
> > On Tue, 5 Jun 2007 16:58:57 -0400 (EDT)
> > "Robert P. J. Day" <rpjday@mindspring.com> wrote:
> >
> > > Replace a couple calls to __get_free_pages() with the corresponding
> > > calls to __get_dma_pages().
> > >
> > > Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
> > >
> > > ---
> > >
> > >   that's the lot of them.
> > >
> > > diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> > > index 10c13ad..8fc38dc 100644
> > > --- a/lib/swiotlb.c
> > > +++ b/lib/swiotlb.c
> > > @@ -201,8 +201,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
> > >  	bytes = io_tlb_nslabs << IO_TLB_SHIFT;
> > >
> > >  	while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
> > > -		io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
> > > -		                                        order);
> > > +		io_tlb_start = (char *)__get_dma_pages(__GFP_NOWARN, order);
> >
> > __get_dma_pages() is just pointless obfuscation.  I think it'd be better to
> > go the other way: open-code the GFP_DMA at all callsites then send
> > __get_dma_pages() bitbucketwards.
> 
> ok, it's easy enough to put together a patch that rids the tree of the
> superfluous __get_dma_pages() call.  but in converting back to a call
> to __get_free_pages(), which of the two zone modifiers should be added
> -- "GFP_DMA" or "__GFP_DMA" -- since they're currently defined
> equivalently in include/linux/gfp.h.  and there's definitely a mixture
> of usage in the tree at the moment:
> 
> $ grep -r "get_free.*GFP_DMA" *
> arch/s390/kernel/smp.c:                 __get_free_pages(GFP_KERNEL | GFP_DMA,
> drivers/net/arm/ep93xx_eth.c:           page = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
> drivers/net/arm/ep93xx_eth.c:           page = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
> drivers/s390/net/qeth_main.c:                   ptr = (void *) __get_free_page(GFP_KERNEL|GFP_DMA);
> drivers/s390/net/claw.c:                        (void *)__get_free_pages(__GFP_DMA,
> drivers/s390/net/claw.c:                        (void *)__get_free_pages(__GFP_DMA,
> drivers/s390/net/claw.c:                   p_buff=(void *)__get_free_pages(__GFP_DMA,
> drivers/s390/net/claw.c:                        (void *)__get_free_pages(__GFP_DMA,
> drivers/s390/net/claw.c:                        p_buff = (void *)__get_free_pages(__GFP_DMA,
> drivers/s390/block/dasd.c:      device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1);
> drivers/s390/char/tty3270.c:                    __get_free_pages(GFP_KERNEL|GFP_DMA, 0);
> drivers/s390/char/sclp_cpi.c:   sccb = (struct cpi_sccb *) __get_free_page(GFP_KERNEL | GFP_DMA);
> drivers/s390/cio/cmf.c:         mem = (void*)__get_free_pages(GFP_KERNEL | GFP_DMA,
> include/linux/gfp.h:            __get_free_pages((gfp_mask) | GFP_DMA,(order))
> lib/swiotlb.c:          io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
> lib/swiotlb.c:  io_tlb_overflow_buffer = (void *)__get_free_pages(GFP_DMA,
> 
>   i'm guessing "GFP_DMA" would be the right choice, which means that,
> for consistency, the calls using __GFP_DMA should be switched over as
> well.  guidance, anyone?

FWIW I prefer:

  GFP_KERNEL | __GFP_DMA
  GFP_ATOMIC | __GFP_DMA

and

  GFP_DMA

That is, when used as a modifier use __GFP_, when used as a class use
GFP_.


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

* Re: [PATCH] lib:  Replace calls to __get_free_pages() with __get_dma_pages().
  2007-06-06  8:24     ` Peter Zijlstra
@ 2007-06-07  7:47       ` Robert P. J. Day
  0 siblings, 0 replies; 7+ messages in thread
From: Robert P. J. Day @ 2007-06-07  7:47 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Andrew Morton, Linux Kernel Mailing List

On Wed, 6 Jun 2007, Peter Zijlstra wrote:
...
> FWIW I prefer:
>
>   GFP_KERNEL | __GFP_DMA
>   GFP_ATOMIC | __GFP_DMA
>
> and
>
>   GFP_DMA
>
> That is, when used as a modifier use __GFP_, when used as a class
> use GFP_.

that sounds eminently reasonable, i'll go with that.

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

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

end of thread, other threads:[~2007-06-07  8:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-05 20:58 [PATCH] lib: Replace calls to __get_free_pages() with __get_dma_pages() Robert P. J. Day
2007-06-06  0:06 ` Andrew Morton
2007-06-06  7:18   ` Robert P. J. Day
2007-06-06  7:34   ` rae l
2007-06-06  7:56   ` Robert P. J. Day
2007-06-06  8:24     ` Peter Zijlstra
2007-06-07  7:47       ` Robert P. J. Day

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox