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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE5EEC369B1 for ; Wed, 16 Apr 2025 07:08:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93A856B0278; Wed, 16 Apr 2025 03:08:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C3266B0279; Wed, 16 Apr 2025 03:08:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 789856B027A; Wed, 16 Apr 2025 03:08:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 593036B0278 for ; Wed, 16 Apr 2025 03:08:34 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3126680238 for ; Wed, 16 Apr 2025 07:08:34 +0000 (UTC) X-FDA: 83339028948.20.BC6460C Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf06.hostedemail.com (Postfix) with ESMTP id 0C437180004 for ; Wed, 16 Apr 2025 07:08:31 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=K9Kay7tF; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=cv3oDNpU; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=K9Kay7tF; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=cv3oDNpU; dmarc=none; spf=pass (imf06.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744787312; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0hkTgZOTiamfrHb9IMLMbFPWdmy++E0DoEdHWknt0ss=; b=mq2JwzDJBIufBqiE/ivFLpFZYC7vCC6WLsxAezHKCg/Qu9xLPRytG9eTAjIkC8rsndpM6V 40PAvufJgdEEMH9E6CA9Wlw8pdaDIsTAq6ZQBzuWU8w3qhf6cP2p8RYGn+DVE0jXB4osPf h/v4AQrX0MzgJkzIbUDGNSo5c81zBHo= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=K9Kay7tF; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=cv3oDNpU; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=K9Kay7tF; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=cv3oDNpU; dmarc=none; spf=pass (imf06.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744787312; a=rsa-sha256; cv=none; b=RRxvK1kY4EmLr/OyXuo9CqjuIbJyfP+RzbA8+E0itA4rbhRLbaMIZ+Ft8uNJL0Y6cQ/E5d qDBFjRaDWkvyp2QBhXbPuFmzxMs/wQoosauoyXGIpqpRLnzMBvHnKtQnAjr9UimnTZLXa9 kBU6AhPU13BObm10b96DEO+KOtymVMA= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3DD3B211A0; Wed, 16 Apr 2025 07:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1744787310; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0hkTgZOTiamfrHb9IMLMbFPWdmy++E0DoEdHWknt0ss=; b=K9Kay7tF7WsWBRYANBzMvleoDeU8WyDfwCbx+KLQlmOJjN9RZLOd88cLaljulrnWBdXjwm idloLV1ul+RBHpW/Ls68XUrWJPx6jxFcqnbyYnkHzaGF0VRioBC+dc3P9YhPfdWFMP+WFA zDUhbXYwySXci0Z/oSCwDog3vspSCfc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1744787310; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0hkTgZOTiamfrHb9IMLMbFPWdmy++E0DoEdHWknt0ss=; b=cv3oDNpU4eF8W8mVVnNZFlPc5ZSX/OqQ9Wj0aOuDtlDovG/YuJAl9Sy/GESD/ksRw/Bmva 35HdAlo/Ko8/J6Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1744787310; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0hkTgZOTiamfrHb9IMLMbFPWdmy++E0DoEdHWknt0ss=; b=K9Kay7tF7WsWBRYANBzMvleoDeU8WyDfwCbx+KLQlmOJjN9RZLOd88cLaljulrnWBdXjwm idloLV1ul+RBHpW/Ls68XUrWJPx6jxFcqnbyYnkHzaGF0VRioBC+dc3P9YhPfdWFMP+WFA zDUhbXYwySXci0Z/oSCwDog3vspSCfc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1744787310; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0hkTgZOTiamfrHb9IMLMbFPWdmy++E0DoEdHWknt0ss=; b=cv3oDNpU4eF8W8mVVnNZFlPc5ZSX/OqQ9Wj0aOuDtlDovG/YuJAl9Sy/GESD/ksRw/Bmva 35HdAlo/Ko8/J6Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2BA1813976; Wed, 16 Apr 2025 07:08:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Ue9kB25X/2epRgAAD6G6ig (envelope-from ); Wed, 16 Apr 2025 07:08:30 +0000 Message-ID: <9f5c4c8e-bdb4-433a-8d1b-855cbebfe88d@suse.cz> Date: Wed, 16 Apr 2025 09:08:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm, hugetlb: Avoid passing a null nodemask when there is mbind policy To: Oscar Salvador , Andrew Morton Cc: Muchun Song , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20250415121503.376811-1-osalvador@suse.de> Content-Language: en-US From: Vlastimil Babka In-Reply-To: <20250415121503.376811-1-osalvador@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: ogs59x44whi1zggxu6ajn7ni4a1nu85q X-Rspamd-Queue-Id: 0C437180004 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1744787311-781576 X-HE-Meta: U2FsdGVkX19vXj7X9ovWMm4PK4tb+c1wHMp0odnhZBzgnnMy/PT8wJd/opgvuNJKMHdFkvI8Ln2xiNI4/RTndH4Sm4/gJItFYX/xQljP7EVAL2QwHekG7hgi6h6q2TAMq1ttXCEylvyAuiI0pTpvQ6+SyLZAoSsluL/TzQ31Qio8n5qy2fSpTYdAIUQ9curI2JOonkzjlZtE7piExkSD2cypOwgLUwCUDGhT/ZxEbe91k8o5agF8ns4XjnQ7uNr3C/EUiIPSF7gRT8qiF2CS8hbbpKr1kCG5feDNCbO4xgrSlKThHRdCiUjmTKWBjO+nrCtxV2Qb8GMDPaw+AwfYDbAe5QHgTJcjGVBUhl+UXhQZdu8BPtZBXUOIsqw63xoOEL8nrMuw4eShgjEhHQQcO/CCqA8A3LKNKx9Kpls63uVr+Ppxi4ZqFSIc6Oz99fYayTLBAKLs1R8Af+Aztmc2qfaQ94R68j59Lo1SnTyn1nG28n9fil+DD7YzffRa1ero7TeGJWgi0n/twEXBmSJcZag/rEKlm0Pm8iA5t0RC+plG3E148jyJXbHJXY3WgOIb5RyiOJyBZ5JExyaj79XDh71O0WNu2AKIxnQx8yTPoNF/RpHGvlgCDm45GvH8nPwzn+PkXdJdHeLZWE6ncnlfeuClVVNfPntKigKbhyP2Tkn9n/8zqf00Tx2+PdPaYJXc63VAJWIeaTEidkKzOHYb6gxbYvFmn/5ZEGgrNsjxTocV5sRZ5ayhQIYU/1uUbXwk9ZZuRJYMSrCf4uJDRBpl3ue3Il7mnPsbK5adzn/pIInzaUq9YX7F6QND1xySYmlEdtLS78kwgtWQlZcbsbmIErHY+B9kIU502dcOSOZrDk0E9oTmu5oXbUUxDwNQZX2+domZwr2sjpfBYBvv17t1fcnGpvR+yY7ZMv+Ke5valY1kTK4pvtI9gQ== 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: List-Subscribe: List-Unsubscribe: On 4/15/25 14:15, Oscar Salvador wrote: > Before trying to allocate a page, gather_surplus_pages() sets up a nodemask > for the nodes we can allocate from, but instead of passing the nodemask > down the road to the page allocator, it iterates over the nodes within that > nodemask right there, meaning that the page allocator will receive a preferred_nid > and a null nodemask. > > This is a problem when using a memory policy, because it might be that > the page allocator ends up using a node as a fallback which is not > represented in the policy. > > Avoid that by passing the nodemask directly to the page allocator, so it can > filter out fallback nodes that are not part of the nodemask. It will also try the fallbacks using numa distance and not incrementing nid. > Signed-off-by: Oscar Salvador Reviewed-by: Vlastimil Babka > --- > mm/hugetlb.c | 22 ++++++---------------- > 1 file changed, 6 insertions(+), 16 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index ccc4f08f8481..5e1cba0f835f 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -2419,7 +2419,6 @@ static int gather_surplus_pages(struct hstate *h, long delta) > long i; > long needed, allocated; > bool alloc_ok = true; > - int node; > nodemask_t *mbind_nodemask, alloc_nodemask; > > mbind_nodemask = policy_mbind_nodemask(htlb_alloc_mask(h)); > @@ -2443,21 +2442,12 @@ static int gather_surplus_pages(struct hstate *h, long delta) > for (i = 0; i < needed; i++) { > folio = NULL; > > - /* Prioritize current node */ > - if (node_isset(numa_mem_id(), alloc_nodemask)) > - folio = alloc_surplus_hugetlb_folio(h, htlb_alloc_mask(h), > - numa_mem_id(), NULL); > - > - if (!folio) { > - for_each_node_mask(node, alloc_nodemask) { > - if (node == numa_mem_id()) > - continue; > - folio = alloc_surplus_hugetlb_folio(h, htlb_alloc_mask(h), > - node, NULL); > - if (folio) > - break; > - } > - } > + /* > + * It is okay to use NUMA_NO_NODE because we use numa_mem_id() > + * down the road to pick the current node if that is the case. > + */ > + folio = alloc_surplus_hugetlb_folio(h, htlb_alloc_mask(h), > + NUMA_NO_NODE, &alloc_nodemask); > if (!folio) { > alloc_ok = false; > break;