From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754388Ab2BVVHD (ORCPT ); Wed, 22 Feb 2012 16:07:03 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35397 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451Ab2BVVHB (ORCPT ); Wed, 22 Feb 2012 16:07:01 -0500 Date: Wed, 22 Feb 2012 13:06:59 -0800 From: Andrew Morton To: Hillf Danton Cc: Linux-MM , LKML , Michal Hocko , KAMEZAWA Hiroyuki , Hugh Dickins Subject: Re: [PATCH] mm: hugetlb: bail out unmapping after serving reference page Message-Id: <20120222130659.d75b6f69.akpm@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 Feb 2012 20:35:34 +0800 Hillf Danton wrote: > When unmapping given VM range, we could bail out if a reference page is > supplied and it is unmapped, which is a minor optimization. > > Signed-off-by: Hillf Danton > --- > > --- a/mm/hugetlb.c Wed Feb 22 19:34:12 2012 > +++ b/mm/hugetlb.c Wed Feb 22 19:50:26 2012 > @@ -2280,6 +2280,9 @@ void __unmap_hugepage_range(struct vm_ar > if (pte_dirty(pte)) > set_page_dirty(page); > list_add(&page->lru, &page_list); > + > + if (page == ref_page) > + break; > } > spin_unlock(&mm->page_table_lock); > flush_tlb_range(vma, start, end); Perhaps add a little comment to this explaining what's going on? It would be sufficient to do if (ref_page) break; This is more efficient, and doesn't make people worry about whether this value of `page' is the same as the one which pte_page(huge_ptep_get()) earlier returned. Why do we evaluate `page' twice inside that loop anyway? And why do we check for huge_pte_none() twice? It looks all messed up.