Received: by 10.223.185.116 with SMTP id b49csp6684291wrg; Thu, 8 Mar 2018 11:25:33 -0800 (PST) X-Google-Smtp-Source: AG47ELt4QVo7Yc5OZtF1usS7DJmQ4lOPBU+eAWR6lI7uMn4Z8tdNmgNPnQZa3gW2K00v24b7Qork X-Received: by 10.101.101.204 with SMTP id y12mr22388667pgv.450.1520537133059; Thu, 08 Mar 2018 11:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520537133; cv=none; d=google.com; s=arc-20160816; b=ZfNgGUgtWHj8gR2RsnpuLQCm3IdmhBsvHY+2u2vsxwujppdnYNE8Vat9MsF3/X68VE gffqhqvfYeDRgcjescH+FvYKE4SbW1frVHmsJKPki9r9RlrAGYviY+Te+r4+0jN5cpQ1 YkvmPgWuIdGbVxoqkBAOeYrs/2eg6EHUQYz9teEzyeosYS3zXc8vpyZ3gZZGM3F0umx7 Ezp6HNgpQtbDW0j/Foastzxo9l3Tpjyecysjn4J91Sq4rr7/Eljt9VIHAv6jtM2F32B7 prlS492LpBFk2062rv7RpQGOnPXhQ5BQl1yLh80cgLsxAef/FJR1Ik7t4ieqyd4uIwYP xLDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=oHb6/MNk9336vzeIe887ZvxrjvOQNSqjiPNQ8sX2Xk8=; b=kBvwu4lHA98NXdwpeYxM6/mBXxZaRPWcoKuCFYcbJNdIybQdgNd0mxrMfKZaBfvPe7 o1hrrFRTOAbQSkNektvzYj829VRrjy01QSDuFP1TYS4cQ/PvSLNyRgNyJed5FdawiGPe pwXdVw85xarPqSWUlSmQMdJjOosTo3uHqyvN0dyjkpDRb9C8vAuqm15Q3+XFY+NFs7P8 VdpbBQjv4vPt61ia1KdpbzVXelc0DVCTQd+nXCR8pYI8lmw/sBKOd/qdPua4KHMkiP6m zXbT6Rn9EXb5WHa/uSIxknvMhLL9n1Rt/EP+ma01XX0NSGC/iWfS7OArLIy12W5CdUni Q7KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4-v6si15209907plb.114.2018.03.08.11.25.18; Thu, 08 Mar 2018 11:25:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935311AbeCHTXk convert rfc822-to-8bit (ORCPT + 99 others); Thu, 8 Mar 2018 14:23:40 -0500 Received: from mga18.intel.com ([134.134.136.126]:56380 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932137AbeCHTXj (ORCPT ); Thu, 8 Mar 2018 14:23:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2018 11:23:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,442,1515484800"; d="scan'208";a="23622598" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga008.jf.intel.com with ESMTP; 08 Mar 2018 11:23:21 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 8 Mar 2018 11:23:21 -0800 Received: from FMSMSX109.amr.corp.intel.com ([169.254.15.144]) by fmsmsx120.amr.corp.intel.com ([169.254.15.251]) with mapi id 14.03.0319.002; Thu, 8 Mar 2018 11:23:21 -0800 From: "Dilger, Andreas" To: NeilBrown CC: "Drokin, Oleg" , Greg Kroah-Hartman , James Simmons , "Linux Kernel Mailing List" , Lustre Development List Subject: Re: [PATCH 10/17] staging: lustre: ptlrpc: use delayed_work in sec_gc Thread-Topic: [PATCH 10/17] staging: lustre: ptlrpc: use delayed_work in sec_gc Thread-Index: AQHTsbWzxLXqmzk1sE2umINNS54o4KPHSImA Date: Thu, 8 Mar 2018 19:23:20 +0000 Message-ID: References: <151994679573.7628.1024109499321778846.stgit@noble> <151994708538.7628.11965951418635189732.stgit@noble> In-Reply-To: <151994708538.7628.11965951418635189732.stgit@noble> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.37.249] Content-Type: text/plain; charset="us-ascii" Content-ID: <3D7D963FEBC7FF4BAE2B88465E0C7FC3@intel.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mar 1, 2018, at 16:31, NeilBrown wrote: > > The garbage collection for security contexts currently > has a dedicated kthread which wakes up every 30 minutes > to discard old garbage. > > Replace this with a simple delayed_work item on the > system work queue. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger > --- > drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 90 ++++++++----------------- > 1 file changed, 28 insertions(+), 62 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c > index 48f1a72afd77..2c8bad7b7877 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c > @@ -55,7 +55,6 @@ static spinlock_t sec_gc_list_lock; > static LIST_HEAD(sec_gc_ctx_list); > static spinlock_t sec_gc_ctx_list_lock; > > -static struct ptlrpc_thread sec_gc_thread; > static atomic_t sec_gc_wait_del = ATOMIC_INIT(0); > > void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec) > @@ -139,86 +138,53 @@ static void sec_do_gc(struct ptlrpc_sec *sec) > sec->ps_gc_next = ktime_get_real_seconds() + sec->ps_gc_interval; > } > > -static int sec_gc_main(void *arg) > -{ > - struct ptlrpc_thread *thread = arg; > - > - unshare_fs_struct(); > +static void sec_gc_main(struct work_struct *ws); > +static DECLARE_DELAYED_WORK(sec_gc_work, sec_gc_main); > > - /* Record that the thread is running */ > - thread_set_flags(thread, SVC_RUNNING); > - wake_up(&thread->t_ctl_waitq); > - > - while (1) { > - struct ptlrpc_sec *sec; > +static void sec_gc_main(struct work_struct *ws) > +{ > + struct ptlrpc_sec *sec; > > - sec_process_ctx_list(); > + sec_process_ctx_list(); > again: > - /* go through sec list do gc. > - * FIXME here we iterate through the whole list each time which > - * is not optimal. we perhaps want to use balanced binary tree > - * to trace each sec as order of expiry time. > - * another issue here is we wakeup as fixed interval instead of > - * according to each sec's expiry time > + /* go through sec list do gc. > + * FIXME here we iterate through the whole list each time which > + * is not optimal. we perhaps want to use balanced binary tree > + * to trace each sec as order of expiry time. > + * another issue here is we wakeup as fixed interval instead of > + * according to each sec's expiry time > + */ > + mutex_lock(&sec_gc_mutex); > + list_for_each_entry(sec, &sec_gc_list, ps_gc_list) { > + /* if someone is waiting to be deleted, let it > + * proceed as soon as possible. > */ > - mutex_lock(&sec_gc_mutex); > - list_for_each_entry(sec, &sec_gc_list, ps_gc_list) { > - /* if someone is waiting to be deleted, let it > - * proceed as soon as possible. > - */ > - if (atomic_read(&sec_gc_wait_del)) { > - CDEBUG(D_SEC, "deletion pending, start over\n"); > - mutex_unlock(&sec_gc_mutex); > - goto again; > - } > - > - sec_do_gc(sec); > + if (atomic_read(&sec_gc_wait_del)) { > + CDEBUG(D_SEC, "deletion pending, start over\n"); > + mutex_unlock(&sec_gc_mutex); > + goto again; > } > - mutex_unlock(&sec_gc_mutex); > - > - /* check ctx list again before sleep */ > - sec_process_ctx_list(); > - wait_event_idle_timeout(thread->t_ctl_waitq, > - thread_is_stopping(thread), > - SEC_GC_INTERVAL * HZ); > > - if (thread_test_and_clear_flags(thread, SVC_STOPPING)) > - break; > + sec_do_gc(sec); > } > + mutex_unlock(&sec_gc_mutex); > > - thread_set_flags(thread, SVC_STOPPED); > - wake_up(&thread->t_ctl_waitq); > - return 0; > + /* check ctx list again before sleep */ > + sec_process_ctx_list(); > + schedule_delayed_work(&sec_gc_work, SEC_GC_INTERVAL * HZ); > } > > int sptlrpc_gc_init(void) > { > - struct task_struct *task; > - > mutex_init(&sec_gc_mutex); > spin_lock_init(&sec_gc_list_lock); > spin_lock_init(&sec_gc_ctx_list_lock); > > - /* initialize thread control */ > - memset(&sec_gc_thread, 0, sizeof(sec_gc_thread)); > - init_waitqueue_head(&sec_gc_thread.t_ctl_waitq); > - > - task = kthread_run(sec_gc_main, &sec_gc_thread, "sptlrpc_gc"); > - if (IS_ERR(task)) { > - CERROR("can't start gc thread: %ld\n", PTR_ERR(task)); > - return PTR_ERR(task); > - } > - > - wait_event_idle(sec_gc_thread.t_ctl_waitq, > - thread_is_running(&sec_gc_thread)); > + schedule_delayed_work(&sec_gc_work, 0); > return 0; > } > > void sptlrpc_gc_fini(void) > { > - thread_set_flags(&sec_gc_thread, SVC_STOPPING); > - wake_up(&sec_gc_thread.t_ctl_waitq); > - > - wait_event_idle(sec_gc_thread.t_ctl_waitq, > - thread_is_stopped(&sec_gc_thread)); > + cancel_delayed_work_sync(&sec_gc_work); > } > > Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation