GNU bug report logs - #77943
[PATCH 0/2] Using the Shepherd's system log on the Hurd

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Sun, 20 Apr 2025 15:54:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 77943 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to janneke <at> gnu.org, guix-patches <at> gnu.org:
bug#77943; Package guix-patches. (Sun, 20 Apr 2025 15:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to janneke <at> gnu.org, guix-patches <at> gnu.org. (Sun, 20 Apr 2025 15:54:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: guix-patches <at> gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>,
 Yelninei <yelninei <at> tutamail.com>
Subject: [PATCH 0/2] Using the Shepherd's system log on the Hurd
Date: Sun, 20 Apr 2025 17:52:37 +0200
Hello!

This changes the Hurd to use the Shepherd’s system log instead of
syslogd from Inetutils, as is already the case on Linux.  I wanted
to try now that Yelninei and I have addressed most of the issues
they reported in this area: <https://issues.guix.gnu.org/77634>.

It works, but maybe we should hold on a bit though, because of this:

--8<---------------cut here---------------start------------->8---
shepherd[1]: GNU Shepherd 1.0.4 (Guile 3.0.9, i586-pc-gnu)
shepherd[1]: Starting service root...
[…]
shepherd[1]: Service root-file-system running with value #t.
shepherd[1]: Service root-file-system has been started.
Uncaught exception in task:
In fibers.scm:
    172:8  7 (_)
In shepherd/service/system-log.scm:
    240:7  6 (run-system-log #<<channel> getq: #<atomic-box 33088d0?> ?)
In ice-9/suspendable-ports.scm:
   681:11  5 (read-delimited _ _ _)
    613:2  4 (read-char _)
   184:27  3 (fill-input #<input: /dev/klog 44> _ _)
     72:4  2 (read-bytes #<input: /dev/klog 44> #vu8(51 98 120 121 ?) ?)
In unknown file:
           1 (port-read #<input: /dev/klog 44> #vu8(51 98 120 121 ?) ?)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure fport_read: (os/device) operation would block
--8<---------------cut here---------------end--------------->8---

It’s non-fatal but I think everything going to /dev/log after that
is dismissed—IOW, the system log doesn’t log anything.  There’s also
the "\0" sender that appears in /var/log/messages: it works, but it’s
not nice.

I reported it on bug-hurd and hopefully it has an easy solution.

Ludovic Courtès (2):
  services: shepherd: Provide the right #:kernel-log-file on the Hurd.
  system: hurd: Switch to the Shepherd’s system log.

 gnu/services/shepherd.scm | 9 +++++++++
 gnu/system/hurd.scm       | 4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)


base-commit: d14663b94a7428eccbfa27aa620dc3d8ba67d752
-- 
2.49.0





Information forwarded to guix-patches <at> gnu.org:
bug#77943; Package guix-patches. (Sun, 20 Apr 2025 15:56:04 GMT) Full text and rfc822 format available.

Message #8 received at 77943 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 77943 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>,
 Yelninei <yelninei <at> tutamail.com>
Subject: [PATCH 1/2] services: shepherd: Provide the right #:kernel-log-file
 on the Hurd.
Date: Sun, 20 Apr 2025 17:54:46 +0200
* gnu/services/shepherd.scm (shepherd-system-log-service-type):
Pass #:kernel-log-file.

Reported-by: Yelninei <yelninei <at> tutamail.com>
Change-Id: I6f7a4b4e8e69a116069886e3879400d600645b30
---
 gnu/services/shepherd.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index c8e01c9d83..156a36c2da 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -781,6 +781,15 @@ (define shepherd-system-log-service-type
                                     (#f #~())
                                     (value #~(#:message-destination #$value)))
 
+                               ;; The Shepherd <= 1.0.4 chooses /proc/kmsg
+                               ;; unconditionally.  Fix that.
+                               #:kernel-log-file
+                               (cond ((string-contains %host-type "linux") ;Linux
+                                      "/proc/kmsg")
+                                     ((string-suffix? "-gnu" %host-type) ;GNU/Hurd
+                                      "/dev/klog")
+                                     (else #f))
+
                                #:date-format #$date-format
                                #:history-size #$history-size
                                #:max-silent-time #$max-silent-time)))))
-- 
2.49.0





Information forwarded to janneke <at> gnu.org, guix-patches <at> gnu.org:
bug#77943; Package guix-patches. (Sun, 20 Apr 2025 15:56:05 GMT) Full text and rfc822 format available.

Message #11 received at 77943 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 77943 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH 2/2] system: hurd: Switch to the Shepherd’s system log.
Date: Sun, 20 Apr 2025 17:54:47 +0200
This is a followup to 8492a3c8962664db4bd0e7475f63be0ef59db87a.

* gnu/system/hurd.scm (%base-services/hurd): Replace
‘syslog-service-type’ by ‘shepherd-system-log-service-type’.

Change-Id: I3e12087a04f06210bd10b649b29fcf9949c5aa35
---
 gnu/system/hurd.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/system/hurd.scm b/gnu/system/hurd.scm
index c9df366f24..96b6a9a290 100644
--- a/gnu/system/hurd.scm
+++ b/gnu/system/hurd.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2020-2024 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2020-2025 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2020, 2023, 2024 Janneke Nieuwenhuizen <janneke <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -100,7 +100,7 @@ (define %base-services/hurd
                          `(("/bin/sh" ,(file-append bash "/bin/sh"))
                            ("/usr/bin/env" ,(file-append coreutils
                                                          "/bin/env"))))
-                (service syslog-service-type))
+                (service shepherd-system-log-service-type))
           (map (lambda (n)
                  (service hurd-getty-service-type
                           (hurd-getty-configuration
-- 
2.49.0





Information forwarded to guix-patches <at> gnu.org:
bug#77943; Package guix-patches. (Mon, 02 Jun 2025 14:36:02 GMT) Full text and rfc822 format available.

Message #14 received at 77943 <at> debbugs.gnu.org (full text, mbox):

From: yelninei <at> tutamail.com
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 77943 <77943 <at> debbugs.gnu.org>
Subject: Re: [PATCH 1/2] services: shepherd: Provide the right
 #:kernel-log-file on the Hurd.
Date: Mon, 2 Jun 2025 16:35:42 +0200 (CEST)
Hi Ludo,

I am a bit late to this:

Does it still make sense to duplicate the default kernel-log-file in guix and shepherd now that 1.0.5 is available?

The issue with ED_WOULD_BLOCK is still present on hurd-0.9.git20250420 on core-packages-team. 
I tried it for a while with #:kernel-log-file set to #f and it felt like it was slowing down shepherd significantly enough to be mildly annoying but idk if this is something I only noticed because I was actively looking for changes.


Apr 20, 2025, 15:54 by ludo <at> gnu.org:

> * gnu/services/shepherd.scm (shepherd-system-log-service-type):
> Pass #:kernel-log-file.
>
> Reported-by: Yelninei <yelninei <at> tutamail.com>
> Change-Id: I6f7a4b4e8e69a116069886e3879400d600645b30
> ---
> gnu/services/shepherd.scm | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
> index c8e01c9d83..156a36c2da 100644
> --- a/gnu/services/shepherd.scm
> +++ b/gnu/services/shepherd.scm
> @@ -781,6 +781,15 @@ (define shepherd-system-log-service-type
> (#f #~())
> (value #~(#:message-destination #$value)))
>
> +                               ;; The Shepherd <= 1.0.4 chooses /proc/kmsg
> +                               ;; unconditionally.  Fix that.
> +                               #:kernel-log-file
> +                               (cond ((string-contains %host-type "linux") ;Linux
> +                                      "/proc/kmsg")
> +                                     ((string-suffix? "-gnu" %host-type) ;GNU/Hurd
> +                                      "/dev/klog")
> +                                     (else #f))
> +
> #:date-format #$date-format
> #:history-size #$history-size
> #:max-silent-time #$max-silent-time)))))
> --
> 2.49.0
>





Information forwarded to guix-patches <at> gnu.org:
bug#77943; Package guix-patches. (Mon, 02 Jun 2025 16:10:03 GMT) Full text and rfc822 format available.

Message #17 received at 77943 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: yelninei <at> tutamail.com
Cc: 77943 <77943 <at> debbugs.gnu.org>
Subject: Re: [PATCH 1/2] services: shepherd: Provide the right
 #:kernel-log-file on the Hurd.
Date: Mon, 02 Jun 2025 17:01:37 +0200
Hi,

yelninei <at> tutamail.com writes:

> Does it still make sense to duplicate the default kernel-log-file in guix and shepherd now that 1.0.5 is available?

No, it’s no longer necessary.

> The issue with ED_WOULD_BLOCK is still present on hurd-0.9.git20250420 on core-packages-team. 

Right, I started looking into it back then but then didn’t take the time
to track it down.

> I tried it for a while with #:kernel-log-file set to #f and it felt
> like it was slowing down shepherd significantly enough to be mildly
> annoying but idk if this is something I only noticed because I was
> actively looking for changes.

How did you notice that it was slowing down?  That was with 1.0.5,
right?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#77943; Package guix-patches. (Mon, 02 Jun 2025 20:03:02 GMT) Full text and rfc822 format available.

Message #20 received at 77943 <at> debbugs.gnu.org (full text, mbox):

From: yelninei <at> tutamail.com
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 77943 <77943 <at> debbugs.gnu.org>
Subject: Re: [PATCH 1/2] services: shepherd: Provide the right
 #:kernel-log-file on the Hurd.
Date: Mon, 2 Jun 2025 22:02:01 +0200 (CEST)
Hello,

Jun 2, 2025, 16:09 by ludo <at> gnu.org:

> The issue with ED_WOULD_BLOCK is still present on hurd-0.9.git20250420 on core-packages-team. 
>
> Right, I started looking into it back then but then didn’t take the time
> to track it down.
>
>> I tried it for a while with #:kernel-log-file set to #f and it felt
>> like it was slowing down shepherd significantly enough to be mildly
>> annoying but idk if this is something I only noticed because I was
>> actively looking for changes.
>>
>
> How did you notice that it was slowing down?  That was with 1.0.5,
> right?
>

I dont know if I am just imagining this but anything ssh related felt a bit laggy but idk how the syslog should cause this except that sshd logs to syslog and shepherd is also managing the sshd socket.

 Also things like herd status felt a lot slower.

But all of this was not really consistent and I dont know if I am just making this up so this might be all wrong.
No this was all with 1.0.4, tested this on master around when you sent the initial version. And on core-packages-team shepherd is still 1.0.4.

> Thanks,
> Ludo’.
>





Information forwarded to guix-patches <at> gnu.org:
bug#77943; Package guix-patches. (Tue, 10 Jun 2025 09:52:03 GMT) Full text and rfc822 format available.

Message #23 received at 77943 <at> debbugs.gnu.org (full text, mbox):

From: yelninei <at> tutamail.com
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 77943 <77943 <at> debbugs.gnu.org>
Subject: Re: [PATCH 1/2] services: shepherd: Provide the right
 #:kernel-log-file on the Hurd.
Date: Tue, 10 Jun 2025 11:50:27 +0200 (CEST)
Hello Ludo,


Jun 2, 2025, 16:09 by ludo <at> gnu.org:

> Hi,
>
> Right, I started looking into it back then but then didn’t take the time
> to track it down.
>

I tried your patch that you sent to bug-hurd but I still end up with D_WOULD_BLOCK at the end. Was it working for you?

As pointed out by Samuel on bug-hurd the initial "if (err) return err" looks weird. I tried removing it and at the end of /dev/klog it died with SIGLOST.

I then tried this patch similar to yours to intercept D_WOULD_BLOCK at the beginning instead:

diff --git a/trans/streamio.c b/trans/streamio.c
index e42ff908..ee3cf9b4 100644
--- a/trans/streamio.c
+++ b/trans/streamio.c
@@ -1005,7 +1005,12 @@ dev_read (size_t amount, void **buf, size_t *len, int nowait)
   size_t max, avail;
 
   if (err)
-    return err;
+    {
+      if (err == D_WOULD_BLOCK)
+	  return EWOULDBLOCK;
+      else
+	  return err;
+    }
 
   while (!buffer_readable (input_buffer))
     {

and my example now fails with EAGAIN.

I am not sure yet what is setting this, the joy of global variables.

However something still seems wrong when I added back the shepherd syslog. It still crashes/hangs when it reaches the initial end of /dev/klog and does not process messages further: 
there is an extra message and e.g. sshd messages to the syslog dont get processed.

root <at> childhurd ~# ./main
irq handler [11]: new delivery port f5e44038 entry f4f39840

errno: Resource temporarily unavailable

To be continued.

Note: I had to add the patch to the default hurd and just patching the hurd package that is used in operating-system-hurd was not enough. Dont know what is up with that.

> Thanks,
> Ludo’.
>





Information forwarded to guix-patches <at> gnu.org:
bug#77943; Package guix-patches. (Tue, 10 Jun 2025 12:56:02 GMT) Full text and rfc822 format available.

Message #26 received at 77943 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: yelninei <at> tutamail.com
Cc: 77943 <77943 <at> debbugs.gnu.org>
Subject: Re: [PATCH 1/2] services: shepherd: Provide the right
 #:kernel-log-file on the Hurd.
Date: Tue, 10 Jun 2025 14:46:44 +0200
Hi Yelninei,

yelninei <at> tutamail.com writes:

> I tried your patch that you sent to bug-hurd but I still end up with D_WOULD_BLOCK at the end. Was it working for you?

No no, it wasn’t, but I haven’t taken the time to dig further.

> As pointed out by Samuel on bug-hurd the initial "if (err) return err" looks weird. I tried removing it and at the end of /dev/klog it died with SIGLOST.

[...]

> and my example now fails with EAGAIN.

I’m not sure what example but EAGAIN is fine, it’s what we want.

Thanks for investigating!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#77943; Package guix-patches. (Tue, 10 Jun 2025 14:57:04 GMT) Full text and rfc822 format available.

Message #29 received at 77943 <at> debbugs.gnu.org (full text, mbox):

From: yelninei <at> tutamail.com
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 77943 <77943 <at> debbugs.gnu.org>
Subject: Re: [PATCH 1/2] services: shepherd: Provide the right
 #:kernel-log-file on the Hurd.
Date: Tue, 10 Jun 2025 16:56:38 +0200 (GMT+02:00)
Hello,


Jun 10, 2025, 12:55 by ludo <at> gnu.org:

> Hi Yelninei,
>
> yelninei <at> tutamail.com writes:
>
>> I tried your patch that you sent to bug-hurd but I still end up with D_WOULD_BLOCK at the end. Was it working for you?
>>
>
> No no, it wasn’t, but I haven’t taken the time to dig further.
>
>> As pointed out by Samuel on bug-hurd the initial "if (err) return err" looks weird. I tried removing it and at the end of /dev/klog it died with SIGLOST.
>>
>
> [...]
>
>> and my example now fails with EAGAIN.
>>
>
> I’m not sure what example but EAGAIN is fine, it’s what we want.
>

The example is just some terrible C code that runs fgets in a loop.

When I try something similar with guile and (@ (ice-9 rdelim) read-line) it seems to block forever at the "last" line.
 From the C example that last line seems to be missing a terminating newline and I am thinking read-line cannot handle this situation when the deliminator is just EAGAIN so the port is never handed of to fibers (fport_read which was erroring before seems to return -1  in this case as a ssize_t cast to size_t which also seems wrong ).

Further investigation required.
> Thanks for investigating!
>
> Ludo’.
>
Yelninei




This bug report was last modified 9 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.