linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan.kim@gmail.com>
To: Tejun Heo <tj@kernel.org>
Cc: Christoph Lameter <cl@linux-foundation.org>,
	Mel Gorman <mel@csn.ul.ie>,
	Andrew Morton <akpm@linux-foundation.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Bob Liu <lliubbo@gmail.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 2/6] change alloc function in pcpu_alloc_pages
Date: Mon, 19 Apr 2010 09:03:17 +0900	[thread overview]
Message-ID: <j2h28c262361004181703gd3f4bc19r6d00451e01b779a7@mail.gmail.com> (raw)
In-Reply-To: <4BCB780C.1030001@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 3916 bytes --]

Hi, Tejun.

On Mon, Apr 19, 2010 at 6:22 AM, Tejun Heo <tj@kernel.org> wrote:
> On 04/19/2010 12:54 AM, Minchan Kim wrote:
>>> alloc_pages is the same as alloc_pages_any_node so why have it?
>>
>> I don't want to force using '_node' postfix on UMA users.
>> Maybe they don't care getting page from any node and event don't need to
>> know about _NODE_.
>
> Yeah, then, remove alloc_pages_any_node().  I can't really see the
> point of any_/exact_node.  alloc_pages() and alloc_pages_node() are
> fine and in line with other functions.  Why change it?
>
>>> Why remove it? If you want to get rid of -1 handling then check all the
>>
>> alloc_pages_node have multiple meaning as you said. So some of users
>> misuses that API. I want to clear intention of user.
>
> The name is fine.  Just clean up the users and make the intended usage
> clear in documentation and implementation (ie. trigger a big fat
> warning) and make all the callers use named constants instead of -1
> for special meanings.
>
> Thanks.

Let's tidy my table.

I made quick patch to show the concept with one example of pci-dma.
(Sorry but I attach patch since web gmail's mangling.)

On UMA, we can change alloc_pages with
alloc_pages_exact_node(numa_node_id(),....)
(Actually, the patch is already merged mmotm)

on NUMA, alloc_pages is some different meaning, so I don't want to change it.
on NUMA, alloc_pages_node means _ANY_NODE_.
So let's remove nid argument and change naming with alloc_pages_any_node.

Then, whole users of alloc_pages_node can be changed between
alloc_pages_exact_node and alloc_pages_any_node.

It was my intention. What's your concern?

Thanks for your interest, Tejun. :)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a4ac764..dc511cb 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -152,12 +152,21 @@ void *dma_generic_alloc_coherent(struct device
*dev, size_t size,
        unsigned long dma_mask;
        struct page *page;
        dma_addr_t addr;
+       int nid;

        dma_mask = dma_alloc_coherent_mask(dev, flag);

        flag |= __GFP_ZERO;
 again:
-       page = alloc_pages_node(dev_to_node(dev), flag, get_order(size));
+       nid = dev_to_node(dev);
+       /*
+        * If pci-dma maintainer makes sure nid never has NUMA_NO_NODE
+        * we can remove this ugly checking.
+        */
+       if (nid == NUMA_NO_NODE)
+               page = alloc_pages_any_node(flag, get_order(size));
+       else
+               page = alloc_pages_exact_node(nid, flag, get_order(size));
        if (!page)
                return NULL;

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 4c6d413..47fba21 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -278,13 +278,10 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
        return __alloc_pages_nodemask(gfp_mask, order, zonelist, NULL);
 }

-static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
+static inline struct page *alloc_pagse_any_node(gfp_t gfp_mask,
                                                unsigned int order)
 {
-       /* Unknown node is current node */
-       if (nid < 0)
-               nid = numa_node_id();
-
+       int nid = numa_node_id();
        return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
 }

@@ -308,7 +305,7 @@ extern struct page *alloc_page_vma(gfp_t gfp_mask,
                        struct vm_area_struct *vma, unsigned long addr);
 #else
 #define alloc_pages(gfp_mask, order) \
-               alloc_pages_node(numa_node_id(), gfp_mask, order)
+               alloc_pages_exact_node(numa_node_id(), gfp_mask, order)
 #define alloc_page_vma(gfp_mask, vma, addr) alloc_pages(gfp_mask, 0)
 #endif
 #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)
~

-- 
Kind regards,
Minchan Kim

[-- Attachment #2: change_alloc_functions_naming.patch --]
[-- Type: text/x-diff, Size: 1844 bytes --]

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a4ac764..dc511cb 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -152,12 +152,21 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
 	unsigned long dma_mask;
 	struct page *page;
 	dma_addr_t addr;
+	int nid;
 
 	dma_mask = dma_alloc_coherent_mask(dev, flag);
 
 	flag |= __GFP_ZERO;
 again:
-	page = alloc_pages_node(dev_to_node(dev), flag, get_order(size));
+	nid = dev_to_node(dev);
+	/*
+	 * If pci-dma maintainer makes sure nid never has NUMA_NO_NODE
+	 * we can remove this ugly checking.
+	 */
+	if (nid == NUMA_NO_NODE)
+		page = alloc_pages_any_node(flag, get_order(size));
+	else
+		page = alloc_pages_exact_node(nid, flag, get_order(size));
 	if (!page)
 		return NULL;
 
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 4c6d413..47fba21 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -278,13 +278,10 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
 	return __alloc_pages_nodemask(gfp_mask, order, zonelist, NULL);
 }
 
-static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
+static inline struct page *alloc_pagse_any_node(gfp_t gfp_mask,
 						unsigned int order)
 {
-	/* Unknown node is current node */
-	if (nid < 0)
-		nid = numa_node_id();
-
+	int nid = numa_node_id();
 	return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
 }
 
@@ -308,7 +305,7 @@ extern struct page *alloc_page_vma(gfp_t gfp_mask,
 			struct vm_area_struct *vma, unsigned long addr);
 #else
 #define alloc_pages(gfp_mask, order) \
-		alloc_pages_node(numa_node_id(), gfp_mask, order)
+		alloc_pages_exact_node(numa_node_id(), gfp_mask, order)
 #define alloc_page_vma(gfp_mask, vma, addr) alloc_pages(gfp_mask, 0)
 #endif
 #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)

  reply	other threads:[~2010-04-19  0:03 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-13 15:24 [PATCH 1/6] Remove node's validity check in alloc_pages Minchan Kim
2010-04-13 15:24 ` [PATCH 2/6] change alloc function in pcpu_alloc_pages Minchan Kim
2010-04-13 15:48   ` Mel Gorman
2010-04-14 23:39     ` Tejun Heo
2010-04-15  1:31       ` Minchan Kim
2010-04-15  7:21         ` Tejun Heo
2010-04-15  8:00           ` Minchan Kim
2010-04-15  8:15             ` Tejun Heo
2010-04-15  9:40               ` Minchan Kim
2010-04-15 10:08                 ` Tejun Heo
2010-04-15 10:21                   ` Minchan Kim
2010-04-15 10:33                     ` Minchan Kim
2010-04-15 11:43                     ` Tejun Heo
2010-04-15 11:49                       ` Minchan Kim
2010-04-16 16:07                         ` Christoph Lameter
2010-04-16 19:13                           ` Lee Schermerhorn
2010-04-18 15:55                             ` Minchan Kim
2010-04-18 15:54                           ` Minchan Kim
2010-04-18 21:22                             ` Tejun Heo
2010-04-19  0:03                               ` Minchan Kim [this message]
2010-04-19 17:45                                 ` Christoph Lameter
2010-04-20  0:20                                   ` Minchan Kim
2010-04-19 17:38                             ` Christoph Lameter
2010-04-19 22:27                               ` Tejun Heo
2010-04-20 15:05                                 ` Mel Gorman
2010-04-21 10:48                                   ` Tejun Heo
2010-04-22 10:15                                     ` Minchan Kim
2010-04-21 14:15                                   ` Christoph Lameter
2010-04-21 17:06                                     ` Minchan Kim
2010-04-13 15:25 ` [PATCH 3/6] change alloc function in alloc_slab_page Minchan Kim
2010-04-13 15:52   ` Mel Gorman
2010-04-13 16:01     ` Minchan Kim
2010-04-13 16:14       ` Mel Gorman
2010-04-13 21:37   ` David Rientjes
2010-04-13 23:40     ` Minchan Kim
2010-04-13 23:55       ` David Rientjes
2010-04-14  0:02         ` Minchan Kim
2010-04-14  0:18   ` KAMEZAWA Hiroyuki
2010-04-14 12:23     ` Pekka Enberg
2010-04-16 16:10       ` Christoph Lameter
2010-04-18 18:49         ` Pekka Enberg
2010-04-19  9:05         ` Mel Gorman
2010-04-13 15:25 ` [PATCH 4/6] change alloc function in vmemmap_alloc_block Minchan Kim
2010-04-13 15:59   ` Mel Gorman
2010-04-14  0:19   ` KAMEZAWA Hiroyuki
2010-04-13 15:25 ` [PATCH 5/6] change alloc function in __vmalloc_area_node Minchan Kim
2010-04-13 16:02   ` Mel Gorman
2010-04-14  0:22   ` KAMEZAWA Hiroyuki
2010-04-14  0:33     ` Minchan Kim
2010-04-13 15:25 ` [PATCH 6/6] Add comment in alloc_pages_exact_node Minchan Kim
2010-04-13 16:13   ` Mel Gorman
2010-04-13 16:20     ` Minchan Kim
2010-04-13 15:32 ` [PATCH 1/6] Remove node's validity check in alloc_pages Mel Gorman
2010-04-14  0:04 ` KAMEZAWA Hiroyuki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=j2h28c262361004181703gd3f4bc19r6d00451e01b779a7@mail.gmail.com \
    --to=minchan.kim@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lliubbo@gmail.com \
    --cc=mel@csn.ul.ie \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).