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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 45BE1C4707F for ; Thu, 27 May 2021 08:20:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C3105613AC for ; Thu, 27 May 2021 08:20:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3105613AC 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 073D26B0036; Thu, 27 May 2021 04:20:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F39CD6B006E; Thu, 27 May 2021 04:20:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD09F6B0070; Thu, 27 May 2021 04:20:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id 660FC6B0036 for ; Thu, 27 May 2021 04:20:11 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 077B54417 for ; Thu, 27 May 2021 08:20:11 +0000 (UTC) X-FDA: 78186313422.20.E350381 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf13.hostedemail.com (Postfix) with ESMTP id A9942E000806 for ; Thu, 27 May 2021 08:20:02 +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=1622103609; 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=XB8CgP16Z2uVxIEDkdauFJUwH6W3alLpLkpuqADlG0Q=; b=lD05TOJlHjh9PizvGAeHx9p6vrNW0J38GgxixQkpw1wMVGOE4caz3NdYUvE0m0OWJd5KBW 96bHjl6viBPLtiaNqGuF72MosQmk00vHmoREYzlcmKdq7z96ZYF7h5887fBcwP3ZUYS9E/ e2pt2BMM6CTlP+6v3C/HF34G4tWaOas= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 595AEAC3A; Thu, 27 May 2021 08:20:09 +0000 (UTC) Date: Thu, 27 May 2021 10:20:08 +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 4/4] mm/mempolicy: kill MPOL_F_LOCAL bit Message-ID: References: <1622005302-23027-1-git-send-email-feng.tang@intel.com> <1622005302-23027-5-git-send-email-feng.tang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1622005302-23027-5-git-send-email-feng.tang@intel.com> Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=lD05TOJl; spf=pass (imf13.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A9942E000806 X-Stat-Signature: pf3pyrthah8osfz9mby4ck3w9gdeygpa X-HE-Tag: 1622103602-931292 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-05-21 13:01:42, Feng Tang wrote: > Now the only remaining case of a real 'local' policy faked by > 'prefer' policy plus MPOL_F_LOCAL bit is: > > A valid 'prefer' policy with a valid 'preferred' node is 'rebind' > to a nodemask which doesn't contains the 'preferred' node, then it > will handle allocation with 'local' policy. > > Add a new 'MPOL_F_LOCAL_TEMP' bit for this case, and kill the > MPOL_F_LOCAL bit, which could simplify the code much. As I've pointed out in the reply to the previous patch. It would have been much better if most of the MPOL_F_LOCAL usage was gone by this patch. I also dislike a new MPOL_F_LOCAL_TEMP. This smells like sneaking the hack back in after you have painstakingly removed it. So this looks like a step backwards to me. I also do not understand why do we need the rebind callback for local policy at all. There is no node mask for local so what is going on here? [...] > +static void mpol_rebind_local(struct mempolicy *pol, > + const nodemask_t *nodes) > +{ > + if (unlikely(pol->flags & MPOL_F_STATIC_NODES)) { > + int node = first_node(pol->w.user_nodemask); > + > + BUG_ON(!(pol->flags & MPOL_F_LOCAL_TEMP)); > + > + if (node_isset(node, *nodes)) { > + pol->v.preferred_node = node; > + pol->mode = MPOL_PREFERRED; > + pol->flags &= ~MPOL_F_LOCAL_TEMP; > + } > + } > +} > + I have to confess I've got lost here. Could you explain why do you need all this handling for a local policy? > static void mpol_rebind_preferred(struct mempolicy *pol, > const nodemask_t *nodes) > { > @@ -347,13 +363,19 @@ static void mpol_rebind_preferred(struct mempolicy *pol, > > if (node_isset(node, *nodes)) { > pol->v.preferred_node = node; > - pol->flags &= ~MPOL_F_LOCAL; > - } else > - pol->flags |= MPOL_F_LOCAL; > + } else { > + /* > + * If there is no valid node, change the mode to > + * MPOL_LOCAL, which will be restored back when > + * next rebind() sees a valid node. > + */ > + pol->mode = MPOL_LOCAL; > + pol->flags |= MPOL_F_LOCAL_TEMP; > + } > } else if (pol->flags & MPOL_F_RELATIVE_NODES) { > mpol_relative_nodemask(&tmp, &pol->w.user_nodemask, nodes); > pol->v.preferred_node = first_node(tmp); > - } else if (!(pol->flags & MPOL_F_LOCAL)) { > + } else { > pol->v.preferred_node = node_remap(pol->v.preferred_node, > pol->w.cpuset_mems_allowed, > *nodes); > @@ -372,7 +394,7 @@ static void mpol_rebind_policy(struct mempolicy *pol, const nodemask_t *newmask) > { > if (!pol) > return; > - if (!mpol_store_user_nodemask(pol) && !(pol->flags & MPOL_F_LOCAL) && > + if (!mpol_store_user_nodemask(pol) && > nodes_equal(pol->w.cpuset_mems_allowed, *newmask)) > return; > > @@ -425,7 +447,7 @@ static const struct mempolicy_operations mpol_ops[MPOL_MAX] = { > }, > [MPOL_LOCAL] = { > .create = mpol_new_local, > - .rebind = mpol_rebind_default, > + .rebind = mpol_rebind_local, > }, > }; -- Michal Hocko SUSE Labs