From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 25 May 2004 15:00:09 -0700 (PDT) From: Linus Torvalds Subject: Re: [PATCH] ppc64: Fix possible race with set_pte on a present PTE In-Reply-To: Message-ID: References: <1085369393.15315.28.camel@gaston> <1085371988.15281.38.camel@gaston> <1085373839.14969.42.camel@gaston> <20040525034326.GT29378@dualathlon.random> <20040525114437.GC29154@parcelfarce.linux.theplanet.co.uk> <20040525153501.GA19465@foobazco.org> <20040525102547.35207879.davem@redhat.com> <20040525105442.2ebdc355.davem@redhat.com> <1085521251.24948.127.camel@gaston> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org Return-Path: To: Benjamin Herrenschmidt Cc: "David S. Miller" , wesolows@foobazco.org, willy@debian.org, Andrea Arcangeli , Andrew Morton , Linux Kernel list , mingo@elte.hu, bcrl@kvack.org, linux-mm@kvack.org, Linux Arch list List-ID: On Tue, 25 May 2004, Linus Torvalds wrote: > > > On Wed, 26 May 2004, Benjamin Herrenschmidt wrote: > > > > Well, just setting one of those 2 bits doesn't require a hash table > > invalidate as long as nothing else changes. > > Ok. And nothing ever writes to the SW page tables outside the page table > lock, right? So on ppc64, we could just do > > #define ptep_update_dirty_accessed(ptep, entry, dirty) \ > *(ptep) = (entry) > > and be done with it. No? No. I'm an idiot. We do need to keep the "hashed" bit atomically, so it would need to be something on the order of static inline void ptep_update_dirty_accessed(pte_t *ptep, pte_t entry, int dirty) { unsigned long bits = pte_value(entry) & (_PAGE_DIRTY | _PAGE_ACCESSED); unsigned long tmp; __asm__ __volatile__( "1: lwarx %0,0,%3\n\ or %0,%2,%0\n\ stwcx. %0,0,%3\n\ bne- 1b" :"=&r" (tmp), "=m" (*ptep) :"r" (bits), "r" (ptep) :"cc"); } /* Make asm-generic/pgtable.h know about it.. */ #define ptep_update_dirty_accessed ptep_update_dirty_accessed or whatever. Anyway, I don't feel competent enough to commit it, so.. Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: aart@kvack.org