Re: pps_capture() and pps_fetch()
- Reply: Poul-Henning Kamp: "Re: pps_capture() and pps_fetch()"
- In reply to: Poul-Henning Kamp: "Re: pps_capture() and pps_fetch()"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 03 Jun 2022 13:10:10 UTC
On 03.06.22 10:28, Poul-Henning Kamp wrote:
>> The expensive part in pps_event() is after the th_generation checks. I
>> think from a performance point of view, the checks can be reduced to
>> just one th_generation check. I am more concerned if this would
>> introduce a subtle functional change.
> Assuming that your timecounter hardware does not roll over fast enough
> to open any races, I think that is correct.
Would a timecounter overflow within a time interval from th_generation
to th_generation + 1 not be a bug in general?
static __inline void
bintime_off(struct bintime *bt, u_int off)
{
struct timehands *th;
struct bintime *btp;
uint64_t scale;
u_int delta, gen, large_delta;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
For example, if the thread gets interrupted here and the timecounter
overflows, then the measurement below would be wrong if th_generation
didn't change.
btp = (struct bintime *)((vm_offset_t)th + off);
*bt = *btp;
scale = th->th_scale;
delta = tc_delta(th);
large_delta = th->th_large_delta;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
bintime_add_tc_delta(bt, scale, large_delta, delta);
}
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/