Skip to content

Commit b93e021

Browse files
committed
Merge: hugetlb: prioritize surplus allocation from current node
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/290 JIRA: https://issues.redhat.com/browse/RHEL-74490 Tested: by me Signed-off-by: Aristeu Rozanski <arozansk@redhat.com> Approved-by: Waiman Long <longman@redhat.com> Approved-by: Luiz Capitulino <luizcap@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 8693eb4 + f4e5676 commit b93e021

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

mm/hugetlb.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,13 @@ static int gather_surplus_pages(struct hstate *h, long delta)
24622462
long needed, allocated;
24632463
bool alloc_ok = true;
24642464
int node;
2465-
nodemask_t *mbind_nodemask = policy_mbind_nodemask(htlb_alloc_mask(h));
2465+
nodemask_t *mbind_nodemask, alloc_nodemask;
2466+
2467+
mbind_nodemask = policy_mbind_nodemask(htlb_alloc_mask(h));
2468+
if (mbind_nodemask)
2469+
nodes_and(alloc_nodemask, *mbind_nodemask, cpuset_current_mems_allowed);
2470+
else
2471+
alloc_nodemask = cpuset_current_mems_allowed;
24662472

24672473
lockdep_assert_held(&hugetlb_lock);
24682474
needed = (h->resv_huge_pages + delta) - h->free_huge_pages;
@@ -2478,8 +2484,16 @@ static int gather_surplus_pages(struct hstate *h, long delta)
24782484
spin_unlock_irq(&hugetlb_lock);
24792485
for (i = 0; i < needed; i++) {
24802486
folio = NULL;
2481-
for_each_node_mask(node, cpuset_current_mems_allowed) {
2482-
if (!mbind_nodemask || node_isset(node, *mbind_nodemask)) {
2487+
2488+
/* Prioritize current node */
2489+
if (node_isset(numa_mem_id(), alloc_nodemask))
2490+
folio = alloc_surplus_hugetlb_folio(h, htlb_alloc_mask(h),
2491+
numa_mem_id(), NULL);
2492+
2493+
if (!folio) {
2494+
for_each_node_mask(node, alloc_nodemask) {
2495+
if (node == numa_mem_id())
2496+
continue;
24832497
folio = alloc_surplus_hugetlb_folio(h, htlb_alloc_mask(h),
24842498
node, NULL);
24852499
if (folio)

0 commit comments

Comments
 (0)