From: "Dilger, Andreas" <andreas.dilger@intel.com>
To: NeilBrown <neilb@suse.com>
Cc: "Drokin, Oleg" <oleg.drokin@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
James Simmons <jsimmons@infradead.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
Lustre Development List <lustre-devel@lists.lustre.org>
Subject: Re: [PATCH 10/17] staging: lustre: ptlrpc: use delayed_work in sec_gc
Date: Thu, 8 Mar 2018 19:23:20 +0000 [thread overview]
Message-ID: <D6D3EC01-6338-4285-A4FE-9F9C54EC1586@intel.com> (raw)
In-Reply-To: <151994708538.7628.11965951418635189732.stgit@noble>
On Mar 1, 2018, at 16:31, NeilBrown <neilb@suse.com> 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 <neilb@suse.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
> ---
> 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
prev parent reply other threads:[~2018-03-08 19:23 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-01 23:31 [PATCH 00/17] staging: remove requirement that lustre be built as module NeilBrown
2018-03-01 23:31 ` [PATCH 06/17] staging: lustre: get entropy from nid when nid set NeilBrown
2018-03-08 0:19 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 02/17] staging: lustre: fix bug in osc_enter_cache_try NeilBrown
2018-03-07 20:51 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 03/17] staging: lustre: statahead: remove incorrect test on agl_list_empty() NeilBrown
2018-03-07 21:08 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 07/17] staging: lustre: ptlrpc: change GFP_NOFS to GFP_KERNEL NeilBrown
2018-03-08 0:20 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 17/17] Revert "staging: Disable lustre file system for MIPS, SH, and XTENSA" NeilBrown
2018-03-09 0:37 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 13/17] staging: lustre: remove 'ptlrpc_thread usage' for sai_agl_thread NeilBrown
2018-03-09 0:12 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 14/17] staging: lustre: change sai_thread to sai_task NeilBrown
2018-03-09 0:20 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 05/17] staging: lustre: lnet: keep ln_nportals consistent NeilBrown
2018-03-07 21:24 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 08/17] staging: lustre: obdclass: use workqueue for zombie management NeilBrown
2018-03-08 0:27 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 12/17] staging: lustre: remove unused flag from ptlrpc_thread NeilBrown
2018-03-08 23:54 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 01/17] staging: lustre: obd_mount: use correct niduuid suffix NeilBrown
2018-03-07 20:49 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 16/17] staging: lustre: allow monolithic builds NeilBrown
2018-03-09 0:32 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 09/17] staging: lustre: ldlm: use delayed_work for pools_recalc NeilBrown
2018-03-08 19:22 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 04/17] staging: lustre: obdclass: don't require lct_owner to be non-NULL NeilBrown
2018-03-07 21:10 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 11/17] staging: lustre: ptlrpc: use workqueue for pinger NeilBrown
2018-03-08 23:53 ` Dilger, Andreas
2018-03-11 21:37 ` NeilBrown
2018-03-01 23:31 ` [PATCH 15/17] staging: lustre: ptlrpc: move thread creation out of module initialization NeilBrown
2018-03-09 0:31 ` Dilger, Andreas
2018-03-01 23:31 ` [PATCH 10/17] staging: lustre: ptlrpc: use delayed_work in sec_gc NeilBrown
2018-03-08 19:23 ` Dilger, Andreas [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=D6D3EC01-6338-4285-A4FE-9F9C54EC1586@intel.com \
--to=andreas.dilger@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jsimmons@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=neilb@suse.com \
--cc=oleg.drokin@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).