Re: [PATCH -mm 1/1] audit: cleanup audit_log_start/wait_for_auditdmess

From: Andrew Morton
Date: Thu Jun 06 2013 - 16:56:20 EST


On Mon, 3 Jun 2013 22:46:20 +0200 Oleg Nesterov <oleg@xxxxxxxxxx> wrote:

> audit_log_start() tries to obfusticate the code/logic and
> reimplements wait_event_timeout() in a very confusing way.
>
> Just change wait_for_auditd() to use wait_event_timeout()
> and return bool.
>
> Also remove the unnecessary "ab = NULL" initialization.

I would prefer that this be nicely tested - for a cosmetic thing I
don't think it's worth the risk as-is.

> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -1051,20 +1051,19 @@ static inline void audit_get_stamp(struct audit_context *ctx,
> }
>
> /*
> - * Wait for auditd to drain the queue a little
> + * Wait for auditd to drain audit_skb_queue if it is full
> */
> -static void wait_for_auditd(unsigned long sleep_time)
> +static bool wait_for_auditd(gfp_t gfp_mask)
> {
> - DECLARE_WAITQUEUE(wait, current);
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - add_wait_queue(&audit_backlog_wait, &wait);
> -
> - if (audit_backlog_limit &&
> - skb_queue_len(&audit_skb_queue) > audit_backlog_limit)
> - schedule_timeout(sleep_time);
> -
> - __set_current_state(TASK_RUNNING);
> - remove_wait_queue(&audit_backlog_wait, &wait);
> + /* Atomic callers use can 5 more entries over the limit */

"can use"

> + if (!(gfp_mask & __GFP_WAIT))
> + return skb_queue_len(&audit_skb_queue) <=
> + audit_backlog_limit + 5;
> +
> + return wait_event_timeout(audit_backlog_wait,
> + !audit_backlog_limit ||
> + skb_queue_len(&audit_skb_queue) <= audit_backlog_limit,
> + audit_backlog_wait_time);
> }
>
> ...
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/