All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit
@ 2022-11-10  8:24 Genjian
  2023-01-06 14:53 ` Paul E. McKenney
  0 siblings, 1 reply; 4+ messages in thread
From: Genjian @ 2022-11-10  8:24 UTC (permalink / raw)
  To: frederic, paulmck
  Cc: linux-kernel, zhanggenjian123, Genjian Zhang, k2ci, kernel test robot

From: Genjian Zhang <zhanggenjian@kylinos.cn>

vmlinux.o: warning: objtool: __ct_user_enter+0x45: call to
__kasan_check_write() leaves .noinstr.text section
vmlinux.o: warning: objtool: __ct_user_exit+0x3f: call to
__kasan_check_write() leaves .noinstr.text section

noinstr cannot have atomic_*() functions.because they have explicit
instrumentation.Switch to arch_ prefixed atomic operation functions to
avoid the explicit instrumentation.

Reported-by: k2ci <kernel-bot@kylinos.cn>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
---
 kernel/context_tracking.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 77978e372377..a09f1c19336a 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -510,7 +510,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
 			 * In this we case we don't care about any concurrency/ordering.
 			 */
 			if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
-				atomic_set(&ct->state, state);
+				arch_atomic_set(&ct->state, state);
 		} else {
 			/*
 			 * Even if context tracking is disabled on this CPU, because it's outside
@@ -527,7 +527,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
 			 */
 			if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
 				/* Tracking for vtime only, no concurrent RCU EQS accounting */
-				atomic_set(&ct->state, state);
+				arch_atomic_set(&ct->state, state);
 			} else {
 				/*
 				 * Tracking for vtime and RCU EQS. Make sure we don't race
@@ -535,7 +535,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
 				 * RCU only requires RCU_DYNTICKS_IDX increments to be fully
 				 * ordered.
 				 */
-				atomic_add(state, &ct->state);
+				arch_atomic_add(state, &ct->state);
 			}
 		}
 	}
@@ -630,12 +630,12 @@ void noinstr __ct_user_exit(enum ctx_state state)
 			 * In this we case we don't care about any concurrency/ordering.
 			 */
 			if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
-				atomic_set(&ct->state, CONTEXT_KERNEL);
+				arch_atomic_set(&ct->state, CONTEXT_KERNEL);
 
 		} else {
 			if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
 				/* Tracking for vtime only, no concurrent RCU EQS accounting */
-				atomic_set(&ct->state, CONTEXT_KERNEL);
+				arch_atomic_set(&ct->state, CONTEXT_KERNEL);
 			} else {
 				/*
 				 * Tracking for vtime and RCU EQS. Make sure we don't race
@@ -643,7 +643,7 @@ void noinstr __ct_user_exit(enum ctx_state state)
 				 * RCU only requires RCU_DYNTICKS_IDX increments to be fully
 				 * ordered.
 				 */
-				atomic_sub(state, &ct->state);
+				arch_atomic_sub(state, &ct->state);
 			}
 		}
 	}
-- 
2.25.1


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

* Re: [PATCH] context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit
  2022-11-10  8:24 [PATCH] context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit Genjian
@ 2023-01-06 14:53 ` Paul E. McKenney
  2023-01-09  7:13   ` genjian zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2023-01-06 14:53 UTC (permalink / raw)
  To: Genjian; +Cc: frederic, linux-kernel, Genjian Zhang, k2ci, kernel test robot

On Thu, Nov 10, 2022 at 04:24:43PM +0800, Genjian wrote:
> From: Genjian Zhang <zhanggenjian@kylinos.cn>
> 
> vmlinux.o: warning: objtool: __ct_user_enter+0x45: call to
> __kasan_check_write() leaves .noinstr.text section
> vmlinux.o: warning: objtool: __ct_user_exit+0x3f: call to
> __kasan_check_write() leaves .noinstr.text section
> 
> noinstr cannot have atomic_*() functions.because they have explicit
> instrumentation.Switch to arch_ prefixed atomic operation functions to
> avoid the explicit instrumentation.
> 
> Reported-by: k2ci <kernel-bot@kylinos.cn>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>

Apologies for the delay, but finally queued, thank you!  Frederic gave
his ack off-list, which I have included in the wordsmithed version below.
Could you please check to make sure that I did not mess anything up?

							Thanx, Paul

------------------------------------------------------------------------

commit 936acd859f4a7b2b0f9900e26bc972385286df6e
Author: Genjian Zhang <zhanggenjian@kylinos.cn>
Date:   Thu Nov 10 16:24:43 2022 +0800

    context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit
    
    The following diagnostics are issued by objtool:
    
    vmlinux.o: warning: objtool: __ct_user_enter+0x45: call to
    __kasan_check_write() leaves .noinstr.text section
    vmlinux.o: warning: objtool: __ct_user_exit+0x3f: call to
    __kasan_check_write() leaves .noinstr.text section
    
    The reason for these diagnostics is that code marked noinstr if prohibited
    from using atomic_*() functions, which have explicit instrumentation.
    Therefore, switch to arch_ prefixed atomic operation functions to avoid
    the explicit instrumentation.
    
    Reported-by: k2ci <kernel-bot@kylinos.cn>
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
    Acked-by: Frederic Weisbecker <frederic@kernel.org>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 77978e3723771..a09f1c19336ae 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -510,7 +510,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
 			 * In this we case we don't care about any concurrency/ordering.
 			 */
 			if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
-				atomic_set(&ct->state, state);
+				arch_atomic_set(&ct->state, state);
 		} else {
 			/*
 			 * Even if context tracking is disabled on this CPU, because it's outside
@@ -527,7 +527,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
 			 */
 			if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
 				/* Tracking for vtime only, no concurrent RCU EQS accounting */
-				atomic_set(&ct->state, state);
+				arch_atomic_set(&ct->state, state);
 			} else {
 				/*
 				 * Tracking for vtime and RCU EQS. Make sure we don't race
@@ -535,7 +535,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
 				 * RCU only requires RCU_DYNTICKS_IDX increments to be fully
 				 * ordered.
 				 */
-				atomic_add(state, &ct->state);
+				arch_atomic_add(state, &ct->state);
 			}
 		}
 	}
@@ -630,12 +630,12 @@ void noinstr __ct_user_exit(enum ctx_state state)
 			 * In this we case we don't care about any concurrency/ordering.
 			 */
 			if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
-				atomic_set(&ct->state, CONTEXT_KERNEL);
+				arch_atomic_set(&ct->state, CONTEXT_KERNEL);
 
 		} else {
 			if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
 				/* Tracking for vtime only, no concurrent RCU EQS accounting */
-				atomic_set(&ct->state, CONTEXT_KERNEL);
+				arch_atomic_set(&ct->state, CONTEXT_KERNEL);
 			} else {
 				/*
 				 * Tracking for vtime and RCU EQS. Make sure we don't race
@@ -643,7 +643,7 @@ void noinstr __ct_user_exit(enum ctx_state state)
 				 * RCU only requires RCU_DYNTICKS_IDX increments to be fully
 				 * ordered.
 				 */
-				atomic_sub(state, &ct->state);
+				arch_atomic_sub(state, &ct->state);
 			}
 		}
 	}

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

* Re: [PATCH] context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit
  2023-01-06 14:53 ` Paul E. McKenney
@ 2023-01-09  7:13   ` genjian zhang
  2023-01-09 15:10     ` Paul E. McKenney
  0 siblings, 1 reply; 4+ messages in thread
From: genjian zhang @ 2023-01-09  7:13 UTC (permalink / raw)
  To: paulmck; +Cc: frederic, linux-kernel, Genjian Zhang, k2ci, kernel test robot

On Fri, Jan 6, 2023 at 10:53 PM Paul E. McKenney <paulmck@kernel.org> wrote:
>
> On Thu, Nov 10, 2022 at 04:24:43PM +0800, Genjian wrote:
> > From: Genjian Zhang <zhanggenjian@kylinos.cn>
> >
> > vmlinux.o: warning: objtool: __ct_user_enter+0x45: call to
> > __kasan_check_write() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: __ct_user_exit+0x3f: call to
> > __kasan_check_write() leaves .noinstr.text section
> >
> > noinstr cannot have atomic_*() functions.because they have explicit
> > instrumentation.Switch to arch_ prefixed atomic operation functions to
> > avoid the explicit instrumentation.
> >
> > Reported-by: k2ci <kernel-bot@kylinos.cn>
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
>
> Apologies for the delay, but finally queued, thank you!  Frederic gave
> his ack off-list, which I have included in the wordsmithed version below.
> Could you please check to make sure that I did not mess anything up?
>
>                                                         Thanx, Paul
>
> ------------------------------------------------------------------------
>
> commit 936acd859f4a7b2b0f9900e26bc972385286df6e
> Author: Genjian Zhang <zhanggenjian@kylinos.cn>
> Date:   Thu Nov 10 16:24:43 2022 +0800
>
>     context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit
>
>     The following diagnostics are issued by objtool:
>
>     vmlinux.o: warning: objtool: __ct_user_enter+0x45: call to
>     __kasan_check_write() leaves .noinstr.text section
>     vmlinux.o: warning: objtool: __ct_user_exit+0x3f: call to
>     __kasan_check_write() leaves .noinstr.text section
>
>     The reason for these diagnostics is that code marked noinstr if prohibited
>     from using atomic_*() functions, which have explicit instrumentation.
>     Therefore, switch to arch_ prefixed atomic operation functions to avoid
>     the explicit instrumentation.
>
>     Reported-by: k2ci <kernel-bot@kylinos.cn>
>     Reported-by: kernel test robot <lkp@intel.com>
>     Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
>     Acked-by: Frederic Weisbecker <frederic@kernel.org>
>     Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
>
> diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
> index 77978e3723771..a09f1c19336ae 100644
> --- a/kernel/context_tracking.c
> +++ b/kernel/context_tracking.c
> @@ -510,7 +510,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
>                          * In this we case we don't care about any concurrency/ordering.
>                          */
>                         if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
> -                               atomic_set(&ct->state, state);
> +                               arch_atomic_set(&ct->state, state);
>                 } else {
>                         /*
>                          * Even if context tracking is disabled on this CPU, because it's outside
> @@ -527,7 +527,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
>                          */
>                         if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
>                                 /* Tracking for vtime only, no concurrent RCU EQS accounting */
> -                               atomic_set(&ct->state, state);
> +                               arch_atomic_set(&ct->state, state);
>                         } else {
>                                 /*
>                                  * Tracking for vtime and RCU EQS. Make sure we don't race
> @@ -535,7 +535,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
>                                  * RCU only requires RCU_DYNTICKS_IDX increments to be fully
>                                  * ordered.
>                                  */
> -                               atomic_add(state, &ct->state);
> +                               arch_atomic_add(state, &ct->state);
>                         }
>                 }
>         }
> @@ -630,12 +630,12 @@ void noinstr __ct_user_exit(enum ctx_state state)
>                          * In this we case we don't care about any concurrency/ordering.
>                          */
>                         if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
> -                               atomic_set(&ct->state, CONTEXT_KERNEL);
> +                               arch_atomic_set(&ct->state, CONTEXT_KERNEL);
>
>                 } else {
>                         if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
>                                 /* Tracking for vtime only, no concurrent RCU EQS accounting */
> -                               atomic_set(&ct->state, CONTEXT_KERNEL);
> +                               arch_atomic_set(&ct->state, CONTEXT_KERNEL);
>                         } else {
>                                 /*
>                                  * Tracking for vtime and RCU EQS. Make sure we don't race
> @@ -643,7 +643,7 @@ void noinstr __ct_user_exit(enum ctx_state state)
>                                  * RCU only requires RCU_DYNTICKS_IDX increments to be fully
>                                  * ordered.
>                                  */
> -                               atomic_sub(state, &ct->state);
> +                               arch_atomic_sub(state, &ct->state);
>                         }
>                 }
>         }

Seems good to me.

Thanks,

Genjian.

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

* Re: [PATCH] context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit
  2023-01-09  7:13   ` genjian zhang
@ 2023-01-09 15:10     ` Paul E. McKenney
  0 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2023-01-09 15:10 UTC (permalink / raw)
  To: genjian zhang
  Cc: frederic, linux-kernel, Genjian Zhang, k2ci, kernel test robot

On Mon, Jan 09, 2023 at 03:13:06PM +0800, genjian zhang wrote:
> On Fri, Jan 6, 2023 at 10:53 PM Paul E. McKenney <paulmck@kernel.org> wrote:
> >
> > On Thu, Nov 10, 2022 at 04:24:43PM +0800, Genjian wrote:
> > > From: Genjian Zhang <zhanggenjian@kylinos.cn>
> > >
> > > vmlinux.o: warning: objtool: __ct_user_enter+0x45: call to
> > > __kasan_check_write() leaves .noinstr.text section
> > > vmlinux.o: warning: objtool: __ct_user_exit+0x3f: call to
> > > __kasan_check_write() leaves .noinstr.text section
> > >
> > > noinstr cannot have atomic_*() functions.because they have explicit
> > > instrumentation.Switch to arch_ prefixed atomic operation functions to
> > > avoid the explicit instrumentation.
> > >
> > > Reported-by: k2ci <kernel-bot@kylinos.cn>
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
> >
> > Apologies for the delay, but finally queued, thank you!  Frederic gave
> > his ack off-list, which I have included in the wordsmithed version below.
> > Could you please check to make sure that I did not mess anything up?
> >
> >                                                         Thanx, Paul
> >
> > ------------------------------------------------------------------------
> >
> > commit 936acd859f4a7b2b0f9900e26bc972385286df6e
> > Author: Genjian Zhang <zhanggenjian@kylinos.cn>
> > Date:   Thu Nov 10 16:24:43 2022 +0800
> >
> >     context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit
> >
> >     The following diagnostics are issued by objtool:
> >
> >     vmlinux.o: warning: objtool: __ct_user_enter+0x45: call to
> >     __kasan_check_write() leaves .noinstr.text section
> >     vmlinux.o: warning: objtool: __ct_user_exit+0x3f: call to
> >     __kasan_check_write() leaves .noinstr.text section
> >
> >     The reason for these diagnostics is that code marked noinstr if prohibited
> >     from using atomic_*() functions, which have explicit instrumentation.
> >     Therefore, switch to arch_ prefixed atomic operation functions to avoid
> >     the explicit instrumentation.
> >
> >     Reported-by: k2ci <kernel-bot@kylinos.cn>
> >     Reported-by: kernel test robot <lkp@intel.com>
> >     Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
> >     Acked-by: Frederic Weisbecker <frederic@kernel.org>
> >     Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> >
> > diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
> > index 77978e3723771..a09f1c19336ae 100644
> > --- a/kernel/context_tracking.c
> > +++ b/kernel/context_tracking.c
> > @@ -510,7 +510,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
> >                          * In this we case we don't care about any concurrency/ordering.
> >                          */
> >                         if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
> > -                               atomic_set(&ct->state, state);
> > +                               arch_atomic_set(&ct->state, state);
> >                 } else {
> >                         /*
> >                          * Even if context tracking is disabled on this CPU, because it's outside
> > @@ -527,7 +527,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
> >                          */
> >                         if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
> >                                 /* Tracking for vtime only, no concurrent RCU EQS accounting */
> > -                               atomic_set(&ct->state, state);
> > +                               arch_atomic_set(&ct->state, state);
> >                         } else {
> >                                 /*
> >                                  * Tracking for vtime and RCU EQS. Make sure we don't race
> > @@ -535,7 +535,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
> >                                  * RCU only requires RCU_DYNTICKS_IDX increments to be fully
> >                                  * ordered.
> >                                  */
> > -                               atomic_add(state, &ct->state);
> > +                               arch_atomic_add(state, &ct->state);
> >                         }
> >                 }
> >         }
> > @@ -630,12 +630,12 @@ void noinstr __ct_user_exit(enum ctx_state state)
> >                          * In this we case we don't care about any concurrency/ordering.
> >                          */
> >                         if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
> > -                               atomic_set(&ct->state, CONTEXT_KERNEL);
> > +                               arch_atomic_set(&ct->state, CONTEXT_KERNEL);
> >
> >                 } else {
> >                         if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
> >                                 /* Tracking for vtime only, no concurrent RCU EQS accounting */
> > -                               atomic_set(&ct->state, CONTEXT_KERNEL);
> > +                               arch_atomic_set(&ct->state, CONTEXT_KERNEL);
> >                         } else {
> >                                 /*
> >                                  * Tracking for vtime and RCU EQS. Make sure we don't race
> > @@ -643,7 +643,7 @@ void noinstr __ct_user_exit(enum ctx_state state)
> >                                  * RCU only requires RCU_DYNTICKS_IDX increments to be fully
> >                                  * ordered.
> >                                  */
> > -                               atomic_sub(state, &ct->state);
> > +                               arch_atomic_sub(state, &ct->state);
> >                         }
> >                 }
> >         }
> 
> Seems good to me.

Thank you for checking!

							Thanx, Paul

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

end of thread, other threads:[~2023-01-09 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10  8:24 [PATCH] context_tracking: Use arch_atomic_*() in __ct_user_enter and __ct_user_exit Genjian
2023-01-06 14:53 ` Paul E. McKenney
2023-01-09  7:13   ` genjian zhang
2023-01-09 15:10     ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.