linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Feng Tang <feng.tang@intel.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	David Rientjes <rientjes@google.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Ben Widawsky <ben.widawsky@intel.com>,
	linux-kernel@vger.kernel.org,
	Andrea Arcangeli <aarcange@redhat.com>,
	Mel Gorman <mgorman@techsingularity.net>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Vlastimil Babka <vbabka@suse.cz>, Andi Kleen <ak@linux.intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	ying.huang@intel.com
Subject: Re: [PATCH v1 4/4] mm/mempolicy: kill MPOL_F_LOCAL bit
Date: Mon, 31 May 2021 09:00:25 +0200	[thread overview]
Message-ID: <YLSJiV0tLPvCTnjG@dhcp22.suse.cz> (raw)
In-Reply-To: <20210528043954.GA32292@shbuild999.sh.intel.com>

On Fri 28-05-21 12:39:54, Feng Tang wrote:
> On Thu, May 27, 2021 at 05:34:56PM +0200, Michal Hocko wrote:
> > On Thu 27-05-21 21:34:36, Feng Tang wrote:
> > > On Thu, May 27, 2021 at 02:26:24PM +0200, Michal Hocko wrote:
> > > > On Thu 27-05-21 20:10:41, Feng Tang wrote:
> > > > > On Thu, May 27, 2021 at 10:20:08AM +0200, Michal Hocko wrote:
> > > > > > 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?
> > > > > 
> > > > > This is the special case 4 for 'perfer' policy with MPOL_F_STATIC_NODES
> > > > > flag set, say it prefer node 1, when it is later 'refind' to a new
> > > > > nodemask node 2-3, according to current code it will be add the
> > > > > MPOL_F_LOCAL bit and performs 'local' policy acctually. And in future
> > > > > it is 'rebind' again with a nodemask 1-2, it will be restored back
> > > > > to 'prefer' policy with preferred node 1.
> > > > 
> > > > Honestly I still do not follow the actual problem. 
> > > 
> > > I was confused too, and don't know the original thought behind it. This
> > > case 4 was just imagined by reading the code.
> > > 
> > > > A preferred node is a
> > > > _hint_. If you rebind the task to a different cpuset then why should we
> > > > actually care? The allocator will fallback to the closest node according
> > > > to the distance metric. Maybe the original code was trying to handle
> > > > that in some way but I really do fail to understand that code and I
> > > > strongly suspect it is more likely to overengineered rather than backed
> > > > by a real usecase. I might be wrong here but then this is an excellent
> > > > opportunity to clarify all those subtleties.
> > > 
> > > From the code, the original special handling may be needed in 3 cases:
> > >     get_policy_nodemask()
> > >     policy_node()
> > >     mempolicy_slab_node()
> > > to not return the preset prefer_nid.
> > 
> > I am sorry but I do not follow. What is actually wrong if the preferred
> > node is outside of the cpuset nodemask?
> 
> Sorry, I didn't make it clear. With current code logic, it will perform
> as 'local' policy, but its mode is kept as 'prefer', so the code still
> has these tricky bit checking when these APIs are called for this policy.
> I agree with you that these ping-pong rebind() may be over engineering,
> so for this case can we just change the policy from 'prefer' to 'local',
> and drop the tricky bit manipulation, as the 'prefer' is just a hint,
> if these rebind misses the target node, there is no need to stick with
> the 'prefer' policy?

Again. I really do not understand why we should rebind or mark as local
anything here. Is this a documented/expected behavior? What if somebody
just changes the cpuset to include the preferred node again. Is it
expected to have local preference now?

I can see you have posted a newer version which I haven't seen yet but
this is really better to get resolved before building up more on top.
And let me be explicit. 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.
-- 
Michal Hocko
SUSE Labs


  reply	other threads:[~2021-05-31  7:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26  5:01 [PATCH v1 0/4] mm/mempolicy: some fix and semantics cleanup Feng Tang
2021-05-26  5:01 ` [PATCH v1 1/4] mm/mempolicy: skip nodemask intersect check for 'interleave' when oom Feng Tang
2021-05-27  7:30   ` Michal Hocko
2021-05-27 13:05     ` Feng Tang
2021-05-27 13:15       ` Michal Hocko
2021-05-27 13:22         ` Feng Tang
2021-05-26  5:01 ` [PATCH v1 2/4] mm/mempolicy: unify the preprocessing for mbind and set_mempolicy Feng Tang
2021-05-27  7:39   ` Michal Hocko
2021-05-27 12:31     ` Feng Tang
2021-05-26  5:01 ` [PATCH v1 3/4] mm/mempolicy: don't handle MPOL_LOCAL like a fake MPOL_PREFERRED policy Feng Tang
2021-05-27  8:12   ` Michal Hocko
2021-05-27 12:06     ` Feng Tang
2021-05-27 12:16       ` Michal Hocko
2021-05-26  5:01 ` [PATCH v1 4/4] mm/mempolicy: kill MPOL_F_LOCAL bit Feng Tang
2021-05-27  8:20   ` Michal Hocko
2021-05-27 12:10     ` Feng Tang
2021-05-27 12:26       ` Michal Hocko
2021-05-27 13:34         ` Feng Tang
2021-05-27 15:34           ` Michal Hocko
2021-05-28  4:39             ` Feng Tang
2021-05-31  7:00               ` Michal Hocko [this message]
2021-05-31  7:32                 ` Feng Tang
2021-05-31  8:22                   ` Michal Hocko
2021-05-31  8:29                     ` Feng Tang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YLSJiV0tLPvCTnjG@dhcp22.suse.cz \
    --to=mhocko@suse.com \
    --cc=aarcange@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=ben.widawsky@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=feng.tang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mike.kravetz@oracle.com \
    --cc=rdunlap@infradead.org \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).