X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lnet%2Fklnds%2Fgnilnd%2Fgnilnd_cb.c;h=ea712dc963dc09ad7c7086a15f36425fb194bf2e;hp=c8b4fe61d88dce57f06f6a314f1c4483c6779ff1;hb=7a74d382d5e8867785f662aede54a3e399168325;hpb=dab78a9efd05e4f22fc83232bdadce347d3dafda diff --git a/lnet/klnds/gnilnd/gnilnd_cb.c b/lnet/klnds/gnilnd/gnilnd_cb.c index c8b4fe6..ea712dc 100644 --- a/lnet/klnds/gnilnd/gnilnd_cb.c +++ b/lnet/klnds/gnilnd/gnilnd_cb.c @@ -26,6 +26,7 @@ #include #include +#include #include "gnilnd.h" /* this is useful when needed to debug wire corruption. */ @@ -81,7 +82,6 @@ kgnilnd_schedule_device(kgn_device_t *dev) if (!already_live) { wake_up_all(&dev->gnd_waitq); } - return; } void kgnilnd_schedule_device_timer(unsigned long arg) @@ -151,7 +151,7 @@ kgnilnd_schedule_process_conn(kgn_conn_t *conn, int sched_intent) * as scheduled */ int -_kgnilnd_schedule_conn(kgn_conn_t *conn, const char *caller, int line, int refheld) +_kgnilnd_schedule_conn(kgn_conn_t *conn, const char *caller, int line, int refheld, int lock_held) { kgn_device_t *dev = conn->gnc_device; int sched; @@ -184,10 +184,11 @@ _kgnilnd_schedule_conn(kgn_conn_t *conn, const char *caller, int line, int refhe conn, sched); CDEBUG(D_INFO, "scheduling conn 0x%p caller %s:%d\n", conn, caller, line); - - spin_lock(&dev->gnd_lock); + if (!lock_held) + spin_lock(&dev->gnd_lock); list_add_tail(&conn->gnc_schedlist, &dev->gnd_ready_conns); - spin_unlock(&dev->gnd_lock); + if (!lock_held) + spin_unlock(&dev->gnd_lock); set_mb(conn->gnc_last_sched_ask, jiffies); rc = 1; } else { @@ -197,6 +198,23 @@ _kgnilnd_schedule_conn(kgn_conn_t *conn, const char *caller, int line, int refhe /* make sure thread(s) going to process conns - but let it make * separate decision from conn schedule */ + if (!lock_held) + kgnilnd_schedule_device(dev); + return rc; +} + +int +_kgnilnd_schedule_delay_conn(kgn_conn_t *conn) +{ + kgn_device_t *dev = conn->gnc_device; + int rc = 0; + spin_lock(&dev->gnd_lock); + if (list_empty(&conn->gnc_delaylist)) { + list_add_tail(&conn->gnc_delaylist, &dev->gnd_delay_conns); + rc = 1; + } + spin_unlock(&dev->gnd_lock); + kgnilnd_schedule_device(dev); return rc; } @@ -303,8 +321,8 @@ kgnilnd_cksum(void *ptr, size_t nob) } __u16 -kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov, - unsigned int offset, unsigned int nob, int dump_blob) +kgnilnd_cksum_kiov(unsigned int nkiov, struct bio_vec *kiov, + unsigned int offset, unsigned int nob, int dump_blob) { __wsum cksum = 0; __wsum tmpck; @@ -321,15 +339,15 @@ kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov, /* if loops changes, please change kgnilnd_setup_phys_buffer */ - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; + while (offset >= kiov->bv_len) { + offset -= kiov->bv_len; nkiov--; kiov++; LASSERT(nkiov > 0); } - /* ignore nob here, if nob < (kiov_len - offset), kiov == 1 */ - odd = (unsigned long) (kiov[0].kiov_len - offset) & 1; + /* ignore nob here, if nob < (bv_len - offset), kiov == 1 */ + odd = (unsigned long) (kiov[0].bv_len - offset) & 1; if ((odd || *kgnilnd_tunables.kgn_vmap_cksum) && nkiov > 1) { struct page **pages = kgnilnd_data.kgn_cksum_map_pages[get_cpu()]; @@ -338,10 +356,10 @@ kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov, get_cpu(), kgnilnd_data.kgn_cksum_map_pages); CDEBUG(D_BUFFS, "odd %d len %u offset %u nob %u\n", - odd, kiov[0].kiov_len, offset, nob); + odd, kiov[0].bv_len, offset, nob); for (i = 0; i < nkiov; i++) { - pages[i] = kiov[i].kiov_page; + pages[i] = kiov[i].bv_page; } addr = vmap(pages, nkiov, VM_MAP, PAGE_KERNEL); @@ -354,42 +372,46 @@ kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov, } atomic_inc(&kgnilnd_data.kgn_nvmap_cksum); - tmpck = _kgnilnd_cksum(0, (void *) addr + kiov[0].kiov_offset + offset, nob); + tmpck = _kgnilnd_cksum(0, ((void *) addr + kiov[0].bv_offset + + offset), nob); cksum = tmpck; if (dump_blob) { kgnilnd_dump_blob(D_BUFFS, "flat kiov RDMA payload", - (void *)addr + kiov[0].kiov_offset + offset, nob); + (void *)addr + kiov[0].bv_offset + + offset, nob); } CDEBUG(D_BUFFS, "cksum 0x%x (+0x%x) for addr 0x%p+%u len %u offset %u\n", - cksum, tmpck, addr, kiov[0].kiov_offset, nob, offset); + cksum, tmpck, addr, kiov[0].bv_offset, nob, offset); vunmap(addr); } else { do { - fraglen = min(kiov->kiov_len - offset, nob); + fraglen = min(kiov->bv_len - offset, nob); /* make dang sure we don't send a bogus checksum if somehow we get * an odd length fragment on anything but the last entry in a kiov - * we know from kgnilnd_setup_rdma_buffer that we can't have non * PAGE_SIZE pages in the middle, so if nob < PAGE_SIZE, it is the last one */ LASSERTF(!(fraglen&1) || (nob < PAGE_SIZE), - "odd fraglen %u on nkiov %d, nob %u kiov_len %u offset %u kiov 0x%p\n", - fraglen, nkiov, nob, kiov->kiov_len, offset, kiov); + "odd fraglen %u on nkiov %d, nob %u bv_len %u offset %u kiov 0x%p\n", + fraglen, nkiov, nob, kiov->bv_len, + offset, kiov); - addr = (void *)kmap(kiov->kiov_page) + kiov->kiov_offset + offset; + addr = (void *)kmap(kiov->bv_page) + kiov->bv_offset + + offset; tmpck = _kgnilnd_cksum(cksum, addr, fraglen); CDEBUG(D_BUFFS, "cksum 0x%x (+0x%x) for page 0x%p+%u (0x%p) len %u offset %u\n", - cksum, tmpck, kiov->kiov_page, kiov->kiov_offset, addr, - fraglen, offset); + cksum, tmpck, kiov->bv_page, kiov->bv_offset, + addr, fraglen, offset); cksum = tmpck; if (dump_blob) kgnilnd_dump_blob(D_BUFFS, "kiov cksum", addr, fraglen); - kunmap(kiov->kiov_page); + kunmap(kiov->bv_page); kiov++; nkiov--; @@ -491,7 +513,7 @@ kgnilnd_nak_rdma(kgn_conn_t *conn, int rx_type, int error, __u64 cookie, lnet_ni int kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov, - struct kvec *iov, lnet_kiov_t *kiov, + struct kvec *iov, struct bio_vec *kiov, unsigned int offset, unsigned int nob) { kgn_msg_t *msg = &tx->tx_msg; @@ -507,42 +529,45 @@ kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov, } else if (kiov != NULL) { if ((niov > 0) && unlikely(niov > (nob/PAGE_SIZE))) { - niov = ((nob + offset + kiov->kiov_offset + PAGE_SIZE - 1) / - PAGE_SIZE); + niov = round_up(nob + offset + kiov->bv_offset, + PAGE_SIZE); } LASSERTF(niov > 0 && niov < GNILND_MAX_IMMEDIATE/PAGE_SIZE, "bad niov %d msg %p kiov %p iov %p offset %d nob%d\n", niov, msg, kiov, iov, offset, nob); - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; + while (offset >= kiov->bv_len) { + offset -= kiov->bv_len; niov--; kiov++; LASSERT(niov > 0); } for (i = 0; i < niov; i++) { - /* We can't have a kiov_offset on anything but the first entry, - * otherwise we'll have a hole at the end of the mapping as we only map - * whole pages. - * Also, if we have a kiov_len < PAGE_SIZE but we need to map more - * than kiov_len, we will also have a whole at the end of that page - * which isn't allowed */ - if ((kiov[i].kiov_offset != 0 && i > 0) || - (kiov[i].kiov_offset + kiov[i].kiov_len != PAGE_SIZE && i < niov - 1)) { - CNETERR("Can't make payload contiguous in I/O VM:" - "page %d, offset %u, nob %u, kiov_offset %u kiov_len %u \n", - i, offset, nob, kiov->kiov_offset, kiov->kiov_len); + /* We can't have a bv_offset on anything but the first + * entry, otherwise we'll have a hole at the end of the + * mapping as we only map whole pages. + * Also, if we have a bv_len < PAGE_SIZE but we need to + * map more than bv_len, we will also have a whole at + * the end of that page which isn't allowed + */ + if ((kiov[i].bv_offset != 0 && i > 0) || + (kiov[i].bv_offset + kiov[i].bv_len != PAGE_SIZE && + i < niov - 1)) { + CNETERR("Can't make payload contiguous in I/O VM:page %d, offset %u, nob %u, bv_offset %u bv_len %u\n", + i, offset, nob, kiov->bv_offset, + kiov->bv_len); RETURN(-EINVAL); } - tx->tx_imm_pages[i] = kiov[i].kiov_page; + tx->tx_imm_pages[i] = kiov[i].bv_page; } /* hijack tx_phys for the later unmap */ if (niov == 1) { /* tx->phyx being equal to NULL is the signal for unmap to discern between kmap and vmap */ tx->tx_phys = NULL; - tx->tx_buffer = (void *)kmap(tx->tx_imm_pages[0]) + kiov[0].kiov_offset + offset; + tx->tx_buffer = (void *)kmap(tx->tx_imm_pages[0]) + + kiov[0].bv_offset + offset; atomic_inc(&kgnilnd_data.kgn_nkmap_short); GNIDBG_TX(D_NET, tx, "kmapped page for %d bytes for kiov 0x%p, buffer 0x%p", nob, kiov, tx->tx_buffer); @@ -554,10 +579,14 @@ kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov, } atomic_inc(&kgnilnd_data.kgn_nvmap_short); - /* make sure we take into account the kiov offset as the start of the buffer */ - tx->tx_buffer = (void *)tx->tx_phys + kiov[0].kiov_offset + offset; - GNIDBG_TX(D_NET, tx, "mapped %d pages for %d bytes from kiov 0x%p to 0x%p, buffer 0x%p", - niov, nob, kiov, tx->tx_phys, tx->tx_buffer); + /* make sure we take into account the kiov offset as the + * start of the buffer + */ + tx->tx_buffer = (void *)tx->tx_phys + kiov[0].bv_offset + + offset; + GNIDBG_TX(D_NET, tx, + "mapped %d pages for %d bytes from kiov 0x%p to 0x%p, buffer 0x%p", + niov, nob, kiov, tx->tx_phys, tx->tx_buffer); } tx->tx_buftype = GNILND_BUF_IMMEDIATE_KIOV; tx->tx_nob = nob; @@ -633,7 +662,7 @@ kgnilnd_setup_virt_buffer(kgn_tx_t *tx, } int -kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov, +kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, struct bio_vec *kiov, unsigned int offset, unsigned int nob) { gni_mem_segment_t *phys; @@ -661,8 +690,8 @@ kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov, /* if loops changes, please change kgnilnd_cksum_kiov * and kgnilnd_setup_immediate_buffer */ - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; + while (offset >= kiov->bv_len) { + offset -= kiov->bv_len; nkiov--; kiov++; LASSERT(nkiov > 0); @@ -674,31 +703,31 @@ kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov, tx->tx_buftype = GNILND_BUF_PHYS_UNMAPPED; tx->tx_nob = nob; - /* kiov_offset is start of 'valid' buffer, so index offset past that */ - tx->tx_buffer = (void *)((unsigned long)(kiov->kiov_offset + offset)); + /* bv_offset is start of 'valid' buffer, so index offset past that */ + tx->tx_buffer = (void *)((unsigned long)(kiov->bv_offset + offset)); phys = tx->tx_phys; CDEBUG(D_NET, "tx 0x%p buffer 0x%p map start kiov 0x%p+%u niov %d offset %u\n", - tx, tx->tx_buffer, kiov, kiov->kiov_offset, nkiov, offset); + tx, tx->tx_buffer, kiov, kiov->bv_offset, nkiov, offset); do { - fraglen = min(kiov->kiov_len - offset, nob); - - /* We can't have a kiov_offset on anything but the first entry, - * otherwise we'll have a hole at the end of the mapping as we only map - * whole pages. Only the first page is allowed to have an offset - - * we'll add that into tx->tx_buffer and that will get used when we - * map in the segments (see kgnilnd_map_buffer). - * Also, if we have a kiov_len < PAGE_SIZE but we need to map more - * than kiov_len, we will also have a whole at the end of that page - * which isn't allowed */ + fraglen = min(kiov->bv_len - offset, nob); + + /* We can't have a bv_offset on anything but the first entry, + * otherwise we'll have a hole at the end of the mapping as we + * only map whole pages. Only the first page is allowed to + * have an offset - we'll add that into tx->tx_buffer and that + * will get used when we map in the segments (see + * kgnilnd_map_buffer). Also, if we have a bv_len < PAGE_SIZE + * but we need to map more than bv_len, we will also have a + * whole at the end of that page which isn't allowed + */ if ((phys != tx->tx_phys) && - ((kiov->kiov_offset != 0) || - ((kiov->kiov_len < PAGE_SIZE) && (nob > kiov->kiov_len)))) { - CERROR("Can't make payload contiguous in I/O VM:" - "page %d, offset %u, nob %u, kiov_offset %u kiov_len %u \n", + ((kiov->bv_offset != 0) || + ((kiov->bv_len < PAGE_SIZE) && (nob > kiov->bv_len)))) { + CERROR("Can't make payload contiguous in I/O VM:page %d, offset %u, nob %u, bv_offset %u bv_len %u\n", (int)(phys - tx->tx_phys), - offset, nob, kiov->kiov_offset, kiov->kiov_len); + offset, nob, kiov->bv_offset, kiov->bv_len); rc = -EINVAL; GOTO(error, rc); } @@ -714,11 +743,12 @@ kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov, GOTO(error, rc); } - CDEBUG(D_BUFFS, "page 0x%p kiov_offset %u kiov_len %u nob %u " - "nkiov %u offset %u\n", - kiov->kiov_page, kiov->kiov_offset, kiov->kiov_len, nob, nkiov, offset); + CDEBUG(D_BUFFS, + "page 0x%p bv_offset %u bv_len %u nob %u nkiov %u offset %u\n", + kiov->bv_page, kiov->bv_offset, kiov->bv_len, nob, nkiov, + offset); - phys->address = page_to_phys(kiov->kiov_page); + phys->address = page_to_phys(kiov->bv_page); phys++; kiov++; nkiov--; @@ -746,7 +776,7 @@ error: static inline int kgnilnd_setup_rdma_buffer(kgn_tx_t *tx, unsigned int niov, - struct kvec *iov, lnet_kiov_t *kiov, + struct kvec *iov, struct bio_vec *kiov, unsigned int offset, unsigned int nob) { int rc; @@ -774,9 +804,9 @@ kgnilnd_setup_rdma_buffer(kgn_tx_t *tx, unsigned int niov, * transfer. */ static void -kgnilnd_parse_lnet_rdma(lnet_msg_t *lntmsg, unsigned int *niov, +kgnilnd_parse_lnet_rdma(struct lnet_msg *lntmsg, unsigned int *niov, unsigned int *offset, unsigned int *nob, - lnet_kiov_t **kiov, int put_len) + struct bio_vec **kiov, int put_len) { /* GETs are weird, see kgnilnd_send */ if (lntmsg->msg_type == LNET_MSG_GET) { @@ -799,10 +829,10 @@ kgnilnd_parse_lnet_rdma(lnet_msg_t *lntmsg, unsigned int *niov, static inline void kgnilnd_compute_rdma_cksum(kgn_tx_t *tx, int put_len) { - unsigned int niov, offset, nob; - lnet_kiov_t *kiov; - lnet_msg_t *lntmsg = tx->tx_lntmsg[0]; - int dump_cksum = (*kgnilnd_tunables.kgn_checksum_dump > 1); + unsigned int niov, offset, nob; + struct bio_vec *kiov; + struct lnet_msg *lntmsg = tx->tx_lntmsg[0]; + int dump_cksum = (*kgnilnd_tunables.kgn_checksum_dump > 1); GNITX_ASSERTF(tx, ((tx->tx_msg.gnm_type == GNILND_MSG_PUT_DONE) || (tx->tx_msg.gnm_type == GNILND_MSG_GET_DONE) || @@ -852,8 +882,8 @@ kgnilnd_verify_rdma_cksum(kgn_tx_t *tx, __u16 rx_cksum, int put_len) int rc = 0; __u16 cksum; unsigned int niov, offset, nob; - lnet_kiov_t *kiov; - lnet_msg_t *lntmsg = tx->tx_lntmsg[0]; + struct bio_vec *kiov; + struct lnet_msg *lntmsg = tx->tx_lntmsg[0]; int dump_on_err = *kgnilnd_tunables.kgn_checksum_dump; /* we can only match certain requests */ @@ -1132,8 +1162,10 @@ kgnilnd_unmap_buffer(kgn_tx_t *tx, int error) int hold_timeout = 0; /* code below relies on +1 relationship ... */ - CLASSERT(GNILND_BUF_PHYS_MAPPED == (GNILND_BUF_PHYS_UNMAPPED + 1)); - CLASSERT(GNILND_BUF_VIRT_MAPPED == (GNILND_BUF_VIRT_UNMAPPED + 1)); + BUILD_BUG_ON(GNILND_BUF_PHYS_MAPPED != + (GNILND_BUF_PHYS_UNMAPPED + 1)); + BUILD_BUG_ON(GNILND_BUF_VIRT_MAPPED != + (GNILND_BUF_VIRT_UNMAPPED + 1)); switch (tx->tx_buftype) { default: @@ -1198,9 +1230,9 @@ kgnilnd_unmap_buffer(kgn_tx_t *tx, int error) void kgnilnd_tx_done(kgn_tx_t *tx, int completion) { - lnet_msg_t *lntmsg0, *lntmsg1; + struct lnet_msg *lntmsg0, *lntmsg1; int status0, status1; - lnet_ni_t *ni = NULL; + struct lnet_ni *ni = NULL; kgn_conn_t *conn = tx->tx_conn; LASSERT(!in_interrupt()); @@ -1343,70 +1375,35 @@ search_again: return 0; } -static inline int -kgnilnd_tx_should_retry(kgn_conn_t *conn, kgn_tx_t *tx) +static inline void +kgnilnd_tx_log_retrans(kgn_conn_t *conn, kgn_tx_t *tx) { - int max_retrans = *kgnilnd_tunables.kgn_max_retransmits; int log_retrans; - int log_retrans_level; - - /* I need kgni credits to send this. Replace tx at the head of the - * fmaq and I'll get rescheduled when credits appear */ - tx->tx_state = 0; - tx->tx_retrans++; - conn->gnc_tx_retrans++; - log_retrans = ((tx->tx_retrans < 25) || ((tx->tx_retrans % 25) == 0) || - (tx->tx_retrans > (max_retrans / 2))); - log_retrans_level = tx->tx_retrans < (max_retrans / 2) ? D_NET : D_NETERROR; - /* Decision time - either error, warn or just retransmit */ + log_retrans = ((tx->tx_retrans < 25) || ((tx->tx_retrans % 25) == 0)); /* we don't care about TX timeout - it could be that the network is slower * or throttled. We'll keep retranmitting - so if the network is so slow * that we fill up our mailbox, we'll keep trying to resend that msg * until we exceed the max_retrans _or_ gnc_last_rx expires, indicating * that he hasn't send us any traffic in return */ - - if (tx->tx_retrans > max_retrans) { - /* this means we are not backing off the retransmits - * in a healthy manner and are likely chewing up the - * CPU cycles quite badly */ - GNIDBG_TOMSG(D_ERROR, &tx->tx_msg, - "SOFTWARE BUG: too many retransmits (%d) for tx id %x " - "conn 0x%p->%s\n", - tx->tx_retrans, tx->tx_id, conn, - libcfs_nid2str(conn->gnc_peer->gnp_nid)); - - /* yes - double errors to help debug this condition */ - GNIDBG_TOMSG(D_NETERROR, &tx->tx_msg, "connection dead. " - "unable to send to %s for %lu secs (%d tries)", - libcfs_nid2str(tx->tx_conn->gnc_peer->gnp_nid), - cfs_duration_sec(jiffies - tx->tx_cred_wait), - tx->tx_retrans); - - kgnilnd_close_conn(conn, -ETIMEDOUT); - - /* caller should terminate */ - RETURN(0); - } else { - /* some reasonable throttling of the debug message */ - if (log_retrans) { - unsigned long now = jiffies; - /* XXX Nic: Mystical TX debug here... */ - GNIDBG_SMSG_CREDS(log_retrans_level, conn); - GNIDBG_TOMSG(log_retrans_level, &tx->tx_msg, - "NOT_DONE on conn 0x%p->%s id %x retrans %d wait %dus" - " last_msg %uus/%uus last_cq %uus/%uus", - conn, libcfs_nid2str(conn->gnc_peer->gnp_nid), - tx->tx_id, tx->tx_retrans, - jiffies_to_usecs(now - tx->tx_cred_wait), - jiffies_to_usecs(now - conn->gnc_last_tx), - jiffies_to_usecs(now - conn->gnc_last_rx), - jiffies_to_usecs(now - conn->gnc_last_tx_cq), - jiffies_to_usecs(now - conn->gnc_last_rx_cq)); - } - /* caller should retry */ - RETURN(1); + + /* some reasonable throttling of the debug message */ + if (log_retrans) { + unsigned long now = jiffies; + /* XXX Nic: Mystical TX debug here... */ + /* We expect retransmissions so only log when D_NET is enabled */ + GNIDBG_SMSG_CREDS(D_NET, conn); + GNIDBG_TOMSG(D_NET, &tx->tx_msg, + "NOT_DONE on conn 0x%p->%s id %x retrans %d wait %dus" + " last_msg %uus/%uus last_cq %uus/%uus", + conn, libcfs_nid2str(conn->gnc_peer->gnp_nid), + tx->tx_id, tx->tx_retrans, + jiffies_to_usecs(now - tx->tx_cred_wait), + jiffies_to_usecs(now - conn->gnc_last_tx), + jiffies_to_usecs(now - conn->gnc_last_rx), + jiffies_to_usecs(now - conn->gnc_last_tx_cq), + jiffies_to_usecs(now - conn->gnc_last_rx_cq)); } } @@ -1419,7 +1416,6 @@ kgnilnd_sendmsg_nolock(kgn_tx_t *tx, void *immediate, unsigned int immediatenob, { kgn_conn_t *conn = tx->tx_conn; kgn_msg_t *msg = &tx->tx_msg; - int retry_send; gni_return_t rrc; unsigned long newest_last_rx, timeout; unsigned long now; @@ -1529,9 +1525,11 @@ kgnilnd_sendmsg_nolock(kgn_tx_t *tx, void *immediate, unsigned int immediatenob, return 0; case GNI_RC_NOT_DONE: - /* XXX Nic: We need to figure out how to track this - * - there are bound to be good reasons for it, - * but we want to know when it happens */ + /* Jshimek: We can get GNI_RC_NOT_DONE for 3 reasons currently + * 1: out of mbox credits + * 2: out of mbox payload credits + * 3: On Aries out of dla credits + */ kgnilnd_conn_mutex_unlock(&conn->gnc_smsg_mutex); kgnilnd_gl_mutex_unlock(&conn->gnc_device->gnd_cq_mutex); /* We'll handle this error inline - makes the calling logic much more @@ -1542,31 +1540,36 @@ kgnilnd_sendmsg_nolock(kgn_tx_t *tx, void *immediate, unsigned int immediatenob, return -EAGAIN; } - retry_send = kgnilnd_tx_should_retry(conn, tx); - if (retry_send) { - /* add to head of list for the state and retries */ - spin_lock(state_lock); - kgnilnd_tx_add_state_locked(tx, conn->gnc_peer, conn, state, 0); - spin_unlock(state_lock); - - /* We only reschedule for a certain number of retries, then - * we will wait for the CQ events indicating a release of SMSG - * credits */ - if (tx->tx_retrans < (*kgnilnd_tunables.kgn_max_retransmits/4)) { - kgnilnd_schedule_conn(conn); - return 0; - } else { - /* CQ event coming in signifies either TX completed or - * RX receive. Either of these *could* free up credits - * in the SMSG mbox and we should try sending again */ - GNIDBG_TX(D_NET, tx, "waiting for CQID %u event to resend", - tx->tx_conn->gnc_cqid); - /* use +ve return code to let upper layers know they - * should stop looping on sends */ - return EAGAIN; - } + /* I need kgni credits to send this. Replace tx at the head of the + * fmaq and I'll get rescheduled when credits appear. Reset the tx_state + * and bump retrans counts since we are requeueing the tx. + */ + tx->tx_state = 0; + tx->tx_retrans++; + conn->gnc_tx_retrans++; + + kgnilnd_tx_log_retrans(conn, tx); + /* add to head of list for the state and retries */ + spin_lock(state_lock); + kgnilnd_tx_add_state_locked(tx, conn->gnc_peer, conn, state, 0); + spin_unlock(state_lock); + + /* We only reschedule for a certain number of retries, then + * we will wait for the CQ events indicating a release of SMSG + * credits */ + if (tx->tx_retrans < *kgnilnd_tunables.kgn_max_retransmits) { + kgnilnd_schedule_conn(conn); + return 0; } else { - return -EAGAIN; + /* CQ event coming in signifies either TX completed or + * RX receive. Either of these *could* free up credits + * in the SMSG mbox and we should try sending again */ + GNIDBG_TX(D_NET, tx, "waiting for CQID %u event to resend", + tx->tx_conn->gnc_cqid); + kgnilnd_schedule_delay_conn(conn); + /* use +ve return code to let upper layers know they + * should stop looping on sends */ + return EAGAIN; } default: /* handle bad retcode gracefully */ @@ -1770,7 +1773,7 @@ kgnilnd_queue_tx(kgn_conn_t *conn, kgn_tx_t *tx) } void -kgnilnd_launch_tx(kgn_tx_t *tx, kgn_net_t *net, lnet_process_id_t *target) +kgnilnd_launch_tx(kgn_tx_t *tx, kgn_net_t *net, struct lnet_process_id *target) { kgn_peer_t *peer; kgn_peer_t *new_peer = NULL; @@ -1924,11 +1927,11 @@ kgnilnd_rdma(kgn_tx_t *tx, int type, tx->tx_offset = ((__u64)((unsigned long)sink->gnrd_addr)) & 3; if (tx->tx_offset) - kgnilnd_admin_addref(kgnilnd_data.kgn_rev_offset); + atomic_inc(&kgnilnd_data.kgn_rev_offset); if ((nob + tx->tx_offset) & 3) { desc_nob = ((nob + tx->tx_offset) + (4 - ((nob + tx->tx_offset) & 3))); - kgnilnd_admin_addref(kgnilnd_data.kgn_rev_length); + atomic_inc(&kgnilnd_data.kgn_rev_length); } else { desc_nob = (nob + tx->tx_offset); } @@ -1944,7 +1947,7 @@ kgnilnd_rdma(kgn_tx_t *tx, int type, kgnilnd_tx_done(tx, -EFAULT); return 0; } - kgnilnd_admin_addref(kgnilnd_data.kgn_rev_copy_buff); + atomic_inc(&kgnilnd_data.kgn_rev_copy_buff); rc = kgnilnd_mem_register(conn->gnc_device->gnd_handle, (__u64)tx->tx_buffer_copy, desc_nob, NULL, GNI_MEM_READWRITE, &tx->tx_buffer_copy_map_key); if (rc != GNI_RC_SUCCESS) { /* Registration Failed nak rdma and kill the tx. */ @@ -2080,7 +2083,7 @@ kgnilnd_release_msg(kgn_conn_t *conn) LASSERTF(rrc == GNI_RC_SUCCESS, "bad rrc %d\n", rrc); GNIDBG_SMSG_CREDS(D_NET, conn); - return; + kgnilnd_schedule_conn(conn); } void @@ -2104,21 +2107,19 @@ kgnilnd_consume_rx(kgn_rx_t *rx) kmem_cache_free(kgnilnd_data.kgn_rx_cache, rx); CDEBUG(D_MALLOC, "slab-freed 'rx': %lu at %p.\n", sizeof(*rx), rx); - - return; } int -kgnilnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) +kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg) { struct lnet_hdr *hdr = &lntmsg->msg_hdr; int type = lntmsg->msg_type; - lnet_process_id_t target = lntmsg->msg_target; + struct lnet_process_id target = lntmsg->msg_target; int target_is_router = lntmsg->msg_target_is_router; int routing = lntmsg->msg_routing; unsigned int niov = lntmsg->msg_niov; struct kvec *iov = lntmsg->msg_iov; - lnet_kiov_t *kiov = lntmsg->msg_kiov; + struct bio_vec *kiov = lntmsg->msg_kiov; unsigned int offset = lntmsg->msg_offset; unsigned int nob = lntmsg->msg_len; unsigned int msg_vmflush = lntmsg->msg_vmflush; @@ -2281,13 +2282,13 @@ out: } void -kgnilnd_setup_rdma(lnet_ni_t *ni, kgn_rx_t *rx, lnet_msg_t *lntmsg, int mlen) +kgnilnd_setup_rdma(struct lnet_ni *ni, kgn_rx_t *rx, struct lnet_msg *lntmsg, int mlen) { kgn_conn_t *conn = rx->grx_conn; kgn_msg_t *rxmsg = rx->grx_msg; unsigned int niov = lntmsg->msg_niov; struct kvec *iov = lntmsg->msg_iov; - lnet_kiov_t *kiov = lntmsg->msg_kiov; + struct bio_vec *kiov = lntmsg->msg_kiov; unsigned int offset = lntmsg->msg_offset; unsigned int nob = lntmsg->msg_len; int done_type; @@ -2342,7 +2343,7 @@ kgnilnd_setup_rdma(lnet_ni_t *ni, kgn_rx_t *rx, lnet_msg_t *lntmsg, int mlen) } int -kgnilnd_eager_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, +kgnilnd_eager_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg, void **new_private) { kgn_rx_t *rx = private; @@ -2433,9 +2434,9 @@ kgnilnd_eager_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, } int -kgnilnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, +kgnilnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg, int delayed, unsigned int niov, - struct kvec *iov, lnet_kiov_t *kiov, + struct kvec *iov, struct bio_vec *kiov, unsigned int offset, unsigned int mlen, unsigned int rlen) { kgn_rx_t *rx = private; @@ -2811,7 +2812,7 @@ kgnilnd_check_peer_timeouts_locked(kgn_peer_t *peer, struct list_head *todie, peer, libcfs_nid2str(peer->gnp_nid), peer->gnp_reconnect_interval); - timeout = cfs_time_seconds(MAX(*kgnilnd_tunables.kgn_timeout, + timeout = cfs_time_seconds(max(*kgnilnd_tunables.kgn_timeout, GNILND_MIN_TIMEOUT)); conn = kgnilnd_find_conn_locked(peer); @@ -2895,8 +2896,9 @@ kgnilnd_check_peer_timeouts_locked(kgn_peer_t *peer, struct list_head *todie, CDEBUG(D_NET, "starting connect to %s\n", libcfs_nid2str(peer->gnp_nid)); - LASSERTF(peer->gnp_connecting == GNILND_PEER_IDLE, "Peer was idle and we" - "have a write_lock, state issue %d\n", peer->gnp_connecting); + LASSERTF(peer->gnp_connecting == GNILND_PEER_IDLE, + "Peer was idle and we have a write_lock, state issue %d\n", + peer->gnp_connecting); peer->gnp_connecting = GNILND_PEER_CONNECT; kgnilnd_peer_addref(peer); /* extra ref for connd */ @@ -2986,8 +2988,6 @@ kgnilnd_check_peer_timeouts_locked(kgn_peer_t *peer, struct list_head *todie, } } } - - return; } void @@ -2995,11 +2995,8 @@ kgnilnd_reaper_check(int idx) { struct list_head *peers = &kgnilnd_data.kgn_peers[idx]; struct list_head *ctmp, *ctmpN; - struct list_head geriatrics; - struct list_head souls; - - INIT_LIST_HEAD(&geriatrics); - INIT_LIST_HEAD(&souls); + LIST_HEAD(geriatrics); + LIST_HEAD(souls); write_lock(&kgnilnd_data.kgn_peer_conn_lock); @@ -3051,8 +3048,6 @@ kgnilnd_reaper(void *arg) struct timer_list timer; DEFINE_WAIT(wait); - cfs_block_allsigs(); - /* all gnilnd threads need to run fairly urgently */ set_user_nice(current, *kgnilnd_tunables.kgn_nice); spin_lock(&kgnilnd_data.kgn_reaper_lock); @@ -3139,8 +3134,8 @@ kgnilnd_reaper(void *arg) int kgnilnd_recv_bte_get(kgn_tx_t *tx) { unsigned niov, offset, nob; - lnet_kiov_t *kiov; - lnet_msg_t *lntmsg = tx->tx_lntmsg[0]; + struct bio_vec *kiov; + struct lnet_msg *lntmsg = tx->tx_lntmsg[0]; kgnilnd_parse_lnet_rdma(lntmsg, &niov, &offset, &nob, &kiov, tx->tx_nob_rdma); if (kiov != NULL) { @@ -3338,6 +3333,7 @@ kgnilnd_check_fma_send_cq(kgn_device_t *dev) kgn_conn_t *conn = NULL; int queued_fma, saw_reply, rc; long num_processed = 0; + struct list_head *ctmp, *ctmpN; for (;;) { /* make sure we don't keep looping if we need to reset */ @@ -3360,6 +3356,22 @@ kgnilnd_check_fma_send_cq(kgn_device_t *dev) "SMSG send CQ %d not ready (data %#llx) " "processed %ld\n", dev->gnd_id, event_data, num_processed); + + if (num_processed > 0) { + spin_lock(&dev->gnd_lock); + if (!list_empty(&dev->gnd_delay_conns)) { + list_for_each_safe(ctmp, ctmpN, &dev->gnd_delay_conns) { + conn = list_entry(ctmp, kgn_conn_t, gnc_delaylist); + list_del_init(&conn->gnc_delaylist); + CDEBUG(D_NET, "Moving Conn %p from delay queue to ready_queue\n", conn); + kgnilnd_schedule_conn_nolock(conn); + } + spin_unlock(&dev->gnd_lock); + kgnilnd_schedule_device(dev); + } else { + spin_unlock(&dev->gnd_lock); + } + } return num_processed; } @@ -3529,8 +3541,7 @@ kgnilnd_check_fma_rcv_cq(kgn_device_t *dev) /* set overrun too */ event_data |= (1UL << 63); LASSERTF(GNI_CQ_OVERRUN(event_data), - "(1UL << 63) is no longer the bit to" - "set to indicate CQ_OVERRUN\n"); + "(1UL << 63) is no longer the bit to set to indicate CQ_OVERRUN\n"); } } /* sender should get error event too and take care @@ -4900,6 +4911,12 @@ kgnilnd_process_conns(kgn_device_t *dev, unsigned long deadline) conn = list_first_entry(&dev->gnd_ready_conns, kgn_conn_t, gnc_schedlist); list_del_init(&conn->gnc_schedlist); + /* + * Since we are processing conn now, we don't need to be on the delaylist any longer. + */ + + if (!list_empty(&conn->gnc_delaylist)) + list_del_init(&conn->gnc_delaylist); spin_unlock(&dev->gnd_lock); conn_sched = xchg(&conn->gnc_scheduled, GNILND_CONN_PROCESS); @@ -4926,7 +4943,7 @@ kgnilnd_process_conns(kgn_device_t *dev, unsigned long deadline) kgnilnd_conn_decref(conn); up_write(&dev->gnd_conn_sem); } else if (rc != 1) { - kgnilnd_conn_decref(conn); + kgnilnd_conn_decref(conn); } /* clear this so that scheduler thread doesn't spin */ found_work = 0; @@ -4977,7 +4994,7 @@ kgnilnd_process_conns(kgn_device_t *dev, unsigned long deadline) kgnilnd_conn_decref(conn); up_write(&dev->gnd_conn_sem); } else if (rc != 1) { - kgnilnd_conn_decref(conn); + kgnilnd_conn_decref(conn); } /* check list again with lock held */ @@ -5006,8 +5023,6 @@ kgnilnd_scheduler(void *arg) dev = &kgnilnd_data.kgn_devices[(threadno + 1) % kgnilnd_data.kgn_ndevs]; - cfs_block_allsigs(); - /* all gnilnd threads need to run fairly urgently */ set_user_nice(current, *kgnilnd_tunables.kgn_sched_nice); deadline = jiffies + cfs_time_seconds(*kgnilnd_tunables.kgn_sched_timeout);