On 1/17/20 4:16 AM, Andrew Morton wrote: > On Tue, 14 Jan 2020 17:58:36 -0800 (PST) David Rientjes <rientjes@xxxxxxxxxx> 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.