[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250702145536.08a6aa7a@kernel.org>
Date: Wed, 2 Jul 2025 14:55:36 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Jeongjun Park <aha310510@...il.com>
Cc: richardcochran@...il.com, andrew+netdev@...n.ch, davem@...emloft.net,
edumazet@...gle.com, pabeni@...hat.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] ptp: remove unnecessary mutex lock in
ptp_clock_unregister()
On Wed, 2 Jul 2025 02:03:53 +0900 Jeongjun Park wrote:
> ptp_clock_unregister() is called by ptp core and several drivers that
> require ptp clock feature. And in this function, ptp_vclock_in_use()
> is called to check if ptp virtual clock is in use, and
> ptp->is_virtual_clock, ptp->n_vclocks are checked.
>
> It is true that you should always check ptp->is_virtual_clock to see if
> you are using ptp virtual clock, but you do not necessarily need to
> check ptp->n_vclocks.
>
> ptp->n_vclocks is a feature need by ptp sysfs or some ptp cores, so in
> most cases, except for these callers, it is not necessary to check.
>
> The problem is that ptp_clock_unregister() checks ptp->n_vclocks even
> when called by a driver other than the ptp core, and acquires
> ptp->n_vclocks_mux to avoid concurrency issues when checking.
>
> I think this logic is inefficient, so I think it would be appropriate to
> modify the caller function that must check ptp->n_vclocks to check
> ptp->n_vclocks in advance before calling ptp_clock_unregister().
Please repost this and CC Vladimir.
--
pw-bot: cr
Powered by blists - more mailing lists