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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 2DD92C47082 for ; Thu, 3 Jun 2021 07:41:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B76C06121D for ; Thu, 3 Jun 2021 07:41:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B76C06121D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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 E6C596B006C; Thu, 3 Jun 2021 03:41:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF5A26B006E; Thu, 3 Jun 2021 03:41:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C47B76B0070; Thu, 3 Jun 2021 03:41:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 887E66B006C for ; Thu, 3 Jun 2021 03:41:41 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 114AE180AD804 for ; Thu, 3 Jun 2021 07:41:41 +0000 (UTC) X-FDA: 78211618002.40.32744AC Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf29.hostedemail.com (Postfix) with ESMTP id 093E254C for ; Thu, 3 Jun 2021 07:41:22 +0000 (UTC) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0710B1FD4D; Thu, 3 Jun 2021 07:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622706099; 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=ebOYC51xpAwwJwmb6UgGBARcJyEnbBxqNxBGjsm4F68=; b=R9jVRWLA+7JbDRVrTV9C6BZPqXRHUgUWQQTk71NFEGxXroSA7qHLHNQtMgOgNQDES04tEG nBaZD/2uH8N5qovAgRZ9T28dUJj8cC8+Fn9Wo2ySu+idZZf+5MqYowuojO+SexvPWvnKJG 48e1INrOH0DQ92H+JMYU2JVuANFRg2o= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id A504FA3B84; Thu, 3 Jun 2021 07:41:38 +0000 (UTC) Date: Thu, 3 Jun 2021 09:41:38 +0200 From: Michal Hocko To: Feng Tang Cc: linux-mm@kvack.org, Andrew Morton , David Rientjes , Dave Hansen , Ben Widawsky , Andrea Arcangeli , Mel Gorman , Mike Kravetz , Randy Dunlap , Vlastimil Babka , Andi Kleen , Dan Williams , ying.huang@intel.com Subject: Re: [v4 PATCH 2/3] mm/mempolicy: don't handle MPOL_LOCAL like a fake MPOL_PREFERRED policy Message-ID: References: <1622560492-1294-1-git-send-email-feng.tang@intel.com> <1622560492-1294-3-git-send-email-feng.tang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1622560492-1294-3-git-send-email-feng.tang@intel.com> Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=R9jVRWLA; 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-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 093E254C X-Stat-Signature: wocyfw67z6a59cja49qi47u8emjmcfr3 X-HE-Tag: 1622706082-273025 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 Tue 01-06-21 23:14:51, Feng Tang wrote: > MPOL_LOCAL policy has been setup as a real policy, but it is still handled > like a faked POL_PREFERRED policy with one internal MPOL_F_LOCAL flag bit > set, and there are many places having to judge the real 'prefer' or the > 'local' policy, which are quite confusing. > > In current code, there are 4 cases that MPOL_LOCAL are used: > 1. user specifies 'local' policy > 2. user specifies 'prefer' policy, but with empty nodemask > 3. system 'default' policy is used > 4. 'prefer' policy + valid 'preferred' node with MPOL_F_STATIC_NODES > flag set, and when it is 'rebind' to a nodemask which doesn't > contains the 'preferred' node, it will perform as 'local' policy > > So make 'local' a real policy instead of a fake 'prefer' one, and kill > MPOL_F_LOCAL bit, which can greatly reduce the confusion for code reading. > > For case 4, the logic of mpol_rebind_preferred() is confusing, as Michal > Hocko pointed out: > > : I do believe that rebinding preferred policy is just bogus and it should > : be dropped altogether on the ground that a preference is a mere hint from > : userspace where to start the allocation. Unless I am missing something > : cpusets will be always authoritative for the final placement. The > : preferred node just acts as a starting point and it should be really > : preserved when cpusets changes. Otherwise we have a very subtle behavior > : corner cases. > > So dump all the tricky transformation between 'prefer' and 'local', > and just record the new nodemask of rebinding. > > Suggested-by: Michal Hocko > Signed-off-by: Feng Tang Acked-by: Michal Hocko But this having another pair of eyes would be definitely helpful. Still one nit though > @@ -234,30 +229,27 @@ static int mpol_set_nodemask(struct mempolicy *pol, > /* if mode is MPOL_DEFAULT, pol is NULL. This is right. */ > if (pol == NULL) > return 0; > + > + if (pol->mode == MPOL_LOCAL) > + return 0; > + This would benefit from a comment. The one above pol NULL check is just desperately unhelpful. I would go with the following /* * Default (pol==NULL) resp. local memory policies are not a * subject of any remapping. They also do not need any special * constructor. */ if (!pol || pol->mode == MPOL_LOCAL) return 0; > /* Check N_MEMORY */ > nodes_and(nsc->mask1, > cpuset_current_mems_allowed, node_states[N_MEMORY]); -- Michal Hocko SUSE Labs