public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Jeongjun Park <aha310510@gmail.com>
Cc: richardcochran@gmail.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2] ptp: remove unnecessary mutex lock in ptp_clock_unregister()
Date: Thu, 3 Jul 2025 16:34:50 +0300	[thread overview]
Message-ID: <20250703133450.kaoncopz3i2ileug@skbuf> (raw)
In-Reply-To: <20250703055340.55158-1-aha310510@gmail.com> <20250703055340.55158-1-aha310510@gmail.com>

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?

      reply	other threads:[~2025-07-03 13:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03  5:53 [PATCH net-next v2] ptp: remove unnecessary mutex lock in ptp_clock_unregister() Jeongjun Park
2025-07-03 13:34 ` Vladimir Oltean [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=20250703133450.kaoncopz3i2ileug@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=aha310510@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    /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