From: Kumar Gala <kumar.gala@freescale.com>
To: "Christoph Lameter" <christoph@lameter.com>
Cc: "Nick Piggin" <nickpiggin@yahoo.com.au>,
"LKML list" <linux-kernel@vger.kernel.org>
Subject: Re: return value of ptep_get_and_clear
Date: Wed, 6 Apr 2005 12:55:36 -0500 [thread overview]
Message-ID: <1a0fc11558f3bf76d1a8ab889278dcc7@freescale.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0504061006120.4635@graphe.net>
On Apr 6, 2005, at 12:09 PM, Christoph Lameter wrote:
> 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...
Thanks, I was guessing that getting the value atomically was why this
was done after I give it a bit more thought.
- kumar
next prev parent reply other threads:[~2005-04-06 17:55 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
2005-04-06 17:55 ` Kumar Gala [this message]
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=1a0fc11558f3bf76d1a8ab889278dcc7@freescale.com \
--to=kumar.gala@freescale.com \
--cc=christoph@lameter.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®