From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADC4EC433F5 for ; Thu, 11 Nov 2021 08:51:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4131C6162E for ; Thu, 11 Nov 2021 08:51:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4131C6162E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9A5F56B009F; Thu, 11 Nov 2021 03:51:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 956D86B00A0; Thu, 11 Nov 2021 03:51:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 843BC6B00A1; Thu, 11 Nov 2021 03:51:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 749776B009F for ; Thu, 11 Nov 2021 03:51:44 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 38CF9805A7 for ; Thu, 11 Nov 2021 08:51:44 +0000 (UTC) X-FDA: 78796031328.18.8A9DC61 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf04.hostedemail.com (Postfix) with ESMTP id A68845000307 for ; Thu, 11 Nov 2021 08:51:32 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10164"; a="213599051" X-IronPort-AV: E=Sophos;i="5.87,225,1631602800"; d="scan'208";a="213599051" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2021 00:51:41 -0800 X-IronPort-AV: E=Sophos;i="5.87,225,1631602800"; d="scan'208";a="492465439" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.159.101]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2021 00:51:37 -0800 From: "Huang, Ying" To: Baolin Wang Cc: , , , , , , , , Subject: Re: [PATCH v2 2/2] mm: migrate: Allocate the node_demotion structure dynamically References: Date: Thu, 11 Nov 2021 16:51:35 +0800 In-Reply-To: (Baolin Wang's message of "Thu, 11 Nov 2021 15:48:35 +0800") Message-ID: <87pmr7m5wo.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A68845000307 X-Stat-Signature: jid9iswhzjmeq8ew8y76qi38jdhiwsw1 Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf04.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=ying.huang@intel.com X-HE-Tag: 1636620692-915828 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: Baolin Wang writes: > For the worst case (MAX_NUMNODES=1024), the node_demotion structure can > consume 32k bytes, which appears too large, so we can change to allocate > node_demotion dynamically at initialization time. Meanwhile allocating > the target demotion nodes array dynamically to select a suitable size > according to the MAX_NUMNODES. > > Signed-off-by: Baolin Wang > --- > mm/migrate.c | 38 +++++++++++++++++++++++++++++--------- > 1 file changed, 29 insertions(+), 9 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index 126e9e6..0145b38 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1152,10 +1152,11 @@ static int __unmap_and_move(struct page *page, struct page *newpage, > #define DEFAULT_DEMOTION_TARGET_NODES 15 > struct demotion_nodes { > unsigned short nr; > - short nodes[DEFAULT_DEMOTION_TARGET_NODES]; > + short nodes[]; > }; > > -static struct demotion_nodes node_demotion[MAX_NUMNODES] __read_mostly; > +static struct demotion_nodes *node_demotion[MAX_NUMNODES] __read_mostly; > +static unsigned short target_nodes_max; I think we can use something as below, #if MAX_NUMNODES < DEFAULT_DEMOTION_TARGET_NODES #define DEMOTION_TARGET_NODES (MAX_NUMNODES - 1) #else #define DEMOTION_TARGET_NODES DEFAULT_DEMOTION_TARGET_NODES #endif static struct demotion_nodes *node_demotion; Then we can allocate nr_node_ids * sizeof(struct demotion_nodes) for node_demotion. Best Regards, Huang, Ying [snip]