[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <025511aa-4721-2edb-d658-78d6368a9101@suse.cz>
Date: Fri, 17 Jan 2020 09:24:01 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Andrew Morton <akpm@...ux-foundation.org>,
David Rientjes <rientjes@...gle.com>
Cc: Mel Gorman <mgorman@...hsingularity.net>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [patch] mm, thp: fix defrag setting if newline is not used
On 1/17/20 4:16 AM, Andrew Morton wrote:
> On Tue, 14 Jan 2020 17:58:36 -0800 (PST) David Rientjes <rientjes@...gle.com> 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.
Powered by blists - more mailing lists