Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp685333rwi; Wed, 26 Oct 2022 06:07:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pwx+z/9GqaDuPPUp/1FlwYrO8mZZ4ww4U2YaQaC9nDhpqSvuEj/l0wVhxV1wsZb8D03u7 X-Received: by 2002:a63:2ad8:0:b0:46e:bb8e:b343 with SMTP id q207-20020a632ad8000000b0046ebb8eb343mr23378080pgq.408.1666789663919; Wed, 26 Oct 2022 06:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666789663; cv=none; d=google.com; s=arc-20160816; b=kFg69yG5HGo/nUqibVuXdCqO9tDq7PKwKA+QUSBj0xIf5g3ylNfdbQWsMcrIS4Bg4b Gx9vuYGKg4Wm/Aw6OxQJXvTaH/RY/Nb80gQ0YxF/8TskG5jubpkus+g5IYuQjjEKWR1z MRnFzddetdVHWN59229ON+ds9b+7/8QmAfnsV3jCc6kmWlr7grBU40KADlhN0UCa71+q yjpC3alNzrRp01K6100NAGoHZQWkyH0v6ejxLQ0pYz1E4DhxUYPMV1/0FvhouKp7WVji z8+vzRXzWNwUWFa33o7NRhWVAfnza9WRpNxeHWo/vwAcZwsw01b4fM5xCg7Ok2KU3GC7 HRCw== 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=stwyNrefmhSrw8ppEzQNvMc29Kx0uiDfudCufTdmCGM=; b=PuXJRnY4GGvliHJ8V05hgekirwmBBcB5yr0eTpseujD9Lb8/l1+3Gm+FJqx3gVUymE 2WZ94//XR8O3l92YJucgO1QcsVl68/mQYnQGkKqEwUQEJxk8m9VTLQaYDIHDKjMuJISa r/KgkLTnIMf5pIkz3jrNHk9/X7QIXdjNfgHVxpF9miLXP7y6NRvzRntYDxbga3hJ8Kbq zXO4piTph2NPrZjHoR90An9HJFo26Oj5TEiT/j0Bs7A8bT1Kl9X14VVV8WXECi+gCw2F JAul0xCWvk632g4roja8GvnEaPls6OOpmPs4IfCrAfWY/d971TRlwrVMe2Tn30U5A7QJ WDag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=h4NGPvxQ; 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 g7-20020a1709029f8700b0018668e41784si6223112plq.13.2022.10.26.06.07.31; Wed, 26 Oct 2022 06:07:43 -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=h4NGPvxQ; 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 S233572AbiJZMVT (ORCPT + 99 others); Wed, 26 Oct 2022 08:21:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233009AbiJZMVS (ORCPT ); Wed, 26 Oct 2022 08:21:18 -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 C0E6B85597; Wed, 26 Oct 2022 05:21:15 -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 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> 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,URIBL_BLOCKED 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 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