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 9F588423A7C for ; Fri, 29 May 2026 15:24:28 +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=1780068272; cv=none; b=MJgB5YL3RHTO8U0P5YNtvrZmB553UBJIXhO8ShLJ8a62wPbxxTBuElF/1w8Krpy4xgysTcF4vq+6Nc+TfqC03kFnffN4o25sG8h2H/RUDCTVRaaYQBPbVVtShZG4oAaPYEQAGKq6cW3YuP8mTkSZ7ZNK+fuvu1sPANKRJzei06g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780068272; c=relaxed/simple; bh=9yxmheTwtEMdpXjxhcMq1i9/4nCbH4yqJLWMjAN8B0Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sbWNtgqoPluYjqhBBZfxTHLpcWqeSXYP/cJvQpH0Y7q4bD1c8XRl0pJf3pnU0IXIoEXyyOzgt3z5llKdBY6L6e20ORNIMlxYOh3zOVGSxkQqtThtFtYcbJ7U6lw8HE9WEO4e4T74BqST0dWK9e5vYRUMvOQFH5HLbDR8+OFgy74= 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=c+JpZ81L; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=H5gUySYk; 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="c+JpZ81L"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="H5gUySYk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780068267; 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=8dg7l+XMBUZMVnB4+qTLsym8fNCo7JvPxwQL0Jq5Z3w=; b=c+JpZ81LIvP0qgDnz/QYWb8+vAS4c7FijKF1xgtvSsch9zleXlo08cFxMbwtTV/wlXGgK1 +/avlr6aGHJ4f+UEtis1MFMuSBgdhXmO8cWYtd9AsyMzJCapgdLWG7TAjeFuzSSPZhRTyq P7NTryoUmajd5+XaBFRCdjHxOKysOfY= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-e09ult4jMS2c6sWEe7us1A-1; Fri, 29 May 2026 11:24:25 -0400 X-MC-Unique: e09ult4jMS2c6sWEe7us1A-1 X-Mimecast-MFC-AGG-ID: e09ult4jMS2c6sWEe7us1A_1780068264 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-44696b11265so16693332f8f.0 for ; Fri, 29 May 2026 08:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780068264; x=1780673064; 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=8dg7l+XMBUZMVnB4+qTLsym8fNCo7JvPxwQL0Jq5Z3w=; b=H5gUySYk+xa3k4Wm4aO51vHq8+pFx3zvh1JKWJnWM/hXDZcidGZrQv0oHcuV55r6x0 QV+jTRBBrJGr7euKaSvFT1ZohAptgk9Lj7hPKhvvfxKUntHpQazH5ktCcn8U7hVOBgwE vmw0uw4vNk4z603ekBYL0x+8JiLRI9qHJjFcZKbNd8gOKH6UCSatZUZZZggFx9gZVKKy vCXz7+lQolgpSkG20QOpPyYxFONoLSRv4e3u5okMALBkG5hjeOZ4NqFRtcZlJdWkA3kq DQk3RsVmIEu58whJwJxV6OaMO84Z1dDTdLhSH2QZq0QVUekO8J6gObdHDE8g1Gmsz9Et 3XWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780068264; x=1780673064; 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=8dg7l+XMBUZMVnB4+qTLsym8fNCo7JvPxwQL0Jq5Z3w=; b=krU4jA6zwOW+jTBEUFGx8QhEK9a9FpaKK5zBfpivqdWAAwVgWTxH8tRJTngjbCiNNf td5mp9VisGoYd2KKT5sonFPE9BtaVQvMwAPeBbj2RG+c5fWRylbhMPUccP8KH+/sUsdc FQmVblHaRYD1WvNWT5Hdj9Vu1vLrzSO7gb/P6eHiGEQ7l52wx9xcFgFYPa7CzuJ+LmnX ejCkx9xxw8TWuTBfnRSd2ypydv66xCNei7PrrXTUiaCChjBM/pWxt+A10qVlqUIqUm92 ncFbpO/iLdEsZei7GaWbbMplYHA4hZ9B/N6jV6lu2ieomxavuIVjNzQxxMWO4RauRxhz a6uw== X-Gm-Message-State: AOJu0YxyGDBbwSFNHWe5ZqgfJ7uTG1nl3ldtY8JeITAwp/1GGyOjDdnY AGe/6pnIists0n/kPOEaFFZsEdlaeJ9DojYea+N0RCaYEi8U99TF4xhgq+DTe/kY3p8lHh186Rz GRPpMMEC8fVpbjyo+U22/1X6M7bOWMEzbmbeYTJWkb4N3/jupT0w+jOwT4fVKhZJi+j7SMhsSQu CJ6X6TXD5WxJ35IJafA72lr7t56XpQBdLZsTZK/dHkffw= X-Gm-Gg: Acq92OGLjdXuQc39M4PF6Rt5d5wlFSD89JeCVK+FaZ6f+mZRmFJ+PIIZJb19pQ+pr4x 8XI1TkFYLjW0iDVFooTSKyHgO4nB417DIHgGROAkFxE6ff0+Ub1izTKwCDIDSBDy9T6OSdUeNSP /9kNJHk8t58pEZPxgMB8cf3VHgqw4LHM7M4D1BL2lKHyltcHzWPWV61CydGmusF67uAlxJ3A03x UXGicCML2qnU9EY/FsD+6wpETty2cZzQbYJ+aBqRlRdukcfb8Xzz111zjFuEx8qWuTbEMvjJwF1 XuPHFQrHVrr5b8hmggiHEuIzP/ba82mgkLJt/BPA/82R7dkoj3quVTJX02Om4eCTXb19spCpCdE Jr2mTLkk0L5iHZ+Le2ADGqa0csjwxqRpKODKkhrksK6UpV91AvS80gA== X-Received: by 2002:adf:ea85:0:b0:45e:eec6:5023 with SMTP id ffacd0b85a97d-45ef6b8831dmr324588f8f.37.1780068263732; Fri, 29 May 2026 08:24:23 -0700 (PDT) X-Received: by 2002:adf:ea85:0:b0:45e:eec6:5023 with SMTP id ffacd0b85a97d-45ef6b8831dmr324493f8f.37.1780068262980; Fri, 29 May 2026 08:24:22 -0700 (PDT) Received: from redhat.com (IGLD-80-230-25-45.inter.net.il. [80.230.25.45]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef34b834esm4139592f8f.11.2026.05.29.08.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 08:24:22 -0700 (PDT) Date: Fri, 29 May 2026 11:24:18 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , Muchun Song , Oscar Salvador , Andrew Morton , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Hugh Dickins , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , Axel Rasmussen , Yuanchu Xie , Wei Xu , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , virtualization@lists.linux.dev, linux-mm@kvack.org, Andrea Arcangeli Subject: [PATCH v9 23/37] mm: page_alloc: use aliasing checks instead of user_alloc_needs_zeroing Message-ID: <8229023108f900d50b47bd85b5a8f8eb5f95ef03.1780067977.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 Replace user_alloc_needs_zeroing() with the direct aliasing checks (cpu_dcache_is_aliasing() || cpu_icache_is_aliasing()) in the post_alloc_hook aliasing guard. user_alloc_needs_zeroing() includes a !init_on_alloc term that means "allocator didn't zero this page." But in this guard's context (!zeroed && !init && __GFP_ZERO), we already know the page is zero; init incorporates init_on_alloc via want_init_on_alloc(). The only question left is whether the cache architecture needs the data re-zeroed through a congruent mapping, which is purely cpu_dcache_is_aliasing() || cpu_icache_is_aliasing(). On non-aliasing architectures with init_on_free=true and init_on_alloc=false, this avoids a redundant re-zero of an already-zero page. Note on PowerPC: PowerPC overrides clear_user_page to call flush_dcache_page after clear_page, but on freshly allocated pages PG_dcache_clean is already clear (cleared by __free_pages_prepare), so flush_dcache_page is a no-op. Skipping this here thus has no effect. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5158f7e23d18..4cb7e779a6c5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1883,7 +1883,7 @@ inline void post_alloc_hook(struct page *page, unsigned int order, */ if (!zeroed && !init && (gfp_flags & __GFP_ZERO) && user_addr != USER_ADDR_NONE && - user_alloc_needs_zeroing()) + (cpu_dcache_is_aliasing() || cpu_icache_is_aliasing())) init = true; /* * If memory is still not initialized, initialize it now. -- MST