RE: [PATCH v4 6/8] mm: Introduce deferred freeing for kernel page tables

Tian, Kevin
2025-09-19T08:18:30Z

> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Monday, September 15, 2025 7:35 PM
>
> On Fri, Sep 12, 2025 at 08:17:23AM +0000, Tian, Kevin wrote:
> > > From: Jason Gunthorpe <jgg@nvidia.com>
> > > Sent: Saturday, September 6, 2025 2:44 AM
> > >
> > > On Fri, Sep 05, 2025 at 01:51:01PM +0800, Lu Baolu wrote:
> > >
> > > > + list_for_each_entry_safe(pt, next, &page_list, pt_list) {
> > > > + list_del(&pt->pt_list);
> > >
> > > The list_del isn't necessary, it doesn't zero the list, just _safe
> > > iteration is fine.
> > >
> >
> > if no list_del why need to keep the _safe iteration?
>
> __pagetable_free() can change the memory holding pt->pt-list, it is
> like kfree. So _safe is needed to allow that.
>
> _safe is not just about deletion, anything that could change the list
> element must use a safe iteration.
>

yeah, my oversight.