Date: Fri, 3 Jun 2022 15:10:10 +0200 From: Sebastian Huber <sebastian.huber@embedded-brains.de> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: Konstantin Belousov <kostikbel@gmail.com>, hackers@freebsd.org Subject: Re: pps_capture() and pps_fetch() Message-ID: <35d4d55c-ff62-cff7-cdbf-ea2549dee86c@embedded-brains.de> In-Reply-To: <202206030828.2538ScDg080165@critter.freebsd.dk> References: <5b8310db-c94b-709f-8c57-bec2d413a80f@embedded-brains.de> <202206010725.2517PEfF036703@critter.freebsd.dk> <e1093df0-c719-0421-3e96-c6d7df861a51@embedded-brains.de> <YphDlMyWxDWvJo5Q@kib.kiev.ua> <c4fe6a08-24b6-522e-3963-cf03eb994496@embedded-brains.de> <202206030828.2538ScDg080165@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
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=20 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 =3D timehands; gen =3D atomic_load_acq_int(&th->th_generation); For example, if the thread gets interrupted here and the timecounter=20 overflows, then the measurement below would be wrong if th_generation=20 didn't change. btp =3D (struct bintime *)((vm_offset_t)th + off); *bt =3D *btp; scale =3D th->th_scale; delta =3D tc_delta(th); large_delta =3D th->th_large_delta; atomic_thread_fence_acq(); } while (gen =3D=3D 0 || gen !=3D th->th_generation); bintime_add_tc_delta(bt, scale, large_delta, delta); } --=20 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=C3=BCnchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch=C3=A4ftsf=C3=BChrer: Peter Rasmussen, Thomas= D=C3=B6rfler Unsere Datenschutzerkl=C3=A4rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35d4d55c-ff62-cff7-cdbf-ea2549dee86c>