From patchwork Tue Nov 20 10:35:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10690209 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 534BD14BD for ; Tue, 20 Nov 2018 10:35:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4561F2906E for ; Tue, 20 Nov 2018 10:35:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 393912A87C; Tue, 20 Nov 2018 10:35:42 +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 212372906E for ; Tue, 20 Nov 2018 10:35:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AB256B1FCE; Tue, 20 Nov 2018 05:35:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4B8A96B1FCF; Tue, 20 Nov 2018 05:35:35 -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 30FC06B1FD0; Tue, 20 Nov 2018 05:35:35 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id C74AE6B1FCE for ; Tue, 20 Nov 2018 05:35:34 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id e17so1051916edr.7 for ; Tue, 20 Nov 2018 02:35:34 -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=UipYMHSvtb8aOnY17kKqlQt8aWhzlLzqt0JzwQhgn3Q=; b=uLKGdfahYBHt2iXTlEzd/gdhVRxhlNs03L8wB0j/JWRZY8uetKcz7r0IQOHPoMfaoH esEnUumVyTV7uhENUw6+udBPnxlkBOKCxTJ9qHWDxgrB7oYAtJRw9jfXilUCUfWIU6IW nYzLs63NjzEZR5JDzrzRsZe8qWl175JErp/4kwqSmQ2ebVSU/ybnjhvjdHmjILqLjXxR ZFsr3xqrP5kmj80iQNRqmpX+KM8u6ExALvGMAD3Cfgg61AcrvtYhathSUKkq8vJAKcJy WX2SCgkI3FAqkxdwcaDu6m8fX09cctRnncJq3KXXTCE5kCPRVM5ibrbcFPlqQOY9wxPZ 6o4A== 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: AGRZ1gLtPjouujQ9qs00j5bEWuepNbjHIbV5C+jTh0zeN465tcx9OMo4 NEIy4qIalr48yFmgApGaqhUJGYMINjhnobsB8bwpnsL14GVpoaMxztY5fPv1vQ5fovQ95podYQ5 WjSN4l+z/0O7VsncMnEdc4GJObw3ouRYOb7e2eQZ6mNRmFpRoIOakaXcDX3lU7dBU2pSDsBvrMW MR+nlINpSwqCsqwnz25GU0avUW+8T3FsqEtult4Pi2dR9o9RQR5E/Y+O2XPLaf+ACEbPdZ+wqiW IX/2mNiVmKA+I59F0FOjeZ40L3KtIeXGqhylNqbw4Z3qGDjDtzawKKWhBtMstk/PLeAYvU0RYEy k0KWjbIAIA/ztj63KMiXo7a1HxczEpETt5BkftSsQz+ufYbgWJiXF1vFfeHNnk518laM2IGLcA= = X-Received: by 2002:a17:906:4003:: with SMTP id v3-v6mr1578404ejj.240.1542710134309; Tue, 20 Nov 2018 02:35:34 -0800 (PST) X-Received: by 2002:a17:906:4003:: with SMTP id v3-v6mr1578363ejj.240.1542710133351; Tue, 20 Nov 2018 02:35:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542710133; cv=none; d=google.com; s=arc-20160816; b=vHvZb4JCFckBTWAYY04OekA8wGumc2VkIZqRcr6xUaQ+7gAGQfIeTkUR12XwbPRuXN 3+alGeRApG0su42ISKO7kSFhqyfF5qvRuubl3iKtWaFElAlizRYIgBM+xPWQDInLrG1g E2L7TGqcjgu0cptldTFVuizw6VzBUcn5ZQmSLcRrT0NLzG6vitjmiwJtd6F4QbsJMvem bD58PUxNhI22e3uVPbK449uNoPA3EYoIgaUV213ox4Ot6GrNGAPp5WKHR3ro9WTpyqbb mVN1+MiH8ijDQQzmzoanEVPYmexarzrkmQR5JMravEY18dMr9AaHUm6YkPCMT0vTYx52 8ZZA== 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=UipYMHSvtb8aOnY17kKqlQt8aWhzlLzqt0JzwQhgn3Q=; b=Pg4aoaoi3dvxI+pyi5oS+SQcWj6dVLN6M+r00ghOyBcUHHoLO2W5LFVbzH6o6RaGyd D2Kub6vF6lv3EgREAkVaqc3EdwhsRgHktN7xNWASJTpxbaZYHjIK2QUMoV39R3whgXZ5 JHVtll+YCTD2Ykh2pPdOIkTzVn4tyMyQR8ciXB5iR+REoSoijseQgCORJyDI2tYUsmF9 8qzs0kHIqzxUI/NAW+4SNvHC8awm45461eoRzuYye/Fgrw+YglNNUxGe1ststihEbldU S7+ALsla+CgA0inKPHqkDDI1l22Y6uDKJO4rvDMVfkmmvkQlEMhbvp6M7dzfQ6gE2igo T7yQ== 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 a37sor5172224edd.23.2018.11.20.02.35.33 for (Google Transport Security); Tue, 20 Nov 2018 02:35:33 -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/V5yVod2Y7gafwz/wymq1xETuPkqzv1mUxA0rNo7S2XrmUm5lrOtF+JGoyJr0YZVRuMcFZIxA== X-Received: by 2002:a05:6402:144c:: with SMTP id d12mr1853102edx.83.1542710132817; Tue, 20 Nov 2018 02:35:32 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id a15-v6sm5967233ejj.5.2018.11.20.02.35.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 02:35:32 -0800 (PST) From: Michal Hocko To: linux-api@vger.kernel.org Cc: Andrew Morton , Alexey Dobriyan , , LKML , Michal Hocko Subject: [RFC PATCH 3/3] mm, proc: report PR_SET_THP_DISABLE in proc Date: Tue, 20 Nov 2018 11:35:15 +0100 Message-Id: <20181120103515.25280-4-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120103515.25280-1-mhocko@kernel.org> References: <20181120103515.25280-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") Signed-off-by: Michal Hocko Acked-by: Vlastimil Babka --- 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 06562bab509a..7995e9322889 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);