linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: syzbot <syzbot+0251e883fe39e7a0cb0a@syzkaller.appspotmail.com>,
	"David Miller" <davem@davemloft.net>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jamal Hadi Salim" <jhs@mojatatu.com>,
	"Jiří Pírko" <jiri@resnulli.us>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	kvalo@codeaurora.org, leon@kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	linux-kselftest@vger.kernel.org, Netdev <netdev@vger.kernel.org>,
	"Shuah Khan" <shuah@kernel.org>,
	syzkaller-bugs@googlegroups.com,
	"Thomas Gleixner" <tglx@linutronix.de>,
	vivien.didelot@gmail.com, "Cong Wang" <xiyou.wangcong@gmail.com>
Subject: Re: INFO: rcu detected stall in wg_packet_tx_worker
Date: Mon, 4 May 2020 05:23:17 -0600	[thread overview]
Message-ID: <CAHmME9ocB-LUYwJTxsqui1Bh+cbKixEP-sayVNa9puY25hEASA@mail.gmail.com> (raw)
In-Reply-To: <85e76f66-f807-ad12-df9d-0805b68133fa@gmail.com>

So in spite of this Syzkaller bug being unrelated in the end, I've
continued to think about the stacktrace a bit, and combined with some
other [potentially false alarm] bug reports I'm trying to wrap my head
around, I'm a bit a curious about ideal usage for the udp_tunnel API.

All the uses I've seen in the kernel (including wireguard) follow this pattern:

rcu_read_lock_bh();
sock = rcu_dereference(obj->sock);
...
udp_tunnel_xmit_skb(..., sock, ...);
rcu_read_unlock_bh();

udp_tunnel_xmit_skb calls iptunnel_xmit, which winds up in the usual
ip_local_out path, which eventually winds up calling some other
devices' ndo_xmit, or gets queued up in a qdisc. Calls to
udp_tunnel_xmit_skb aren't exactly cheap. So I wonder: is holding the
rcu lock for all that time really a good thing?

A different pattern that avoids holding the rcu lock would be:

rcu_read_lock_bh();
sock = rcu_dereference(obj->sock);
sock_hold(sock);
rcu_read_unlock_bh();
...
udp_tunnel_xmit_skb(..., sock, ...);
sock_put(sock);

This seems better, but I wonder if it has some drawbacks too. For
example, sock_put has some comment that warns against incrementing it
in response to forwarded packets. And if this isn't necessary to do,
it's marginally more costly than the first pattern.

Any opinions about this?

Jason

      reply	other threads:[~2020-05-04 11:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <00000000000005d1ab05a4351006@google.com>
2020-04-26 17:57 ` INFO: rcu detected stall in wg_packet_tx_worker syzbot
2020-04-26 19:40   ` Eric Dumazet
2020-04-26 19:42     ` Jason A. Donenfeld
2020-04-26 19:52       ` Jason A. Donenfeld
2020-04-26 19:58         ` Jason A. Donenfeld
2020-04-26 20:26       ` Eric Dumazet
2020-04-26 20:38         ` Eric Dumazet
2020-04-26 20:46           ` Jason A. Donenfeld
2020-04-26 21:53             ` Eric Dumazet
2020-05-04 11:23               ` Jason A. Donenfeld [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHmME9ocB-LUYwJTxsqui1Bh+cbKixEP-sayVNa9puY25hEASA@mail.gmail.com \
    --to=jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=krzk@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=syzbot+0251e883fe39e7a0cb0a@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tglx@linutronix.de \
    --cc=vivien.didelot@gmail.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).