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 81D2EC433FE for ; Wed, 26 Oct 2022 12:21:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2335C8E0003; Wed, 26 Oct 2022 08:21:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 195B48E0001; Wed, 26 Oct 2022 08:21:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 010258E0003; Wed, 26 Oct 2022 08:21:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E50828E0001 for ; Wed, 26 Oct 2022 08:21:16 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BA41F40F3C for ; Wed, 26 Oct 2022 12:21:16 +0000 (UTC) X-FDA: 80063010552.09.11D0607 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf29.hostedemail.com (Postfix) with ESMTP id DFEB0120048 for ; Wed, 26 Oct 2022 12:21:15 +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 579231F8BE; Wed, 26 Oct 2022 12:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1666786874; 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=stwyNrefmhSrw8ppEzQNvMc29Kx0uiDfudCufTdmCGM=; b=h4NGPvxQAvmYcOQAcqLhGHjHFLpeODtWyPXeWpOJ/M8Xb1AVRvurQrYS76hwRzaDG4wibb rPherkc7CwQHQIMqW6AirPDBmhmF0N3JvYLy/JT1aQjl5blqf1AjnHUVZ0007JwCHx4XGx oD0pqddYyE7kqh6rV9Xy+Yv4aejT4HA= 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 38F3413A77; Wed, 26 Oct 2022 12:21:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UMwBCzomWWOmPgAAMHmgww (envelope-from ); Wed, 26 Oct 2022 12:21:14 +0000 Date: Wed, 26 Oct 2022 14:21:13 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44e485d4-acf5-865d-17fe-13be1c1b430b@linux.ibm.com> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666786876; 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=stwyNrefmhSrw8ppEzQNvMc29Kx0uiDfudCufTdmCGM=; b=VquNWrG59ALr773gFf9Vq/pBpH25HhzryZZ89MvowTwnIuAP3QiQ585F4NGA5XRPED7MWo VVmatznECrrOyDvSP3vfuowqAU1U5zJTF6d29AxM8wdJ8gC55wfmwlwxFvGaY15Aoihd3P 4Qznj2Xb+iMfKI5oei4W6giWLJI78Lc= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=h4NGPvxQ; spf=pass (imf29.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=1666786876; a=rsa-sha256; cv=none; b=taU780kUSFTIsrSaOLtavJMLwDRxajnxoFmgKuhi1CV3e9NWaEMyJUNd7jEpt3bIH8f8oM d0lIgYE7zynU7NMfTsI2642GehhIIS8MxJZ/tUSekbOSGp49gXeIJo15rfbsFcGorQnSeO 2ytu2MYAjcf8QQLmvJGszpLp+0ziNAA= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: DFEB0120048 X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=h4NGPvxQ; spf=pass (imf29.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-Stat-Signature: gxn9jip64h4iak1b9z5tziwoh7yjw968 X-HE-Tag: 1666786875-152603 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 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? This is not a valid combination IIRC. What I meant is a simple MAP_PRIVATE|MAP_ANON that is CoW shared between parent and child. [...] -- Michal Hocko SUSE Labs