Netdev List
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: David Woodhouse <dwmw2@infradead.org>,
	Harshitha Ramamurthy <hramamurthy@google.com>,
	netdev@vger.kernel.org, Arthur Kiyanovski <akiyano@amazon.com>
Cc: joshwash@google.com, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	richardcochran@gmail.com, jstultz@google.com, sboyd@kernel.org,
	willemb@google.com, nktgrg@google.com, jfraker@google.com,
	ziweixiao@google.com, maolson@google.com, jordanrhee@google.com,
	thostet@google.com, alok.a.tiwari@oracle.com,
	pkaligineedi@google.com, horms@kernel.org,
	jacob.e.keller@intel.com, yyd@google.com, jefrogers@google.com,
	linux-kernel@vger.kernel.org,
	"Naman Gulati" <namangulati@google.com>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: Re: [PATCH net-next v8 3/3] gve: implement PTP gettimex64
Date: Fri, 22 May 2026 09:49:47 +0200	[thread overview]
Message-ID: <877bovvq78.ffs@tglx> (raw)
In-Reply-To: <38ded3d61878f319ad74869924a55665d8baadb9.camel@infradead.org>

On Fri, May 22 2026 at 01:12, David Woodhouse wrote:
> On Fri, 2026-05-22 at 00:43 +0200, Thomas Gleixner wrote:
>> > So surely a device can only support this if it *does* have a precise
>> > hardware timestamp, e.g. from ART? And the corresponding sys_realtime
>> > and sys_monoraw fields also have to be from the *same* value, surely?
>> 
>> That is correct, but you still fail to explain how this new made up
>> att.counter_id/att.counter_value is filled in coherently without the
>> driver doing something abysmal?
>>
>> You can't explain it, because the only way to do that correctly is by
>> extending the cross time stamp struct and get_device_system_crosststamp().
>
> Yes. Isn't that what I asked Arthur to do?

You maybe asked him, but I can't see any evidence of it anywhere. All I
can see is a magic struct attr, which conveys CS related data that is
supposed to be produced magically at some undefined place.

>> > Is that not how it works? If not.... WTF *is* it for?
>> 
>> Yes, that's the way it works since get_device_system_crosststamp() got
>> introduced, but that does not give a random driver access to the actual
>> converted (TSC) counter value. The driver can only observe the PTM value
>> which is ART on x86 and whatever on other architectures. So it does not
>> know anything about it.
>
> Sure, the driver can only return what it *knows*.
>
> We're certainly missing some infrastructure here... maybe the pci_bus
> should have a CSID which corresponds to its PTM domain, which on x86
> would be CSID_X86_ART?

Yes, that's correct. But that does not solve the underlying problem:

The driver gets the PTP/SystemTime pair from the hardware/firmware,
which is what it hands back to get_device_system_crosststamp(). What
does SystemTime mean?

Here it gets interesting as that depends on the NIC/PTP magic firmware
and the architecture:

   On X86:

     - The plain ART value, which is converted to TSC in
       get_device_system_crosststamp().

     - The ART value which is magically converted to "nanoseconds" by
       the firmware.

    That is conveyed in system_counterval_t and the 'use_nsec' flag,
    which is a misnomer, determines the conversion in the core.
   
     - If set it uses the nominal frequency of the underlying base clock
       (ART) for conversion.
   
     - If not it uses the nominator/denominator pair of the underlying base
       clock (ART) for conversion.
   
   On ARM64:
   
     - The ARM ARCH counter value (however that is converted from PTM
       magically)
   
     - The ARM ARCH counter which is magically converted to "nanoseconds"
       by the firmware. Actually it's not, but the drivers claim it is.
   
     It does not matter because the core does no conversion for ARM64 as
     the SystemTime CSID is the same as the core timekeeper CSID.

Q: How is a driver supposed to fill in attr->cs_cycles coherently?

A: Not at all.

The consequence of this is that the next driver writer will just go and
do:

       attr->cs_id = IS_ENABLED(X86) ? CSID_X86_TSC : CSID_ARM_COUNTER;
       attr->cs_cycles = get_cycles();
   or
       attr->cs_cycles = ptm_cycles * pulledout_of_thin_air_factor +
                         pulledout_of_thin_air_offset;

and this mess is going to proliferate faster than you can breathe.

The same applies to the pre/post timestamp mechanism for
gettimexattrs64().

These new attr IOCTLs are not restricted to your favorite vmclock PTP
toy. They are available for every PTP driver which implements them, but
there is no infrastructure to actually provide the required data. That
ENA driver implementing gettimexattrs64() is demonstrating it. It at
least does not try to make them up, but that's just a matter of time to
happen.

I know you don't care because that's outside of your sandpit, but I care
because providing this interface is going to result in random drivers
growing the most absurd warts just to work around the lack of core
infrastructure.

Are you going to monitor drivers/net/ for those instances and make sure
they are burned before seeing the light of day?

Surely not and neither is netdev going to care as demonstrated with
this GEV mess.

It took me half an hour to add basic support for that into the core
infrastructure, but this new IOCTL stuff has been in the making for
almost a year without anyone spending a single brain cycle to even think
about it.

And you just have proven it by still claiming that this is a completely
cosmetic problem.

Seriously?

>> I agree, but the way how this attr.counter_id/value extension is defined
>> either requires unholy hacks to get access to the ART/TSC conversion or
>> resort to get_cycles().

> Never get_cycles(). Let's perhaps make it *not* need unholy hacks to
> interpret a PTM counter value. Otherwise what's the point in ART and
> PTM at all?

Perhaps? There is no perhaps and aside of that I gave you the solution
for the problem already in the mail you just replied to, no?

I'm glad we agree on "Never get_cycles()" at least. May I ask you then
to get a stiff drink ready and run:

  # git blame drivers/ptp/ptp_vmclock.c | grep get_cycles

:)

Thanks,

        tglx

  reply	other threads:[~2026-05-22  7:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 22:58 [PATCH net-next v8 0/3] gve: add support for PTP gettimex64 Harshitha Ramamurthy
2026-05-14 22:58 ` [PATCH net-next v8 1/3] gve: skip error logging for retryable AdminQ commands Harshitha Ramamurthy
2026-05-14 22:58 ` [PATCH net-next v8 2/3] gve: make nic clock reads thread safe Harshitha Ramamurthy
2026-05-14 22:58 ` [PATCH net-next v8 3/3] gve: implement PTP gettimex64 Harshitha Ramamurthy
2026-05-20 21:08   ` Thomas Gleixner
2026-05-20 22:16     ` Jakub Kicinski
2026-05-21  4:35     ` Jordan Rhee
2026-05-21 10:08     ` David Laight
2026-05-21 11:43   ` David Woodhouse
2026-05-21 18:06     ` Thomas Gleixner
2026-05-21 19:59       ` David Woodhouse
2026-05-21 22:43         ` Thomas Gleixner
2026-05-22  0:12           ` David Woodhouse
2026-05-22  7:49             ` Thomas Gleixner [this message]
2026-05-22  8:56               ` David Woodhouse
2026-05-22 14:41                 ` Thomas Gleixner
2026-05-22 10:34           ` David Woodhouse
2026-05-22 14:46             ` Thomas Gleixner
2026-05-20  1:30 ` [PATCH net-next v8 0/3] gve: add support for " patchwork-bot+netdevbpf

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=877bovvq78.ffs@tglx \
    --to=tglx@kernel.org \
    --cc=akiyano@amazon.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dwmw2@infradead.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jefrogers@google.com \
    --cc=jfraker@google.com \
    --cc=jordanrhee@google.com \
    --cc=joshwash@google.com \
    --cc=jstultz@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maolson@google.com \
    --cc=namangulati@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=nktgrg@google.com \
    --cc=pabeni@redhat.com \
    --cc=pkaligineedi@google.com \
    --cc=richardcochran@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=thostet@google.com \
    --cc=willemb@google.com \
    --cc=yyd@google.com \
    --cc=ziweixiao@google.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