[systemd-devel] [PATCH 1/2] RFC: journald: Allow to cache the cg_get_root_path

Lennart Poettering lennart at poettering.net
Mon Jul 15 18:26:56 PDT 2013


On Mon, 08.07.13 18:39, Karol Lewandowski (k.lewandowsk at samsung.com) wrote:

> 
> On 06/27/2013 06:30 PM, Holger Hans Peter Freyther wrote:
> > From: Holger Hans Peter Freyther <holger at moiji-mobile.com>
> > 
> > Allow to cache the cg_get_root_path and introduce a new method
> > cg_pid_get_path_shifted_with_root that can use the cached version
> > instead of allocating a new string.
> 
> My 2c,
> 
> I have been thinking about something similar albeit a bit more
> generic.
> 
> According to my analysis /proc access is costly and it would
> be best to cache the result for later use.  Difficulty comes
> from trying to keep cache up to date, though.

We can't really cache this. This stuff is already racy, as by the time
we read the attributes the process might already be gone.

I think the best way to deal with the performance issue here is the
stuff discussed here:

https://bugzilla.redhat.com/show_bug.cgi?id=963620

i.e. just have the kernel augment our messages with the data we need,
unconditionally. That way we fix both the race issue, and the
performance issue, since the data is just there and we can make use of
it without any further work.

> I've just started looking into connector's cn_proc which _seem_
> to offer all the required functionality (fork, exec, exit
> notifications).  I have to finish my prototype to verify if
> it's worth complications it brings.

cn_proc is asynchronous, so you get even more race problems like this,
where processes are already gone by the time you get the message about
them.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list