Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3005162yba; Mon, 22 Apr 2019 17:38:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKHiMkPr+44v3mBgp5TQ+3BKpuV3vRf0T8NDO9ClCP9nUTq0cPyJ1scdMHht09lxbpa0lt X-Received: by 2002:a62:62c3:: with SMTP id w186mr23092188pfb.73.1555979901065; Mon, 22 Apr 2019 17:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555979901; cv=none; d=google.com; s=arc-20160816; b=DE3iJQ/RKbb3fKq2lYAVC9LmBpyiu+tkaOC+e5gV2NnsYVxDZOANI2LSlOM2cY+/Yq Y8JP2Y1srl1ytErgO+1kpzl0/s6ZHPG20S88BcZZeX0YCTVacDrWOgyr+c6/7652yzwR HroUet2eR3aQK8XueeozHFKGNSTzfMUuWIxI4ZaJRNjiOU2E+Y8SdZDvsI9rJvZsXgjl 0puGijC3z56574o9Owus/C4Jh4nRMvoYgFYEeWM9FZV79QRQbmr/w2XbYqU3O3GCuhGz R+lJtTjvQkzn8a1ZaAAIqj36eMn7Po9bpNjdPpVwvDblzjE+gAirqFUWQCeEIO8aFwY+ bUuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=7Izj+DWXH3+Wsi34otsLo96Ls123Pc9kPSHyJW0hfAY=; b=Gg59SJUN48E4R1IUUTX4xdr75jlc5MRV4npkSlQH2mcbVbngJLeVbDEzUrobDeWN7G l1vFAhua301udFRIuuB2mRNKbGHhXSIWpo9xMbMuFLQyVS1sD9J8jyRGjvQbCpRlXt40 1OhReJKobVeK2COmR2NK3PK2QGGs3VCaXNFdg6Kksp8+4xlpHWzO3fltp0fp/6r90Tq6 I1CUMW/cWNLCGOdDaUbqDa9Qokj1jufC6lyKdAtphjfglyfSaqDKU8kO0BW5PKQ0vj17 gBzVLrVGCr+quS+0MdukZTMvgZkdye6DegITmlMvKfa3ZQrtL1KLVWVlYGX29kwLo+2i kJmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t69si14657818pfa.7.2019.04.22.17.38.05; Mon, 22 Apr 2019 17:38:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732630AbfDVULe (ORCPT + 99 others); Mon, 22 Apr 2019 16:11:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52616 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728687AbfDVULd (ORCPT ); Mon, 22 Apr 2019 16:11:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F1AFC13070F; Mon, 22 Apr 2019 20:11:32 +0000 (UTC) Received: from redhat.com (unknown [10.20.6.236]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B7F05D9D4; Mon, 22 Apr 2019 20:11:28 +0000 (UTC) Date: Mon, 22 Apr 2019 16:11:26 -0400 From: Jerome Glisse To: Laurent Dufour Cc: akpm@linux-foundation.org, mhocko@kernel.org, peterz@infradead.org, kirill@shutemov.name, ak@linux.intel.com, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , aneesh.kumar@linux.ibm.com, benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon , Sergey Senozhatsky , sergey.senozhatsky.work@gmail.com, Andrea Arcangeli , Alexei Starovoitov , kemi.wang@intel.com, Daniel Jordan , David Rientjes , Ganesh Mahendran , Minchan Kim , Punit Agrawal , vinayak menon , Yang Shi , zhong jiang , Haiyan Song , Balbir Singh , sj38.park@gmail.com, Michel Lespinasse , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, npiggin@gmail.com, paulmck@linux.vnet.ibm.com, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: Re: [PATCH v12 15/31] mm: introduce __lru_cache_add_active_or_unevictable Message-ID: <20190422201126.GF14666@redhat.com> References: <20190416134522.17540-1-ldufour@linux.ibm.com> <20190416134522.17540-16-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190416134522.17540-16-ldufour@linux.ibm.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 22 Apr 2019 20:11:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 16, 2019 at 03:45:06PM +0200, Laurent Dufour wrote: > The speculative page fault handler which is run without holding the > mmap_sem is calling lru_cache_add_active_or_unevictable() but the vm_flags > is not guaranteed to remain constant. > Introducing __lru_cache_add_active_or_unevictable() which has the vma flags > value parameter instead of the vma pointer. > > Acked-by: David Rientjes > Signed-off-by: Laurent Dufour Reviewed-by: J?r?me Glisse > --- > include/linux/swap.h | 10 ++++++++-- > mm/memory.c | 8 ++++---- > mm/swap.c | 6 +++--- > 3 files changed, 15 insertions(+), 9 deletions(-) > > diff --git a/include/linux/swap.h b/include/linux/swap.h > index 4bfb5c4ac108..d33b94eb3c69 100644 > --- a/include/linux/swap.h > +++ b/include/linux/swap.h > @@ -343,8 +343,14 @@ extern void deactivate_file_page(struct page *page); > extern void mark_page_lazyfree(struct page *page); > extern void swap_setup(void); > > -extern void lru_cache_add_active_or_unevictable(struct page *page, > - struct vm_area_struct *vma); > +extern void __lru_cache_add_active_or_unevictable(struct page *page, > + unsigned long vma_flags); > + > +static inline void lru_cache_add_active_or_unevictable(struct page *page, > + struct vm_area_struct *vma) > +{ > + return __lru_cache_add_active_or_unevictable(page, vma->vm_flags); > +} > > /* linux/mm/vmscan.c */ > extern unsigned long zone_reclaimable_pages(struct zone *zone); > diff --git a/mm/memory.c b/mm/memory.c > index 56802850e72c..85ec5ce5c0a8 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -2347,7 +2347,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) > ptep_clear_flush_notify(vma, vmf->address, vmf->pte); > page_add_new_anon_rmap(new_page, vma, vmf->address, false); > mem_cgroup_commit_charge(new_page, memcg, false, false); > - lru_cache_add_active_or_unevictable(new_page, vma); > + __lru_cache_add_active_or_unevictable(new_page, vmf->vma_flags); > /* > * We call the notify macro here because, when using secondary > * mmu page tables (such as kvm shadow page tables), we want the > @@ -2896,7 +2896,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > if (unlikely(page != swapcache && swapcache)) { > page_add_new_anon_rmap(page, vma, vmf->address, false); > mem_cgroup_commit_charge(page, memcg, false, false); > - lru_cache_add_active_or_unevictable(page, vma); > + __lru_cache_add_active_or_unevictable(page, vmf->vma_flags); > } else { > do_page_add_anon_rmap(page, vma, vmf->address, exclusive); > mem_cgroup_commit_charge(page, memcg, true, false); > @@ -3048,7 +3048,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) > inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES); > page_add_new_anon_rmap(page, vma, vmf->address, false); > mem_cgroup_commit_charge(page, memcg, false, false); > - lru_cache_add_active_or_unevictable(page, vma); > + __lru_cache_add_active_or_unevictable(page, vmf->vma_flags); > setpte: > set_pte_at(vma->vm_mm, vmf->address, vmf->pte, entry); > > @@ -3327,7 +3327,7 @@ vm_fault_t alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg, > inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES); > page_add_new_anon_rmap(page, vma, vmf->address, false); > mem_cgroup_commit_charge(page, memcg, false, false); > - lru_cache_add_active_or_unevictable(page, vma); > + __lru_cache_add_active_or_unevictable(page, vmf->vma_flags); > } else { > inc_mm_counter_fast(vma->vm_mm, mm_counter_file(page)); > page_add_file_rmap(page, false); > diff --git a/mm/swap.c b/mm/swap.c > index 3a75722e68a9..a55f0505b563 100644 > --- a/mm/swap.c > +++ b/mm/swap.c > @@ -450,12 +450,12 @@ void lru_cache_add(struct page *page) > * directly back onto it's zone's unevictable list, it does NOT use a > * per cpu pagevec. > */ > -void lru_cache_add_active_or_unevictable(struct page *page, > - struct vm_area_struct *vma) > +void __lru_cache_add_active_or_unevictable(struct page *page, > + unsigned long vma_flags) > { > VM_BUG_ON_PAGE(PageLRU(page), page); > > - if (likely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) != VM_LOCKED)) > + if (likely((vma_flags & (VM_LOCKED | VM_SPECIAL)) != VM_LOCKED)) > SetPageActive(page); > else if (!TestSetPageMlocked(page)) { > /* > -- > 2.21.0 >