From patchwork Wed Jun 15 07:12:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Whitchurch X-Patchwork-Id: 12881872 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 4053FC433EF for ; Wed, 15 Jun 2022 07:13:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A811C6B0071; Wed, 15 Jun 2022 03:13:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A30D96B0072; Wed, 15 Jun 2022 03:13:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 920236B0073; Wed, 15 Jun 2022 03:13:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8366F6B0071 for ; Wed, 15 Jun 2022 03:13:01 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 556ECB53 for ; Wed, 15 Jun 2022 07:13:01 +0000 (UTC) X-FDA: 79579603362.25.AAC6032 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by imf23.hostedemail.com (Postfix) with ESMTP id 60A75140066 for ; Wed, 15 Jun 2022 07:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1655277180; x=1686813180; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=31d2aqWVAyXdsRipazb3IE8Miw4X3sTPNxD+NrkvWJg=; b=b6+TJYbhCKl0fsTuoniLvJHAo+nE99rgFCLTf41nZ1LVoY9QxXxcX5xp 8NE6AJOhburSkBmzWHuaqtSxxIvin7MfXVnIId82wcn42A+4RDa9IsCYq ol0nbepCujnifviAh6aZwjIuar2VXzRTK1z8D0+BD1ZWuuGxC+UPDK6yA LNeGenPlnkxh6P541tKTxv7onjsnsEDTvpI0azMsBWDyf8t0OMN95MC66 PjUOb9Dgv/M1+VBGXXOj9AddDZxmnF6MM39drf/qMlhHCT54Z9gL2fk4o gizRnm9FlIHkmF0bTSduJcAY3WcLgK164kTv9wIOZ9BYCCVJ66VKD51qT Q==; From: Vincent Whitchurch To: CC: , , Vincent Whitchurch , , Subject: [PATCH] mm/smaps: add Pss_Dirty Date: Wed, 15 Jun 2022 09:12:52 +0200 Message-ID: <20220615071252.1153408-1-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655277181; a=rsa-sha256; cv=none; b=Bt+rCqqFbNDNoV/pDPcv9+6MoJUSH2b0cbpF4hmtrArAEABnjKmCjy43NNi6nBYBfG8ann GyjwOGlLrVOx6OH6NdEg6y+xH8GwkO0IxPESdtrKMZc4S5/8OSaxkYtL/qYHPXo2A0JukN IjnyoNaFySodPIIWB/17Z3jsVoLG0LE= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=axis.com header.s=axis-central1 header.b=b6+TJYbh; dmarc=pass (policy=none) header.from=axis.com; spf=pass (imf23.hostedemail.com: domain of Vincent.Whitchurch@axis.com designates 195.60.68.17 as permitted sender) smtp.mailfrom=Vincent.Whitchurch@axis.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655277181; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=31d2aqWVAyXdsRipazb3IE8Miw4X3sTPNxD+NrkvWJg=; b=S157MtXE+RiTIUu58y+Hoa2N1mWzjgrhcbzbAxQRhc6m3H90SFY7zgTVJ6t8AgzQPHQJoZ e6nNFe73IDwa8CnsPjgmSmbwjY9T2l/szgLn7Z5QIkoDggUh3JqUZGxPKz3n1dLWJD9Els hMGOz8e4Y8fEfjMZqZe2UTrooaLHsn4= Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=axis.com header.s=axis-central1 header.b=b6+TJYbh; dmarc=pass (policy=none) header.from=axis.com; spf=pass (imf23.hostedemail.com: domain of Vincent.Whitchurch@axis.com designates 195.60.68.17 as permitted sender) smtp.mailfrom=Vincent.Whitchurch@axis.com X-Rspam-User: X-Stat-Signature: 9fexkiufc1gggx4p7yqq3k7yizx3dm5z X-Rspamd-Queue-Id: 60A75140066 X-Rspamd-Server: rspam08 X-HE-Tag: 1655277180-147769 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Pss is the sum of the sizes of clean and dirty private pages, and the proportional sizes of clean and dirty shared pages: Private = Private_Dirty + Private_Clean Shared_Proportional = Shared_Dirty_Proportional + Shared_Clean_Proportional Pss = Private + Shared_Proportional The Shared*Proportional fields are not present in smaps, so it is not possible to determine how much of the Pss is from dirty pages and how much is from clean pages. This information can be useful for measuring memory usage for the purpose of optimisation, since clean pages can usually be discarded by the kernel immediately while dirty pages cannot. The smaps routines in the kernel already have access to this data, so add a Pss_Dirty to show it to userspace. Pss_Clean is not added since it can be calculated from Pss and Pss_Dirty. Signed-off-by: Vincent Whitchurch --- fs/proc/task_mmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 2d04e3470d4c..696bb546ea06 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -406,6 +406,7 @@ struct mem_size_stats { u64 pss_anon; u64 pss_file; u64 pss_shmem; + u64 pss_dirty; u64 pss_locked; u64 swap_pss; }; @@ -427,6 +428,7 @@ static void smaps_page_accumulate(struct mem_size_stats *mss, mss->pss_locked += pss; if (dirty || PageDirty(page)) { + mss->pss_dirty += pss; if (private) mss->private_dirty += size; else @@ -820,6 +822,7 @@ static void __show_smap(struct seq_file *m, const struct mem_size_stats *mss, SEQ_PUT_DEC(" kB\nPss_Shmem: ", mss->pss_shmem >> PSS_SHIFT); } + SEQ_PUT_DEC(" kB\nPss_Dirty: ", mss->pss_dirty >> PSS_SHIFT); SEQ_PUT_DEC(" kB\nShared_Clean: ", mss->shared_clean); SEQ_PUT_DEC(" kB\nShared_Dirty: ", mss->shared_dirty); SEQ_PUT_DEC(" kB\nPrivate_Clean: ", mss->private_clean);