[10/34] lnet: add ni arg to lnet_cpt_of_nid()
diff mbox series

Message ID 153628137163.8267.8668023630519839070.stgit@noble
State New
Headers show
Series
  • Beginning of multi-rail support for drivers/staging/lustre
Related show

Commit Message

NeilBrown Sept. 7, 2018, 12:49 a.m. UTC
When choosing a cpt to use for a given network (identified by nid),
the choice might depend on a particular interface which has
already been identified - different interfaces can have different
sets of cpts.

So add an 'ni' arg to lnet_cpt_of_nid(). If given, choose a cpt
from the cpts of that interface. If not given, choose one from
the set of all cpts associated with any interface on the network.

This is part of
    8cbb8cd3e771e7f7e0f99cafc19fad32770dc015
       LU-7734 lnet: Multi-Rail local NI split

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |    4 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    4 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    2 -
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 +-
 drivers/staging/lustre/lnet/lnet/api-ni.c          |   41 ++++++++++++--------
 drivers/staging/lustre/lnet/lnet/lib-move.c        |   12 +++---
 drivers/staging/lustre/lnet/lnet/lib-ptl.c         |    2 -
 drivers/staging/lustre/lnet/lnet/peer.c            |    4 +-
 drivers/staging/lustre/lnet/lnet/router.c          |    4 +-
 drivers/staging/lustre/lnet/selftest/brw_test.c    |    2 -
 drivers/staging/lustre/lnet/selftest/framework.c   |    3 +
 drivers/staging/lustre/lnet/selftest/selftest.h    |    2 -
 12 files changed, 48 insertions(+), 36 deletions(-)

Comments

Doug Oucharek Sept. 10, 2018, 11:32 p.m. UTC | #1
Reviewed-by: Doug Oucharek <dougso@me.com<mailto:dougso@me.com>>

Doug

On Sep 6, 2018, at 5:49 PM, NeilBrown <neilb@suse.com<mailto:neilb@suse.com>> wrote:

When choosing a cpt to use for a given network (identified by nid),
the choice might depend on a particular interface which has
already been identified - different interfaces can have different
sets of cpts.

So add an 'ni' arg to lnet_cpt_of_nid(). If given, choose a cpt
from the cpts of that interface. If not given, choose one from
the set of all cpts associated with any interface on the network.

This is part of
   8cbb8cd3e771e7f7e0f99cafc19fad32770dc015
      LU-7734 lnet: Multi-Rail local NI split

Signed-off-by: NeilBrown <neilb@suse.com<mailto:neilb@suse.com>>
---
.../staging/lustre/include/linux/lnet/lib-lnet.h   |    4 +-
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    4 +-
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    2 -
.../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 +-
drivers/staging/lustre/lnet/lnet/api-ni.c          |   41 ++++++++++++--------
drivers/staging/lustre/lnet/lnet/lib-move.c        |   12 +++---
drivers/staging/lustre/lnet/lnet/lib-ptl.c         |    2 -
drivers/staging/lustre/lnet/lnet/peer.c            |    4 +-
drivers/staging/lustre/lnet/lnet/router.c          |    4 +-
drivers/staging/lustre/lnet/selftest/brw_test.c    |    2 -
drivers/staging/lustre/lnet/selftest/framework.c   |    3 +
drivers/staging/lustre/lnet/selftest/selftest.h    |    2 -
12 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index 34509e52bac7..e32dbb854d80 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -395,8 +395,8 @@ lnet_net2rnethash(__u32 net)
extern struct lnet_lnd the_lolnd;
extern int avoid_asym_router_failure;

-int lnet_cpt_of_nid_locked(lnet_nid_t nid);
-int lnet_cpt_of_nid(lnet_nid_t nid);
+int lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni);
+int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
struct lnet_ni *lnet_net2ni_locked(__u32 net, int cpt);
struct lnet_ni *lnet_net2ni(__u32 net);
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index ade566d20c69..958ac9a99045 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -320,7 +320,7 @@ int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp,
{
struct kib_peer *peer;
struct kib_net *net = ni->ni_data;
- int cpt = lnet_cpt_of_nid(nid);
+ int cpt = lnet_cpt_of_nid(nid, ni);
unsigned long flags;

LASSERT(net);
@@ -643,7 +643,7 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer *peer, struct rdma_cm_id *cm

dev = net->ibn_dev;

- cpt = lnet_cpt_of_nid(peer->ibp_nid);
+ cpt = lnet_cpt_of_nid(peer->ibp_nid, peer->ibp_ni);
sched = kiblnd_data.kib_scheds[cpt];

LASSERT(sched->ibs_nthreads > 0);
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index c266940cb2ae..e64c14914924 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -119,7 +119,7 @@ kiblnd_get_idle_tx(struct lnet_ni *ni, lnet_nid_t target)
struct kib_tx *tx;
struct kib_tx_poolset *tps;

- tps = net->ibn_tx_ps[lnet_cpt_of_nid(target)];
+ tps = net->ibn_tx_ps[lnet_cpt_of_nid(target, ni)];
node = kiblnd_pool_alloc_node(&tps->tps_poolset);
if (!node)
return NULL;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 2036a0ae5917..ba68bcee90bc 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -101,7 +101,7 @@ static int
ksocknal_create_peer(struct ksock_peer **peerp, struct lnet_ni *ni,
    struct lnet_process_id id)
{
- int cpt = lnet_cpt_of_nid(id.nid);
+ int cpt = lnet_cpt_of_nid(id.nid, ni);
struct ksock_net *net = ni->ni_data;
struct ksock_peer *peer;

@@ -1099,7 +1099,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
LASSERT(conn->ksnc_proto);
LASSERT(peerid.nid != LNET_NID_ANY);

- cpt = lnet_cpt_of_nid(peerid.nid);
+ cpt = lnet_cpt_of_nid(peerid.nid, ni);

if (active) {
ksocknal_peer_addref(peer);
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index c21aef32cdde..6e0b8310574d 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -713,31 +713,41 @@ lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)
}

int
-lnet_cpt_of_nid_locked(lnet_nid_t nid)
+lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni)
{
- struct lnet_ni *ni;
+ struct lnet_net *net;

/* must called with hold of lnet_net_lock */
if (LNET_CPT_NUMBER == 1)
return 0; /* the only one */

- /* take lnet_net_lock(any) would be OK */
- if (!list_empty(&the_lnet.ln_nis_cpt)) {
- list_for_each_entry(ni, &the_lnet.ln_nis_cpt, ni_cptlist) {
- if (LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid))
- continue;
+ /*
+ * If NI is provided then use the CPT identified in the NI cpt
+ * list if one exists. If one doesn't exist, then that NI is
+ * associated with all CPTs and it follows that the net it belongs
+ * to is implicitly associated with all CPTs, so just hash the nid
+ * and return that.
+ */
+ if (ni != NULL) {
+ if (ni->ni_cpts != NULL)
+ return ni->ni_cpts[lnet_nid_cpt_hash(nid,
+     ni->ni_ncpts)];
+ else
+ return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
+ }

- LASSERT(ni->ni_cpts);
- return ni->ni_cpts[lnet_nid_cpt_hash
-   (nid, ni->ni_ncpts)];
- }
+ /* no NI provided so look at the net */
+ net = lnet_get_net_locked(LNET_NIDNET(nid));
+
+ if (net != NULL && net->net_cpts) {
+ return net->net_cpts[lnet_nid_cpt_hash(nid, net->net_ncpts)];
}

return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
}

int
-lnet_cpt_of_nid(lnet_nid_t nid)
+lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni)
{
int cpt;
int cpt2;
@@ -745,11 +755,10 @@ lnet_cpt_of_nid(lnet_nid_t nid)
if (LNET_CPT_NUMBER == 1)
return 0; /* the only one */

- if (list_empty(&the_lnet.ln_nis_cpt))
- return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
-
cpt = lnet_net_lock_current();
- cpt2 = lnet_cpt_of_nid_locked(nid);
+
+ cpt2 = lnet_cpt_of_nid_locked(nid, ni);
+
lnet_net_unlock(cpt);

return cpt2;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index b6e81a693fc3..02cd1a5a466f 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -1095,7 +1095,9 @@ lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid)
msg->msg_sending = 1;

LASSERT(!msg->msg_tx_committed);
- cpt = lnet_cpt_of_nid(rtr_nid == LNET_NID_ANY ? dst_nid : rtr_nid);
+ local_ni = lnet_net2ni(LNET_NIDNET(dst_nid));
+ cpt = lnet_cpt_of_nid(rtr_nid == LNET_NID_ANY ? dst_nid : rtr_nid,
+      local_ni);
 again:
lnet_net_lock(cpt);

@@ -1188,7 +1190,7 @@ lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid)
* was changed when we release the lock
*/
if (rtr_nid != lp->lp_nid) {
- cpt2 = lnet_cpt_of_nid_locked(lp->lp_nid);
+ cpt2 = lp->lp_cpt;
if (cpt2 != cpt) {
if (src_ni)
lnet_ni_decref_locked(src_ni, cpt);
@@ -1677,7 +1679,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
payload_length = le32_to_cpu(hdr->payload_length);

for_me = (ni->ni_nid == dest_nid);
- cpt = lnet_cpt_of_nid(from_nid);
+ cpt = lnet_cpt_of_nid(from_nid, ni);

switch (type) {
case LNET_MSG_ACK:
@@ -2149,7 +2151,7 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)
lnet_msg_attach_md(msg, getmd, getmd->md_offset, getmd->md_length);
lnet_res_unlock(cpt);

- cpt = lnet_cpt_of_nid(peer_id.nid);
+ cpt = lnet_cpt_of_nid(peer_id.nid, ni);

lnet_net_lock(cpt);
lnet_msg_commit(msg, cpt);
@@ -2160,7 +2162,7 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)
return msg;

 drop:
- cpt = lnet_cpt_of_nid(peer_id.nid);
+ cpt = lnet_cpt_of_nid(peer_id.nid, ni);

lnet_net_lock(cpt);
the_lnet.ln_counters[cpt]->drop_count++;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
index 90ce51801726..c8d8162cc706 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
@@ -220,7 +220,7 @@ lnet_match2mt(struct lnet_portal *ptl, struct lnet_process_id id, __u64 mbits)

/* if it's a unique portal, return match-table hashed by NID */
return lnet_ptl_is_unique(ptl) ?
-       ptl->ptl_mtables[lnet_cpt_of_nid(id.nid)] : NULL;
+       ptl->ptl_mtables[lnet_cpt_of_nid(id.nid, NULL)] : NULL;
}

struct lnet_match_table *
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index ed29124ebded..808ce25f1f00 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -270,7 +270,7 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
return -ESHUTDOWN;

/* cpt can be LNET_LOCK_EX if it's called from router functions */
- cpt2 = cpt != LNET_LOCK_EX ? cpt : lnet_cpt_of_nid_locked(nid);
+ cpt2 = cpt != LNET_LOCK_EX ? cpt : lnet_cpt_of_nid_locked(nid, NULL);

ptable = the_lnet.ln_peer_tables[cpt2];
lp = lnet_find_peer_locked(ptable, nid);
@@ -362,7 +362,7 @@ lnet_debug_peer(lnet_nid_t nid)
int rc;
int cpt;

- cpt = lnet_cpt_of_nid(nid);
+ cpt = lnet_cpt_of_nid(nid, NULL);
lnet_net_lock(cpt);

rc = lnet_nid2peer_locked(&lp, nid, cpt);
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 72b8ca2b0fc6..5493d13de6d9 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1207,7 +1207,7 @@ lnet_router_checker(void *arg)
version = the_lnet.ln_routers_version;

list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) {
- cpt2 = lnet_cpt_of_nid_locked(rtr->lp_nid);
+ cpt2 = rtr->lp_cpt;
if (cpt != cpt2) {
lnet_net_unlock(cpt);
cpt = cpt2;
@@ -1693,7 +1693,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, time64_t when)
{
struct lnet_peer *lp = NULL;
time64_t now = ktime_get_seconds();
- int cpt = lnet_cpt_of_nid(nid);
+ int cpt = lnet_cpt_of_nid(nid, ni);

LASSERT(!in_interrupt());

diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
index f1ee219bc8f3..e372ff3044c8 100644
--- a/drivers/staging/lustre/lnet/selftest/brw_test.c
+++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
@@ -124,7 +124,7 @@ brw_client_init(struct sfw_test_instance *tsi)
return -EINVAL;

list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) {
- bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid),
+ bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid, NULL),
      off, npg, len, opc == LST_BRW_READ);
if (!bulk) {
brw_client_fini(tsi);
diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
index 944a2a6598fa..a82efc394659 100644
--- a/drivers/staging/lustre/lnet/selftest/framework.c
+++ b/drivers/staging/lustre/lnet/selftest/framework.c
@@ -1013,7 +1013,8 @@ sfw_run_batch(struct sfw_batch *tsb)
tsu->tsu_loop = tsi->tsi_loop;
wi = &tsu->tsu_worker;
swi_init_workitem(wi, sfw_run_test,
-  lst_test_wq[lnet_cpt_of_nid(tsu->tsu_dest.nid)]);
+  lst_test_wq[lnet_cpt_of_nid(tsu->tsu_dest.nid,
+  NULL)]);
swi_schedule_workitem(wi);
}
}
diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h
index 9dbb0a51d430..edf783af90e8 100644
--- a/drivers/staging/lustre/lnet/selftest/selftest.h
+++ b/drivers/staging/lustre/lnet/selftest/selftest.h
@@ -527,7 +527,7 @@ srpc_init_client_rpc(struct srpc_client_rpc *rpc, struct lnet_process_id peer,

INIT_LIST_HEAD(&rpc->crpc_list);
swi_init_workitem(&rpc->crpc_wi, srpc_send_rpc,
-  lst_test_wq[lnet_cpt_of_nid(peer.nid)]);
+  lst_test_wq[lnet_cpt_of_nid(peer.nid, NULL)]);
spin_lock_init(&rpc->crpc_lock);
atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Reviewed-by: Doug Oucharek &lt;<a href="mailto:dougso@me.com" class="">dougso@me.com</a>&gt;
<div class=""><br class="">
</div>
<div class="">Doug</div>
<div class=""><br class="">
<div style="">
<blockquote type="cite" class="">
<div class="">On Sep 6, 2018, at 5:49 PM, NeilBrown &lt;<a href="mailto:neilb@suse.com" class="">neilb@suse.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">When choosing a cpt to use for a given network (identified by nid),<br class="">
the choice might depend on a particular interface which has<br class="">
already been identified - different interfaces can have different<br class="">
sets of cpts.<br class="">
<br class="">
So add an 'ni' arg to lnet_cpt_of_nid(). If given, choose a cpt<br class="">
from the cpts of that interface. If not given, choose one from<br class="">
the set of all cpts associated with any interface on the network.<br class="">
<br class="">
This is part of<br class="">
&nbsp;&nbsp;&nbsp;8cbb8cd3e771e7f7e0f99cafc19fad32770dc015<br class="">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LU-7734 lnet: Multi-Rail local NI split<br class="">
<br class="">
Signed-off-by: NeilBrown &lt;<a href="mailto:neilb@suse.com" class="">neilb@suse.com</a>&gt;<br class="">
---<br class="">
.../staging/lustre/include/linux/lnet/lib-lnet.h &nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;4 &#43;-<br class="">
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c &nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;4 &#43;-<br class="">
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | &nbsp;&nbsp;&nbsp;2 -<br class="">
.../staging/lustre/lnet/klnds/socklnd/socklnd.c &nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;4 &#43;-<br class="">
drivers/staging/lustre/lnet/lnet/api-ni.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;41 &#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;--------<br class="">
drivers/staging/lustre/lnet/lnet/lib-move.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;12 &#43;&#43;&#43;---<br class="">
drivers/staging/lustre/lnet/lnet/lib-ptl.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;2 -<br class="">
drivers/staging/lustre/lnet/lnet/peer.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;4 &#43;-<br class="">
drivers/staging/lustre/lnet/lnet/router.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;4 &#43;-<br class="">
drivers/staging/lustre/lnet/selftest/brw_test.c &nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;2 -<br class="">
drivers/staging/lustre/lnet/selftest/framework.c &nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;3 &#43;<br class="">
drivers/staging/lustre/lnet/selftest/selftest.h &nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;2 -<br class="">
12 files changed, 48 insertions(&#43;), 36 deletions(-)<br class="">
<br class="">
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h<br class="">
index 34509e52bac7..e32dbb854d80 100644<br class="">
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h<br class="">
@@ -395,8 &#43;395,8 @@ lnet_net2rnethash(__u32 net)<br class="">
extern struct lnet_lnd the_lolnd;<br class="">
extern int avoid_asym_router_failure;<br class="">
<br class="">
-int lnet_cpt_of_nid_locked(lnet_nid_t nid);<br class="">
-int lnet_cpt_of_nid(lnet_nid_t nid);<br class="">
&#43;int lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni);<br class="">
&#43;int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);<br class="">
struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);<br class="">
struct lnet_ni *lnet_net2ni_locked(__u32 net, int cpt);<br class="">
struct lnet_ni *lnet_net2ni(__u32 net);<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c<br class="">
index ade566d20c69..958ac9a99045 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c<br class="">
@@ -320,7 &#43;320,7 @@ int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp,<br class="">
{<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct kib_peer *peer;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct kib_net *net = ni-&gt;ni_data;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>int cpt = lnet_cpt_of_nid(nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>int cpt = lnet_cpt_of_nid(nid, ni);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>unsigned long flags;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(net);<br class="">
@@ -643,7 &#43;643,7 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer *peer, struct rdma_cm_id *cm<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>dev = net-&gt;ibn_dev;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(peer-&gt;ibp_nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(peer-&gt;ibp_nid, peer-&gt;ibp_ni);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>sched = kiblnd_data.kib_scheds[cpt];<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(sched-&gt;ibs_nthreads &gt; 0);<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c<br class="">
index c266940cb2ae..e64c14914924 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c<br class="">
@@ -119,7 &#43;119,7 @@ kiblnd_get_idle_tx(struct lnet_ni *ni, lnet_nid_t target)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct kib_tx *tx;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct kib_tx_poolset *tps;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>tps = net-&gt;ibn_tx_ps[lnet_cpt_of_nid(target)];<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>tps = net-&gt;ibn_tx_ps[lnet_cpt_of_nid(target, ni)];<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>node = kiblnd_pool_alloc_node(&amp;tps-&gt;tps_poolset);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (!node)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return NULL;<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c<br class="">
index 2036a0ae5917..ba68bcee90bc 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c<br class="">
@@ -101,7 &#43;101,7 @@ static int<br class="">
ksocknal_create_peer(struct ksock_peer **peerp, struct lnet_ni *ni,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;struct lnet_process_id id)<br class="">
{<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>int cpt = lnet_cpt_of_nid(id.nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>int cpt = lnet_cpt_of_nid(id.nid, ni);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct ksock_net *net = ni-&gt;ni_data;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct ksock_peer *peer;<br class="">
<br class="">
@@ -1099,7 &#43;1099,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(conn-&gt;ksnc_proto);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(peerid.nid != LNET_NID_ANY);<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(peerid.nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(peerid.nid, ni);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (active) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ksocknal_peer_addref(peer);<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c<br class="">
index c21aef32cdde..6e0b8310574d 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/api-ni.c<br class="">
@@ -713,31 &#43;713,41 @@ lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)<br class="">
}<br class="">
<br class="">
int<br class="">
-lnet_cpt_of_nid_locked(lnet_nid_t nid)<br class="">
&#43;lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni)<br class="">
{<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_ni *ni;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_net *net;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* must called with hold of lnet_net_lock */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (LNET_CPT_NUMBER == 1)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return 0; /* the only one */<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>/* take lnet_net_lock(any) would be OK */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!list_empty(&amp;the_lnet.ln_nis_cpt)) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>list_for_each_entry(ni, &amp;the_lnet.ln_nis_cpt, ni_cptlist) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (LNET_NIDNET(ni-&gt;ni_nid) != LNET_NIDNET(nid))<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>continue;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>/*<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>* If NI is provided then use the CPT identified in the NI cpt<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>* list if one exists. If one doesn't exist, then that NI is<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>* associated with all CPTs and it follows that the net it belongs<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>* to is implicitly associated with all CPTs, so just hash the nid<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>* and return that.<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>*/<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (ni != NULL) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (ni-&gt;ni_cpts != NULL)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return ni-&gt;ni_cpts[lnet_nid_cpt_hash(nid,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;ni-&gt;ni_ncpts)];<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>else<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(ni-&gt;ni_cpts);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return ni-&gt;ni_cpts[lnet_nid_cpt_hash<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;(nid,
 ni-&gt;ni_ncpts)];<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>/* no NI provided so look at the net */<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>net = lnet_get_net_locked(LNET_NIDNET(nid));<br class="">
&#43;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (net != NULL &amp;&amp; net-&gt;net_cpts) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return net-&gt;net_cpts[lnet_nid_cpt_hash(nid, net-&gt;net_ncpts)];<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);<br class="">
}<br class="">
<br class="">
int<br class="">
-lnet_cpt_of_nid(lnet_nid_t nid)<br class="">
&#43;lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni)<br class="">
{<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int cpt;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int cpt2;<br class="">
@@ -745,11 &#43;755,10 @@ lnet_cpt_of_nid(lnet_nid_t nid)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (LNET_CPT_NUMBER == 1)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return 0; /* the only one */<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (list_empty(&amp;the_lnet.ln_nis_cpt))<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);<br class="">
-<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>cpt = lnet_net_lock_current();<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>cpt2 = lnet_cpt_of_nid_locked(nid);<br class="">
&#43;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>cpt2 = lnet_cpt_of_nid_locked(nid, ni);<br class="">
&#43;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_net_unlock(cpt);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>return cpt2;<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c<br class="">
index b6e81a693fc3..02cd1a5a466f 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/lib-move.c<br class="">
@@ -1095,7 &#43;1095,9 @@ lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>msg-&gt;msg_sending = 1;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(!msg-&gt;msg_tx_committed);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(rtr_nid == LNET_NID_ANY ? dst_nid : rtr_nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>local_ni = lnet_net2ni(LNET_NIDNET(dst_nid));<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(rtr_nid == LNET_NID_ANY ? dst_nid : rtr_nid,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local_ni);<br class="">
&nbsp;again:<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_net_lock(cpt);<br class="">
<br class="">
@@ -1188,7 &#43;1190,7 @@ lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>* was changed when we release the lock<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*/<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (rtr_nid != lp-&gt;lp_nid) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>cpt2 = lnet_cpt_of_nid_locked(lp-&gt;lp_nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>cpt2 = lp-&gt;lp_cpt;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (cpt2 != cpt) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (src_ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>lnet_ni_decref_locked(src_ni,
 cpt);<br class="">
@@ -1677,7 &#43;1679,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>payload_length = le32_to_cpu(hdr-&gt;payload_length);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>for_me = (ni-&gt;ni_nid == dest_nid);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(from_nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(from_nid, ni);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>switch (type) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>case LNET_MSG_ACK:<br class="">
@@ -2149,7 &#43;2151,7 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_msg_attach_md(msg, getmd, getmd-&gt;md_offset, getmd-&gt;md_length);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_res_unlock(cpt);<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(peer_id.nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(peer_id.nid, ni);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_net_lock(cpt);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_msg_commit(msg, cpt);<br class="">
@@ -2160,7 &#43;2162,7 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>return msg;<br class="">
<br class="">
&nbsp;drop:<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(peer_id.nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(peer_id.nid, ni);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_net_lock(cpt);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>the_lnet.ln_counters[cpt]-&gt;drop_count&#43;&#43;;<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c<br class="">
index 90ce51801726..c8d8162cc706 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/lib-ptl.c<br class="">
@@ -220,7 &#43;220,7 @@ lnet_match2mt(struct lnet_portal *ptl, struct lnet_process_id id, __u64 mbits)<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* if it's a unique portal, return match-table hashed by NID */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>return lnet_ptl_is_unique(ptl) ?<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ptl-&gt;ptl_mtables[lnet_cpt_of_nid(id.nid)] : NULL;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ptl-&gt;ptl_mtables[lnet_cpt_of_nid(id.nid, NULL)] : NULL;<br class="">
}<br class="">
<br class="">
struct lnet_match_table *<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c<br class="">
index ed29124ebded..808ce25f1f00 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/peer.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/peer.c<br class="">
@@ -270,7 &#43;270,7 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return -ESHUTDOWN;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* cpt can be LNET_LOCK_EX if it's called from router functions */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>cpt2 = cpt != LNET_LOCK_EX ? cpt : lnet_cpt_of_nid_locked(nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>cpt2 = cpt != LNET_LOCK_EX ? cpt : lnet_cpt_of_nid_locked(nid, NULL);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>ptable = the_lnet.ln_peer_tables[cpt2];<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lp = lnet_find_peer_locked(ptable, nid);<br class="">
@@ -362,7 &#43;362,7 @@ lnet_debug_peer(lnet_nid_t nid)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int rc;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int cpt;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>cpt = lnet_cpt_of_nid(nid, NULL);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_net_lock(cpt);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>rc = lnet_nid2peer_locked(&amp;lp, nid, cpt);<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c<br class="">
index 72b8ca2b0fc6..5493d13de6d9 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/router.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/router.c<br class="">
@@ -1207,7 &#43;1207,7 @@ lnet_router_checker(void *arg)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>version = the_lnet.ln_routers_version;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>list_for_each_entry(rtr, &amp;the_lnet.ln_routers, lp_rtr_list) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>cpt2 = lnet_cpt_of_nid_locked(rtr-&gt;lp_nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>cpt2 = rtr-&gt;lp_cpt;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (cpt != cpt2) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>lnet_net_unlock(cpt);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>cpt = cpt2;<br class="">
@@ -1693,7 &#43;1693,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, time64_t when)<br class="">
{<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_peer *lp = NULL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>time64_t now = ktime_get_seconds();<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>int cpt = lnet_cpt_of_nid(nid);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>int cpt = lnet_cpt_of_nid(nid, ni);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(!in_interrupt());<br class="">
<br class="">
diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c<br class="">
index f1ee219bc8f3..e372ff3044c8 100644<br class="">
--- a/drivers/staging/lustre/lnet/selftest/brw_test.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/selftest/brw_test.c<br class="">
@@ -124,7 &#43;124,7 @@ brw_client_init(struct sfw_test_instance *tsi)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return -EINVAL;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>list_for_each_entry(tsu, &amp;tsi-&gt;tsi_units, tsu_list) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu-&gt;tsu_dest.nid),<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu-&gt;tsu_dest.nid, NULL),<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;off, npg, len,
 opc == LST_BRW_READ);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (!bulk) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>brw_client_fini(tsi);<br class="">
diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c<br class="">
index 944a2a6598fa..a82efc394659 100644<br class="">
--- a/drivers/staging/lustre/lnet/selftest/framework.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/selftest/framework.c<br class="">
@@ -1013,7 &#43;1013,8 @@ sfw_run_batch(struct sfw_batch *tsb)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>tsu-&gt;tsu_loop = tsi-&gt;tsi_loop;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>wi = &amp;tsu-&gt;tsu_worker;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>swi_init_workitem(wi, sfw_run_test,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;lst_test_wq[lnet_cpt_of_nid(tsu-&gt;tsu_dest.nid)]);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;lst_test_wq[lnet_cpt_of_nid(tsu-&gt;tsu_dest.nid,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;NULL)]);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>swi_schedule_workitem(wi);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h<br class="">
index 9dbb0a51d430..edf783af90e8 100644<br class="">
--- a/drivers/staging/lustre/lnet/selftest/selftest.h<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/selftest/selftest.h<br class="">
@@ -527,7 &#43;527,7 @@ srpc_init_client_rpc(struct srpc_client_rpc *rpc, struct lnet_process_id peer,<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>INIT_LIST_HEAD(&amp;rpc-&gt;crpc_list);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>swi_init_workitem(&amp;rpc-&gt;crpc_wi, srpc_send_rpc,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;lst_test_wq[lnet_cpt_of_nid(peer.nid)]);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;lst_test_wq[lnet_cpt_of_nid(peer.nid, NULL)]);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>spin_lock_init(&amp;rpc-&gt;crpc_lock);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>atomic_set(&amp;rpc-&gt;crpc_refcount, 1); /* 1 ref for caller */<br class="">
<br class="">
<br class="">
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>
James Simmons Sept. 11, 2018, 1:03 a.m. UTC | #2
> When choosing a cpt to use for a given network (identified by nid),
> the choice might depend on a particular interface which has
> already been identified - different interfaces can have different
> sets of cpts.
> 
> So add an 'ni' arg to lnet_cpt_of_nid(). If given, choose a cpt
> from the cpts of that interface. If not given, choose one from
> the set of all cpts associated with any interface on the network.

Reviewed-by: James Simmons <jsimmons@infradead.org>

The below needs fixing based on response to cover letter.

> This is part of
>     8cbb8cd3e771e7f7e0f99cafc19fad32770dc015
>        LU-7734 lnet: Multi-Rail local NI split
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/lnet/lib-lnet.h   |    4 +-
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    4 +-
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    2 -
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 +-
>  drivers/staging/lustre/lnet/lnet/api-ni.c          |   41 ++++++++++++--------
>  drivers/staging/lustre/lnet/lnet/lib-move.c        |   12 +++---
>  drivers/staging/lustre/lnet/lnet/lib-ptl.c         |    2 -
>  drivers/staging/lustre/lnet/lnet/peer.c            |    4 +-
>  drivers/staging/lustre/lnet/lnet/router.c          |    4 +-
>  drivers/staging/lustre/lnet/selftest/brw_test.c    |    2 -
>  drivers/staging/lustre/lnet/selftest/framework.c   |    3 +
>  drivers/staging/lustre/lnet/selftest/selftest.h    |    2 -
>  12 files changed, 48 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> index 34509e52bac7..e32dbb854d80 100644
> --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> @@ -395,8 +395,8 @@ lnet_net2rnethash(__u32 net)
>  extern struct lnet_lnd the_lolnd;
>  extern int avoid_asym_router_failure;
>  
> -int lnet_cpt_of_nid_locked(lnet_nid_t nid);
> -int lnet_cpt_of_nid(lnet_nid_t nid);
> +int lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni);
> +int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
>  struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
>  struct lnet_ni *lnet_net2ni_locked(__u32 net, int cpt);
>  struct lnet_ni *lnet_net2ni(__u32 net);
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index ade566d20c69..958ac9a99045 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -320,7 +320,7 @@ int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp,
>  {
>  	struct kib_peer *peer;
>  	struct kib_net *net = ni->ni_data;
> -	int cpt = lnet_cpt_of_nid(nid);
> +	int cpt = lnet_cpt_of_nid(nid, ni);
>  	unsigned long flags;
>  
>  	LASSERT(net);
> @@ -643,7 +643,7 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer *peer, struct rdma_cm_id *cm
>  
>  	dev = net->ibn_dev;
>  
> -	cpt = lnet_cpt_of_nid(peer->ibp_nid);
> +	cpt = lnet_cpt_of_nid(peer->ibp_nid, peer->ibp_ni);
>  	sched = kiblnd_data.kib_scheds[cpt];
>  
>  	LASSERT(sched->ibs_nthreads > 0);
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> index c266940cb2ae..e64c14914924 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> @@ -119,7 +119,7 @@ kiblnd_get_idle_tx(struct lnet_ni *ni, lnet_nid_t target)
>  	struct kib_tx *tx;
>  	struct kib_tx_poolset *tps;
>  
> -	tps = net->ibn_tx_ps[lnet_cpt_of_nid(target)];
> +	tps = net->ibn_tx_ps[lnet_cpt_of_nid(target, ni)];
>  	node = kiblnd_pool_alloc_node(&tps->tps_poolset);
>  	if (!node)
>  		return NULL;
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 2036a0ae5917..ba68bcee90bc 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -101,7 +101,7 @@ static int
>  ksocknal_create_peer(struct ksock_peer **peerp, struct lnet_ni *ni,
>  		     struct lnet_process_id id)
>  {
> -	int cpt = lnet_cpt_of_nid(id.nid);
> +	int cpt = lnet_cpt_of_nid(id.nid, ni);
>  	struct ksock_net *net = ni->ni_data;
>  	struct ksock_peer *peer;
>  
> @@ -1099,7 +1099,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
>  	LASSERT(conn->ksnc_proto);
>  	LASSERT(peerid.nid != LNET_NID_ANY);
>  
> -	cpt = lnet_cpt_of_nid(peerid.nid);
> +	cpt = lnet_cpt_of_nid(peerid.nid, ni);
>  
>  	if (active) {
>  		ksocknal_peer_addref(peer);
> diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
> index c21aef32cdde..6e0b8310574d 100644
> --- a/drivers/staging/lustre/lnet/lnet/api-ni.c
> +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
> @@ -713,31 +713,41 @@ lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)
>  }
>  
>  int
> -lnet_cpt_of_nid_locked(lnet_nid_t nid)
> +lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni)
>  {
> -	struct lnet_ni *ni;
> +	struct lnet_net *net;
>  
>  	/* must called with hold of lnet_net_lock */
>  	if (LNET_CPT_NUMBER == 1)
>  		return 0; /* the only one */
>  
> -	/* take lnet_net_lock(any) would be OK */
> -	if (!list_empty(&the_lnet.ln_nis_cpt)) {
> -		list_for_each_entry(ni, &the_lnet.ln_nis_cpt, ni_cptlist) {
> -			if (LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid))
> -				continue;
> +	/*
> +	 * If NI is provided then use the CPT identified in the NI cpt
> +	 * list if one exists. If one doesn't exist, then that NI is
> +	 * associated with all CPTs and it follows that the net it belongs
> +	 * to is implicitly associated with all CPTs, so just hash the nid
> +	 * and return that.
> +	 */
> +	if (ni != NULL) {
> +		if (ni->ni_cpts != NULL)
> +			return ni->ni_cpts[lnet_nid_cpt_hash(nid,
> +							     ni->ni_ncpts)];
> +		else
> +			return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
> +	}
>  
> -			LASSERT(ni->ni_cpts);
> -			return ni->ni_cpts[lnet_nid_cpt_hash
> -					   (nid, ni->ni_ncpts)];
> -		}
> +	/* no NI provided so look at the net */
> +	net = lnet_get_net_locked(LNET_NIDNET(nid));
> +
> +	if (net != NULL && net->net_cpts) {
> +		return net->net_cpts[lnet_nid_cpt_hash(nid, net->net_ncpts)];
>  	}
>  
>  	return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
>  }
>  
>  int
> -lnet_cpt_of_nid(lnet_nid_t nid)
> +lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni)
>  {
>  	int cpt;
>  	int cpt2;
> @@ -745,11 +755,10 @@ lnet_cpt_of_nid(lnet_nid_t nid)
>  	if (LNET_CPT_NUMBER == 1)
>  		return 0; /* the only one */
>  
> -	if (list_empty(&the_lnet.ln_nis_cpt))
> -		return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
> -
>  	cpt = lnet_net_lock_current();
> -	cpt2 = lnet_cpt_of_nid_locked(nid);
> +
> +	cpt2 = lnet_cpt_of_nid_locked(nid, ni);
> +
>  	lnet_net_unlock(cpt);
>  
>  	return cpt2;
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
> index b6e81a693fc3..02cd1a5a466f 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-move.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
> @@ -1095,7 +1095,9 @@ lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid)
>  	msg->msg_sending = 1;
>  
>  	LASSERT(!msg->msg_tx_committed);
> -	cpt = lnet_cpt_of_nid(rtr_nid == LNET_NID_ANY ? dst_nid : rtr_nid);
> +	local_ni = lnet_net2ni(LNET_NIDNET(dst_nid));
> +	cpt = lnet_cpt_of_nid(rtr_nid == LNET_NID_ANY ? dst_nid : rtr_nid,
> +			      local_ni);
>   again:
>  	lnet_net_lock(cpt);
>  
> @@ -1188,7 +1190,7 @@ lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid)
>  		 * was changed when we release the lock
>  		 */
>  		if (rtr_nid != lp->lp_nid) {
> -			cpt2 = lnet_cpt_of_nid_locked(lp->lp_nid);
> +			cpt2 = lp->lp_cpt;
>  			if (cpt2 != cpt) {
>  				if (src_ni)
>  					lnet_ni_decref_locked(src_ni, cpt);
> @@ -1677,7 +1679,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
>  	payload_length = le32_to_cpu(hdr->payload_length);
>  
>  	for_me = (ni->ni_nid == dest_nid);
> -	cpt = lnet_cpt_of_nid(from_nid);
> +	cpt = lnet_cpt_of_nid(from_nid, ni);
>  
>  	switch (type) {
>  	case LNET_MSG_ACK:
> @@ -2149,7 +2151,7 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)
>  	lnet_msg_attach_md(msg, getmd, getmd->md_offset, getmd->md_length);
>  	lnet_res_unlock(cpt);
>  
> -	cpt = lnet_cpt_of_nid(peer_id.nid);
> +	cpt = lnet_cpt_of_nid(peer_id.nid, ni);
>  
>  	lnet_net_lock(cpt);
>  	lnet_msg_commit(msg, cpt);
> @@ -2160,7 +2162,7 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)
>  	return msg;
>  
>   drop:
> -	cpt = lnet_cpt_of_nid(peer_id.nid);
> +	cpt = lnet_cpt_of_nid(peer_id.nid, ni);
>  
>  	lnet_net_lock(cpt);
>  	the_lnet.ln_counters[cpt]->drop_count++;
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
> index 90ce51801726..c8d8162cc706 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
> @@ -220,7 +220,7 @@ lnet_match2mt(struct lnet_portal *ptl, struct lnet_process_id id, __u64 mbits)
>  
>  	/* if it's a unique portal, return match-table hashed by NID */
>  	return lnet_ptl_is_unique(ptl) ?
> -	       ptl->ptl_mtables[lnet_cpt_of_nid(id.nid)] : NULL;
> +	       ptl->ptl_mtables[lnet_cpt_of_nid(id.nid, NULL)] : NULL;
>  }
>  
>  struct lnet_match_table *
> diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
> index ed29124ebded..808ce25f1f00 100644
> --- a/drivers/staging/lustre/lnet/lnet/peer.c
> +++ b/drivers/staging/lustre/lnet/lnet/peer.c
> @@ -270,7 +270,7 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
>  		return -ESHUTDOWN;
>  
>  	/* cpt can be LNET_LOCK_EX if it's called from router functions */
> -	cpt2 = cpt != LNET_LOCK_EX ? cpt : lnet_cpt_of_nid_locked(nid);
> +	cpt2 = cpt != LNET_LOCK_EX ? cpt : lnet_cpt_of_nid_locked(nid, NULL);
>  
>  	ptable = the_lnet.ln_peer_tables[cpt2];
>  	lp = lnet_find_peer_locked(ptable, nid);
> @@ -362,7 +362,7 @@ lnet_debug_peer(lnet_nid_t nid)
>  	int rc;
>  	int cpt;
>  
> -	cpt = lnet_cpt_of_nid(nid);
> +	cpt = lnet_cpt_of_nid(nid, NULL);
>  	lnet_net_lock(cpt);
>  
>  	rc = lnet_nid2peer_locked(&lp, nid, cpt);
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index 72b8ca2b0fc6..5493d13de6d9 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -1207,7 +1207,7 @@ lnet_router_checker(void *arg)
>  		version = the_lnet.ln_routers_version;
>  
>  		list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) {
> -			cpt2 = lnet_cpt_of_nid_locked(rtr->lp_nid);
> +			cpt2 = rtr->lp_cpt;
>  			if (cpt != cpt2) {
>  				lnet_net_unlock(cpt);
>  				cpt = cpt2;
> @@ -1693,7 +1693,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, time64_t when)
>  {
>  	struct lnet_peer *lp = NULL;
>  	time64_t now = ktime_get_seconds();
> -	int cpt = lnet_cpt_of_nid(nid);
> +	int cpt = lnet_cpt_of_nid(nid, ni);
>  
>  	LASSERT(!in_interrupt());
>  
> diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
> index f1ee219bc8f3..e372ff3044c8 100644
> --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
> +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
> @@ -124,7 +124,7 @@ brw_client_init(struct sfw_test_instance *tsi)
>  		return -EINVAL;
>  
>  	list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) {
> -		bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid),
> +		bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid, NULL),
>  				       off, npg, len, opc == LST_BRW_READ);
>  		if (!bulk) {
>  			brw_client_fini(tsi);
> diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
> index 944a2a6598fa..a82efc394659 100644
> --- a/drivers/staging/lustre/lnet/selftest/framework.c
> +++ b/drivers/staging/lustre/lnet/selftest/framework.c
> @@ -1013,7 +1013,8 @@ sfw_run_batch(struct sfw_batch *tsb)
>  			tsu->tsu_loop = tsi->tsi_loop;
>  			wi = &tsu->tsu_worker;
>  			swi_init_workitem(wi, sfw_run_test,
> -					  lst_test_wq[lnet_cpt_of_nid(tsu->tsu_dest.nid)]);
> +					  lst_test_wq[lnet_cpt_of_nid(tsu->tsu_dest.nid,
> +							  NULL)]);
>  			swi_schedule_workitem(wi);
>  		}
>  	}
> diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h
> index 9dbb0a51d430..edf783af90e8 100644
> --- a/drivers/staging/lustre/lnet/selftest/selftest.h
> +++ b/drivers/staging/lustre/lnet/selftest/selftest.h
> @@ -527,7 +527,7 @@ srpc_init_client_rpc(struct srpc_client_rpc *rpc, struct lnet_process_id peer,
>  
>  	INIT_LIST_HEAD(&rpc->crpc_list);
>  	swi_init_workitem(&rpc->crpc_wi, srpc_send_rpc,
> -			  lst_test_wq[lnet_cpt_of_nid(peer.nid)]);
> +			  lst_test_wq[lnet_cpt_of_nid(peer.nid, NULL)]);
>  	spin_lock_init(&rpc->crpc_lock);
>  	atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */
>  
> 
> 
>

Patch
diff mbox series

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index 34509e52bac7..e32dbb854d80 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -395,8 +395,8 @@  lnet_net2rnethash(__u32 net)
 extern struct lnet_lnd the_lolnd;
 extern int avoid_asym_router_failure;
 
-int lnet_cpt_of_nid_locked(lnet_nid_t nid);
-int lnet_cpt_of_nid(lnet_nid_t nid);
+int lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni);
+int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
 struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
 struct lnet_ni *lnet_net2ni_locked(__u32 net, int cpt);
 struct lnet_ni *lnet_net2ni(__u32 net);
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index ade566d20c69..958ac9a99045 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -320,7 +320,7 @@  int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp,
 {
 	struct kib_peer *peer;
 	struct kib_net *net = ni->ni_data;
-	int cpt = lnet_cpt_of_nid(nid);
+	int cpt = lnet_cpt_of_nid(nid, ni);
 	unsigned long flags;
 
 	LASSERT(net);
@@ -643,7 +643,7 @@  struct kib_conn *kiblnd_create_conn(struct kib_peer *peer, struct rdma_cm_id *cm
 
 	dev = net->ibn_dev;
 
-	cpt = lnet_cpt_of_nid(peer->ibp_nid);
+	cpt = lnet_cpt_of_nid(peer->ibp_nid, peer->ibp_ni);
 	sched = kiblnd_data.kib_scheds[cpt];
 
 	LASSERT(sched->ibs_nthreads > 0);
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index c266940cb2ae..e64c14914924 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -119,7 +119,7 @@  kiblnd_get_idle_tx(struct lnet_ni *ni, lnet_nid_t target)
 	struct kib_tx *tx;
 	struct kib_tx_poolset *tps;
 
-	tps = net->ibn_tx_ps[lnet_cpt_of_nid(target)];
+	tps = net->ibn_tx_ps[lnet_cpt_of_nid(target, ni)];
 	node = kiblnd_pool_alloc_node(&tps->tps_poolset);
 	if (!node)
 		return NULL;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 2036a0ae5917..ba68bcee90bc 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -101,7 +101,7 @@  static int
 ksocknal_create_peer(struct ksock_peer **peerp, struct lnet_ni *ni,
 		     struct lnet_process_id id)
 {
-	int cpt = lnet_cpt_of_nid(id.nid);
+	int cpt = lnet_cpt_of_nid(id.nid, ni);
 	struct ksock_net *net = ni->ni_data;
 	struct ksock_peer *peer;
 
@@ -1099,7 +1099,7 @@  ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
 	LASSERT(conn->ksnc_proto);
 	LASSERT(peerid.nid != LNET_NID_ANY);
 
-	cpt = lnet_cpt_of_nid(peerid.nid);
+	cpt = lnet_cpt_of_nid(peerid.nid, ni);
 
 	if (active) {
 		ksocknal_peer_addref(peer);
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index c21aef32cdde..6e0b8310574d 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -713,31 +713,41 @@  lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)
 }
 
 int
-lnet_cpt_of_nid_locked(lnet_nid_t nid)
+lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni)
 {
-	struct lnet_ni *ni;
+	struct lnet_net *net;
 
 	/* must called with hold of lnet_net_lock */
 	if (LNET_CPT_NUMBER == 1)
 		return 0; /* the only one */
 
-	/* take lnet_net_lock(any) would be OK */
-	if (!list_empty(&the_lnet.ln_nis_cpt)) {
-		list_for_each_entry(ni, &the_lnet.ln_nis_cpt, ni_cptlist) {
-			if (LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid))
-				continue;
+	/*
+	 * If NI is provided then use the CPT identified in the NI cpt
+	 * list if one exists. If one doesn't exist, then that NI is
+	 * associated with all CPTs and it follows that the net it belongs
+	 * to is implicitly associated with all CPTs, so just hash the nid
+	 * and return that.
+	 */
+	if (ni != NULL) {
+		if (ni->ni_cpts != NULL)
+			return ni->ni_cpts[lnet_nid_cpt_hash(nid,
+							     ni->ni_ncpts)];
+		else
+			return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
+	}
 
-			LASSERT(ni->ni_cpts);
-			return ni->ni_cpts[lnet_nid_cpt_hash
-					   (nid, ni->ni_ncpts)];
-		}
+	/* no NI provided so look at the net */
+	net = lnet_get_net_locked(LNET_NIDNET(nid));
+
+	if (net != NULL && net->net_cpts) {
+		return net->net_cpts[lnet_nid_cpt_hash(nid, net->net_ncpts)];
 	}
 
 	return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
 }
 
 int
-lnet_cpt_of_nid(lnet_nid_t nid)
+lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni)
 {
 	int cpt;
 	int cpt2;
@@ -745,11 +755,10 @@  lnet_cpt_of_nid(lnet_nid_t nid)
 	if (LNET_CPT_NUMBER == 1)
 		return 0; /* the only one */
 
-	if (list_empty(&the_lnet.ln_nis_cpt))
-		return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
-
 	cpt = lnet_net_lock_current();
-	cpt2 = lnet_cpt_of_nid_locked(nid);
+
+	cpt2 = lnet_cpt_of_nid_locked(nid, ni);
+
 	lnet_net_unlock(cpt);
 
 	return cpt2;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index b6e81a693fc3..02cd1a5a466f 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -1095,7 +1095,9 @@  lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid)
 	msg->msg_sending = 1;
 
 	LASSERT(!msg->msg_tx_committed);
-	cpt = lnet_cpt_of_nid(rtr_nid == LNET_NID_ANY ? dst_nid : rtr_nid);
+	local_ni = lnet_net2ni(LNET_NIDNET(dst_nid));
+	cpt = lnet_cpt_of_nid(rtr_nid == LNET_NID_ANY ? dst_nid : rtr_nid,
+			      local_ni);
  again:
 	lnet_net_lock(cpt);
 
@@ -1188,7 +1190,7 @@  lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid)
 		 * was changed when we release the lock
 		 */
 		if (rtr_nid != lp->lp_nid) {
-			cpt2 = lnet_cpt_of_nid_locked(lp->lp_nid);
+			cpt2 = lp->lp_cpt;
 			if (cpt2 != cpt) {
 				if (src_ni)
 					lnet_ni_decref_locked(src_ni, cpt);
@@ -1677,7 +1679,7 @@  lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
 	payload_length = le32_to_cpu(hdr->payload_length);
 
 	for_me = (ni->ni_nid == dest_nid);
-	cpt = lnet_cpt_of_nid(from_nid);
+	cpt = lnet_cpt_of_nid(from_nid, ni);
 
 	switch (type) {
 	case LNET_MSG_ACK:
@@ -2149,7 +2151,7 @@  lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)
 	lnet_msg_attach_md(msg, getmd, getmd->md_offset, getmd->md_length);
 	lnet_res_unlock(cpt);
 
-	cpt = lnet_cpt_of_nid(peer_id.nid);
+	cpt = lnet_cpt_of_nid(peer_id.nid, ni);
 
 	lnet_net_lock(cpt);
 	lnet_msg_commit(msg, cpt);
@@ -2160,7 +2162,7 @@  lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)
 	return msg;
 
  drop:
-	cpt = lnet_cpt_of_nid(peer_id.nid);
+	cpt = lnet_cpt_of_nid(peer_id.nid, ni);
 
 	lnet_net_lock(cpt);
 	the_lnet.ln_counters[cpt]->drop_count++;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
index 90ce51801726..c8d8162cc706 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
@@ -220,7 +220,7 @@  lnet_match2mt(struct lnet_portal *ptl, struct lnet_process_id id, __u64 mbits)
 
 	/* if it's a unique portal, return match-table hashed by NID */
 	return lnet_ptl_is_unique(ptl) ?
-	       ptl->ptl_mtables[lnet_cpt_of_nid(id.nid)] : NULL;
+	       ptl->ptl_mtables[lnet_cpt_of_nid(id.nid, NULL)] : NULL;
 }
 
 struct lnet_match_table *
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index ed29124ebded..808ce25f1f00 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -270,7 +270,7 @@  lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
 		return -ESHUTDOWN;
 
 	/* cpt can be LNET_LOCK_EX if it's called from router functions */
-	cpt2 = cpt != LNET_LOCK_EX ? cpt : lnet_cpt_of_nid_locked(nid);
+	cpt2 = cpt != LNET_LOCK_EX ? cpt : lnet_cpt_of_nid_locked(nid, NULL);
 
 	ptable = the_lnet.ln_peer_tables[cpt2];
 	lp = lnet_find_peer_locked(ptable, nid);
@@ -362,7 +362,7 @@  lnet_debug_peer(lnet_nid_t nid)
 	int rc;
 	int cpt;
 
-	cpt = lnet_cpt_of_nid(nid);
+	cpt = lnet_cpt_of_nid(nid, NULL);
 	lnet_net_lock(cpt);
 
 	rc = lnet_nid2peer_locked(&lp, nid, cpt);
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 72b8ca2b0fc6..5493d13de6d9 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1207,7 +1207,7 @@  lnet_router_checker(void *arg)
 		version = the_lnet.ln_routers_version;
 
 		list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) {
-			cpt2 = lnet_cpt_of_nid_locked(rtr->lp_nid);
+			cpt2 = rtr->lp_cpt;
 			if (cpt != cpt2) {
 				lnet_net_unlock(cpt);
 				cpt = cpt2;
@@ -1693,7 +1693,7 @@  lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, time64_t when)
 {
 	struct lnet_peer *lp = NULL;
 	time64_t now = ktime_get_seconds();
-	int cpt = lnet_cpt_of_nid(nid);
+	int cpt = lnet_cpt_of_nid(nid, ni);
 
 	LASSERT(!in_interrupt());
 
diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
index f1ee219bc8f3..e372ff3044c8 100644
--- a/drivers/staging/lustre/lnet/selftest/brw_test.c
+++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
@@ -124,7 +124,7 @@  brw_client_init(struct sfw_test_instance *tsi)
 		return -EINVAL;
 
 	list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) {
-		bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid),
+		bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid, NULL),
 				       off, npg, len, opc == LST_BRW_READ);
 		if (!bulk) {
 			brw_client_fini(tsi);
diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
index 944a2a6598fa..a82efc394659 100644
--- a/drivers/staging/lustre/lnet/selftest/framework.c
+++ b/drivers/staging/lustre/lnet/selftest/framework.c
@@ -1013,7 +1013,8 @@  sfw_run_batch(struct sfw_batch *tsb)
 			tsu->tsu_loop = tsi->tsi_loop;
 			wi = &tsu->tsu_worker;
 			swi_init_workitem(wi, sfw_run_test,
-					  lst_test_wq[lnet_cpt_of_nid(tsu->tsu_dest.nid)]);
+					  lst_test_wq[lnet_cpt_of_nid(tsu->tsu_dest.nid,
+							  NULL)]);
 			swi_schedule_workitem(wi);
 		}
 	}
diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h
index 9dbb0a51d430..edf783af90e8 100644
--- a/drivers/staging/lustre/lnet/selftest/selftest.h
+++ b/drivers/staging/lustre/lnet/selftest/selftest.h
@@ -527,7 +527,7 @@  srpc_init_client_rpc(struct srpc_client_rpc *rpc, struct lnet_process_id peer,
 
 	INIT_LIST_HEAD(&rpc->crpc_list);
 	swi_init_workitem(&rpc->crpc_wi, srpc_send_rpc,
-			  lst_test_wq[lnet_cpt_of_nid(peer.nid)]);
+			  lst_test_wq[lnet_cpt_of_nid(peer.nid, NULL)]);
 	spin_lock_init(&rpc->crpc_lock);
 	atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */