[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <33b39588-5a39-4474-ac17-bde923803600@gmail.com>
Date: Wed, 13 Aug 2025 11:17:57 +0800
From: Ethan Zhao <etzhao1900@...il.com>
To: Jason Gunthorpe <jgg@...dia.com>, Baolu Lu <baolu.lu@...ux.intel.com>
Cc: Dave Hansen <dave.hansen@...el.com>, Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>, Robin Murphy <robin.murphy@....com>,
Kevin Tian <kevin.tian@...el.com>, Jann Horn <jannh@...gle.com>,
Vasant Hegde <vasant.hegde@....com>, Alistair Popple <apopple@...dia.com>,
Peter Zijlstra <peterz@...radead.org>, Uladzislau Rezki <urezki@...il.com>,
Jean-Philippe Brucker <jean-philippe@...aro.org>,
Andy Lutomirski <luto@...nel.org>, Yi Lai <yi1.lai@...el.com>,
iommu@...ts.linux.dev, security@...nel.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH v3 1/1] iommu/sva: Invalidate KVA range on kernel TLB
flush
On 8/11/2025 8:57 PM, Jason Gunthorpe wrote:
> On Fri, Aug 08, 2025 at 01:15:12PM +0800, Baolu Lu wrote:
>> +static void kernel_pte_work_func(struct work_struct *work)
>> +{
>> + struct ptdesc *ptdesc, *next;
>> +
>> + iommu_sva_invalidate_kva_range(0, TLB_FLUSH_ALL);
>> +
>> + guard(spinlock)(&kernel_pte_work.lock);
>> + list_for_each_entry_safe(ptdesc, next, &kernel_pte_work.list, pt_list) {
>> + list_del_init(&ptdesc->pt_list);
>> + pagetable_dtor_free(ptdesc);
>> + }
>
> Do a list_move from kernel_pte_work.list to an on-stack list head and
> then immediately release the lock. No reason to hold the spinock while
> doing frees, also no reason to do list_del_init, that memory probably
> gets zerod in pagetable_dtor_free()
Yep,using guard(spinlock)() for scope-bound lock management sacrifices
fine-grained control over the protected area. If offers convenience at
the cost of precision.
Out of my bias, calling it sluggard(spinlock)() might be proper.
Thanks,
Ethan
>
> Jason
>
Powered by blists - more mailing lists