Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3613880pxb; Mon, 21 Feb 2022 01:51:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxuGaGTKJUgiOXsN2W1QyoNrkQENuBZFlOWh88LHYVm+nHA4O8iHfa9XQu0U3Ksz/ggLKG2 X-Received: by 2002:a63:5758:0:b0:34e:b5da:7dac with SMTP id h24-20020a635758000000b0034eb5da7dacmr15444255pgm.515.1645437100424; Mon, 21 Feb 2022 01:51:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645437100; cv=none; d=google.com; s=arc-20160816; b=xUdczaN6IU8P+888i0ccoPGp+rl924Bj4Fy4YZx2J8yAblhXwnLM5t1tvSeM/JPybW 3PKz8nv4Ycixn+OkmU09NyRlvC7kHfvcUiKtDtVGx4AseLPyDaBuVQnqrFBrO4W3dDPN PgxSIJ4XK8hFKlBN7wQ9no0lQ7bbnds8Maobd5WZWOBcgTBWooHRwi7gzo8+WFVbXhFZ dy3KCed8HGlhZpU0gCUbafT7xBEyv/i5+lpCK2czFyuX58WbQIgFXn8ONi1pw9jKvhsm REpDVU058hU/+Smz+NWwppgdswb0dDyiLDx26XwRSUu4a+OFd9pfO4Sc9xP3fjJALxrI L52A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X52RU6iWqINOU3u+uEMlGvLz9xSqJ163an6YIIDaZOI=; b=K5hSt2A/IhIVml6q6QNLKJgX1iTjPYBW7/XBcZAWgEIyFE4Yo/OzvbloCsqqTv1+qn V5sKvN48n4UQCii0wlNyRkzm+75OOt1i7fLe1WzwVRerTqPgqq2BnuiZXTEsO6VIDv6C nLW256PkI2YAUVzUaHNZzlxYjdwqCT7H3bbG0ma387EoUqhYGolWetlrv4tOiy+dV30d 1gzA50JeNqdK2OobFCqbGH3U/5uDluiJhMGyktFJwuAVdmSjFL6aHc9PZnwtSGQx78xS 3jfqFwzdVTkjl8Hvf9akuE51SDS8DtnYNVO4HnzRxtVc19D2W7sa/90ZMSYG0MxBIQal bPSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PvC9fJeb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg10si6553093pjb.157.2022.02.21.01.51.27; Mon, 21 Feb 2022 01:51:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PvC9fJeb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344695AbiBUIqS (ORCPT + 99 others); Mon, 21 Feb 2022 03:46:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239931AbiBUIqN (ORCPT ); Mon, 21 Feb 2022 03:46:13 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD39413D0D for ; Mon, 21 Feb 2022 00:45:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645433150; x=1676969150; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4HCHxrBhbQYFe01Ic3R1XRJ+H18O6gzEf6OjpE+bQjM=; b=PvC9fJebMQuqiK+NKgZ9ZNQEtZ8OOU2KCg201Vv6hSMnG1oPKr6Nd+MB URdN7jY9rl0yfZFPy0ZGLAYd6zuwgOimLVF/n9ukzVBSfVOt62+fh+Lyh C3tC18g3vGdJyRZ67pSnS5IlbOIVYl5El/a+33WPc9v4L73Ps9OUOV2T6 0JMBCjinxqgm7lxVRCAPeOwh5qLikEZ+WD8BdOrnRzOSk/nvDR9GC6xpC llBnkgncjSP+pw1fuCO9/ofw6seJ5xdR3MypNtp3595mpkxg1K9tZSZlf iVcBfmq5v8FZs33pYZWxn9Tvvmr28V6RkL78eLDMdEiEEalYzO1s1pA40 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10264"; a="249045775" X-IronPort-AV: E=Sophos;i="5.88,385,1635231600"; d="scan'208";a="249045775" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2022 00:45:50 -0800 X-IronPort-AV: E=Sophos;i="5.88,385,1635231600"; d="scan'208";a="531774849" Received: from yhuang6-desk2.sh.intel.com ([10.239.13.11]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2022 00:45:46 -0800 From: Huang Ying To: Peter Zijlstra , Mel Gorman , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Feng Tang , Huang Ying , Yang Shi , Baolin Wang , Johannes Weiner , Oscar Salvador , Michal Hocko , Rik van Riel , Dave Hansen , Zi Yan , Wei Xu , Shakeel Butt , zhongjiang-ali Subject: [PATCH -V13 1/3] NUMA Balancing: add page promotion counter Date: Mon, 21 Feb 2022 16:45:27 +0800 Message-Id: <20220221084529.1052339-2-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220221084529.1052339-1-ying.huang@intel.com> References: <20220221084529.1052339-1-ying.huang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In a system with multiple memory types, e.g. DRAM and PMEM, the CPU and DRAM in one socket will be put in one NUMA node as before, while the PMEM will be put in another NUMA node as described in the description of the commit c221c0b0308f ("device-dax: "Hotplug" persistent memory for use like normal RAM"). So, the NUMA balancing mechanism will identify all PMEM accesses as remote access and try to promote the PMEM pages to DRAM. To distinguish the number of the inter-type promoted pages from that of the inter-socket migrated pages. A new vmstat count is added. The counter is per-node (count in the target node). So this can be used to identify promotion imbalance among the NUMA nodes. Signed-off-by: "Huang, Ying" Reviewed-by: Yang Shi Tested-by: Baolin Wang Reviewed-by: Baolin Wang Acked-by: Johannes Weiner Reviewed-by: Oscar Salvador Cc: Andrew Morton Cc: Michal Hocko Cc: Rik van Riel Cc: Mel Gorman Cc: Peter Zijlstra Cc: Dave Hansen Cc: Zi Yan Cc: Wei Xu Cc: Shakeel Butt Cc: zhongjiang-ali Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org --- include/linux/mmzone.h | 3 +++ include/linux/node.h | 5 +++++ mm/migrate.c | 13 ++++++++++--- mm/vmstat.c | 3 +++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index aed44e9b5d89..44bd054ca12b 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -210,6 +210,9 @@ enum node_stat_item { NR_PAGETABLE, /* used for pagetables */ #ifdef CONFIG_SWAP NR_SWAPCACHE, +#endif +#ifdef CONFIG_NUMA_BALANCING + PGPROMOTE_SUCCESS, /* promote successfully */ #endif NR_VM_NODE_STAT_ITEMS }; diff --git a/include/linux/node.h b/include/linux/node.h index bb21fd631b16..81bbf1c0afd3 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -181,4 +181,9 @@ static inline void register_hugetlbfs_with_node(node_registration_func_t reg, #define to_node(device) container_of(device, struct node, dev) +static inline bool node_is_toptier(int node) +{ + return node_state(node, N_CPU); +} + #endif /* _LINUX_NODE_H_ */ diff --git a/mm/migrate.c b/mm/migrate.c index 665dbe8cad72..cdeaf01e601a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2072,6 +2072,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, pg_data_t *pgdat = NODE_DATA(node); int isolated; int nr_remaining; + unsigned int nr_succeeded; LIST_HEAD(migratepages); new_page_t *new; bool compound; @@ -2110,7 +2111,8 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, list_add(&page->lru, &migratepages); nr_remaining = migrate_pages(&migratepages, *new, NULL, node, - MIGRATE_ASYNC, MR_NUMA_MISPLACED, NULL); + MIGRATE_ASYNC, MR_NUMA_MISPLACED, + &nr_succeeded); if (nr_remaining) { if (!list_empty(&migratepages)) { list_del(&page->lru); @@ -2119,8 +2121,13 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, putback_lru_page(page); } isolated = 0; - } else - count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_pages); + } + if (nr_succeeded) { + count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded); + if (!node_is_toptier(page_to_nid(page)) && node_is_toptier(node)) + mod_node_page_state(pgdat, PGPROMOTE_SUCCESS, + nr_succeeded); + } BUG_ON(!list_empty(&migratepages)); return isolated; diff --git a/mm/vmstat.c b/mm/vmstat.c index 4057372745d0..846b670dd346 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1242,6 +1242,9 @@ const char * const vmstat_text[] = { #ifdef CONFIG_SWAP "nr_swapcached", #endif +#ifdef CONFIG_NUMA_BALANCING + "pgpromote_success", +#endif /* enum writeback_stat_item counters */ "nr_dirty_threshold", -- 2.30.2