linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: Dave Hansen <dave.hansen@intel.com>,
	"Kirill A. Shutemov" <kirill@shutemov.name>,
	Hugh Dickins <hughd@google.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: X86 ML <x86@kernel.org>
Subject: Can someone explain what free_pgd_range(), etc actually do?
Date: Fri, 3 Nov 2017 05:11:12 -0700	[thread overview]
Message-ID: <CALCETrW73eB7GFkO6BEkF25wJODr2KCCv0baUykzfBZnWwOrVQ@mail.gmail.com> (raw)

I want to reserve a tiny bit of the address space just below 1<<47 on
x86_64 for kernel purposes but without stealing away management of the
page tables.  It seems like the way to do that is to set
USER_PGTABLES_CEILING to 0 and then make some adjustment to
exit_mmap() to free the tables on exit.

The problem is that free_pgd_range(), free_pgtables, etc are quite
opaque to me, and I'm having a hard time understanding the pagetable
freeing code.  Some questions I haven't figured out:

 - What is the intended purpose of addr, end, floor, and ceiling?
What are the pagetable freeing functions actually *supposed* to do?

 - Are there any invariants that, for example, there is never a
pagetable that doesn't have any vmas at all under it?  I can
understand how all the code would be correct if this invariant were to
exist, but I don't see what would preserve it.  But maybe
free_pgd_range(), etc really do preserve it.

 - What keeps mm->mmap pointing to the lowest-addressed vma?  I see
lots of code that seems to assume that you can start at mm->mmap,
follow the vm_next links, and find all vmas, but I can't figure out
why this would work.

 - What happens if a process exits while mm->mmap is NULL?

 - Is there any piece of code that makes it obvious that all the
pagetables are gone by the time the exit_mmap() finishes?

Because I'm staring to wonder whether some weird combination of maps
and unmaps will just leak pagetables, and the code is rather
complicated, subtle, and completely lacking in documentation, and I've
learned to be quite suspicious of such things.

--Andy

--
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>

             reply	other threads:[~2017-11-03 12:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03 12:11 Andy Lutomirski [this message]
2017-11-03 15:06 ` Can someone explain what free_pgd_range(), etc actually do? Dave Hansen

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=CALCETrW73eB7GFkO6BEkF25wJODr2KCCv0baUykzfBZnWwOrVQ@mail.gmail.com \
    --to=luto@amacapital.net \
    --cc=dave.hansen@intel.com \
    --cc=hughd@google.com \
    --cc=kirill@shutemov.name \
    --cc=linux-mm@kvack.org \
    --cc=x86@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).