From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CABE939FCDC for ; Mon, 8 Jun 2026 20:56:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780952173; cv=none; b=DZmodZxQ40E2mEvzTUhbMBJkgexUQkI434rVzWe+YbxNMedt1djQFpFyIhyNO9rVqJSGln4hABkTwIJ9oORXp/Pv7xOEm02Aq5FGlgbWLuDoYKvA0oZLPZ/Zsf3I5j/DWjzF9Wh4H+48veXDaHYUPFP+QYKWqzkYELq6H8XwxtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780952173; c=relaxed/simple; bh=4uPqreWhfD9TRFZ8S24VSlOkGn3Vz++056QSRM5GRyA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DFeFUDfG9w3jS/DdYpseoV7M4Mr+uxkto8bulVv7k1AnUadPo4CqFSVYmROjTufTTFjlRHhMtHGyeUT2S/CQEQo3vy9nhkKr4xD5AcJLKcF7q8SzR71+w4EFqxGC/UboH2FkM4uAFlh09D7PfdHYrHH9Qpc5V5EZ1kNpwMclnNY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=tBOEISO2; arc=none smtp.client-ip=209.85.160.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="tBOEISO2" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-51758478240so23489411cf.2 for ; Mon, 08 Jun 2026 13:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1780952171; x=1781556971; 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=fHaHyUtmd7xYX3FTc2W1dWbFRus+iCyGxuj8fCGhfn0=; b=tBOEISO2Y/vAeg7yAVceku7qdgDBoZ/c/PezSvZ+A4h1w64x34XQLyygANcZwsXfvt WvGZtcJ5hGc2gJCWFCrdxS6GfgTwIhbeMaAcIoaiVX5g3SM8BP5KjGaXz8m/VhNbM+Jc zu+kX/4Ba78d/Cm3BGqqo88+qYKky8XXKEnMkuvipDBRjy85kgD4m/grv29ih09oPzkR KIfXnonW9DW/trtyW1jky60sqevAvgsLE8UOOPic45DLZiuPpVq6Nqe4SEzYyuFYrbcF m/vX7iIX2exGxR/38Wq8j7zjWxedj7aAUGnx1A7TItcP3QJ14/GvXRFEWzf729Xjc9jA /z7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780952171; x=1781556971; 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=fHaHyUtmd7xYX3FTc2W1dWbFRus+iCyGxuj8fCGhfn0=; b=PMpIpS7jXtwlHGyPjjLWzAF1oP9SRNFwCDARwRW5ygKYvn2EjCrLosoza2FT/29ALN eShj1scqtNQAhcPGFBTQBrRE0RjIp2i19bMq8NOI+4GLVCqKnpCKDbIUUF/kCqAmoD8t bU25/yGpWjrwOr3ndElsfM7TM4MBIPeRKKRVR1VFlL16D5jODpOXu9V4Tiyl/xKego8D j4rQ0j4l1H7W2u5rILNfglH3Rhf13uJTWcdRdlXN8yRY0nWWolwh1X50sOt1Uxl2ziJj M+LxzIQltew6d05u1kEkA/YP8PClu2/TRrCP/GvcFlqfwo8m2WZqzPV9LL7dXV9UJZpV fmzQ== X-Forwarded-Encrypted: i=1; AFNElJ8qU150KfZLvsfvuQTjUOQsGeNnvXTI3OVLw/R0BbcgWc9q9U1PE/lNzdB4Hf1t7kGm+OrUOnOqJr7/M3k=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+opPMKtdx6JSIN2X1NqGUyZ8AwiLHy+NJJJhtOc4KwqjKH5Ph +HmkcK56wWB6YsX8B6gHXllyoRI87OCBDs+TkgdOyGXl9X29ZYRM1SB+hYGL5C3vJBo= X-Gm-Gg: Acq92OHpM4/4tPpTaaYSRuwV2Q0M3h9ubfean5hMKVZnYgVK75CYfSItvSJtzPVP+g9 Qzx/DHAQhQnmGB1RVPfTioyHRFGibqiWQWP1jtkczBFoxd+rrOSYZRzobV8DIrQhc8H59JDiLrh casxtQ5yBsSqy5vJhbC0DLbFYlvhFxPlQWhvzxhrgrcN9KZWwSPJKJtCiEtRz3M6OtUz48DyubW R+sZVU4O95WLe7TOQZDJxPtQBVR9xexSOmO1GPjltnfTbS+cEBRW4aNKVS/13012c95uCrIlbzT a1He+OwCAXSea/RrEp/zCoL7OTa4QnzqAPREzSUxNFBajG0Y+8hO8DA6UGBuwZ4ssVAlv8LQCi9 jw4ZXrZKt+YzqGObjiqCN3/OuLf9RgfLPd5Rk3Wog3tERpI2Zc3nwr442OHuyh0pZHItY0EwqWo OUDbjcF/mEFERtdwl5CN5xRrUTKv5yua78blJr3C5f85QtyV2ASNAx74tyA5aHEbSUWGXud/trl i4QqHjbrBIauKRF2g== X-Received: by 2002:a05:622a:2597:b0:516:cfb9:2856 with SMTP id d75a77b69052e-51795be2429mr255289181cf.31.1780952170668; Mon, 08 Jun 2026 13:56:10 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-173-79-60-52.washdc.fios.verizon.net. [173.79.60.52]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ceccd9fda2sm180883106d6.2.2026.06.08.13.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 13:56:10 -0700 (PDT) Date: Mon, 8 Jun 2026 16:56:08 -0400 From: Gregory Price To: Zi Yan Cc: "David Hildenbrand (Arm)" , Lorenzo Stoakes , "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Muchun Song , Oscar Salvador , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Hugh Dickins , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , 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: Re: [PATCH v10 07/37] mm: thread user_addr through page allocator for cache-friendly zeroing Message-ID: References: <50d410b47fe3f45327783e05bd306d5eaab75e65.1780906288.git.mst@redhat.com> <64f2e580-aa82-4849-9236-b8ec4208ca24@kernel.org> <2475e4c4-9ba3-4091-9bfd-1c1c15163da7@kernel.org> <8BB8D6E5-8644-4CBC-BAF1-0AA19702E042@nvidia.com> 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: On Mon, Jun 08, 2026 at 04:37:59PM -0400, Zi Yan wrote: > On 8 Jun 2026, at 16:25, Gregory Price wrote: > > > > essentially we end up with something like > > > > alloc_frozen_...(..., gfp) > > { > > folio = whatever(..., gfp); > > if (gfp & __GFP_ZERO) > > folio_zero(folio, -1); /* don't do cache flush part */ > > } > > > > alloc_frozen_user_...(..., gfp, user_addr) > > { > > folio = whatever(..., gfp); > > if (gfp & __GFP_ZERO) > > folio_zero(folio, user_addr); /* do cache flush part */ > > } > > > > The downside of this is obvious: it's easy for developers to get this > > wrong and call the non-user interface for user-bound allocations and > > miss the cache flush (that is only needed on some archs). > > > > Not saying that's a deal breaker, but it's something to chew on. > > I agree that misuse can cause trouble. But if we do the churn approach, > what prevents developer from doing alloc_frozen(..., user_addr = -1) > and using the returned page for userspace? It is possible the allocated > page can be exported to userspace later. > > BTW, that cache flush thing is fragile even today, you probably can > do alloc_page() + vm_insert() to get a page without doing proper flush > and export it to userspace. There seems to be no mechanism to > prevent that. > Oh of course, I said that elsewhere. It leaves us in a spot where we're not technically worse than we were yesterday - except that the surface of the buddy has increased (developers need to know about 2 APIs instead of 1). That carries maintenance burden (if something in alloc_frozen() changes, something in alloc_frozen_user() may need to change). There's a careful dance here. ~Gregory