linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <yang.shi@linux.alibaba.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: mgorman@techsingularity.net, vbabka@suse.cz,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] mm: mempolicy: remove MPOL_MF_LAZY
Date: Thu, 21 Mar 2019 16:25:24 -0700	[thread overview]
Message-ID: <2cbd2f5c-4cb9-457a-6a0a-8ae99ca5eb6e@linux.alibaba.com> (raw)
In-Reply-To: <20190321194539.GY8696@dhcp22.suse.cz>



On 3/21/19 12:45 PM, Michal Hocko wrote:
> On Thu 21-03-19 10:25:08, Yang Shi wrote:
>>
>> On 3/21/19 9:51 AM, Michal Hocko wrote:
>>> On Thu 21-03-19 09:21:39, Yang Shi wrote:
>>>> On 3/21/19 7:57 AM, Michal Hocko wrote:
>>>>> On Wed 20-03-19 08:27:39, Yang Shi wrote:
>>>>>> MPOL_MF_LAZY was added by commit b24f53a0bea3 ("mm: mempolicy: Add
>>>>>> MPOL_MF_LAZY"), then it was disabled by commit a720094ded8c ("mm:
>>>>>> mempolicy: Hide MPOL_NOOP and MPOL_MF_LAZY from userspace for now")
>>>>>> right away in 2012.  So, it is never ever exported to userspace.
>>>>>>
>>>>>> And, it looks nobody is interested in revisiting it since it was
>>>>>> disabled 7 years ago.  So, it sounds pointless to still keep it around.
>>>>> The above changelog owes us a lot of explanation about why this is
>>>>> safe and backward compatible. I am also not sure you can change
>>>>> MPOL_MF_INTERNAL because somebody still might use the flag from
>>>>> userspace and we want to guarantee it will have the exact same semantic.
>>>> Since MPOL_MF_LAZY is never exported to userspace (Mel helped to confirm
>>>> this in the other thread), so I'm supposed it should be safe and backward
>>>> compatible to userspace.
>>> You didn't get my point. The flag is exported to the userspace and
>>> nothing in the syscall entry path checks and masks it. So we really have
>>> to preserve the semantic of the flag bit for ever.
>> Thanks, I see you point. Yes, it is exported to userspace in some sense
>> since it is in uapi header. But, it is never documented and MPOL_MF_VALID
>> excludes it. mbind() does check and mask it. It would return -EINVAL if
>> MPOL_MF_LAZY or any other undefined/invalid flag is set. See the below code
>> snippet from do_mbind():
>>
>> ...
>> #define MPOL_MF_VALID    (MPOL_MF_STRICT   |     \
>>               MPOL_MF_MOVE     |     \
>>               MPOL_MF_MOVE_ALL)
>>
>> if (flags & ~(unsigned long)MPOL_MF_VALID)
>>          return -EINVAL;
>>
>> So, I don't think any application would really use the flag for mbind()
>> unless it is aimed to test the -EINVAL. If just test program, it should be
>> not considered as a regression.
> I have overlook that MPOL_MF_VALID doesn't include MPOL_MF_LAZY. Anyway,
> my argument still holds that the bit has to be reserved for ever because
> it used to be valid at some point of time and not returning EINVAL could
> imply you are running on the kernel which supports the flag.

I'd say it is not valid since very beginning. MPOL_MF_LAZY was added by 
commit b24f53a0bea3 ("mm: mempolicy: Add
MPOL_MF_LAZY"), then it was hidden by commit a720094ded8c ("mm:
mempolicy: Hide MPOL_NOOP and MPOL_MF_LAZY from userspace for now"). 
And, git describe --contains shows:

US-143344MP:linux yang.s$ git describe --contains b24f53a0bea3
v3.8-rc1~92^2~27
US-143344MP:linux yang.s$ git describe --contains a720094ded8c
v3.8-rc1~92^2~25

This is why I thought it is never ever exported to userspace.

>   
>>>> I'm also not sure if anyone use MPOL_MF_INTERNAL or not and how they use it
>>>> in their applications, but how about keeping it unchanged?
>>> You really have to. Because it is an offset of other MPLO flags for
>>> internal usage.
>>>
>>> That being said. Considering that we really have to preserve
>>> MPOL_MF_LAZY value (we cannot even rename it because it is in uapi
>>> headers and we do not want to break compilation). What is the point of
>>> this change? Why is it an improvement? Yes, nobody is probably using
>>> this because this is not respected in anything but the preferred mem
>>> policy. At least that is the case from my quick glance. I might be still
>>> wrong as it is quite easy to overlook all the consequences. So the risk
>>> is non trivial while the benefit is not really clear to me. If you see
>>> one, _document_ it. "Mel said it is not in use" is not a justification,
>>> with all due respect.
>> As I elaborated above, mbind() syscall does check it and treat it as an
>> invalid flag. MPOL_PREFERRED doesn't use it either, but just use MPOL_F_MOF
>> directly.
> As Mel already pointed out. This doesn't really sound like a sound
> argument. Say we would remove those few lines of code and preserve the
> flag for future reservation of the flag bit. I would bet my head that it
> will not be long before somebody just goes and clean it up and remove
> because the flag is unused. So you would have to put a note explaining
> why this has to be preserved. Maybe the current code is better to
> document that. It would be much more sound to remove the code if it was
> causing a measurable overhead or a maintenance burden. Is any of that
> the case?

As what I found out, I just thought it may be dead code, if so why not 
remove it otherwise we may have to keep maintaining the unused code.

Thanks,
Yang

>


      reply	other threads:[~2019-03-21 23:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20  0:27 [RFC PATCH] mm: mempolicy: remove MPOL_MF_LAZY Yang Shi
2019-03-21 14:57 ` Michal Hocko
2019-03-21 16:21   ` Yang Shi
2019-03-21 16:51     ` Michal Hocko
2019-03-21 17:25       ` Yang Shi
2019-03-21 19:24         ` Mel Gorman
2019-03-21 23:29           ` Yang Shi
2019-03-21 19:45         ` Michal Hocko
2019-03-21 23:25           ` Yang Shi [this message]

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=2cbd2f5c-4cb9-457a-6a0a-8ae99ca5eb6e@linux.alibaba.com \
    --to=yang.shi@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=vbabka@suse.cz \
    /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).