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.7 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,URIBL_BLOCKED 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 6C44CC4707F for ; Thu, 27 May 2021 12:16:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 11C4361059 for ; Thu, 27 May 2021 12:16:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11C4361059 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 88F0C6B0036; Thu, 27 May 2021 08:16:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8371A6B006E; Thu, 27 May 2021 08:16:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F6276B0070; Thu, 27 May 2021 08:16:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id EDA576B0036 for ; Thu, 27 May 2021 08:16:39 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 804338249980 for ; Thu, 27 May 2021 12:16:39 +0000 (UTC) X-FDA: 78186909318.26.5B55D2B Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf22.hostedemail.com (Postfix) with ESMTP id 275D1C0042EC for ; Thu, 27 May 2021 12:16:31 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622117797; 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=6wkJVTjtj0SOxpAXDD4PWLluAmn8GdGlIAAMNZ9zTuQ=; b=VXxZiLlfCVJ9WNr0xIo9wky1/9y3qkUqxtFqYQ57wt9xjXgAiAi0Kd0ilmafJxZv+euobL RnmUveOkYR8cwnHFP9wu80w9lfP+xm9T4625u3EChIfR896eJXrWuHjhFcUsj+pmsHKkn3 PMazkvyJbtQ+e8Sh5LTcwddBnHedVKY= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A6A32AD19; Thu, 27 May 2021 12:16:37 +0000 (UTC) Date: Thu, 27 May 2021 14:16:36 +0200 From: Michal Hocko To: Feng Tang 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: References: <1622005302-23027-1-git-send-email-feng.tang@intel.com> <1622005302-23027-4-git-send-email-feng.tang@intel.com> <20210527120642.GA85753@shbuild999.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210527120642.GA85753@shbuild999.sh.intel.com> Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=VXxZiLlf; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf22.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 275D1C0042EC X-Stat-Signature: d5qcqih6smwsr41hkftywsjcgbxijnrc X-HE-Tag: 1622117791-984367 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 Thu 27-05-21 20:06:42, Feng Tang wrote: > 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 Please don't and handle the above and those below in a single patch. > 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 -- Michal Hocko SUSE Labs