public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Manfred Spraul <manfred@colorfullife.com>
Cc: Linus Torvalds <torvalds@transmeta.com>, linux-kernel@vger.kernel.org
Subject: Re: x86 ptep_get_and_clear question
Date: Fri, 16 Feb 2001 16:27:41 +0100	[thread overview]
Message-ID: <20010216162741.A4284@pcep-jamie.cern.ch> (raw)
In-Reply-To: <3A8C499A.E0370F63@colorfullife.com> <Pine.LNX.4.10.10102151702320.12656-100000@penguin.transmeta.com> <20010216151839.A3989@pcep-jamie.cern.ch> <3A8D4045.F8F27782@colorfullife.com>
In-Reply-To: <3A8D4045.F8F27782@colorfullife.com>; from manfred@colorfullife.com on Fri, Feb 16, 2001 at 03:59:17PM +0100

Manfred Spraul wrote:
> > I can think of one case where performance is considered quite important:
> > mprotect() is used by several garbage collectors, including threaded
> > ones.  Maybe mprotect() isn't the best primitive for those anyway, but
> > it's what they have to work with atm.
> 
> Does mprotect() actually care for wrong dirty bits?
> The race should be invisible to user space apps.
> 
> >>>>>>> mprotect()
> for_all_affected_ptes() {
> 	lock andl ~PERMISSION_MASK, *pte;
> 	lock orl new_permission, *pte;
> }
> < now anther cpu could still write to the write protected pages
> < and set the dirty bit, but who cares? Shouldn't be a problem.
> flush_tlb_range().
> < tlb flush before ending the syscall, user space can't notice
> < the delay.
> <<<<

The user-space app doesn't even _know_ about dirty bits.

I don't think there's even the possibility of losing dirty bits with
mprotect(), so long as pte_modify doesn't clear the dirty bit, which it
doesn't, in this code:

/* mprotect.c */
	entry = ptep_get_and_clear(pte);
	set_pte(pte, pte_modify(entry, newprot));

I.e. the only code with the race condition is code which explicitly
clears the dirty bit, in vmscan.c.

Do you see any possibility of losing a dirty bit here?

If not, there's no need for the intricate "gather" or "double scan"
schemes for mprotect() and it can stay as fast as possible.

Btw, a possible mprotect optimisation: there is no need for
flush_tlb_range() when increasing permissions.

-- Jamie

  reply	other threads:[~2001-02-16 15:28 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20010215173547.A2079@pcep-jamie.cern.ch>
     [not found] ` <200102151723.JAA43255@google.engr.sgi.com>
2001-02-15 17:47   ` x86 ptep_get_and_clear question Jamie Lokier
2001-02-15 18:05     ` Kanoj Sarcar
2001-02-15 18:23     ` Kanoj Sarcar
2001-02-15 18:42       ` Jamie Lokier
2001-02-15 18:57         ` Kanoj Sarcar
2001-02-15 19:06           ` Ben LaHaise
2001-02-15 19:19             ` Kanoj Sarcar
2001-02-15 20:16               ` Linus Torvalds
2001-02-15 18:51       ` Manfred Spraul
2001-02-15 19:05         ` Kanoj Sarcar
2001-02-15 19:19           ` Jamie Lokier
2001-02-15 20:31             ` Linus Torvalds
2001-02-15 21:26               ` Manfred Spraul
2001-02-15 21:29                 ` Manfred Spraul
2001-02-16  1:21                 ` Linus Torvalds
2001-02-16 14:18                   ` Jamie Lokier
2001-02-16 14:59                     ` Manfred Spraul
2001-02-16 15:27                       ` Jamie Lokier [this message]
2001-02-16 15:54                         ` Manfred Spraul
2001-02-16 16:00                           ` Jamie Lokier
2001-02-16 16:23                             ` Manfred Spraul
2001-02-16 16:43                               ` Jamie Lokier
2001-02-16 17:12                                 ` Manfred Spraul
2001-02-16 17:20                                   ` Jamie Lokier
2001-02-16 17:36                                     ` Linus Torvalds
2001-02-16 18:49                                       ` Manfred Spraul
2001-02-16 19:00                                         ` Linus Torvalds
2001-02-16 19:02                                         ` Ben LaHaise
2001-02-16 19:32                                           ` Linus Torvalds
2001-02-16 19:42                                             ` Ben LaHaise
2001-02-16 17:37                                   ` Jamie Lokier
2001-02-16 18:04                                     ` Manfred Spraul
2001-02-16 18:09                                       ` Jamie Lokier
2001-02-16 18:36                                     ` Hugh Dickins
2001-02-16 17:29                                 ` Ben LaHaise
2001-02-16 17:38                                   ` Linus Torvalds
2001-02-16 17:44                                     ` Ben LaHaise
2001-02-16 17:59                       ` Linus Torvalds
2001-02-15 23:57               ` Jamie Lokier
2001-02-16  0:55                 ` Linus Torvalds
2001-02-15 19:07         ` Jamie Lokier

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=20010216162741.A4284@pcep-jamie.cern.ch \
    --to=lk@tantalophile.demon.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=torvalds@transmeta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox