[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANr-f5zW9J+1Z+Oe270xRpye4qtD2r97QAdoCrykOrk1SOuVag@mail.gmail.com>
Date: Thu, 24 Mar 2022 20:52:18 +0100
From: Gerhard Engleder <gerhard@...leder-embedded.com>
To: Richard Cochran <richardcochran@...il.com>
Cc: yangbo.lu@....com, David Miller <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, mlichvar@...hat.com,
Vinicius Costa Gomes <vinicius.gomes@...el.com>,
netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next v1 5/6] ptp: Support late timestamp determination
> > diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> > index 54b9f54ac0b2..b7a8cf27c349 100644
> > --- a/drivers/ptp/ptp_clock.c
> > +++ b/drivers/ptp/ptp_clock.c
> > @@ -450,6 +450,33 @@ void ptp_cancel_worker_sync(struct ptp_clock *ptp)
> > }
> > EXPORT_SYMBOL(ptp_cancel_worker_sync);
> >
> > +ktime_t ptp_get_timestamp(int index,
> > + const struct skb_shared_hwtstamps *hwtstamps,
> > + bool cycles)
> > +{
> > + char name[PTP_CLOCK_NAME_LEN] = "";
> > + struct ptp_clock *ptp;
> > + struct device *dev;
> > + ktime_t ts;
> > +
> > + snprintf(name, PTP_CLOCK_NAME_LEN, "ptp%d", index);
> > + dev = class_find_device_by_name(ptp_class, name);
>
> This seems expensive for every single Rx frame in a busy PTP network.
> Can't this be cached in the socket?
I thought that PTP packages are rare and that bloating the socket is
not welcome.
I'll try to implement some caching.
> > --- a/include/linux/skbuff.h
> > +++ b/include/linux/skbuff.h
> > @@ -564,7 +564,10 @@ static inline bool skb_frag_must_loop(struct page *p)
> > * &skb_shared_info. Use skb_hwtstamps() to get a pointer.
> > */
> > struct skb_shared_hwtstamps {
> > - ktime_t hwtstamp;
> > + union {
> > + ktime_t hwtstamp;
> > + void *phc_data;
>
> needs kdoc update
Sorry, I totally forgot that. I'll fix it.
> > @@ -886,18 +885,32 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
> > if (shhwtstamps &&
> > (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) &&
> > !skb_is_swtx_tstamp(skb, false_tstamp)) {
> > - if (sk->sk_tsflags & SOF_TIMESTAMPING_BIND_PHC)
> > - hwtstamp = ptp_convert_timestamp(&shhwtstamps->hwtstamp,
> > - sk->sk_bind_phc);
> > + rcu_read_lock();
> > + orig_dev = dev_get_by_napi_id(skb_napi_id(skb));
> > + if (orig_dev) {
> > + if_index = orig_dev->ifindex;
> > + if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP_PHC)
> > + phc_index = ethtool_get_phc(orig_dev);
>
> again, this is something that can be cached, no?
I'll try to implement some caching.
Thanks for your review!
Gerhard
Powered by blists - more mailing lists