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 22D433FF1C4 for ; Fri, 15 May 2026 15:45:15 +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=1778859917; cv=none; b=t25U4LC3OUXQVcGXdgz8gPEJPav4qXddUttxiXesigIRZ2U0qj0kxc1QO+1sQXXuCm8pTH8XuEL9ahRnXBhcpYNwKHbmzkgss7sWjBVh0w+FrupTOwsqurvmykaG+ruUXLxnoUM7hTw29zOQktEQLHXWPoP5FaN839LqnwYK3Pw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778859917; c=relaxed/simple; bh=9rXKEqxtzfmDQWqxkjEZdy4XXZNMoYLm7lH5AYwmn6c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hjQBwdQ9LoSPf10UUsUBcsml0jB5njDI7FEOO1DxEKJhRLMV4+iFbFTZF867wDNjiNKN0MqtDat4Y6ycmIvIbTtX8c0FYn+j8IKL3tbbO5NmCcxkYl4riWjuqfA3Ad1PIqjcs2gBLjb+p7310cMhJoswC4JYf3LoxIXz/UX7fGA= 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=PeiQc64P; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=EYzFT7Gn; 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="PeiQc64P"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="EYzFT7Gn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778859915; 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=bRJQWnIR/vMJOWlGH40eGCuLKFeHnLlb7//zEsKwBIQ=; b=PeiQc64Pkgu3rFm2Yp1eMcH8b04E8ifzdZhdhnYzw1WJIr8WDECHViJTNr4KcjnaQs0HlB JDN32C9Ai26slcUvqwYV9H80ggsUuv+zl+bFRsKMNH6BD+dng4Y0uDV444bNcrOSrojXkq aiTl+k1InpiTXqq6KBwVY4qL2L+CUr4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-0SgoOSRSNF2ON6QVSKdE0Q-1; Fri, 15 May 2026 11:45:13 -0400 X-MC-Unique: 0SgoOSRSNF2ON6QVSKdE0Q-1 X-Mimecast-MFC-AGG-ID: 0SgoOSRSNF2ON6QVSKdE0Q_1778859913 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-48fd233d1e2so28190155e9.1 for ; Fri, 15 May 2026 08:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778859912; x=1779464712; 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=bRJQWnIR/vMJOWlGH40eGCuLKFeHnLlb7//zEsKwBIQ=; b=EYzFT7Gn4yLRrWmNVz+9+7BP/Z4zcHKRcRThmJGqGUuvLEpK/VbZo8jjl4bjruJGtP 6P2YHsfgsnTY/kddfAAclylEhgOOIykRqqV0cU7Y+sfiOpu7oA6US6Y1IX0GBxWvc27G jku6q5ZYyYZyHOeVoHIwraDeKAzo0mGlMGjdMmN5Han0PZDQMdJlI/5wQJsryTrrclWN BfgvzA575e1muqNqMuJfeTIMly0epqF2yEN8I4hKeX8cBbMvtkHdNntS5gVdi+b2umNn brI1hvHWWoNnjUuckDQRe1iRpyEgOQZCs0iWb2NSSDQ4QbsWZ04m04AC1XSoZJO5DQd5 KXKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778859912; x=1779464712; 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=bRJQWnIR/vMJOWlGH40eGCuLKFeHnLlb7//zEsKwBIQ=; b=VEQTklbPwOwLsVJVNiWovDjAADLx9x0kOdk/AWll04Qhc/f7axBlN6JwVP22VjSTSR ZmNVk3yDUeNeSyBuZM+yLpsBFMSN8zLBZJ2NQdKl2wFebarV8JtIzslcmeto0IFXU5Bx 7HDRpHXU83tFeoVD6xErh4xPOR+FbKzD+tsSk2KJd+AL242V9CJoHPSHh7S5rv0NzUIs svI+wr88fJBBeHj+8csTMZMSs4qGzjmecbOASjEgb31Cu9duavG5vyZ6hrVQItu3RlTR GPjcsPgBvUzmPeQRI438kFDIJcUxNcuJn3MwM923AC9v/3MMRQdnZfyUZlNqRe3JohMX YnUA== X-Gm-Message-State: AOJu0Yz6GDw/9w/IiVmCbqFskQj5cjTSvKbbVXHnyaCgdjwgKwL0ElAV nVIm+ocwDzOhgGXdd1Z3E8XDCERdvfghjr1kNlqp+tC0Qk6ukaT5DyIDgNsYx4tqhgdrPRN0P+P ZYKJfZGcwTljOQRiNSVkKcAoVY/KOyKJGt4ZFtQq8YhKLiqEHfBxF5/SJIXlS0tnUCA== X-Gm-Gg: Acq92OG9uUVCTKzeh3ONhA+ZxgGZPSDa5YOYq7Otu7LK04PzWKrL/V/saCk1PRZ0oXV N2KwhW5mzNOSrF1H/etemZ7SZqsw72gthrx8vcURmaYw9lstQqhLnfyEP2kR5aeWSLnTtLvaBkS hztpUN1PCcWfiKbdx9WiZ5gD07vWTe98NgENQQIPy4Mcfi5dE2/NAp5y6o/AkTOvAqRazO2m+dW tzMmGPBFLWaY0abIsAwwaZN52SJLu4RiUZPD3hb+tcW/7gOjqKeeNOWkaHvTifH+vsdHSoUzG/r 7wVjFz5Ifafyn+OZmgmYh2NMDPrs8uaeh86KAVO6lX0ueQjJRxEB+mEVYnY+GX4dOnReeREdBMb su5Q7jrxOQIMBj6ArJ4A+wdt0tp7ltix9xL7KIHiZ X-Received: by 2002:a05:600c:c0db:b0:489:1ff1:74d3 with SMTP id 5b1f17b1804b1-48fe63223e2mr46155915e9.20.1778859912398; Fri, 15 May 2026 08:45:12 -0700 (PDT) X-Received: by 2002:a05:600c:c0db:b0:489:1ff1:74d3 with SMTP id 5b1f17b1804b1-48fe63223e2mr46154975e9.20.1778859911682; Fri, 15 May 2026 08:45:11 -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-48fe5ab527asm79317025e9.11.2026.05.15.08.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2026 08:45:10 -0700 (PDT) Date: Fri, 15 May 2026 11:45:05 -0400 From: "Michael S. Tsirkin" To: Gregory Price 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: <20260515114250-mutt-send-email-mst@kernel.org> References: <45d1ea85b574399459a64fdba28fcf04abfa3e7e.1778616612.git.mst@redhat.com> <20260514135214-mutt-send-email-mst@kernel.org> <20260514150750-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: On Fri, May 15, 2026 at 11:39:20AM -0400, Gregory Price wrote: > On Thu, May 14, 2026 at 03:08:13PM -0400, Michael S. Tsirkin wrote: > > On Thu, May 14, 2026 at 02:56:54PM -0400, Gregory Price wrote: > > > 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 :] > > > > Hmm. Are you sure? Isn't the address used for numa policy? > > > > You said "They do not allocate userspace pages" - so wouldn't uaddr be > USER_ADDR_NONE anyway? That part was wrong. > > Even if they do allocate userspace pages, they weren't passing > __GFP_ZERO before, so either: > > 1) They did not depend on the buddy to do zeroing before, and > user_addr is just a dead variable in those cases anyway. > > or > > 2) There is a bug, and they should be zeroing the page. IIUC, it's neither. Consider CoW: yes we are allocating a new page for userspace, but no we do not need to zero: we are copying data on write. > I just see an interesting hardening opportunity. > > Not suggesting you actually implement this, to be clear, maybe just > documenting the idea on the thread as a potential follow up. > > ~Gregory