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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FE9FC38A2D for ; Thu, 27 Oct 2022 09:02:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39A018E0002; Thu, 27 Oct 2022 05:02:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 322BA8E0001; Thu, 27 Oct 2022 05:02:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C35A8E0002; Thu, 27 Oct 2022 05:02:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0BAF38E0001 for ; Thu, 27 Oct 2022 05:02:24 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C8714AB7FE for ; Thu, 27 Oct 2022 09:02:23 +0000 (UTC) X-FDA: 80066138166.24.D9910AF Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf15.hostedemail.com (Postfix) with ESMTP id 41685A0042 for ; Thu, 27 Oct 2022 09:02:22 +0000 (UTC) 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> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666861342; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=abWXMIW14QMmwLX6rgyw26Wf5wOTbYNMJll8QH7TOGE=; b=HGx25Do0swBZNdPS/bVYUekFffcW8meC2D3QPV/3z2/dE1rQXuaSHRce1+JL9VEJN2aL17 7EBhKur06fQl041N5GO/bHo7MyMVzdfRQw2dRihuIkkfemHJgkufxG3Vm1Dw+tvRFouxXt Y3Lr21bprhG1Y8hEoFLzNKQanEz1ia0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=KmIPb4Kp; spf=pass (imf15.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666861342; a=rsa-sha256; cv=none; b=I9Pivm8jDLhEGosnKv3uEOvJN6apQ7doIXetM2ntdcB0XRUAjW0QDCTJDyM6vZRMFYuSdW IvynCS2z9o1cQqg9tBJHJhUOMZrDr55u0Xoooeq3cbC451ahdKnYlwED1M/LIsPNkzfYiC Fb5mCzWpNojcI8bzJ5ylmdoDYHyr60Q= X-Rspamd-Queue-Id: 41685A0042 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=KmIPb4Kp; spf=pass (imf15.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: tgamcm14guauitq8er3obkkpuhzzrunh X-HE-Tag: 1666861342-921056 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 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