From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx114.postini.com [74.125.245.114]) by kanga.kvack.org (Postfix) with SMTP id 454DA6B0005 for ; Fri, 8 Mar 2013 21:18:29 -0500 (EST) Received: by mail-pb0-f50.google.com with SMTP id up1so1820690pbc.37 for ; Fri, 08 Mar 2013 18:18:28 -0800 (PST) Message-ID: <513A9BD3.4010807@gmail.com> Date: Sat, 09 Mar 2013 10:17:55 +0800 From: Jiang Liu MIME-Version: 1.0 Subject: Re: [RFC PATCH v1 01/33] mm: introduce common help functions to deal with reserved/managed pages References: <1362495317-32682-1-git-send-email-jiang.liu@huawei.com> <1362495317-32682-2-git-send-email-jiang.liu@huawei.com> <20130305194722.GA12225@merkur.ravnborg.org> In-Reply-To: <20130305194722.GA12225@merkur.ravnborg.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Sam Ravnborg Cc: Andrew Morton , David Rientjes , Jiang Liu , Wen Congyang , Maciej Rutecki , Chris Clayton , "Rafael J . Wysocki" , Mel Gorman , Minchan Kim , KAMEZAWA Hiroyuki , Michal Hocko , Jianguo Wu , Anatolij Gustschin , Aurelien Jacquiot , Benjamin Herrenschmidt , Catalin Marinas , Chen Liqin , Chris Metcalf , Chris Zankel , David Howells , "David S. Miller" , Eric Biederman , Fenghua Yu , Geert Uytterhoeven , Guan Xuetao , Haavard Skinnemoen , Hans-Christian Egtvedt , Heiko Carstens , Helge Deller , Hirokazu Takata , "H. Peter Anvin" , Ingo Molnar , Ivan Kokshaysky , "James E.J. Bottomley" , Jeff Dike , Jeremy Fitzhardinge , Jonas Bonn , Koichi Yasutake , Konrad Rzeszutek Wilk , Lennox Wu , Mark Salter , Martin Schwidefsky , Matt Turner , Max Filippov , "Michael S. Tsirkin" , Michal Simek , Michel Lespinasse , Mikael Starvik , Mike Frysinger , Paul Mackerras , Paul Mundt , Ralf Baechle , Richard Henderson , Rik van Riel , Russell King , Rusty Russell , Tang Chen , Thomas Gleixner , Tony Luck , Will Deacon , Yasuaki Ishimatsu , Yinghai Lu , Yoshinori Sato , x86@kernel.org, xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, virtualization@lists.linux-foundation.org Hi Sam, Thanks for review! On 03/06/2013 03:47 AM, Sam Ravnborg wrote: > On Tue, Mar 05, 2013 at 10:54:44PM +0800, Jiang Liu wrote: >> Code to deal with reserved/managed pages are duplicated by many >> architectures, so introduce common help functions to reduce duplicated >> code. These common help functions will also be used to concentrate code >> to modify totalram_pages and zone->managed_pages, which makes the code >> much more clear. >> >> Signed-off-by: Jiang Liu >> --- >> include/linux/mm.h | 37 +++++++++++++++++++++++++++++++++++++ >> mm/page_alloc.c | 20 ++++++++++++++++++++ >> 2 files changed, 57 insertions(+) >> >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index 7acc9dc..881461c 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -1295,6 +1295,43 @@ extern void free_area_init_node(int nid, unsigned long * zones_size, >> unsigned long zone_start_pfn, unsigned long *zholes_size); >> extern void free_initmem(void); >> >> +/* Help functions to deal with reserved/managed pages. */ >> +extern unsigned long free_reserved_area(unsigned long start, unsigned long end, >> + int poison, char *s); >> + >> +static inline void adjust_managed_page_count(struct page *page, long count) >> +{ >> + totalram_pages += count; >> +} > > What is the purpose of the unused page argument? I will be used in a later patch. > >> + >> +static inline void __free_reserved_page(struct page *page) >> +{ >> + ClearPageReserved(page); >> + init_page_count(page); >> + __free_page(page); >> +} > This method is useful for architectures which implment HIGHMEM, > like 32 bit x86 and 32 bit sparc. > This calls for a name without underscores. We will introduce another help function named free_highmem_page() to free highmem into the buddy system. In normal cases __free_reserved_page() won't be called directly, it's just used to handle several special cases. > > >> + >> +static inline void free_reserved_page(struct page *page) >> +{ >> + __free_reserved_page(page); >> + adjust_managed_page_count(page, 1); >> +} >> + >> +static inline void mark_page_reserved(struct page *page) >> +{ >> + SetPageReserved(page); >> + adjust_managed_page_count(page, -1); >> +} >> + >> +static inline void free_initmem_default(int poison) >> +{ > > Why request user to supply the poison argumet. If this is the default > implmentation then use the default poison value too (POISON_FREE_INITMEM) > >> + extern char __init_begin[], __init_end[]; >> + >> + free_reserved_area(PAGE_ALIGN((unsigned long)&__init_begin) , >> + ((unsigned long)&__init_end) & PAGE_MASK, >> + poison, "unused kernel"); >> +} > > > Maybe it is just me how is not used to this area of the kernel. > But a few comments that describe what the purpose is of each > function would have helped me. Good suggestion, will add comments for them. Regards! Gerry > > Sam > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org