From: "Huang, Ying" <ying.huang@intel.com>
To: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: <akpm@linux-foundation.org>, <dave.hansen@linux.intel.com>,
<ziy@nvidia.com>, <osalvador@suse.de>, <shy828301@gmail.com>,
<zhongjiang-ali@linux.alibaba.com>, <xlpang@linux.alibaba.com>,
<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] mm: migrate: Allocate the node_demotion structure dynamically
Date: Fri, 12 Nov 2021 07:39:39 +0800 [thread overview]
Message-ID: <8735o2mfd0.fsf@yhuang6-desk2.ccr.corp.intel.com> (raw)
In-Reply-To: <c08caa62-82af-0254-1e77-aa02d1ce53e5@linux.alibaba.com> (Baolin Wang's message of "Thu, 11 Nov 2021 19:20:11 +0800")
Baolin Wang <baolin.wang@linux.alibaba.com> writes:
> On 2021/11/11 16:51, Huang, Ying wrote:
>> Baolin Wang <baolin.wang@linux.alibaba.com> 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 <baolin.wang@linux.alibaba.com>
>>> ---
>>> 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
>
> Yes, looks better.
>
>> static struct demotion_nodes *node_demotion;
>> Then we can allocate nr_node_ids * sizeof(struct demotion_nodes) for
>> node_demotion.
>
> Yeah, this is simple. The reason I want to declare the structure like
> "struct demotion_nodes *node_demotion[MAX_NUMNODES]" is that, we can
> validate the non-possible nodes which are invalid to demote memory,
> and in case the node_demotion[nid] is failed to be allocated which can
> be validated, though this is unlikely.
In case allocation failure, we can still check "node_demotion == NULL".
Best Regards,
Huang, Ying
> However, I agree with you to
> keep things simple now and can be merged into patch 1. Will do in next
> version. Thanks.
prev parent reply other threads:[~2021-11-11 23:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 7:48 [PATCH v2 0/2] Support multiple target nodes demotion Baolin Wang
2021-11-11 7:48 ` [PATCH v2 1/2] mm: migrate: " Baolin Wang
2021-11-11 8:20 ` Huang, Ying
2021-11-11 10:52 ` Baolin Wang
2021-11-11 7:48 ` [PATCH v2 2/2] mm: migrate: Allocate the node_demotion structure dynamically Baolin Wang
2021-11-11 8:51 ` Huang, Ying
2021-11-11 11:20 ` Baolin Wang
2021-11-11 23:39 ` Huang, Ying [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735o2mfd0.fsf@yhuang6-desk2.ccr.corp.intel.com \
--to=ying.huang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=shy828301@gmail.com \
--cc=xlpang@linux.alibaba.com \
--cc=zhongjiang-ali@linux.alibaba.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).