From: "Jan Beulich" <jbeulich@novell.com>
To: Keir Fraser <keir@xensource.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: Fwd: Re: struct page field arrangement
Date: Fri, 16 Mar 2007 11:58:51 +0000 [thread overview]
Message-ID: <45FA948B.76E4.0078.0@novell.com> (raw)
>>>> Keir Fraser <keir@xensource.com> 01.03.07 11:22 >>>
>>Can we confident that the mm_pin/mm_unpin code (which walks pagetables and
>>has to find every page to make every one read-only or writable) is safe?
>>Presumably for this to be true we need to be sure that noone can meanwhile
>>concurrently be populating the pagetable we are walking with extra
>>pgds/puds/pmds/ptes...
>
>Since the pin/unpin walking only cares about pgd/pud/pmd entries, synchronization
>is guaranteed through mm->page_table_lock. The pte lock is used only for leaf
>entries, which are of no concern to (un)pinning.
I'm afraid I have to correct myself. Stress testing has shown severe
problems, and after a few hours of staring at this I'm almost certain there
is a race condition here: While no new pte-s can ever appear, the logic in
mm/vmscan.c may try to modify pte-s in an mm currently being unpinned
(at least through ptep_clear_flush_young() called from
page_referenced_one() in mm/rmap.c). If this happens when
xen_pgd_unpin() has already passed the respective pte page, but
mm_walk() hasn't reached the page, yet, the update will fail (if done
directly, ptwr will no pick this up, and if done through a hypercall, the
call would fail, likely producing a BUG()).
Of course we could back out that changeset, but one of the reasons for
submitting it was to get closer to native. Therefore I'm considering
alternatives:
- lock all pte pages right after taking the page table lock in the pin/unpin
functions, and drop them right before dropping the page table lock
(this nesting should be no problem, as none of them can ever nest
elsewhere, since otherwise the non-split-pt-lock case would not work)
- find a way to fix up the possibly resulting page fault (e.g. allow the
ptwr code to update the page if it is PGT_l1_page_table but has a
zero type reference count; the PGT_writable case would be more
difficult and would probably need to be caught in the guest by checking
the pte and finding it to be writable); the hypercalls don't seem to be
affected (do_mmu_update seems okay as it doesn't look at the type
reference count, and do_update_va_mapping can be called only on
the currently active address space, which cannot be the one being in
transition)
Dealing with an mm being pinned seems more difficult, as its L1 page
table pages will not be in PGT_l1_page_table state yet. Thus another
alternative could be to make page_check_address() in the kernel
detect the being-(un)pinned status, or even adjust pte_lockptr() to
return the page table lock for mm-s being (un)pinned (this would
perhaps be the cheapest fix).
Jan
next reply other threads:[~2007-03-16 11:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-16 11:58 Jan Beulich [this message]
2007-03-16 12:11 ` Fwd: Re: struct page field arrangement Keir Fraser
2007-03-16 12:25 ` Keir Fraser
2007-03-16 12:54 ` Jan Beulich
2007-03-16 12:37 ` Keir Fraser
2007-03-16 12:46 ` Jan Beulich
-- strict thread matches above, loose matches on Subject: below --
2007-03-16 13:47 Jan Beulich
2007-03-16 14:13 ` Keir Fraser
2007-03-16 14:30 ` Keir Fraser
2007-03-16 15:15 ` Jan Beulich
2007-03-16 15:30 ` Keir Fraser
2007-02-28 14:31 Jan Beulich
2007-02-28 21:08 ` Hugh Dickins
2007-03-01 8:42 ` Fwd: " Jan Beulich
2007-03-01 10:22 ` Keir Fraser
2007-03-01 11:45 ` Jan Beulich
2007-03-01 12:12 ` Keir Fraser
2007-03-01 12:50 ` Jan Beulich
2007-03-01 13:42 ` Keir Fraser
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=45FA948B.76E4.0078.0@novell.com \
--to=jbeulich@novell.com \
--cc=keir@xensource.com \
--cc=xen-devel@lists.xensource.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.