From: Kurt Kanzenbach <kurt@linutronix.de>
To: Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Paul Menzel <pmenzel@molgen.mpg.de>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Richard Cochran <richardcochran@gmail.com>,
Vinicius Costa Gomes <vinicius.gomes@intel.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org
Subject: Re: [Intel-wired-lan] [PATCH iwl-next] igb: Retrieve Tx timestamp directly from interrupt
Date: Sat, 16 Aug 2025 11:06:49 +0200 [thread overview]
Message-ID: <87bjofoct2.fsf@jax.kurt.home> (raw)
In-Reply-To: <1f42eff0-b6a5-44cb-996e-655c325591be@linux.dev>
[-- Attachment #1: Type: text/plain, Size: 5660 bytes --]
On Fri Aug 15 2025, Vadim Fedorenko wrote:
> On 15/08/2025 09:17, Kurt Kanzenbach wrote:
>> Hi Paul,
>>
>> On Fri Aug 15 2025, Paul Menzel wrote:
>>> Dear Kurt,
>>>
>>>
>>> Thank you for your patch.
>>>
>>> Am 15.08.25 um 08:50 schrieb Kurt Kanzenbach:
>>>> Retrieve Tx timestamp directly from interrupt handler.
>>>>
>>>> The current implementation uses schedule_work() which is executed by the
>>>> system work queue to retrieve Tx timestamps. This increases latency and can
>>>> lead to timeouts in case of heavy system load.
>>>>
>>>> Therefore, fetch the timestamp directly from the interrupt handler.
>>>>
>>>> The work queue code stays for the Intel 82576. Tested on Intel i210.
>>>
>>> Excuse my ignorance, I do not understand the first sentence in the last
>>> line. Is it because the driver support different models? Why not change
>>> it for Intel 82576 too?
>>
>> Yes, the driver supports lots of different NIC(s). AFAICS Intel 82576 is
>> the only one which does not use time sync interrupts. Probably it does
>> not have this feature. Therefore, the 82576 needs to schedule a work
>> queue item.
>>
>>>
>>> Do you have a reproducer for the issue, so others can test.
>>
>> Yeah, I do have a reproducer:
>>
>> - Run ptp4l with 40ms tx timeout (--tx_timestamp_timeout)
>> - Run periodic RT tasks (e.g. with SCHED_FIFO 1) with run time of
>> 50-100ms per CPU core
>>
>> This leads to sporadic error messages from ptp4l such as "increasing
>> tx_timestamp_timeout or increasing kworker priority may correct this
>> issue, but a driver bug likely causes it"
>>
>> However, increasing the kworker priority is not an option, simply
>> because this kworker is doing non-related PTP work items as well.
>
> Well, in this case, as it pointed out for other drivers, the best
> practice would be to use a dedicated PTP worker which does only PTP
> related tasks and can have higher priority.
>
> The inline retrieving of timestamp, of course, the best option, but for
> 82576 could you please consider using @do_aux_work in ptp_caps and do
> proper ptp_schedule_worker()?
Sure, using the PTP aux worker is always the better than using the
system work queue. I ordered a 82576 for testing. But, that conversion
will be another patch.
>
>>
>> As the time sync interrupt already signals that the Tx timestamp is
>> available, there's no need to schedule a work item in this case. I might
>> have missed something though. But my testing looked good. The warn_on
>> never triggered.
>>
>>>
>>>> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
>>>> ---
>>>> drivers/net/ethernet/intel/igb/igb.h | 1 +
>>>> drivers/net/ethernet/intel/igb/igb_main.c | 2 +-
>>>> drivers/net/ethernet/intel/igb/igb_ptp.c | 22 ++++++++++++++++++++++
>>>> 3 files changed, 24 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
>>>> index c3f4f7cd264e9b2ff70f03b580f95b15b528028c..102ca32e8979fa3203fc2ea36eac456f1943cfca 100644
>>>> --- a/drivers/net/ethernet/intel/igb/igb.h
>>>> +++ b/drivers/net/ethernet/intel/igb/igb.h
>>>> @@ -776,6 +776,7 @@ int igb_ptp_hwtstamp_get(struct net_device *netdev,
>>>> int igb_ptp_hwtstamp_set(struct net_device *netdev,
>>>> struct kernel_hwtstamp_config *config,
>>>> struct netlink_ext_ack *extack);
>>>> +void igb_ptp_tx_tstamp_event(struct igb_adapter *adapter);
>>>> void igb_set_flag_queue_pairs(struct igb_adapter *, const u32);
>>>> unsigned int igb_get_max_rss_queues(struct igb_adapter *);
>>>> #ifdef CONFIG_IGB_HWMON
>>>> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
>>>> index a9a7a94ae61e93aa737b0103e00580e73601d62b..8ab6e52cb839bbb698007a74462798faaaab0071 100644
>>>> --- a/drivers/net/ethernet/intel/igb/igb_main.c
>>>> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
>>>> @@ -7080,7 +7080,7 @@ static void igb_tsync_interrupt(struct igb_adapter *adapter)
>>>>
>>>> if (tsicr & E1000_TSICR_TXTS) {
>>>> /* retrieve hardware timestamp */
>>>> - schedule_work(&adapter->ptp_tx_work);
>>>> + igb_ptp_tx_tstamp_event(adapter);
>>>> }
>>>>
>>>> if (tsicr & TSINTR_TT0)
>>>> diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
>>>> index a7876882aeaf2b2a7fb9ec6ff5c83d8a1b06008a..20ecafecc60557353f8cc5ab505030246687c8e4 100644
>>>> --- a/drivers/net/ethernet/intel/igb/igb_ptp.c
>>>> +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
>>>> @@ -796,6 +796,28 @@ static int igb_ptp_verify_pin(struct ptp_clock_info *ptp, unsigned int pin,
>>>> return 0;
>>>> }
>>>>
>>>> +/**
>>>> + * igb_ptp_tx_tstamp_event
>>>> + * @adapter: pointer to igb adapter
>>>> + *
>>>> + * This function checks the TSYNCTXCTL valid bit and stores the Tx hardware
>>>> + * timestamp at the current skb.
>>>> + **/
>>>> +void igb_ptp_tx_tstamp_event(struct igb_adapter *adapter)
>>>> +{
>>>> + struct e1000_hw *hw = &adapter->hw;
>>>> + u32 tsynctxctl;
>>>> +
>>>> + if (!adapter->ptp_tx_skb)
>>>> + return;
>>>> +
>>>> + tsynctxctl = rd32(E1000_TSYNCTXCTL);
>>>> + if (WARN_ON_ONCE(!(tsynctxctl & E1000_TSYNCTXCTL_VALID)))
>>>> + return;
>>>> +
>>>> + igb_ptp_tx_hwtstamp(adapter);
>>>> +}
>>>> +
>>>> /**
>>>> * igb_ptp_tx_work
>>>> * @work: pointer to work struct
>>>
>>> The diff looks fine.
>>>
>>> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
>
> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Thanks!
Kurt
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
next prev parent reply other threads:[~2025-08-16 9:15 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 6:50 [PATCH iwl-next] igb: Retrieve Tx timestamp directly from interrupt Kurt Kanzenbach
2025-08-15 7:55 ` [Intel-wired-lan] " Paul Menzel
2025-08-15 8:10 ` Sebastian Andrzej Siewior
2025-08-15 8:17 ` Kurt Kanzenbach
2025-08-15 12:54 ` Paul Menzel
2025-08-15 16:41 ` Sebastian Andrzej Siewior
2025-08-15 13:58 ` Vadim Fedorenko
2025-08-16 9:06 ` Kurt Kanzenbach [this message]
2025-08-18 12:24 ` Miroslav Lichvar
2025-08-19 6:09 ` Kurt Kanzenbach
2025-08-19 14:50 ` Kurt Kanzenbach
2025-08-20 6:54 ` Miroslav Lichvar
2025-08-19 23:31 ` Jacob Keller
2025-08-20 7:56 ` Miroslav Lichvar
2025-08-20 20:29 ` Jacob Keller
2025-08-21 7:50 ` Miroslav Lichvar
2025-08-21 11:38 ` Kurt Kanzenbach
2025-08-21 12:59 ` Miroslav Lichvar
2025-08-21 14:08 ` Kurt Kanzenbach
2025-08-21 14:51 ` Miroslav Lichvar
2025-08-19 23:24 ` Jacob Keller
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=87bjofoct2.fsf@jax.kurt.home \
--to=kurt@linutronix.de \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pmenzel@molgen.mpg.de \
--cc=przemyslaw.kitszel@intel.com \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
--cc=vinicius.gomes@intel.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;
as well as URLs for NNTP newsgroup(s).