From: Paul Eggert <eggert@cs.ucla.edu>
To: Bruno Haible <bruno@clisp.org>
Cc: "Robert Pluim" <rpluim@gmail.com>,
bug-gnulib@gnu.org, "Pádraig Brady" <P@draigbrady.com>,
"Sven Joachim" <svenjoac@gmx.de>,
64937@debbugs.gnu.org, "Natanael Copa" <natanael.copa@gmail.com>,
"Po Lu" <luangruo@yahoo.com>,
"Emacs Development" <Emacs-devel@gnu.org>,
"Thorsten Kukuk" <kukuk@suse.com>
Subject: Re: boot time on Linux
Date: Wed, 9 Aug 2023 12:31:46 -0700 [thread overview]
Message-ID: <c8c927bb-5e44-f26d-837e-ae6b73e60add@cs.ucla.edu> (raw)
In-Reply-To: <3732835.vtg8X0x55z@nimes>
[-- Attachment #1: Type: text/plain, Size: 1203 bytes --]
[For those cc'ed, the thread'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 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.
[-- Attachment #2: 0001-Adjust-to-random-seed-move.patch --]
[-- Type: text/x-patch, Size: 3400 bytes --]
From cc0a30a876adffa5ec110df9f4e0f21097f6d73e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 9 Aug 2023 12:06:25 -0700
Subject: [PATCH] Adjust to random-seed move
For some time, GNU/Linux systems have put their random-seed file
somewhere other than where src/filelock.c looks for it.
Catch up to this by having 'configure' scout for it.
* configure.ac (BOOT_TIME_FILE):
Define this at configure-time.
* nt/inc/ms-w32.h (BOOT_TIME_FILE): Override 'configure'.
* src/filelock.c (BOOT_TIME_FILE): Remove default definition,
since 'configure' defaults it now.
---
configure.ac | 31 +++++++++++++++++++++++++++++++
nt/inc/ms-w32.h | 1 +
src/filelock.c | 6 ------
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6e080c1c666..56c8cf1ae05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2625,6 +2625,37 @@ AC_DEFUN
fi
AC_SUBST([AUTO_DEPEND])
+AC_CACHE_CHECK([for old but post-boot file],
+ [emacs_cv_boot_time_file],
+ [AS_CASE([$opsys],
+ [*bsd|darwin|dragonfly],
+ [emacs_cv_boot_time_file='not needed'],
+ [emacs_cv_boot_time_file=unknown
+ AS_IF([test $cross_compiling = no],
+ [# systemd puts it in /var/lib/systemd.
+ # initscripts puts it in /var/lib/urandom (previously /var/lib).
+ # Linux drivers/char/random.c before 2022-02-21 suggests /var/run.
+ for file in \
+ /var/lib/systemd/random-seed \
+ /var/lib/urandom/random-seed \
+ /var/lib/random-seed \
+ /var/run/random-seed
+ do
+ test -f $file && { emacs_cv_boot_time_file=$file; break; }
+ done])])])
+AS_CASE([$emacs_cv_boot_time_file],
+ [/*|*:*], [BOOT_TIME_FILE=\"$emacs_cv_boot_time_file\"],
+ [NULL|nullptr|0], [BOOT_TIME_FILE=$emacs_cv_boot_time_file],
+ ['not needed'], [BOOT_TIME_FILE=NULL],
+ [# Guess systemd if unknown.
+ # If guess is wrong, Emacs falls back on something else.
+ BOOT_TIME_FILE=\"/var/lib/systemd/random-seed\"])
+AC_DEFINE_UNQUOTED([BOOT_TIME_FILE], [$BOOT_TIME_FILE],
+ [Name of file that, if it exists, postdates boot and predates
+ the first Emacs invocation; or a null pointer if no such file is known.
+ This file is used only on GNU/Linux and other systems
+ that lack the FreeBSD-style sysctl with KERN_BOOTTIME.])
+
#### Choose a window system.
## We leave window_system equal to none if
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index 58be1199345..b23fd5030fa 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -121,6 +121,7 @@ #define HAVE_C99_STRTOLD 1
the output, but that's gross. So this should do; if the file is
not there, the boot time will be returned as zero, and filelock.c
already handles that. */
+#undef BOOT_TIME_FILE
#define BOOT_TIME_FILE "C:/pagefile.sys"
/* ============================================================ */
diff --git a/src/filelock.c b/src/filelock.c
index 66b8fd2ceac..0ad130353f3 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -59,12 +59,6 @@ Copyright (C) 1985-1987, 1993-1994, 1996, 1998-2023 Free Software
#include <utmp.h>
#endif
-/* A file whose last-modified time is just after the most recent boot.
- Define this to be NULL to disable checking for this file. */
-#ifndef BOOT_TIME_FILE
-#define BOOT_TIME_FILE "/var/run/random-seed"
-#endif
-
/* Boot time is not available on Android. */
#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY
--
2.39.2
next parent reply other threads:[~2023-08-09 19:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87tttmpt5h.fsf@turtle.gmx.de>
[not found] ` <20230808173430.GA27131@suse.com>
[not found] ` <26226778.6c9BZvbsD2@nimes>
[not found] ` <3732835.vtg8X0x55z@nimes>
2023-08-09 19:31 ` Paul Eggert [this message]
2023-08-09 21:06 ` boot time on Linux Bruno Haible
2023-08-09 23:53 ` Po Lu
2023-08-10 0:14 ` Bruno Haible
2023-08-10 2:14 ` Po Lu
2023-08-10 6:22 ` Paul Eggert
2023-08-10 6:58 ` Po Lu
2023-08-10 10:30 ` Bruno Haible
2023-08-10 12:23 ` bug#64937: " Po Lu via GNU coreutils Bug Reports
2023-08-10 12:25 ` Bruno Haible
2023-08-10 13:04 ` Po Lu
2023-08-10 14:12 ` Bruno Haible
2023-08-11 8:27 ` Po Lu
2023-08-10 9:30 ` Natanael Copa
2023-08-10 9:38 ` Po Lu
2023-08-10 10:05 ` Natanael Copa
2023-08-10 15:30 ` Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c8c927bb-5e44-f26d-837e-ae6b73e60add@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=64937@debbugs.gnu.org \
--cc=Emacs-devel@gnu.org \
--cc=P@draigbrady.com \
--cc=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=kukuk@suse.com \
--cc=luangruo@yahoo.com \
--cc=natanael.copa@gmail.com \
--cc=rpluim@gmail.com \
--cc=svenjoac@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.