[systemd-devel] [PATCH 0/2] RFC for avoid dynamic allocation in journald

Holger Hans Peter Freyther holger at freyther.de
Sat Apr 6 01:20:33 PDT 2013


The following two patches are compile tested only. The first one is
to avoid work when systemd is compiled without audit support. The
second is starting to remove dynamic allocations from the
dispatch_message_real method.



Variables that can easily be statically allocated:
_SYSTEMD_OWNER_UID
_SOURCE_REALTIME_TIMESTAMP


Variables that could benefit from a 'head room' (think of skb or
msgb in Osmocom):
_COMM
_EXE
_CMDLINE
_SYSTEMD_CGROUP
_SYSTEMD_UNIT
_SYSTEMD_USER_UNIT
_HOSTNAME

E.g. 

	r = get_process_comm(ucred->pid, &t);
        if (r >= 0) {
        	comm = strappend("_COMM=", t);
                free(t);

                if (comm)
                	IOVEC_SET_STRING(iovec[n++], comm);
        }

could become..

	r = get_process_comm_hr(ucred->pid, &t, STATIC_STRLEN("_COMM="));
	if (r >= 0) {
		PREPEND("_COMM=", t);
		IOVEC_SET_STRING(iovec[n++], t);
	}

or...

	r = get_process_comm_prep(ucred->pid, &t, "_COMM=");
	if (r >= 0) 
		IOVEC_SET_STRING(iovec[n++], t);

and the get_process_comm would be an inline function to call
it with 0/NULL.



Variables that could be 'static':
_BOOT_ID
_MACHINE_ID

Are these allowed/expected to be changed during the runtime of the
journald?



Holger Hans Peter Freyther (2):
  RFC: journald: Do not always record _AUDIT_SESSION and
    _AUDIT_LOGINUID
  RFC: journald: Do not dynamically allocate _UID/_GID/_PID strings

 src/journal/journald-server.c |   26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

-- 
1.7.10.4



More information about the systemd-devel mailing list