From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F99FC33CB6 for ; Sun, 19 Jan 2020 21:57:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C118E206B7 for ; Sun, 19 Jan 2020 21:57:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Axgh4EC1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C118E206B7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1B3966B0586; Sun, 19 Jan 2020 16:57:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 165656B0587; Sun, 19 Jan 2020 16:57:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07A3A6B0588; Sun, 19 Jan 2020 16:57:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id E63D46B0586 for ; Sun, 19 Jan 2020 16:57:13 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id B92732DFA for ; Sun, 19 Jan 2020 21:57:13 +0000 (UTC) X-FDA: 76395745146.12.pet15_4d80ee6ab407 X-HE-Tag: pet15_4d80ee6ab407 X-Filterd-Recvd-Size: 5045 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Sun, 19 Jan 2020 21:57:13 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id d9so527915plo.11 for ; Sun, 19 Jan 2020 13:57:13 -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=SPx32i1UEzikbAtd2xbEHHebdGJ+DKNnhjuXHlPE4rzD+ZmJ1neSyOnyXbRguuxxwK po3f+CutSdH2oOWq97rrspOowf5abPHJgUPY0xrqDGdR0/0qc6DAcRzvM28XKP1cWfxe gMbJC3/Xpfd6Zvyos6ti+gZK+RLUPbeEzbWgiYlGOmCecJ+HL/59n7xqlRAYAVY6bcOj HrJOE4W/EMf4FMbTtMV5wJ+5B9L6Db0vIMwgAn03EEYBQqW8xg+gYzDKCKhzW1Ixle1K 0tPOVEfIqCvCx/i1GuD5BgmxEI+GdFzbCQNAIg7XXLwhNnBL673zDUCZO7OS+XaMcNrj Cvyg== X-Gm-Message-State: APjAAAUSOf0MVvlxQ/3jbePHH9CvxBKNvmLjrPi33za7S4MlX5kogEED qVpLUEn3a/xKgnU/2jp5mH45Og== X-Google-Smtp-Source: APXvYqwCuHGQaqO8riKKlkERDqzLF6h9yeD1unPBi3A8sA3J85TXPrAU4vefgWFzrtcBfUv3/XLOGg== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.