Re: [PATCH] drop the deprecated malloc/free hooks in hurd/mach-defpager

2016-05-26 Thread Justus Winter
Quoting Justus Winter (2016-05-18 13:27:13)
> > Backing up one step: what is actually being done here in mach-defpager?
> > Again from just a quick look, is the idea to use wired memory for all of
> > mach-defpager's process memory?

Yes, wiring the memory is required to avoid deadlocks [0].

0: 
http://darnassus.sceen.net/~rbraun/hurd_related_papers/mach/moving_the_default_memory_manager_out_of_the_mach_kernel.pdf

> > So, for example, if now some mach-defpager code calls calloc, it will now
> > get non-wired "glibc" memory instead of wired "kalloc" memory.  The
> > problem here is not mach-defpager's own code (which we can easily
> > verify/control), but the problems is the libraries it links against,
> > which currently are: libihash, libpthread, glibc itself, and any
> 
> And indeed libihash uses calloc.
> 
> > dependencies these may have.  Can we be sure these are not internally
> > using calloc, for example?
> > 
> > Now, this is not a new problem that you introduced ;-) -- previously we
> > also didn't provide malloc's memalign and realloc hooks, and realloc is
> > used quite commonly, I suppose?
> > 
> > If my theories are correct, do we need to use a different mechanism to
> > get the whole mach-defpager process into wired memory?
> 
> As Richard said in #hurd, implement mlockall and MCL_FUTURE and just
> use the default allocator.
> 
> I'd suggest reverting that change, or is the removal of that
> deprecated interface imminent?

Wdyt?

Cheers,
Justus



Re: [PATCH] libhurdutil: New library containing utils to be used by Guix.

2016-05-26 Thread Justus Winter
Quoting manolis...@gmail.com (2016-05-25 17:05:56)
> 
> I am resending the patch from 
> https://lists.gnu.org/archive/html/bug-hurd/2016-05/msg00040.html modified to 
> apply on master. 

git send-email --in-reply-to=MSGIDGOESHERE is your friend ;)

Justus



Re: [PATCH] libhurdutil: New library containing utils to be used by Guix.

2016-05-26 Thread Justus Winter
Hi :)

Quoting manolis...@gmail.com (2016-05-25 17:05:57)
> From: Manolis Ragkousis 
> 
> * libhurdutil/hurdutil.h: New file.
> * libhurdutil/settrans.c: New file.
> * libhurdutil/Makefile: New file.
> * utils/Makefile (HURDLIBS, settrans): Use the new library.
> * utils/settrans.c: Update to use the new library.
> * Makefile: (lib-subdirs): Add library.
> ---
>  Makefile   |   2 +-
>  libhurdutil/Makefile   |  28 +++
>  libhurdutil/hurdutil.h |  78 
>  libhurdutil/settrans.c | 377 +++
>  utils/Makefile |   4 +-
>  utils/settrans.c   | 475 
> +++--
>  6 files changed, 594 insertions(+), 370 deletions(-)
>  create mode 100644 libhurdutil/Makefile
>  create mode 100644 libhurdutil/hurdutil.h
>  create mode 100644 libhurdutil/settrans.c
> 
> diff --git a/Makefile b/Makefile
> index d48baaa..e712767 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -29,7 +29,7 @@ include ./Makeconf
>  lib-subdirs = libshouldbeinlibc libihash libiohelp libports libthreads \
>   libpager libfshelp libdiskfs libtrivfs libps \
>   libnetfs libpipe libstore libhurdbugaddr libftpconn libcons \
> - libhurd-slab
> + libhurd-slab libhurdutil
>  
>  # Hurd programs
>  prog-subdirs = auth proc exec term \
> diff --git a/libhurdutil/Makefile b/libhurdutil/Makefile
> new file mode 100644
> index 000..2e0e642
> --- /dev/null
> +++ b/libhurdutil/Makefile
> @@ -0,0 +1,28 @@
> +#   Copyright (C) 2016 Free Software Foundation, Inc.
> +#
> +#   This file is part of the GNU Hurd.
> +#
> +#   The GNU Hurd is free software; you can redistribute it and/or
> +#   modify it under the terms of the GNU General Public License as
> +#   published by the Free Software Foundation; either version 2, or (at
> +#   your option) any later version.
> +#
> +#   The GNU Hurd 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
> +#   General Public License for more details.
> +#
> +#   You should have received a copy of the GNU General Public License
> +#   along with this program; if not, write to the Free Software
> +#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

This is an old license template, the current one doesn't list a
snailmail address, but some URL.

> +
> +dir := libhurdutil
> +makemode := library
> +
> +libname := libhurdutil
> +SRCS = settrans.c
> +installhdrs = hurdutil.h
> +
> +OBJS = $(SRCS:.c=.o)
> +
> +include ../Makeconf
> diff --git a/libhurdutil/hurdutil.h b/libhurdutil/hurdutil.h
> new file mode 100644
> index 000..5786cff
> --- /dev/null
> +++ b/libhurdutil/hurdutil.h
> @@ -0,0 +1,78 @@
> +/* hurdutil.h - Hurd utils interface.
> +   Copyright (C) 2016 Free Software Foundation, Inc.
> +   Written by Manolis Fragkiskos Ragkousis .
> +
> +   This file is part of the GNU Hurd.
> +
> +   The GNU Hurd is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU General Public License as
> +   published by the Free Software Foundation; either version 2, or (at
> +   your option) any later version.
> +
> +   The GNU Hurd 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
> +   General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with the GNU Hurd; if not, write to the Free Software
> +   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
> +
> +#ifndef _HURD_UTIL_H
> +#define _HURD_UTIL_H
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +

As Guillem noted, we might want to change the way options are passed
into the library.  Let's see...

> +struct settrans_flags
> +{
> +  /* The name of the node we're putting the translator on. */
> +  char *node_name;
> +
> +  /* Flags to pass to file_set_translator.  */
> +  int lookup_flags;
> +  int goaway_flags;

These two contain ORed flags.

> +  /* Various option flags.  */
> +  int passive;
> +  int active;
> +  int keep_active;
> +  int pause;
> +  int kill_active;
> +  int orphan;
> +  int start;
> +  int stack;
> +  int excl;
> +  int timeout;

These are boolean, and the idiomatic way would be to OR some constants
containing powers of two together.  Or use a bitfield, that might be
more modern, I don't know.

> +  char *pid_file;
> +  char *underlying_node_name;
> +  int underlying_lookup_flags;
> +  char **chroot_command;
> +  char *chroot_chdir;
> +
> +  /* The translator's arg vector, in '\0' separated format.  */
> +  char *argz;
> +  size_t argz_len;
> +};

So only using bitflags is not enough, we have plenty of other kind of
options.  Maybe we shouldn't call it 'settrans_flags' then, mayb