Re: [patch v2] mm, thp: fix defrag setting if newline is not used

From: Vlastimil Babka
Date: Sat Jan 18 2020 - 05:58:44 EST


On 1/17/20 11:11 PM, David Rientjes 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.
>
> Fixes: 21440d7eb904 ("mm, thp: add new defer+madvise defrag option")
> Cc: Vlastimil Babka <vbabka@xxxxxxx>
> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx>
> Suggested-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>

Acked-by: Vlastimil Babka <vbabka@xxxxxxx>
Thanks.