Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp217675rdb; Mon, 22 Jan 2024 01:38:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+tEvg4scW/X6yLJNiKbu8HKDfCuNXU5Sep/COxo8XtV1Xl/rrYAC4yEvv6gWmBSHw51tZ X-Received: by 2002:a05:6a00:1384:b0:6da:d8b7:d442 with SMTP id t4-20020a056a00138400b006dad8b7d442mr2101047pfg.6.1705916318013; Mon, 22 Jan 2024 01:38:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705916317; cv=pass; d=google.com; s=arc-20160816; b=nzxegJyA4LvlMK0CvX+YgEqR3uYU1FbNiwveURz32P5Q9WmCnIuo07y3ZD39mKLRRt 2jL78YiylG3OqGAG4tZ2jXipmHySP1SU35dx+RM3PYeBgE/LaaUmbSQaBbt1Xh7yLjsE 9UEyMpU2d04nTzcsAF0KbYKBP44GdBFtzsfL6rSYah/0zvZdL5FDojqn4IP1m1/j4e8r j5o4LueQGcjlXD7A9O4DigPNuIhgbMbaAkbG1E67CkHoTaTgQYd2r3eCEEHabd73WZC8 Go8A1kwBhIwlF7uZ6gKE0EHGGDE2FMnMrqCz7sDVduKvZrFKzpu8C1e7CPD6DCJYgodK 5YWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=2lP5WZIQefovoUpcgS/TdLZH0rQJtQEYYdZtxKrIHJY=; fh=c+Ry74MH7F5NutkJtGr+OKYqWiij5HqjJ3nAysQBmdQ=; b=SctIAYIyuCGYLCVQzwnJSk5ozR2sAVI3+zV09XZU4jd3PO3BTmsokPV5yxQBymqDyI CRN0+lt9cVPUfDSKJffRW2V8tRhgk4zxPjaGg/5XcLRrEQsWr7iBiRIkmX0cR5M2BCRk 2TjU8wkuyhK4j+Y8dC2yu384+BTn9oA4ul4dmOgQ0ugQDfoIRSWaZVTFxODzwvswbeyZ BA3iI6TNsBujc9JOQrCvKbtYsmQ54IzEtudMECaNTzOz6WbBszscmkiTVYrT5IJf6BqN rP5b3uWnrX4+xoiA+pQqsFAzyGdSR2CGwE/N6uFMSfHhO/shsGuCoT6j555N+pjbsziu 4afg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Isc2BeNg; 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-32608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32608-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. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l6-20020a656806000000b005bdf5961646si7636955pgt.268.2024.01.22.01.38.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 01:38:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Isc2BeNg; 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-32608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32608-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 92F59B24E8D for ; Mon, 22 Jan 2024 09:15:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C4C73A1D7; Mon, 22 Jan 2024 09:14:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Isc2BeNg" Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 429B83A1A8 for ; Mon, 22 Jan 2024 09:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705914888; cv=none; b=lGA3OlQtAUtwlo8aRZg2DpGbkInmaHNqXJ1HVAhk0Sk2QoBFn88X2H7vOSChhj/qvNtBJf9fwa4oMsiftAc2M4jpoWEAobb97ZFLOadRDVeOzaRZSWwBbPzszDJyAojZ5ILZowSqUNf7meKw0E/+J7nodMn0vLmH2aq5qu3muxQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705914888; c=relaxed/simple; bh=Qy4fsezFSYvwxIkwm1wQOGaj6uzXBPjygbKRVWIIEbs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BKTnL7FqBDvdGKhMMImbJMI1wxPcc+kvamCZM0F4PcLBuxnLD7Z/jcou/PX88RZL3vnVUkzRASvKrF5ROgMYgjImxTNfN5HX2KjoBndUWFR+vNHjkY70voZ805I+Z1laKfFE9nhERphZM/eCf6q68iG1MZisyQi6sI218bSw2tI= 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=Isc2BeNg; arc=none smtp.client-ip=95.215.58.186 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 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 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 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 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.