From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Moore Subject: Re: [PATCH] audit: cleanup prune_tree_thread Date: Mon, 04 Apr 2016 10:06:41 -0400 Message-ID: <3910113.5gUCLERkgh@sifl> References: <1459414168-5010-1-git-send-email-jslaby@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u34E6iuS018722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 4 Apr 2016 10:06:44 -0400 Received: from mail-qg0-f66.google.com (mail-qg0-f66.google.com [209.85.192.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0777064369 for ; Mon, 4 Apr 2016 14:06:43 +0000 (UTC) Received: by mail-qg0-f66.google.com with SMTP id j35so17749633qge.1 for ; Mon, 04 Apr 2016 07:06:42 -0700 (PDT) In-Reply-To: <1459414168-5010-1-git-send-email-jslaby@suse.cz> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: Jiri Slaby Cc: linux-audit@redhat.com, linux-kernel@vger.kernel.org List-Id: linux-audit@redhat.com 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 > Cc: Paul Moore > Cc: Eric Paris > Cc: > --- > 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