From: David Rientjes <rientjes@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>,
Mel Gorman <mgorman@techsingularity.net>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [patch v2] mm, thp: fix defrag setting if newline is not used
Date: Sun, 19 Jan 2020 13:57:10 -0800 (PST) [thread overview]
Message-ID: <alpine.DEB.2.21.2001191351570.43388@chino.kir.corp.google.com> (raw)
In-Reply-To: <20200118170445.370d908ce29f42068390addb@linux-foundation.org>
On Sat, 18 Jan 2020, Andrew Morton 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.
> >
> > Use the more appropriate sysfs_streq() that handles the trailing newline
> > for us. Since this doubles as a nice cleanup, do it in enabled_store()
> > as well.
>
> I can't really I really understand this prefix-matching thing that
> we're taking away. Documentation/admin-guide/mm/transhuge.rst doesn't
> appear to mention it. Could we please add a paragraph to the changelog
> to spell all this out. Bonus points for formally describing the
> behaviour which we're removing!
>
The current implementation relies on prefix matching: the number of bytes
compared is either the number of bytes written or the length of the option
being compared. With a newline, "defer\n" does not match
"defer+"madvise"; without a newline, however, "defer" is considered to
match "defer+madvise" (prefix matching is only comparing the first five
bytes). End result is that writing "defer" is broken unless it has an
additional trailing character.
This means that writing "madv" in the past would match and set "madvise".
With strict checking, that no longer is the case but it is unlikely
anybody is currently doing this.
prev parent reply other threads:[~2020-01-19 21:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 1:58 [patch] " 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
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 [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=alpine.DEB.2.21.2001191351570.43388@chino.kir.corp.google.com \
--to=rientjes@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--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