Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3232615imu; Sat, 24 Nov 2018 00:41:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/UDYwvM1Pefji08/+JlT15vulezfSkaFV+/oCMJgM7rZomVowJnvMfPc2AUDc7rEUhd4YJb X-Received: by 2002:a63:4101:: with SMTP id o1mr17003825pga.447.1543048873580; Sat, 24 Nov 2018 00:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543048873; cv=none; d=google.com; s=arc-20160816; b=t/hI9DYoGXYFU3x/2atYkWYaHKSJX+1p+AVD1sygVlhwo1X0W3Tutpgkxdt3YfDJYP VqWzJl2cjl2NJyUax7dDltGrZ8vC1/ZSxZ7/mo+kvh7AxGIXYHXfQL2tBIQxjyNF5vYG LH71ijL9dtRDv7XEoEbzZW8qkbg6PO/sOrE4el4MU7wbeIsmXX69LD/yROTwQQyGYIfG H3a157cBQIx1v2b+8gkW94xPSc3SacAY3yMr/tYaMMc0FGJVt35gZvej6v8OgtTLt7Ag RoJn1z2WZWPCf80YPu5qTUbtL85gMRAEheUF0jMtdcHHkxWvkKrHLV1PltCuUjQ5JpHi 54Qg== 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=AbB2Lh0TdkUkzIQYxXjZe9oQK9ICLFdRXGcS+0va3Y4=; b=xGa6356ff1+d/JIWR1vg6NagYPnGrvHwPGt/Gw9ZHiveBneF3APl5F7Nwa/KeQEOKb aU//sAJjqWWloaLDjLt+v9eQzZhMbcKF/dHEmL0a9wOFEnELXcyLlooriDf18ANI/K8s ZAXXEs/CWO6fmkapbI02yRI9Fdf9qC5haJT2h1Z/H4vPsIPc6tGXPsTb2ALiaYv1Cs9i XgqPMrK2n8Kxq6oXmJVgIVfnmW52FDJsXCIdcZzJgqVhraLdGfOP1fJscMj/i+CiA+5K UoRGR14Ca8dsenpk03EQCObHgFuntoHpvKTuxvupIE9Ih41y7BfxmNAGn0ZQEemcUVA1 esFw== 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 gn20si52303668plb.273.2018.11.24.00.40.59; Sat, 24 Nov 2018 00:41:13 -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 S2632729AbeKXCGP (ORCPT + 99 others); Fri, 23 Nov 2018 21:06:15 -0500 Received: from mx2.suse.de ([195.135.220.15]:57504 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2394997AbeKXCGO (ORCPT ); Fri, 23 Nov 2018 21:06:14 -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 46FBEAC4C; Fri, 23 Nov 2018 15:21:37 +0000 (UTC) Date: Fri, 23 Nov 2018 16:21:36 +0100 From: Michal Hocko To: Vlastimil Babka Cc: linux-api@vger.kernel.org, Andrew Morton , Alexey Dobriyan , linux-mm@kvack.org, LKML Subject: Re: [RFC PATCH 2/3] mm, thp, proc: report THP eligibility for each vma Message-ID: <20181123152136.GA5827@dhcp22.suse.cz> References: <20181120103515.25280-1-mhocko@kernel.org> <20181120103515.25280-3-mhocko@kernel.org> <73b55240-d36c-cf97-d7fd-85e2ae1e9309@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73b55240-d36c-cf97-d7fd-85e2ae1e9309@suse.cz> 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 Fri 23-11-18 16:07:06, Vlastimil Babka wrote: > On 11/20/18 11:35 AM, Michal Hocko wrote: > > From: Michal Hocko > > > > Userspace falls short when trying to find out whether a specific memory > > range is eligible for THP. There are usecases that would like to know > > that > > http://lkml.kernel.org/r/alpine.DEB.2.21.1809251248450.50347@chino.kir.corp.google.com > > : This is used to identify heap mappings that should be able to fault thp > > : but do not, and they normally point to a low-on-memory or fragmentation > > : issue. > > > > The only way to deduce this now is to query for hg resp. nh flags and > > confronting the state with the global setting. Except that there is > > also PR_SET_THP_DISABLE that might change the picture. So the final > > logic is not trivial. Moreover the eligibility of the vma depends on > > the type of VMA as well. In the past we have supported only anononymous > > memory VMAs but things have changed and shmem based vmas are supported > > as well these days and the query logic gets even more complicated > > because the eligibility depends on the mount option and another global > > configuration knob. > > > > Simplify the current state and report the THP eligibility in > > /proc//smaps for each existing vma. Reuse transparent_hugepage_enabled > > for this purpose. The original implementation of this function assumes > > that the caller knows that the vma itself is supported for THP so make > > the core checks into __transparent_hugepage_enabled and use it for > > existing callers. __show_smap just use the new transparent_hugepage_enabled > > which also checks the vma support status (please note that this one has > > to be out of line due to include dependency issues). > > > > Signed-off-by: Michal Hocko > > Not thrilled by this, Any specific concern? > but kernel is always better suited to report this, > than userspace piecing it together from multiple sources, relying on > possibly outdated knowledge of kernel implementation details... yep. > Acked-by: Vlastimil Babka Thanks! > A nitpick: > > > --- > > Documentation/filesystems/proc.txt | 3 +++ > > fs/proc/task_mmu.c | 2 ++ > > include/linux/huge_mm.h | 13 ++++++++++++- > > mm/huge_memory.c | 12 +++++++++++- > > mm/memory.c | 4 ++-- > > 5 files changed, 30 insertions(+), 4 deletions(-) > > > > diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt > > index b1fda309f067..06562bab509a 100644 > > --- a/Documentation/filesystems/proc.txt > > +++ b/Documentation/filesystems/proc.txt > > @@ -425,6 +425,7 @@ SwapPss: 0 kB > > KernelPageSize: 4 kB > > MMUPageSize: 4 kB > > Locked: 0 kB > > +THPeligible: 0 > > I would use THP_Eligible. There are already fields with underscore in smaps. I do not feel strongly. I will wait for more comments and see whether there is some consensus. -- Michal Hocko SUSE Labs