linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mel@csn.ul.ie>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org, linux-mm@kvack.org,
	linaro-mm-sig@lists.linaro.org,
	Michal Nazarewicz <mina86@mina86.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Russell King <linux@arm.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Ankita Garg <ankita@in.ibm.com>,
	Daniel Walker <dwalker@codeaurora.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Jesse Barker <jesse.barker@linaro.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Shariq Hasnain <shariq.hasnain@linaro.org>,
	Chunsang Jeong <chunsang.jeong@linaro.org>,
	Dave Hansen <dave@linux.vnet.ibm.com>
Subject: Re: [PATCH 03/11] mm: mmzone: introduce zone_pfn_same_memmap()
Date: Mon, 12 Dec 2011 14:19:53 +0000	[thread overview]
Message-ID: <20111212141953.GD3277@csn.ul.ie> (raw)
In-Reply-To: <1321634598-16859-4-git-send-email-m.szyprowski@samsung.com>

On Fri, Nov 18, 2011 at 05:43:10PM +0100, Marek Szyprowski wrote:
> From: Michal Nazarewicz <mina86@mina86.com>
> 
> This commit introduces zone_pfn_same_memmap() function which checkes

s/checkes/checks/

> whether two PFNs within the same zone have struct pages within the
> same memmap. 

s/memmap/same sparsemem section/

> This check is needed because in general pointer
> arithmetic on struct pages may lead to invalid pointers.
> 
> On memory models that are not affected, zone_pfn_same_memmap() is
> defined as always returning true so the call should be optimised
> at compile time.
> 
> Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  include/linux/mmzone.h |   16 ++++++++++++++++
>  mm/compaction.c        |    5 ++++-
>  2 files changed, 20 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 188cb2f..84e07d0 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -1166,6 +1166,22 @@ static inline int memmap_valid_within(unsigned long pfn,
>  }
>  #endif /* CONFIG_ARCH_HAS_HOLES_MEMORYMODEL */
>  
> +#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
> +/*
> + * Both PFNs must be from the same zone!  If this function returns

from the same sparsemem section, not the same zone. 

> + * true, pfn_to_page(pfn1) + (pfn2 - pfn1) == pfn_to_page(pfn2).
> + */
> +static inline bool zone_pfn_same_memmap(unsigned long pfn1, unsigned long pfn2)
> +{
> +	return pfn_to_section_nr(pfn1) == pfn_to_section_nr(pfn2);
> +}
> +
> +#else
> +
> +#define zone_pfn_same_memmap(pfn1, pfn2) (true)
> +
> +#endif
> +
>  #endif /* !__GENERATING_BOUNDS.H */
>  #endif /* !__ASSEMBLY__ */
>  #endif /* _LINUX_MMZONE_H */
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 6afae0e..09c9702 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -111,7 +111,10 @@ skip:
>  
>  next:
>  		pfn += isolated;
> -		page += isolated;
> +		if (zone_pfn_same_memmap(pfn - isolated, pfn))
> +			page += isolated;
> +		else
> +			page = pfn_to_page(pfn);
>  	}

Is this necessary?

We are isolating pages, the largest of which is a MAX_ORDER_NR_PAGES
page. Sections are never smaller than MAX_ORDER_NR_PAGES so the end
of the free range of pages should never be in another section. That
should mean that the PFN walk will always consider the first
PFN of every section and you can implement a simplier check than
zone_pfn_same_memmap based on pfn & PAGE_SECTION_MASK and contain it
within mm/compaction.c

That said, everywhere else managed to avoid checks like this by always
scanning in units of pageblocks. Maybe this should be structured
the same way to guarantee pfn_valid is called at least per pageblock
(even though only once per MAX_ORDER_NR_PAGES is necessary).

-- 
Mel Gorman
SUSE Labs

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-12-12 14:19 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18 16:43 [PATCHv17 0/11] Contiguous Memory Allocator Marek Szyprowski
2011-11-18 16:43 ` [PATCH 01/11] mm: page_alloc: handle MIGRATE_ISOLATE in free_pcppages_bulk() Marek Szyprowski
2011-12-12 13:42   ` Mel Gorman
2011-12-12 14:23     ` Michal Nazarewicz
2011-12-12 14:42       ` Mel Gorman
2011-11-18 16:43 ` [PATCH 02/11] mm: compaction: introduce isolate_{free,migrate}pages_range() Marek Szyprowski
2011-12-12 14:07   ` Mel Gorman
2011-12-12 15:22     ` Michal Nazarewicz
2011-12-12 16:30       ` Mel Gorman
2011-12-12 16:46         ` Michal Nazarewicz
2011-12-12 17:20           ` Mel Gorman
2011-11-18 16:43 ` [PATCH 03/11] mm: mmzone: introduce zone_pfn_same_memmap() Marek Szyprowski
2011-12-12 14:19   ` Mel Gorman [this message]
2011-12-12 14:35     ` Michal Nazarewicz
2011-12-12 14:40       ` Mel Gorman
2011-12-12 14:51         ` Michal Nazarewicz
2011-12-12 15:51           ` Mel Gorman
2011-11-18 16:43 ` [PATCH 04/11] mm: compaction: export some of the functions Marek Szyprowski
2011-12-12 14:29   ` Mel Gorman
2011-12-12 14:41     ` Michal Nazarewicz
2011-12-12 15:40       ` Mel Gorman
2011-12-12 15:46         ` Michal Nazarewicz
2011-12-12 16:22         ` Arnd Bergmann
2011-11-18 16:43 ` [PATCH 05/11] mm: page_alloc: introduce alloc_contig_range() Marek Szyprowski
2011-11-18 16:43 ` [PATCH 06/11] mm: mmzone: MIGRATE_CMA migration type added Marek Szyprowski
2011-11-18 16:43 ` [PATCH 07/11] mm: page_isolation: MIGRATE_CMA isolation functions added Marek Szyprowski
2011-11-18 16:43 ` [PATCH 08/11] drivers: add Contiguous Memory Allocator Marek Szyprowski
2011-11-18 16:43 ` [PATCH 09/11] X86: integrate CMA with DMA-mapping subsystem Marek Szyprowski
2011-11-18 16:43 ` [PATCH 10/11] ARM: " Marek Szyprowski
2011-11-18 16:43 ` [PATCH 11/11] ARM: Samsung: use CMA for 2 memory banks for s5p-mfc device Marek Szyprowski
2011-11-18 21:20 ` [Linaro-mm-sig] [PATCHv17 0/11] Contiguous Memory Allocator sandeep patil
2011-11-18 21:26   ` Michal Nazarewicz
2011-11-18 23:30     ` sandeep patil
2011-11-19 18:09       ` Michal Nazarewicz
2011-11-25 16:43 ` [PATCH] mm: cma: hack/workaround for some allocation issues Marek Szyprowski
2011-11-25 21:08   ` Michal Nazarewicz

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=20111212141953.GD3277@csn.ul.ie \
    --to=mel@csn.ul.ie \
    --cc=akpm@linux-foundation.org \
    --cc=ankita@in.ibm.com \
    --cc=arnd@arndb.de \
    --cc=chunsang.jeong@linaro.org \
    --cc=corbet@lwn.net \
    --cc=dave@linux.vnet.ibm.com \
    --cc=dwalker@codeaurora.org \
    --cc=jesse.barker@linaro.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=mina86@mina86.com \
    --cc=shariq.hasnain@linaro.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).