From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.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 B4C86296BD2 for ; Mon, 12 Jan 2026 23:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768261990; cv=none; b=Z6j7B30yrb7qgk7GZqOfPVOIsG62P28f68H/WWlWeAj/q1FlyO+wNYBhpk22kShXLi7GtTCPI7BACcSGzodDwJGO5FNhMcPm3yGuHBEDdiGQgXDJJ4V9lGELa/t3xHXrLFEMxU6zFjOKcCSAQB0sW+Az7WxdtU9gkLLWLFzhjAk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768261990; c=relaxed/simple; bh=OsumxHHod6cIwX4b7rdpDcd79fga9ieWIlr7hu71obk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VNYhIzvJcmpgCd0cvGn0+NglWHoj1olovMDSHADkIDDAh7JWX0377Enege1prq7MAiaMgMeP1RHbdPjYeIXn0vIwcrk0K7JM4cs4g9mSsshdOy+eZy2+LyY0euxWFp4yHcUO08EjDygA2K9buxo1xcCoWRCOESKY98ZLXIO2XgM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=KtPItGSB; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="KtPItGSB" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-8b23b6d9f11so748504785a.3 for ; Mon, 12 Jan 2026 15:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1768261987; x=1768866787; 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=MFAPVPPrTQcXGzmX4uMQny5ONRwVZsvoYJMZG32QBJM=; b=KtPItGSBQvLvHb6BqDZRMhIZcvxl8SAHN+P7ok/p1aKuAQMtWJhhXrcREM04DDEH/v xpOJYL4tPEFlpIJ6XvEwhuUsWgkVv1Pv0jJAq8pmcmuUSI2SmuZldT+/vPwufztTxt52 3P1FICBcMfFbtc64HIW+1ramux3MLbaDIVX/SnLL8rX4ZnTGWekTayWntFXxxLU9UTi8 aOCgpbDmI4+N+THurVfFu8XBmuqY+yDiQUlMQ8hhLgqCRWd/RgUbcVnoA0q8aTqyplJd Ahtq7MGMGIAeCpiswjEJOgbIQnm3Xkub+Tak4us3eYoDIAA78DjRTgUHNibTKf2m6vwD oWaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768261987; x=1768866787; 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=MFAPVPPrTQcXGzmX4uMQny5ONRwVZsvoYJMZG32QBJM=; b=WnawIQCkufLZLF9a/3+LHSx/lB6hfGyvFpYoj7fia+SmBmtD6WRlv4qeoT9In0YVKS 4PWhxtILNhGBQE4zcs27MhkGI/sTT106QuF5cX872T7R+rfbB9CEHZkq3BgNOXQIYaqc ciIm9Qq4iX7EBQFydh8Y7KqvCrcxRFXfbQ0Qs2U0jKl1tRfSFG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8b2:7536:bd2c with SMTP id af79cd13be357-8c3894188a8mr2759937485a.78.1768261987580; Mon, 12 Jan 2026 15:53:07 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-112-119.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.112.119]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8c37f530907sm1597443885a.39.2026.01.12.15.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jan 2026 15:53:07 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1vfRic-00000003fUQ-2VnR; Mon, 12 Jan 2026 19:53:06 -0400 Date: Mon, 12 Jan 2026 19:53:06 -0400 From: Jason Gunthorpe To: Zi Yan Cc: Matthew Wilcox , Balbir Singh , Francois Dugast , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Matthew Brost , Madhavan Srinivasan , Nicholas Piggin , Michael Ellerman , "Christophe Leroy (CS GROUP)" , Felix Kuehling , Alex Deucher , Christian =?utf-8?B?S8O2bmln?= , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lyude Paul , Danilo Krummrich , Bjorn Helgaas , Logan Gunthorpe , David Hildenbrand , Oscar Salvador , Andrew Morton , Leon Romanovsky , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Alistair Popple , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, linux-cxl@vger.kernel.org Subject: Re: [PATCH v4 1/7] mm/zone_device: Add order argument to folio_free callback Message-ID: <20260112235306.GN745888@ziepe.ca> References: <874d29da-2008-47e6-9c27-6c00abbf404a@nvidia.com> <0D532F80-6C4D-4800-9473-485B828B55EC@nvidia.com> <20260112134510.GC745888@ziepe.ca> <218D42B0-3E08-4ABC-9FB4-1203BB31E547@nvidia.com> <20260112165001.GG745888@ziepe.ca> <86D91C8B-C3EA-4836-8DC2-829499477618@nvidia.com> <20260112182500.GI745888@ziepe.ca> <6AFCEB51-8EE1-4AC9-8F39-FCA561BE8CB5@nvidia.com> <20260112192816.GL745888@ziepe.ca> <8DB7DC41-FDBD-4739-AABC-D363A1572ADD@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: <8DB7DC41-FDBD-4739-AABC-D363A1572ADD@nvidia.com> On Mon, Jan 12, 2026 at 06:34:06PM -0500, Zi Yan wrote: > page[1].flags.f &= ~PAGE_FLAGS_SECOND. It clears folio->order. > > free_tail_page_prepare() clears ->mapping, which is TAIL_MAPPING, and > compound_head at the end. > > page->flags.f &= ~PAGE_FLAGS_CHECK_AT_PREP. It clears PG_head for compound > pages. > > These three parts undo prep_compound_page(). Well, mm doesn't clear all things on alloc.. > In current nouveau code, ->free_folios is used holding the freed folio. > In nouveau_dmem_page_alloc_locked(), the freed folio is passed to > zone_device_folio_init(). If the allocated folio order is different > from the freed folio order, I do not know how you are going to keep > track of the rest of the freed folio. Of course you can implement a > buddy allocator there. nouveau doesn't support high order folios. A simple linked list is not really a suitable data structure to ever support high order folios with.. If it were to use such a thing, and did want to take a high order folio off the list, and reduce its order, then it would have to put the remainder back on the list with a revised order value. That's all, nothing hard. Again if the driver needs to store information in the struct page to manage its free list mechanism (ie linked pointers, order, whatever) then it should be doing that directly. When it takes the memory range off the free list it should call zone_device_page_init() to make it ready to be used again. I think it is a poor argument to say that zone_device_page_init() should rely on values already in the struct page to work properly :\ The usable space within the struct page, and what values must be fixed for correct system function, should exactly mirror what frozen pages require. After free it is effectively now a frozen page owned by the device driver. I haven't seen any documentation on that, but I suspect Matthew and David have some ideas.. If there is a reason for order, flags and mapping to be something particular then it should flow from the definition of frozen pages, and be documented, IMHO. Jason