linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Milton Miller <miltonm@bga.com>
To: Minchan Kim <minchan.kim@gmail.com>
Cc: Christoph Lameter <cl@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Russell King <linux@arm.linux.org.uk>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Mel Gorman <mel@csn.ul.ie>, Johannes Weiner <hannes@cmpxchg.org>,
	Kukjin Kim <kgene.kim@samsung.com>
Subject: Re: [PATCH] Tight check of pfn_valid on sparsemem - v4
Date: Tue, 27 Jul 2010 03:12:38 -0500	[thread overview]
Message-ID: <pfn.valid.v4.reply.2@mdm.bga.com> (raw)
In-Reply-To: <AANLkTimtTVvorrR9pDVTyPKj0HbYOYY3aR7B-QWGhTei@mail.gmail.com>


On Tue Jul 27 2010 about 02:11:22 Minchan Kim wrote:
> > [Sorry if i missed or added anyone on cc, patchwork.kernel.org  LKML is not
> > working and I'm not subscribed to the list ]
> 
> Readd them. :)

Changed linux-mmc at vger to linxu-mm at kvack.org, from my poor use of grep 
MAINTAINERS.

> On Tue, Jul 27, 2010 at 2:55 PM, <miltonm@xxxxxxx> wrote:
> > On Mon Jul 26 2010 about 12:47:37 EST, Christoph Lameter wrote:
> > > On Tue, 27 Jul 2010, Minchan Kim wrote:
> > >
> > > > This patch registers address of mem_section to memmap itself's page struct's
> > > > pg->private field. This means the page is used for memmap of the section.
> > > > Otherwise, the page is used for other purpose and memmap has a hole.
> >
> > >
> > > > +void mark_valid_memmap(unsigned long start, unsigned long end);
> > > > +
> > > > +#ifdef CONFIG_ARCH_HAS_HOLES_MEMORYMODEL
> > > > +static inline int memmap_valid(unsigned long pfn)
> > > > +{
> > > > + struct page *page = pfn_to_page(pfn);
> > > > + struct page *__pg = virt_to_page(page);
> > > > + return page_private(__pg) == (unsigned long)__pg;
> > >
> > >
> > > What if page->private just happens to be the value of the page struct?
> > > Even if that is not possible today, someday someone may add new
> > > functionality to the kernel where page->pivage == page is used for some
> > > reason.
> > >
> > > Checking for PG_reserved wont work?
> >
> > I had the same thought and suggest setting it to the memory section block,
> > since that is a uniquie value (unlike PG_reserved),
> 
> You mean setting pg->private to mem_section address?
> I hope I understand your point.
> 
> Actually, KAMEZAWA tried it at first version but I changed it.
> That's because I want to support this mechanism to ARM FLATMEM.
> (It doesn't have mem_section)

> >
> > .. and we already have computed it when we use it so we could pass it as
> > a parameter (to both _valid and mark_valid).
> 
> I hope this can support FALTMEM which have holes(ex, ARM).
> 

If we pass a void * to this helper we should be able to find another
symbol.  Looking at the pfn_valid() in arch/arm/mm/init.c I would
probably choose &meminfo as it is already used nearby, and using a single
symbol in would avoid issues if a more specific symbol chosen (eg bank)
were to change at a pfn boundary not PAGE_SIZE / sizeof(struct page).
Similarly the asm-generic/page.h version could use &max_mapnr.

This function is a validation helper for pfn_valid not the only check.

something like

static inline int memmap_valid(unsigned long pfn, void *validate)
{
	struct page *page = pfn_to_page(pfn);
	struct page *__pg = virt_to_page(page);
	return page_private(__pg) == validate;
}

static inline int pfn_valid(unsigned long pfn)
{
	struct mem_section *ms;
	if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
		return 0;
	ms = __nr_to_section(pfn_to_section_nr(pfn));
	return valid_section(ms) && memmap_valid(pfn, ms);
}

> > > > +/*
> > > > + * Fill pg->private on valid mem_map with page itself.
> > > > + * pfn_valid() will check this later. (see include/linux/mmzone.h)
> > > > + * Every arch for supporting hole of mem_map should call
> > > > + * mark_valid_memmap(start, end). please see usage in ARM.
> > > > + */
> > > > +void mark_valid_memmap(unsigned long start, unsigned long end)
> > > > +{
> > > > +	struct mem_section *ms;
> > > > +	unsigned long pos, next;
> > > > +	struct page *pg;
> > > > +	void *memmap, *mapend;
> > > > +
> > > > +	for (pos = start; pos < end; pos = next) {
> > > > +		next = (pos + PAGES_PER_SECTION) & PAGE_SECTION_MASK;
> > > > +		ms = __pfn_to_section(pos);
> > > > +		if (!valid_section(ms))
> > > > +			continue;
> > > > +	
> > > > +		for (memmap = (void*)pfn_to_page(pos),
> > > > +					/* The last page in section */
> > > > +					mapend = pfn_to_page(next-1);
> > > > +				memmap < mapend; memmap += PAGE_SIZE) {
> > > > +			pg = virt_to_page(memmap);
> > > > +			set_page_private(pg, (unsigned long)pg);
> > > > +		}
> > > > +	}
> > > > +}

Hmm, this loop would need to change for sections.   And sizeof(struct
page) % PAGE_SIZE may not be 0, so we want a global symbol for sparsemem
too.  Perhaps the mem_section array.  Using a symbol that is part of
the model pre-checks can remove a global symbol lookup and has the side
effect of making sure our pfn_valid is for the right model.

milton

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2010-07-27  8:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-26 15:46 [PATCH] Tight check of pfn_valid on sparsemem - v4 Minchan Kim
2010-07-26 16:40 ` Christoph Lameter
2010-07-26 22:47   ` Minchan Kim
     [not found]   ` <pfn.valid.v4.reply.1@mdm.bga.com>
     [not found]     ` <AANLkTimtTVvorrR9pDVTyPKj0HbYOYY3aR7B-QWGhTei@mail.gmail.com>
2010-07-27  8:12       ` Milton Miller [this message]
2010-07-27  8:13         ` KAMEZAWA Hiroyuki
2010-07-27 10:01           ` Minchan Kim
2010-07-27 14:34             ` Christoph Lameter
2010-07-27 22:33               ` Minchan Kim
2010-07-28 15:14                 ` Christoph Lameter
2010-07-28 15:56                   ` Minchan Kim
2010-07-28 17:02                     ` Christoph Lameter
2010-07-28 22:57                       ` Minchan Kim
2010-07-29 15:46                         ` Christoph Lameter
2010-07-29 16:18                           ` Minchan Kim
2010-07-29 16:47                             ` Christoph Lameter
2010-07-29 17:03                               ` Minchan Kim
2010-07-29 17:30                                 ` Christoph Lameter
2010-07-29 18:33                                   ` Russell King - ARM Linux
2010-07-29 19:55                                     ` Christoph Lameter
2010-07-29 21:13                                       ` Russell King - ARM Linux
2010-07-29 20:55                                     ` Dave Hansen
2010-07-29 22:14                                       ` Russell King - ARM Linux
2010-07-29 22:28                                         ` Christoph Lameter
2010-07-30  0:38                                         ` Dave Hansen
2010-07-30  9:43                                           ` Minchan Kim
2010-07-30 12:48                                           ` Christoph Lameter
2010-07-30 15:43                                             ` Dave Hansen
2010-07-31 15:30                                             ` Russell King - ARM Linux
2010-08-02 15:48                                               ` Christoph Lameter
2010-07-30  9:32                                       ` Minchan Kim
2010-07-31 10:38                                         ` Russell King - ARM Linux
2010-08-11 15:31                                           ` Dave Hansen
2010-07-27  9:56         ` Minchan Kim

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=pfn.valid.v4.reply.2@mdm.bga.com \
    --to=miltonm@bga.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mel@csn.ul.ie \
    --cc=minchan.kim@gmail.com \
    /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).