Thread (1 message) 1 message, 1 author, 2025-07-03

Re: [PATCH net-next v2] ptp: remove unnecessary mutex lock in ptp_clock_unregister()

From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: 2025-07-03 13:34:59
Also in: lkml

On Thu, Jul 03, 2025 at 02:53:40PM +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,
Can you present a single metric by which you qualify this logic as
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().
And which are the call sites of ptp_clock_unregister() which should
check ptp->n_vclocks in advance, in your proposal?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help