From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 C67173A168C for ; Mon, 20 Apr 2026 12:50:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776689450; cv=none; b=YA4kNm7ywoLN/Udbl1kOW25PY7yA3WnI8YUlm3K2bhQ3dv1HWTNbnmCAASprLe22EvUng5IKqV/Pv28Zly8sT5EkUkpfGiUhdVoMxg8tZoxmS8pAC9Z7G4xGd6G9ap7/BgTBzbahugUCkbq63MHvuI1AKZPz5GuaFqIRxcg561s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776689450; c=relaxed/simple; bh=sSfa5mO+Tuc8WlFhLhsagE6tOSwlDbqV/IGvIAB9fvk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=c4EdsX3chgtFwSyX6O/2DXFEwV9Y5YeUdUDa6KlFi5cumgTJwyA8Yb3D57pFnUfjG8BOettvLLtt2D0BE6wNoEqiqMLZZ4vdqht0TpsWRBddxptIK3OYWiY0Fqz2zi9OgtBub42Dxbmh0tteDCGecreut/Lj8bW3dqQLgicyZI8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fJEx5iuV; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=d/0KggIB; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fJEx5iuV"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="d/0KggIB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776689448; 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: in-reply-to:in-reply-to:references:references; bh=H1uMYUyGM2Qrt5nxh6GVo3Jl5MBn378JvNFc5Ca6urQ=; b=fJEx5iuVIJa6EUWILuRMuJZwyNRy+d0JODJASy1zr4GvnDKpjBxvFbafepUlLVwKMqnx6t bFFfvETnD/sNsVMe+/MwLC8epeUy3AgqkLg/83SXdxt+HR/2gyFt/nZFSqBCO1Gk6aBsZx g/BfD4JJs5jGEEVQ+dpPuIQXGsY0E5U= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-482-C3s5wUptNTCgc1Cv_yL41g-1; Mon, 20 Apr 2026 08:50:45 -0400 X-MC-Unique: C3s5wUptNTCgc1Cv_yL41g-1 X-Mimecast-MFC-AGG-ID: C3s5wUptNTCgc1Cv_yL41g_1776689445 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-488d3eec9bcso18917175e9.3 for ; Mon, 20 Apr 2026 05:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776689444; x=1777294244; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=H1uMYUyGM2Qrt5nxh6GVo3Jl5MBn378JvNFc5Ca6urQ=; b=d/0KggIBKth3WkWySWlcwIuzd2XmJbu2lHA6G7VZeIy9SRZSkWqxa8fFT6mpUyETHt KYdJSJoZD+CNanG92NNFFvb+qY4tzEdgmEe3CN0LKVuRl+OW5koa8V/yvr+jU2V0YzsT eIVVqJB0bCaLWMG3iqtAnY2ySP/jaDl4IfAYEDXNLzjxFDS66WTyBP6jof2a2FAK0Udj Fh04RN6z6acqX0/ox0l02/l5XOLTKQveYe0FSSt44ku7/brhLJ+4H3v4OTx4yS9dLrkX lOf0xXyRmL7Z2X+KUj3yYmY7MCbH9OPPK1tA4eIdo6iHvjthvdeVQ7FXQwlItUJSMe4g mr1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776689444; x=1777294244; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H1uMYUyGM2Qrt5nxh6GVo3Jl5MBn378JvNFc5Ca6urQ=; b=JtEDfbnbAxCtLNtJi/wqe+PzfHqt3YHjPuIF/539MFfbqaYqFz9VPDvJO6rcbWGrAv DtBiQ+eIv3mEYJRDSjlFByGZ8PgLPq2PyFGGZZenxSePUjZjzxGtGfj9G/axZO6hjjiH QJZEaXyJ+PzS3MWV2SLt6kPruCy/HnZmbtmYI1A7bkdGujmIorh84MrGtiIjHw1DCYg5 Ja563KNif2gU32GlWqFd7/1LCR/g/swuvFF2AW3RlFuTmXkL/B6BdZIbJX/Egu//BkBR Aqwxa4wXZun55/kN2NLZpRIxdhRxRtJZUrAJ/3cY/X4TQ5V8jAu71dCnU8blOWnBHSwF 9qjw== X-Gm-Message-State: AOJu0YyMKgad5Z2ptKaQkvOI/yH7ZScYRh19vLausIYkBbtLSD8WVoyf DEi73hk8J41CX7H4718NjcDgg4cw/YoyOWWE+1fR2GznPFeY7pj4r8nSGSfi1BB0eJrRgMTzgC/ DWFfRulQFgeiEYsII8k4ta8Kie0b0tF7ooxLtngZu0HIiB8MUUc0nnLoZxpoS3iMNhG+h0FMUmo n0mNtkmA4jPpzZKBFJjeefUmBQ+gROzmjaD3eig7HUDcM= X-Gm-Gg: AeBDies4T3XInLkrHvxrXGz4zIoS2yOWxY3gcSvJ7VV4BG1HFhx5Y2HLokJThrPaSiu WBqa1a6Jek8cvGUjlWAF6z59lA8vndMNwJA7Ib1A2d9PPmJeIpktDhAo+E0GiRYM4t0s9rA39aC r7YjlCTqGHsGBa9Rb/m9AiY4YHuXWNEQHR5wYmz0jVztDN9wJpgOrIpiAq+EFn/GVJeEkPTwqEP NWPlBfFts+RhAqZD5RXUf7hvJOct/Eoeg7Tyo3F31wtxtHoJXE7JT9/3AcAXmY2KEIWeN8w2T/+ Jy5W6K2LUENAwSZ0lFSozkpRUeDfw1icpvZQ/nYtWTDB//irpW9gAKiSRzm1AgQH4TSI20x3A1l BgJxxZLd/h8VdP7Xuxk+hKsMrk6M1GPcp55Ai7PTz+wEYatXyzAJo/w== X-Received: by 2002:a05:600c:1390:b0:483:709e:f238 with SMTP id 5b1f17b1804b1-488fb78ea6fmr191197995e9.29.1776689444305; Mon, 20 Apr 2026 05:50:44 -0700 (PDT) X-Received: by 2002:a05:600c:1390:b0:483:709e:f238 with SMTP id 5b1f17b1804b1-488fb78ea6fmr191197445e9.29.1776689443758; Mon, 20 Apr 2026 05:50:43 -0700 (PDT) Received: from redhat.com (IGLD-80-230-25-21.inter.net.il. [80.230.25.21]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc0f82bbsm466309085e9.3.2026.04.20.05.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 05:50:43 -0700 (PDT) Date: Mon, 20 Apr 2026 08:50:41 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Andrew Morton , David Hildenbrand , Vlastimil Babka , Brendan Jackman , Michal Hocko , Suren Baghdasaryan , Jason Wang , Andrea Arcangeli , linux-mm@kvack.org, virtualization@lists.linux.dev, Muchun Song , Oscar Salvador , Hugh Dickins , Baolin Wang Subject: [PATCH RFC v2 08/18] mm: hugetlb: thread pghint_t through buddy allocation chain Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Thread pghint_t *hints through the hugetlb buddy allocation path: alloc_buddy_frozen_folio -> only_alloc_fresh_hugetlb_folio alloc_buddy_frozen_folio now calls __alloc_frozen_pages_hints() so the reported-page zeroed hint can propagate up. Add pghint_t *hints to alloc_hugetlb_folio_reserve() for the memfd path. Callers that do not need hints pass NULL. No functional change yet: hints are threaded but not acted upon. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 Assisted-by: cursor-agent:GPT-5.4-xhigh --- include/linux/hugetlb.h | 6 ++++-- mm/hugetlb.c | 29 ++++++++++++++++++++--------- mm/memfd.c | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 65910437be1c..7311ad87add4 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -710,7 +710,8 @@ struct folio *alloc_hugetlb_folio_nodemask(struct hstate *h, int preferred_nid, nodemask_t *nmask, gfp_t gfp_mask, bool allow_alloc_fallback); struct folio *alloc_hugetlb_folio_reserve(struct hstate *h, int preferred_nid, - nodemask_t *nmask, gfp_t gfp_mask); + nodemask_t *nmask, gfp_t gfp_mask, + pghint_t *hints); int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping, pgoff_t idx); @@ -1124,7 +1125,8 @@ static inline struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma, static inline struct folio * alloc_hugetlb_folio_reserve(struct hstate *h, int preferred_nid, - nodemask_t *nmask, gfp_t gfp_mask) + nodemask_t *nmask, gfp_t gfp_mask, + pghint_t *hints) { return NULL; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 327eaa4074d3..faa94a114fd4 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1842,7 +1842,8 @@ struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio) } static struct folio *alloc_buddy_frozen_folio(int order, gfp_t gfp_mask, - int nid, nodemask_t *nmask, nodemask_t *node_alloc_noretry) + int nid, nodemask_t *nmask, nodemask_t *node_alloc_noretry, + pghint_t *hints) { struct folio *folio; bool alloc_try_hard = true; @@ -1859,7 +1860,8 @@ static struct folio *alloc_buddy_frozen_folio(int order, gfp_t gfp_mask, if (alloc_try_hard) gfp_mask |= __GFP_RETRY_MAYFAIL; - folio = (struct folio *)__alloc_frozen_pages(gfp_mask, order, nid, nmask); + folio = (struct folio *)__alloc_frozen_pages_hints(gfp_mask, order, + nid, nmask, hints); /* * If we did not specify __GFP_RETRY_MAYFAIL, but still got a @@ -1888,11 +1890,14 @@ static struct folio *alloc_buddy_frozen_folio(int order, gfp_t gfp_mask, static struct folio *only_alloc_fresh_hugetlb_folio(struct hstate *h, gfp_t gfp_mask, int nid, nodemask_t *nmask, - nodemask_t *node_alloc_noretry) + nodemask_t *node_alloc_noretry, pghint_t *hints) { struct folio *folio; int order = huge_page_order(h); + if (hints) + *hints = 0; + if (nid == NUMA_NO_NODE) nid = numa_mem_id(); @@ -1900,7 +1905,7 @@ static struct folio *only_alloc_fresh_hugetlb_folio(struct hstate *h, folio = alloc_gigantic_frozen_folio(order, gfp_mask, nid, nmask); else folio = alloc_buddy_frozen_folio(order, gfp_mask, nid, nmask, - node_alloc_noretry); + node_alloc_noretry, hints); if (folio) init_new_hugetlb_folio(folio); return folio; @@ -1918,7 +1923,8 @@ static struct folio *alloc_fresh_hugetlb_folio(struct hstate *h, { struct folio *folio; - folio = only_alloc_fresh_hugetlb_folio(h, gfp_mask, nid, nmask, NULL); + folio = only_alloc_fresh_hugetlb_folio(h, gfp_mask, nid, nmask, + NULL, NULL); if (folio) hugetlb_vmemmap_optimize_folio(h, folio); return folio; @@ -1958,7 +1964,8 @@ static struct folio *alloc_pool_huge_folio(struct hstate *h, struct folio *folio; folio = only_alloc_fresh_hugetlb_folio(h, gfp_mask, node, - nodes_allowed, node_alloc_noretry); + nodes_allowed, node_alloc_noretry, + NULL); if (folio) return folio; } @@ -2231,10 +2238,13 @@ struct folio *alloc_buddy_hugetlb_folio_with_mpol(struct hstate *h, } struct folio *alloc_hugetlb_folio_reserve(struct hstate *h, int preferred_nid, - nodemask_t *nmask, gfp_t gfp_mask) + nodemask_t *nmask, gfp_t gfp_mask, pghint_t *hints) { struct folio *folio; + if (hints) + *hints = (pghint_t)0; + spin_lock_irq(&hugetlb_lock); if (!h->resv_huge_pages) { spin_unlock_irq(&hugetlb_lock); @@ -3434,13 +3444,14 @@ static void __init hugetlb_hstate_alloc_pages_onenode(struct hstate *h, int nid) gfp_t gfp_mask = htlb_alloc_mask(h) | __GFP_THISNODE; folio = only_alloc_fresh_hugetlb_folio(h, gfp_mask, nid, - &node_states[N_MEMORY], NULL); + &node_states[N_MEMORY], NULL, NULL); if (!folio && !list_empty(&folio_list) && hugetlb_vmemmap_optimizable_size(h)) { prep_and_add_allocated_folios(h, &folio_list); INIT_LIST_HEAD(&folio_list); folio = only_alloc_fresh_hugetlb_folio(h, gfp_mask, nid, - &node_states[N_MEMORY], NULL); + &node_states[N_MEMORY], NULL, + NULL); } if (!folio) break; diff --git a/mm/memfd.c b/mm/memfd.c index 919c2a53eb96..f1c00600e19a 100644 --- a/mm/memfd.c +++ b/mm/memfd.c @@ -93,7 +93,7 @@ struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx) folio = alloc_hugetlb_folio_reserve(h, numa_node_id(), NULL, - gfp_mask); + gfp_mask, NULL); if (folio) { u32 hash; -- MST