From: Vlastimil Babka <vbabka@suse.cz>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Mel Gorman <mgorman@techsingularity.net>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [patch] mm, thp: fix defrag setting if newline is not used
Date: Fri, 17 Jan 2020 11:12:24 +0100 [thread overview]
Message-ID: <a3c269a7-ff41-ee7c-9041-ee06e50c5a10@suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.21.2001170136280.20618@chino.kir.corp.google.com>
On 1/17/20 10:43 AM, David Rientjes wrote:
> On Fri, 17 Jan 2020, Vlastimil Babka wrote:
>
>>>> If thp defrag setting "defer" is used and a newline is *not* used when
>>>> writing to the sysfs file, this is interpreted as the "defer+madvise"
>>>> option.
>>>>
>>>> This is because we do prefix matching and if five characters are written
>>>> without a newline, the current code ends up comparing to the first five
>>>> bytes of the "defer+madvise" option and using that instead.
>>>>
>>>> Find the length of what the user is writing and use that to guide our
>>>> decision on which string comparison to do.
>>>
>>> Gee, why is this code so complicated? Can't we just do
>>>
>>> if (sysfs_streq(buf, "always")) {
>>> ...
>>> } else if sysfs_streq(buf, "defer+madvise")) {
>>> ...
>>> }
>>> ...
>>
>> Yeah, if we knew this existed :)
>>
>> We would lose the prefix matching but hopefully nobody will complain.
>>
>
> I tested Vlastimil's patch and it works as intended so I was about to
> modify the changelog and send his patch and ask for a sign-off line
> because I think I agree the *partial* prefix matching has ~0.1% chance of
> breaking userspace and that 0.1% chance outweighs my desire to make the
> code consistent for all options.
If prefix matching worked with "echo alw > /sys..." then I would expect
some script out there relies on it, but since it only works with "echo
-n alw > /..." then perhaps there's no such script :)
> But if userspace were broken by this, then at least it was already broken
> for "defer" depending on newline vs no newline. (What we do know is that
> nobody has used "defer" for the past couple years without a newline :).
>
> If nobody objects, I'll test and send Andrew's version with the changelog
> because I think we all agree the risk of breakage here is very minimal and
> actually fixes the case for defer.
Agreed.
next prev parent reply other threads:[~2020-01-17 10:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 1:58 David Rientjes
2020-01-15 12:45 ` Vlastimil Babka
2020-01-17 3:16 ` Andrew Morton
2020-01-17 8:24 ` Vlastimil Babka
2020-01-17 9:43 ` David Rientjes
2020-01-17 10:12 ` Vlastimil Babka [this message]
2020-01-17 22:11 ` [patch v2] " David Rientjes
2020-01-18 10:54 ` Vlastimil Babka
2020-01-19 1:04 ` Andrew Morton
2020-01-19 21:57 ` David Rientjes
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=a3c269a7-ff41-ee7c-9041-ee06e50c5a10@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=rientjes@google.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