Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1270486 > unrolled thread

Re: [PATCH v2] ip_tunnel: disable preemption when updating per-cpu tstats

Started byDavid Miller <davem@davemloft.net>
First post2015-11-16 20:20 +0100
Last post2015-11-16 20:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2] ip_tunnel: disable preemption when updating per-cpu  tstats David Miller <davem@davemloft.net> - 2015-11-16 20:20 +0100
    Re: [PATCH v2] ip_tunnel: disable preemption when updating per-cpu tstats "Jason A. Donenfeld" <Jason@zx2c4.com> - 2015-11-16 20:40 +0100

#1270486 — Re: [PATCH v2] ip_tunnel: disable preemption when updating per-cpu tstats

FromDavid Miller <davem@davemloft.net>
Date2015-11-16 20:20 +0100
SubjectRe: [PATCH v2] ip_tunnel: disable preemption when updating per-cpu tstats
Message-ID<qvxtL-2U5-15@gated-at.bofh.it>
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Thu, 12 Nov 2015 17:35:58 +0100

> Drivers like vxlan use the recently introduced
> udp_tunnel_xmit_skb/udp_tunnel6_xmit_skb APIs. udp_tunnel6_xmit_skb
> makes use of ip6tunnel_xmit, and ip6tunnel_xmit, after sending the
> packet, updates the struct stats using the usual
> u64_stats_update_begin/end calls on this_cpu_ptr(dev->tstats).
> udp_tunnel_xmit_skb makes use of iptunnel_xmit, which doesn't touch
> tstats, so drivers like vxlan, immediately after, call
> iptunnel_xmit_stats, which does the same thing - calls
> u64_stats_update_begin/end on this_cpu_ptr(dev->tstats).
> 
> While vxlan is probably fine (I don't know?), calling a similar function
> from, say, an unbound workqueue, on a fully preemptable kernel causes
> real issues:
> 
> [  188.434537] BUG: using smp_processor_id() in preemptible [00000000] code: kworker/u8:0/6
> [  188.435579] caller is debug_smp_processor_id+0x17/0x20
> [  188.435583] CPU: 0 PID: 6 Comm: kworker/u8:0 Not tainted 4.2.6 #2
> [  188.435607] Call Trace:
> [  188.435611]  [<ffffffff8234e936>] dump_stack+0x4f/0x7b
> [  188.435615]  [<ffffffff81915f3d>] check_preemption_disabled+0x19d/0x1c0
> [  188.435619]  [<ffffffff81915f77>] debug_smp_processor_id+0x17/0x20
> 
> The solution would be to protect the whole
> this_cpu_ptr(dev->tstats)/u64_stats_update_begin/end blocks with
> disabling preemption and then reenabling it.
> 
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

Applied and queued up for -stable, thanks Jason

Arguably, ip6tunnel_xmit() is primarily a ->ndo_start_xmit() and
therefore could assume that it only ran inside of a BH disabled code
sequence.  And as you noted, when this was turned into a general case
helper function that guarantee was no longer necessarily there.

So another fix could have been to do local_bh_disable() in the
udp_tunnel6_xmit_skb() helper.

Thanks again.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1270514 — Re: [PATCH v2] ip_tunnel: disable preemption when updating per-cpu tstats

From"Jason A. Donenfeld" <Jason@zx2c4.com>
Date2015-11-16 20:40 +0100
SubjectRe: [PATCH v2] ip_tunnel: disable preemption when updating per-cpu tstats
Message-ID<qvxN8-33j-23@gated-at.bofh.it>
In reply to#1270486
On Mon, Nov 16, 2015 at 8:17 PM, David Miller <davem@davemloft.net> wrote:
> So another fix could have been to do local_bh_disable() in the
> udp_tunnel6_xmit_skb() helper.

This would have fixed one problem, but everywhere
udp_tunnel_xmit_skb() (4, not 6) is called, iptunnel_xmit_stats is
called right after it, so there would have to be a modicum of patches
for all of these places too.

By the way, there's something else I noticed about this in dealing
with these functions: the return value of udp_tunnel_xmit_skb is
different from that of udp_tunnel6_xmit_skb. Nobody is using them
incorrectly, so far as I can see, but it is confusing that they return
different things. I had started to clean this up and send a patch, but
it got a bit invasive in drivers I shouldn't really touch. But if
somebody with a bit more top-down command of things wants to poke at
this, it's a low hanging fruit as far as I can see.

>
> Thanks again.

My pleasure.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web