Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp234981rdb; Mon, 22 Jan 2024 02:22:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkLfCpJPMvq66D9sV694GrOW59gAQrCG4Dfm90oGjSXvUulCZBXNZ4KdnQV+vknjuWAcpZ X-Received: by 2002:a05:6a00:1792:b0:6db:e098:80ee with SMTP id s18-20020a056a00179200b006dbe09880eemr1639561pfg.17.1705918942677; Mon, 22 Jan 2024 02:22:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705918942; cv=pass; d=google.com; s=arc-20160816; b=zqvpD4wrW2YdMqZDoDrJIFbN8fULdjU5p82SRLDtQGavAut02ZJjirlT9AGxB2XiGH KqJDQ7cCLH/y9hqMeekyoGPFqgKkBvpT272H/NXgs+ddDkU67qK9P1Q9Pq4K9GeXvT4s 8oE8GSTLPT8Cu12rShD40pEZT5K/NDXWyBWoYUagAloW04FBk0lUFxP3UceT3BJM69c0 Ah6ATkQBSgYRlhZDuWDKBm3IR+4domswco0mSDLRVAvPlG5aWWBuNitQBrkPofj59cof ITQ9aIxeA8kpN70Hy6/jWJvZVZ8qP8AwfAu7H33ssWT3DDSIe5VNANmKs0qK3oSo7lkm +ELw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=wuYC06RX3OtM9f7oUAxUdtkdP4RrZ1CoNtn1dGQVcuw=; fh=AYxwyR3J/kPtM4magQIyzlUdQEW2jx+zDn9RDMQmKe0=; b=yUlgHnD1MeaFV6oYjSaAU4X6t5nPdRr1xXuoxa73y7a9AGrvbLWE3Tugf1LZ8Gn+eb IuPq+oa183zezf8VbQAMrlx9fyioYBJvi3qnZ3X7EP0DefdGH45hYLMJ4jARk0I15hjz gx/dVlDSqFPzFCynNlWIBDjgVR9HPcbhEzm8qHy/H4ddFbyH9bAAYMEQfGpU7+T7hbHg iWXFV0+0YQpR07z4HewicDwoIRb5YKT0dLygtSUHmOxgRKAF6A8sMAgv3HouDoSsdgjK 44hHKi8eekrxFj1Ha5aa+kIteRH0ETjbNnB9r1hJngzIVekKraBZGGvm8dmRMJYTLTlu PpVA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Yk8ugVUB; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-32671-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32671-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v6-20020a62a506000000b006dbe7073ce1si716606pfm.201.2024.01.22.02.22.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 02:22:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32671-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Yk8ugVUB; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-32671-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32671-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 919C0B22D51 for ; Mon, 22 Jan 2024 09:52:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE4EF3A8DC; Mon, 22 Jan 2024 09:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Yk8ugVUB" Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39B863A8C5 for ; Mon, 22 Jan 2024 09:51:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705917071; cv=none; b=Gra8oWs/da1XAOBVjBb0Rj5UKrfeqhHE0S3qDmLRNzR29iTF7DJGJAHakWUJczuAmCPnhtev/wnBN3ZdNkV8V98ldGcDw4aoXSnR+a4RM4h9S/2xFTyPzrpRKfbL/jis0iqVUDoejfJHoWVL6uky41GGVH8wGpiKerCsOBzZni4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705917071; c=relaxed/simple; bh=w8DEEbROLnC6K+V6qLygCGRyL7ECn+rsYZ/7tXTMPbM=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=KRankZRP9ZVSxXOF7zijzUf7s2cn/4agFysHPSf7BHkZ/K9KOPuCekVIWuNx1qXbJBw3ogaOY/XS50m9TazJBFtRm5coFPwAdTKbK702in2iq+UvFnsVtKU1vvHL7XzpivP9AtfNXNYgfX/SLMMfVohAI4xutgBIi+9zLHycL60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Yk8ugVUB; arc=none smtp.client-ip=95.215.58.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705917065; 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=wuYC06RX3OtM9f7oUAxUdtkdP4RrZ1CoNtn1dGQVcuw=; b=Yk8ugVUBfKEAMZ0SoNd9vUrDnjdTkUXZ3EdpoOmDf9zJcVu76WkfDSXoDfd9p2C1620yZh QkHajUAFf5P8I7HJ5vuvu6uqRpvePsmntng+NB8tRw8R9pE78BDgFFbsyMH80uBQj0Qm2j bWZG3e2tiWPC814YXlaDIS9AjbU8TOA= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Subject: Re: [PATCH v4 4/7] hugetlb: pass *next_nid_to_alloc directly to for_each_node_mask_to_alloc X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: Date: Mon, 22 Jan 2024 17:50:26 +0800 Cc: David Hildenbrand , David Rientjes , Mike Kravetz , Andrew Morton , Tim Chen , Linux-MM , LKML , ligang.bdlg@bytedance.com Content-Transfer-Encoding: quoted-printable Message-Id: <84380389-0922-4073-B4C7-DBF9F865E162@linux.dev> References: <20240118123911.88833-1-gang.li@linux.dev> <20240118123911.88833-5-gang.li@linux.dev> To: Gang Li X-Migadu-Flow: FLOW_OUT > On Jan 22, 2024, at 17:14, Gang Li wrote: >=20 > 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 =3D 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. >=20 > 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. Yes. When I read your patch 6, I realized this. >=20 > 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.