From patchwork Wed Jan 26 17:00:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonghyeon Kim X-Patchwork-Id: 12725489 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 820ACC63682 for ; Wed, 26 Jan 2022 17:00:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9F4A6B0073; Wed, 26 Jan 2022 12:00:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D4E3B6B0074; Wed, 26 Jan 2022 12:00:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C16806B0075; Wed, 26 Jan 2022 12:00:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay028.a.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id B3AEB6B0073 for ; Wed, 26 Jan 2022 12:00:37 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 7D81760BD0 for ; Wed, 26 Jan 2022 17:00:37 +0000 (UTC) X-FDA: 79073052114.03.AB3E4BC Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf17.hostedemail.com (Postfix) with ESMTP id 7294B40029 for ; Wed, 26 Jan 2022 17:00:32 +0000 (UTC) Received: by mail-pf1-f182.google.com with SMTP id 128so237068pfe.12 for ; Wed, 26 Jan 2022 09:00:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ajou.ac.kr; s=google; h=from:to:cc:subject:date:message-id; bh=ZLHyK20O5fjF8tpaoo4j4wWZ9TVY0iYMrpJ/AYsNoaQ=; b=vrRs5jvx6MkUUyv2+3VMlJ0DdZKdb5shEnyiX6qp1PYWk/jGgYvTT5hwB+VXIgNNh/ Sss0qn3KCFbxifeoskWZw8SC5TMnXCX/L1/7Q6Da2k0lUBZj/MLhH6/gP/BGcjs65Ujt G1OWv1P2NOFGz8C73t9E4E0auwqGR5PwM8qrQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZLHyK20O5fjF8tpaoo4j4wWZ9TVY0iYMrpJ/AYsNoaQ=; b=MDJLV4MQXd+NKxLhk8cQiaoyzLa8+LubX/SsKiVyLHAAaDJmnNzX8we/oOkXPKKZvk OY0i9A5DKTNRdfBVuxtaw9TZsFKH/LuDyPlQGWH9dOOhREY4af7WJBT+enUx7fUSdXPU 35icF1S+jTFPQZKSfT6Rub733elFO5wV3xZOAlEZZMFneldXkQ0jgliPQW63lnaZM7v0 d6Dt7psuwWwhEVJTJvVXamHRMbuhmhbx9Q4ECLLRKUGMhFz4cqoUHJwFXhIOM6+6da72 y15yNKfK/wSPjc9dadBgRVdvG1ebEF1Bpa3n/Iy14kEWYL9nUyhkyU9eB24UZ7m27UHb gz1A== X-Gm-Message-State: AOAM531px3sfGcDdQvoHu7C8/+MwnwRbBDEVTe8OONhTg4w4ETZbZ0BI cEvecAatPC7ZlL5vYhspI2FY0A== X-Google-Smtp-Source: ABdhPJxjVpKnnpPwVrHzt9Td3FqWXgprztHCOyVZfWq6BIkg6WioylZ1Pcindlze94y0eyDQ5CLH9g== X-Received: by 2002:a65:578b:: with SMTP id b11mr11425671pgr.318.1643216431459; Wed, 26 Jan 2022 09:00:31 -0800 (PST) Received: from localhost.localdomain ([210.107.197.32]) by smtp.googlemail.com with ESMTPSA id q6sm17540644pgb.85.2022.01.26.09.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 09:00:31 -0800 (PST) From: Jonghyeon Kim To: dan.j.williams@intel.com Cc: vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jonghyeon Kim Subject: [PATCH 1/2] mm/memory_hotplug: Export shrink span functions for zone and node Date: Thu, 27 Jan 2022 02:00:01 +0900 Message-Id: <20220126170002.19754-1-tome01@ajou.ac.kr> X-Mailer: git-send-email 2.17.1 X-Stat-Signature: 88yp7t43wz7dkwsiznxapnq3r998tz5p X-Rspam-User: nil Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=ajou.ac.kr header.s=google header.b=vrRs5jvx; spf=pass (imf17.hostedemail.com: domain of tome01@ajou.ac.kr designates 209.85.210.182 as permitted sender) smtp.mailfrom=tome01@ajou.ac.kr; dmarc=pass (policy=reject) header.from=ajou.ac.kr X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 7294B40029 X-HE-Tag: 1643216432-982721 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000399, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Export shrink_zone_span() and update_pgdat_span() functions to head file. We need to update real number of spanned pages for NUMA nodes and zones when we add memory device node such as device dax memory. Signed-off-by: Jonghyeon Kim --- include/linux/memory_hotplug.h | 3 +++ mm/memory_hotplug.c | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index be48e003a518..25c7f60c317e 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -337,6 +337,9 @@ extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, extern void remove_pfn_range_from_zone(struct zone *zone, unsigned long start_pfn, unsigned long nr_pages); +extern void shrink_zone_span(struct zone *zone, unsigned long start_pfn, + unsigned long end_pfn); +extern void update_pgdat_span(struct pglist_data *pgdat); extern bool is_memblock_offlined(struct memory_block *mem); extern int sparse_add_section(int nid, unsigned long pfn, unsigned long nr_pages, struct vmem_altmap *altmap); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 2a9627dc784c..38f46a9ef853 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -389,7 +389,7 @@ static unsigned long find_biggest_section_pfn(int nid, struct zone *zone, return 0; } -static void shrink_zone_span(struct zone *zone, unsigned long start_pfn, +void shrink_zone_span(struct zone *zone, unsigned long start_pfn, unsigned long end_pfn) { unsigned long pfn; @@ -428,8 +428,9 @@ static void shrink_zone_span(struct zone *zone, unsigned long start_pfn, } } } +EXPORT_SYMBOL_GPL(shrink_zone_span); -static void update_pgdat_span(struct pglist_data *pgdat) +void update_pgdat_span(struct pglist_data *pgdat) { unsigned long node_start_pfn = 0, node_end_pfn = 0; struct zone *zone; @@ -456,6 +457,7 @@ static void update_pgdat_span(struct pglist_data *pgdat) pgdat->node_start_pfn = node_start_pfn; pgdat->node_spanned_pages = node_end_pfn - node_start_pfn; } +EXPORT_SYMBOL_GPL(update_pgdat_span); void __ref remove_pfn_range_from_zone(struct zone *zone, unsigned long start_pfn, From patchwork Wed Jan 26 17:00:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonghyeon Kim X-Patchwork-Id: 12725490 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 B7B19C63682 for ; Wed, 26 Jan 2022 17:01:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5128C6B0071; Wed, 26 Jan 2022 12:01:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C2C26B0074; Wed, 26 Jan 2022 12:01:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38A816B0075; Wed, 26 Jan 2022 12:01:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id 29B546B0071 for ; Wed, 26 Jan 2022 12:01:05 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DBCE6181CB145 for ; Wed, 26 Jan 2022 17:01:04 +0000 (UTC) X-FDA: 79073053248.29.0F41729 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf25.hostedemail.com (Postfix) with ESMTP id 8A4AAA0088 for ; Wed, 26 Jan 2022 17:00:42 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id y27so305173pfa.0 for ; Wed, 26 Jan 2022 09:00:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ajou.ac.kr; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Onl1JpmjZEa6zJu2g35kLpJMmMBIoxN/vI9o07uZnSE=; b=vG81hp3GKcDmDaHOEl5NZqjWXqgKUrX8vpZ4U+RfzlWC0F5JUgHlxzbXhrzgfjS//A HUeiYP+XaNjRlzyClU0pNEVdAgc/UC/0hICDjqLbIw8LfYGJ4jUW+PffSJFnRHLctw6A 0V627+CXnH7SJVSr2BOcS8aAGbFY3INNRdSF0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Onl1JpmjZEa6zJu2g35kLpJMmMBIoxN/vI9o07uZnSE=; b=K0ul17cA/w7eG5ReG7PNIRJWqVS+FZuY+Gq8vi7+725nrNQF8XY3OBTYUcjUzTumLv q9TjDB/u8wZqgk56Dsm95EIhrjfwx0tpBGsEfCcoq+0DjnIsFMay4Qz8rwzMStuXaiOd Xt2ht8a95SfYzuKX0x/FYdk6JTkKNJSmd4+APFznku7MMAoY+IXstZewbqUpin6Zmph1 o03Ey0cFqZOCdRcmx7QsBxi9FPn7srJ9Iq8NLaOZcDOHmA29vs0hj3pLCFXkRgvewD/t AF5LKpR7Yb9tDCdmTT0kN2PJre2/cOCpB2DjeE8OKqEM279opdt5v7CK3UGBoKTH9OW0 xZAw== X-Gm-Message-State: AOAM5329RyRs3eHnkCcu4Jpd5pFeIiYmSmarROaPzxjzYf70snpB3joy 9PDiqbg6BbMfaOe72sHOaTOGda3aOMMhFwZYKMg= X-Google-Smtp-Source: ABdhPJzhTWxkvUgBtwM91u+cYKbIdx3dFiNFTCB+D62IGdpTAENUFNPgH4+d0xS7tt+MSUEXK5AAeQ== X-Received: by 2002:aa7:9009:0:b0:4c6:fe2f:6a94 with SMTP id m9-20020aa79009000000b004c6fe2f6a94mr11307661pfo.25.1643216441424; Wed, 26 Jan 2022 09:00:41 -0800 (PST) Received: from localhost.localdomain ([210.107.197.32]) by smtp.googlemail.com with ESMTPSA id q6sm17540644pgb.85.2022.01.26.09.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 09:00:41 -0800 (PST) From: Jonghyeon Kim To: dan.j.williams@intel.com Cc: vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jonghyeon Kim Subject: [PATCH 2/2] dax/kmem: Update spanned page stat of origin device node Date: Thu, 27 Jan 2022 02:00:02 +0900 Message-Id: <20220126170002.19754-2-tome01@ajou.ac.kr> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220126170002.19754-1-tome01@ajou.ac.kr> References: <20220126170002.19754-1-tome01@ajou.ac.kr> X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8A4AAA0088 X-Stat-Signature: t8jx1yxhj7b73xg1t97btgetknftw56z Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=ajou.ac.kr header.s=google header.b=vG81hp3G; dmarc=pass (policy=reject) header.from=ajou.ac.kr; spf=pass (imf25.hostedemail.com: domain of tome01@ajou.ac.kr designates 209.85.210.178 as permitted sender) smtp.mailfrom=tome01@ajou.ac.kr X-HE-Tag: 1643216442-744143 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001464, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When device memory adds to the online NUMA node, the number of spanned pages of the original device NUMA node should be updated. By this patch, we can monitor the current spanned pages of each node more accurately. Signed-off-by: Jonghyeon Kim Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/dax/kmem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index a37622060fff..f63a739ac790 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "dax-private.h" #include "bus.h" @@ -48,6 +49,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) struct dax_kmem_data *data; int i, rc, mapped = 0; int numa_node; + int dev_node; /* * Ensure good NUMA information for the persistent memory. @@ -147,6 +149,18 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) dev_set_drvdata(dev, data); + /* Update spanned_pages of the device numa node */ + dev_node = dev_to_node(dev); + if (dev_node != numa_node && dev_node < numa_node) { + struct pglist_data *pgdat = NODE_DATA(dev_node); + struct zone *zone = &pgdat->node_zones[ZONE_DEVICE]; + unsigned long start_pfn = zone->zone_start_pfn; + unsigned long nr_pages = NODE_DATA(numa_node)->node_spanned_pages; + + shrink_zone_span(zone, start_pfn, start_pfn + nr_pages); + update_pgdat_span(pgdat); + } + return 0; err_request_mem: