linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive
@ 2021-07-29  8:25 Rui Wang
  2021-07-29  9:03 ` Boqun Feng
  2021-07-29  9:53 ` Thomas Bogendoerfer
  0 siblings, 2 replies; 8+ messages in thread
From: Rui Wang @ 2021-07-29  8:25 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Peter Zijlstra
  Cc: Will Deacon, Boqun Feng, linux-kernel, linux-mips, Rui Wang, hev

This looks like a typo and that caused atomic64 test failed.

Signed-off-by: Rui Wang <wangrui@loongson.cn>
Signed-off-by: hev <r@hev.cc>
---
 arch/mips/include/asm/atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
index 95e1f7f3597f..a0b9e7c1e4fc 100644
--- a/arch/mips/include/asm/atomic.h
+++ b/arch/mips/include/asm/atomic.h
@@ -206,7 +206,7 @@ ATOMIC_OPS(atomic64, xor, s64, ^=, xor, lld, scd)
  * The function returns the old value of @v minus @i.
  */
 #define ATOMIC_SIP_OP(pfx, type, op, ll, sc)				\
-static __inline__ int arch_##pfx##_sub_if_positive(type i, pfx##_t * v)	\
+static __inline__ type arch_##pfx##_sub_if_positive(type i, pfx##_t * v)	\
 {									\
 	type temp, result;						\
 									\
-- 
2.32.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive
  2021-07-29  8:25 [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive Rui Wang
@ 2021-07-29  9:03 ` Boqun Feng
  2021-07-29  9:15   ` hev
  2021-07-29  9:53 ` Thomas Bogendoerfer
  1 sibling, 1 reply; 8+ messages in thread
From: Boqun Feng @ 2021-07-29  9:03 UTC (permalink / raw)
  To: Rui Wang
  Cc: Thomas Bogendoerfer, Peter Zijlstra, Will Deacon, linux-kernel,
	linux-mips, hev

Hi,

On Thu, Jul 29, 2021 at 04:25:49PM +0800, Rui Wang wrote:
> This looks like a typo and that caused atomic64 test failed.
> 
> Signed-off-by: Rui Wang <wangrui@loongson.cn>
> Signed-off-by: hev <r@hev.cc>

In your upcoming patches, please change this part to your real name.
Here is a quote from Documentation/process/submitting-patches.rst:
  
	using your real name (sorry, no pseudonyms or anonymous contributions.)

Regards,
Boqun

> ---
>  arch/mips/include/asm/atomic.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
> index 95e1f7f3597f..a0b9e7c1e4fc 100644
> --- a/arch/mips/include/asm/atomic.h
> +++ b/arch/mips/include/asm/atomic.h
> @@ -206,7 +206,7 @@ ATOMIC_OPS(atomic64, xor, s64, ^=, xor, lld, scd)
>   * The function returns the old value of @v minus @i.
>   */
>  #define ATOMIC_SIP_OP(pfx, type, op, ll, sc)				\
> -static __inline__ int arch_##pfx##_sub_if_positive(type i, pfx##_t * v)	\
> +static __inline__ type arch_##pfx##_sub_if_positive(type i, pfx##_t * v)	\
>  {									\
>  	type temp, result;						\
>  									\
> -- 
> 2.32.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive
  2021-07-29  9:03 ` Boqun Feng
@ 2021-07-29  9:15   ` hev
  0 siblings, 0 replies; 8+ messages in thread
From: hev @ 2021-07-29  9:15 UTC (permalink / raw)
  To: Boqun Feng
  Cc: Rui Wang, Thomas Bogendoerfer, Peter Zijlstra, Will Deacon,
	linux-kernel, linux-mips

Hi, Boqun,

On Thu, Jul 29, 2021 at 5:04 PM Boqun Feng <boqun.feng@gmail.com> wrote:
>
> Hi,
>
> On Thu, Jul 29, 2021 at 04:25:49PM +0800, Rui Wang wrote:
> > This looks like a typo and that caused atomic64 test failed.
> >
> > Signed-off-by: Rui Wang <wangrui@loongson.cn>
> > Signed-off-by: hev <r@hev.cc>
>
> In your upcoming patches, please change this part to your real name.
> Here is a quote from Documentation/process/submitting-patches.rst:
>
>         using your real name (sorry, no pseudonyms or anonymous contributions.)
Ok, got it. :-)

Thank you. I will resend these patches.

Regards
Rui

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive
  2021-07-29  8:25 [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive Rui Wang
  2021-07-29  9:03 ` Boqun Feng
@ 2021-07-29  9:53 ` Thomas Bogendoerfer
  2021-07-29 11:00   ` hev
  2021-07-29 12:31   ` hev
  1 sibling, 2 replies; 8+ messages in thread
From: Thomas Bogendoerfer @ 2021-07-29  9:53 UTC (permalink / raw)
  To: Rui Wang
  Cc: Peter Zijlstra, Will Deacon, Boqun Feng, linux-kernel, linux-mips, hev

On Thu, Jul 29, 2021 at 04:25:49PM +0800, Rui Wang wrote:
> This looks like a typo and that caused atomic64 test failed.
> 
> Signed-off-by: Rui Wang <wangrui@loongson.cn>
> Signed-off-by: hev <r@hev.cc>
> ---
>  arch/mips/include/asm/atomic.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
> index 95e1f7f3597f..a0b9e7c1e4fc 100644
> --- a/arch/mips/include/asm/atomic.h
> +++ b/arch/mips/include/asm/atomic.h
> @@ -206,7 +206,7 @@ ATOMIC_OPS(atomic64, xor, s64, ^=, xor, lld, scd)
>   * The function returns the old value of @v minus @i.
>   */
>  #define ATOMIC_SIP_OP(pfx, type, op, ll, sc)				\
> -static __inline__ int arch_##pfx##_sub_if_positive(type i, pfx##_t * v)	\
> +static __inline__ type arch_##pfx##_sub_if_positive(type i, pfx##_t * v)	\
>  {									\
>  	type temp, result;						\
>  									\

sub_if_postive looks unused to me. Could you send a patch removing it
instead ? riscv also has a sub_if_positive implementation, which looks
unused.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive
  2021-07-29  9:53 ` Thomas Bogendoerfer
@ 2021-07-29 11:00   ` hev
  2021-07-29 12:31   ` hev
  1 sibling, 0 replies; 8+ messages in thread
From: hev @ 2021-07-29 11:00 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: Rui Wang, Peter Zijlstra, Will Deacon, Boqun Feng, linux-kernel,
	linux-mips

On Thu, Jul 29, 2021 at 5:53 PM Thomas Bogendoerfer
<tsbogend@alpha.franken.de> wrote:
>
> On Thu, Jul 29, 2021 at 04:25:49PM +0800, Rui Wang wrote:
> > This looks like a typo and that caused atomic64 test failed.
> >
> > Signed-off-by: Rui Wang <wangrui@loongson.cn>
> > Signed-off-by: hev <r@hev.cc>
> > ---
> >  arch/mips/include/asm/atomic.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
> > index 95e1f7f3597f..a0b9e7c1e4fc 100644
> > --- a/arch/mips/include/asm/atomic.h
> > +++ b/arch/mips/include/asm/atomic.h
> > @@ -206,7 +206,7 @@ ATOMIC_OPS(atomic64, xor, s64, ^=, xor, lld, scd)
> >   * The function returns the old value of @v minus @i.
> >   */
> >  #define ATOMIC_SIP_OP(pfx, type, op, ll, sc)                         \
> > -static __inline__ int arch_##pfx##_sub_if_positive(type i, pfx##_t * v)      \
> > +static __inline__ type arch_##pfx##_sub_if_positive(type i, pfx##_t * v)     \
> >  {                                                                    \
> >       type temp, result;                                              \
> >                                                                       \
>
> sub_if_postive looks unused to me. Could you send a patch removing it
> instead ? riscv also has a sub_if_positive implementation, which looks
> unused.
Okay.

Regards,
Rui

>
> Thomas.
>
> --
> Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
> good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive
  2021-07-29  9:53 ` Thomas Bogendoerfer
  2021-07-29 11:00   ` hev
@ 2021-07-29 12:31   ` hev
  2021-07-29 14:33     ` Thomas Bogendoerfer
  1 sibling, 1 reply; 8+ messages in thread
From: hev @ 2021-07-29 12:31 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: Rui Wang, Peter Zijlstra, Will Deacon, Boqun Feng, linux-kernel,
	linux-mips

Hi, Thomas,

On Thu, Jul 29, 2021 at 5:53 PM Thomas Bogendoerfer
<tsbogend@alpha.franken.de> wrote:
>
> On Thu, Jul 29, 2021 at 04:25:49PM +0800, Rui Wang wrote:
> > This looks like a typo and that caused atomic64 test failed.
> >
> > Signed-off-by: Rui Wang <wangrui@loongson.cn>
> > Signed-off-by: hev <r@hev.cc>
> > ---
> >  arch/mips/include/asm/atomic.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
> > index 95e1f7f3597f..a0b9e7c1e4fc 100644
> > --- a/arch/mips/include/asm/atomic.h
> > +++ b/arch/mips/include/asm/atomic.h
> > @@ -206,7 +206,7 @@ ATOMIC_OPS(atomic64, xor, s64, ^=, xor, lld, scd)
> >   * The function returns the old value of @v minus @i.
> >   */
> >  #define ATOMIC_SIP_OP(pfx, type, op, ll, sc)                         \
> > -static __inline__ int arch_##pfx##_sub_if_positive(type i, pfx##_t * v)      \
> > +static __inline__ type arch_##pfx##_sub_if_positive(type i, pfx##_t * v)     \
> >  {                                                                    \
> >       type temp, result;                                              \
> >                                                                       \
>
> sub_if_postive looks unused to me. Could you send a patch removing it
> instead ? riscv also has a sub_if_positive implementation, which looks
> unused.
I found atomic{_64,}_dec_if_postive is based on sub_if_postive, and
used in many places:

kernel/kmod.c:    if (atomic_dec_if_positive(&kmod_concurrent_max) < 0) {
kernel/kmod.c:
atomic_dec_if_positive(&kmod_concurrent_max) >= 0,
kernel/module.c:        ret = atomic_dec_if_positive(&module->refcnt);
...
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c:
atomic64_dec_if_positive(&esw->user_count);
drivers/net/netdevsim/fib.c:        atomic64_dec_if_positive(&entry->num);
drivers/net/netdevsim/fib.c:        atomic64_dec_if_positive(&entry->num);

Are you sure to remove it?

Regards,
Rui

>
> Thomas.
>
> --
> Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
> good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive
  2021-07-29 12:31   ` hev
@ 2021-07-29 14:33     ` Thomas Bogendoerfer
  2021-08-04 13:46       ` hev
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Bogendoerfer @ 2021-07-29 14:33 UTC (permalink / raw)
  To: hev
  Cc: Rui Wang, Peter Zijlstra, Will Deacon, Boqun Feng, linux-kernel,
	linux-mips

On Thu, Jul 29, 2021 at 08:31:11PM +0800, hev wrote:
> Hi, Thomas,
> 
> On Thu, Jul 29, 2021 at 5:53 PM Thomas Bogendoerfer
> <tsbogend@alpha.franken.de> wrote:
> >
> > On Thu, Jul 29, 2021 at 04:25:49PM +0800, Rui Wang wrote:
> > > This looks like a typo and that caused atomic64 test failed.
> > >
> > > Signed-off-by: Rui Wang <wangrui@loongson.cn>
> > > Signed-off-by: hev <r@hev.cc>
> > > ---
> > >  arch/mips/include/asm/atomic.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
> > > index 95e1f7f3597f..a0b9e7c1e4fc 100644
> > > --- a/arch/mips/include/asm/atomic.h
> > > +++ b/arch/mips/include/asm/atomic.h
> > > @@ -206,7 +206,7 @@ ATOMIC_OPS(atomic64, xor, s64, ^=, xor, lld, scd)
> > >   * The function returns the old value of @v minus @i.
> > >   */
> > >  #define ATOMIC_SIP_OP(pfx, type, op, ll, sc)                         \
> > > -static __inline__ int arch_##pfx##_sub_if_positive(type i, pfx##_t * v)      \
> > > +static __inline__ type arch_##pfx##_sub_if_positive(type i, pfx##_t * v)     \
> > >  {                                                                    \
> > >       type temp, result;                                              \
> > >                                                                       \
> >
> > sub_if_postive looks unused to me. Could you send a patch removing it
> > instead ? riscv also has a sub_if_positive implementation, which looks
> > unused.
> I found atomic{_64,}_dec_if_postive is based on sub_if_postive, and
> used in many places:
> 
> kernel/kmod.c:    if (atomic_dec_if_positive(&kmod_concurrent_max) < 0) {
> kernel/kmod.c:
> atomic_dec_if_positive(&kmod_concurrent_max) >= 0,
> kernel/module.c:        ret = atomic_dec_if_positive(&module->refcnt);
> ...
> drivers/net/ethernet/mellanox/mlx5/core/eswitch.c:
> atomic64_dec_if_positive(&esw->user_count);
> drivers/net/netdevsim/fib.c:        atomic64_dec_if_positive(&entry->num);
> drivers/net/netdevsim/fib.c:        atomic64_dec_if_positive(&entry->num);
> 
> Are you sure to remove it?

in that case, let's keep it. There is a fallback for atomic_dec_if_positive,
that's why I didn't notice where it is used.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive
  2021-07-29 14:33     ` Thomas Bogendoerfer
@ 2021-08-04 13:46       ` hev
  0 siblings, 0 replies; 8+ messages in thread
From: hev @ 2021-08-04 13:46 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: Rui Wang, Peter Zijlstra, Will Deacon, Boqun Feng,
	Linux Kernel Mailing List, linux-mips

On Thu, Jul 29, 2021 at 10:33 PM Thomas Bogendoerfer
<tsbogend@alpha.franken.de> wrote:
>
> On Thu, Jul 29, 2021 at 08:31:11PM +0800, hev wrote:
> > Hi, Thomas,
> >
> > On Thu, Jul 29, 2021 at 5:53 PM Thomas Bogendoerfer
> > <tsbogend@alpha.franken.de> wrote:
> > >
> > > On Thu, Jul 29, 2021 at 04:25:49PM +0800, Rui Wang wrote:
> > > > This looks like a typo and that caused atomic64 test failed.
> > > >
> > > > Signed-off-by: Rui Wang <wangrui@loongson.cn>
> > > > Signed-off-by: hev <r@hev.cc>
> > > > ---
> > > >  arch/mips/include/asm/atomic.h | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
> > > > index 95e1f7f3597f..a0b9e7c1e4fc 100644
> > > > --- a/arch/mips/include/asm/atomic.h
> > > > +++ b/arch/mips/include/asm/atomic.h
> > > > @@ -206,7 +206,7 @@ ATOMIC_OPS(atomic64, xor, s64, ^=, xor, lld, scd)
> > > >   * The function returns the old value of @v minus @i.
> > > >   */
> > > >  #define ATOMIC_SIP_OP(pfx, type, op, ll, sc)                         \
> > > > -static __inline__ int arch_##pfx##_sub_if_positive(type i, pfx##_t * v)      \
> > > > +static __inline__ type arch_##pfx##_sub_if_positive(type i, pfx##_t * v)     \
> > > >  {                                                                    \
> > > >       type temp, result;                                              \
> > > >                                                                       \
> > >
> > > sub_if_postive looks unused to me. Could you send a patch removing it
> > > instead ? riscv also has a sub_if_positive implementation, which looks
> > > unused.
> > I found atomic{_64,}_dec_if_postive is based on sub_if_postive, and
> > used in many places:
> >
> > kernel/kmod.c:    if (atomic_dec_if_positive(&kmod_concurrent_max) < 0) {
> > kernel/kmod.c:
> > atomic_dec_if_positive(&kmod_concurrent_max) >= 0,
> > kernel/module.c:        ret = atomic_dec_if_positive(&module->refcnt);
> > ...
> > drivers/net/ethernet/mellanox/mlx5/core/eswitch.c:
> > atomic64_dec_if_positive(&esw->user_count);
> > drivers/net/netdevsim/fib.c:        atomic64_dec_if_positive(&entry->num);
> > drivers/net/netdevsim/fib.c:        atomic64_dec_if_positive(&entry->num);
> >
> > Are you sure to remove it?
>
> in that case, let's keep it. There is a fallback for atomic_dec_if_positive,
> that's why I didn't notice where it is used.

yep, do you think this patch is okay?

Regards,

Rui

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-08-04 13:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29  8:25 [RFC PATCH] locking/atomic: arch/mips: Fix atomic{_64,}_sub_if_positive Rui Wang
2021-07-29  9:03 ` Boqun Feng
2021-07-29  9:15   ` hev
2021-07-29  9:53 ` Thomas Bogendoerfer
2021-07-29 11:00   ` hev
2021-07-29 12:31   ` hev
2021-07-29 14:33     ` Thomas Bogendoerfer
2021-08-04 13:46       ` hev

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox