lustre-devel-lustre.org archive mirror
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: Andreas Dilger <adilger@whamcloud.com>,
	Oleg Drokin <green@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: Chris Horn <chris.horn@hpe.com>,
	Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 19/24] lnet: Remove duplicate checks for peer sensitivity
Date: Mon,  5 Sep 2022 21:55:32 -0400	[thread overview]
Message-ID: <1662429337-18737-20-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1662429337-18737-1-git-send-email-jsimmons@infradead.org>

From: Chris Horn <chris.horn@hpe.com>

Callers of lnet_inc_lpni_healthv_locked() and
lnet_dec_healthv_locked() currently check whether the parent peer
has a peer specific sensitivity defined. To remove this code
duplication, this logic is rolled into
lnet_inc_lpni_healthv_locked() and lnet_dec_lpni_healthv_locked().
The latter is a new wrapper around lnet_dec_healthv_locked().

lnet_dec_healthv_locked() is changed to return a bool indicating
whether the health value was actually modified so that the peer
net health is only updated when the peer NI health actually changes.

HPE-bug-id: LUS-11018
WC-bug-id: https://jira.whamcloud.com/browse/LU-15930
Lustre-commit: 84b1ca8618129d4e3 ("LU-15930 lnet: Remove duplicate checks for peer sensitivity")
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Reviewed-on: https://review.whamcloud.com/46626
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 include/linux/lnet/lib-lnet.h | 44 +++++++++++++++++++++++++++++++++++++++----
 net/lnet/lnet/lib-msg.c       | 37 ++----------------------------------
 net/lnet/lnet/router.c        |  9 +--------
 3 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h
index 2900c05..1d9b8c7 100644
--- a/include/linux/lnet/lib-lnet.h
+++ b/include/linux/lnet/lib-lnet.h
@@ -1108,13 +1108,49 @@ int lnet_get_peer_ni_info(u32 peer_index, u64 *nid,
 	return mod;
 }
 
+static bool
+lnet_dec_healthv_locked(atomic_t *healthv, int sensitivity)
+{
+	int h = atomic_read(healthv);
+
+	if (h == 0)
+		return false;
+
+	if (h < sensitivity)
+		h = 0;
+	else
+		h -= sensitivity;
+
+	return (atomic_xchg(healthv, h) != h);
+}
+
 static inline void
-lnet_inc_lpni_healthv_locked(struct lnet_peer_ni *lpni, int value)
+lnet_dec_lpni_healthv_locked(struct lnet_peer_ni *lpni)
 {
-	/* only adjust the net health if the lpni health value changed */
-	if (lnet_atomic_add_unless_max(&lpni->lpni_healthv, value,
-				       LNET_MAX_HEALTH_VALUE))
+	/* If there is a health sensitivity in the peer then use that
+	 * instead of the globally set one.
+	 * only adjust the net health if the lpni health value changed
+	 */
+	if (lnet_dec_healthv_locked(&lpni->lpni_healthv,
+			lpni->lpni_peer_net->lpn_peer->lp_health_sensitivity ? :
+			lnet_health_sensitivity)) {
 		lnet_update_peer_net_healthv(lpni);
+	}
+}
+
+static inline void
+lnet_inc_lpni_healthv_locked(struct lnet_peer_ni *lpni)
+{
+	/* If there is a health sensitivity in the peer then use that
+	 * instead of the globally set one.
+	 * only adjust the net health if the lpni health value changed
+	 */
+	if (lnet_atomic_add_unless_max(&lpni->lpni_healthv,
+			lpni->lpni_peer_net->lpn_peer->lp_health_sensitivity ? :
+			lnet_health_sensitivity,
+				       LNET_MAX_HEALTH_VALUE)) {
+		lnet_update_peer_net_healthv(lpni);
+	}
 }
 
 static inline void
diff --git a/net/lnet/lnet/lib-msg.c b/net/lnet/lnet/lib-msg.c
index 95695b2..3b1f6a3 100644
--- a/net/lnet/lnet/lib-msg.c
+++ b/net/lnet/lnet/lib-msg.c
@@ -443,19 +443,6 @@
 	return 0;
 }
 
-static void
-lnet_dec_healthv_locked(atomic_t *healthv, int sensitivity)
-{
-	int h = atomic_read(healthv);
-
-	if (h < sensitivity) {
-		atomic_set(healthv, 0);
-	} else {
-		h -= sensitivity;
-		atomic_set(healthv, h);
-	}
-}
-
 /* must hold net_lock/0 */
 void
 lnet_ni_add_to_recoveryq_locked(struct lnet_ni *ni,
@@ -505,20 +492,7 @@
 void
 lnet_handle_remote_failure_locked(struct lnet_peer_ni *lpni)
 {
-	u32 sensitivity = lnet_health_sensitivity;
-	u32 lp_sensitivity;
-
-	/* If there is a health sensitivity in the peer then use that
-	 * instead of the globally set one.
-	 */
-	lp_sensitivity = lpni->lpni_peer_net->lpn_peer->lp_health_sensitivity;
-	if (lp_sensitivity)
-		sensitivity = lp_sensitivity;
-
-	lnet_dec_healthv_locked(&lpni->lpni_healthv, sensitivity);
-
-	/* update the peer_net's health value */
-	lnet_update_peer_net_healthv(lpni);
+	lnet_dec_lpni_healthv_locked(lpni);
 
 	/* add the peer NI to the recovery queue if it's not already there
 	 * and it's health value is actually below the maximum. It's
@@ -914,14 +888,7 @@
 				lnet_set_lpni_healthv_locked(lpni,
 							     LNET_MAX_HEALTH_VALUE);
 			} else {
-				struct lnet_peer *lpn_peer;
-				u32 sensitivity;
-
-				lpn_peer = lpni->lpni_peer_net->lpn_peer;
-				sensitivity = lpn_peer->lp_health_sensitivity ?
-					      lpn_peer->lp_health_sensitivity :
-					      lnet_health_sensitivity;
-				lnet_inc_lpni_healthv_locked(lpni, sensitivity);
+				lnet_inc_lpni_healthv_locked(lpni);
 				/* This peer NI may have previously aged out
 				 * of recovery. Now that we've received a
 				 * message from it, we can continue recovery
diff --git a/net/lnet/lnet/router.c b/net/lnet/lnet/router.c
index 98707e9..146647c 100644
--- a/net/lnet/lnet/router.c
+++ b/net/lnet/lnet/router.c
@@ -1761,14 +1761,7 @@ bool lnet_router_checker_active(void)
 			lnet_set_lpni_healthv_locked(lpni,
 						     LNET_MAX_HEALTH_VALUE);
 		} else {
-			struct lnet_peer *lpn_peer;
-			u32 sensitivity;
-
-			lpn_peer = lpni->lpni_peer_net->lpn_peer;
-			sensitivity = lpn_peer->lp_health_sensitivity;
-			lnet_inc_lpni_healthv_locked(lpni,
-						     (sensitivity) ? sensitivity :
-						     lnet_health_sensitivity);
+			lnet_inc_lpni_healthv_locked(lpni);
 		}
 	} else if (reset) {
 		lpni->lpni_ns_status = LNET_NI_STATUS_DOWN;
-- 
1.8.3.1

_______________________________________________
lustre-devel mailing list
lustre-devel@lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

  parent reply	other threads:[~2022-09-06  1:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06  1:55 [lustre-devel] [PATCH 00/24] lustre: update to OpenSFS tree Sept 5, 2022 James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 01/24] lustre: sec: new connect flag for name encryption James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 02/24] lustre: lmv: always space-balance r-r directories James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 03/24] lustre: ldlm: rid of obsolete param of ldlm_resource_get() James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 04/24] lustre: llite: fully disable readahead in kernel I/O path James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 05/24] lustre: llite: use fatal_signal_pending in range_lock James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 06/24] lustre: update version to 2.15.51 James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 07/24] lustre: llite: simplify callback handling for async getattr James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 08/24] lustre: statahead: add total hit/miss count stats James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 09/24] lnet: o2iblnd: Salt comp_vector James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 10/24] lnet: selftest: use preallocate bulk for server James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 11/24] lnet: change ni_status in lnet_ni to u32* James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 12/24] lustre: llite: Rework upper/lower DIO/AIO James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 13/24] lustre: sec: use enc pool for bounce pages James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 14/24] lustre: llite: Unify range unlock James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 15/24] lustre: llite: Refactor DIO/AIO free code James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 16/24] lnet: Use fatal NI if none other available James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 17/24] lnet: LNet peer aliveness broken James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 18/24] lnet: Correct net selection for router ping James Simmons
2022-09-06  1:55 ` James Simmons [this message]
2022-09-06  1:55 ` [lustre-devel] [PATCH 20/24] lustre: obdclass: use consistent stats units James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 21/24] lnet: Memory leak on adding existing interface James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 22/24] lustre: sec: fix detection of SELinux enforcement James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 23/24] lustre: idl: add checks for OBD_CONNECT flags James Simmons
2022-09-06  1:55 ` [lustre-devel] [PATCH 24/24] lustre: llite: fix stat attributes_mask James Simmons

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=1662429337-18737-20-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=adilger@whamcloud.com \
    --cc=chris.horn@hpe.com \
    --cc=green@whamcloud.com \
    --cc=lustre-devel@lists.lustre.org \
    --cc=neilb@suse.de \
    /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).