All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keir Fraser <keir@xen.org>
To: Tim Deegan <tim@xen.org>, Andres Lagar-Cavilla <andres@lagarcavilla.org>
Cc: xen-devel@lists.xensource.com, ian.campbell@citrix.com,
	andres@gridcentric.ca, keir.xen@gmail.com, jbeulich@suse.com,
	ian.jackson@citrix.com, adin@gridcentric.ca
Subject: Re: [PATCH 12 of 18] x86/mm: Make page_lock/unlock() in arch/x86/mm.c externally callable
Date: Fri, 09 Dec 2011 15:02:21 +0000	[thread overview]
Message-ID: <CB07D37D.35959%keir@xen.org> (raw)
In-Reply-To: <20111209145704.GJ87836@ocelot.phlegethon.org>

On 09/12/2011 14:57, "Tim Deegan" <tim@xen.org> wrote:

> At 18:54 -0800 on 08 Dec (1323370449), Andres Lagar-Cavilla wrote:
>>> At 02:47 -0500 on 08 Dec (1323312447), Andres Lagar-Cavilla wrote:
>>>> This is necessary for a new consumer of page_lock/unlock to follow in
>>>> the series.
>>>> 
>>>> Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
>>> 
>>> Nak, I'm afraid.
>>> 
>>> These were OK as local functions but if they're going to be made
>>> generally visible, they need clear comments describing what this
>>> locking protects and what the discipline is for avoiding deadlocks.
>> 
>> How about something along the lines of
>> "page_lock() is used for two purposes: pte serialization, and memory
>> sharing. All users of page lock for pte serialization live in mm.c, use it
>> to lock a page table page during pte updates, do not take other locks
>> within the critical section delimited by page_lock/unlock, and perform no
>> nesting. All users of page lock for memory sharing live in
>> mm/mem_sharing.c. For memory sharing, nesting may happen when sharing (and
>> locking) two pages -- deadlock is avoided by locking pages in increasing
>> order. Memory sharing may take the p2m_lock within a page_lock/unlock
>> critical section. These two users (pte serialization and memory sharing)
>> should never collide, as long as page table pages are properly unshared
>> prior to updating."
> 
> Thanks.  Extracting from that and from Keir's response:
> 
> It serves both as a spinlock and to exclude any to the page-type of the
> page in question (by causing the get_page_type() functions to spin).

It does not cause the get_page_type() functions to spin. An attempt to get
another reference to the current type will succeed; an attempt to change the
type will immediately fail. From the p.o.v. of the type-tracking logic,
page_lock() simply takes a reference to the current type.

 -- Keir

> What it currently protects is all modifications to pages that have
> pagetable type.  This serialises PV PTE validations, both against other
> validations of the same PTE and against concurrent changes of the
> enclosing page's type.
> 
> Your planned use is to protect updates to the page-sharing state
> associated with a page.  Can you be clear about what exactly is protected?
> 
> The proposed locking discipline is that
> - page locks must be taken in increasing order of MFN, yes?
> - and that you must always take page locks before the p2m lock?
> 
> Is that about right?
> 
> Tim.

      parent reply	other threads:[~2011-12-09 15:02 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-08  7:47 [PATCH 00 of 18] Memory sharing overhaul Andres Lagar-Cavilla
2011-12-08  7:47 ` [PATCH 01 of 18] x86/mm: Code style fixes in mem_sharing.c Andres Lagar-Cavilla
2011-12-08 11:11   ` Tim Deegan
2011-12-08 16:16     ` Andres Lagar-Cavilla
2011-12-08 21:54       ` Tim Deegan
2011-12-08  7:47 ` [PATCH 02 of 18] x86/mm: Making a page sharable sets PGT_validated, but making a page private doesn't expect it Andres Lagar-Cavilla
2011-12-08 11:16   ` Tim Deegan
2011-12-08  7:47 ` [PATCH 03 of 18] x86/mm: Eliminate hash table in sharing code as index of shared mfns Andres Lagar-Cavilla
2011-12-08 22:13   ` Tim Deegan
2011-12-08  7:47 ` [PATCH 04 of 18] x86/mm: Update mem sharing interface to (re)allow sharing of grants Andres Lagar-Cavilla
2011-12-08 22:20   ` Tim Deegan
2011-12-09  2:57     ` Andres Lagar-Cavilla
2011-12-08  7:47 ` [PATCH 05 of 18] Tools: Do not assume sharing target is dom0 in libxc wrappers Andres Lagar-Cavilla
2011-12-09 10:01   ` Ian Jackson
2011-12-08  7:47 ` [PATCH 06 of 18] Tools: Update libxc mem sharing interface Andres Lagar-Cavilla
2011-12-09  9:59   ` Ian Jackson
2011-12-08  7:47 ` [PATCH 07 of 18] Tools: Update memshr tool to use new sharing API Andres Lagar-Cavilla
2011-12-09  9:59   ` Ian Jackson
2011-12-08  7:47 ` [PATCH 08 of 18] Tools: Add a sharing command to xl for information about shared pages Andres Lagar-Cavilla
2011-12-09 10:08   ` Ian Jackson
2011-12-09 14:43     ` Andres Lagar-Cavilla
2011-12-09 10:10   ` Ian Campbell
2011-12-09 11:29     ` Ian Jackson
2011-12-08  7:47 ` [PATCH 09 of 18] x86/mm: Check how many mfns are shared, in addition to how many are saved Andres Lagar-Cavilla
2011-12-08 22:27   ` Tim Deegan
2011-12-08  7:47 ` [PATCH 10 of 18] Tools: Expose to libxc the total number of shared frames and space saved Andres Lagar-Cavilla
2011-12-08  7:47 ` [PATCH 11 of 18] Tools: Allow libxl/xl to expose " Andres Lagar-Cavilla
2011-12-09 10:02   ` Ian Jackson
2011-12-08  7:47 ` [PATCH 12 of 18] x86/mm: Make page_lock/unlock() in arch/x86/mm.c externally callable Andres Lagar-Cavilla
2011-12-08 22:38   ` Tim Deegan
2011-12-08 23:06     ` Keir Fraser
2011-12-09  3:01       ` Andres Lagar-Cavilla
2011-12-09  8:17         ` Keir Fraser
2011-12-09 14:47           ` Andres Lagar-Cavilla
2011-12-09  2:54     ` Andres Lagar-Cavilla
2011-12-09  8:51       ` Jan Beulich
2011-12-09 14:53         ` Andres Lagar-Cavilla
2011-12-09 15:06           ` Jan Beulich
2011-12-09 17:34             ` Andres Lagar-Cavilla
2011-12-09 14:57       ` Tim Deegan
2011-12-09 14:59         ` Andres Lagar-Cavilla
2011-12-09 15:02         ` Keir Fraser [this message]

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=CB07D37D.35959%keir@xen.org \
    --to=keir@xen.org \
    --cc=adin@gridcentric.ca \
    --cc=andres@gridcentric.ca \
    --cc=andres@lagarcavilla.org \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir.xen@gmail.com \
    --cc=tim@xen.org \
    --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.