From: Peter Zijlstra <peterz@infradead.org>
To: xu.xin16@zte.com.cn
Cc: bsegall@google.com, dietmar.eggemann@arm.com, fan.yu9@zte.com.cn,
he.peilin@zte.com.cn, jiang.kun2@zte.com.cn,
juri.lelli@redhat.com, linux-kernel@vger.kernel.org,
liu.chun2@zte.com.cn, mgorman@suse.de, mingo@redhat.com,
rostedt@goodmis.org, tu.qiang35@zte.com.cn,
vincent.guittot@linaro.org, yang.yang29@zte.com.cn,
zhang.yunkai@zte.com.cn
Subject: Re: [PATCH linux-next v3 RESEND] sched/core: Add WARN_ON_ONCE() to check overflow for migrate_disable
Date: Tue, 16 Jul 2024 11:16:39 +0200 [thread overview]
Message-ID: <20240716091639.GB26750@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20240716104244764N2jD8gnBpnsLjCDnQGQ8c@zte.com.cn>
On Tue, Jul 16, 2024 at 10:42:44AM +0800, xu.xin16@zte.com.cn wrote:
> From: Peilin He <he.peilin@zte.com.cn>
>
> Background
> ==========
> When repeated migrate_disable() calls are made with missing the
> corresponding migrate_enable() calls, there is a risk of
> 'migration_disabled' going upper overflow because
> 'migration_disabled' is a type of unsigned short whose max value is
> 65535.
>
> In PREEMPT_RT kernel, if 'migration_disabled' goes upper overflow, it may
> make the migrate_disable() ineffective within local_lock_irqsave(). This
> is because, during the scheduling procedure, the value of
> 'migration_disabled' will be checked, which can trigger CPU migration.
> Consequently, the count of 'rcu_read_lock_nesting' may leak due to
> local_lock_irqsave() and local_unlock_irqrestore() occurring on different
> CPUs.
>
> Usecase
> ========
> For example, When I developed a driver, I encountered a warning like
> "WARNING: CPU: 4 PID: 260 at kernel/rcu/tree_plugin.h:315
> rcu_note_context_switch+0xa8/0x4e8" warning. It took me half a month
> to locate this issue. Ultimately, I discovered that the lack of upper
> overflow detection mechanism in migrate_disable() was the root cause,
> leading to a significant amount of time spent on problem localization.
>
> If the upper overflow detection mechanism was added to migrate_disable(),
> the root cause could be very quickly and easily identified.
>
> Effect
> ======
> Using WARN_ON_ONCE() to check if 'migration_disabled' is upper overflow
> can help developers identify the issue quickly.
>
> Signed-off-by: Peilin He<he.peilin@zte.com.cn>
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>
> Reviewed-by: Yunkai Zhang <zhang.yunkai@zte.com.cn>
> Reviewed-by: Qiang Tu <tu.qiang35@zte.com.cn>
> Reviewed-by: Kun Jiang <jiang.kun2@zte.com.cn>
> Reviewed-by: Fan Yu <fan.yu9@zte.com.cn>
> Cc: Yang Yang <yang.yang29@zte.com.cn>
> Cc: Liu Chun <liu.chun2@zte.com.cn>
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
Thanks, I'll queue this for sched/urgent once -rc1 rolls around.
next prev parent reply other threads:[~2024-07-16 9:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 2:42 xu.xin16
2024-07-16 9:16 ` Peter Zijlstra [this message]
2024-07-29 10:34 ` [tip: sched/core] sched/core: Add WARN_ON_ONCE() to check overflow for migrate_disable() tip-bot2 for Peilin He
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=20240716091639.GB26750@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=fan.yu9@zte.com.cn \
--cc=he.peilin@zte.com.cn \
--cc=jiang.kun2@zte.com.cn \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liu.chun2@zte.com.cn \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tu.qiang35@zte.com.cn \
--cc=vincent.guittot@linaro.org \
--cc=xu.xin16@zte.com.cn \
--cc=yang.yang29@zte.com.cn \
--cc=zhang.yunkai@zte.com.cn \
/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
all inboxes | Powered by JetHome®