linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Zi Yan <ziy@nvidia.com>
Cc: "Mika Penttilä" <mpenttil@redhat.com>,
	"Francois Dugast" <francois.dugast@intel.com>,
	intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	"Balbir Singh" <balbirs@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Oscar Salvador" <osalvador@suse.de>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-cxl@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/7] mm: Split device-private and coherent folios before freeing
Date: Fri, 9 Jan 2026 10:26:35 -0800	[thread overview]
Message-ID: <aWFIW6XCKXPpIinv@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <DF5A6B81-7811-4654-855F-8EAB76CCCE51@nvidia.com>

On Fri, Jan 09, 2026 at 12:28:22PM -0500, Zi Yan wrote:
> On 9 Jan 2026, at 6:09, Mika Penttilä wrote:
> 
> > Hi,
> >
> > On 1/9/26 10:54, Francois Dugast wrote:
> >
> >> From: Matthew Brost <matthew.brost@intel.com>
> >>
> >> Split device-private and coherent folios into individual pages before
> >> freeing so that any order folio can be formed upon the next use of the
> >> pages.
> >>
> >> Cc: Balbir Singh <balbirs@nvidia.com>
> >> Cc: Alistair Popple <apopple@nvidia.com>
> >> Cc: Zi Yan <ziy@nvidia.com>
> >> Cc: David Hildenbrand <david@kernel.org>
> >> Cc: Oscar Salvador <osalvador@suse.de>
> >> Cc: Andrew Morton <akpm@linux-foundation.org>
> >> Cc: linux-mm@kvack.org
> >> Cc: linux-cxl@vger.kernel.org
> >> Cc: linux-kernel@vger.kernel.org
> >> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> >> Signed-off-by: Francois Dugast <francois.dugast@intel.com>
> >> ---
> >>  mm/memremap.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >>
> >> diff --git a/mm/memremap.c b/mm/memremap.c
> >> index 63c6ab4fdf08..7289cdd6862f 100644
> >> --- a/mm/memremap.c
> >> +++ b/mm/memremap.c
> >> @@ -453,6 +453,8 @@ void free_zone_device_folio(struct folio *folio)
> >>  	case MEMORY_DEVICE_COHERENT:
> >>  		if (WARN_ON_ONCE(!pgmap->ops || !pgmap->ops->folio_free))
> >>  			break;
> >> +
> >> +		folio_split_unref(folio);
> >>  		pgmap->ops->folio_free(folio);
> >>  		percpu_ref_put_many(&folio->pgmap->ref, nr);
> >>  		break;
> >
> > This breaks folio_free implementations like nouveau_dmem_folio_free
> > which checks the folio order and act upon that.
> > Maybe add an order parameter to folio_free or let the driver handle the split?

'let the driver handle the split?' - I had consisder this as an option.

> 
> Passing an order parameter might be better to avoid exposing core MM internals
> by asking drivers to undo compound pages.
> 

It looks like Nouveau tracks free folios and free pages—something Xe’s
device memory allocator (DRM Buddy) cannot do. I guess this answers my
earlier question of how Nouveau avoids hitting the same bug as Xe / GPU
SVM with respect to reusing folios. It appears Nouveau prefers not to
split the folio, so I’m leaning toward moving this call into the
driver’s folio_free function.

Matt

> Best Regards,
> Yan, Zi


  reply	other threads:[~2026-01-09 18:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260109085605.443316-1-francois.dugast@intel.com>
2026-01-09  8:54 ` [PATCH v3 1/7] mm: Add folio_split_unref helper Francois Dugast
2026-01-09 13:19   ` David Hildenbrand (Red Hat)
2026-01-09 13:26     ` David Hildenbrand (Red Hat)
2026-01-09 14:30       ` Zi Yan
2026-01-09 15:11         ` David Hildenbrand (Red Hat)
2026-01-09 18:38           ` Matthew Brost
2026-01-09 18:37     ` Andrew Morton
2026-01-09 18:41       ` Zi Yan
2026-01-09 18:54         ` Francois Dugast
2026-01-09 18:43       ` Matthew Brost
2026-01-09 19:22         ` Andrew Morton
2026-01-09 19:26           ` Liam R. Howlett
2026-01-09  8:54 ` [PATCH v3 3/7] mm: Split device-private and coherent folios before freeing Francois Dugast
2026-01-09 11:09   ` Mika Penttilä
2026-01-09 17:28     ` Zi Yan
2026-01-09 18:26       ` Matthew Brost [this message]
2026-01-09 18:53         ` Zi Yan
2026-01-09 19:08           ` Matthew Brost
2026-01-09 19:23             ` Zi Yan
2026-01-09 20:03               ` Matthew Brost
2026-01-09 20:15                 ` Zi Yan
2026-01-09 21:34                   ` Balbir Singh
2026-01-09 21:43                     ` Zi Yan
2026-01-09 22:11                       ` Balbir Singh
2026-01-09 22:14                         ` Zi Yan
2026-01-09 22:36                           ` Balbir Singh
2026-01-09 23:15                             ` Matthew Brost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aWFIW6XCKXPpIinv@lstrano-desk.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=balbirs@nvidia.com \
    --cc=david@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mpenttil@redhat.com \
    --cc=osalvador@suse.de \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox