Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1900262ybl; Sun, 19 Jan 2020 14:01:06 -0800 (PST) X-Google-Smtp-Source: APXvYqyIBsIkUIqIkhSw2lhcOE21I7apcOQioSLJ6sIf+t2e1AP2wxr6Ys5lmL/QYS9fSowxkFyO X-Received: by 2002:a05:6830:2111:: with SMTP id i17mr13128565otc.24.1579471266863; Sun, 19 Jan 2020 14:01:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579471266; cv=none; d=google.com; s=arc-20160816; b=BhRzXXH83DPlyfd+txjP3l8UUIbBWbdC5o5zyPyqQQamlYvO09MPhZF0t1JNi3KJp+ j0WIdrrBb2td+wVZlh1u3YTwxvMMvpvcYk5MJoph05FRp7F6yPhrO59PDZ7v3xDZir+L aYa+onwnXshilbGfQMKX8rW0gyQVRNoXbyVj3XhVliIe7xX9ON7gybyBghuZt1KmHYSX 6tLS/GNwqtj2JGNR5QpiFlZyUlr6BtOYZMUoo+Nu+jqr/GmKaBFwnTB9xpdSbBvRDUqP X4z1xIdcjPQaoWtOvNzjQ3TqtnraXVAT+KJxR8z/rz2ZR+jG6BvPVDyx+3AK/llBaT4Q CDVA== 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=sgjV84nCEnzbwj6ezGkciS3O1efN4WtDGoU2lYCK0MU=; b=zU+w+hHl4BDvrmDrAqsmAin6DmcKvCTRvpFyFmzi//P4XuL7wOWPEU57MAbgsjxhcu s099xJTGEUOWXGyO74z6/bzRpICRCj7R2PHOJIJ0NcrMekOEGPpwLtgpU1Mr1rKi3+kb zO4BpTexIQM42Kz30UhY92WCLW7hJ5wXJbUX9eRRwwSXrO7lvhNy+UgHF6v3qTZ7eAQR 6p6O/j2UyiQAE87LLSyXY2mmleAxOPjugmO8jol6olfum0Hv4B0AnFT+e0NEE9ld2W5o KxfKSFR+gUasdHw7rk3KzNt5gaKus9SZyDo9HErAknZGNZ09hWNWNoo66Sg0h3Db4A+Y 84mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Axgh4EC1; 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 h24si15937776oie.151.2020.01.19.14.00.43; Sun, 19 Jan 2020 14:01:06 -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=Axgh4EC1; 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 S1728819AbgASV5N (ORCPT + 99 others); Sun, 19 Jan 2020 16:57:13 -0500 Received: from mail-pl1-f177.google.com ([209.85.214.177]:37277 "EHLO mail-pl1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727556AbgASV5M (ORCPT ); Sun, 19 Jan 2020 16:57:12 -0500 Received: by mail-pl1-f177.google.com with SMTP id c23so12296167plz.4 for ; Sun, 19 Jan 2020 13:57:12 -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=sgjV84nCEnzbwj6ezGkciS3O1efN4WtDGoU2lYCK0MU=; b=Axgh4EC1lgaKyEUskSo9a2kogl5Y/r5vOb6buWTNDyhkn98nuVedRGsmbC/xUWQWat sRx+bP5NRPuhIMUgBnP/fRzRBx/qEtZ2yFM9NJUuFpTZFQ7/p37JY5L9xzWKZkmSdbmq PuLVN5Lkv/FImE7NbF8HZVgGp8KsD9bVtDdlRafFGV+SajGPXYDheDRjIRgsKw2hMoel nFJd/CAulgfdvQrVowLUkSLT/G0/N0VJBr3OnP+MVeezDBogwytTa3pf7FF7Qjb8KjNG c6WbtPUpR9PKuoePrxk8EOpI31EFU/08Vws4zzHyqdchuOX9mHMA4IZKgoREZwOQZ3Hf E9ng== 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=sgjV84nCEnzbwj6ezGkciS3O1efN4WtDGoU2lYCK0MU=; b=ONzOilTYUw9853S2eOFtmFnAsFuEHWlW9CDLNpOgfNn/VNXw0G2JtVjEl/kK/85uz6 RSfuMCCgw0LupxSoBUYsoYHjuDc1M8fJpCKlMLXlIabpsfILv2bJYSJ+kGEwQ5vEtK0L 7sVHS2f1ckmhRk/B5HxMShAJerpaNI9iEgNKeOPtptTPz6ZVoaCzMzxPrOmtLdZs4Yf5 eZ9OAOAREObAJADgot1IWczypomkp0vQvXIdkRoHFP/hZHjE5lYjbW0hw9uckL0uvNsy KgH+WlgP955b3C3xO0gJ5aX9LETh4grAi/DJy3aDi5OoszQgypZwLblxKpxq7H3Y+aOD 72zQ== X-Gm-Message-State: APjAAAUm504cydGX7jiNQ/0o36uAflKUg3nGkpyFER11JGmj38kXlo21 bxq2h3BBaUBjC8LZ8YHsDcNefYPnSe8= X-Received: by 2002:a17:902:900a:: with SMTP id a10mr11526249plp.191.1579471031885; Sun, 19 Jan 2020 13:57:11 -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 c68sm36886806pfc.156.2020.01.19.13.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jan 2020 13:57:11 -0800 (PST) Date: Sun, 19 Jan 2020 13:57:10 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrew Morton cc: Vlastimil Babka , Mel Gorman , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch v2] mm, thp: fix defrag setting if newline is not used In-Reply-To: <20200118170445.370d908ce29f42068390addb@linux-foundation.org> Message-ID: References: <20200116191609.3972fd5301cf364a27381923@linux-foundation.org> <025511aa-4721-2edb-d658-78d6368a9101@suse.cz> <20200118170445.370d908ce29f42068390addb@linux-foundation.org> 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 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.