public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: GuangFei Luo <luogf2025@163.com>
To: rafael@kernel.org
Cc: michal.wilczynski@intel.com, dan.carpenter@linaro.org,
	lenb@kernel.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	lkp@intel.com, sre@kernel.org, stable@vger.kernel.org
Subject: Re:[PATCH v6] ACPI: battery: prevent sysfs_add_battery re-entry on rapid events
Date: Wed, 24 Sep 2025 00:18:33 +0800	[thread overview]
Message-ID: <20250923161833.1307303-1-luogf2025@163.com> (raw)
In-Reply-To: <20250910142653.313360-1-luogf2025@163.com>

Yes, in my tests with battery hot-plug, I observed that
acpi_battery_notify() can be triggered multiple times in quick
succession. Only adding a lock inside acpi_battery_notify()
is sufficient.

The functions battery_hook_add_battery(), battery_hook_remove_battery(),
and sysfs_remove_battery() already acquire locks, so their internal
accesses are safe.

acpi_battery_refresh() does check battery->bat, but its child
functions (sysfs_add_battery() and sysfs_remove_battery()) already
handle locking.

In acpi_battery_notify(), battery->bat has no lock. However, the
check of battery->bat is at the very end of the function. During
earlier calls, battery->bat has already been protected by locks, so
re-entry will not cause issues.


      parent reply	other threads:[~2025-09-23 16:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250910142653.313360-1-luogf2025@163.com>
2025-09-12 15:48 ` [PATCH v3] ACPI: battery: prevent sysfs_add_battery re-entry on rapid events GuangFei Luo
2025-09-12 15:57   ` Greg KH
2025-09-12 16:25     ` GuangFei Luo
2025-09-13  6:05       ` Greg KH
2025-09-13  7:19 ` [PATCH v4] " GuangFei Luo
2025-09-13  7:33   ` Greg KH
2025-09-13  7:56 ` [PATCH v5] " GuangFei Luo
2025-09-14 11:12 ` [PATCH v6] " GuangFei Luo
2025-09-23  2:38   ` GuangFei Luo
2025-09-23 11:48     ` Rafael J. Wysocki
2025-09-23 16:13       ` GuangFei Luo
2025-09-23 17:12         ` [PATCH " Rafael J. Wysocki
2025-09-23 19:10           ` Rafael J. Wysocki
2025-09-23 22:38             ` GuangFei Luo
2025-09-24 10:40               ` [PATCH " Rafael J. Wysocki
2025-09-24 14:10                 ` GuangFei Luo
2025-09-24 17:22                   ` [PATCH " Rafael J. Wysocki
2025-09-23 16:18 ` GuangFei Luo [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=20250923161833.1307303-1-luogf2025@163.com \
    --to=luogf2025@163.com \
    --cc=dan.carpenter@linaro.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=michal.wilczynski@intel.com \
    --cc=rafael@kernel.org \
    --cc=sre@kernel.org \
    --cc=stable@vger.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