From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (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 AAB4F354AE3 for ; Thu, 14 May 2026 18:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778785020; cv=none; b=Jtr8tlFZm88ggx9kJ0Z8H32FJsA7fbOZgtkQGaGgwNBs1JN60de6mtH1nAabtAiNZgQpJUklittMmg7tEKWp+XLvL+TT6M7vlEjvPuJgZUEPtGsKsTFYr6Ja03D0TDdavJ9v+5ojutGV5r4NjErux/9QTBaEnDydip+9XZjcF9w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778785020; c=relaxed/simple; bh=PTJYSe0IvbiXAB6GYmp0kp0T7miMLyPrJGEmhAbWNn4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gMlmXRhn8JM3SGtpEIu7qBWvsqK8x1WfUW3IbTjKx+s+4ElndvOAGF85Im0X5m2nERuPk7y1SaGeaOZ8ze95SI+/uSEikGXs9HdlnX9upqN5TvsE4hGxBZMDY3tWfW2nA8xn3lJAB33vCRSvxmXCvAWwMc0xP8S6gXkAIkfbVqk= 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=H1mvlTVv; arc=none smtp.client-ip=209.85.222.173 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="H1mvlTVv" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-911796e9885so18496185a.0 for ; Thu, 14 May 2026 11:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1778785018; x=1779389818; 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=V8Dmb/0xFR5yj63uM1EuYrYGpP68khCa5e0rkyGQMeU=; b=H1mvlTVvs7vTuZAyGm1J37VGj9ZVHes1K9KhxcBIft2e80PAOCDsJERmsrymDfun+a PKsTqiF3p39vs6JrxfYxuF0+MX4Jwtpq47C+9d0swLFdjwU0HfJdmC74WY3TG9O1xaGs GLhDcj8M0TBoe7s2yuUToH3dHvzjSjfcY42ZFgaKFIfojqhrRNk8K4+lCLLJCsVyrtgG l0q6JdRJJakD49/WEv6kj4vmT0ivxRXq1hCkMOhAY+YkEj1c444NrOsWiYR8UO67nARX LcdWhGX0/UFD/J8MnRuRIJlBatwvjSrZmVDH+kj2m5+Pt261KuYVBEOElEo08rHGFcHF u/rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778785018; x=1779389818; 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=V8Dmb/0xFR5yj63uM1EuYrYGpP68khCa5e0rkyGQMeU=; b=ZGuQqJA7qzeLAgtNwtmkn4Grlsj2imZV1FrWCADHPrT+VgGlsBf4c0lil5Txytvuzn U6pP5RUnJeHSvL3UAQ+7CRM6MSZaLxBGTM6zSu6IiDMBZSrVpnMYA7GDndGpCbs4vgXD B/9B0H1ItD8O71Vtsnbrw4WHfNL2MUbHMjSmJCXSQ5be2pUlIouBwYTsv0a5yrHzSpEM nf2cuxzMRWO3Hxb6bj34ec+Uoo5U8tet/GKDcLDNche7uyHdJ877yuhlO25/sFf1I77j zSKntxCtX1/HiZgTGxorc+e0luBjTBlGqcrQd190U45s+v5X8qeEKWpFosLRPek75e7c JWkA== X-Gm-Message-State: AOJu0YzlgmoKYTxuPEV1oqDzhBIsHQkyE54Wcf4OUjG3ptng4xG4m2Kv uU9jsDcqKEZV+M+pHLKjMz9imih6E+JxBWF/EyoL0Cl6KxaUAfZcYeyXDlt5XIQEu/E= X-Gm-Gg: Acq92OFGkuwn9qnYPzwfHYP6ajcvZUZZRFCIMEbKFE+KgKz+e9ka/QB3bC1KUyqJZ1b dbx2mNEdOLhZRqv7JNCggfIpZ3CqjSqDecmW6ggwWrB2Iq421u1SJ8VzMOBqYh3mdMQtdCSqpQz eI8yWv8F7NjrOscSQgpwRa3F6niBjCo/fwEZoQez+NdXGFjWn32nAewwpqO7jUr4CSpnsOtNBGS ewv9nvJkFMCdeUYTUjkqLjzNvjsdzuljvAS1jj7WsVE5wzrU81nz3z6TeSAnUdYCtMPbpSOtVKE y9bAZHYtL1ASRCCEwMtOhmkwJ1MTVZ02X6BnWLHWrLTGpBFliXfnsQY2ZPIAkDmTumbfKp8dx7l OPZTITWGF29udmiDi38UQtREQQZOHuAGRYipkLJjoezKtUDoGG+3/hFpuVqeMR9Wg5FleePIrTJ Z7xqbcakD0HbEVzSVWWiePjGft0ytzLm+k5RGAKu1hFJSmvc3x42ZEeLBJq6B2bpMNbbnGGjZ47 SGuXMaRezeU X-Received: by 2002:a05:620a:2587:b0:911:c5c0:d5f8 with SMTP id af79cd13be357-911c5c0ddbfmr149858785a.9.1778785017499; Thu, 14 May 2026 11:56:57 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-100-36-248-188.washdc.fios.verizon.net. [100.36.248.188]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8c90874e4besm30437366d6.2.2026.05.14.11.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2026 11:56:57 -0700 (PDT) Date: Thu, 14 May 2026 14:56:54 -0400 From: Gregory Price To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , 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 , 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 v7 09/31] mm: use folio_zero_user for user pages in post_alloc_hook Message-ID: References: <45d1ea85b574399459a64fdba28fcf04abfa3e7e.1778616612.git.mst@redhat.com> <20260514135214-mutt-send-email-mst@kernel.org> 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: <20260514135214-mutt-send-email-mst@kernel.org> On Thu, May 14, 2026 at 02:00:31PM -0400, Michael S. Tsirkin wrote: > On Thu, May 14, 2026 at 09:49:33AM -0400, Gregory Price wrote: > > There are calls with no __GFP_ZERO but they do not allocate userspace pages. > > - drm_pagemap.c: GFP_HIGHUSER -- no zero. But this is a DRM device > page migration, the page content is preserved from the source. > > - test_hmm.c: GFP_HIGHUSER_MOVABLE -- no zero. Test driver, pages get > content from device. > > - mm/ksm.c: GFP_HIGHUSER_MOVABLE -- no zero. KSM merges identical > pages, content comes from the source page (copy). > > - mm/memory.c new_folio = GFP_HIGHUSER_MOVABLE > - no zero. This is CoW, content is copied from old page. > > - mm/userfaultfd.c: GFP_HIGHUSER_MOVABLE - no zero. Content comes from userspace via userfaultfd. > > - arm64/fault.c: __GFP_ZEROTAGS not __GFP_ZERO. MTE tag zeroing, not page zeroing. Page is zeroed separately. > Right, so in all of these cases, it would be just as correct to pass USER_ADDR_NONE I imagine :] i.e. the user address is irrelevant, and the caller is responsible for sanitization before return if it's relevant. Otherwise, passing (user_addr != -1) the buddy takes care of it for you. Just an obvious security bonus to all of this, but by no means a requirement for your set. Just an observation. > > I'd do this on top if possible. > Yeah reasonable. ~Gregory