mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: ivecera@redhat.com
Cc: netdev@vger.kernel.org, vadim.fedorenko@linux.dev,
	arkadiusz.kubalewski@intel.com, jiri@resnulli.us, corbet@lwn.net,
	skhan@linuxfoundation.org, rdunlap@infradead.org,
	min.li@microchip.com, anthony.l.nguyen@intel.com,
	przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, richardcochran@gmail.com,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org, grzegorz.nitka@intel.com,
	karol.kolacinski@intel.com, saeedm@nvidia.com, tariqt@nvidia.com,
	poros@redhat.com
Subject: Re: [PATCH net-next 05/10] dpll: convert dpll_lock to rwsem
Date: Tue, 10 Nov 2026 17:53:24 +0000	[thread overview]
Message-ID: <179433320479.994134.13826920591104367019@kernel.org> (raw)
In-Reply-To: <20261106121005.1327603-6-ivecera@redhat.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] This patch turns dpll_lock from a mutex into an rwsem.

--

dpll: convert dpll_lock to rwsem

This commit converts dpll_lock from a mutex to an rwsem. Core functions
that change the topology take it for write. Netlink requests, dump parts
and change notifications take it for read, so callbacks of different
domains can run concurrently.

> diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
> index dd09f52817099..8eb7468234315 100644
> --- a/drivers/dpll/dpll_core.c
> +++ b/drivers/dpll/dpll_core.c
> @@ -19,8 +19,12 @@
>  #include "dpll_core.h"
>  #include "dpll_netlink.h"
>  
> -/* Mutex lock to protect DPLL subsystem devices and pins */
> -DEFINE_MUTEX(dpll_lock);
> +/* Protects the topology and lifetime of DPLL devices and pins. Taken for write
> + * to change them and for read for the whole netlink request, part of a dump or
> + * change notification that uses them. Driver callbacks are serialized by domain
> + * locks, which are only taken under this lock.
> + */
> +DECLARE_RWSEM(dpll_lock);

[Severity: Low]
Should the assertions in dpll_domain_get() and dpll_domain_put() be changed
to lockdep_assert_held_write() along with this conversion?

Both helpers still use the plain form:

drivers/dpll/dpll_core.c:dpll_domain_get() {
	lockdep_assert_held(&dpll_lock);

	xa_for_each(&dpll_domain_xa, i, domain) {
		if (domain->clock_id == clock_id && domain->module == module) {
			refcount_inc(&domain->refcount);
			return domain;
		}
	}
	...
	ret = xa_alloc(&dpll_domain_xa, &domain->id, domain, xa_limit_32b,
		       GFP_KERNEL);
	...
}

drivers/dpll/dpll_core.c:dpll_domain_put() {
	lockdep_assert_held(&dpll_lock);

	if (refcount_dec_and_test(&domain->refcount)) {
		xa_erase(&dpll_domain_xa, domain->id);
		mutex_destroy(&domain->lock);
		kfree(domain);
	}
}

On the old mutex, lockdep_assert_held() checked for exclusive ownership. On
an rwsem it also passes when only the read lock is held.

Every current caller holds dpll_lock for write: dpll_device_get() and
dpll_pin_get() via the alloc helpers, and dpll_device_put(), dpll_pin_put()
and the register/unregister paths via the __put helpers. So this is not a
runtime problem today.

However, the read-side holders added here (dpll_pre_doit(),
dpll_pin_pre_doit(), the dumpits, dpll_device_change_ntf() and
dpll_pin_change_ntf()) can now run concurrently. If one of them reached a
domain lookup-or-create, or a final put, lockdep would no longer warn about
the race on dpll_domain_xa or on the domain refcount.

call_dpll_notifiers() can keep the plain lockdep_assert_held(), because it
legitimately runs under the read lock.

These assertions are still unchanged at the end of the series.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261106121005.1327603-1-ivecera%40redhat.com

  parent reply	other threads:[~2026-11-10 17:53 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 12:09 [PATCH net-next 00/10] dpll: do not serialize driver callbacks under global dpll_lock Ivan Vecera
2026-11-06 12:09 ` [PATCH net-next 01/10] ice: dpll: notify TSPLL lock status from the periodic work only Ivan Vecera
2026-11-10 12:20   ` Petr Oros
2026-11-10 17:53   ` netdev-bot+sashiko
2026-11-06 12:09 ` [PATCH net-next 02/10] ice: dpll: serialize changes of the SyncE CGU registers Ivan Vecera
2026-11-10 17:53   ` netdev-bot+sashiko
2026-11-06 12:09 ` [PATCH net-next 03/10] dpll: add domain object Ivan Vecera
2026-11-10 12:23   ` Petr Oros
2026-11-10 17:53   ` netdev-bot+sashiko
2026-11-06 12:09 ` [PATCH net-next 04/10] dpll: take domain locks around driver callbacks Ivan Vecera
2026-11-10 12:23   ` Petr Oros
2026-11-06 12:10 ` [PATCH net-next 05/10] dpll: convert dpll_lock to rwsem Ivan Vecera
2026-11-10 12:24   ` Petr Oros
2026-11-10 17:53   ` netdev-bot+sashiko [this message]
2026-11-06 12:10 ` [PATCH net-next 06/10] dpll: add KUnit tests for core locking Ivan Vecera
2026-11-10 12:24   ` Petr Oros
2026-11-10 17:53   ` netdev-bot+sashiko
2026-11-06 12:10 ` [PATCH net-next 07/10] dpll: reject measured_freq_get for foreign and on-pin registrations Ivan Vecera
2026-11-10 12:24   ` Petr Oros
2026-11-06 12:10 ` [PATCH net-next 08/10] dpll: zl3073x: update locking comments Ivan Vecera
2026-11-10 12:24   ` Petr Oros
2026-11-06 12:10 ` [PATCH net-next 09/10] ice: dpll: " Ivan Vecera
2026-11-10 15:31   ` Petr Oros
2026-11-10 17:53   ` netdev-bot+sashiko
2026-11-06 12:10 ` [PATCH net-next 10/10] dpll: document locking rules Ivan Vecera
2026-11-10 12:25   ` Petr Oros
2026-11-10 17:53   ` netdev-bot+sashiko

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=179433320479.994134.13826920591104367019@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=grzegorz.nitka@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=ivecera@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=karol.kolacinski@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=min.li@microchip.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=poros@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rdunlap@infradead.org \
    --cc=richardcochran@gmail.com \
    --cc=saeedm@nvidia.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tariqt@nvidia.com \
    --cc=vadim.fedorenko@linux.dev \
    /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®