public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: eparis@redhat.com, linux-kernel@vger.kernel.org, linux-audit@redhat.com
Subject: Re: [PATCH] audit: cleanup prune_tree_thread
Date: Mon, 04 Apr 2016 10:06:41 -0400	[thread overview]
Message-ID: <3910113.5gUCLERkgh@sifl> (raw)
In-Reply-To: <1459414168-5010-1-git-send-email-jslaby@suse.cz>

On Thursday, March 31, 2016 10:49:28 AM Jiri Slaby wrote:
> We can use kthread_run instead of kthread_create+wake_up_process for
> creating the thread.
> 
> We do not need to set the task state to TASK_RUNNING after schedule(),
> the process is in that state already.
> 
> And we do not need to set the state to TASK_INTERRUPTIBLE when not
> doing schedule() as we set the state to TASK_RUNNING immediately
> afterwards.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Paul Moore <paul@paul-moore.com>
> Cc: Eric Paris <eparis@redhat.com>
> Cc: <linux-audit@redhat.com>
> ---
>  kernel/audit_tree.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)

Thanks, it looks good to me; merged.

> diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
> index 5efe9b299a12..25772476fa4a 100644
> --- a/kernel/audit_tree.c
> +++ b/kernel/audit_tree.c
> @@ -661,10 +661,10 @@ static int tag_mount(struct vfsmount *mnt, void *arg)
>  static int prune_tree_thread(void *unused)
>  {
>  	for (;;) {
> -		set_current_state(TASK_INTERRUPTIBLE);
> -		if (list_empty(&prune_list))
> +		if (list_empty(&prune_list)) {
> +			set_current_state(TASK_INTERRUPTIBLE);
>  			schedule();
> -		__set_current_state(TASK_RUNNING);
> +		}
> 
>  		mutex_lock(&audit_cmd_mutex);
>  		mutex_lock(&audit_filter_mutex);
> @@ -693,16 +693,14 @@ static int audit_launch_prune(void)
>  {
>  	if (prune_thread)
>  		return 0;
> -	prune_thread = kthread_create(prune_tree_thread, NULL,
> +	prune_thread = kthread_run(prune_tree_thread, NULL,
>  				"audit_prune_tree");
>  	if (IS_ERR(prune_thread)) {
>  		pr_err("cannot start thread audit_prune_tree");
>  		prune_thread = NULL;
>  		return -ENOMEM;
> -	} else {
> -		wake_up_process(prune_thread);
> -		return 0;
>  	}
> +	return 0;
>  }
> 
>  /* called with audit_filter_mutex */

-- 
paul moore
www.paul-moore.com

      reply	other threads:[~2016-04-04 14:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-31  8:49 [PATCH] audit: cleanup prune_tree_thread Jiri Slaby
2016-04-04 14:06 ` Paul Moore [this message]

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=3910113.5gUCLERkgh@sifl \
    --to=paul@paul-moore.com \
    --cc=eparis@redhat.com \
    --cc=jslaby@suse.cz \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox