From patchwork Tue Dec 11 14:36:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10723917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31AD891E for ; Tue, 11 Dec 2018 14:37:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DD7829B27 for ; Tue, 11 Dec 2018 14:37:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 121F02A04F; Tue, 11 Dec 2018 14:37:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9388C29B27 for ; Tue, 11 Dec 2018 14:36:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A80108E009C; Tue, 11 Dec 2018 09:36:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A2A238E0095; Tue, 11 Dec 2018 09:36:54 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87CB28E009C; Tue, 11 Dec 2018 09:36:54 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 2FE348E0095 for ; Tue, 11 Dec 2018 09:36:54 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id f17so5885696edm.20 for ; Tue, 11 Dec 2018 06:36:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AyqbHZLKGmThJTrdoLh3HA5rnpO95hPXZGeWvc40dsA=; b=AN9ZY1bDWe5sY0yiX3UD5xYF9gt9ls3OICvsexq/vAzoIfLZhcm8bkwUDPpz1OC8NS /AwqDVxIR3cSIE8viIebibCGb0cSMS8fhBUR9vdA1+TEyIesZVJhR79+GWCZt8I9zZTn Mh/RLvrivfHiG5AoBDHJr2RQOzy9jy6UfJ3nc7ttKJhJe7hdIms5zqx73RCxTHQyLqzy qRTu5seHYRQ74u0olPxlerCkyNw66ECrft2E7rYbRUQUMH0ZGtl0vOGTia+9PCkgG8gB UyP+whDz5GUVtK/jU/NpZckbnf1BT2c9MlyggZg8YKKscrECx/d79+PTi7lsIS1VdO92 6rnw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AA+aEWYQOX13bvW8NKzwl5lilpE1JxpiAVMQTpiVhsVrY6uGI1JD5NwW bO9ilwWaXEGYgKCy0L6oyjQQz333LzUyKKbEYhVOP1s20SaBm5yuffih9iJaZoOZjuwVRcpgbV8 vrhbyzbl08fdz0+SgKh32sFt5RHJrbeszrsq8/487DuuBdaiw1q4opKkcCi0UKpcdlge0VBjFjL cCk+x7PF3C7Cx+DaO6UZIqP468QbbDjk9doYBFjp2wgZHll4UvLQ8+MkvWmygoWkLsuZKILzA3M 4Ikz7NM6U5UH3YqX7EXP/UE9R2f5qILBc5pktSzkSgCGi9oULiekwd5wTnAAPH1OqL+SEvHqj3u ihSPU6t3zKGiDqxkXv+BvnmmG/r6DhZNs20gW8hcqCCbUMfh9XZa+w8Cft1hitzNy8Ci4tbSzQ= = X-Received: by 2002:aa7:cf88:: with SMTP id z8mr15540981edx.208.1544539013709; Tue, 11 Dec 2018 06:36:53 -0800 (PST) X-Received: by 2002:aa7:cf88:: with SMTP id z8mr15540937edx.208.1544539012793; Tue, 11 Dec 2018 06:36:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544539012; cv=none; d=google.com; s=arc-20160816; b=u4fXZbb4RICNnooFfGuE04QKADXhu+5VKbsWWL3p52Ppf4QTNAaxjx+0u7c5r6NJ6e Hz1A9IsNaM/bBB0+189ntU1+QvzZuvQAPSDaXyp1DdGqOH+LZr0d53a8H9G46FcOhorB d0sgGjcKhFfWQWTTCY05XKQjubXyJjqyV4EUr1q0FaRXdzp8R0oJVKDqZfJ7leO9PI/4 gEiRXuxPy4thcoQ6c3EtprNgH8HqyXbvl5JTdEul0fPYKYBZ+moV4JkbpFd9Wqjplli9 CKEcPtzZ6n9MfCKNSZaOWhUOJeqVEI85uqCcFof2dj55Sk3QTODJ72YXVMzQh0t3sEng lxnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=AyqbHZLKGmThJTrdoLh3HA5rnpO95hPXZGeWvc40dsA=; b=cr7cQVkrMzbHJomp0aAJMBPJcCYaeQ//nDH7UfHvxc+0fXidlsySMSobyqDHGwZSqa 1fxMpEbNAQGpHRv8Kf4s9XpEiY602pMf+vo8rZaxEs6WeCS6HzmY6N6yL75Iz6/Tm5YP jf7LfP9PiCV63tPoPXrH00h5lFPYXW2+/f1AJ98aTrzB2gx2WLLpU9wQJEFvTb7c8XGw Crpw/ZF5TK8NurP2Qi7p2N1LbV59NtkJq6m0ViPlTMxNOuZBczslGtHRk5qVJnE+e87c YReLEcv+REfOGMwHjNL+2bXmaGWf8gtpUN5qP70nWfrzZjKWlGbZUpStTI8wB5RUgeXP ycKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id k26sor8087632edd.12.2018.12.11.06.36.52 for (Google Transport Security); Tue, 11 Dec 2018 06:36:52 -0800 (PST) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AFSGD/X7KLzdI7d7PZLo/hrL6aPDD+b2i67B2umVhARl/QOcSpLVm+N2KaswALPenC4TARVGpLhuOQ== X-Received: by 2002:a50:a086:: with SMTP id 6mr15066935edo.88.1544539012411; Tue, 11 Dec 2018 06:36:52 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id z40sm4017084edz.86.2018.12.11.06.36.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 06:36:51 -0800 (PST) From: Michal Hocko To: Andrew Morton Cc: linux-api@vger.kernel.org, , LKML , Michal Hocko , Vlastimil Babka Subject: [PATCH 3/3] mm, proc: report PR_SET_THP_DISABLE in proc Date: Tue, 11 Dec 2018 15:36:41 +0100 Message-Id: <20181211143641.3503-4-mhocko@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181211143641.3503-1-mhocko@kernel.org> References: <20181211143641.3503-1-mhocko@kernel.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko David Rientjes has reported that 1860033237d4 ("mm: make PR_SET_THP_DISABLE immediately active") has changed the way how we report THPable VMAs to the userspace. Their monitoring tool is triggering false alarms on PR_SET_THP_DISABLE tasks because it considers an insufficient THP usage as a memory fragmentation resp. memory pressure issue. Before the said commit each newly created VMA inherited VM_NOHUGEPAGE flag and that got exposed to the userspace via /proc//smaps file. This implementation had its downsides as explained in the commit message but it is true that the userspace doesn't have any means to query for the process wide THP enabled/disabled status. PR_SET_THP_DISABLE is a process wide flag so it makes a lot of sense to export in the process wide context rather than per-vma. Introduce a new field to /proc//status which export this status. If PR_SET_THP_DISABLE is used then it reports false same as when the THP is not compiled in. It doesn't consider the global THP status because we already export that information via sysfs Fixes: 1860033237d4 ("mm: make PR_SET_THP_DISABLE immediately active") Acked-by: Vlastimil Babka Signed-off-by: Michal Hocko --- Documentation/filesystems/proc.txt | 3 +++ fs/proc/array.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index cd465304bec4..b24fd9bccc99 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt @@ -182,6 +182,7 @@ For example, to get the status information of a process, all you have to do is VmSwap: 0 kB HugetlbPages: 0 kB CoreDumping: 0 + THP_enabled: 1 Threads: 1 SigQ: 0/28578 SigPnd: 0000000000000000 @@ -256,6 +257,8 @@ Table 1-2: Contents of the status files (as of 4.8) HugetlbPages size of hugetlb memory portions CoreDumping process's memory is currently being dumped (killing the process may lead to a corrupted core) + THP_enabled process is allowed to use THP (returns 0 when + PR_SET_THP_DISABLE is set on the process Threads number of threads SigQ number of signals queued/max. number for queue SigPnd bitmap of pending signals for the thread diff --git a/fs/proc/array.c b/fs/proc/array.c index 0ceb3b6b37e7..9d428d5a0ac8 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -392,6 +392,15 @@ static inline void task_core_dumping(struct seq_file *m, struct mm_struct *mm) seq_putc(m, '\n'); } +static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) +{ + bool thp_enabled = IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE); + + if (thp_enabled) + thp_enabled = !test_bit(MMF_DISABLE_THP, &mm->flags); + seq_printf(m, "THP_enabled:\t%d\n", thp_enabled); +} + int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task) { @@ -406,6 +415,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, if (mm) { task_mem(m, mm); task_core_dumping(m, mm); + task_thp_status(m, mm); mmput(mm); } task_sig(m, task);