From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrea Arcangeli Subject: Re: [PATCH] mmu notifiers #v7 Date: Fri, 29 Feb 2008 01:40:01 +0100 Message-ID: <20080229004001.GN8091@v2.random> References: <20080219084357.GA22249@wotan.suse.de> <20080219135851.GI7128@v2.random> <20080219231157.GC18912@wotan.suse.de> <20080220010941.GR7128@v2.random> <20080220103942.GU7128@v2.random> <20080221045430.GC15215@wotan.suse.de> <20080221144023.GC9427@v2.random> <20080221161028.GA14220@sgi.com> <20080227192610.GF28483@v2.random> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Nick Piggin , Steve Wise , Peter Zijlstra , linux-mm@kvack.org, Kanoj Sarcar , Roland Dreier , Jack Steiner , linux-kernel@vger.kernel.org, Avi Kivity , kvm-devel@lists.sourceforge.net, daniel.blueman@quadrics.com, Robin Holt , general@lists.openfabrics.org, akpm@linux-foundation.org To: Christoph Lameter Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org On Thu, Feb 28, 2008 at 03:05:30PM -0800, Christoph Lameter wrote: > Still think that the lock here is not of too much use and can be easily > replaced by mmap_sem. I can use the mmap_sem. > > +#define mmu_notifier(function, mm, args...) \ > > + do { \ > > + struct mmu_notifier *__mn; \ > > + struct hlist_node *__n; \ > > + \ > > + if (unlikely(!hlist_empty(&(mm)->mmu_notifier.head))) { \ > > + rcu_read_lock(); \ > > + hlist_for_each_entry_rcu(__mn, __n, \ > > + &(mm)->mmu_notifier.head, \ > > + hlist) \ > > + if (__mn->ops->function) \ > > + __mn->ops->function(__mn, \ > > + mm, \ > > + args); \ > > + rcu_read_unlock(); \ > > + } \ > > + } while (0) > > Andrew recomended local variables for parameters used multile times. This > means the mm parameter here. I don't exactly see what "buggy macro" meant? I already use parenthesis as needed to avoid the need of local variables to be safe. Not really sure what's buggy, sorry! > Note also Andrew's comments on the use of 0x00ff... I thought I tried the (void) but it didn't work and your solution worked, but perhaps I did something wrong, I'll try again with (void) nevertheless. > > +/* > > + * No synchronization. This function can only be called when only a single > > + * process remains that performs teardown. > > + */ > > +void mmu_notifier_release(struct mm_struct *mm) > > +{ > > + struct mmu_notifier *mn; > > + struct hlist_node *n, *tmp; > > + > > + if (unlikely(!hlist_empty(&mm->mmu_notifier.head))) { > > + hlist_for_each_entry_safe(mn, n, tmp, > > + &mm->mmu_notifier.head, hlist) { > > + hlist_del(&mn->hlist); > > + if (mn->ops->release) > > + mn->ops->release(mn, mm); > > + } > > + } > > +} > > One could avoid a hlist_for_each_entry_safe here by simply always deleting > the first object. Agreed, the current construct come from the fact we previously didn't assume nobody could ever call mmu_notifier_unregister by the time mm_users is 0. > Also re the _notify variants: The binding to pte_clear_flush_young etc > will become a problem for notifiers that want to sleep because > pte_clear_flush is usually called with the pte lock held. See f.e. > try_to_unmap_one, page_mkclean_one etc. Calling __free_page out of the PT lock is much bigger change. do_wp_page will require changes anyway when the sleepable notifiers are merged. > It would be better if the notifier calls could be moved outside of the > pte lock. The point is that it can't make a difference right now, and my objective was to avoid unnecessary source code duplication (later it will be necessary, right now it isn't). By the time you rework do_wp_page, removing _notify will be a very minor detail compared to the rest of the changes to do_wp_page IMHO. Expanding it now won't provide a real advantage later. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/