From: Alistair Popple <apopple@nvidia.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
Wei Xu <weixugc@google.com>, Huang Ying <ying.huang@intel.com>,
Yang Shi <shy828301@gmail.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Tim C Chen <tim.c.chen@intel.com>,
Michal Hocko <mhocko@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Hesham Almatary <hesham.almatary@huawei.com>,
Dave Hansen <dave.hansen@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Dan Williams <dan.j.williams@intel.com>,
Jagdish Gediya <jvgediya@linux.ibm.com>
Subject: Re: [PATCH v7 09/12] mm/demotion: Demote pages according to allocation fallback order
Date: Thu, 23 Jun 2022 12:53:10 +1000 [thread overview]
Message-ID: <87czf06q1i.fsf@nvdebian.thelocal> (raw)
In-Reply-To: <20220622082513.467538-10-aneesh.kumar@linux.ibm.com>
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
> From: Jagdish Gediya <jvgediya@linux.ibm.com>
[...]
> -static struct page *alloc_demote_page(struct page *page, unsigned long node)
> +static struct page *alloc_demote_page(struct page *page, unsigned long private)
> {
> - struct migration_target_control mtc = {
> - /*
> - * Allocate from 'node', or fail quickly and quietly.
> - * When this happens, 'page' will likely just be discarded
> - * instead of migrated.
> - */
> - .gfp_mask = (GFP_HIGHUSER_MOVABLE & ~__GFP_RECLAIM) |
> - __GFP_THISNODE | __GFP_NOWARN |
> - __GFP_NOMEMALLOC | GFP_NOWAIT,
> - .nid = node
> - };
> + struct page *target_page;
> + nodemask_t *allowed_mask;
> + struct migration_target_control *mtc;
> +
> + mtc = (struct migration_target_control *)private;
> +
> + allowed_mask = mtc->nmask;
> + /*
> + * make sure we allocate from the target node first also trying to
> + * reclaim pages from the target node via kswapd if we are low on
> + * free memory on target node. If we don't do this and if we have low
> + * free memory on the target memtier, we would start allocating pages
> + * from higher memory tiers without even forcing a demotion of cold
> + * pages from the target memtier. This can result in the kernel placing
> + * hotpages in higher memory tiers.
> + */
> + mtc->nmask = NULL;
> + mtc->gfp_mask |= __GFP_THISNODE;
> + target_page = alloc_migration_target(page, (unsigned long)&mtc);
I finally managed to get a system setup to start testing some of this
out. However it quickly crashed due to the bad pointer in the above call
- you need mtc not &mtc here.
> + if (target_page)
> + return target_page;
> +
> + mtc->gfp_mask &= ~__GFP_THISNODE;
> + mtc->nmask = allowed_mask;
>
> return alloc_migration_target(page, (unsigned long)&mtc);
And here.
> }
> @@ -1487,6 +1500,19 @@ static unsigned int demote_page_list(struct list_head *demote_pages,
> {
> int target_nid = next_demotion_node(pgdat->node_id);
> unsigned int nr_succeeded;
> + nodemask_t allowed_mask;
> +
> + struct migration_target_control mtc = {
> + /*
> + * Allocate from 'node', or fail quickly and quietly.
> + * When this happens, 'page' will likely just be discarded
> + * instead of migrated.
> + */
> + .gfp_mask = (GFP_HIGHUSER_MOVABLE & ~__GFP_RECLAIM) | __GFP_NOWARN |
> + __GFP_NOMEMALLOC | GFP_NOWAIT,
> + .nid = target_nid,
> + .nmask = &allowed_mask
> + };
>
> if (list_empty(demote_pages))
> return 0;
> @@ -1494,10 +1520,12 @@ static unsigned int demote_page_list(struct list_head *demote_pages,
> if (target_nid == NUMA_NO_NODE)
> return 0;
>
> + node_get_allowed_targets(pgdat, &allowed_mask);
> +
> /* Demotion ignores all cpuset and mempolicy settings */
> migrate_pages(demote_pages, alloc_demote_page, NULL,
> - target_nid, MIGRATE_ASYNC, MR_DEMOTION,
> - &nr_succeeded);
> + (unsigned long)&mtc, MIGRATE_ASYNC, MR_DEMOTION,
> + &nr_succeeded);
>
> if (current_is_kswapd())
> __count_vm_events(PGDEMOTE_KSWAPD, nr_succeeded);
next prev parent reply other threads:[~2022-06-23 3:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 8:25 [PATCH v7 00/12] mm/demotion: Memory tiers and demotion Aneesh Kumar K.V
2022-06-22 8:25 ` [PATCH v7 01/12] mm/demotion: Add support for explicit memory tiers Aneesh Kumar K.V
2022-06-22 8:25 ` [PATCH v7 02/12] mm/demotion: Move memory demotion related code Aneesh Kumar K.V
2022-06-22 8:25 ` [PATCH v7 03/12] mm/demotion/dax/kmem: Set node's memory tier to MEMORY_TIER_PMEM Aneesh Kumar K.V
2022-06-22 8:25 ` [PATCH v7 04/12] mm/demotion: Add hotplug callbacks to handle new numa node onlined Aneesh Kumar K.V
2022-06-22 8:25 ` [PATCH v7 05/12] mm/demotion: Build demotion targets based on explicit memory tiers Aneesh Kumar K.V
2022-06-22 8:25 ` [PATCH v7 06/12] mm/demotion: Expose memory tier details via sysfs Aneesh Kumar K.V
2022-06-22 8:25 ` [PATCH v7 07/12] mm/demotion: Add per node memory tier attribute to sysfs Aneesh Kumar K.V
2022-06-22 8:25 ` [PATCH v7 08/12] mm/demotion: Add pg_data_t member to track node memory tier details Aneesh Kumar K.V
2022-06-22 22:52 ` kernel test robot
2022-06-22 8:25 ` [PATCH v7 09/12] mm/demotion: Demote pages according to allocation fallback order Aneesh Kumar K.V
2022-06-23 2:53 ` Alistair Popple [this message]
2022-06-27 3:54 ` Aneesh Kumar K.V
2022-06-27 4:18 ` Alistair Popple
2022-06-22 8:25 ` [PATCH v7 10/12] mm/demotion: Update node_is_toptier to work with memory tiers Aneesh Kumar K.V
2022-06-22 8:25 ` [PATCH v7 11/12] mm/demotion: Add documentation for memory tiering Aneesh Kumar K.V
2022-06-22 21:21 ` kernel test robot
2022-06-25 2:56 ` Bagas Sanjaya
2022-06-25 4:13 ` Bagas Sanjaya
2022-06-27 4:40 ` Aneesh Kumar K.V
2022-06-30 0:57 ` Souptick Joarder
2022-06-22 8:25 ` [PATCH v7 12/12] mm/demotion: Add sysfs ABI documentation Aneesh Kumar K.V
2022-06-22 11:06 ` [PATCH v7 00/12] mm/demotion: Memory tiers and demotion Aneesh Kumar K.V
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=87czf06q1i.fsf@nvdebian.thelocal \
--to=apopple@nvidia.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=dave@stgolabs.net \
--cc=hesham.almatary@huawei.com \
--cc=jvgediya@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=shy828301@gmail.com \
--cc=tim.c.chen@intel.com \
--cc=weixugc@google.com \
--cc=ying.huang@intel.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