[systemd-devel] [Patch 0/5] support for logging the unit of user session units

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Fri Jan 18 09:04:50 PST 2013


On Fri, Jan 18, 2013 at 10:40:18AM +0100, Mirco Tischler wrote:
> 2013/1/18 Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
> 
> > Hi,
> > I had a look at the your patches (without actually running them :).
> > I started with a few cleanups, I'll post them as replies to this letter.
> > Then I had a better look at the logic of USER_UNIT and I have a few
> > questions.
> >
> > Hi
> Thanks for having a look.
> 
> > -#define log_full_unit(level, unit, ...) log_meta_object(level,
> > __FILE__, __LINE__, __func__, "UNIT=", unit, __VA_ARGS__)
> > +#define log_full_unit(level, unit, ...) log_meta_object(level, __FILE__,
> > __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit,
> > __VA_ARGS__)
> > +#define log_struct_unit(level, unit, ...) log_struct(level, getpid() == 1
> > ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__)
> 
> Are all those calls to getpid() efficient? Is the result cached or does
> > each one generate a system call?
> >
> >  According to man 2 getpid the result is cached, which btw Linus calls a
> "totally useless optimization" ;)
> http://yarchive.net/comp/linux/getpid_caching.html

Hi,
committed this now. Everything looks OK.

> +        if (!endswith(unit, ".service") &&
> > +            !endswith(unit, ".socket") &&
> > +            !endswith(unit, ".mount") &&
> > +            !endswith(unit, ".swap"))
> > +                return 0;
> >
> > +        if (!endswith(unit, ".service") &&
> > +            !endswith(unit, ".socket"))
> >
> > Do those conditions make sense? Aren't the messages logged for
> > all types of units (at least under debug or error conditions)
> > by systemd itself?
>
> The the first four conditions already exist in the current code. I wasn't
> sure if they make sense either but left them in place for now or rather
> removed mount and swap units for the user session.
I guess that this is subject for a separate patch.

Zbyszek


More information about the systemd-devel mailing list