<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 6, 2023 at 4:59 AM Stephen Hemminger <<a href="mailto:stephen@networkplumber.org">stephen@networkplumber.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 29 Aug 2023 20:25:54 +0530<br>
Hari Haran <<a href="mailto:info2hariharan@gmail.com" target="_blank">info2hariharan@gmail.com</a>> wrote:<br>
<br>
> Hi All,<br>
> <br>
> Subject: rte_rdtsc() - what is the performance impact of using rte_rdtsc()<br>
> time under lcore thread while(1)<br>
> <br>
> Requirement:<br>
> <br>
> 1. Store the packet received timestamp - based on it packets will be<br>
> removed from buffer if it exceeds the threshold timer of buffer<br>
> 2. Two threads are available, One is lcore(dedicated core) and another<br>
> is pthread(not a dedicated core. In pthread, have to get the timestamp of<br>
> last received packet timestamp<br>
> <br>
> <br>
> Query:<br>
> <br>
> 1. For every packet reception in lcore thread under while(1), will get<br>
> the packet received timestamp using rte_rdtsc() function. Whether usage of<br>
> rte_rdtsc() function adds more delay in packet processing?<br>
> 2. Is there any way to convert rte_rdtsc() timestamp value to current<br>
> system time in pthread()? In pthread, the last packet received time needed<br>
> in the form of system time.<br>
> <br>
> <br>
> Thanks in advance.<br>
> <br>
> Regards,<br>
> Hariharan<br>
<br>
The problem is that rte_rdtsc() stops speculative execution so doing<br>
lots of TSC instructions can hurt performance.<br>
<br>
To correlate TSC timestamp to system time, you need to compute the offsets<br>
once at startup. Alternatively, don't use rte_rdtsc() and instead use<br>
clock_gettime() with the monotonic timer and the C library does the calculation<br>
for you.<br></blockquote><div><br></div><div><br></div><div>As part of query 1 and based on your response, I am asking below query</div><div><br></div><div>But usage of clock_gettime() (kernel function) in lcore is advisable one? My understanding is, </div><div>shall avoid usage of kernel function in lcore. Correct me if I am wrong? </div><div><br></div><div>TIA. </div><div><br></div><div>Regards,</div><div>Hariharan </div><div> </div></div></div>