From patchwork Fri Feb 10 21:50:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13136516 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 9D6AAC05027 for ; Fri, 10 Feb 2023 21:57:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30CD8280025; Fri, 10 Feb 2023 16:57:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BC4A280021; Fri, 10 Feb 2023 16:57:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 137C4280025; Fri, 10 Feb 2023 16:57:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F1586280021 for ; Fri, 10 Feb 2023 16:57:58 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CDDEBC056D for ; Fri, 10 Feb 2023 21:57:58 +0000 (UTC) X-FDA: 80452745436.21.9830775 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 36E121C0012 for ; Fri, 10 Feb 2023 21:57:56 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf18.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=1676066277; 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=KOSmZ5knDgHSl76RDDlt1TUiSdpuev+T40nmiawnyCE=; b=tHPRHqQ7kBPpdQ5CJsB76AdoeX5r3k/3XS9J2iex0z/WiOFL4PARZdH4gzWH+UUnpIsIN/ eViLvbnAijaxUtDUXWuYW29SRUFYFDGnI1OjG/05m8C7csLoeQg9AEmC8qPs9l/2vte5Og Tt6Qlkt3sc/tBIT64G3SCAdxmGlvbVY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf18.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=1676066277; a=rsa-sha256; cv=none; b=snf5WTqyPb8vHw212RG3TIu/4+EQedtkelf6SjDKKgT1V6a9uvxgxHGPJc8CuZSRHMUMHn o2xkFuh700ucpPsY7sNS6a03/UztFvJs5s0C/pa4wJAfo4WDGpfsQo4uPwSdmcsQwXnzvZ yoBrDQGlFHnBW/nVvH2VWExjVE1emjU= Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 959DE6BFC2DD; Fri, 10 Feb 2023 13:50:33 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com Cc: shr@devkernel.io, linux-mm@kvack.org, riel@surriel.com, mhocko@suse.com, david@redhat.com, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, akpm@linux-foundation.org Subject: [RFC PATCH v2 12/19] mm: expose ksm process profit metric in ksm_stat Date: Fri, 10 Feb 2023 13:50:16 -0800 Message-Id: <20230210215023.2740545-13-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230210215023.2740545-1-shr@devkernel.io> References: <20230210215023.2740545-1-shr@devkernel.io> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X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y63LVtJVaoHLFjvBF7eTzOYv66V9Djn4epz28WHRjB/IJCv7upE1E22PNYSZhCYzc3WufeO+g8sffyd8mIjbic65PkHkxZjO X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 ac9ebe972be0..fb9567bc42a4 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" @@ -3208,6 +3209,8 @@ static int proc_pid_ksm_stat(struct seq_file *m, struct pid_namespace *ns, if (mm) { seq_printf(m, "ksm_rmap_items %lu\n", mm->ksm_rmap_items); seq_printf(m, "zero_pages_sharing %lu\n", mm->ksm_zero_pages_sharing); + 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); }