Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp381647rwi; Thu, 27 Oct 2022 02:33:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4eO+tRVzCdOpacydhkh7lhQts4dRqIxFp1DpJeIk7IyXXCy38UaQF1IKhve7DaYHztOZ0e X-Received: by 2002:a63:2a81:0:b0:43c:5fa6:1546 with SMTP id q123-20020a632a81000000b0043c5fa61546mr40768182pgq.43.1666863207391; Thu, 27 Oct 2022 02:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666863207; cv=none; d=google.com; s=arc-20160816; b=ySuzE44v469pAAd3HQrWbQJ68oN1g2asllhjXMv/w700Ixkpc6DawBm4slhNhN12VS ZlouYWfilc5F9cShzr+i1uyolnXg+Gu0qj2vKeRZvV3X073mOuHKvcW5pdRUFc0/G34n MwV+GPuiE0F67uUU2r9WNDx1Afho3nzFUYuoCvVTgHUkT0KZ0u4LDIpZK5GrZ2r5g3BB qV69b/94qkhhcxT3xiPos5xOJHxAByygEa16S6MdqkouvbQTokOSoeiEHfbp0hTrkBu9 22AOZPr5WBssTQwCwtuFV+4HlQ8F74l1FrFZ+2tqTbRiRfBJWfBWmz6VW3xXIXNKoM2t fqfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=abWXMIW14QMmwLX6rgyw26Wf5wOTbYNMJll8QH7TOGE=; b=l4mBXlpXQwykHKxPHeB4eCbvb4tPYj/4FJZ2uZpGyWMbq7BVUqMXFGmoSZIaBQ4MYb WhSE2hpMXv65XFJMNyNBCYvgs9Hap/0QJRP1wgp1ebKNwqZW1b6zo3CEaCe8VXrcb6lA /MLc6kInafQwD0mqQjaYg+bMW2BCVSk8Jc1iMxG14xyeoPO8QyoVyL4mdG0EDpMWj+cL YJko4XrMggCkUH53xDFixi34Fi3dDsSXZn7nFQkheREO68vzR2Td3mYSZeLe9T4PKN3F miRjjUjOEQkkz6UyH+5PR6g3HcvmGl2u9WUqRhkFZRNuotcGRvFx46p+E0zj+BpvTM9D 8jZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=KmIPb4Kp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n20-20020a63a514000000b0043c69a39e26si962562pgf.215.2022.10.27.02.33.14; Thu, 27 Oct 2022 02:33:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=KmIPb4Kp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234036AbiJ0JC0 (ORCPT + 99 others); Thu, 27 Oct 2022 05:02:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233687AbiJ0JCY (ORCPT ); Thu, 27 Oct 2022 05:02:24 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E84B6EE17; Thu, 27 Oct 2022 02:02:21 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9933C1F90E; Thu, 27 Oct 2022 09:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1666861340; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=abWXMIW14QMmwLX6rgyw26Wf5wOTbYNMJll8QH7TOGE=; b=KmIPb4KptjOneG9xka1N5ZhLzgLficsjGClb7Rq1ztk9mUHdmyHdltHfVtUOSsV8n6NguH zEHucmecCAssl6eNHMVt8Tp99tm0dq02c//IqslDp9afk5YdErL5cE1DFDMIAr7DSQkoKb 2PyN9891NGvY96L0fFNckraQ2wjbat4= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7A2A513357; Thu, 27 Oct 2022 09:02:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id t1bpGxxJWmOLUgAAMHmgww (envelope-from ); Thu, 27 Oct 2022 09:02:20 +0000 Date: Thu, 27 Oct 2022 11:02:19 +0200 From: Michal Hocko To: Aneesh Kumar K V Cc: Feng Tang , Andrew Morton , Johannes Weiner , Tejun Heo , Zefan Li , Waiman Long , "Huang, Ying" , "linux-mm@kvack.org" , "cgroups@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Hansen, Dave" , "Chen, Tim C" , "Yin, Fengwei" Subject: Re: [PATCH] mm/vmscan: respect cpuset policy during page demotion Message-ID: References: <20221026074343.6517-1-feng.tang@intel.com> <44e485d4-acf5-865d-17fe-13be1c1b430b@linux.ibm.com> <22590f74-ec91-e673-32df-8a04b4ab3931@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22590f74-ec91-e673-32df-8a04b4ab3931@linux.ibm.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 26-10-22 18:05:46, Aneesh Kumar K V wrote: > On 10/26/22 5:51 PM, Michal Hocko wrote: > > On Wed 26-10-22 17:38:06, Aneesh Kumar K V wrote: > >> On 10/26/22 4:32 PM, Michal Hocko wrote: > >>> On Wed 26-10-22 16:12:25, Aneesh Kumar K V wrote: > >>>> On 10/26/22 2:49 PM, Michal Hocko wrote: > >>>>> On Wed 26-10-22 16:00:13, Feng Tang wrote: > >>>>>> On Wed, Oct 26, 2022 at 03:49:48PM +0800, Aneesh Kumar K V wrote: > >>>>>>> On 10/26/22 1:13 PM, Feng Tang wrote: > >>>>>>>> In page reclaim path, memory could be demoted from faster memory tier > >>>>>>>> to slower memory tier. Currently, there is no check about cpuset's > >>>>>>>> memory policy, that even if the target demotion node is not allowd > >>>>>>>> by cpuset, the demotion will still happen, which breaks the cpuset > >>>>>>>> semantics. > >>>>>>>> > >>>>>>>> So add cpuset policy check in the demotion path and skip demotion > >>>>>>>> if the demotion targets are not allowed by cpuset. > >>>>>>>> > >>>>>>> > >>>>>>> What about the vma policy or the task memory policy? Shouldn't we respect > >>>>>>> those memory policy restrictions while demoting the page? > >>>>>> > >>>>>> Good question! We have some basic patches to consider memory policy > >>>>>> in demotion path too, which are still under test, and will be posted > >>>>>> soon. And the basic idea is similar to this patch. > >>>>> > >>>>> For that you need to consult each vma and it's owning task(s) and that > >>>>> to me sounds like something to be done in folio_check_references. > >>>>> Relying on memcg to get a cpuset cgroup is really ugly and not really > >>>>> 100% correct. Memory controller might be disabled and then you do not > >>>>> have your association anymore. > >>>>> > >>>> > >>>> I was looking at this recently and I am wondering whether we should worry about VM_SHARE > >>>> vmas. > >>>> > >>>> ie, page_to_policy() can just reverse lookup just one VMA and fetch the policy right? > >>> > >>> How would that help for private mappings shared between parent/child? > >> > >> > >> this is MAP_PRIVATE | MAP_SHARED? > > > > Sorry, I meant MAP_ANONYMOUS | MAP_SHARED. I am still not sure where you are targeting to be honest. MAP_SHARED or MAP_PRIVATE both can have page shared between several vmas. -- Michal Hocko SUSE Labs