Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1641997imu; Tue, 20 Nov 2018 22:58:13 -0800 (PST) X-Google-Smtp-Source: AJdET5dQxCpNC6rcWubrZkCykgRQR8LYdoFhKq46pRZ7fLoqeUAzhdzKEV4JdnW7YeCcsoo2lFJL X-Received: by 2002:a62:4587:: with SMTP id n7mr5537636pfi.118.1542783493039; Tue, 20 Nov 2018 22:58:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542783493; cv=none; d=google.com; s=arc-20160816; b=eNZkW1Mth0/HUK2qz9ku80zocp0cE4kkUjdOjDuR787SolYjO6vTpiI0BF39YAworx sluHA5FwWZ2tDQTTptAstfNx6NoexLWE7QH/rO5iIfeltkCplw0iEmcpPnUF7H5VihoS QwgwmAZYYLFkqRfmIUa/iiCcEjtVMEuFSmtP81H9Dfas/98GHxr8hNc1t4+7iZUiDTVQ Xg87yY1UFfnE4TtpNm/RZBPX6ZtTNc5wSynzcxYUpSmKet/zmH8+/p8OUozI/EJmec7A 4S/mPxc6XG6XDcDo6S/P2SoTX9I3GtiMbT38X+WP07ONecHlTRugh30ag71mUKyjXOiC PiVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=dY7EEfyypSHTSr8eCNeVlvu8rPSqBZwJhbyLutaVKMw=; b=B9wRHuH9e11uT7z3TvHpIDC3TfDKyDtIUCCjLcRX8mbFiwrJ5cclLeYDAx8QsDikRK /bk8yypKp/FSKvB2G8mx5doJrYrDcpavwbOPJQEAWiBCvoeRhjEgyLajxQY2jBFLDDjS +tlD3f53x8HrbbO+e+jJLzo6MV+C6b/nIZe+/cQGzeAsFuHZmRed6XiNOMaLsQOOxVZx txNn5Z29Bq7RsPrbGdnI9v1CxQPclOl8RWdQA2ZvzLWZ0A3Eskdv7Ufka7dSKdei6zIH ROZIosySE6t1EDhSdwP6FzzIxTvvhNuOvQxaq3GhobhSNVefmjz+zpZ9tMXZ4Gi5G3s3 Trzw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w64-v6si49663530pfw.101.2018.11.20.22.57.58; Tue, 20 Nov 2018 22:58:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727566AbeKURaP (ORCPT + 99 others); Wed, 21 Nov 2018 12:30:15 -0500 Received: from mx2.suse.de ([195.135.220.15]:56924 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726039AbeKURaP (ORCPT ); Wed, 21 Nov 2018 12:30:15 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0F077B037; Wed, 21 Nov 2018 06:56:58 +0000 (UTC) Date: Wed, 21 Nov 2018 07:56:56 +0100 From: Michal Hocko To: David Rientjes Cc: Jan Kara , linux-api@vger.kernel.org, Andrew Morton , Alexey Dobriyan , linux-mm@kvack.org, LKML , Dan Williams Subject: Re: [RFC PATCH 1/3] mm, proc: be more verbose about unstable VMA flags in /proc//smaps Message-ID: <20181121065656.GA12932@dhcp22.suse.cz> References: <20181120103515.25280-1-mhocko@kernel.org> <20181120103515.25280-2-mhocko@kernel.org> <20181120105135.GF8842@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 20-11-18 16:01:47, David Rientjes wrote: > 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? Well, I would treat it as any standard feature request. Ask for the feature upstream and work with the comunity to come up with a reasonable and a stable API. > Anyway, mentioning that the vm flags here only have meaning depending on > the kernel version seems like a worthwhile addition: > > Acked-by: David Rientjes Thanks! -- Michal Hocko SUSE Labs