From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: ACJfBouAJpUVZEkKtDChVEnxUDTbxjLDROQ1ddmRXApmyHmH5CtkI/eKpArFHm1T56BRiiWV5edv ARC-Seal: i=1; a=rsa-sha256; t=1516203162; cv=none; d=google.com; s=arc-20160816; b=jKRXW7uNpRBLMFClUc1/WMswoAlreKgtdmPJdoNuLS2JHK2KR0RoeQLAy95YzRZKnf /UPAq7DZdlqK8o9wMA1WwKVvxX3LkZn4Hglv36M5X6IT5ydJV5hxdwH49imn3OGTbvlO 3CnfjPN9LmQHt9Ouj4DNvRlzkILUumM5G+Xnl+K+PUoXFUF/6nM/QUmMn1Jpz9lS1ufJ gU6gmC5/tRXr+VaYO7YAUJvnsWoIfvfS6D4S9w+04LzCDPMRKYOyzZmB3zb6uUgJo345 avy0vj30xoacTLeWLmJTl7dMuumhrLzWqg9aKOUUx5u2g33wvCCyaMExbZZdu3o5zNnV SEEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:dkim-signature:arc-authentication-results; bh=m54QURPTmEhHiWK+9wcPUQhwfquXKCucGOwjDBQWCFw=; b=As82ruSEKjuDZJHLNMqcSahNSfuhdecZKHzgzKIB45cDxPmnjhGv/hU8H3aQfdMazi hKUaRvgFwyBi14Zd2+h6vehUbU0W3vzsNIws0osBNXT1lfpmLhF2P64huebqY3o81FLc 8HnTMIOKbGa5HOPXmsJ/rFWRvrAITeehfwrZqdySDlIvtrov/sOG2ebb4XOVbDX52mgJ +nQhzdfCvVYMqVefUTXCmZnKJIFMwHzcwB4gkGDEQ6FOws3dR1DbgBp7Gb4+LX39R0IN t8YzMMPgL9AvK6dICOvFBmvH5rb7m1t6vNqCAVHNGNn0TwL1FtT+r7rzzY914hEfaJNg Hogg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=K3kVSDFZ; spf=pass (google.com: best guess record for domain of jsimmons@infradead.org designates 2001:8b0:10b:1236::1 as permitted sender) smtp.mailfrom=jsimmons@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=K3kVSDFZ; spf=pass (google.com: best guess record for domain of jsimmons@infradead.org designates 2001:8b0:10b:1236::1 as permitted sender) smtp.mailfrom=jsimmons@infradead.org Date: Wed, 17 Jan 2018 15:32:38 +0000 (GMT) From: James Simmons To: NeilBrown cc: Oleg Drokin , Andreas Dilger , Greg Kroah-Hartman , lkml , lustre Subject: Re: [PATCH 10/19] staging: lustre: simplify waiting in ptlrpc_invalidate_import() In-Reply-To: <151538209368.23920.17745110760039469689.stgit@noble> Message-ID: References: <151538168618.23920.8261096424342988792.stgit@noble> <151538209368.23920.17745110760039469689.stgit@noble> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180117_153238_563010_7EF16B8B X-CRM114-Status: GOOD ( 16.46 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 NO_RELAYS Informational: message was not relayed via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1588993428071859812?= X-GMAIL-MSGID: =?utf-8?q?1589854247337990871?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: > This waiter currently wakes up every second to re-test if > imp_flight is zero. If we ensure wakeup is called whenever > imp_flight is decremented to zero, we can just have a simple > wait_event_idle_timeout(). > > So add a wake_up_all to the one place it is missing, and simplify > the wait_event. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/ptlrpc/client.c | 3 ++- > drivers/staging/lustre/lustre/ptlrpc/import.c | 21 ++++++++------------- > 2 files changed, 10 insertions(+), 14 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c > index 0ab13f8e5993..81b7a7046d82 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/client.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c > @@ -1588,7 +1588,8 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) > spin_lock(&imp->imp_lock); > if (!list_empty(&req->rq_list)) { > list_del_init(&req->rq_list); > - atomic_dec(&req->rq_import->imp_inflight); > + if (atomic_dec_and_test(&req->rq_import->imp_inflight)) > + wake_up_all(&req->rq_import->imp_recovery_waitq); > } > spin_unlock(&imp->imp_lock); > ptlrpc_rqphase_move(req, RQ_PHASE_NEW); > diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c > index ed210550f61f..5d62c9de27eb 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/import.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c > @@ -265,7 +265,6 @@ void ptlrpc_invalidate_import(struct obd_import *imp) > { > struct list_head *tmp, *n; > struct ptlrpc_request *req; > - struct l_wait_info lwi; > unsigned int timeout; > int rc; > > @@ -306,19 +305,15 @@ void ptlrpc_invalidate_import(struct obd_import *imp) > * callbacks. Cap it at obd_timeout -- these should all > * have been locally cancelled by ptlrpc_abort_inflight. > */ > - lwi = LWI_TIMEOUT_INTERVAL( > - cfs_timeout_cap(timeout * HZ), > - (timeout > 1) ? HZ : > - HZ / 2, > - NULL, NULL); > - rc = l_wait_event(imp->imp_recovery_waitq, > - (atomic_read(&imp->imp_inflight) == 0), > - &lwi); > - if (rc) { > + rc = wait_event_idle_timeout(imp->imp_recovery_waitq, > + atomic_read(&imp->imp_inflight) == 0, > + obd_timeout * HZ); > + > + if (rc == 0) { > const char *cli_tgt = obd2cli_tgt(imp->imp_obd); > > - CERROR("%s: rc = %d waiting for callback (%d != 0)\n", > - cli_tgt, rc, > + CERROR("%s: timeout waiting for callback (%d != 0)\n", > + cli_tgt, > atomic_read(&imp->imp_inflight)); > > spin_lock(&imp->imp_lock); > @@ -365,7 +360,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) > } > spin_unlock(&imp->imp_lock); > } > - } while (rc != 0); > + } while (rc == 0); > > /* > * Let's additionally check that no new rpcs added to import in > > >