From patchwork Mon Jan 15 09:34:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vern Hao X-Patchwork-Id: 13519432 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 56276C47422 for ; Mon, 15 Jan 2024 09:34:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6AAE6B009A; Mon, 15 Jan 2024 04:34:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC9476B009C; Mon, 15 Jan 2024 04:34:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF3BA6B009D; Mon, 15 Jan 2024 04:34:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 95F8D6B009A for ; Mon, 15 Jan 2024 04:34:57 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6F57AC0808 for ; Mon, 15 Jan 2024 09:34:57 +0000 (UTC) X-FDA: 81681036234.11.52AD473 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by imf15.hostedemail.com (Postfix) with ESMTP id 95D95A0009 for ; Mon, 15 Jan 2024 09:34:55 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Hxt+LAXp; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of haoxing990@gmail.com designates 209.85.210.45 as permitted sender) smtp.mailfrom=haoxing990@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705311295; 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:dkim-signature; bh=2SCgXOqPBaHJ3YE4KKpTYFMJxEYoP9vWqzEHBPuX+vE=; b=ub77Hc/1xyyLDcKEsUa9NJ8bwoSoAFToV0mJ3LU9UjbODOpZFgj2IyfWtlYdzA3GiQdFwa dxIwcGnBZiwJBuI6gihH5fg16lPgUTPHpExwbdhZNJgmkTp9bi6PzWtqTcYuuqAak+YuZI kw9qeLi/YKgxbwjDdRuRkVn3tT2eGkY= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Hxt+LAXp; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of haoxing990@gmail.com designates 209.85.210.45 as permitted sender) smtp.mailfrom=haoxing990@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705311295; a=rsa-sha256; cv=none; b=Qo8SsBYYrPkpFVOFH4xU0proYI2+wvGVETV0kxNUSMv9aXzidC943B/pWeRcBKIDpnVv3T +zVliEqDkhhra/wmxm4ob4LmTPum+tm9quoq0bCRqVbWWC+Dg5rB+eqer76skauHmGJq/g PWT5xSMgD4X03JnEt16fe5n1Iwv0gr0= Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6ddeb7b4366so3546825a34.2 for ; Mon, 15 Jan 2024 01:34:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705311295; x=1705916095; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2SCgXOqPBaHJ3YE4KKpTYFMJxEYoP9vWqzEHBPuX+vE=; b=Hxt+LAXpnGY5sLxbxt6pkKbgGb6LCLKjYqK4DFQH+78CM1cV2C6H1DzdzpRCIr3bVe d49dXnbHwPVW0QnU/epeh4L5newKvMUQJ0VZ0NSgTLIOrjcDzvoM/AIPNveMSVjTwSTb 5R1MMRcqlOdYUryEEaGKzFxTjwQtfyOYJCblPzHxLSFzqPTrl1SS57r5m0l4Ogrlq1d1 EVp3KJjbARva0+Hf/v6MT0hcZmo7cwxIZ/hn8aO3x9TCsjMlOOC0Gj4LTPDm6WNv1UCl F0+sAw2Momds6FrwBJSc+2/GDYTU+4ldK8jbmO19K0ccYhtppq7iH44GOrtedaSitbWZ XCsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705311295; x=1705916095; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2SCgXOqPBaHJ3YE4KKpTYFMJxEYoP9vWqzEHBPuX+vE=; b=gDzf6srfgpnWy35D6jJHhxiU7G6EsTVu7UmMOb8zGdu1H3vkstovuqTFr251CbCUPF vpz0y8nTNNUPiZacbqaxrpCvB2ywX6Leyy3wYGjrYfUbohhlgsJzRGezSHIxm9sFepuF FQVTu3vIFfiju3m5AMe/FtcHn33pZE2v6et3ApI47za6wpNnQRmsVzrJ1nvlVVBtXuhQ TlCTjWxRvJKnXr9aeJFj4p9e/CXIhvkg25tJrGLPx7gxwk9/v4GtK3XBe5OfGv4scb6Z 4pUM3GyxW69A7NNqf4zg9I3UPRvkiW+6buJkS08ZB8vMp++IDvOuKKV4Ifa5DsUTvm2D r8fg== X-Gm-Message-State: AOJu0Yx+nPovAvdfEgAbi0YjjtScuH03mL0iPmtgNJbRHCjCQldKkqSy wgEJ7ONnkedWclYncNS73NI= X-Google-Smtp-Source: AGHT+IE0jj2s198opE4MLHJOo8KEJPjRf/vmyPe2fbkHZcvVXqNW8fP6J3CEdVeGdxXXjsygIo57Ug== X-Received: by 2002:a9d:6298:0:b0:6dd:e6f2:2ba0 with SMTP id x24-20020a9d6298000000b006dde6f22ba0mr4099609otk.49.1705311294692; Mon, 15 Jan 2024 01:34:54 -0800 (PST) Received: from VERNHAO-MC1.tencent.com ([43.132.98.40]) by smtp.gmail.com with ESMTPSA id b12-20020aa78ecc000000b006db105027basm7200686pfr.50.2024.01.15.01.34.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 15 Jan 2024 01:34:54 -0800 (PST) From: Vern Hao X-Google-Original-From: Vern Hao To: mgorman@techsingularity.net Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, haoxing990@gmail.com, Xin Hao Subject: [PATCH RFC v1 2/2] mm, pcp: add more detail info about high order page count Date: Mon, 15 Jan 2024 17:34:36 +0800 Message-ID: <20240115093437.87814-3-vernhao@tencent.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240115093437.87814-1-vernhao@tencent.com> References: <20240115093437.87814-1-vernhao@tencent.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 95D95A0009 X-Stat-Signature: rjsneot44bnzyidxsgcbh7aikg341rm5 X-Rspam-User: X-HE-Tag: 1705311295-225971 X-HE-Meta: U2FsdGVkX1+uOAFcvPLIN+9kDmcrA+a73pXIeQuZxEvpUmImpIzby/A6M2frM6eZ2LUH98RWNuS6fUrelTtGtPK8Nv0lpZDR0JS3obfmX690Is2HEzh62l/Vn1UHTBbVd53PoHHExSjjJGI0veSzVAK1WJQjuj5ef9UMcM7JIceKwNovhwt5xuf8VJprDTXMANHwcjMBuBarX5mW+wweVgd8Oevy3f/kiZEgc43467YJU1KTPCP73gIvdZJWriuW8d5QhF+O/WIceCstv7RgMcpdao8UREbnUUnkEyQuXo/TQabI9VPUdpVJrcnJwZLjOsaCPiv4S2kimXmHS01e+CyuWMMq2Db7lAvY4QsDNbNj7/CvmTdlVCqCYs6cCtpIkSwYKB1ylgcpwqD4GPbxoVEqu447wm86pXX+OpOss5uTXn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m@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Xin Hao With this patch, we can see the distribution of pages of different orders on each cpu, just like below. #cat /proc/zoneinfo .... cpu: 2 total_count: 14286 order0 : 1260 order1 : 13 order2 : 42 order3 : 4 order4 : 0 order5 : 0 order6 : 0 order7 : 0 order8 : 0 order9 : 25 order10: 0 order11: 0 order12: 0 high: 14541 batch: 63 Signed-off-by: Xin Hao --- include/linux/mmzone.h | 1 + mm/page_alloc.c | 4 ++++ mm/vmstat.c | 18 ++++++++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 883168776fea..55d25b4f51e5 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -684,6 +684,7 @@ enum zone_watermarks { struct per_cpu_pages { spinlock_t lock; /* Protects lists field */ int total_count; /* total number of pages in the list */ + int count[NR_PCP_LISTS]; /* per-order page counts */ int high; /* high watermark, emptying needed */ int high_min; /* min high watermark */ int high_max; /* max high watermark */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4e91e429b8d1..7ec2dc5c5ea5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1228,6 +1228,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, list_del(&page->pcp_list); count -= nr_pages; pcp->total_count -= nr_pages; + pcp->count[order] -= 1; /* MIGRATE_ISOLATE page should not go to pcplists */ VM_BUG_ON_PAGE(is_migrate_isolate(mt), page); @@ -2478,6 +2479,7 @@ static void free_unref_page_commit(struct zone *zone, struct per_cpu_pages *pcp, pindex = order_to_pindex(migratetype, order); list_add(&page->pcp_list, &pcp->lists[pindex]); pcp->total_count += 1 << order; + pcp->count[order] += 1; batch = READ_ONCE(pcp->batch); /* @@ -2858,6 +2860,7 @@ struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order, migratetype, alloc_flags); pcp->total_count += alloced << order; + pcp->count[order] += alloced; if (unlikely(list_empty(list))) return NULL; } @@ -2865,6 +2868,7 @@ struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order, page = list_first_entry(list, struct page, pcp_list); list_del(&page->pcp_list); pcp->total_count -= 1 << order; + pcp->count[order] -= 1; } while (check_new_pages(page, order)); return page; diff --git a/mm/vmstat.c b/mm/vmstat.c index c1e8096ff0a6..e04300ec450f 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1735,19 +1735,25 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, seq_printf(m, "\n pagesets"); for_each_online_cpu(i) { + int j; struct per_cpu_pages *pcp; struct per_cpu_zonestat __maybe_unused *pzstats; pcp = per_cpu_ptr(zone->per_cpu_pageset, i); seq_printf(m, "\n cpu: %i" - "\n count: %i" - "\n high: %i" - "\n batch: %i", + "\n total_count: %i", i, - pcp->total_count, - pcp->high, - pcp->batch); + pcp->total_count); + for (j = 0; j < NR_PCP_LISTS; j++) + seq_printf(m, + "\n order%-2i: %-3i", + j, pcp->count[j]); + seq_printf(m, + "\n high: %i" + "\n batch: %i", + pcp->high, + pcp->batch); #ifdef CONFIG_SMP pzstats = per_cpu_ptr(zone->per_cpu_zonestats, i); seq_printf(m, "\n vm stats threshold: %d",