lkml.org 
[lkml]   [2020]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch v2] mm, thp: fix defrag setting if newline is not used
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.

\
 
 \ /
  Last update: 2020-01-19 22:58    [W:0.503 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site