From patchwork Mon Jan 23 17:37:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13112648 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E49DC25B50 for ; Mon, 23 Jan 2023 17:38:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 178596B0092; Mon, 23 Jan 2023 12:38:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 127CA6B007B; Mon, 23 Jan 2023 12:38:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F316F6B0095; Mon, 23 Jan 2023 12:38:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E2CA56B0092 for ; Mon, 23 Jan 2023 12:38:40 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9558B41C9E for ; Mon, 23 Jan 2023 17:38:40 +0000 (UTC) X-FDA: 80386773600.26.EEAFC49 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf25.hostedemail.com (Postfix) with ESMTP id 490DAA000C for ; Mon, 23 Jan 2023 17:38:37 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf25.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674495518; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OEwH+3PoAg0i63suZqVpZUf8rAexTmeuq4F/YsaSxAk=; b=jBvuFqn2qTSP0JjQh7cd9kdQ/Fc8L9tLabp5U+3efNUpFTas1GqoQonPjuXjpUQCD9N8Re T92EXgPEj8mLtA6oKu2Q72RZwhAxPcx4ef8nCD1nhCiuoSMiCAHduIS41V7FCNE6AFDjKe TR8v6m6TyXzsXtIsyKqslUX6HoGqwNs= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf25.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674495518; a=rsa-sha256; cv=none; b=lHD41N5RgL5SHYSvbwiILB/NaAO4M1wCPHxO7ivcqGm5FQWDDWWJCNSxT3Jce1QvQe7kNr MnuO1FiFz2q3ypaypMDmv23lNSw9mlbqcWvmTyXUXx8OhjLE8DQlpwn3YuOTlSPYJpiu05 uHjwVxEMljvukSWn4Nl+/z72+cUOkGg= Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 732985616BEB; Mon, 23 Jan 2023 09:37:56 -0800 (PST) From: Stefan Roesch To: linux-mm@kvack.org Cc: shr@devkernel.io, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [RESEND RFC PATCH v1 13/20] mm: expose ksm process profit metric in ksm_stat Date: Mon, 23 Jan 2023 09:37:41 -0800 Message-Id: <20230123173748.1734238-14-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230123173748.1734238-1-shr@devkernel.io> References: <20230123173748.1734238-1-shr@devkernel.io> MIME-Version: 1.0 X-Rspamd-Queue-Id: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JK0ePHCh RBROclUX UcKIAfwt/0qupamSRAZIV6PdrRRd1tkj7CX/WV5aAgpqhDzqSu2byq6LMjGtDBsJCoD1kWxBclc+JuyhJD+/Sl9gxUOo/AMtxdKcf X-Bogosity: Ham, tests=bogofilter, spamicity=0.000328, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This exposes the ksm process profit metric in /proc//ksm_stat. The documentation mentions the formula for the ksm process profit metric, however it does not calculate it. In addition the formula depends on the size of internal structures. So it makes sense to expose it. Signed-off-by: Stefan Roesch --- fs/proc/base.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index 9e479d7d202b..a2b7779f76f6 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -96,6 +96,7 @@ #include #include #include +#include #include #include "internal.h" #include "fd.h" @@ -3207,6 +3208,8 @@ static int proc_pid_ksm_stat(struct seq_file *m, struct pid_namespace *ns, mm = get_task_mm(task); if (mm) { seq_printf(m, "ksm_rmap_items %lu\n", mm->ksm_rmap_items); + seq_printf(m, "ksm_merging_pages %lu\n", mm->ksm_merging_pages); + seq_printf(m, "ksm_process_profit %ld\n", ksm_process_profit(mm)); mmput(mm); }