* [raw v1 2/4] [NET] Use raw_cpu ops for SNMP stats
[not found] <20131007183226.334180014@linux.com>
@ 2013-10-07 18:31 ` Christoph Lameter
2013-10-08 7:21 ` Ingo Molnar
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Lameter @ 2013-10-07 18:31 UTC (permalink / raw)
To: Tejun Heo
Cc: akpm, Eric Dumazet, netdev, Steven Rostedt, linux-kernel,
Ingo Molnar, Peter Zijlstra, Thomas Gleixner
SNMP stats are not protected by preemption but by bh handling.
Since protection is provided outside of preemption raw_cpu_ops
need to be used to avoid false positives.
Cc: Eric Dumazet <edumazet@google.com>
CC: netdev@vger.kernel.org
Signed-off-by: Christoph Lameter <cl@linux.com>
Index: linux/include/net/snmp.h
===================================================================
--- linux.orig/include/net/snmp.h 2013-10-07 09:16:07.595206864 -0500
+++ linux/include/net/snmp.h 2013-10-07 09:16:07.591206909 -0500
@@ -126,7 +126,7 @@ struct linux_xfrm_mib {
extern __typeof__(type) __percpu *name[SNMP_ARRAY_SZ]
#define SNMP_INC_STATS_BH(mib, field) \
- __this_cpu_inc(mib[0]->mibs[field])
+ raw_cpu_inc(mib[0]->mibs[field])
#define SNMP_INC_STATS_USER(mib, field) \
this_cpu_inc(mib[0]->mibs[field])
@@ -141,7 +141,7 @@ struct linux_xfrm_mib {
this_cpu_dec(mib[0]->mibs[field])
#define SNMP_ADD_STATS_BH(mib, field, addend) \
- __this_cpu_add(mib[0]->mibs[field], addend)
+ raw_cpu_add(mib[0]->mibs[field], addend)
#define SNMP_ADD_STATS_USER(mib, field, addend) \
this_cpu_add(mib[0]->mibs[field], addend)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [raw v1 2/4] [NET] Use raw_cpu ops for SNMP stats
2013-10-07 18:31 ` [raw v1 2/4] [NET] Use raw_cpu ops for SNMP stats Christoph Lameter
@ 2013-10-08 7:21 ` Ingo Molnar
2013-10-08 10:21 ` Peter Zijlstra
0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2013-10-08 7:21 UTC (permalink / raw)
To: Christoph Lameter
Cc: Tejun Heo, akpm, Eric Dumazet, netdev, Steven Rostedt,
linux-kernel, Peter Zijlstra, Thomas Gleixner
* Christoph Lameter <cl@linux.com> wrote:
> SNMP stats are not protected by preemption but by bh handling.
Most forms of bh exclusion work via the preemption count though, and
softirq contexts themselves are generally not preemptible [to other CPUs]
either.
So the warnings should, in most cases, not trigger.
> Since protection is provided outside of preemption raw_cpu_ops
> need to be used to avoid false positives.
Could you quote the warning that pops up? It might be better to annotate
the specific safe usages than to potentially hide bugs:
> --- linux.orig/include/net/snmp.h 2013-10-07 09:16:07.595206864 -0500
> +++ linux/include/net/snmp.h 2013-10-07 09:16:07.591206909 -0500
> @@ -126,7 +126,7 @@ struct linux_xfrm_mib {
> extern __typeof__(type) __percpu *name[SNMP_ARRAY_SZ]
>
> #define SNMP_INC_STATS_BH(mib, field) \
> - __this_cpu_inc(mib[0]->mibs[field])
> + raw_cpu_inc(mib[0]->mibs[field])
>
> #define SNMP_INC_STATS_USER(mib, field) \
> this_cpu_inc(mib[0]->mibs[field])
> @@ -141,7 +141,7 @@ struct linux_xfrm_mib {
> this_cpu_dec(mib[0]->mibs[field])
>
> #define SNMP_ADD_STATS_BH(mib, field, addend) \
> - __this_cpu_add(mib[0]->mibs[field], addend)
> + raw_cpu_add(mib[0]->mibs[field], addend)
>
> #define SNMP_ADD_STATS_USER(mib, field, addend) \
> this_cpu_add(mib[0]->mibs[field], addend)
Doing this will hide any true bugs if any of these primitives is used in
an unsafe context.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [raw v1 2/4] [NET] Use raw_cpu ops for SNMP stats
2013-10-08 7:21 ` Ingo Molnar
@ 2013-10-08 10:21 ` Peter Zijlstra
2013-10-08 10:26 ` Ingo Molnar
0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2013-10-08 10:21 UTC (permalink / raw)
To: Ingo Molnar
Cc: Christoph Lameter, Tejun Heo, akpm, Eric Dumazet, netdev,
Steven Rostedt, linux-kernel, Thomas Gleixner
On Tue, Oct 08, 2013 at 09:21:14AM +0200, Ingo Molnar wrote:
>
> * Christoph Lameter <cl@linux.com> wrote:
>
> > SNMP stats are not protected by preemption but by bh handling.
>
> Most forms of bh exclusion work via the preemption count though, and
> softirq contexts themselves are generally not preemptible [to other CPUs]
> either.
>
> So the warnings should, in most cases, not trigger.
Right, so softirqs run either in the irq tail at which point
preempt_count += SOFTIRQ_OFFSET and thus preemption is disabled, or it
runs in ksoftirqd which has strict cpu affinity which also disables the
warning, and it also increments preempt_count with SOFTIRQ_OFFSET to
exclude the softirq from interrupts while its running, also disabling
the warning.
So it should very much not trigger.. if it does you want to know about
it.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [raw v1 2/4] [NET] Use raw_cpu ops for SNMP stats
2013-10-08 10:21 ` Peter Zijlstra
@ 2013-10-08 10:26 ` Ingo Molnar
0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2013-10-08 10:26 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Christoph Lameter, Tejun Heo, akpm, Eric Dumazet, netdev,
Steven Rostedt, linux-kernel, Thomas Gleixner
* Peter Zijlstra <peterz@infradead.org> wrote:
> On Tue, Oct 08, 2013 at 09:21:14AM +0200, Ingo Molnar wrote:
> >
> > * Christoph Lameter <cl@linux.com> wrote:
> >
> > > SNMP stats are not protected by preemption but by bh handling.
> >
> > Most forms of bh exclusion work via the preemption count though, and
> > softirq contexts themselves are generally not preemptible [to other CPUs]
> > either.
> >
> > So the warnings should, in most cases, not trigger.
>
> Right, so softirqs run either in the irq tail at which point
> preempt_count += SOFTIRQ_OFFSET and thus preemption is disabled, or it
> runs in ksoftirqd which has strict cpu affinity which also disables the
> warning, and it also increments preempt_count with SOFTIRQ_OFFSET to
> exclude the softirq from interrupts while its running, also disabling
> the warning.
A third context would be syscall-level code that runs with
local_bh_disable()/enable() - but that too ought to have the preempt count
elevated.
> So it should very much not trigger.. if it does you want to know about
> it.
Yes. If nothing else then for the education value.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-10-08 10:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20131007183226.334180014@linux.com>
2013-10-07 18:31 ` [raw v1 2/4] [NET] Use raw_cpu ops for SNMP stats Christoph Lameter
2013-10-08 7:21 ` Ingo Molnar
2013-10-08 10:21 ` Peter Zijlstra
2013-10-08 10:26 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).