Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1355552imu; Tue, 20 Nov 2018 16:27:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/XJR8Hs/ehwGP47vJ9cWHB15osu0DsYbLqZzz6Q6mSfjXOBYG3nc4oYceW1BWeZ0FEhThqW X-Received: by 2002:a17:902:2dc3:: with SMTP id p61mr4407080plb.166.1542760027731; Tue, 20 Nov 2018 16:27:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542760027; cv=none; d=google.com; s=arc-20160816; b=WJucL1XR6GjHdhxJGDiBsk7sCgGq0oiBVVi0f1LPX7Cd9oGngUdTDCykMZvXOmBwJ/ OVTZYtNrl8ap5gltEPk4QR6rNmpzkWsZdU4wNC8CZ+HRg2GxnejbZbynKpiAYMTyATOe DZAXSYN5uxFKmPGf52uthLXNxS4HSBsP/7FO61kyzmnLyoD0OhoYU6hHzX8BxaLEApYK n1UV4boLS35GwUFuJN7/vlLPzoehM5l4AINGxZkyTFtnNqx8aC4QvB4gnLc2v1RroIYS 6XMf9zojRGIZtntP3fKDDWlVaXDtwI8wQTh3oToKJPdr6SrbcsoUW2cJPjryBK2q8LEx /amQ== 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=ESDgRLDwVIKN01iWb2NZ8edlx75PdpNdlKtBC19Cq38=; b=KbsJ7eOEqhbvmIzSRr+SGwP9KbE3YDuMQZBtOnC5pOeHb+ksv28V5xGXHjQg4rRrvJ 2nWHTQR3FmRAmrz0hkAN0RF6UQmQaBOeZzleMZMq2n2StGWDY+QufOOUBgXsewQfJkpb iI1w+sbblAK3LDRWgvFnhsP7AR88taaiJDuQEmRE9eL2jhRJhr8tMXpN5xkyEeUQaWlt AJU5vDdvlChGmcybmZAn8Lzd2d+eMLZ9ZjYJtVyaU66RPqvGRiiM3SV5OkaskhKkaxGz JP8unJ4x0Z3Nd/c2dtE38nTtddT/lqv9tCKyd/VI+Q9g5/YLOpK94g6PGfRzpbM5DWXJ X7Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=g8LSDG0S; 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 h68si6361949plb.375.2018.11.20.16.26.52; Tue, 20 Nov 2018 16:27:07 -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=g8LSDG0S; 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 S1726792AbeKUKdi (ORCPT + 99 others); Wed, 21 Nov 2018 05:33:38 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37540 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbeKUKdi (ORCPT ); Wed, 21 Nov 2018 05:33:38 -0500 Received: by mail-pl1-f196.google.com with SMTP id b5so2663795plr.4 for ; Tue, 20 Nov 2018 16:01:49 -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=ESDgRLDwVIKN01iWb2NZ8edlx75PdpNdlKtBC19Cq38=; b=g8LSDG0SR+AAnlIhDxI963bVaCJNNoVLE0x8FJxCSuQ0Jr1pjY+txkWmujDxajcinD ebGqzvRfDgQvm08/QgAIC+JdvmKNFG4d97VrNjLrtCk3ZTcY78QQAfj0ge2LlrBy/Iaz Wp3Q7aJYwLZo5Q1mP0VzCa2gYSgDRJTdbW7VSKide821PkGiHS7R4MsbOymz9+heMvY/ TPHS6JrThn2wgImxDTeo2RBhpd4bCwdBNnxyWt4FZJw5W0QKrGEmvGMbFHyr1PyKntBN oOEV5mkG7tCkdBMJDOdVtFGh/XZCYPBap0XMwSwt67uwiL4ucqVHbzjLi5OHkadMwBDm SfXA== 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=ESDgRLDwVIKN01iWb2NZ8edlx75PdpNdlKtBC19Cq38=; b=WmKoRuq2FSxM9dWR9Avgm6R6kLZar5hE35TJVQ/nQ19T8aKvSLX9QcFlOYkTcfUDs/ u0i9zRwvNFC3L48GVJZB/O/MQd4oUvgu0U7sjBfrhRKdH00Wj/B3qqLabikV12ceMuef vx6q+XI9o5lHe1SASDbEM1W5kAhn9CR0lTT6SFRBIVmq1wDycXgTt9pehylwWd+YCpQJ NxHrb0PSzvZCuL6X7rZ99A+/MB/XY2JfUJYNs9AsbwA6mvDkpt7E+OBz3+DFNMQT2D1z gZFOWYd2C/9EN62k7X4daS9JSE7Kck6oCaMyDdCGd/bt1amL0gKDAmdsCe9POMeA8qr5 A7yA== X-Gm-Message-State: AGRZ1gLvNNNz15NFtd2n9B+M6AwMkQj/n+dg5eEJmpPVPvX+yyrlsM5k ilCyZHjCAsAb3KdWTVa1e28ruQ== X-Received: by 2002:a62:6d83:: with SMTP id i125-v6mr4475518pfc.184.1542758508805; Tue, 20 Nov 2018 16:01:48 -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 z9sm32460926pfd.99.2018.11.20.16.01.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Nov 2018 16:01:48 -0800 (PST) Date: Tue, 20 Nov 2018 16:01:47 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Jan Kara cc: Michal Hocko , linux-api@vger.kernel.org, Andrew Morton , Alexey Dobriyan , linux-mm@kvack.org, LKML , Michal Hocko , Dan Williams Subject: Re: [RFC PATCH 1/3] mm, proc: be more verbose about unstable VMA flags in /proc//smaps In-Reply-To: <20181120105135.GF8842@quack2.suse.cz> Message-ID: References: <20181120103515.25280-1-mhocko@kernel.org> <20181120103515.25280-2-mhocko@kernel.org> <20181120105135.GF8842@quack2.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 Tue, 20 Nov 2018, Jan Kara wrote: > > Even though vma flags exported via /proc//smaps are explicitly > > documented to be not guaranteed for future compatibility the warning > > doesn't go far enough because it doesn't mention semantic changes to > > those flags. And they are important as well because these flags are > > a deep implementation internal to the MM code and the semantic might > > change at any time. > > > > Let's consider two recent examples: > > http://lkml.kernel.org/r/20181002100531.GC4135@quack2.suse.cz > > : commit e1fb4a086495 "dax: remove VM_MIXEDMAP for fsdax and device dax" has > > : removed VM_MIXEDMAP flag from DAX VMAs. Now our testing shows that in the > > : mean time certain customer of ours started poking into /proc//smaps > > : and looks at VMA flags there and if VM_MIXEDMAP is missing among the VMA > > : flags, the application just fails to start complaining that DAX support is > > : missing in the kernel. > > > > http://lkml.kernel.org/r/alpine.DEB.2.21.1809241054050.224429@chino.kir.corp.google.com > > : Commit 1860033237d4 ("mm: make PR_SET_THP_DISABLE immediately active") > > : introduced a regression in that userspace cannot always determine the set > > : of vmas where thp is ineligible. > > : Userspace relies on the "nh" flag being emitted as part of /proc/pid/smaps > > : to determine if a vma is eligible to be backed by hugepages. > > : Previous to this commit, prctl(PR_SET_THP_DISABLE, 1) would cause thp to > > : be disabled and emit "nh" as a flag for the corresponding vmas as part of > > : /proc/pid/smaps. After the commit, thp is disabled by means of an mm > > : flag and "nh" is not emitted. > > : This causes smaps parsing libraries to assume a vma is eligible for thp > > : and ends up puzzling the user on why its memory is not backed by thp. > > > > In both cases userspace was relying on a semantic of a specific VMA > > flag. The primary reason why that happened is a lack of a proper > > internface. While this has been worked on and it will be fixed properly, > > it seems that our wording could see some refinement and be more vocal > > about semantic aspect of these flags as well. > > > > Cc: Jan Kara > > Cc: Dan Williams > > Cc: David Rientjes > > Signed-off-by: Michal Hocko > > Honestly, it just shows that no amount of documentation is going to stop > userspace from abusing API that's exposing too much if there's no better > alternative. But this is a good clarification regardless. So feel free to > add: > > Acked-by: Jan Kara > I'm not sure what is expected of a userspace developer who finds they have a single way to determine if something is enabled/disabled. Should they refer to the documentation and see that the flag may be unstable so they write a kernel patch and have it merged upstream before using it? What to do when they don't control the kernel version they are running on? Anyway, mentioning that the vm flags here only have meaning depending on the kernel version seems like a worthwhile addition: Acked-by: David Rientjes