* [PATCH 1/1] use documented cmpxchg api @ 2014-06-05 22:19 Pranith Kumar 2014-06-06 0:34 ` Peter Hurley 0 siblings, 1 reply; 5+ messages in thread From: Pranith Kumar @ 2014-06-05 22:19 UTC (permalink / raw) To: dwmw2, joro; +Cc: iommu, linux-kernel use the documented atomic_cmpxchg instead of __cmpxchg64 This kills the last user of said API in drivers code. Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> --- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 6bb3277..270113f 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -293,7 +293,7 @@ static inline u64 dma_pte_addr(struct dma_pte *pte) return pte->val & VTD_PAGE_MASK; #else /* Must have a full atomic 64-bit read */ - return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; + return atomic_cmpxchg(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; #endif } -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] use documented cmpxchg api 2014-06-05 22:19 [PATCH 1/1] use documented cmpxchg api Pranith Kumar @ 2014-06-06 0:34 ` Peter Hurley 2014-06-06 1:03 ` Pranith Kumar 0 siblings, 1 reply; 5+ messages in thread From: Peter Hurley @ 2014-06-06 0:34 UTC (permalink / raw) To: Pranith Kumar, dwmw2, joro; +Cc: iommu, linux-kernel On 06/05/2014 06:19 PM, Pranith Kumar wrote: > use the documented atomic_cmpxchg instead of __cmpxchg64 > > This kills the last user of said API in drivers code. > > > Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> > --- > drivers/iommu/intel-iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > index 6bb3277..270113f 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -293,7 +293,7 @@ static inline u64 dma_pte_addr(struct dma_pte *pte) > return pte->val & VTD_PAGE_MASK; > #else > /* Must have a full atomic 64-bit read */ > - return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; > + return atomic_cmpxchg(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; This is not equivalent. The __cmpxchg64() is specifically being used in this case when !CONFIG_64BIT for a full 64-bit RMW, whereas atomic_cmpxchg() uses ints which would be 32-bit RMW. Regards, Peter Hurley ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] use documented cmpxchg api 2014-06-06 0:34 ` Peter Hurley @ 2014-06-06 1:03 ` Pranith Kumar 2014-06-06 10:55 ` Peter Hurley 0 siblings, 1 reply; 5+ messages in thread From: Pranith Kumar @ 2014-06-06 1:03 UTC (permalink / raw) To: Peter Hurley, Pranith Kumar, dwmw2, joro; +Cc: iommu, linux-kernel On 06/05/2014 08:34 PM, Peter Hurley wrote: > On 06/05/2014 06:19 PM, Pranith Kumar wrote: >> use the documented atomic_cmpxchg instead of __cmpxchg64 >> >> This kills the last user of said API in drivers code. >> >> >> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> >> --- >> drivers/iommu/intel-iommu.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c >> index 6bb3277..270113f 100644 >> --- a/drivers/iommu/intel-iommu.c >> +++ b/drivers/iommu/intel-iommu.c >> @@ -293,7 +293,7 @@ static inline u64 dma_pte_addr(struct dma_pte *pte) >> return pte->val & VTD_PAGE_MASK; >> #else >> /* Must have a full atomic 64-bit read */ >> - return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; >> + return atomic_cmpxchg(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; > > This is not equivalent. > > The __cmpxchg64() is specifically being used in this case > when !CONFIG_64BIT for a full 64-bit RMW, whereas atomic_cmpxchg() > uses ints which would be 32-bit RMW. > You are right! The previous patch is wrong in that atomic_cmpxchg needs an atomic_t argument. cmpxchg() handles the size internally using typeof() to figure out the width of RMW. There is also an explicit cmpxchg64() which does the same thing. Fixed with the following v2: use the documented cmpxchg instead of __cmpxchg64 This kills the last user of said API in drivers code. Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> --- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 6bb3277..270113f 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -293,7 +293,7 @@ static inline u64 dma_pte_addr(struct dma_pte *pte) return pte->val & VTD_PAGE_MASK; #else /* Must have a full atomic 64-bit read */ - return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; + return cmpxchg(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; #endif } -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] use documented cmpxchg api 2014-06-06 1:03 ` Pranith Kumar @ 2014-06-06 10:55 ` Peter Hurley 2014-06-06 14:27 ` Pranith Kumar 0 siblings, 1 reply; 5+ messages in thread From: Peter Hurley @ 2014-06-06 10:55 UTC (permalink / raw) To: Pranith Kumar, Pranith Kumar, dwmw2, joro; +Cc: iommu, linux-kernel On 06/05/2014 09:03 PM, Pranith Kumar wrote: > On 06/05/2014 08:34 PM, Peter Hurley wrote: >> On 06/05/2014 06:19 PM, Pranith Kumar wrote: >>> use the documented atomic_cmpxchg instead of __cmpxchg64 >>> >>> This kills the last user of said API in drivers code. >>> >>> >>> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> >>> --- >>> drivers/iommu/intel-iommu.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c >>> index 6bb3277..270113f 100644 >>> --- a/drivers/iommu/intel-iommu.c >>> +++ b/drivers/iommu/intel-iommu.c >>> @@ -293,7 +293,7 @@ static inline u64 dma_pte_addr(struct dma_pte *pte) >>> return pte->val & VTD_PAGE_MASK; >>> #else >>> /* Must have a full atomic 64-bit read */ >>> - return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; >>> + return atomic_cmpxchg(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; >> >> This is not equivalent. >> >> The __cmpxchg64() is specifically being used in this case >> when !CONFIG_64BIT for a full 64-bit RMW, whereas atomic_cmpxchg() >> uses ints which would be 32-bit RMW. >> > > > You are right! The previous patch is wrong in that atomic_cmpxchg needs an atomic_t argument. > cmpxchg() handles the size internally using typeof() to figure out the width of RMW. > There is also an explicit cmpxchg64() which does the same thing. This won't work either, and should generate a compile or link error on CONFIG_X86_32. The auto-sizing done by __cmpxchg() does not substitute the cmpxchg8b instruction for the cmpxchg instruction. __X86_CASE_Q is defined as -1 for CONFIG_X86_32 so the 8-byte size variant is dead-code, and calls __cmpxchg_wrong_size() instead. > Fixed with the following v2: > > use the documented cmpxchg instead of __cmpxchg64 > > This kills the last user of said API in drivers code. > > Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> > --- > drivers/iommu/intel-iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > index 6bb3277..270113f 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -293,7 +293,7 @@ static inline u64 dma_pte_addr(struct dma_pte *pte) > return pte->val & VTD_PAGE_MASK; > #else > /* Must have a full atomic 64-bit read */ > - return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; > + return cmpxchg(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; > #endif > } ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] use documented cmpxchg api 2014-06-06 10:55 ` Peter Hurley @ 2014-06-06 14:27 ` Pranith Kumar 0 siblings, 0 replies; 5+ messages in thread From: Pranith Kumar @ 2014-06-06 14:27 UTC (permalink / raw) To: Peter Hurley, Pranith Kumar, dwmw2, joro; +Cc: iommu, linux-kernel On 06/06/2014 06:55 AM, Peter Hurley wrote: > > This won't work either, and should generate a compile or link error > on CONFIG_X86_32. > > The auto-sizing done by __cmpxchg() does not substitute the cmpxchg8b > instruction for the cmpxchg instruction. __X86_CASE_Q is defined as -1 for > CONFIG_X86_32 so the 8-byte size variant is dead-code, and calls > __cmpxchg_wrong_size() instead. > > Fixed with the following v3: use the documented cmpxchg64 instead of __cmpxchg64. This kills the last user of said API in drivers code. Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> --- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 6bb3277..270113f 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -293,7 +293,7 @@ static inline u64 dma_pte_addr(struct dma_pte *pte) return pte->val & VTD_PAGE_MASK; #else /* Must have a full atomic 64-bit read */ - return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; + return cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; #endif } -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-06 14:27 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-06-05 22:19 [PATCH 1/1] use documented cmpxchg api Pranith Kumar 2014-06-06 0:34 ` Peter Hurley 2014-06-06 1:03 ` Pranith Kumar 2014-06-06 10:55 ` Peter Hurley 2014-06-06 14:27 ` Pranith Kumar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox