Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8611231ybl; Thu, 16 Jan 2020 20:53:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxYb4YoAOoIVIKIo9RRtJMSweFuWA2X/IXD5/p2p1QuZNMfrc1KvEf44nwyHdyh85dXBaRy X-Received: by 2002:a9d:4c81:: with SMTP id m1mr4631607otf.31.1579236815827; Thu, 16 Jan 2020 20:53:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579236815; cv=none; d=google.com; s=arc-20160816; b=DdS2hXAQRB7DsvnNKRoUu18WOBC6eqoCTOsb70tr8ACAe8PX1OYovFWePoja2AboLw mLsNia03mWbIW+YAhkgKtCDx6w6yyDFXiMUeNFalonWqtXOHU4deshXi5OTt5UleAD6a 8xWvwDY3RbcFvC8eSR+gKa4dylcEPXF6eHk0KIaHedkUNRMCw1lv5sSi2kvFtQ9zQXUv DwyYm31Dv88sJy3iieeWK1ovekexhqc74dpL74BjtwEur7bz6xcjVZbMMJy1zVY20liF gl8kGd63epE6QBpUra30tJGo2JxeV95GjQhkvPfqSUW2U7Rfvl4jVph2VKhscTn9FCfn RsAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Jc33RrohYxHXC7Ee7yoOhhEFI443OHNbzNd/PO+qCbA=; b=lnpryYwDfR7cIJKqBIVaMiKqFfk6vZ79H5yvIHFi5pM8PCGhNpouIMbYO0lVqqa0hW +GO9q5ZmNhfIsoeL+OFKU2kxoJ9KlxqPtZxQt//flpyah8mhnb5RL+4ApvkHfQjM0h+a KcYOrCcD4gCwgWZ33W/1jtlUoFc7KxI4A0DNQJpp9sf+gA2l6TRvo/oLNuDcNEcInE6C QRPQMtCxc87PjGqFaDZiI7xUSRUkNvMg4ogI6iSyvuWV5VKLnoZoLiwVCwPY9xVnpDGJ Bxq/M2e1EEffBifSh1am6Re0tDXA6QNrKrlPxcgi7kSnv21gZnWnhTeO1aPfukGNw2Er D1GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PxYqemw+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si15038280otp.139.2020.01.16.20.53.24; Thu, 16 Jan 2020 20:53:35 -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=@kernel.org header.s=default header.b=PxYqemw+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389326AbgAQDQK (ORCPT + 99 others); Thu, 16 Jan 2020 22:16:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:52122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727015AbgAQDQK (ORCPT ); Thu, 16 Jan 2020 22:16:10 -0500 Received: from X1 (nat-ab2241.sltdut.senawave.net [162.218.216.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE85220679; Fri, 17 Jan 2020 03:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579230969; bh=Pv2hU0kC+NNhp2G0ieTjOr4w9ey+PNyLJxlmNWkf/j4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PxYqemw+WtaVcgnGoE30v238L3q61frkBF7mDd9rfw2Li3dIWg6z/0I805u3XKDLz AZMCUCujV11mMjaPdcQLcHrgZhDfI88Bod1Avr6KwaH3JOY68+8ZqpfUgw0gUZfTDp NjsAvGFq3rCcT3rIqmOZcdhFIPzT78HTOTXokPPA= Date: Thu, 16 Jan 2020 19:16:09 -0800 From: Andrew Morton To: David Rientjes Cc: Mel Gorman , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch] mm, thp: fix defrag setting if newline is not used Message-Id: <20200116191609.3972fd5301cf364a27381923@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 14 Jan 2020 17:58:36 -0800 (PST) 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. > > 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")) { ... } ...