From nobody Mon Feb 7 18:04:37 2022 X-Original-To: freebsd-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 2B9F519592E1 for ; Mon, 7 Feb 2022 18:04:50 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-vk1-xa2f.google.com (mail-vk1-xa2f.google.com [IPv6:2607:f8b0:4864:20::a2f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JsvDd3S4Rz4bYY for ; Mon, 7 Feb 2022 18:04:49 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-vk1-xa2f.google.com with SMTP id o15so8335669vki.2 for ; Mon, 07 Feb 2022 10:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GPhjG5d6zzlWTP3JccLg/C2GGchcibnBBmjjxgqFYnA=; b=ioOaV20Bd+5SSOzMXL56LdDYnz3Lsb9sYjn9PoaNk3n35IS2qSfu09eXyObTxC5hE8 59Nn7+85paw3RW5irxyvCFppA94N5sBOwwmHXEcGrkCL9FX+KUp4ja+Mwqh8ZWICScep bZCCUQyIPgWKR27zfh3nkFEJeBsA7F16j0JSGnq/ZEiEsbF5f7p4dLz4S6Q4EhXXTtzF 2nY5ZkIouyCAtRQvvAzA0AWp+lbieOhW+QoBxluCDFi/9lenLluGoDETWa87MUQpAU4S QRnm9NDAyMI18IABd8uMwRtZYYA8zSwwlkoJvYP1dPEeCcqxeCvpuUMYtxVvYDkWcTkE 2UKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GPhjG5d6zzlWTP3JccLg/C2GGchcibnBBmjjxgqFYnA=; b=MAfhws4luUss4fMjVFQdXCDbYvxsnWYHf34STPkYZQepiRl5cE7OFsStnuSyp6HqNt agJrG4MSGZw2QipVj174G4U7yj12jsitLWRnxXTP1m8jXdjXttkVzHVVn7rfVVHy5rn8 bSKhRKud/aqnbOp97StnhVPdvNKktMAYOcYgoyFSXKwgT9V1vgPoh4KUdVKZ+FtYo5IX ppKUUdi4fufWM0JkiuX+lbJGtPlkgY7njJm2RPGtUc5lEHw4sUOXRAGNhDHjk14r1Bro eInS6bZ0TNUsNVhbHKthwbez9uSHrUMQX1rENYGDzObbVtiiuCv187H3dmBMybylOVHz biMQ== X-Gm-Message-State: AOAM530cQCqfLSyFVQyl1DInXElSqLdA/uvku38NiWl0A+kZy63DqIPL mxH+jlETtLeLBvj8Ddgowne3Qlw5SAKdoAey1ONbFg== X-Google-Smtp-Source: ABdhPJwuzBclgCU449Hy/s9BPtABxCIHK3mrTprYRwQPkPMeVylVGuOZImw3b3uUNdXMybK4rILDuDj149KSlZPyteQ= X-Received: by 2002:a05:6122:181a:: with SMTP id ay26mr215092vkb.5.1644257088689; Mon, 07 Feb 2022 10:04:48 -0800 (PST) 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 References: In-Reply-To: From: Warner Losh Date: Mon, 7 Feb 2022 11:04:37 -0700 Message-ID: Subject: Re: ntp_init() looks like a nop To: Konstantin Belousov Cc: Sebastian Huber , FreeBSD Hackers Content-Type: multipart/alternative; boundary="000000000000b0ea4d05d7716fe2" X-Rspamd-Queue-Id: 4JsvDd3S4Rz4bYY X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20210112.gappssmtp.com header.s=20210112 header.b=ioOaV20B; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::a2f) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-2.93 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20210112.gappssmtp.com:s=20210112]; NEURAL_HAM_MEDIUM(-0.99)[-0.990]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20210112.gappssmtp.com:+]; NEURAL_HAM_SHORT(-0.94)[-0.944]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::a2f:from]; MLMMJ_DEST(0.00)[freebsd-hackers]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; R_SPF_NA(0.00)[no SPF record]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com] X-ThisMailContainsUnwantedMimeParts: N --000000000000b0ea4d05d7716fe2 Content-Type: text/plain; charset="UTF-8" On Mon, Feb 7, 2022 at 8:20 AM Konstantin Belousov wrote: > On Mon, Feb 07, 2022 at 04:04:56PM +0100, Sebastian Huber wrote: > > Hello, > > > > I review currently the kern_ntptime.c module since I would like to use > it in > > RTEMS. I have a question to ntp_init(): > > > > /* > > * ntp_init() - initialize variables and structures > > * > > * This routine must be called after the kernel variables hz and tick > > * are set or changed and before the next tick interrupt. In this > > * particular implementation, these values are assumed set elsewhere in > > * the kernel. The design allows the clock frequency and tick interval > > * to be changed while the system is running. So, this routine should > > * probably be integrated with the code that does that. > > */ > > static void > > ntp_init(void) > > { > > > > /* > > * The following variables are initialized only at startup. Only > > * those structures not cleared by the compiler need to be > > * initialized, and these only in the simulator. In the actual > > * kernel, any nonzero values here will quickly evaporate. > > */ > > L_CLR(time_offset); > > L_CLR(time_freq); > > #ifdef PPS_SYNC > > pps_tf[0].tv_sec = pps_tf[0].tv_nsec = 0; > > pps_tf[1].tv_sec = pps_tf[1].tv_nsec = 0; > > pps_tf[2].tv_sec = pps_tf[2].tv_nsec = 0; > > pps_fcount = 0; > > L_CLR(pps_freq); > > #endif /* PPS_SYNC */ > > } > > > > SYSINIT(ntpclocks, SI_SUB_CLOCKS, SI_ORDER_MIDDLE, ntp_init, NULL); > > > > The ntp_init() function sets a couple of global variables to zero. These > > variables should be in the .bss section. Are they not already cleared > during > > the kernel loading? > This is nop indeed, be it linked in kernel, or loaded as a module. > I just looked at the posted patch, and I concur. Warner --000000000000b0ea4d05d7716fe2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Mon, Feb 7, 2022 at 8:20 AM Konsta= ntin Belousov <kostikbel@gmail.co= m> wrote:
On Mon, Feb 07, 2022 at 04:04:56PM +0100, Sebastian Huber wrote:
> Hello,
>
> I review currently the kern_ntptime.c module since I would like to use= it in
> RTEMS. I have a question to ntp_init():
>
> /*
>=C2=A0 * ntp_init() - initialize variables and structures
>=C2=A0 *
>=C2=A0 * This routine must be called after the kernel variables hz and = tick
>=C2=A0 * are set or changed and before the next tick interrupt. In this=
>=C2=A0 * particular implementation, these values are assumed set elsewh= ere in
>=C2=A0 * the kernel. The design allows the clock frequency and tick int= erval
>=C2=A0 * to be changed while the system is running. So, this routine sh= ould
>=C2=A0 * probably be integrated with the code that does that.
>=C2=A0 */
> static void
> ntp_init(void)
> {
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0/*
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 * The following variables are initialized o= nly at startup. Only
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 * those structures not cleared by the compi= ler need to be
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 * initialized, and these only in the simula= tor. In the actual
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 * kernel, any nonzero values here will quic= kly evaporate.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
>=C2=A0 =C2=A0 =C2=A0 =C2=A0L_CLR(time_offset);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0L_CLR(time_freq);
> #ifdef PPS_SYNC
>=C2=A0 =C2=A0 =C2=A0 =C2=A0pps_tf[0].tv_sec =3D pps_tf[0].tv_nsec =3D 0= ;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0pps_tf[1].tv_sec =3D pps_tf[1].tv_nsec =3D 0= ;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0pps_tf[2].tv_sec =3D pps_tf[2].tv_nsec =3D 0= ;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0pps_fcount =3D 0;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0L_CLR(pps_freq);
> #endif /* PPS_SYNC */
> }
>
> SYSINIT(ntpclocks, SI_SUB_CLOCKS, SI_ORDER_MIDDLE, ntp_init, NULL); >
> The ntp_init() function sets a couple of global variables to zero. The= se
> variables should be in the .bss section. Are they not already cleared = during
> the kernel loading?
This is nop indeed, be it linked in kernel, or loaded as a module.

I just looked at the posted patch, and I concur= .

Warner=C2=A0
--000000000000b0ea4d05d7716fe2--