@@ -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
@@ -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
@@ -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;