Skip to content

Commit 67c3b61

Browse files
Alejandro Lucerokuba-moo
authored andcommitted
sfc: disable softirqs for ptp TX
Sending a PTP packet can imply to use the normal TX driver datapath but invoked from the driver's ptp worker. The kernel generic TX code disables softirqs and preemption before calling specific driver TX code, but the ptp worker does not. Although current ptp driver functionality does not require it, there are several reasons for doing so: 1) The invoked code is always executed with softirqs disabled for non PTP packets. 2) Better if a ptp packet transmission is not interrupted by softirq handling which could lead to high latencies. 3) netdev_xmit_more used by the TX code requires preemption to be disabled. Indeed a solution for dealing with kernel preemption state based on static kernel configuration is not possible since the introduction of dynamic preemption level configuration at boot time using the static calls functionality. Fixes: f79c957 ("drivers: net: sfc: use netdev_xmit_more helper") Signed-off-by: Alejandro Lucero <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0c10455 commit 67c3b61

File tree

1 file changed

+22
-0
lines changed
  • drivers/net/ethernet/sfc

1 file changed

+22
-0
lines changed

drivers/net/ethernet/sfc/ptp.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,29 @@ static void efx_ptp_xmit_skb_queue(struct efx_nic *efx, struct sk_buff *skb)
11001100

11011101
tx_queue = efx_channel_get_tx_queue(ptp_data->channel, type);
11021102
if (tx_queue && tx_queue->timestamping) {
1103+
/* This code invokes normal driver TX code which is always
1104+
* protected from softirqs when called from generic TX code,
1105+
* which in turn disables preemption. Look at __dev_queue_xmit
1106+
* which uses rcu_read_lock_bh disabling preemption for RCU
1107+
* plus disabling softirqs. We do not need RCU reader
1108+
* protection here.
1109+
*
1110+
* Although it is theoretically safe for current PTP TX/RX code
1111+
* running without disabling softirqs, there are three good
1112+
* reasond for doing so:
1113+
*
1114+
* 1) The code invoked is mainly implemented for non-PTP
1115+
* packets and it is always executed with softirqs
1116+
* disabled.
1117+
* 2) This being a single PTP packet, better to not
1118+
* interrupt its processing by softirqs which can lead
1119+
* to high latencies.
1120+
* 3) netdev_xmit_more checks preemption is disabled and
1121+
* triggers a BUG_ON if not.
1122+
*/
1123+
local_bh_disable();
11031124
efx_enqueue_skb(tx_queue, skb);
1125+
local_bh_enable();
11041126
} else {
11051127
WARN_ONCE(1, "PTP channel has no timestamped tx queue\n");
11061128
dev_kfree_skb_any(skb);

0 commit comments

Comments
 (0)