From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEDA2C432C3 for ; Fri, 15 Nov 2019 13:25:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A823B206CC for ; Fri, 15 Nov 2019 13:25:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A823B206CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1B60C6B000C; Fri, 15 Nov 2019 08:25:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 167046B000E; Fri, 15 Nov 2019 08:25:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 056A56B0010; Fri, 15 Nov 2019 08:25:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id E43786B000C for ; Fri, 15 Nov 2019 08:25:22 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id AB70E181AEF21 for ; Fri, 15 Nov 2019 13:25:22 +0000 (UTC) X-FDA: 76158583284.24.idea31_2edf5f098285a X-HE-Tag: idea31_2edf5f098285a X-Filterd-Recvd-Size: 3865 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Nov 2019 13:25:21 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 12722B29D; Fri, 15 Nov 2019 13:25:19 +0000 (UTC) Date: Fri, 15 Nov 2019 14:25:18 +0100 From: Michal Hocko To: "lixinhai.lxh@gmail.com" Cc: David Hildenbrand , "linux-mm@kvack.org" , akpm Subject: Re: [PATCH] mm: Improve PageAnon() to check the whole PAGE_MAPPING_FLAGS Message-ID: <20191115132518.GC29990@dhcp22.suse.cz> References: <1573787903-2023-1-git-send-email-lixinhai.lxh@gmail.com> <2019111513593472959835@gmail.com> <2019111521095345906413@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <2019111521095345906413@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri 15-11-19 21:09:55, lixinhai.lxh@gmail.com wrote: > On 2019-11-15=A0at 20:50=A0David Hildenbrand=A0wrote: > >On 15.11.19 06:59, lixinhai.lxh@gmail.com wrote: > >> On 2019-11-15=A0at 11:18=A0Li Xinhai=A0wrote: > >>> PageAnon() just checking on PAGE_MAPPING_ANON bit would cause page, > >>> with PageKsm as true, been wrongly considered as PageAnon. Now, > >>> checking the whole PAGE_MAPPING_FLAGS to avoid this error. > >>> > >>> Reported from: > >>> https://lore.kernel.org/linux-mm/20191113000651.20677-1-rcampbell@n= vidia.com/ > >>> > >>> Reported-by: Ralph Campbell > >>> Cc: Andrew Morton > >>> Cc: Michal Hocko > >>> Signed-off-by: Li Xinhai > >>> --- > >>> include/linux/page-flags.h | 3 ++- > >>> 1 file changed, 2 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.= h > >>> index 1bf83c8..1849fc3 100644 > >>> --- a/include/linux/page-flags.h > >>> +++ b/include/linux/page-flags.h > >>> @@ -461,7 +461,8 @@ static __always_inline int PageMappingFlags(str= uct page *page) > >>> static __always_inline int PageAnon(struct page *page) > >>> { > >>> page =3D compound_head(page); > >>> - return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) !=3D 0; > >>> + return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) =3D=3D > >>> + PAGE_MAPPING_ANON; > >>> } > >>> > >>> static __always_inline int __PageMovable(struct page *page) > >>> -- > >>> 1.8.3.1 > >>> > >> > >> The current semantics of PageAnon() for both KSM and !KSM are used i= n many > >> places, so can't change it alone without change other code. > >> Need skip this patch. > > > >... I assume that was intended because KSM only merges anonymous pages= ? > >If it was not intended, it would scream for a cleanup. > >=20 > Yes, I think that was intended to keep the origial version of PageAnon(= ) when add the=20 > PageKsm(). So all places where used to have PageAnon() didn't requre ch= ange, but other > places for new code we have some thing like (PageAnon() && !PageKsm()) = check, or do=20 > checking in correct sequence. >=20 > One thing I am not quite sure is about couting of anonymous page, in ca= se page is KSM=20 > or !KSM, hope those old codes has been correctly handled.=A0 I am not really sure I understand what do you like to achieve here. Yes there are different checks representing different classes of pages. In this particular case the ordering of the check was just wrong. That is trivial to be fixed. PageAnon works as intented AFAIK. If that is not the case then please be explicit why. --=20 Michal Hocko SUSE Labs