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 72E25C4725D for ; Mon, 22 Jan 2024 09:14:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDE3B6B0078; Mon, 22 Jan 2024 04:14:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B8E216B007E; Mon, 22 Jan 2024 04:14:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7D036B0080; Mon, 22 Jan 2024 04:14:48 -0500 (EST) 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 975796B0078 for ; Mon, 22 Jan 2024 04:14:48 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 619E71A027D for ; Mon, 22 Jan 2024 09:14:48 +0000 (UTC) X-FDA: 81706387056.05.5C897FC Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) by imf02.hostedemail.com (Postfix) with ESMTP id 6053780008 for ; Mon, 22 Jan 2024 09:14:46 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Isc2BeNg; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf02.hostedemail.com: domain of gang.li@linux.dev designates 95.215.58.182 as permitted sender) smtp.mailfrom=gang.li@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705914886; 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=2lP5WZIQefovoUpcgS/TdLZH0rQJtQEYYdZtxKrIHJY=; b=lclQRqyLry7DWVYA8Gaq7je6vI+1qrhVbwSbqxdt3ywvecuPWsaWirEj+/O8xYB9prQZP0 MQKenrHa0MlqHjicTBE6AlRFMKWU3pKR2s0K0QasiMF2NfMNOKo2L3KUBo/Z/cfHNZewr6 PymrWgTQzMge5z4LFaIuP0hFDCv9+no= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Isc2BeNg; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf02.hostedemail.com: domain of gang.li@linux.dev designates 95.215.58.182 as permitted sender) smtp.mailfrom=gang.li@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705914886; a=rsa-sha256; cv=none; b=1SqFO0YK4980w5dpCBUKp9hGoxtIMU1lMIRcjgIcxliKaDJP6oHoQlCa+kF5T5UNI4jYJf MBDrLKrrzzA+3anufc4VfL7t10KY/+eP/hVPPSZ35jr/1/Tjeids6re2goaPsUx1KLlr5Q ayGuAw/dpzl0ebYaNnZ8CjATnji8+nM= Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705914884; h=from:from: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; bh=2lP5WZIQefovoUpcgS/TdLZH0rQJtQEYYdZtxKrIHJY=; b=Isc2BeNgilmq13B5rv9/2uKlx48sNVonOO2SChSOy5jzvXv3O8smUIfQq+XqSvgJxjsCiQ ncUbk/eA1IhtF4M9eokgHfbk6sK0R9qQbBL5dDNhr4c+HZ8cnHrjBR8AN7B1TV1p/NNAy1 Bb4/Db7MBcTqGtbKCdc6e2TojrYL13A= Date: Mon, 22 Jan 2024 17:14:33 +0800 MIME-Version: 1.0 Subject: Re: [PATCH v4 4/7] hugetlb: pass *next_nid_to_alloc directly to for_each_node_mask_to_alloc Content-Language: en-US To: Muchun Song , David Hildenbrand , David Rientjes , Mike Kravetz , Andrew Morton , Tim Chen Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, ligang.bdlg@bytedance.com References: <20240118123911.88833-1-gang.li@linux.dev> <20240118123911.88833-5-gang.li@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Gang Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: 9ij9bppnnkuegpnk4sf7wunuo89w9r6c X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6053780008 X-HE-Tag: 1705914886-105386 X-HE-Meta: U2FsdGVkX1/ymMyKdCRff3JGZyuTDgceWAaP2VyymxOtuVCKxsRcEuFR9btMtE5INczwrJXW4qaiRkia8Jf2LF/aVYJ0QoTd5MRR8yv9ctHZBg2hVcgiReFzTUQa60uaaMzb+q7xzGARTR+M0nyiUFuZhewu941ZoVBMKMg5Ay3hrtgKqYglic93FlzDp83Aw6V+PBHAu/6CCIn6Ac0FNzYGGxSOteA1bxtwCmh5pb8fhFg0LfFQsoQ61EKqRPpP+Os0UyCJESe/2EswlQK5YGbIzrjfqQvp4j4AZTwTM1H+YMVkt7jU7PGRfW93UqPPWHBFXHOOiw98htRIKTvNAidAPn7AI7uW392OgmOyRF7uB8ehjDP80BhgqMKEmjCuuO9gJyce1GCGBkfbaRE1BT3CAcFTMLZPZcy4Or2Va6ykXOzKYVnZD4m7s19ioAbietmyYm+tFrUuyq+YIsgNLuQBMgQS/j7KCrMGDgxLzgfdMM1bJcE++rWUl/tNAULRjw6n5tM5JEVB/AQT5vQuCA6yA6nF57/VF1jVC8j07L1vRS4cuZWFWQcqiXSf3E1TsvRDxPcqLF9DDztCGzLxFvrNfzmuOSBiavX4y+fCl8ZkSuPVu1hjRARMlZiQYjZi/OgEMvSzBzRSJ3f3GhslTY+w35UWaZnAXNq13/6ujU+lD173R3adt62liyrrt3xhRoBuPV9OXh/D2ei3f47Dfsg9zRHsN7HmtNVhcoPIkvtoGyKJwiA3ECFBgazk20VKQUJfc8dQCCPbq8dp1U9h8mPOkxderkAv6eFlhmO3/F02kjLNdjdb+YpWSwTNsUZsw34naTqVqQiNTg5C7Gxrs1Zkf2GIDXM8Y4VGcq0xOSp6KuqKGUoR/f4uCH5xmunDq0g4J9ZJ2QXDonSyO7oBSAS+e4FXxqG0cTI3cxdtSLTGu8vrLcF0lpeHXMZ2OhjXq9/HGrYJUsvr0FLdn3D gMfDS/NV lAIAx0jFfQy3CSTu3oflJo4UZaVXSIfWkeR4n92TrHGdLlDD1T792yNaV2ubmfVjcxeRvVvIdiqLi+n5bnO69/S0e9XIqP32Lduu2CMXfI5FQVCE+sgHU1ogwPaCsI+F8aDby 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 2024/1/22 14:16, Muchun Song wrote: > On 2024/1/18 20:39, Gang Li wrote: >>   static struct folio *alloc_pool_huge_folio(struct hstate *h, >>                       nodemask_t *nodes_allowed, >> -                    nodemask_t *node_alloc_noretry) >> +                    nodemask_t *node_alloc_noretry, >> +                    int *next_node) >>   { >>       gfp_t gfp_mask = htlb_alloc_mask(h) | __GFP_THISNODE; >>       int nr_nodes, node; >> -    for_each_node_mask_to_alloc(h, nr_nodes, node, nodes_allowed) { >> +    for_each_node_mask_to_alloc(next_node, nr_nodes, node, >> nodes_allowed) { > > > A small question here, why not pass h->next_nid_to_alloc to > for_each_node_mask_to_alloc()? What's the purpose of the third > parameter of alloc_pool_huge_folio()? > > Thanks. > In hugetlb_alloc_node->alloc_pool_huge_folio, hugetlb is initialized in parallel at boot time, then it needs each thread to have its own next_nid, and can't use the global h->next_nid_to_alloc. so an extra parameter is added. And h->next_nid_to_alloc in set_max_huge_pages->alloc_pool_huge_folio can not be removed. Because if the user calls set_max_huge_pages frequently and only adds 1 page at a time, that would result in each request being made on the same node if local variables are used.