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 X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 3E9FEC4707F for ; Thu, 27 May 2021 12:06:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DE39860FE8 for ; Thu, 27 May 2021 12:06:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE39860FE8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1E96D6B0036; Thu, 27 May 2021 08:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16CC46B006E; Thu, 27 May 2021 08:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF0946B0070; Thu, 27 May 2021 08:06:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id 7B78C6B0036 for ; Thu, 27 May 2021 08:06:53 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 196A41E0D for ; Thu, 27 May 2021 12:06:53 +0000 (UTC) X-FDA: 78186884706.38.D86CA4F Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf18.hostedemail.com (Postfix) with ESMTP id 6C85F200099A for ; Thu, 27 May 2021 12:06:44 +0000 (UTC) IronPort-SDR: V7azD2Q+cNRzSPFCwI+A6TtZfgMnGyYkidE/MsgY8ReepbWlHsN9snp0W1H/w17Zz5VVDUpp9O 2OJHhIkd5fyg== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="266605381" X-IronPort-AV: E=Sophos;i="5.82,334,1613462400"; d="scan'208";a="266605381" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2021 05:06:47 -0700 IronPort-SDR: 6dMBmsoiyi2tlDJUNAFJYwIR7h9/PdVjoY4FOZJFvyli6+W18HJCASDPQpKYQoKyWFTWpSMS3M YPRebWN414lw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,334,1613462400"; d="scan'208";a="477456220" Received: from shbuild999.sh.intel.com (HELO localhost) ([10.239.147.94]) by orsmga001.jf.intel.com with ESMTP; 27 May 2021 05:06:43 -0700 Date: Thu, 27 May 2021 20:06:42 +0800 From: Feng Tang To: Michal Hocko Cc: linux-mm@kvack.org, Andrew Morton , David Rientjes , Dave Hansen , Ben Widawsky , linux-kernel@vger.kernel.org, Andrea Arcangeli , Mel Gorman , Mike Kravetz , Randy Dunlap , Vlastimil Babka , Andi Kleen , Dan Williams , ying.huang@intel.com Subject: Re: [PATCH v1 3/4] mm/mempolicy: don't handle MPOL_LOCAL like a fake MPOL_PREFERRED policy Message-ID: <20210527120642.GA85753@shbuild999.sh.intel.com> References: <1622005302-23027-1-git-send-email-feng.tang@intel.com> <1622005302-23027-4-git-send-email-feng.tang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf18.hostedemail.com: domain of feng.tang@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=feng.tang@intel.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6C85F200099A X-Stat-Signature: ks6nm6f64q55fcpp9qdqsfeotxncgegw X-HE-Tag: 1622117204-713809 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: Hi Michal, Many thanks for the reivews! On Thu, May 27, 2021 at 10:12:15AM +0200, Michal Hocko wrote: > On Wed 26-05-21 13:01:41, 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 four cases that MPOL_LOCAL are used: > > * user specifies 'local' policy > > * user specifies 'prefer' policy, but with empty nodemask > > * system 'default' policy is used > > * '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 add the MPOL_F_LOCAL bit > > and performs as 'local' policy. In future if it is 'rebind' again > > with valid nodemask, the policy will be restored back to 'prefer' > > > > So for the first three cases, we make 'local' a real policy > > instead of a fake 'prefer' one, this will reduce confusion for > > reading code. > > > > And next optional patch will kill the 'MPOL_F_LOCAL' bit. > > I do like this approach. An additional policy should be much easier to > grasp than a special casing. This code is quite tricky so another pair > of eyes would be definitely good for the review. > > > Signed-off-by: Feng Tang > > Acked-by: Michal Hocko Thanks! > Just few nits. > > > static int migrate_page_add(struct page *page, struct list_head *pagelist, > > @@ -1965,6 +1965,8 @@ unsigned int mempolicy_slab_node(void) > > &policy->v.nodes); > > return z->zone ? zone_to_nid(z->zone) : node; > > } > > + case MPOL_LOCAL: > > + return node; > > Any reason you haven't removed MPOL_F_LOCAL in this and following > functions? It would make it much more easier to review this patch if > there was no actual use of the flag in the code after this patch. As in the commit log, there are 4 cases using 'prefer' + MPOL_F_LOCAL to represent 'local' policy. I'm confident in this patch which handle the case 1/2/3, while not sure if the solution (patch 4/4) for case 4 is the right method. So I separte them into 3/4 and 4/4 Thanks, Feng > > > > default: > > BUG(); > > @@ -2089,6 +2091,11 @@ bool init_nodemask_of_mempolicy(nodemask_t *mask) > > *mask = mempolicy->v.nodes; > > break; > > > > + case MPOL_LOCAL: > > + nid = numa_node_id(); > > + init_nodemask_of_node(mask, nid); > > + break; > > + > > default: > > BUG(); > > } > > @@ -2333,6 +2340,8 @@ bool __mpol_equal(struct mempolicy *a, struct mempolicy *b) > > if (a->flags & MPOL_F_LOCAL) > > return true; > > return a->v.preferred_node == b->v.preferred_node; > > + case MPOL_LOCAL: > > + return true; > > default: > > BUG(); > > return false; > > @@ -2476,6 +2485,10 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long > > polnid = pol->v.preferred_node; > > break; > > > > + case MPOL_LOCAL: > > + polnid = numa_node_id(); > > + break; > > + > > case MPOL_BIND: > > /* Optimize placement among multiple nodes via NUMA balancing */ > > if (pol->flags & MPOL_F_MORON) { > -- > Michal Hocko > SUSE Labs