From nobody Fri Jun 03 13:10:10 2022 X-Original-To: hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3049E1B51107 for ; Fri, 3 Jun 2022 13:10:23 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4LF3CK4cjlz4qvb for ; Fri, 3 Jun 2022 13:10:17 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from sslproxy05.your-server.de ([78.46.172.2]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nx747-0006ue-MA; Fri, 03 Jun 2022 15:10:11 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nx747-000WYp-J2; Fri, 03 Jun 2022 15:10:11 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 469C14800D4; Fri, 3 Jun 2022 15:10:11 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id OZMAKrYFFWWC; Fri, 3 Jun 2022 15:10:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id ED597480135; Fri, 3 Jun 2022 15:10:10 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id tELSReMR-vak; Fri, 3 Jun 2022 15:10:10 +0200 (CEST) Received: from [192.168.96.159] (unknown [192.168.96.159]) by mail.embedded-brains.de (Postfix) with ESMTPSA id CCDB94800D4; Fri, 3 Jun 2022 15:10:10 +0200 (CEST) Message-ID: <35d4d55c-ff62-cff7-cdbf-ea2549dee86c@embedded-brains.de> Date: Fri, 3 Jun 2022 15:10:10 +0200 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: pps_capture() and pps_fetch() Content-Language: en-US To: Poul-Henning Kamp Cc: Konstantin Belousov , hackers@freebsd.org References: <5b8310db-c94b-709f-8c57-bec2d413a80f@embedded-brains.de> <202206010725.2517PEfF036703@critter.freebsd.dk> <202206030828.2538ScDg080165@critter.freebsd.dk> From: Sebastian Huber In-Reply-To: <202206030828.2538ScDg080165@critter.freebsd.dk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.103.6/26561/Fri Jun 3 10:05:55 2022) X-Rspamd-Queue-Id: 4LF3CK4cjlz4qvb X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of sebastian.huber@embedded-brains.de designates 85.10.215.148 as permitted sender) smtp.mailfrom=sebastian.huber@embedded-brains.de X-Spamd-Result: default: False [-3.30 / 15.00]; RCVD_COUNT_SEVEN(0.00)[8]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:85.10.215.148]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; DMARC_NA(0.00)[embedded-brains.de]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; MLMMJ_DEST(0.00)[hackers]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:85.10.192.0/18, country:DE]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org]; HAS_X_AS(0.00)[] X-ThisMailContainsUnwantedMimeParts: N 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/