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 A4FFE3CD8BB for ; Mon, 11 May 2026 08:54:32 +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=1778489674; cv=none; b=Y6Hglx8E9R9O+IHB2e0qg7ahpoyV4F8Ef5cZk5MNjHA4iUmUS+darUcHTVOKFv1Vrgtrm0F6yzVD/KO6YhYglkcU32ESVlSbX92G9coKiyTIVl8jhFWeyg71/SpjMJcfy/qEhQj1toaYAQCMk3dimOx2rWGMj/Nh6dK5Ed5LAEM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489674; c=relaxed/simple; bh=tkchtNB3GzzFWMQ1E0X1DKUjhQK/O579SYT7H3vP5sk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PqgZD9asUtLDiltx7E399E0CUMt8cahXiZKlgohcwTu2FU4Uy8rpUKJBbzWoiTFl2IG3b8o0L9Ydvvwx6pnDmX6cSSFWuWeCBPmINDdqOFmT316xOpQUnKTxcjkQasz4kHWWsA6xFxY9DOVtTxK11AQWtKwx0tdU85mRIH3rKk8= 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=DKm3U3g4; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=L6FAa9Pc; 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="DKm3U3g4"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="L6FAa9Pc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778489671; 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=43zcPeyEBahcbXzXBePbjbHiq0vh8NFM/GDJyyFYelY=; b=DKm3U3g4cOzdPmFnYpPO85gPh+4r2uQr+xE9prnGY1epa88LFjzkd4ruf+TWrRv0w9ARIi Q3h1YuUUf5i8PNf3CAld/FBnI8cKHn3n6JqhXTX8g8t6UN+UpjM9FFvEAjjslP3C9ckeQm PZRtGGif/jy9HRyiKtVD4ALIAiIfil0= 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-609-H1QUtaMvMSqU-Vy5CarV4Q-1; Mon, 11 May 2026 04:54:30 -0400 X-MC-Unique: H1QUtaMvMSqU-Vy5CarV4Q-1 X-Mimecast-MFC-AGG-ID: H1QUtaMvMSqU-Vy5CarV4Q_1778489670 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-48d0677b5f7so22829455e9.1 for ; Mon, 11 May 2026 01:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778489669; x=1779094469; 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=43zcPeyEBahcbXzXBePbjbHiq0vh8NFM/GDJyyFYelY=; b=L6FAa9PcC1l2UNs3AKuekwPFhEkCjHm0zA8izXWifZU356ca3HYUqtXYHtWs15BBgx Rpjnl0Uaco5dj1909gPeit8MYxDrb4Wl+LkkcwDO/F5K4BJGv3sX3TOcnYcNnovN9pJp vs0An58lNp7iSAGuCJ4lVAoqocyTJnkHW6VdZ+f2xTiczqjVQW1W+C3rBkvBS/Xqi4zd Gz0iTnA12HWUQXvektd5N7pKzfb/StdSt2FkBhkNoxcC2E8BdONJGWqZAGVmNRv1FscA 0YNVM3KBwRzsej6cHlqwkN5JVRH1VNaxFl1zkrtVhv28hjxX4Nl9FeOALLWZNsOJy0sD xaGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778489669; x=1779094469; 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=43zcPeyEBahcbXzXBePbjbHiq0vh8NFM/GDJyyFYelY=; b=p4CrSdbV2stSQcpqz7acRRWcRY8yfm/ot9XxvAKlhMKoFcCddVY9Cf4/aeD7CjkGu0 IeHNyMtMCKLypskFSxPHaqcMCHd34ymCb8g3bWdJWRYQYmr4eaCGMU+ikrHqKSCHaKVO tPRVpSQa6zZArW6WauwmsyMu5Jtlb5NEFca2xuB2xyWN5ALUxBDSCZUxEbc3WPsBQGeb kdp0CTfjieuZfipHECTQkESiEIqD4Xos0ok3HoAzhntfWnaaJGGjnPBNRe+PxytUSa8X ry3/hVZmYyTfk7TxbP7Lepxj2xBGkC9nVtIfJ8sLhFCBOktiBcGVCdwOgZHAEOtMG1xo XN6Q== X-Gm-Message-State: AOJu0Yw/yfhxRAujI07Z0Ysq4/bYywpxiGDwz7k9ZezZ1jvR2a201T6E 4A4bbHQR3DuiOpItyi1gYr510BtLsNLYPpZqCqhAaVLcZnC6MZghcZnfva3oZkZDH2UUJjx70HB jOFfHMOuwvjvIyJf+1oL8C8ewyZCNiPgjgGqmpGZNpyeuvWNk8EY8hT1KgHhjcSWAz1H+/gTv8+ f8QoIaUuk8fvnA1KfOm9Pk5EFYTkXEKOiLbgJs+78JsktWeQ== X-Gm-Gg: Acq92OEiJ1NZGLRTNd7vnB4RRnORrTS+bVYOPwQtUL4LI50JNCYSh8R5ZWkzNrS5YnM gA36zdO4gq1+y25glAM2+EPh+dTm34rVA5LiODDfIvuWwo2ddi3hzkgr+hW8WJsWlC+atAf02N4 kpJ4tfVW4sd6SQfQh55bBWLUHwxVdjhCYsXD11KBa9ngNm6IXuHPdPije5nvhiNHFv856J7PtMo FYSna5sLXI5lYipDdeL3m87MqRxc6+nW76qOsRLSFcLCVByPIXZktS7XG+KREkRsOUtNmmLg3Kr sdBFhzTyEA//5pqOIN1nXg6i931usf+fjcrLt2nrWpB2pV0JzIBb79+7htqh6iFW7vFMTRnbTFl l7mgBjFjxP/mJUOhhmA7QB+yZ6/0APdr+gOGMMF/t X-Received: by 2002:a05:600c:8b57:b0:48e:75fd:9f9e with SMTP id 5b1f17b1804b1-48e75fda826mr127047875e9.20.1778489669202; Mon, 11 May 2026 01:54:29 -0700 (PDT) X-Received: by 2002:a05:600c:8b57:b0:48e:75fd:9f9e with SMTP id 5b1f17b1804b1-48e75fda826mr127046835e9.20.1778489668599; Mon, 11 May 2026 01:54:28 -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-48e6d8d30dbsm91516415e9.1.2026.05.11.01.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 01:54:28 -0700 (PDT) Date: Mon, 11 May 2026 04:54:23 -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 , "Liam R. Howlett" Subject: [PATCH v6 13/30] mm: use __GFP_ZERO in vma_alloc_anon_folio_pmd 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 vma_alloc_anon_folio_pmd() 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 Assisted-by: Claude:claude-opus-4-6 --- mm/huge_memory.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d689e6491ddb..9845c920c29c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1333,7 +1333,7 @@ EXPORT_SYMBOL_GPL(thp_get_unmapped_area); static struct folio *vma_alloc_anon_folio_pmd(struct vm_area_struct *vma, unsigned long addr) { - gfp_t gfp = vma_thp_gfp_mask(vma); + gfp_t gfp = vma_thp_gfp_mask(vma) | __GFP_ZERO; const int order = HPAGE_PMD_ORDER; struct folio *folio; @@ -1356,14 +1356,6 @@ static struct folio *vma_alloc_anon_folio_pmd(struct vm_area_struct *vma, } 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, addr); /* * The memory barrier inside __folio_mark_uptodate makes sure that * folio_zero_user writes become visible before the set_pmd_at() -- MST