From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeremy Fitzhardinge Subject: Re: [PATCH 1 of 4] mm: add a ptep_modify_prot transaction abstraction Date: Wed, 18 Jun 2008 17:37:27 -0700 Message-ID: <4859AA47.2020903@goop.org> References: <1213831403.8011.24.camel@pasglop> <4859A149.9090004@goop.org> <4859A528.1010107@goop.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Linus Torvalds Cc: xen-devel , Peter Zijlstra , kvm-devel , benh@kernel.crashing.org, x86@kernel.org, LKML , Virtualization Mailing List , Hugh Dickins , Ingo Molnar , Thomas Gleixner List-Id: virtualization@lists.linuxfoundation.org Linus Torvalds wrote: > On Wed, 18 Jun 2008, Jeremy Fitzhardinge wrote: > >> Along the lines of: >> > > Hell no. There's a reason we have a special set_wrprotect() thing. We can > do it more efficiently on native hardware by just clearing the bit > atomically. No need to do the cmpxchg games. > It's not cmpxchg, just xchg. In other words, is: lock btr $_PAGE_BIT_RW, (%rbx) much cheaper than mov $0, %rax xchg %rax, (%rbx) and $~_PAGE_RW, %rax mov %rax, (%rbx) ? It's the same number of locked RMW operations, so aside from being a few instructions longer, I think it would be much the same. I guess the correct answer is "lmbench". J