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 7B2D519ABD8 for ; Tue, 9 Jun 2026 08:06:54 +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=1780992415; cv=none; b=I6eDekN9/egi4iXdMxz8bwxLo3AMHXrGtDG8zM5VHBlDg8bk9eJP8RPniKUYmgeY/9Tydu+nJeuhVYUw0Zx9mB1umZuQa8f8sI68Fse/UirjzROY4LWkmjp8JWCpXjmKlijWQbDfUP29JK6UKxiWHZgaimj/YMkJMA/Pg4WYV3U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780992415; c=relaxed/simple; bh=UzctvEXGPkxRJJFL6usyl9J2oOluX53QVY2A6gfvG1A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dGRCJ45SEROU1rvk3Th+UdL9abGlKpEccNHZ0piHOvC9aTlYLc+M63xvkq+e/D/qLxI0Xe6lCV0sHOJllnGpgTBTTlWe42q6tHrGnlRsfrlO/MUF44spAJvP1n9f7c3eMxQYCGZO8DrvO8rd7ywBQ6q+NoOai11zR8F5G6t+hzg= 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=fFP+L6EG; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=I7gXo8FI; 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="fFP+L6EG"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="I7gXo8FI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780992413; 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=Mtkf4sgMqVoG+F92sfanLnqPLF7Ap+Es97Nko8xXfZE=; b=fFP+L6EG6ls71FUvQGss0yhpdX1+UMoZu85MKaqgFAtqJZMd6dqmLUrm6wCReVryHYO40G gwl5Vaa5TgEZsQzsk5hCjrXbfEwpD40nGBV+Zv+zhsC9DZnVqk1CIfX9JW+7PN919PcTwn Fejb5iuQ86Z7heS6MiRb98mcEZG+2m0= 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-153-W-oxTPGlOzqO3mGvNJ93pw-1; Tue, 09 Jun 2026 04:06:16 -0400 X-MC-Unique: W-oxTPGlOzqO3mGvNJ93pw-1 X-Mimecast-MFC-AGG-ID: W-oxTPGlOzqO3mGvNJ93pw_1780992375 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490b8adf8b8so47882785e9.0 for ; Tue, 09 Jun 2026 01:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780992375; x=1781597175; 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=Mtkf4sgMqVoG+F92sfanLnqPLF7Ap+Es97Nko8xXfZE=; b=I7gXo8FIc16DDKp6rPdbCVAHK+sXB3//XvBroVUOv9Ge70GBadnNNU0Q2SMqsFhsIM tzO39O6qp5P7rx1qaHM7pPAOjaNdJ3TaoksyLeSrMizwSk5pgPfiYSYQMbX3YaKPhUCb kDPhSEw9w7PsMUfHhidF6Oj6B65Gnix+TTWm8JuWYrkoD0+lFZmtA34nfIJR9gplkow+ MeWQcCH4QGVilGjkw0bVwhhQK0d7qLMUdUAaF08iVFCaS9Z3OLDFUWYT+E5rLQnUwX1N kvh3AWkTKxRagCjOlGsvk++dJiTfZkmhNLJ1BE4CIiMQVEXlqGpWVMq5+AoDUpLmAz9z KhrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780992375; x=1781597175; 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=Mtkf4sgMqVoG+F92sfanLnqPLF7Ap+Es97Nko8xXfZE=; b=md2N01vaQfp56wyD+TcTiX8X+r8hFQS3B2XL2C2T8SDeZhMQcR+QeD/SUA2wSla4x6 Xt52dThpTWntQgVbqSFi4JVagOjMAizYTGfiNQUa+VROShiTRN5EYbIDYJAhS3U9mill 3tYqD0eE63IhXC7OyX7sJ0Kf2RiMcBuno5105Eo4uRpN9mmKQ7lW8+RT3LNwaFmKEmIJ tQImH9wkOGxtHTg1WjA5IQnrXtCXLZaPLCZrWoD7bRYjtaCnCyCDaw7fwb26ItdWtZYC /uuNAcwg7/bD2H/p0GsvRjMULyzm0sLY/PbDNsIDT0856SHuV/XK2GIxfReQcSSGnSAw IuNQ== X-Gm-Message-State: AOJu0Yy7996W8ibW548hxv31vx+BgTSkXinQvQUnFoxAWLtE2nnyFPs9 s3cF6KqjZ0KO2RVj5BB3OAAN6cZ7QiIvvM5DlheCC+/r1Vu+d7MgLU2JdfKnY1hSMk/638OPq5G 9soyzDNqhqRwsNVD7/y0nMpThVwfv8y9/bm0vhNcW8LBXl3vr4jYzGNdVGCA5zQwlqw== X-Gm-Gg: Acq92OHUbYWkZ2vDj+4keXc+Vzaudb8FNVjfUF7aCVszMcvX4RR5BrJdBKZUpwa0vHO Vnc56qtCde/Uhf/iDSG/n8mH9I2qUDaxpZ1YvW+3WNWi6PymphQdeuj6Ep9OMnAHvu6Tyhhl2hC t9cty6hshxTCL9BN3c5NASDNy8l+TW464RIDNS3EboiOyzjO38C8M6XAMwpockicfzN2oZVmvM7 bOe+MHlcAF/H1PUF+ZwZIW4SoCxy8+fm3BXqmjymHiTooZdijmaKuydoRMW/ZptG5FYeiXi/JgG PfkcGA8NmcJXw06DHplV+EHmar2F90QEoFP3YNR1/1qCWwPuj8I3EOAu5uO0WNKRxZhchFQeDDj ZgfZX3l4JWJ38Wqg4+x0RcB+yBvYp95XrFS5QFdv3T1PMdXUdNhw9gQ== X-Received: by 2002:a05:600c:3515:b0:490:b409:94f4 with SMTP id 5b1f17b1804b1-490c2602a24mr294886845e9.28.1780992375121; Tue, 09 Jun 2026 01:06:15 -0700 (PDT) X-Received: by 2002:a05:600c:3515:b0:490:b409:94f4 with SMTP id 5b1f17b1804b1-490c2602a24mr294885445e9.28.1780992374486; Tue, 09 Jun 2026 01:06:14 -0700 (PDT) Received: from redhat.com (IGLD-80-230-85-71.inter.net.il. [80.230.85.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc3d66c8sm440082815e9.10.2026.06.09.01.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 01:06:13 -0700 (PDT) Date: Tue, 9 Jun 2026 04:06:08 -0400 From: "Michael S. Tsirkin" To: Matthew Wilcox 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 , 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: New design Message-ID: <20260609033042-mutt-send-email-mst@kernel.org> 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: On Tue, Jun 09, 2026 at 04:58:14AM +0100, Matthew Wilcox wrote: > OK, here's how I'd structure this: Thanks a lot for looking into this and writing this Matthew! Looks workable, let's see if there's rough consensus around this. Two questions to make sure I understand. > > 1. Introduce PG_zeroed for buddy pages > 2. Set it if init_on_free is set Not 100% sure why we want this bit. And I am not sure this works actually because init_on_free does kernel_init_pages and does not flush cache on arm32. You will notice that user_alloc_needs_zeroing ignores init_on_free. Right? How about we skip step 2, make the patchset a bit smaller? > 3. Set it from balloon driver > > https://lore.kernel.org/lkml/c7094de807c0e963526686e1d245bc76193b1a92.1776689093.git.mst@redhat.com/ > > but add FPI_ZEROED instead of an extra bool parameter. > > 4. Introduce page_is_zeroed like this: > > static inline bool page_is_zeroed(const struct page *page) > { > /* > * lru.next has bit 2 set if the page is already zeroed. > * Callers may simply overwrite it once they no longer > * need to preserve that information. > */ > return (unsigned long)page->lru.next & BIT(2); > } > > (you'll notice this is similar to page_is_pfmemalloc() but it doesn't > need to be in mm.h) > > This step is going to be a bit fiddly. We weren't expecting to return > multiple flags in page->lru.next, so clear_page_pfmemalloc() just sets > page->lru.next to NULL. So somewhere we need to make sure that > page->lru.next is definitely NULL, and then allow both the zeroed and > pfmemalloc flags to be set in it. > > The important part of this is that it allows the zeroed flag to be > returned from the page allocator without introducing pghint_t like you > did in v2. > > 5. Now you can start skipping various zeroing steps higher in the call > chain. > I understand David's disgust with vma_alloc_zeroed_movable_folio() > but that is surely a separate cleanup and nothing to do with this > patchset. One other question: would people like to see it as a single patchset or multiple ones 1-4? Multiple ones would be easier to review but of course this means no actual perf gain until part 5 is merged. Is that acceptable? -- MST