mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Lameter <christoph@lameter.com>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Kumar Gala <kumar.gala@freescale.com>,
	LKML list <linux-kernel@vger.kernel.org>
Subject: Re: return value of ptep_get_and_clear
Date: Wed, 6 Apr 2005 10:09:38 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0504061006120.4635@graphe.net> (raw)
In-Reply-To: <425412FB.7030209@yahoo.com.au>

On Thu, 7 Apr 2005, Nick Piggin wrote:

> Kumar Gala wrote:
> > ptep_get_and_clear has a signature that looks something like:
> >
> > static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned
> > long addr,
> >                                        pte_t *ptep)
> >
> > It appears that its suppose to return the pte_t pointed to by ptep
> > before its modified.  Why do we bother doing this?  The caller seems
> > perfectly able to dereference ptep and hold on to it.  Am I missing
> > something here?
> >
>
> You need to be able to *atomically* clear the pte and retrieve the
> old value.

The effect of the clearing is that the present bit is cleared which makes
the CPU generate a fault if this pte is referenced.

The problem with replacing pte values is that the code executing is racing
with cpu mmu access to the pte (which may set bits on i386 I believe). So
if you would access the pte and then clear it later then there would be a
small window where the MMU could modify the pte. These changes would not
be detected since you later overwrite the pte.

Using ptep_get_and_clear insures that this does not happen...

  reply	other threads:[~2005-04-06 17:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-06 16:38 Kumar Gala
2005-04-06 16:48 ` Nick Piggin
2005-04-06 17:09   ` Christoph Lameter [this message]
2005-04-06 17:55     ` Kumar Gala
2005-04-06 17:09 ` Brian Gerst

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=Pine.LNX.4.58.0504061006120.4635@graphe.net \
    --to=christoph@lameter.com \
    --cc=kumar.gala@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    /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®