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 4C5FB1E51E0 for ; Mon, 8 Jun 2026 14:08:37 +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=1780927718; cv=none; b=IgbiG296sYRuobIZdaHfq4A2glloVY5pU1o5mvIDr5HNiYvFxDjDI/MAe3IYtV77DzSZn3fg2hmsUPuCtuV8Fjhj8blN8EetlRefci2YTIo269ll8c1i7S8oQkGMZj/SfrCYFhplSO/sKknfHTIz9b9Ka6fOuzw8kmQtV9oOxpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780927718; c=relaxed/simple; bh=U9oxgLYNM6iJKQyHOiyERv6zkQrC0pfJMLIHEKQ4Yo0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PDCtP997g0PmONkJxEkvVB0OYcJW4ANmMgn5xerixg+fVpP24vTlXg8kF4jlOYx6shek74GSEwkMsAoDc7+eS4gjJqwC4UhkSn43fZI7O0cI9dPYXP2Zs6UDnO6fqFvjGBK9GoLQsuHLg4msBjA5c8IfLp83/Kinvw8ef5IPO7s= 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=TrHy/ZNl; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZKdcfY5A; 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="TrHy/ZNl"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZKdcfY5A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780927716; 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=LB5rudO5SFykOh7GP1yRj9jRlO/AUIWutNzfIO1MaUA=; b=TrHy/ZNl3lC5NgxjiBP/eQYHlHU21IRyGudgXnndMQQ34pDPsl2X9jtIXFnoN5FYSaXWv3 KrWu8v26TZPWks8cJSrBp9u1aIRmAp/fgB86MqgxHforffEeWtG5mW2H+JIfTjZxHOlw9c U1JImrw4iZkyfW5uYtmlXGPQiTJsY10= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-307-6Ky9lBCxNL2G89hfBq40iA-1; Mon, 08 Jun 2026 10:08:33 -0400 X-MC-Unique: 6Ky9lBCxNL2G89hfBq40iA-1 X-Mimecast-MFC-AGG-ID: 6Ky9lBCxNL2G89hfBq40iA_1780927712 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-490bfd70b0fso46111325e9.0 for ; Mon, 08 Jun 2026 07:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780927712; x=1781532512; 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=LB5rudO5SFykOh7GP1yRj9jRlO/AUIWutNzfIO1MaUA=; b=ZKdcfY5Awke38Kb1ZnIKuhIKZGmGjDW6jL69rj4hmC5tPUuD10sweR73PC7jOSHS5X LR1gJPE51fr4ikcFfnBAGgrkm9oaINOtz2lj4Binobb5T0ttMSA2u2kYG0ObHfoNt3t2 hR3XXqHGBNRl8YDR7L4vVWnP25e/Bst51t3cXIaYpvPz53ulqKxhp7FP3XhoCyB/yhen vsI6rRFdBH+k+iucEiVlNhdgmQT59mBsRy8ANb8o9ppJY3k/LYx1B27uuKZ49hxdMyim AX0Y7lqETHnTlf0DG2WYpuzFsLzDGWDsLFVW2KvOPxOlb6mjqTIIg7Ftn0FWTFjYpIu4 I2LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780927712; x=1781532512; 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=LB5rudO5SFykOh7GP1yRj9jRlO/AUIWutNzfIO1MaUA=; b=LxrbV+oNAV+W6J3X7BA//+NRS9F34tOfPsAsd6dTnxbVPwkaa6LlLquLOtyZvcvCLP ZUKGaHJA79aoNd6b0zt+psObOJFshL5Wfpt/2A6a4bJ5QZP8cM3A5+YT/skQKNQ64j4U MQ0CKA5Z5sm52hpFF/eXG5avkuJLWpdyJpAAZZZFcfm8Bh9BZBGq1IK4JYoSZyQowtd+ Ax0DI6n/zHHihGYJvPSB70cVC4F5Haceu4nv9QcgSzpKvkc/8JM8ZY+LSiVMajfqV2TC R/yonzoiFCwUNQ6wXcahk8GDENEw2xf0xPnneK/aCGgDDoocicUldh6c51mwDXc6+w67 j6Eg== X-Forwarded-Encrypted: i=1; AFNElJ/GQq0oYcH3f1uWV9Dx0Wd8s6A985/YtnKreUumVsB36q+i8hMr0EELAwy61mi9686E1wXIfLWIrFsWqMA=@vger.kernel.org X-Gm-Message-State: AOJu0YwfLLAF8vBbtrw2QxIvwHsIHSEQCxwRPCabqUnplBeMoIolgZ1W Oso44IuPTUvHFlhODDLrfwvEzyZ5oUd/O1QijAKqgEISQQIk9za+z2SGyxgZXtdGLUp2lb3dgNy Vmu9knRj473r2kpEcWhHod2DcYvC38bfMIRotmvPppBD0Wxf7sl/E7sQ+OMM2J15zuw== X-Gm-Gg: Acq92OHOTgLvi9jXd727MrFDQBL6yBqd1zQNKzfV6+l3Qkpl2roDXL9RAZ8ilNnma/w WCwOqOr3Yds13Mwp1B9pnWdkU7PrekvqwkuyDEwNmg5UICVdOk92x4zed0TVKnHXCOmVnG9dtAz kECN8hj+m1Xh27c5Z9CzjLOZauaotMEFVDwrQgjjWcgO6R8hh6VUNTEuGx/uYNztn5NO2u8tWAX pI0abFq1meQomf93wPPISwrXlSvfkXJONl+XN1Hgo3HK7xfIa0l1klBLQ3OJ24+V6SdYajFhODs fPMQ7C65lv5YlPIgb8df9sVs2NPJOhx8DbCnsXb7WK1sFa3jQXYP9FVL9EeK7m9YXo5+uYI1HcF bNOCt7VNfdCWIGzDNpg6r6G0= X-Received: by 2002:a05:600c:4e04:b0:490:cc1b:15c7 with SMTP id 5b1f17b1804b1-490cc1b1631mr114019965e9.30.1780927711908; Mon, 08 Jun 2026 07:08:31 -0700 (PDT) X-Received: by 2002:a05:600c:4e04:b0:490:cc1b:15c7 with SMTP id 5b1f17b1804b1-490cc1b1631mr114017635e9.30.1780927710559; Mon, 08 Jun 2026 07:08:30 -0700 (PDT) Received: from redhat.com ([185.16.164.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc3cc0f8sm396828465e9.8.2026.06.08.07.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 07:08:30 -0700 (PDT) Date: Mon, 8 Jun 2026 10:08:25 -0400 From: "Michael S. Tsirkin" To: "David Hildenbrand (Arm)" Cc: Lorenzo Stoakes , 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 , 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: Re: [PATCH v10 24/37] mm: add put_page_zeroed and folio_put_zeroed Message-ID: <20260608100602-mutt-send-email-mst@kernel.org> References: <8ec82477-b497-466c-902b-82e108ae2b7b@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: <8ec82477-b497-466c-902b-82e108ae2b7b@kernel.org> On Mon, Jun 08, 2026 at 02:46:34PM +0200, David Hildenbrand (Arm) wrote: > On 6/8/26 14:25, Lorenzo Stoakes wrote: > > On Mon, Jun 08, 2026 at 04:38:54AM -0400, Michael S. Tsirkin wrote: > >> Add put_page_zeroed() / folio_put_zeroed() for callers that hold > >> a reference to a page known to be zeroed. > >> > >> If this drops the last reference, the zeroed hint is > >> propagated to the buddy allocator. If someone else still holds a > >> reference, the hint is simply lost - this is best-effort. > >> > >> This is useful for balloon drivers during deflation: the host > >> has already zeroed the pages, and the balloon is typically the > >> sole owner. But if the page happens to be shared, silently > >> dropping the hint is safe and avoids the need for callers to > >> check the refcount. > >> > >> Note: put_page_zeroed uses folio_put_testzero() which only > >> detects sole ownership at the instant of the atomic decrement. > >> A concurrent reference holder (e.g. migration) means the hint > >> is silently lost. This is by design: the zeroed hint is a > >> performance optimization, not a correctness requirement. > >> Losing it just means the next allocation re-zeroes the page. > > > > Do not put comments about specific expected races like this in the commit > > message but not in the code. Subtleties need to be called out. > > > > The commit message also doesn't at all explain why PG_zeroed doesn't > > suffice here. > > > >> > >> Signed-off-by: Michael S. Tsirkin > >> Assisted-by: Claude:claude-opus-4-6 > > > > I really don't understand why you have a 'zeroed' folio flag but need to > > also have new API calls to detect that? > > > > They're also HORRIBLY named. Zeroed as in what? Zero page? Huge zero page? > > Memory zeroed by kernel? Pages that userland happen to have zeroed? Or host > > VM zeroed? > > > > Each are cases we address individually and relate to folios. > > > > You absolutely fail to clarify _which one_ you mean, and provide absolutely > > no documentation and add an exported mm API with no description. > > > > This is just I think not something we want to add? Especially on something > > so fundamental? > > I raised previously that providing a folio helper is odd, and that I suggested > that we defer this change. Sadly it's a dependency actually - without it memcg failures would cause repeated re-zeroing where previously it failed without zeroing. It's the result of the whole GFP_ZERO idea. > Maybe we'd want to add such an interface for frozen pages later (to be used by > the balloon), but I don't think we want that for folios. > > [1] https://lore.kernel.org/all/5f76af6e-9818-42ea-a305-c0fc1d920dca@kernel.org/ > > -- > Cheers, > > David