All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Grubb <sgrubb@redhat.com>
To: linux-audit@redhat.com
Subject: Re: performance questions
Date: Fri, 30 Sep 2011 09:20:01 -0400	[thread overview]
Message-ID: <201109300920.01318.sgrubb@redhat.com> (raw)
In-Reply-To: <1317310389.2959.93.camel@lcb>

On Thursday, September 29, 2011 11:33:09 AM LC Bruzenak wrote:
> I was looking at some strace results from a process using the
> audit_log_user_message call and I think I see how I can eliminate some
> ioctls and /proc/self lookups by setting the hostname/tty parameters to
> non-NULL pointers pointing to NULL values.
> 
> But the exename is another story. It does a lookup each time. We have
> persistent processes each of which submit 100Ks (on the way to 1Ms) of
> audit_log_user_message events daily, so it would make a difference.
> 
> I was thinking about a patch to store off the exename statically if one
> isn't already in the pipeline. Let me know; I'll submit something if
> not.

You might try this:

diff -urp audit-2.1.4.orig/lib/audit_logging.c audit-2.1.4/lib/audit_logging.c
--- audit-2.1.4.orig/lib/audit_logging.c	2011-09-06 14:17:06.000000000 -0400
+++ audit-2.1.4/lib/audit_logging.c	2011-09-30 09:08:50.000000000 -0400
@@ -240,7 +240,7 @@ int audit_log_user_message(int audit_fd,
 {
 	char buf[MAX_AUDIT_MESSAGE_LENGTH];
 	char addrbuf[INET6_ADDRSTRLEN];
-	char exename[PATH_MAX*2];
+	static char exename[PATH_MAX*2]="";
 	char ttyname[TTY_PATH];
 	const char *success;
 	int ret;
@@ -262,7 +262,8 @@ int audit_log_user_message(int audit_fd,
 	else
 		strncat(addrbuf, addr, sizeof(addrbuf)-1);
 
-	_get_exename(exename, sizeof(exename));
+	if (exename[0] == 0)
+		_get_exename(exename, sizeof(exename));
 	if (tty == NULL) 
 		tty = _get_tty(ttyname, TTY_PATH);
 	else if (*tty == 0)


> The other question is on the auditd side. IIUC on each event the
> write_to_log function is checking the logfile size. Seems to me that we
> could limit the fstat checks to say one every ten events or so. Any
> problems there?

We can probably use the return value of fprintf() +1 (for the NULL byte) and 
just keep the running total in memory.

-Steve

  reply	other threads:[~2011-09-30 13:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-29 15:33 performance questions LC Bruzenak
2011-09-30 13:20 ` Steve Grubb [this message]
2011-09-30 14:20   ` LC Bruzenak
2011-09-30 14:35     ` Steve Grubb
  -- strict thread matches above, loose matches on Subject: below --
2017-11-04 21:05 Performance questions Tomasz Kusmierz
2008-07-30 11:07 performance questions Filka Michal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201109300920.01318.sgrubb@redhat.com \
    --to=sgrubb@redhat.com \
    --cc=linux-audit@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.