mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joshua Crofts <crofts@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, Pavel Machek <pavel@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Johan Hovold <johan@kernel.org>,
	linux-pm@vger.kernel.org, driver-core@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	Dominik Brodowski <linux@dominikbrodowski.net>
Subject: Re: [PATCH 2/3] PM: add sysfs attributes for additional suspend/resume metrics
Date: Tue, 10 Nov 2026 19:50:20 +0100	[thread overview]
Message-ID: <20261110195020.7d07ae63@systembl0wer> (raw)
In-Reply-To: <2026111023-padlock-deluge-4173@gregkh>

On Tue, 10 Nov 2026 12:29:11 -0500
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

...

> > +static ssize_t runtime_resume_count_show(struct device *dev,
> > +					 struct device_attribute *attr,
> > +					 char *buf)
> > +{
> > +	u64 count;
> > +
> > +	spin_lock_irq(&dev->power.lock);
> > +	count = dev->power.resume_count;
> > +	spin_unlock_irq(&dev->power.lock);  
> 
> Why is a lock needed at all?  The value isn't going to "smear", it will
> change right after the lock anyway.

On 64-bit systems an aligned u64 read is atomic, but on 32-bit systems it
gets split into two 32-bit loads. Without locking, the read can tear
between the upper and lower halves.

> And if you need one, why not a guard()?

Yeah, I realized this after sending the series out, nevertheless
Sashiko flagged some other stuff so I thought I'd fixup in v2.

Thanks!

-- 
Kind regards,
Joshua Crofts

  reply	other threads:[~2026-11-10 18:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 10:43 [PATCH 0/3] PM: runtime: add new runtime metrics and summary Joshua Crofts
2026-11-10 10:43 ` [PATCH 1/3] PM: runtime: add additional suspend/resume metrics Joshua Crofts
2026-11-10 10:43 ` [PATCH 2/3] PM: add sysfs attributes for " Joshua Crofts
2026-11-10 17:29   ` Greg Kroah-Hartman
2026-11-10 18:50     ` Joshua Crofts [this message]
2026-11-10 18:54       ` Greg Kroah-Hartman
2026-11-10 18:58         ` Greg Kroah-Hartman
2026-11-10 19:02           ` Joshua Crofts
2026-11-10 10:43 ` [PATCH 3/3] PM: runtime: add debugfs entry for pm_runtime_summary Joshua Crofts

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=20261110195020.7d07ae63@systembl0wer \
    --to=crofts@kernel.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.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®