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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham 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 5E52AC43441 for ; Fri, 23 Nov 2018 15:07:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2276420664 for ; Fri, 23 Nov 2018 15:07:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2276420664 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504776AbeKXBvq (ORCPT ); Fri, 23 Nov 2018 20:51:46 -0500 Received: from mx2.suse.de ([195.135.220.15]:55828 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732166AbeKXBvp (ORCPT ); Fri, 23 Nov 2018 20:51:45 -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 DA07DAE55; Fri, 23 Nov 2018 15:07:11 +0000 (UTC) Subject: Re: [RFC PATCH 2/3] mm, thp, proc: report THP eligibility for each vma To: Michal Hocko , linux-api@vger.kernel.org Cc: Andrew Morton , Alexey Dobriyan , linux-mm@kvack.org, LKML , Michal Hocko References: <20181120103515.25280-1-mhocko@kernel.org> <20181120103515.25280-3-mhocko@kernel.org> From: Vlastimil Babka Open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D+IrDAGLHwPhCr RyfKalnrbYokvbClM9EuU1oUuh7k+Sg5ECNXEsamW9AiWGCaKWNDdHre3Lf4xl+RJWxghOVW RiUdpLA/a3yDvJNVr6rxkDHQ1P24ZZz/VKDyP+6g8aty2aWEU0YFNjI+rqYZb2OppDx6fdma YnLDcIfDFnkVlDmpznnGCyEqLLyMS3GH52AH13zMT9L9QYgT303+r6QQpKBIxAwn8Jg8dAlV OLhgeHXKr+pOQdFf6iu2sXlUR4MkO/5KWM1K0jFR2ug8Pb3aKOhowVMBT64G0TXhQ/kX4tZ2 ZF0QZLUCHU3Cigvbu4AWWVMNDEOGD/4sn9OoHxm6J04jLUHFUpFKDcjab4NRNWoHLsuLGjve Gdbr2RKO2oJ5qZj81K7os0/5vTAA4qHDP2EETAQcunTn6aPlkUnJ8aw6I1Rwyg7/XsU7gQHF IM/cUMuWWm7OUUPtJeR8loxZiZciU7SMvN1/B9ycPMFs/A6EEzyG+2zKryWry8k7G/pcPrFx O2PkDPy3YmN1RfpIX2HEmnCEFTTCsKgYORangFu/qOcXvM83N+2viXxG4mjLAMiIml1o2lKV cqmP8roqufIAj+Ohhzs= Message-ID: <73b55240-d36c-cf97-d7fd-85e2ae1e9309@suse.cz> Date: Fri, 23 Nov 2018 16:07:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181120103515.25280-3-mhocko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, 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... Acked-by: Vlastimil Babka 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.