Re: seqcount usage in xt_replace_table()

2019-01-11 Thread Paul E. McKenney
On Fri, Jan 11, 2019 at 09:34:11AM +0100, Peter Zijlstra wrote: > On Thu, Jan 10, 2019 at 11:29:20PM +0100, Florian Westphal wrote: > > Peter Zijlstra wrote: > > > Would using synchronize_rcu() not also mean you can get rid of that > > > xt_write_recseq*() stuff entirely? > > > > No, because

Re: seqcount usage in xt_replace_table()

2019-01-11 Thread Peter Zijlstra
On Thu, Jan 10, 2019 at 11:29:20PM +0100, Florian Westphal wrote: > Peter Zijlstra wrote: > > Would using synchronize_rcu() not also mean you can get rid of that > > xt_write_recseq*() stuff entirely? > > No, because those are used to synchronize with cpus that read > the ruleset counters, see >

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Florian Westphal
Peter Zijlstra wrote: > Would using synchronize_rcu() not also mean you can get rid of that > xt_write_recseq*() stuff entirely? No, because those are used to synchronize with cpus that read the ruleset counters, see net/ipv4/netfilter/ip_tables.c:get_counters(). > Anyway, synchronize_rcu()

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Peter Zijlstra
On Thu, Jan 10, 2019 at 03:48:12PM +0100, Florian Westphal wrote: > Peter Zijlstra wrote: > > Is performance a concern in this path? There is no comment justifying > > this 'creative' stuff. > > We have to wait until all cpus are done with current iptables ruleset. > > Before this 'creative'

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Peter Zijlstra
On Thu, Jan 10, 2019 at 03:48:12PM +0100, Florian Westphal wrote: > Peter Zijlstra wrote: > > /* > > * Ensure contents of newinfo are visible before assigning to > > * private. > > */ > > smp_wmb(); > > table->private = newinfo; > > > > we have: > > > >

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Peter Zijlstra
On Thu, Jan 10, 2019 at 01:53:28PM +0100, Dmitry Vyukov wrote: > On Thu, Jan 10, 2019 at 1:41 PM Peter Zijlstra wrote: > > > > On Tue, Jan 08, 2019 at 11:37:46PM +0100, Florian Westphal wrote: > > > Anatol Pomozov wrote: > > > > Or maybe xt_replace_table() can be enhanced? When I hear that > > >

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Paul E. McKenney
On Thu, Jan 10, 2019 at 01:41:23PM +0100, Peter Zijlstra wrote: > On Tue, Jan 08, 2019 at 11:37:46PM +0100, Florian Westphal wrote: > > Anatol Pomozov wrote: > > > Or maybe xt_replace_table() can be enhanced? When I hear that > > > something waits until an event happens on all CPUs I think about

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Paul E. McKenney
On Thu, Jan 10, 2019 at 01:38:11PM +0100, Dmitry Vyukov wrote: > On Thu, Jan 10, 2019 at 1:30 PM Andrea Parri > wrote: > > > > > For seqcounts we currently simply ignore all accesses within the read > > > section (thus the requirement to dynamically track read sections). > > > What does LKMM say

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Florian Westphal
Peter Zijlstra wrote: > /* >* Ensure contents of newinfo are visible before assigning to >* private. >*/ > smp_wmb(); > table->private = newinfo; > > we have: > > smp_store_release(>private, newinfo); > > But what store does that second smp_wmb()

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Dmitry Vyukov
On Thu, Jan 10, 2019 at 1:47 PM Andrea Parri wrote: > > On Thu, Jan 10, 2019 at 01:38:11PM +0100, Dmitry Vyukov wrote: > > On Thu, Jan 10, 2019 at 1:30 PM Andrea Parri > > wrote: > > > > > > > For seqcounts we currently simply ignore all accesses within the read > > > > section (thus the

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Dmitry Vyukov
On Thu, Jan 10, 2019 at 1:44 PM Peter Zijlstra wrote: > > On Tue, Jan 08, 2019 at 11:33:39AM -0800, Anatol Pomozov wrote: > > Hello folks, > > > > A bit of context what I am doing. I am trying to port KTSAN (Kernel > > Thread Sanitizer) tool to v4.20. That tool tracks shared data usage > > and

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Dmitry Vyukov
On Thu, Jan 10, 2019 at 1:41 PM Peter Zijlstra wrote: > > On Tue, Jan 08, 2019 at 11:37:46PM +0100, Florian Westphal wrote: > > Anatol Pomozov wrote: > > > Or maybe xt_replace_table() can be enhanced? When I hear that > > > something waits until an event happens on all CPUs I think about > > >

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Andrea Parri
On Thu, Jan 10, 2019 at 01:38:11PM +0100, Dmitry Vyukov wrote: > On Thu, Jan 10, 2019 at 1:30 PM Andrea Parri > wrote: > > > > > For seqcounts we currently simply ignore all accesses within the read > > > section (thus the requirement to dynamically track read sections). > > > What does LKMM say

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Peter Zijlstra
On Tue, Jan 08, 2019 at 11:33:39AM -0800, Anatol Pomozov wrote: > Hello folks, > > A bit of context what I am doing. I am trying to port KTSAN (Kernel > Thread Sanitizer) tool to v4.20. That tool tracks shared data usage > and makes sure it is accessed in a thread-safe manner. > > seqlock is a

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Peter Zijlstra
On Tue, Jan 08, 2019 at 11:37:46PM +0100, Florian Westphal wrote: > Anatol Pomozov wrote: > > Or maybe xt_replace_table() can be enhanced? When I hear that > > something waits until an event happens on all CPUs I think about > > wait_event() function. Would it be better for xt_replace_table() to

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Dmitry Vyukov
On Thu, Jan 10, 2019 at 1:30 PM Andrea Parri wrote: > > > For seqcounts we currently simply ignore all accesses within the read > > section (thus the requirement to dynamically track read sections). > > What does LKMM say about seqlocks? > > LKMM does not currently model seqlocks, if that's what

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Andrea Parri
> For seqcounts we currently simply ignore all accesses within the read > section (thus the requirement to dynamically track read sections). > What does LKMM say about seqlocks? LKMM does not currently model seqlocks, if that's what you're asking; c.f., tools/memory-model/linux-kernel.def for a

Re: seqcount usage in xt_replace_table()

2019-01-10 Thread Dmitry Vyukov
On Wed, Jan 9, 2019 at 6:11 PM Paul E. McKenney wrote: > > On Wed, Jan 09, 2019 at 01:29:02PM +0100, Dmitry Vyukov wrote: > > On Wed, Jan 9, 2019 at 1:11 PM Andrea Parri > > wrote: > > > > > > On Wed, Jan 09, 2019 at 12:55:27PM +0100, Dmitry Vyukov wrote: > > > > On Wed, Jan 9, 2019 at 12:24 PM

Re: seqcount usage in xt_replace_table()

2019-01-09 Thread Paul E. McKenney
On Wed, Jan 09, 2019 at 01:29:02PM +0100, Dmitry Vyukov wrote: > On Wed, Jan 9, 2019 at 1:11 PM Andrea Parri > wrote: > > > > On Wed, Jan 09, 2019 at 12:55:27PM +0100, Dmitry Vyukov wrote: > > > On Wed, Jan 9, 2019 at 12:24 PM Andrea Parri > > > wrote: > > > > > > > > On Tue, Jan 08, 2019 at

Re: seqcount usage in xt_replace_table()

2019-01-09 Thread Dmitry Vyukov
On Wed, Jan 9, 2019 at 1:11 PM Andrea Parri wrote: > > On Wed, Jan 09, 2019 at 12:55:27PM +0100, Dmitry Vyukov wrote: > > On Wed, Jan 9, 2019 at 12:24 PM Andrea Parri > > wrote: > > > > > > On Tue, Jan 08, 2019 at 04:36:46PM -0800, Anatol Pomozov wrote: > > > > Hello > > > > > > > > On Tue, Jan

Re: seqcount usage in xt_replace_table()

2019-01-09 Thread Andrea Parri
On Wed, Jan 09, 2019 at 12:55:27PM +0100, Dmitry Vyukov wrote: > On Wed, Jan 9, 2019 at 12:24 PM Andrea Parri > wrote: > > > > On Tue, Jan 08, 2019 at 04:36:46PM -0800, Anatol Pomozov wrote: > > > Hello > > > > > > On Tue, Jan 8, 2019 at 4:02 PM Andrea Parri > > > wrote: > > > > > > > > Hi

Re: seqcount usage in xt_replace_table()

2019-01-09 Thread Dmitry Vyukov
On Wed, Jan 9, 2019 at 12:24 PM Andrea Parri wrote: > > On Tue, Jan 08, 2019 at 04:36:46PM -0800, Anatol Pomozov wrote: > > Hello > > > > On Tue, Jan 8, 2019 at 4:02 PM Andrea Parri > > wrote: > > > > > > Hi Anatol, > > > > > > On Tue, Jan 08, 2019 at 11:33:39AM -0800, Anatol Pomozov wrote: > >

Re: seqcount usage in xt_replace_table()

2019-01-09 Thread Andrea Parri
On Tue, Jan 08, 2019 at 04:36:46PM -0800, Anatol Pomozov wrote: > Hello > > On Tue, Jan 8, 2019 at 4:02 PM Andrea Parri > wrote: > > > > Hi Anatol, > > > > On Tue, Jan 08, 2019 at 11:33:39AM -0800, Anatol Pomozov wrote: > > > Hello folks, > > > > > > A bit of context what I am doing. I am trying

Re: seqcount usage in xt_replace_table()

2019-01-08 Thread Dmitry Vyukov
On Wed, Jan 9, 2019 at 1:36 AM Anatol Pomozov wrote: > > Hello > > On Tue, Jan 8, 2019 at 4:02 PM Andrea Parri > wrote: > > > > Hi Anatol, > > > > On Tue, Jan 08, 2019 at 11:33:39AM -0800, Anatol Pomozov wrote: > > > Hello folks, > > > > > > A bit of context what I am doing. I am trying to port

Re: seqcount usage in xt_replace_table()

2019-01-08 Thread Anatol Pomozov
Hello On Tue, Jan 8, 2019 at 4:02 PM Andrea Parri wrote: > > Hi Anatol, > > On Tue, Jan 08, 2019 at 11:33:39AM -0800, Anatol Pomozov wrote: > > Hello folks, > > > > A bit of context what I am doing. I am trying to port KTSAN (Kernel > > Thread Sanitizer) tool to v4.20. That tool tracks shared

Re: seqcount usage in xt_replace_table()

2019-01-08 Thread Andrea Parri
Hi Anatol, On Tue, Jan 08, 2019 at 11:33:39AM -0800, Anatol Pomozov wrote: > Hello folks, > > A bit of context what I am doing. I am trying to port KTSAN (Kernel > Thread Sanitizer) tool to v4.20. That tool tracks shared data usage > and makes sure it is accessed in a thread-safe manner.

Re: seqcount usage in xt_replace_table()

2019-01-08 Thread Florian Westphal
Anatol Pomozov wrote: > Or maybe xt_replace_table() can be enhanced? When I hear that > something waits until an event happens on all CPUs I think about > wait_event() function. Would it be better for xt_replace_table() to > introduce an atomic counter that is decremented by CPUs, and the main >

seqcount usage in xt_replace_table()

2019-01-08 Thread Anatol Pomozov
Hello folks, A bit of context what I am doing. I am trying to port KTSAN (Kernel Thread Sanitizer) tool to v4.20. That tool tracks shared data usage and makes sure it is accessed in a thread-safe manner. seqlock is a synchronization primitive used by Linux kernel. KTSAN annotates