mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zhang, Rui" <rui.zhang@intel.com>
To: "Torvalds, Linus" <torvalds@linux-foundation.org>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>
Cc: "Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [BUG v6.3-rc4+] WARNING: CPU: 0 PID: 1 at drivers/thermal/thermal_sysfs.c:879 cooling_device_stats_setup+0xac/0xc0
Date: Thu, 30 Mar 2023 09:57:26 +0000	[thread overview]
Message-ID: <22cab1d16c75cf07e0846a136c355615bc9b05dd.camel@intel.com> (raw)
In-Reply-To: <CAHk-=wiEdcjdceNdfVGPEcbSmAKh_rjtBSy5_Z3Yyx2GFEgLFA@mail.gmail.com>

Hi, Linus,

On Wed, 2023-03-29 at 15:52 -0700, Linus Torvalds wrote:
> On Wed, Mar 29, 2023 at 1:58 PM Steven Rostedt <rostedt@goodmis.org>
> wrote:
> > In preparation to adding my patch that checks for some kinds of
> > bugs in
> > trace events, I decided to run it on the Linus's latest branch, to
> > see if
> > there's any other trace events that may cause issues. But instead I
> > hit
> > this unrelated bug. Looks to be triggering an added
> > lockdep_assert() on
> > boot up.
> 
> So I think that lockdep assert is likely bogus.
> 
> It was added in commit 790930f44289 ("thermal: core: Introduce
> thermal_cooling_device_update()") but the reason I say it's bogus is
> that I don't think it has ever been tested:
> 
> > static void cooling_device_stats_setup(struct
> > thermal_cooling_device *cdev)
> > {
> >         lockdep_assert_held(&cdev->lock); <<<---- line 879
> 
> Yeah, so cooling_device_stats_setup() is called from two places:
> 
>  - thermal_cooling_device_setup_sysfs()
> 
>  - thermal_cooling_device_stats_reinit()
> 
> and that first place is when that cdev is created, before it's
> registered anywhere. It's not locked in that case, and yes, the
> lockdep_assert_held() will trigger.
> 
> As far as I can tell it will always trigger, and this
> lockdep_assert()
> has thus never been tested with lockdep enabled.
> 
> The "stats_reinit" case seems to also be called from only one place
> (thermal_cooling_device_update()), and that path does indeed hold the
> cdev->lock.
> 
> That lockdep could be made happy by having
> thermal_cooling_device_setup_sysfs() create that device with the cdev
> lock held. I guess that's easy enough, although somewhat annoyingly
> there is no "mutex_init_locked()", you have to actually do
> "mutex_init()" followed by a "mutex_lock()". And obviously unlock it
> after doing the setup_sysfs().
> 
> But I question whether the lockdep test should be done at all. I find
> it distasteful that it was added with absolutely zero testing.
> 
> 
I just realized why I cannot reproduce this problem on my testbox.

In order to test the original patch with ACPI passive cooling enabled,
I rebuild the kernel with customized DSDT.
This taints the kernel, and clears the debug_locks, thus I didn't get
any lockdep warnings...

thanks,
rui

  reply	other threads:[~2023-03-30  9:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 20:58 Steven Rostedt
2023-03-29 20:59 ` Steven Rostedt
2023-03-29 21:31   ` Steven Rostedt
2023-03-29 22:52 ` Linus Torvalds
2023-03-30  9:57   ` Zhang, Rui [this message]
2023-03-30 19:08     ` Wysocki, Rafael J

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=22cab1d16c75cf07e0846a136c355615bc9b05dd.camel@intel.com \
    --to=rui.zhang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    /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®