[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211210193556.1349090-5-yannick.vignon@oss.nxp.com>
Date: Fri, 10 Dec 2021 20:35:56 +0100
From: Yannick Vignon <yannick.vignon@....nxp.com>
To: Giuseppe Cavallaro <peppe.cavallaro@...com>,
Alexandre Torgue <alexandre.torgue@...com>,
netdev@...r.kernel.org, Ong Boon Leong <boon.leong.ong@...el.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Jose Abreu <joabreu@...opsys.com>,
Eric Dumazet <edumazet@...gle.com>,
Wei Wang <weiwan@...gle.com>,
Alexander Lobakin <alexandr.lobakin@...el.com>,
Vladimir Oltean <olteanv@...il.com>,
Xiaoliang Yang <xiaoliang.yang_1@....com>, mingkai.hu@....com,
Joakim Zhang <qiangqing.zhang@....com>,
sebastien.laveze@....com
Cc: Yannick Vignon <yannick.vignon@....com>
Subject: [RFC net-next 4/4] net: stmmac: remove unnecessary locking around PTP clock reads
From: Yannick Vignon <yannick.vignon@....com>
Reading the PTP clock is a simple operation requiring only 2 register reads,
while the time can be set atomically through another set of registers. Under
a PREEMPT_RT kernel, protecting the reads by a spin_lock is
counter-productive:
* if the task is preempted in-between the 2 reads, the return time value
could become inconsistent,
* if the 2nd task preempting the 1st has a higher prio but needs to
read time as well, it will require 2 costly context switches, which
will pretty much always be more costly than disabling preemption with a real
spin_lock.
Remove the unneeded locking around the gettime call.
Signed-off-by: Yannick Vignon <yannick.vignon@....com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
index 580cc035536b..8f0dcac23b1e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
@@ -137,9 +137,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts)
unsigned long flags;
u64 ns = 0;
- spin_lock_irqsave(&priv->ptp_lock, flags);
stmmac_get_systime(priv, priv->ptpaddr, &ns);
- spin_unlock_irqrestore(&priv->ptp_lock, flags);
*ts = ns_to_timespec64(ns);
--
2.25.1
Powered by blists - more mailing lists