Re: [PATCH 2/3] iommu/vt-d: Use try_cmpxchg64() in intel_pasid_get_entry()
From: Baolu Lu
Date: Thu May 23 2024 - 09:44:44 EST
On 2024/5/23 21:34, Uros Bizjak wrote:
+ if (!try_cmpxchg64(&dir[dir_index].val, &tmp,
+ (u64)virt_to_phys(entries) | PASID_PTE_PRESENT)) {
Above change will cause a dead loop during boot. It should be
No, it is correct as written:
if (cmpxchg64(*ptr, 0, new))
can be written as:
if (cmpxchg64(*ptr, 0, new) != 0)
this is equivalent to:
tmp = 0ULL;
if (!try_cmpxchg64(*ptr, &tmp, new))
The return value of both cmpxchg64() and try_cmpxchg64() is the old
value that was loaded from the memory location, right?
If so,
if (cmpxchg64(*ptr, 0, new) != 0)
is not equivalent to
if (!try_cmpxchg64(*ptr, &tmp, new))
Best regards,
baolu