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 B19983AFD19 for ; Mon, 8 Jun 2026 08:38:17 +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=1780907899; cv=none; b=c1QsdiVasPgIn5OYiOwCSc0HySH2uOPqym8Jn1ueuU4qrUsWDxg7j4y63HDvUU7QHJTDNW5e2RpjHjp80Hb3v14XhPWNn55biIjC0RDMG9pF55ZxVN6RtW0AguXGvhFsVTjzRvv/qykxSsMOrlJLd6QZAPAN+DISU5MWIkPzUDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780907899; c=relaxed/simple; bh=8+ZahGpeDELrqcGB1YJH6oTjGbft7NUn5eY1+HiJ8Dk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tuyidnTaZlmLtsdWcZksLk/XW3xln4w3lgd5RKcUaQAnNwZh6ZpTjKhlh9A2KuK5xmm8I76/E8FgUVDD3IHSBC9yt5CRik8qI8MuPBHyFXtaQG4m2wPaBMKh2s8e/gsMJt2foMs7cfq/JQ3ovk4D8xY9GTh22RD+vZLqKcIngGA= 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=UTdlxRAw; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=UptaY7Vk; 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="UTdlxRAw"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="UptaY7Vk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780907896; 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=k8mD++2dfZtiFiQOTpn1O7CzJ+9UexLHDFBwODnyZcw=; b=UTdlxRAw9WKvG72HuGbt/XkR0RdTAVPCKET8v4J3nrZJyUcgYUfEETk4QZXDsMdfAJizIz AQDmC4V9haRQAtvwffjmhUaT7BRhfX3OBWv0J3UeFRIh8jOHMaSYGGPhWq0Wda1gQaaa0P yxHw9Ez3QN89A4+dUsPQkB+tIlBGWpQ= 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-629-QYCgmaanOYCCmay2lYYkSA-1; Mon, 08 Jun 2026 04:38:10 -0400 X-MC-Unique: QYCgmaanOYCCmay2lYYkSA-1 X-Mimecast-MFC-AGG-ID: QYCgmaanOYCCmay2lYYkSA_1780907889 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-45efa12a788so2884472f8f.2 for ; Mon, 08 Jun 2026 01:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780907889; x=1781512689; 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=k8mD++2dfZtiFiQOTpn1O7CzJ+9UexLHDFBwODnyZcw=; b=UptaY7Vk6zyOKDvgMp0+2/H01Xuk+YgAgWbkUzVeg2AozMkOrB6k4jKpiFmTe1oC3S WKh0rAQ8dU8YuO0K51J2chp13CmuMsC5jEArzioE2e8qdkptcr3s5ukp6IEI8xvYVls6 hg9LIk7Vdo0LwwwVmAcvI73eZT4xetRYaIiB9fBYq5tQZwkSG/poETVlQAm+YFc9lQJb 6XdBGiDaShnbggoQp3Hs6GOhlZAqZ6xHI8qFBrMjbBXSElqEWFMaGbFhpWXdBjC0fglB Hv2oM8Owl+TcruYsSsz/8tQHA79DhT6GV8lxtWVx2pyhW/+J5u41y394feeIPSqrAQSf rtdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780907889; x=1781512689; 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=k8mD++2dfZtiFiQOTpn1O7CzJ+9UexLHDFBwODnyZcw=; b=bU5RkkGJKBIsbyRQFAz65TFbDsgyFXdNaQP0Au7bBkluijx92L5uT4WwR32FmTSFSZ m7ekUrCicHa7Yn9tTmOkJtTxC+sphKsGac+jtXhW0DR6pyAmZ0L0lsk/eQDWiBWsPhVo r5UPmT+ZnQm/EVrQmaQd7NkiXmKkwsFgeLymCeQmoOgpTb/CbHne3qo0YO2tVO1EE2X7 cxkaAaDAKXWFQ19USsY7zxoucslFyKAs0uAbiBbyNUIwo9d5X1VnB+sBry37lrjM1nzO HyD/haF90mb+Gq/dwDU9htZjt1ulEBLVX1CKTHt/ztbxMRGkatSpzfB3uFh9SOGqzIjP QhZQ== X-Gm-Message-State: AOJu0Yy4iW+8WVO2NxS48/rShIosMwKbFtd2X1Dgvv+xHur/mhCT/ReL pis7LuPCWlbzjAfeFETU+sM8zyRy7YutOB3LYWosyhf4ESXTVAgkkIOcsZsKkIY4EQvUcSycVIy MMqV5ItmmZDQrTifeDa4m15EO/bMuAHmpWz6FJIfT+P9XQ8tCfjbNFutJrWoRsWuEBn/z9bPT/I dsi/wxx+OOOOAdUQYVpVsDcg6ZQFBJ2SpsBlJRhPO1c2U= X-Gm-Gg: Acq92OHDqsS3elHsve1MaZkZKwm9GTaebOVLaFITC3tqS26ZQgjxpoLCZ521YiYLV8v lATKtQrqR4zx8a/czZBWTqatlbqZYu1Bj//9t9IGer/XgByKQoxvVvyrrQ8QS1T+IBf0Ce3ROJ+ xUBYK4NW5s6VbGSfT9+GIPlZ26wNN3zCmtNGjrBvoZHvm5p6AWvCUjjS77xSROq9cUaDWPDOqik gNXJCe/EetU07T76vWIjkV8bOOClku6Vnr9MpvyP28rtSq8IzLis1qunLHM91lXfIYgmnp9XAcW +GtnHmMpbk/Ow13mQWroU34dr0arnmAALLhjSAECtusgu0+8ZE1VWdnGsOF5a9+KX+YfZhBOXoS Ye6iKs9GFygSWvLfb2UgQKOg= X-Received: by 2002:a05:600c:c491:b0:490:bb44:3f8b with SMTP id 5b1f17b1804b1-490c2605385mr243137435e9.17.1780907889256; Mon, 08 Jun 2026 01:38:09 -0700 (PDT) X-Received: by 2002:a05:600c:c491:b0:490:bb44:3f8b with SMTP id 5b1f17b1804b1-490c2605385mr243136515e9.17.1780907888480; Mon, 08 Jun 2026 01:38:08 -0700 (PDT) Received: from redhat.com ([31.152.37.159]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc4082c3sm362037795e9.13.2026.06.08.01.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 01:38:07 -0700 (PDT) Date: Mon, 8 Jun 2026 04:38:00 -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 v10 18/37] mm: page_alloc: use aliasing checks instead of user_alloc_needs_zeroing 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.51.2.2891.g4157995a80.dirty 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 45e824b1ec75..edfc83571985 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1880,7 +1880,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