From patchwork Wed Jul 15 20:45:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11666249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 664511392 for ; Wed, 15 Jul 2020 20:46:31 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4FB642065F for ; Wed, 15 Jul 2020 20:46:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FB642065F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B8DE521F9AE; Wed, 15 Jul 2020 13:46:02 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C74D521F760 for ; Wed, 15 Jul 2020 13:45:30 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id AF4A55C5; Wed, 15 Jul 2020 16:45:20 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id ADE3B2B5; Wed, 15 Jul 2020 16:45:20 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Wed, 15 Jul 2020 16:45:06 -0400 Message-Id: <1594845918-29027-26-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594845918-29027-1-git-send-email-jsimmons@infradead.org> References: <1594845918-29027-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 25/37] lnet: socklnd: use need_resched() X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown Rather than using a counter to decide when to drop the lock and see if we need to reshedule we can use need_resched(), which is a precise test instead of a guess. WC-bug-id: https://jira.whamcloud.com/browse/LU-12678 Lustre-commit: 3f848f85ba3d3 ("LU-12678 socklnd: use need_resched()") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/39128 Reviewed-by: James Simmons Reviewed-by: Shaun Tancheff Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/klnds/socklnd/socklnd.h | 1 - net/lnet/klnds/socklnd/socklnd_cb.c | 12 +++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/net/lnet/klnds/socklnd/socklnd.h b/net/lnet/klnds/socklnd/socklnd.h index 0ac3637..0a0f0a7 100644 --- a/net/lnet/klnds/socklnd/socklnd.h +++ b/net/lnet/klnds/socklnd/socklnd.h @@ -55,7 +55,6 @@ #define SOCKNAL_NSCHEDS_HIGH (SOCKNAL_NSCHEDS << 1) #define SOCKNAL_PEER_HASH_BITS 7 /* # log2 of # of peer_ni lists */ -#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ #define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */ #define SOCKNAL_ENOMEM_RETRY 1 /* seconds between retries */ diff --git a/net/lnet/klnds/socklnd/socklnd_cb.c b/net/lnet/klnds/socklnd/socklnd_cb.c index 623478c..936054ee 100644 --- a/net/lnet/klnds/socklnd/socklnd_cb.c +++ b/net/lnet/klnds/socklnd/socklnd_cb.c @@ -1328,7 +1328,6 @@ int ksocknal_scheduler(void *arg) struct ksock_conn *conn; struct ksock_tx *tx; int rc; - int nloops = 0; long id = (long)arg; sched = ksocknal_data.ksnd_schedulers[KSOCK_THREAD_CPT(id)]; @@ -1470,12 +1469,10 @@ int ksocknal_scheduler(void *arg) did_something = 1; } - if (!did_something || /* nothing to do */ - ++nloops == SOCKNAL_RESCHED) { /* hogging CPU? */ + if (!did_something || /* nothing to do */ + need_resched()) { /* hogging CPU? */ spin_unlock_bh(&sched->kss_lock); - nloops = 0; - if (!did_something) { /* wait for something to do */ rc = wait_event_interruptible_exclusive( sched->kss_waitq, @@ -2080,7 +2077,6 @@ void ksocknal_write_callback(struct ksock_conn *conn) spinlock_t *connd_lock = &ksocknal_data.ksnd_connd_lock; struct ksock_connreq *cr; wait_queue_entry_t wait; - int nloops = 0; int cons_retry = 0; init_waitqueue_entry(&wait, current); @@ -2158,10 +2154,9 @@ void ksocknal_write_callback(struct ksock_conn *conn) } if (dropped_lock) { - if (++nloops < SOCKNAL_RESCHED) + if (!need_resched()) continue; spin_unlock_bh(connd_lock); - nloops = 0; cond_resched(); spin_lock_bh(connd_lock); continue; @@ -2173,7 +2168,6 @@ void ksocknal_write_callback(struct ksock_conn *conn) &wait); spin_unlock_bh(connd_lock); - nloops = 0; schedule_timeout(timeout); remove_wait_queue(&ksocknal_data.ksnd_connd_waitq, &wait);