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 053943CA4A9 for ; Tue, 12 May 2026 21:06:33 +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=1778619995; cv=none; b=V1pw8YSq0Vy+hEgQ0zLlmNMD+sonebxXsY6jZlzl+XYKDGZULVx4/OXgYbSHWHjiAib5scavZtdkLsH2cXqKuOaL+HQbB/xpqaxKR2UO8i0YGqfUOb8tIiXTz1HR16SvSdHr6+v8Hx9QUw8b+0Js3mX+UwqvMzyWpdSOqBQHZ2Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778619995; c=relaxed/simple; bh=Y4i87gvPLne8uDYdZdRz0YtVJ2giC7sgZxD0jT2a23c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nvDpPLhpur/Hw7DHFLwM7LE7j7Byc50/c/0Rs44ZEKMMXmRpmYMpi3mlmHd50d7vYrsYdfYkXx2s2KSZ1viUQRADcNWADh7tCVbb2uey7Mgph4+oBv8QMsYsAfTEqtqzBILB8/JhXMH8wqa7uIGkawetmiZJdx49PeTc55rgA3o= 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=DLr/6nnG; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=UcfPrVSz; 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="DLr/6nnG"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="UcfPrVSz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778619993; 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=kWQzvk6rjiRPyM3eAZla3ajwvkAoYuOsF+wH5y3nY6E=; b=DLr/6nnGLw6lc5GKpJsJ73VvZo6HAjQDeK4gz00vXMoa/r4Zj2FvJbP2pF+6lK/RRdq3il LEs6v4CtYN7ysKbD+6YZXH2u+8crt41zmpUPEKAfG+f+i5bZYD+26Oda8IxrbVhXkHTPs5 RDoH5+aIcCQEM22ApiD+8+0Xouc1ea0= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-669-URPAurvuOWyfVkhHPVzw5A-1; Tue, 12 May 2026 17:06:29 -0400 X-MC-Unique: URPAurvuOWyfVkhHPVzw5A-1 X-Mimecast-MFC-AGG-ID: URPAurvuOWyfVkhHPVzw5A_1778619988 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4411a36715dso4308104f8f.2 for ; Tue, 12 May 2026 14:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778619988; x=1779224788; 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=kWQzvk6rjiRPyM3eAZla3ajwvkAoYuOsF+wH5y3nY6E=; b=UcfPrVSzoswrZCdAktrRBfiPwj6QGRMyrxiTfs14j3x5Fh8u1J/Zs3A3kjB+XdDyKd Cy1lnWpxbfaI9JskMFMBe2p9dOArc6Gg+998CfOsodPYKy7j3KXKTyfC9zaUSYG2lPBc bu+WkfYiAhOjyTPgUDiUKISuW878DuGF1msfkKKiPB7jqVHe1LVzMZPfWQpps7Shkcyt y2hR0XvRpjssrDwHMmHCLQgYUfcWr3Mdb3JNVGMSAneMxG2HzNqcQFf1PaTDBaJUl1Z2 +iOonup1mZohCesJoqEQuOU67zaf1mkERrH1XVZ8PvSOEhfYQerZ9LJbVjFM15n07FS+ 6EYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778619988; x=1779224788; 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=kWQzvk6rjiRPyM3eAZla3ajwvkAoYuOsF+wH5y3nY6E=; b=sriiwgrwxybd1T3ZExiQeGbTWbLyT8BAqJiNFqhF75puVAIAP41Y1+/2pYVMgSkFNL n7JmA07s9G7GXtzJkYMq9nIOvQj7yQtg70mn0VWgdIRc121zJTPclEirucOLPzaCAAJn hm4mYtzSS6oa9syzT5u+y5jpDBKXbCSvaYbf4AqXy+JJqa/Isw/57eUxaxcpSwXYV75k P9TgJc0sFTOBkgHdgwCB+3a0OnqD66lkCSE4OzDRblgYhQdZ1trOGojvDGnxp/9Em0hM SCobppSr239ecXnZr5ueRYqmV9SN4+KEcpgE3Coe2cv8gK7dkg39LKd8UQJqcOyxZQ+/ aGNQ== X-Gm-Message-State: AOJu0YyjqSv7lcMMOg3TLtcNiRSBHOfWf0vGH++nNaDK969NYOSvnXa7 qGgrqnZWZ4P7+CMB1dIByYR3+2aXXeJC/O3SlrZaTIuX2JMHEgR9bi1zVRqwT5FR+UiZfxChRPP VsZO+5B4gCDtkZp5VKEoC08gN5Gkk5xttYG8hd8LRBsGiZnFHpbtm88hrnZqwUnfV/UGjikfyHA hfkks9oJxDXJcFgb2EYXH3AynLnXB3tstUcTzJ5cVM4mA= X-Gm-Gg: Acq92OFB6CJm+xE36Hom/FFzER/pesRA5Tigsx6cfYp//Z/1M2/F1xaCeCzV4sV2iy0 /gwN3nhhbdEFc3gifOKRgZiyFyuxXpAULha8Rm+TSQksnC4ftZMwrOZIW1lnvU1LCa2AH9RXFBK stQGcNt8JySudn7Ysn515VbXPcXSKPbaUV0CNXEPaeuvRutVlgs63mFueGNIJZPl3do1uUesfPd qhKmEvrx7EvhXRuhhWuKhnx54gmFEndOH0d+iBR4bZZ6NvzvcBpaWqaVl0Z8ULtUkLdfuCTMk0j VB6FGRqi37RN3TTp6swgQvBwiijn8gYkMHc0PNNTO/S3pt6v/xmI1EqYH/KoscMYe7MGEsBllZl ZnlcZ22OJNxaeyd5hkzO4lePt+g+em4xBbJ0znzh3 X-Received: by 2002:a05:600c:4fc9:b0:48a:7a10:4f47 with SMTP id 5b1f17b1804b1-48fc9a023a6mr5599415e9.3.1778619987664; Tue, 12 May 2026 14:06:27 -0700 (PDT) X-Received: by 2002:a05:600c:4fc9:b0:48a:7a10:4f47 with SMTP id 5b1f17b1804b1-48fc9a023a6mr5598765e9.3.1778619987004; Tue, 12 May 2026 14:06:27 -0700 (PDT) Received: from redhat.com (IGLD-80-230-48-7.inter.net.il. [80.230.48.7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e8f3f5174sm40737105e9.5.2026.05.12.14.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 14:06:26 -0700 (PDT) Date: Tue, 12 May 2026 17:06:22 -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 v7 14/31] mm: use __GFP_ZERO in alloc_anon_folio 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 Convert alloc_anon_folio() to pass __GFP_ZERO instead of zeroing at the callsite. post_alloc_hook uses the fault address passed through vma_alloc_folio for cache-friendly zeroing. Signed-off-by: Michael S. Tsirkin Reviewed-by: Gregory Price Assisted-by: Claude:claude-opus-4-6 --- mm/memory.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 74523bc00d8a..f3f1bc66366d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5249,7 +5249,7 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf) goto fallback; /* Try allocating the highest of the remaining orders. */ - gfp = vma_thp_gfp_mask(vma); + gfp = vma_thp_gfp_mask(vma) | __GFP_ZERO; while (orders) { folio = vma_alloc_folio(gfp, order, vma, vmf->address); if (folio) { @@ -5259,15 +5259,6 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf) goto next; } folio_throttle_swaprate(folio, gfp); - /* - * When a folio is not zeroed during allocation - * (__GFP_ZERO not used) or user folios require special - * handling, folio_zero_user() is used to make sure - * that the page corresponding to the faulting address - * will be hot in the cache after zeroing. - */ - if (user_alloc_needs_zeroing()) - folio_zero_user(folio, vmf->address); return folio; } next: -- MST