From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Radoslaw Zielonek <radoslaw.zielonek@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com,
syzbot+a7d2b1d5d1af83035567@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com, vinicius.gomes@intel.com,
willemdebruijn.kernel@gmail.com
Subject: Re: [syzbot] [net?] INFO: rcu detected stall in packet_release
Date: Tue, 28 May 2024 15:55:26 +0300 [thread overview]
Message-ID: <20240528125526.qwskv756uya3zaqb@skbuf> (raw)
In-Reply-To: <20240528122610.21393-2-radoslaw.zielonek@gmail.com>
On Tue, May 28, 2024 at 02:25:58PM +0200, Radoslaw Zielonek wrote:
> Hello,
>
> I'm working on similar taprio bug:
> https://syzkaller.appspot.com/bug?extid=c4c6c3dc10cc96bcf723
Could you please let me know if the patches I posted yesterday fix that?
https://lore.kernel.org/netdev/20240527153955.553333-1-vladimir.oltean@nxp.com/
> I think I know what is the root cause.
>
> The function advance_sched()
> [https://elixir.bootlin.com/linux/v5.10.173/source/net/sched/sch_taprio.c#L696]
> runs repeatedly. It is executed using HRTimer.
> In every call to advance_sched(), end_time is calculated,
> and the timer is set so that the next execution will be at end_time.
> To achieve this, first, the expiration time is set using hrtimer_set_expires(),
> and second, HRTIMER_RESTART is returned.
> This means that the timer is re-enqueued with the adjusted expiration time.
> The issue is that end_time is set far before the current time (now),
> causing advance_sched() to execute immediately without a context switch.
>
> __hrtimer_run_queues()
> [https://elixir.bootlin.com/linux/v5.10.173/source/kernel/time/hrtimer.c#L1615]
> is a function with a long loop.
> First, please note that now is calculated once and not updated within this function.
> We can see the statement basenow = now + base->offset,
> but this statement is outside the loop (and in my case, the offset is 0).
> The loop will terminate when the queue is empty or the next entry in the queue
> has an expiration time in the future.
> The issue here is that the queue can be updated within __run_timer().
> In my case, __run_timer() adds a new entry to the queue with advance_sched() function.
> Since the expiration time is before now, we need to execute advance_sched() again.
> The loop is very long because, in our case, the cycle is set to 3ns.
In plain English, the root cause is "the schedule is too tight for the
CPU to keep up with it". Although a schedule with a 3 ns cycle time is
not practically valid in itself, either. Vinicius proposed we should
just reject the cycles that are unrealistically small, using some
simplistic heuristic about the transmission time of a single small
packet. The problem is that the rejection mechanism was slightly broken.
> My idea is to create throttling mechanism.
> When advance_sched() sets the hrtimer expiration time to before the current time
> for X consecutive times, we can postpone the new advance_sched().
> You can see my PoC here: https://lore.kernel.org/all/00000000000089...@google.com/T/
The link is not valid. Can you repost it without the "..."?
> Could you take a look at it? What do you think?
> Is it acceptable, or is it too aggressive with too much impact on the TAPRIO scheduler?
next prev parent reply other threads:[~2024-05-28 12:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 12:16 [syzbot] [net?] INFO: rcu detected stall in packet_release syzbot
2024-05-27 12:43 ` Eric Dumazet
2024-05-27 14:01 ` Vladimir Oltean
2024-05-28 12:25 ` Radoslaw Zielonek
2024-05-28 12:55 ` Vladimir Oltean [this message]
2024-05-28 13:03 ` Radoslaw Zielonek
2024-05-29 13:43 ` Vladimir Oltean
2024-05-29 22:52 ` Hillf Danton
2024-05-29 23:10 ` syzbot
2024-05-29 23:47 ` Hillf Danton
2024-05-30 0:33 ` Vladimir Oltean
2024-05-30 10:34 ` Hillf Danton
2024-05-30 11:19 ` syzbot
2024-05-30 11:57 ` Hillf Danton
2024-05-30 12:30 ` syzbot
2024-05-31 20:24 ` Hillf Danton
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=20240528125526.qwskv756uya3zaqb@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=radoslaw.zielonek@gmail.com \
--cc=syzbot+a7d2b1d5d1af83035567@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=vinicius.gomes@intel.com \
--cc=willemdebruijn.kernel@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