[PATCH glibc] Use proc_getchildren_rusage when available in getrusage and times.

2024-02-17 Thread Flavio Cruz
---
 config.h.in|   3 +
 sysdeps/mach/hurd/configure| 174 +
 sysdeps/mach/hurd/configure.ac |  19 
 sysdeps/mach/hurd/getrusage.c  |   8 +-
 sysdeps/mach/hurd/times.c  |  18 +++-
 5 files changed, 219 insertions(+), 3 deletions(-)

diff --git a/config.h.in b/config.h.in
index 44a34072..2f0669e1 100644
--- a/config.h.in
+++ b/config.h.in
@@ -159,6 +159,9 @@
 /* Mach/i386 specific: define if the `i386_set_gdt' RPC is available.  */
 #undef HAVE_I386_SET_GDT
 
+/* Hurd specific; define if the `proc_getchildren_rusage' RPC is available.  */
+#undef HAVE_HURD_PROC_GETCHILDREN_RUSAGE
+
 /* Define if inlined system calls are available.  */
 #undef HAVE_INLINED_SYSCALLS
 
diff --git a/sysdeps/mach/hurd/configure b/sysdeps/mach/hurd/configure
index 33d3e1fc..cd5af1cd 100644
--- a/sysdeps/mach/hurd/configure
+++ b/sysdeps/mach/hurd/configure
@@ -45,6 +45,180 @@ if test "x$libc_cv_hurd_version" != xok; then
   as_fn_error $? "Hurd headers not installed or too old" "$LINENO" 5
 fi
 
+
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles 
long lines and -e" >&5
+printf %s "checking for grep that handles long lines and -e... " >&6; }
+if test ${ac_cv_path_GREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+'') as_dir=./ ;;
+*/) ;;
+*) as_dir=$as_dir/ ;;
+  esac
+for ac_prog in grep ggrep
+   do
+for ac_exec_ext in '' $ac_executable_extensions; do
+  ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"
+  as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+cat "conftest.in" "conftest.in" >"conftest.tmp"
+mv "conftest.tmp" "conftest.in"
+cp "conftest.in" "conftest.nl"
+printf "%s\n" 'GREP' >> "conftest.nl"
+"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" 
>"conftest.out" 2>/dev/null || break
+diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+as_fn_arith $ac_count + 1 && ac_count=$as_val
+if test $ac_count -gt ${ac_path_GREP_max-0}; then
+  # Best one so far, save it but keep looking for a better one
+  ac_cv_path_GREP="$ac_path_GREP"
+  ac_path_GREP_max=$ac_count
+fi
+# 10*(2^10) chars as input seems more than enough
+test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+  $ac_path_GREP_found && break 3
+done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+as_fn_error $? "no acceptable grep could be found in 
$PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+printf "%s\n" "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+printf %s "checking for egrep... " >&6; }
+if test ${ac_cv_path_EGREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+ if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+'') as_dir=./ ;;
+*/) ;;
+*) as_dir=$as_dir/ ;;
+  esac
+for ac_prog in egrep
+   do
+for ac_exec_ext in '' $ac_executable_extensions; do
+  ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
+  as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+cat "conftest.in" "conftest.in" >"conftest.tmp"
+mv "conftest.tmp" "conftest.in"
+cp "conftest.in" "conftest.nl"
+printf "%s\n" 'EGREP' >> "conftest.nl"
+"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || 
break
+diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+as_fn_arith $ac_count + 1 && ac_count=$as_val
+if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+  # Best one so far, save it but keep looking for a better one
+  ac_cv_path_EGREP="$ac_path_EGREP"
+  ac_path_EGREP_max=$ac_count
+fi
+# 10*(2^

Re: [PATCH glibc] Use proc_getchildren_rusage when available in getrusage and times.

2024-02-17 Thread Samuel Thibault
Looks much nicer, applied, thanks! :D

Flavio Cruz, le sam. 17 févr. 2024 11:48:46 -0500, a ecrit:
> ---
>  config.h.in|   3 +
>  sysdeps/mach/hurd/configure| 174 +
>  sysdeps/mach/hurd/configure.ac |  19 
>  sysdeps/mach/hurd/getrusage.c  |   8 +-
>  sysdeps/mach/hurd/times.c  |  18 +++-
>  5 files changed, 219 insertions(+), 3 deletions(-)
> 
> diff --git a/config.h.in b/config.h.in
> index 44a34072..2f0669e1 100644
> --- a/config.h.in
> +++ b/config.h.in
> @@ -159,6 +159,9 @@
>  /* Mach/i386 specific: define if the `i386_set_gdt' RPC is available.  */
>  #undef   HAVE_I386_SET_GDT
>  
> +/* Hurd specific; define if the `proc_getchildren_rusage' RPC is available.  
> */
> +#undef HAVE_HURD_PROC_GETCHILDREN_RUSAGE
> +
>  /* Define if inlined system calls are available.  */
>  #undef HAVE_INLINED_SYSCALLS
>  
> diff --git a/sysdeps/mach/hurd/configure b/sysdeps/mach/hurd/configure
> index 33d3e1fc..cd5af1cd 100644
> --- a/sysdeps/mach/hurd/configure
> +++ b/sysdeps/mach/hurd/configure
> @@ -45,6 +45,180 @@ if test "x$libc_cv_hurd_version" != xok; then
>as_fn_error $? "Hurd headers not installed or too old" "$LINENO" 5
>  fi
>  
> +
> +
> +
> +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles 
> long lines and -e" >&5
> +printf %s "checking for grep that handles long lines and -e... " >&6; }
> +if test ${ac_cv_path_GREP+y}
> +then :
> +  printf %s "(cached) " >&6
> +else $as_nop
> +  if test -z "$GREP"; then
> +  ac_path_GREP_found=false
> +  # Loop through the user's path and test for each of PROGNAME-LIST
> +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
> +do
> +  IFS=$as_save_IFS
> +  case $as_dir in #(((
> +'') as_dir=./ ;;
> +*/) ;;
> +*) as_dir=$as_dir/ ;;
> +  esac
> +for ac_prog in grep ggrep
> +   do
> +for ac_exec_ext in '' $ac_executable_extensions; do
> +  ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"
> +  as_fn_executable_p "$ac_path_GREP" || continue
> +# Check for GNU ac_path_GREP and select it if it is found.
> +  # Check for GNU $ac_path_GREP
> +case `"$ac_path_GREP" --version 2>&1` in
> +*GNU*)
> +  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
> +*)
> +  ac_count=0
> +  printf %s 0123456789 >"conftest.in"
> +  while :
> +  do
> +cat "conftest.in" "conftest.in" >"conftest.tmp"
> +mv "conftest.tmp" "conftest.in"
> +cp "conftest.in" "conftest.nl"
> +printf "%s\n" 'GREP' >> "conftest.nl"
> +"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" 
> >"conftest.out" 2>/dev/null || break
> +diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
> +as_fn_arith $ac_count + 1 && ac_count=$as_val
> +if test $ac_count -gt ${ac_path_GREP_max-0}; then
> +  # Best one so far, save it but keep looking for a better one
> +  ac_cv_path_GREP="$ac_path_GREP"
> +  ac_path_GREP_max=$ac_count
> +fi
> +# 10*(2^10) chars as input seems more than enough
> +test $ac_count -gt 10 && break
> +  done
> +  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
> +esac
> +
> +  $ac_path_GREP_found && break 3
> +done
> +  done
> +  done
> +IFS=$as_save_IFS
> +  if test -z "$ac_cv_path_GREP"; then
> +as_fn_error $? "no acceptable grep could be found in 
> $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
> +  fi
> +else
> +  ac_cv_path_GREP=$GREP
> +fi
> +
> +fi
> +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
> +printf "%s\n" "$ac_cv_path_GREP" >&6; }
> + GREP="$ac_cv_path_GREP"
> +
> +
> +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
> +printf %s "checking for egrep... " >&6; }
> +if test ${ac_cv_path_EGREP+y}
> +then :
> +  printf %s "(cached) " >&6
> +else $as_nop
> +  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
> +   then ac_cv_path_EGREP="$GREP -E"
> +   else
> + if test -z "$EGREP"; then
> +  ac_path_EGREP_found=false
> +  # Loop through the user's path and test for each of PROGNAME-LIST
> +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
> +do
> +  IFS=$as_save_IFS
> +  case $as_dir in #(((
> +'') as_dir=./ ;;
> +*/) ;;
> +*) as_dir=$as_dir/ ;;
> +  esac
> +for ac_prog in egrep
> +   do
> +for ac_exec_ext in '' $ac_executable_extensions; do
> +  ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
> +  as_fn_executable_p "$ac_path_EGREP" || continue
> +# Check for GNU ac_path_EGREP and select it if it is found.
> +  # Check for GNU $ac_path_EGREP
> +case `"$ac_path_EGREP" --version 2>&1` in
> +*GNU*)
> +  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
> +*)
> +  ac_count=0
> +  printf %s 0123456789 >"conftest.in"
> +  while :
> +  do
> +cat "conftest.in" "conftest.in" >"conftest.tmp"
> +mv "conftest.tmp" "conftest.in"
> +cp "conftest.in" "conftest.nl"
> +printf "%s\n" 'EGREP' >> "conftest.nl"
> +"$ac_path_EGREP"

[PATCH glibc] Implement setcontext/getcontext/makecontext/swapcontext for Hurd x86_64

2024-02-17 Thread Flavio Cruz
Tested with the tests provided by glibc plus some other toy examples.
---
 sysdeps/mach/hurd/x86_64/Makefile  |   4 +
 sysdeps/mach/hurd/x86_64/__start_context.S |  49 +
 sysdeps/mach/hurd/x86_64/getcontext.S  |  68 
 sysdeps/mach/hurd/x86_64/makecontext.c | 119 
 sysdeps/mach/hurd/x86_64/setcontext.S  |  96 +
 sysdeps/mach/hurd/x86_64/swapcontext.S | 120 +
 6 files changed, 456 insertions(+)
 create mode 100644 sysdeps/mach/hurd/x86_64/__start_context.S
 create mode 100644 sysdeps/mach/hurd/x86_64/getcontext.S
 create mode 100644 sysdeps/mach/hurd/x86_64/makecontext.c
 create mode 100644 sysdeps/mach/hurd/x86_64/setcontext.S
 create mode 100644 sysdeps/mach/hurd/x86_64/swapcontext.S

diff --git a/sysdeps/mach/hurd/x86_64/Makefile 
b/sysdeps/mach/hurd/x86_64/Makefile
index 80cf2eb6..2b43f5d6 100644
--- a/sysdeps/mach/hurd/x86_64/Makefile
+++ b/sysdeps/mach/hurd/x86_64/Makefile
@@ -3,3 +3,7 @@ ifeq ($(subdir),conform)
 # (missing SA_NOCLDWAIT)
 conformtest-xfail-conds += x86_64-gnu
 endif
+
+ifeq ($(subdir),stdlib)
+sysdep_routines += __start_context
+endif
diff --git a/sysdeps/mach/hurd/x86_64/__start_context.S 
b/sysdeps/mach/hurd/x86_64/__start_context.S
new file mode 100644
index ..3cb4c6b5
--- /dev/null
+++ b/sysdeps/mach/hurd/x86_64/__start_context.S
@@ -0,0 +1,49 @@
+/* Copyright (C) 2024 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#include 
+
+/* This is the helper code which gets called if a function which is
+   registered with 'makecontext' returns.  In this case we have to
+   install the context listed in the uc_link element of the context
+   'makecontext' manipulated at the time of the 'makecontext' call.
+   If the pointer is NULL the process must terminate.  */
+
+
+ENTRY(__start_context)
+   /* This removes the parameters passed to the function given to
+  'makecontext' from the stack.  RBX contains the address
+  on the stack pointer for the next context.  */
+   movq%rbx, %rsp
+
+   /* Don't use pop here so that stack is aligned to 16 bytes.  */
+   movq(%rsp), %rdi/* This is the next context.  */
+   testq   %rdi, %rdi
+   je  2f  /* If it is zero exit.  */
+
+   call__setcontext
+   /* If this returns (which can happen if __sigprocmask fails) we'll
+  exit the program with the return error value (-1).  */
+   movq%rax,%rdi
+
+2:
+   callHIDDEN_JUMPTARGET(exit)
+   /* The 'exit' call should never return.  In case it does cause
+  the process to terminate.  */
+L(hlt):
+   hlt
+END(__start_context)
diff --git a/sysdeps/mach/hurd/x86_64/getcontext.S 
b/sysdeps/mach/hurd/x86_64/getcontext.S
new file mode 100644
index ..ef431be1
--- /dev/null
+++ b/sysdeps/mach/hurd/x86_64/getcontext.S
@@ -0,0 +1,68 @@
+/* Save current context.
+   Copyright (C) 2024 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#include 
+
+#include "ucontext_i.h"
+
+
+ENTRY(__getcontext)
+   /* Save the preserved registers, the registers used for passing
+  args, and the return address.  */
+   movq%rbx, oRBX(%rdi)
+   movq%rbp, oRBP(%rdi)
+   movq%r12, oR12(%rdi)
+   movq%r13, oR13(%rdi)
+   movq%r14, oR14(%rdi)
+   movq%r15, oR15(%rdi)
+
+   movq%rdi, oRDI(%rdi)
+   movq%rsi, oRSI(%rdi)
+   movq%rdx, oRDX(%rdi)
+   movq%rcx, oRCX(%rdi)
+

Re: [PATCH glibc] Implement setcontext/getcontext/makecontext/swapcontext for Hurd x86_64

2024-02-17 Thread Samuel Thibault
Applied, thanks!!

Flavio Cruz, le sam. 17 févr. 2024 15:25:35 -0500, a ecrit:
> Tested with the tests provided by glibc plus some other toy examples.
> ---
>  sysdeps/mach/hurd/x86_64/Makefile  |   4 +
>  sysdeps/mach/hurd/x86_64/__start_context.S |  49 +
>  sysdeps/mach/hurd/x86_64/getcontext.S  |  68 
>  sysdeps/mach/hurd/x86_64/makecontext.c | 119 
>  sysdeps/mach/hurd/x86_64/setcontext.S  |  96 +
>  sysdeps/mach/hurd/x86_64/swapcontext.S | 120 +
>  6 files changed, 456 insertions(+)
>  create mode 100644 sysdeps/mach/hurd/x86_64/__start_context.S
>  create mode 100644 sysdeps/mach/hurd/x86_64/getcontext.S
>  create mode 100644 sysdeps/mach/hurd/x86_64/makecontext.c
>  create mode 100644 sysdeps/mach/hurd/x86_64/setcontext.S
>  create mode 100644 sysdeps/mach/hurd/x86_64/swapcontext.S
> 
> diff --git a/sysdeps/mach/hurd/x86_64/Makefile 
> b/sysdeps/mach/hurd/x86_64/Makefile
> index 80cf2eb6..2b43f5d6 100644
> --- a/sysdeps/mach/hurd/x86_64/Makefile
> +++ b/sysdeps/mach/hurd/x86_64/Makefile
> @@ -3,3 +3,7 @@ ifeq ($(subdir),conform)
>  # (missing SA_NOCLDWAIT)
>  conformtest-xfail-conds += x86_64-gnu
>  endif
> +
> +ifeq ($(subdir),stdlib)
> +sysdep_routines += __start_context
> +endif
> diff --git a/sysdeps/mach/hurd/x86_64/__start_context.S 
> b/sysdeps/mach/hurd/x86_64/__start_context.S
> new file mode 100644
> index ..3cb4c6b5
> --- /dev/null
> +++ b/sysdeps/mach/hurd/x86_64/__start_context.S
> @@ -0,0 +1,49 @@
> +/* Copyright (C) 2024 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   .  */
> +
> +#include 
> +
> +/* This is the helper code which gets called if a function which is
> +   registered with 'makecontext' returns.  In this case we have to
> +   install the context listed in the uc_link element of the context
> +   'makecontext' manipulated at the time of the 'makecontext' call.
> +   If the pointer is NULL the process must terminate.  */
> +
> +
> +ENTRY(__start_context)
> + /* This removes the parameters passed to the function given to
> +'makecontext' from the stack.  RBX contains the address
> +on the stack pointer for the next context.  */
> + movq%rbx, %rsp
> +
> + /* Don't use pop here so that stack is aligned to 16 bytes.  */
> + movq(%rsp), %rdi/* This is the next context.  */
> + testq   %rdi, %rdi
> + je  2f  /* If it is zero exit.  */
> +
> + call__setcontext
> + /* If this returns (which can happen if __sigprocmask fails) we'll
> +exit the program with the return error value (-1).  */
> + movq%rax,%rdi
> +
> +2:
> + callHIDDEN_JUMPTARGET(exit)
> + /* The 'exit' call should never return.  In case it does cause
> +the process to terminate.  */
> +L(hlt):
> + hlt
> +END(__start_context)
> diff --git a/sysdeps/mach/hurd/x86_64/getcontext.S 
> b/sysdeps/mach/hurd/x86_64/getcontext.S
> new file mode 100644
> index ..ef431be1
> --- /dev/null
> +++ b/sysdeps/mach/hurd/x86_64/getcontext.S
> @@ -0,0 +1,68 @@
> +/* Save current context.
> +   Copyright (C) 2024 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   .  */
> +
> +#include 
> +
> +#include "ucontext_i.h"
> +
> +
> +ENTRY(__getcontext)
> + /* Save the preserved registers, the registers used for passing
> +args, and the return address.  */
> + movq%rbx, oRBX(%rdi)
> + movq%rbp, oRBP(

Re: [PATCH hurd] Add proc_getchildren_rusage RPC and track rusage for children and descendants

2024-02-17 Thread Flávio Cruz
Thanks for the reviews, Samuel! Did you forget to push this change? :)

On Fri, Feb 16, 2024 at 8:24 PM Samuel Thibault 
wrote:

> Applied, thanks!
>
> Flavio Cruz, le ven. 16 févr. 2024 13:26:29 -0500, a ecrit:
> > ---
> >  hurd/process.defs | 6 ++
> >  proc/info.c   | 8 
> >  proc/proc.h   | 4 +++-
> >  proc/wait.c   | 2 ++
> >  4 files changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/hurd/process.defs b/hurd/process.defs
> > index 9a8b3a1..007aa2b 100644
> > --- a/hurd/process.defs
> > +++ b/hurd/process.defs
> > @@ -466,3 +466,9 @@ simpleroutine proc_reauthenticate_reassign (
> > that the user has received from auth_user_authenticate call.  */
> >  simpleroutine proc_reauthenticate_complete (
> >   process: process_t);
> > +
> > +/* Returns the rusage information for the children that were waited
> > + * for plus all their descendants.  */
> > +routine proc_getchildren_rusage (
> > + process: process_t;
> > + out children_rusage: rusage_t);
> > diff --git a/proc/info.c b/proc/info.c
> > index 2d85662..e5b0f47 100644
> > --- a/proc/info.c
> > +++ b/proc/info.c
> > @@ -1093,3 +1093,11 @@ S_proc_get_exe (struct proc *callerp,
> >return 0;
> >  }
> >
> > +kern_return_t
> > +S_proc_getchildren_rusage (struct proc *p, struct rusage *ru)
> > +{
> > +  if (!p)
> > +return EOPNOTSUPP;
> > +  *ru = p->p_child_rusage;
> > +  return 0;
> > +}
> > diff --git a/proc/proc.h b/proc/proc.h
> > index a83a509..bbba095 100644
> > --- a/proc/proc.h
> > +++ b/proc/proc.h
> > @@ -76,7 +76,9 @@ struct proc
> >int p_sigcode;
> >struct rusage p_rusage;/* my usage if I'm dead, to return via
> wait */
> >
> > -  struct rusage p_child_rusage;  /* accumulates p_rusage of all
> dead children */
> > +  /* Accumulates p_rusage of all dead children, including
> > +   * grandchildren and their descendants.  */
> > +  struct rusage p_child_rusage;
> >
> >unsigned int p_exec:1; /* has called proc_mark_exec */
> >unsigned int p_stopped:1;  /* has called proc_mark_stop */
> > diff --git a/proc/wait.c b/proc/wait.c
> > index 4551d28..a31b0e7 100644
> > --- a/proc/wait.c
> > +++ b/proc/wait.c
> > @@ -156,6 +156,8 @@ alert_parent (struct proc *p)
> >  {
> >/* We accumulate the aggregate usage stats of all our dead children.
> */
> >rusage_add (&p->p_parent->p_child_rusage, &p->p_rusage);
> > +  /* ... and descendants.  */
> > +  rusage_add (&p->p_parent->p_child_rusage, &p->p_child_rusage);
> >
> >send_signal (p->p_parent->p_msgport, SIGCHLD, CLD_EXITED,
> p->p_parent->p_task);
> >
> > --
> > 2.39.2
> >
> >
>
> --
> Samuel
> ---
> Pour une évaluation indépendante, transparente et rigoureuse !
> Je soutiens la Commission d'Évaluation de l'Inria.
>


Re: [PATCH hurd] Add proc_getchildren_rusage RPC and track rusage for children and descendants

2024-02-17 Thread Samuel Thibault
Flávio Cruz, le sam. 17 févr. 2024 16:56:48 -0500, a ecrit:
> Thanks for the reviews, Samuel! Did you forget to push this change? :)

For this one, perhaps, but with the second one, both went in :)

Samuel