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.129.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 E7A2934F479 for ; Tue, 21 Apr 2026 22:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776808888; cv=none; b=BiJJHSezdRbMH0lcF9bqeNL0urCB6QsxRbO9dS3bj+m9pm82oazU/kiH8QI8cuNQ7GJMtG5g/TfiKo/MEz3F1AtnNHGJkOGF1exw7VjvTOwa6SBLerpHY0dPAy1lz5gXNBUEy4reHBxNMaGW3Bs7pkC2ns3KJ7xttqqhfR7rYTQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776808888; c=relaxed/simple; bh=wKXQYY6FfDI9a/16Lq7irXZnvvpx8cOvs36gzMXBZhQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TV4Y3kV2QmVAICNDN5Qkexsb6IvN8cct9CneYeh+thcRpQ34K7zjFiKisdH7hLoY6gwqdElYcC5U3q+BWf1RHlin35VcJydZ7IiH8eDDkIFEADl7KGi7YE+b4sgwcmFeRb/7i8unKmzWRo0KGjuijmb6MZR9ZT8hrLguq8t/gH8= 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=YGSQSO22; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=o9UuzKDZ; arc=none smtp.client-ip=170.10.129.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="YGSQSO22"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="o9UuzKDZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776808886; 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=/Et+lyeWTt5FeJ2gsFu/8TUEAo6EEauFnoYjswzfOPc=; b=YGSQSO22MLh+CKJRfi6q6Tnez94aPOA0kXscVNJmIsBveiShjK2qne4mbrcguqtmsC0zfx TuLXNUYbSsJZQxr6fGPOZ2R1IufuLyH0CG3fb1lgyWxSRnnneat7hLr1lpCr0AR4YEwODA rW57q9YP1nWgdv7MMvL3c9x50sRjBCM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-231-UIHvN-n8O4KdldBpeeYKzA-1; Tue, 21 Apr 2026 18:01:24 -0400 X-MC-Unique: UIHvN-n8O4KdldBpeeYKzA-1 X-Mimecast-MFC-AGG-ID: UIHvN-n8O4KdldBpeeYKzA_1776808883 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-488d56f87e8so41965065e9.0 for ; Tue, 21 Apr 2026 15:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776808883; x=1777413683; 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=/Et+lyeWTt5FeJ2gsFu/8TUEAo6EEauFnoYjswzfOPc=; b=o9UuzKDZ0lnyjfKbeVgIaPXSLFtjF2FAGNZbH4dEykiI5H7NfKEm8d4IbHuhxX15hA e94HUKBVhS+5rDNXI9PEsHO78f1y16vlxbLn72AcZOjOo9He3XerVz3YllFA0dd3d5UG 0DrKrkcXXHO0DsZDFrc1ANDJuXTTaTUMimyB7m1B7PosXLkbmbS+Px/WLC5EorRnEg2K S9Lce/UqLmjXU2My/i7sSJxqyQPTbSK0XigRBHuD8eYiXjmXc1uz1HbUoF/sp8XbcJhs OEFy3KeBODfxJSE/HeSNiRMioCNvmZg2vb/JkQZNkpSfdIOv6uoUtrVcnVVrlULqBmjI aZTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776808883; x=1777413683; 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=/Et+lyeWTt5FeJ2gsFu/8TUEAo6EEauFnoYjswzfOPc=; b=T6WHs0UnfnGbCrhKyLlnB3Xwfg/zMROiL+uDSC12vFVKY5izUfUA/J/6bvN7fLe4et BtnRCaa3znxoHZUTIb/cFTTAhM/wZY9fvEmiyS1lK2Mjtlt46DPUAUfuF1l8DdgJgKCD wv+/DTBgQqPVCgvT2j4u+vxixJB4uS6Dk7vUwdidl7ygR7zQynBxe5lKV+K7wGl5fnX1 +fKEcD6jSlZOJtLbuQK1MLKDQFa9+ftQ21UJoBS1UnPcQ0SFpmYdt9E756roo5WtmJzi ZCK1iKWNPAzr9mMc7mW9UpDqtRb23AoE8ok8FUGXKlUSmRwYJ3IgJAzWu529wVbzrDbQ vMTw== X-Gm-Message-State: AOJu0Yw39IocgPYesHQBrb5QgTMls9tzlygNcCcnHhOds+i83T6qji+8 +O2OmDpD2hNXdXvp0jhqkNoUuQkjxAglqF69wePftlSu5wFgQJxpJpuEY3707CnDnu2CZhoIy/V C6LLAxR26OZIX6i5VUabAZUW2/HMI8RE79MULDxBy82160Tfut/PbtQAhSy0a6DglPKdB7jr53R fhZOaZdh2rz9EzVksPbvQF7o5qEeLc39tDJZ5j18Iw//4= X-Gm-Gg: AeBDievXop/CjdQEvQ5rzDE82M9v9HSlx8HGZAHjcnmA0WG7Sqjr2rsWZd2pqI9T7lv MnV0a6NsfLP+w9w7Kn+1CM/H3zqjDapUhyLYIH9Xe2K03SUfeOiHFZWipheCz9PP9Z/znp8ROh9 1tb762GoH9OGKWwj27ToWEDOjVwPpwWSmRmCupyRztJGbhF9oj87MCDlYoZHJdKitkkiBlDrFbi CSj/wleXHk36X9RXtq4+nAG4cmNnduzbl6o48EVlKPSTjyDVikTAHMlCGPqOSHsH02o//IEGcxM +Z+jR3LxCyOlSC0JPG3xQefoEmJKas8FgQizFhDyLDDC9iAM+95TbB3q965wE0MtAyagixpxZ4Z jWNk4Gbtbf+olcuJcGQoUoaMcROFSmIIPYBgNlRpVME/jjWvu8qJemA== X-Received: by 2002:a05:600c:468c:b0:48a:56d5:16f2 with SMTP id 5b1f17b1804b1-48a56d5179amr56679045e9.7.1776808883048; Tue, 21 Apr 2026 15:01:23 -0700 (PDT) X-Received: by 2002:a05:600c:468c:b0:48a:56d5:16f2 with SMTP id 5b1f17b1804b1-48a56d5179amr56678425e9.7.1776808882298; Tue, 21 Apr 2026 15:01:22 -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-48a5549f582sm28902765e9.33.2026.04.21.15.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 15:01:21 -0700 (PDT) Date: Tue, 21 Apr 2026 18:01:19 -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 , Gregory Price , linux-mm@kvack.org, virtualization@lists.linux.dev, Johannes Weiner , Zi Yan Subject: [PATCH RFC v3 03/19] mm: page_alloc: move prep_compound_page before post_alloc_hook Message-ID: <6e574eb533603db74fd03244399df760a174bdea.1776808210.git.mst@redhat.com> 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 Move prep_compound_page() before post_alloc_hook() in prep_new_page(). The next patch adds a folio_zero_user() call to post_alloc_hook(), which uses folio_nr_pages() to determine how many pages to zero. Without compound metadata set up first, folio_nr_pages() returns 1 for higher-order allocations, so only the first page would be zeroed. All other operations in post_alloc_hook() (arch_alloc_page, KASAN, debug, page owner, etc.) use raw page pointers with explicit order counts and are unaffected by this reordering. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 Assisted-by: cursor-agent:GPT-5.4-xhigh --- mm/page_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1cf5551849fe..99c01eb2d59e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1895,11 +1895,11 @@ static void prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags unsigned int alloc_flags, unsigned long user_addr) { - post_alloc_hook(page, order, gfp_flags, user_addr); - if (order && (gfp_flags & __GFP_COMP)) prep_compound_page(page, order); + post_alloc_hook(page, order, gfp_flags, user_addr); + /* * page is set pfmemalloc when ALLOC_NO_WATERMARKS was necessary to * allocate the page. The expectation is that the caller is taking -- MST