mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* seqlock:do_raw_write_seqcount_end smp_wmb
@ 2023-08-24  1:07 Kassey Li
  2023-08-24  6:13 ` Pavan Kondeti
  0 siblings, 1 reply; 2+ messages in thread
From: Kassey Li @ 2023-08-24  1:07 UTC (permalink / raw)
  To: Peter Zijlstra, mingo, will, boqun.feng, LKML

hi, Peter:
	I not quit sure on this, but is that a type error in 
do_raw_write_seqcount_end here  ?
is this change necessary to match with do_raw_write_seqcount_begin ?
		
	
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 987a59d977c5..eb8807ed3a00 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -486,8 +486,8 @@ do { 
                        \

  static inline void do_raw_write_seqcount_end(seqcount_t *s)
  {
-       smp_wmb();
         s->sequence++;
+       smp_wmb();
         kcsan_nestable_atomic_end();
  }


to match with

static inline void do_raw_write_seqcount_begin(seqcount_t *s)
{
	kcsan_nestable_atomic_begin();
	s->sequence++;
	smp_wmb();
}



BR
TNT


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

* Re: seqlock:do_raw_write_seqcount_end smp_wmb
  2023-08-24  1:07 seqlock:do_raw_write_seqcount_end smp_wmb Kassey Li
@ 2023-08-24  6:13 ` Pavan Kondeti
  0 siblings, 0 replies; 2+ messages in thread
From: Pavan Kondeti @ 2023-08-24  6:13 UTC (permalink / raw)
  To: Kassey Li; +Cc: Peter Zijlstra, mingo, will, boqun.feng, LKML

On Thu, Aug 24, 2023 at 09:07:57AM +0800, Kassey Li wrote:
> hi, Peter:
> 	I not quit sure on this, but is that a type error in
> do_raw_write_seqcount_end here  ?
> is this change necessary to match with do_raw_write_seqcount_begin ?
> 		
> 	
> diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
> index 987a59d977c5..eb8807ed3a00 100644
> --- a/include/linux/seqlock.h
> +++ b/include/linux/seqlock.h
> @@ -486,8 +486,8 @@ do {                        \
> 
>  static inline void do_raw_write_seqcount_end(seqcount_t *s)
>  {
> -       smp_wmb();
>         s->sequence++;
> +       smp_wmb();
>         kcsan_nestable_atomic_end();
>  }
> 
> 
> to match with
> 
> static inline void do_raw_write_seqcount_begin(seqcount_t *s)
> {
> 	kcsan_nestable_atomic_begin();
> 	s->sequence++;
> 	smp_wmb();
> }
> 
> 
> 

I don't see anything wrong here. As per my understanding,
do_raw_write_seqcount_end() marks the end of the writer side critical
section. The data modified in the critical section should be visisble to
the *reader* before seqcount::sequence increment is visible. The 
smp_wmb() here pairs with the smp_rmb() in the read_seqcount_begin().
Pls see kernel/sched/cputime.c for an example.

Thanks,
Pavan

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

end of thread, other threads:[~2023-08-24  6:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-24  1:07 seqlock:do_raw_write_seqcount_end smp_wmb Kassey Li
2023-08-24  6:13 ` Pavan Kondeti

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

all inboxes | Powered by JetHome®