From patchwork Wed Jun 26 08:44:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13712417 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 C7C33C27C4F for ; Wed, 26 Jun 2024 08:47:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C2616B0083; Wed, 26 Jun 2024 04:47:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 170766B0085; Wed, 26 Jun 2024 04:47:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 043136B0088; Wed, 26 Jun 2024 04:47:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DAC0E6B0083 for ; Wed, 26 Jun 2024 04:47:04 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 62B2CC0C6A for ; Wed, 26 Jun 2024 08:47:04 +0000 (UTC) X-FDA: 82272409968.30.12EEE8B Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by imf01.hostedemail.com (Postfix) with ESMTP id A0D3F4000E for ; Wed, 26 Jun 2024 08:47:01 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf01.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719391605; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=dTI44VGwV3nuTeAQBP2Z32ATlyXx7SIRGbtOhuUKMPs=; b=Q9dMMhi3tfx8uwI1qarJsl4F7hm9mJUBr0oPkYTVG/mfNQMhYXpoBQpbZo6m2NU8qMkJja u7WVNB/X3oZUvjqacQp5zLORgagAOF5DtjDW1W8yhXt0MtW56Ucz6SdNXm7wawMAcWv5Jq YIYB6uSunTmHqa+PJNX01+/Q/jGP/O0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719391605; a=rsa-sha256; cv=none; b=6MFft3wUkwi8M7UbupoH+PosZS//eDLQg/rRROryLaPvRlXcFlqxAHT73BL2vVCwF1ZAJz O3U7EJl9KZzKfUz2kr3nmBHYdq6+DuX8h/1svo5JHmu6J2usgsPpHMMZOB6J3fRPQPtFCm Ucc2FfutMhqCjG/PndGFCiqMg5N1PNw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf01.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 45Q8iCJx045005; Wed, 26 Jun 2024 16:44:12 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4W8FVp1GfDz2K8nj0; Wed, 26 Jun 2024 16:39:30 +0800 (CST) Received: from bj03382pcu01.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 26 Jun 2024 16:44:10 +0800 From: "zhaoyang.huang" To: Andrew Morton , David Hildenbrand , , , , Zhaoyang Huang , Subject: [RFC PATCH] mm: introduce gen information in /proc/xxx/smaps Date: Wed, 26 Jun 2024 16:44:06 +0800 Message-ID: <20240626084406.2106291-1-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.73.40] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 45Q8iCJx045005 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A0D3F4000E X-Stat-Signature: ox8b6gm7yufssxu3bisdf15mmmawyfoj X-Rspam-User: X-HE-Tag: 1719391621-155014 X-HE-Meta: U2FsdGVkX19v+Dx03H8W3Sw+lsVzAEYIm/7i9wZcxxN+UMxe2uzH98C2yV78zt2x8w3HQX34D1FvDmXGRkl8EQd5H3uD71k7ZObRWDYidxlnMPMuoUSblKGap2riwjNvyrU1UET3lYuDQCBWP9NgIJVls1MCZ5+bAnf4/rH5zm9NBRYQkHaxsk6kdgwid8xk52SS40dqPnZBQfM6EwYUidYGf5PyTcJtkKWNBXaJc1F+BA3s4Yn7stVvicLr0Y3vYogIyoK2HxVjTNdRFSYdYi7WmzewpIzCHxUiMGl5pXZvPrT99ffTTKw2c8+w12gvPO2jymbiReWpjz1yVaYLKK/tainuwDFJNuOzXogITFFjVv8q9b+BEQ78pBru84oZ33bMy1yMhgAA9/yGNuhX+RlVlKmMioUQ9m1ts5sn+uxb6VB4HqwEOhVVvMg+hfHvICxtMUE0vAWCCnflxSxOKqqB/YhAE3il3sl1nNfm1DNiFcCURmbeFC73l8Yo7bq3fW/KEdHhdYfENq5jZftecYJb4evqlAMNC6KIN4eyZaovVVmYQtvYe8KScTbfuPDUWn4aLGSLN6D5solbs/tWRlHq7kYZC6j/Ym3N9pwJaxzl/8Hh2sk9PeCYRNvb4tJJahN+FalXurKk5xLYBkJphYIYRtkDxhPA2uuOCdBZu3stJrjEy4DqcVe3M5x27Bm6majGqyJcZ4yRBFCYScR7/caagE+19kRo/acn7GqJiwWtkremBd64vABX6U/D2THFm8SUe2xgSbqnrVOfz1Wk9FgSVEMMVOfz8czHNHsaiGHlO7l12MKV4GxYJ9nfIJrwIiyC0nSF9ICnNbPUGwSF4Udol1W8dAGPXXHAaZCKP0+sPvd8Mcv14pFnL27oSJ+tsFwd7l51DfOZXiKCbIwPdEoNBpWSpbIMM/gfLQP9NxwmWsSM+K76iTuZHB77xpeENecwB0MnjH+f/CJt4Ex vJMoRPFW BIeBKBoyhaW0heQf9NI2gi7IfmllXTulUF9xUh86DoGUyiyDFFnIkGoLispZDmly9CvD2OOd5XqIMbul5z4gYXnhRt2BOoVYFzhYl6XWpt3/ydBQ0AThZqIIOfKJVp0OTZPA14aNGAqm6z5B7jKmN5ClLegqwF3roR7WTkTIWLv/jweKmtPDqFIwa9SH1iqupsJsk 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: List-Subscribe: List-Unsubscribe: From: Zhaoyang Huang Madvise_cold_and_pageout could break the LRU's balance by colding or moving the folio without taking activity information into consideration. This commit would like to introduce the folios' gen information based on VMA block via which the userspace could query the VA's activity before madvise. eg. The VMA(56c00000-56e14000) which has big Rss/Gen value suggest that it possesses larger proportion active folios than VMA(70dd7000-71090000) does and is not good candidate for madvise. 56c00000-56e14000 rw-p 00000000 00:00 0 [anon:dalvik-/system/framework/oat/arm64/services.art] Size: 2128 kB KernelPageSize: 4 kB MMUPageSize: 4 kB Rss: 2128 kB Pss: 2128 kB Pss_Dirty: 2128 kB Shared_Clean: 0 kB Shared_Dirty: 0 kB Private_Clean: 0 kB Private_Dirty: 2128 kB Referenced: 2128 kB Anonymous: 2128 kB KSM: 0 kB LazyFree: 0 kB AnonHugePages: 0 kB ShmemPmdMapped: 0 kB FilePmdMapped: 0 kB Shared_Hugetlb: 0 kB Private_Hugetlb: 0 kB Swap: 0 kB SwapPss: 0 kB Locked: 0 kB Gen: 664 THPeligible: 0 VmFlags: rd wr mr mw me ac 70dd7000-71090000 rw-p 00000000 00:00 0 [anon:dalvik-/system/framework/boot.art] Size: 2788 kB KernelPageSize: 4 kB MMUPageSize: 4 kB Rss: 2788 kB Pss: 275 kB Pss_Dirty: 275 kB Shared_Clean: 0 kB Shared_Dirty: 2584 kB Private_Clean: 0 kB Private_Dirty: 204 kB Referenced: 2716 kB Anonymous: 2788 kB KSM: 0 kB LazyFree: 0 kB AnonHugePages: 0 kB ShmemPmdMapped: 0 kB FilePmdMapped: 0 kB Shared_Hugetlb: 0 kB Private_Hugetlb: 0 kB Swap: 0 kB SwapPss: 0 kB Locked: 0 kB Gen: 1394 THPeligible: 0 Signed-off-by: Zhaoyang Huang --- fs/proc/task_mmu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index f8d35f993fe5..9731f43aa639 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -408,12 +408,23 @@ struct mem_size_stats { u64 pss_dirty; u64 pss_locked; u64 swap_pss; +#ifdef CONFIG_LRU_GEN + u64 gen; +#endif }; static void smaps_page_accumulate(struct mem_size_stats *mss, struct folio *folio, unsigned long size, unsigned long pss, bool dirty, bool locked, bool private) { +#ifdef CONFIG_LRU_GEN + int gen = folio_lru_gen(folio); + struct lru_gen_folio *lrugen = &folio_lruvec(folio)->lrugen; + + if (gen >= 0) + mss->gen += (lru_gen_from_seq(lrugen->max_seq) - gen + MAX_NR_GENS) % MAX_NR_GENS; +#endif + mss->pss += pss; if (folio_test_anon(folio)) @@ -852,6 +863,10 @@ static void __show_smap(struct seq_file *m, const struct mem_size_stats *mss, SEQ_PUT_DEC(" kB\nLocked: ", mss->pss_locked >> PSS_SHIFT); seq_puts(m, " kB\n"); +#ifdef CONFIG_LRU_GEN + seq_put_decimal_ull_width(m, "Gen: ", mss->gen, 8); + seq_puts(m, "\n"); +#endif } static int show_smap(struct seq_file *m, void *v)