Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8830325ybl; Fri, 17 Jan 2020 01:46:25 -0800 (PST) X-Google-Smtp-Source: APXvYqzCkBsrUd4GQPWtbyo45lCTbBYwPZiljItfL1zr1PiY+Qhq6dgBwSl4tLGMvzXavV5mRGVk X-Received: by 2002:a05:6808:5d0:: with SMTP id d16mr2771693oij.45.1579254385493; Fri, 17 Jan 2020 01:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579254385; cv=none; d=google.com; s=arc-20160816; b=nWnLRDLQYbzGqPflkxaYBW5tK3kltyKZ/tITxVr9IJ/PSKVWXpozBIwnZn0+TP3BdZ Ww9iD3svy65wOsR4fnTU+0fiNhwvF99EE5Det+E+O/KhxdhEUrmUoHl/zWDoTkF46FIt E/LLfdTnEPX0q2eLlQEmo1wZvvIGyK1YJRgXBnTSZ0QlnosNhxHYZlhi65unhZa9J33p WgF9d1CWxezgy2nanwtACgYrXejaGbsYmWYbEqzaQS1lPCqgpylfEJ+2UtmuzS6DLnyD wqVqX/nIg2WLksBGQE344HAhBWYTEva57/kEAIebfdfAGT5fuxKdvHPIIRjnAFJJqSTH 9M4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=00G05jNcrM2B7qg+tGmrQSVLLyzjItlORoc+42XWNYc=; b=vuEJmZ3wpIWMz+ejfTJ62dIik/R9pRt+gIjKYtIuOy0OrfpGh0j0b8uvXqa8449qUD egulWWdQxAH4Wk7nUtHq2ZAeW4l5KdEbwjJKLGsa44+0+X1e51Utz0mw997J7TpmqZDl +nde73DxkIf4+D3OGjBjnhOJW/PwIf2NStcDmk6Y3CUJZXILIdCG/vdvD9+IpiQfdXJp 8F0xKZVpHErFZARUklZuPk7RrzHrDBBlVpW2wyWJrt43PscgNzg9nnvL3DjRIaLjq6+t NqLx4BbSxLQ/nTNh1wHIL2im+V+HmyMZIl5u8Q+l6yDGbcvSQOqAv+M40g/XXRfFZ0EU iE4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=flAhPTGx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i10si14809434otk.195.2020.01.17.01.46.13; Fri, 17 Jan 2020 01:46:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=flAhPTGx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729076AbgAQJoC (ORCPT + 99 others); Fri, 17 Jan 2020 04:44:02 -0500 Received: from mail-pj1-f52.google.com ([209.85.216.52]:32984 "EHLO mail-pj1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729019AbgAQJoB (ORCPT ); Fri, 17 Jan 2020 04:44:01 -0500 Received: by mail-pj1-f52.google.com with SMTP id u63so4076923pjb.0 for ; Fri, 17 Jan 2020 01:44:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=00G05jNcrM2B7qg+tGmrQSVLLyzjItlORoc+42XWNYc=; b=flAhPTGxlrlifEOZ+Tn9hOXazKmSkeBxFMkQr7zEaZUkHgvdnuNsmY0fYyogJXEd/b k+WQoNlGHUsVjpAWDRB/Ru69KzFJjaHKiJ0LBpYlqMllOy9ImLsOG8RLWkGG8jl5NTKw tfuEheB6PhYV7Kd+eLr1zs1HDMQ1hkFhozggktUGVuvMWLx0IAFD9vtVZ3alEY01ztXH CUCjNUHUIehXaqZCk61UUImcuiv9FODEFzHCcetLk7bbyVkZikDBKRzYgGjP4iNN0YTO pcDX1TzP+wd16+CA+zSn2nIEByurgz6daAUfY5R660xi6M73yTwnSFDp1eUhSaHztJ/Z ejbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=00G05jNcrM2B7qg+tGmrQSVLLyzjItlORoc+42XWNYc=; b=QCNSqPOm4Z83NusyN5OnkHH69ntYn5H/r8f+pHRjPwAQOKbjLPzfIiRVVjUBTMKXR6 hJ2EQltjIwAMa6rU4E+KQBLjd6oSgZMW4H+4+61fNI+pukT7fe3ZLP1pMZEpBcVn0XP7 khm2mMaIuJkr8WAzKfZA0ximuIucIaFwx4/pzEEWKipqimpr9LGQEJP1vauRAJOs+Jt2 LmID8MkDHKPZQdMacHi6hnZ7A5Et6AfXCJv9PY4wSQH6UV7EMOfudxIN1Aupc6d8i/PM 46cCY0FYSYAKc1iuurlW5S+h9zgpbUCH+k4EsBCkHLV6NZrh2qReaVYIR5CQ1HCyem2M WpTg== X-Gm-Message-State: APjAAAWOtISfYNoYPshcGgcBQVEep+sCuvx9/X1vMxzdatABjLkh/Co6 /hn7ywMceIC3H2vk5ggwGtttGBveukk= X-Received: by 2002:a17:902:321:: with SMTP id 30mr38684650pld.130.1579254240671; Fri, 17 Jan 2020 01:44:00 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id x132sm28646025pfc.148.2020.01.17.01.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2020 01:44:00 -0800 (PST) Date: Fri, 17 Jan 2020 01:43:59 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Vlastimil Babka cc: Andrew Morton , Mel Gorman , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch] mm, thp: fix defrag setting if newline is not used In-Reply-To: <025511aa-4721-2edb-d658-78d6368a9101@suse.cz> Message-ID: References: <20200116191609.3972fd5301cf364a27381923@linux-foundation.org> <025511aa-4721-2edb-d658-78d6368a9101@suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 17 Jan 2020, Vlastimil Babka 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. > I tested Vlastimil's patch and it works as intended so I was about to modify the changelog and send his patch and ask for a sign-off line because I think I agree the *partial* prefix matching has ~0.1% chance of breaking userspace and that 0.1% chance outweighs my desire to make the code consistent for all options. But if userspace were broken by this, then at least it was already broken for "defer" depending on newline vs no newline. (What we do know is that nobody has used "defer" for the past couple years without a newline :). If nobody objects, I'll test and send Andrew's version with the changelog because I think we all agree the risk of breakage here is very minimal and actually fixes the case for defer.