Received: by 10.223.185.116 with SMTP id b49csp224926wrg; Thu, 8 Mar 2018 16:13:29 -0800 (PST) X-Google-Smtp-Source: AG47ELtCDu/P3rJFKlI2PL9mBsSsPfkqFTp28QIy4JTHbTUs6hu2FpQHk7I+FeBz3dHTAQT52fdN X-Received: by 2002:a17:902:b690:: with SMTP id c16-v6mr25998902pls.264.1520554409473; Thu, 08 Mar 2018 16:13:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520554409; cv=none; d=google.com; s=arc-20160816; b=l2yc+4f77EiThI4Z6Ht7qxgHoZkV0m5XzUd/uJqMhFtXwog5yOc4frfVE4n9O0xoD0 SVIYz24oaTglbLLdMLf5yGPcVDY1d2qhpz5LO/ozSVXa56CK7mG8fQdO1rVJ32NuavpR 7yge7sN9n/sDcVlgLxQIKd49S8E0QO6xFK1OwLaA8YZXCk0QcFDasx1MygD5PygKlFpK OGh7QNqGfVzFXVwrz0wE0IktkrbslaZRGO4VakuusWmc/77pUgFISlvyYm+5f89WsPff FKWX0YpGuLKWha5W64DxQu+Pj9E/xloHKWXRq8O+Ts2Bt12fXzwFM+ZUcqb2lfQx8FPg tyhQ== 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=l5/9MYZ6ODcRxd9E2w5qGdegOBmHZlCy3wkHtDXE4t4=; b=EBDjDJvcb10bx0bkFYm4FC+xdC3CfjJECymJXg9qDX8etsbFsp146TJBiLNd83WrVJ JY2/f/rl/b+Z2CE46DO+OgjOstHHRFuc5h4eINOS7oZZ+egQCHI5TubiiFHQSAboNk0y VdOwPVn4aDdWCuCNHYnPSJcPBt4vKv67rS9TNVJBYzBfK/F646w65JBL1x0JXrn4vf4C L1yvLu98IieJiPuXkBHES7bGNvd+AkTn9KtgRxbr/8pS5mOT8AaT1pnoloXQbe5MLXUC DL5eYMxTd+fF5G3AIlS9j7NOpBZiYKmxii66UY1xkIBdBw6eeVFx8IKFnR2QbSqDq193 X4Pw== 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 i78si3364846pfi.93.2018.03.08.16.13.09; Thu, 08 Mar 2018 16:13:29 -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 S1750939AbeCIAMQ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 8 Mar 2018 19:12:16 -0500 Received: from mga06.intel.com ([134.134.136.31]:61674 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750824AbeCIAMO (ORCPT ); Thu, 8 Mar 2018 19:12:14 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2018 16:12:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,443,1515484800"; d="scan'208";a="40420738" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga002.jf.intel.com with ESMTP; 08 Mar 2018 16:12:13 -0800 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 8 Mar 2018 16:12:13 -0800 Received: from FMSMSX109.amr.corp.intel.com ([169.254.15.144]) by fmsmsx123.amr.corp.intel.com ([169.254.7.215]) with mapi id 14.03.0319.002; Thu, 8 Mar 2018 16:12:13 -0800 From: "Dilger, Andreas" To: NeilBrown CC: "Drokin, Oleg" , Greg Kroah-Hartman , James Simmons , "Linux Kernel Mailing List" , Lustre Development List , "Yong, Fan" Subject: Re: [PATCH 13/17] staging: lustre: remove 'ptlrpc_thread usage' for sai_agl_thread Thread-Topic: [PATCH 13/17] staging: lustre: remove 'ptlrpc_thread usage' for sai_agl_thread Thread-Index: AQHTsbXDyzh0gMmR60mYrILJYhE5yqPHmTqA Date: Fri, 9 Mar 2018 00:12:12 +0000 Message-ID: References: <151994679573.7628.1024109499321778846.stgit@noble> <151994708549.7628.13268008928655143336.stgit@noble> In-Reply-To: <151994708549.7628.13268008928655143336.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: 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: > > Lustre has a 'struct ptlrpc_thread' which provides > control functionality wrapped around kthreads. > None of the functionality used in statahead.c requires > ptlrcp_thread - it can all be done directly with kthreads. > > So discard the ptlrpc_thread and just use a task_struct directly. > > One particular change worth noting is that in the current > code, the thread performs some start-up actions and then > signals that it is ready to go. In the new code, the thread > is first created, then the startup actions are perform, then > the thread is woken up. This means there is no need to wait > any more than kthread_create() already waits. > > Signed-off-by: NeilBrown Looks reasonable, but one minor comment inline below. Not enough to make me think the patch is bad, just a minor inefficiency... Reviewed-by: Andreas Dilger I've also CC'd Fan Yong, who is the author of this code in case he has any comments. > diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c > index ba00881a5745..39241b952bf4 100644 > --- a/drivers/staging/lustre/lustre/llite/statahead.c > +++ b/drivers/staging/lustre/lustre/llite/statahead.c > @@ -861,35 +860,13 @@ static int ll_agl_thread(void *arg) > struct inode *dir = d_inode(parent); > struct ll_inode_info *plli = ll_i2info(dir); > struct ll_inode_info *clli; > - struct ll_sb_info *sbi = ll_i2sbi(dir); > - struct ll_statahead_info *sai; > - struct ptlrpc_thread *thread; > + /* We already own this reference, so it is safe to take it without a lock. */ > + struct ll_statahead_info *sai = plli->lli_sai; > > - sai = ll_sai_get(dir); Here we used to grab a reference to "sai" from the directory, but you get it in the calling thread now... > @@ -937,16 +917,22 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) > sai, parent); > > plli = ll_i2info(d_inode(parent)); > + task = kthread_create(ll_agl_thread, parent, "ll_agl_%u", > + plli->lli_opendir_pid); > if (IS_ERR(task)) { > CERROR("can't start ll_agl thread, rc: %ld\n", PTR_ERR(task)); > return; > } > > + sai->sai_agl_task = task; > + atomic_inc(&ll_i2sbi(d_inode(parent))->ll_agl_total); > + spin_lock(&plli->lli_agl_lock); > + sai->sai_agl_valid = 1; > + spin_unlock(&plli->lli_agl_lock); > + /* Get an extra reference that the thread holds */ > + ll_sai_get(d_inode(parent)); Here you get the extra reference, but we already have the pointer to "sai", do going through "parent->d_inode->lli->lli_sai" to get "sai" again seems convoluted. One option is atomic_inc(&sai->sai_refcount), but given that this is done only once per "ls" call I don't think it is a huge deal, and not more work than was done before. Cheers, Andreas > + > + wake_up_process(task); > } > > /* statahead thread main function */ > @@ -958,7 +944,6 @@ static int ll_statahead_thread(void *arg) > struct ll_sb_info *sbi = ll_i2sbi(dir); > struct ll_statahead_info *sai; > struct ptlrpc_thread *sa_thread; > - struct ptlrpc_thread *agl_thread; > struct page *page = NULL; > __u64 pos = 0; > int first = 0; > @@ -967,7 +952,6 @@ static int ll_statahead_thread(void *arg) > > sai = ll_sai_get(dir); > sa_thread = &sai->sai_thread; > - agl_thread = &sai->sai_agl_thread; > sa_thread->t_pid = current_pid(); > CDEBUG(D_READA, "statahead thread starting: sai %p, parent %pd\n", > sai, parent); > @@ -1129,21 +1113,13 @@ static int ll_statahead_thread(void *arg) > sa_handle_callback(sai); > } > out: > - if (sai->sai_agl_valid) { > - spin_lock(&lli->lli_agl_lock); > - thread_set_flags(agl_thread, SVC_STOPPING); > - spin_unlock(&lli->lli_agl_lock); > - wake_up(&agl_thread->t_ctl_waitq); > + if (sai->sai_agl_task) { > + kthread_stop(sai->sai_agl_task); > > CDEBUG(D_READA, "stop agl thread: sai %p pid %u\n", > - sai, (unsigned int)agl_thread->t_pid); > - wait_event_idle(agl_thread->t_ctl_waitq, > - thread_is_stopped(agl_thread)); > - } else { > - /* Set agl_thread flags anyway. */ > - thread_set_flags(agl_thread, SVC_STOPPED); > + sai, (unsigned int)sai->sai_agl_task->pid); > + sai->sai_agl_task = NULL; > } > - > /* > * wait for inflight statahead RPCs to finish, and then we can free sai > * safely because statahead RPC will access sai data > > Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation