mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: David Howells <dhowells@redhat.com>
Cc: dwmw2@infradead.org, hch@infradead.org, torvalds@osdl.org,
	davidm@snapgear.com, linux-kernel@vger.kernel.org,
	uclinux-dev@uclinux.org, kamezawa.hiroyu@jp.fujitsu.com
Subject: Re: [PATCH] VM routine fixes
Date: Thu, 11 Nov 2004 03:43:53 -0800	[thread overview]
Message-ID: <20041111034353.00d35589.akpm@osdl.org> (raw)
In-Reply-To: <24698.1100172576@redhat.com>

David Howells <dhowells@redhat.com> wrote:
>
> 
> > > On Wed, 2004-11-10 at 11:01 -0800, Andrew Morton wrote:
> > > > Why _does_ !CONFIG_MMU futz around with page counts in such weird ways
> > > > anyway?  Why does it have requirements for higher-order pages which
> > > > differ from !CONFIG_MMU?
> 
> The problem is ptrace() and various /proc/<pid/ files; or more properly, the
> problem is access_process_vm() and suchlike.
> 
> When one process goes rooting around in another process's memory map, it
> increments the refcount on the page it is looking at to stop it going away.
> 
> The problem on uClinux is that a process can have multipage chunks mapped into
> userspace, and access_process_vm() can look at a page in the middle of such a
> span.
> 
> Without this change, bad_page() is called when access_process_vm() calls a
> put_page() on a page in the middle because its refcount would say it's no
> longer in use and then put_page() would then attempt to free the page.
> 
> access_process_vm() guards against the target page going away due to the
> target process exiting at an inconvenient moment by pinning the target mm and
> holding its semaphore.

Compound pages will fix all that up.  You take a ref on any of the subpages
and that will pin the entire higher-order page.

> > I assume the CONFIG_MMU logic assumes that it's legal to physically free a
> > single page from inside the middle of a higher-order page.
> 
> No, it isn't. munmap() is prohibited from releasing anything other than a
> complete mmap() on uClinux.

hrm.  I'd have thought that such a restriction would be unnecessary if we
get the page refcounting done right.  With, say, compound pages!

Maybe the restriction is there for other reasons.

> > See, if we enable the compound page logic if !CONFIG_MMU then all this
> > stuff just goes away and the page refcounting is controlled purely by the
> > head page.  A get_page() or a put_page() against any of the constituent
> > pages will manipulate the head page's refcount.
> 
> That's true to a point, and probably a reasonable idea, assuming that compound
> pages aren't limited in size to TLB-specific values. If they are, then it
> makes no real difference.

Compound pages are just a way of handling refcounting of a higher-order
page.  Nothing to do with TLBs at all.


  reply	other threads:[~2004-11-11 11:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-08 14:32 dhowells
2004-11-09 12:55 ` Christoph Hellwig
2004-11-09 13:53 ` David Howells
2004-11-09 14:01   ` Christoph Hellwig
2004-11-10 13:37   ` David Howells
2004-11-10 19:01     ` Andrew Morton
2004-11-11  1:17       ` David Woodhouse
2004-11-11  2:26         ` Andrew Morton
2004-11-11 11:29         ` David Howells
2004-11-11 11:43           ` Andrew Morton [this message]
2004-11-11 12:03           ` David Howells
2004-11-11 22:31 ` Andrew Morton
2004-11-12 10:33 ` David Howells
2004-11-12 10:38   ` Andrew Morton
2004-11-12 11:05   ` David Howells
2004-11-14  5:07     ` Linus Torvalds
2004-11-15 13:14     ` David Howells
2004-11-15 15:35       ` Linus Torvalds

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=20041111034353.00d35589.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=davidm@snapgear.com \
    --cc=dhowells@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=hch@infradead.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=uclinux-dev@uclinux.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

all inboxes | Powered by JetHome®