+lnet_update_peer_net_healthv(struct lnet_peer_ni *lpni)
+{
+ struct lnet_peer_net *lpn;
+ int best_healthv = 0;
+
+ lpn = lpni->lpni_peer_net;
+
+ list_for_each_entry(lpni, &lpn->lpn_peer_nis, lpni_peer_nis) {
+ int lpni_healthv = atomic_read(&lpni->lpni_healthv);
+ if (best_healthv < lpni_healthv)
+ best_healthv = lpni_healthv;
+ }
+
+ lpn->lpn_healthv = best_healthv;
+}
+
+static inline void
+lnet_set_lpni_healthv_locked(struct lnet_peer_ni *lpni, int value)
+{
+ if (atomic_read(&lpni->lpni_healthv) == value)
+ return;
+ atomic_set(&lpni->lpni_healthv, value);
+ lnet_update_peer_net_healthv(lpni);
+}
+
+static inline bool
+lnet_atomic_add_unless_max(atomic_t *v, int a, int u)
+{
+ int c = atomic_read(v);
+ bool mod = false;
+ int old;
+ int m;
+
+ if (c == u)
+ return mod;
+
+ for (;;) {
+ if (c + a >= u)
+ m = u;
+ else
+ m = c + a;
+ old = atomic_cmpxchg(v, c, m);
+
+ if (old == u)
+ break;
+
+ if (old == c) {
+ mod = true;
+ break;
+ }
+ c = old;
+ }
+
+ return mod;
+}
+
+static inline void
+lnet_inc_lpni_healthv_locked(struct lnet_peer_ni *lpni, int value)