From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Natanael Copa Newsgroups: gmane.emacs.devel,gmane.comp.lib.gnulib.bugs Subject: Re: boot time on Linux Date: Thu, 10 Aug 2023 11:30:19 +0200 Message-ID: References: <87tttmpt5h.fsf@turtle.gmx.de> <20230808173430.GA27131@suse.com> <26226778.6c9BZvbsD2@nimes> <3732835.vtg8X0x55z@nimes> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000004f529b06028e3f19" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26628"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Bruno Haible , Robert Pluim , bug-gnulib@gnu.org, =?UTF-8?Q?P=C3=A1draig_Brady?= , Sven Joachim , 64937@debbugs.gnu.org, Po Lu , Emacs Development , Thorsten Kukuk , Natanael Copa To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Aug 10 11:44:16 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qU2DI-0006kv-6T for ged-emacs-devel@m.gmane-mx.org; Thu, 10 Aug 2023 11:44:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qU2CR-00053d-Dd; Thu, 10 Aug 2023 05:43:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qU204-0001O9-Vr; Thu, 10 Aug 2023 05:30:37 -0400 Original-Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qU202-0002lx-CM; Thu, 10 Aug 2023 05:30:36 -0400 Original-Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-51d95aed33aso806328a12.3; Thu, 10 Aug 2023 02:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691659831; x=1692264631; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jlpbA71pJ+7Cw28UPpFABmAmhc4CNKJJoTOKHW3XChI=; b=VkJqkLhemuTLjMFyQ68gAD1Q6Y4LKD5iFg4x2xJCoMTi4eIWpzvAgExxogEbYXfoGj xmiIJ86Kp+wYG0pFvb992cepv/oYytbp6OOk/WyCOXo48CGNl0ZPhIc+tgJOB/OPoKS8 3JL76PHIbuq2ZPkNXCxBwvB2XS1ijIl/9M9jKDcqL7Pxae/7liC0rnYwF20gfwhtEBT3 wdxIMNxYQ8rmpBV3vHagn0UOYYHHOaQ8F9tbTON8k2DzIiw6+oP+TZgmnxbYT+uElxYD r5CWlNomBjwzfI/wOJUxE4/znK/kexvFJjJt/YrHJF9S6MKmUNDFuhMJYKTyKYaeFFfR GD3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691659831; x=1692264631; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jlpbA71pJ+7Cw28UPpFABmAmhc4CNKJJoTOKHW3XChI=; b=O97/DWqbCC3QswfJqpTePxTygiht+RmsK1GtLaDFpmXuKEvDzMFUqkA/9nHCAIQnQg aPvcLHwJTx3qU5i+h/DvFuw/bOV9pbb8cdw9M+g9EcukcAJOitvpCQgELwQ0xm4KWh3R 1VS0dyfLkMyWibIelBcYAe1F1LCzMhXVvRfusYPCoud9/yvLhdofF5JRuuMcH5dT7luc omTvtlIu9audWr/UbeJ598WXRD/yEKgKJGqjXTJqLbXSl7KhylYwtzy0yNOBb/8Tuhag d+0JkXBKsKuJoX2tEIo5kdd4e6Yi/DovA4Au3ihRiodJGZdmgdGG3SOUfj4YmdXRBfSD 5MxA== X-Gm-Message-State: AOJu0YwoKjtk2Wz0WC7ijyudgFqn5waLfW/jT+f4RMNXpltOw8CJ98iZ KsS3jeh4te+r0O5zlMSmJVAHTAkOt3vQIFbEzuA= X-Google-Smtp-Source: AGHT+IHr2f0dH0OyvlVLOdTpC+O4spZ4VStdQYuG84x/d/5t5gMYdlvJYfHSMTHmygiJfzGcdJmfwMktQmmU9beAIC4= X-Received: by 2002:a05:6402:332:b0:523:1901:d19c with SMTP id q18-20020a056402033200b005231901d19cmr1501150edw.24.1691659831037; Thu, 10 Aug 2023 02:30:31 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=natanael.copa@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 10 Aug 2023 05:43:22 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:308516 gmane.comp.lib.gnulib.bugs:48139 Archived-At: --0000000000004f529b06028e3f19 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, I had a quick look at the thread, and I have a few comments. 1) it is openrc's bootmisc ( https://github.com/OpenRC/openrc/blob/86efc43d0e0d7569f5d2e7a58b8c461ac9f7d= ae8/init.d/bootmisc.in#L197) that creates /var/run/utmp. There is no guarantee that this exists. You can for example run emacs in a alpine docker container. 2) Even if it does exist, there is no guarantee that the timestamp is correct. There are machines without RTC (Raspberry PI for example), and in this case the time stamp may end up to be the same every reboot (if correctly set up it should save the shutdown time for the reboot and set time to this on next boot, but there is no guarantee). For emacs' use case I'd say the best solution would be to use uptime from sysinfo(2) and assume system time is correct (NTP client should be running at the time emacs is started). -nc On Wed, Aug 9, 2023 at 9:31=E2=80=AFPM Paul Eggert wro= te: > [For those cc'ed, the thread's at .] > > On 2023-08-09 07:29, Bruno Haible wrote: > > > And on Alpine Linux, while /var/run/utmp is empty, its time stamp is > > essentially the boot time. > > > > The approach used by Emacs, namely to look at the time stamp of > > /var/run/random-seed, is therefore essentially one of the best > approaches. > > It just needs to also look at /var/lib/systemd/random-seed and - on > Alpine > > Linux - /var/run/utmp . > > Thanks for looking into this. Clearly Emacs had some catching up to do, > since it was using a location for the random-seed file that current > GNU/Linux distros no longer use. To try to fix this I installed the > attached patch to Emacs master on Savannah. > > This patch does not address the problem for Alpine, nor I suspect for > Android. I suppose Alpine could use the timestamp of /var/run/utmp (or > is that /run/utmp?) but I don't know how 'configure' would reliably > detect it's being built or cross-built for Alpine. I'll cc this to > Natanael Copa, who does the Alpine ports for Emacs, to see whether he > can give advice. > > Also, I don't know how Android records boot time so I'll cc this to Po > Lu, the main developer for Emacs on Android. --=20 Natanael Copa --0000000000004f529b06028e3f19 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, I had a quick look at the threa= d, and I have a few comments.





[For those cc'ed, the thread&#= 39;s at <https://bugs.gnu.org/64937#142>.]

On 2023-08-09 07:29, Bruno Haible wrote:

> And on Alpine Linux, while /var/run/utmp is empty, its time stamp is > essentially the boot time.
>
> The approach used by Emacs, namely to look at the time stamp of
> /var/run/random-seed, is therefore essentially one of the best approac= hes.
> It just needs to also look at /var/lib/systemd/random-seed and - on Al= pine
> Linux - /var/run/utmp .

Thanks for looking into this. Clearly Emacs had some catching up to do, since it was using a location for the random-seed file that current
GNU/Linux distros no longer use. To try to fix this I installed the
attached patch to Emacs master on Savannah.

This patch does not address the problem for Alpine, nor I suspect for
Android. I suppose Alpine could use the timestamp of /var/run/utmp (or
is that /run/utmp?) but I don't know how 'configure' would reli= ably
detect it's being built or cross-built for Alpine. I'll cc this to =
Natanael Copa, who does the Alpine ports for Emacs, to see whether he
can give advice.

Also, I don't know how Android records boot time so I'll cc this to= Po
Lu, the main developer for Emacs on Android.


--
<= div dir=3D"ltr" class=3D"gmail_signature">Natanael Copa
--0000000000004f529b06028e3f19--