IB/hfi1, rdmavt, qib: First batch of fixes for 4.8
Subsystems (3)
cover IB/hfi1, rdmavt, qib: First batch of fixes for 4.8
Hi Doug,
Here is a set of fixes and improvmenets that would be for the next release. They apply onto of the last set of RC fixes previously posted.
Of particular note in here is the twsi code clean up that was asked for previously while we were in staging. I think this does the job of not duplicating what is already present in the kernel. These are the two patches from Dean.
The patches from Mike improve rdmavt and make the posting of sends more friendly to work with and extend.
There are also performance improvement patches in this bunch as well as well as a couple minor fixes that we felt are more appropriate for the next merge cycle rather than RC.
These patches have been added to my GitHub branch and have passed zero day builds.
https://github.com/ddalessa/kernel/tree/for-4.8
---
Dean Luick (2):
IB/hfi1: Use built-in i2c bit-shift bus adapter IB/hfi1: Remove TWSI references
Ira Weiny (2):
IB/hfi1: Clean up port state structure definition IB/hfi1: Remove unnecessary done label in hfi1_write_iter
Jakub Pawlak (3):
IB/hfi1: Add VL XmitDiscards counters to the opapmaquery IB/hfi1: Add counter to track unsupported packets drop IB/hfi1: Correct receive packet handler assignment
Jianxin Xiong (1):
IB/hfi1: Improve SDMA engine assignment for user SDMA
Mike Marciniszyn (5):
IB/hfi1: Fix trace sparse errors
IB/rdmavt: Add data structures and routines for table driven post send IB/hfi1: Add hfi1 post send tables
IB/qib: Add qib post send table
IB/rdmavt: Use new driver specific post send table
Sebastian Sanchez (4):
IB/hfi1: Separate tracepoints into specific headers IB/hfi1: Add global structure for affinity assignments IB/hfi1: Reserve and collapse CPU cores for contexts IB/hfi1: Refine user process affinity algorithm
Tadeusz Struk (1):
IB/hfi1: Fix typo
drivers/infiniband/hw/hfi1/Kconfig | 3 drivers/infiniband/hw/hfi1/Makefile | 2 drivers/infiniband/hw/hfi1/affinity.c | 526 +++++++++-- drivers/infiniband/hw/hfi1/affinity.h | 34 + drivers/infiniband/hw/hfi1/chip.c | 82 +- drivers/infiniband/hw/hfi1/chip.h | 2 drivers/infiniband/hw/hfi1/driver.c | 1 drivers/infiniband/hw/hfi1/file_ops.c | 46 + drivers/infiniband/hw/hfi1/hfi.h | 67 + drivers/infiniband/hw/hfi1/init.c | 36 + drivers/infiniband/hw/hfi1/mad.c | 26 - drivers/infiniband/hw/hfi1/mad.h | 7 drivers/infiniband/hw/hfi1/qp.c | 44 + drivers/infiniband/hw/hfi1/qp.h | 2 drivers/infiniband/hw/hfi1/qsfp.c | 409 +++++++-- drivers/infiniband/hw/hfi1/qsfp.h | 3 drivers/infiniband/hw/hfi1/rc.c | 8 drivers/infiniband/hw/hfi1/trace.h | 1333 ----------------------------- drivers/infiniband/hw/hfi1/trace_ctxts.h | 141 +++ drivers/infiniband/hw/hfi1/trace_dbg.h | 155 +++ drivers/infiniband/hw/hfi1/trace_ibhdrs.h | 209 +++++ drivers/infiniband/hw/hfi1/trace_misc.h | 81 ++ drivers/infiniband/hw/hfi1/trace_rc.h | 123 +++ drivers/infiniband/hw/hfi1/trace_rx.h | 322 +++++++ drivers/infiniband/hw/hfi1/trace_tx.h | 642 ++++++++++++++ drivers/infiniband/hw/hfi1/twsi.c | 489 ----------- drivers/infiniband/hw/hfi1/twsi.h | 65 - drivers/infiniband/hw/hfi1/user_sdma.c | 29 + drivers/infiniband/hw/hfi1/verbs.c | 32 - drivers/infiniband/hw/qib/qib_qp.c | 43 + drivers/infiniband/hw/qib/qib_verbs.c | 2 drivers/infiniband/hw/qib/qib_verbs.h | 2 drivers/infiniband/sw/rdmavt/qp.c | 113 ++ drivers/infiniband/sw/rdmavt/vt.c | 3 include/rdma/opa_port_info.h | 16 include/rdma/rdma_vt.h | 3 include/rdma/rdmavt_qp.h | 28 + 37 files changed, 2811 insertions(+), 2318 deletions(-) create mode 100644 drivers/infiniband/hw/hfi1/trace_ctxts.h create mode 100644 drivers/infiniband/hw/hfi1/trace_dbg.h create mode 100644 drivers/infiniband/hw/hfi1/trace_ibhdrs.h create mode 100644 drivers/infiniband/hw/hfi1/trace_misc.h create mode 100644 drivers/infiniband/hw/hfi1/trace_rc.h create mode 100644 drivers/infiniband/hw/hfi1/trace_rx.h create mode 100644 drivers/infiniband/hw/hfi1/trace_tx.h delete mode 100644 drivers/infiniband/hw/hfi1/twsi.c delete mode 100644 drivers/infiniband/hw/hfi1/twsi.h
--
-Denny
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/18 IB/hfi1: Clean up port state structure definition
In reply to a message not in the archiveFrom: Ira Weiny <[email protected]>
The definition of port state changed mid development and the old structure was kept accidentally. Remove this dead code.
--- drivers/infiniband/hw/hfi1/mad.c | 12 ------------ drivers/infiniband/hw/hfi1/mad.h | 7 ------- include/rdma/opa_port_info.h | 16 ---------------- 3 files changed, 0 insertions(+), 35 deletions(-)
drivers/infiniband/hw/hfi1/mad.c +0 -12
@@ -588,7 +588,6 @@ static int __subn_get_opa_portinfo(struct opa_smp *smp, u32 am, u8 *data, pi->port_phys_conf = (ppd->port_type &0xf ); -#if PI_LED_ENABLE_SUP pi->port_states.ledenable_offlinereason = ppd->neighbor_normal <<4 ; pi->port_states.ledenable_offlinereason |= ppd->is_sm_config_started <<5 ;
@@ -602,11 +601,6 @@ static int __subn_get_opa_portinfo(struct opa_smp *smp, u32 am, u8 *data, pi->port_states.ledenable_offlinereason |= is_beaconing_active <<6 ; pi->port_states.ledenable_offlinereason |= ppd->offline_disabled_reason; -#else - pi->port_states.offline_reason = ppd->neighbor_normal <<4 ; - pi->port_states.offline_reason |= ppd->is_sm_config_started <<5 ; - pi->port_states.offline_reason |= ppd->offline_disabled_reason; -#endif /* PI_LED_ENABLE_SUP */ pi->port_states.portphysstate_portstate = (hfi1_ibphys_portstate (ppd) <<4 ) | state;
@@ -1752,17 +1746,11 @@ static int __subn_get_opa_psi(struct opa_smp *smp, u32 am, u8 *data,if (start_of_sm_config && (lstate ==IB_PORT_INIT )) ppd->is_sm_config_started =1 ; -#if PI_LED_ENABLE_SUP psi->port_states.ledenable_offlinereason = ppd->neighbor_normal <<4 ; psi->port_states.ledenable_offlinereason |= ppd->is_sm_config_started <<5 ; psi->port_states.ledenable_offlinereason |= ppd->offline_disabled_reason; -#else - psi->port_states.offline_reason = ppd->neighbor_normal <<4 ; - psi->port_states.offline_reason |= ppd->is_sm_config_started <<5 ; - psi->port_states.offline_reason |= ppd->offline_disabled_reason; -#endif /* PI_LED_ENABLE_SUP */ psi->port_states.portphysstate_portstate = (hfi1_ibphys_portstate (ppd) <<4 ) | (lstate &0xf );
drivers/infiniband/hw/hfi1/mad.h +0 -7
@@ -48,15 +48,8 @@#define _HFI1_MAD_H#include <rdma/ib_pma.h> -#define USE_PI_LED_ENABLE 1/* -* use led enabled bit in struct -* opa_port_states, if available -*/ #include <rdma/opa_smi.h> #include <rdma/opa_port_info.h> -#ifndef PI_LED_ENABLE_SUP -#define PI_LED_ENABLE_SUP 0 -#endif #include "opa_compat.h" /*
include/rdma/opa_port_info.h +0 -16
@@ -33,11 +33,6 @@#if !defined(OPA_PORT_INFO_H )#define OPA_PORT_INFO_H -/* Temporary until HFI driver is updated */ -#ifndef USE_PI_LED_ENABLE -#define USE_PI_LED_ENABLE 0 -#endif -#define OPA_PORT_LINK_MODE_NOP 0/* No change */ #define OPA_PORT_LINK_MODE_OPA 4/* Port mode is OPA */
@@ -274,23 +269,12 @@ enum port_info_field_masks { OPA_PI_MASK_MTU_CAP = 0x0F, }; -#if USE_PI_LED_ENABLE struct opa_port_states {u8 reserved;u8 ledenable_offlinereason;/* 1 res, 1 bit, 6 bits */ u8 reserved2;u8 portphysstate_portstate;/* 4 bits, 4 bits */ }; -#define PI_LED_ENABLE_SUP 1 -#else -struct opa_port_states { -u8 reserved; -u8 offline_reason;/* 2 res, 6 bits */ -u8 reserved2; -u8 portphysstate_portstate;/* 4 bits, 4 bits */ -}; -#define PI_LED_ENABLE_SUP 0 -#endif struct opa_port_state_info {struct opa_port_states port_states;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/18 IB/hfi1: Remove unnecessary done label in hfi1_write_iter
In reply to a message not in the archiveFrom: Ira Weiny <[email protected]>
Simple code clean up of hfi1_write_iter.
--- drivers/infiniband/hw/hfi1/file_ops.c | 31 ++++++++++++++----------------- 1 files changed, 14 insertions(+), 17 deletions(-)
drivers/infiniband/hw/hfi1/file_ops.c +14 -17
@@ -392,41 +392,38 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from)struct hfi1_filedata *fd = kiocb->ki_filp->private_data;struct hfi1_user_sdma_pkt_q *pq = fd->pq;struct hfi1_user_sdma_comp_q *cq = fd->cq; -int ret =0 , done =0 , reqs =0 ; +int done =0 , reqs =0 ;unsigned long dim = from->nr_segs; -if (!cq || !pq) { - ret = -EIO ; - goto done; - } +if (!cq || !pq) +return -EIO ; -if (!iter_is_iovec (from) || !dim) { - ret = -EINVAL ; - goto done; - } +if (!iter_is_iovec (from) || !dim) +return -EINVAL ;hfi1_cdbg (SDMA ,"SDMA request from %u:%u (%lu)" , fd->uctxt->ctxt, fd->subctxt, dim); -if (atomic_read (&pq->n_reqs) == pq->n_max_reqs) { - ret = -ENOSPC ; - goto done; - } +if (atomic_read (&pq->n_reqs) == pq->n_max_reqs) +return -ENOSPC ;while (dim) { +int ret;unsigned long count =0 ; ret =hfi1_user_sdma_process_request ( kiocb->ki_filp, (struct iovec *)(from->iov + done), dim, &count); -if (ret) - goto done; +if (ret) { + reqs = ret; +break ; + } dim -= count; done += count; reqs++; } -done: -return ret ? ret : reqs; + +return reqs; }static int hfi1_file_mmap (struct file *fp,struct vm_area_struct *vma)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/18 IB/hfi1: Fix typo
In reply to a message not in the archiveFrom: Tadeusz Struk <[email protected]>
Fix a copy and paste typo in comment.
--- drivers/infiniband/hw/hfi1/qsfp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/qsfp.c +1 -1
@@ -243,7 +243,7 @@ int qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,/* * Perform a stand-alone single QSFP write. Acquire the resource, do the -* read, then release the resource. +* write, then release the resource. */ int one_qsfp_write (struct hfi1_pportdata *ppd,u32 target,int addr,void *bp,int len)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/18 IB/hfi1: Separate tracepoints into specific headers
In reply to a message not in the archiveFrom: Sebastian Sanchez <[email protected]>
The ftrace infrastructure used to evaluate the TRACE_SYSTEM macro on every DEFINE_EVENT() macro. Now the TRACE_SYSTEM macro only gets evaluated when trace/define_trace.h is included, so the group event information is lost. This was introduced in
commit acd388fd3af3 ("tracing: Give system name a pointer") Therefore, each system tracepoint must be on its own file.
--- drivers/infiniband/hw/hfi1/hfi.h | 51 + drivers/infiniband/hw/hfi1/rc.c | 8 drivers/infiniband/hw/hfi1/trace.h | 1333 ----------------------------- drivers/infiniband/hw/hfi1/trace_ctxts.h | 141 +++ drivers/infiniband/hw/hfi1/trace_dbg.h | 155 +++ drivers/infiniband/hw/hfi1/trace_ibhdrs.h | 209 +++++ drivers/infiniband/hw/hfi1/trace_misc.h | 81 ++ drivers/infiniband/hw/hfi1/trace_rc.h | 123 +++ drivers/infiniband/hw/hfi1/trace_rx.h | 322 +++++++ drivers/infiniband/hw/hfi1/trace_tx.h | 642 ++++++++++++++ 10 files changed, 1735 insertions(+), 1330 deletions(-) create mode 100644 drivers/infiniband/hw/hfi1/trace_ctxts.h create mode 100644 drivers/infiniband/hw/hfi1/trace_dbg.h create mode 100644 drivers/infiniband/hw/hfi1/trace_ibhdrs.h create mode 100644 drivers/infiniband/hw/hfi1/trace_misc.h create mode 100644 drivers/infiniband/hw/hfi1/trace_rc.h create mode 100644 drivers/infiniband/hw/hfi1/trace_rx.h create mode 100644 drivers/infiniband/hw/hfi1/trace_tx.h
drivers/infiniband/hw/hfi1/hfi.h +51 -0
@@ -1947,4 +1947,55 @@ static inline u32 qsfp_resource(struct hfi1_devdata *dd)int hfi1_tempsense_rd (struct hfi1_devdata *dd,struct hfi1_temp *temp); +#define DD_DEV_ENTRY (dd) __string(dev, dev_name(&(dd)->pcidev->dev)) +#define DD_DEV_ASSIGN (dd) __assign_str(dev, dev_name(&(dd)->pcidev->dev)) + +#define packettype_name (etype) { RHF_RCV_TYPE_##etype, #etype } +#define show_packettype (etype) \ +__print_symbolic(etype, \ + packettype_name(EXPECTED), \ + packettype_name(EAGER), \ + packettype_name(IB), \ + packettype_name(ERROR), \ + packettype_name(BYPASS)) + +#define ib_opcode_name (opcode) { IB_OPCODE_##opcode, #opcode } +#define show_ib_opcode (opcode) \ +__print_symbolic(opcode, \ + ib_opcode_name(RC_SEND_FIRST), \ + ib_opcode_name(RC_SEND_MIDDLE), \ + ib_opcode_name(RC_SEND_LAST), \ + ib_opcode_name(RC_SEND_LAST_WITH_IMMEDIATE), \ + ib_opcode_name(RC_SEND_ONLY), \ + ib_opcode_name(RC_SEND_ONLY_WITH_IMMEDIATE), \ + ib_opcode_name(RC_RDMA_WRITE_FIRST), \ + ib_opcode_name(RC_RDMA_WRITE_MIDDLE), \ + ib_opcode_name(RC_RDMA_WRITE_LAST), \ + ib_opcode_name(RC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \ + ib_opcode_name(RC_RDMA_WRITE_ONLY), \ + ib_opcode_name(RC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \ + ib_opcode_name(RC_RDMA_READ_REQUEST), \ + ib_opcode_name(RC_RDMA_READ_RESPONSE_FIRST), \ + ib_opcode_name(RC_RDMA_READ_RESPONSE_MIDDLE), \ + ib_opcode_name(RC_RDMA_READ_RESPONSE_LAST), \ + ib_opcode_name(RC_RDMA_READ_RESPONSE_ONLY), \ + ib_opcode_name(RC_ACKNOWLEDGE), \ + ib_opcode_name(RC_ATOMIC_ACKNOWLEDGE), \ + ib_opcode_name(RC_COMPARE_SWAP), \ + ib_opcode_name(RC_FETCH_ADD), \ + ib_opcode_name(UC_SEND_FIRST), \ + ib_opcode_name(UC_SEND_MIDDLE), \ + ib_opcode_name(UC_SEND_LAST), \ + ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE), \ + ib_opcode_name(UC_SEND_ONLY), \ + ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE), \ + ib_opcode_name(UC_RDMA_WRITE_FIRST), \ + ib_opcode_name(UC_RDMA_WRITE_MIDDLE), \ + ib_opcode_name(UC_RDMA_WRITE_LAST), \ + ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \ + ib_opcode_name(UC_RDMA_WRITE_ONLY), \ + ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \ + ib_opcode_name(UD_SEND_ONLY), \ + ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE), \ + ib_opcode_name(CNP))#endif /* _HFI1_KERNEL_H */
drivers/infiniband/hw/hfi1/rc.c +4 -4
@@ -1047,7 +1047,7 @@ void hfi1_rc_timeout(unsigned long arg) ibp->rvp.n_rc_timeouts++; qp->s_flags &= ~RVT_S_TIMER ;del_timer (&qp->s_timer); -trace_hfi1_rc_timeout (qp, qp->s_last_psn +1 ); +trace_hfi1_timeout (qp, qp->s_last_psn +1 );restart_rc (qp, qp->s_last_psn +1 ,1 );hfi1_schedule_send (qp); }
@@ -1171,7 +1171,7 @@ void hfi1_rc_send_complete(struct rvt_qp *qp, struct hfi1_ib_header *hdr)* If we were waiting for sends to complete before re-sending, * and they are now complete, restart sending. */ -trace_hfi1_rc_sendcomplete (qp, psn); +trace_hfi1_sendcomplete (qp, psn);if (qp->s_flags &RVT_S_WAIT_PSN &&cmp_psn (qp->s_sending_psn, qp->s_sending_hpsn) >0 ) { qp->s_flags &= ~RVT_S_WAIT_PSN ;
@@ -1567,7 +1567,7 @@ static void rc_rcv_resp(struct hfi1_ibport *ibp,spin_lock_irqsave (&qp->s_lock, flags); -trace_hfi1_rc_ack (qp, psn); +trace_hfi1_ack (qp, psn);/* Ignore invalid responses. */ smp_read_barrier_depends ();/* see post_one_send */
@@ -1782,7 +1782,7 @@ static noinline int rc_rcv_error(struct hfi1_other_headers *ohdr, void *data,u8 i, prev;int old_req; -trace_hfi1_rc_rcv_error (qp, psn); +trace_hfi1_rcv_error (qp, psn);if (diff >0 ) {/* * Packet sequence error.
drivers/infiniband/hw/hfi1/trace.h +7 -1326
1,336 lines not on this page · raw message
drivers/infiniband/hw/hfi1/trace_ctxts.h new file +141 -0
141 lines not on this page · raw message
drivers/infiniband/hw/hfi1/trace_dbg.h new file +155 -0
155 lines not on this page · raw message
drivers/infiniband/hw/hfi1/trace_ibhdrs.h new file +209 -0
209 lines not on this page · raw message
drivers/infiniband/hw/hfi1/trace_misc.h new file +81 -0
81 lines not on this page · raw message
drivers/infiniband/hw/hfi1/trace_rc.h new file +123 -0
123 lines not on this page · raw message
drivers/infiniband/hw/hfi1/trace_rx.h new file +322 -0
322 lines not on this page · raw message
drivers/infiniband/hw/hfi1/trace_tx.h new file +642 -0
546 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Part of the diff is not shown here. View the raw message.
PATCH 5/18 IB/hfi1: Fix trace sparse errors
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
Fix sparse errors by making sure the fast assign destinations are host cpu typed.
For the void __iomem *, just make the field match source data.
Fix a bug where the hw_free trace printed the pointer vs. the dereferenced value.
--- drivers/infiniband/hw/hfi1/trace_ctxts.h | 8 ++-- drivers/infiniband/hw/hfi1/trace_tx.h | 54 +++++++++++++++--------------- 2 files changed, 31 insertions(+), 31 deletions(-)
drivers/infiniband/hw/hfi1/trace_ctxts.h +4 -4
@@ -56,7 +56,7 @@#define TRACE_SYSTEM hfi1_ctxts#define UCTXT_FMT \ - "cred:%u, credaddr:0x%llx, piobase:0x%llx, rcvhdr_cnt:%u, " \ + "cred:%u, credaddr:0x%llx, piobase:0x%p, rcvhdr_cnt:%u, " \ "rcvbase:0x%llx, rcvegrc:%u, rcvegrb:0x%llx" TRACE_EVENT(hfi1_uctxtdata, TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ctxtdata *uctxt),
@@ -65,7 +65,7 @@ TRACE_EVENT(hfi1_uctxtdata, __field(unsigned int, ctxt) __field(u32, credits) __field(u64, hw_free) - __field(u64, piobase) + __field(void __iomem *, piobase) __field(u16, rcvhdrq_cnt) __field(u64, rcvhdrq_phys) __field(u32, eager_cnt)
@@ -74,8 +74,8 @@ TRACE_EVENT(hfi1_uctxtdata, TP_fast_assign(DD_DEV_ASSIGN(dd); __entry->ctxt = uctxt->ctxt; __entry->credits = uctxt->sc->credits; - __entry->hw_free = (u64 )uctxt->sc->hw_free; - __entry->piobase = (u64 )uctxt->sc->base_addr; + __entry->hw_free =le64_to_cpu (*uctxt->sc->hw_free); + __entry->piobase = uctxt->sc->base_addr; __entry->rcvhdrq_cnt = uctxt->rcvhdrq_cnt; __entry->rcvhdrq_phys = uctxt->rcvhdrq_phys; __entry->eager_cnt = uctxt->egrbufs.alloced;
drivers/infiniband/hw/hfi1/trace_tx.h +27 -27
71 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/18 IB/hfi1: Add VL XmitDiscards counters to the opapmaquery
In reply to a message not in the archiveFrom: Jakub Pawlak <[email protected]>
Add per VL XmitDiscards counters to the opapmaquery status and error response.
--- drivers/infiniband/hw/hfi1/mad.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/mad.c +9 -2
@@ -2487,6 +2487,9 @@ static int pma_get_opa_portstatus(struct opa_pma_mad *pmp,cpu_to_be64 (read_dev_cntr (dd,C_DC_RCV_BCN_VL ,idx_from_vl (vl))); + rsp->vls[vfi].port_vl_xmit_discards = +cpu_to_be64 (read_port_cntr (ppd,C_SW_XMIT_DSCD_VL , +idx_from_vl (vl))); vlinfo++; vfi++; }
@@ -2878,7 +2881,9 @@ static int pma_get_opa_porterrors(struct opa_pma_mad *pmp,for_each_set_bit (vl, (unsigned long *)&(vl_select_mask),8 *sizeof (req->vl_select_mask)) {memset (vlinfo,0 ,sizeof (*vlinfo)); -/* vlinfo->vls[vfi].port_vl_xmit_discards ??? */ + rsp->vls[vfi].port_vl_xmit_discards = +cpu_to_be64 (read_port_cntr (ppd,C_SW_XMIT_DSCD_VL , +idx_from_vl (vl))); vlinfo +=1 ; vfi++; }
@@ -3211,7 +3216,9 @@ static int pma_set_opa_portstatus(struct opa_pma_mad *pmp,/* if (counter_select & CS_PORT_MARK_FECN) * write_csr(dd, DCC_PRF_PORT_VL_MARK_FECN_CNT + offset, 0); */ -/* port_vl_xmit_discards ??? */ +if (counter_select &C_SW_XMIT_DSCD_VL ) +write_port_cntr (ppd,C_SW_XMIT_DSCD_VL , +idx_from_vl (vl),0 ); }if (resp_len)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/18 IB/hfi1: Add counter to track unsupported packets drop
In reply to a message not in the archiveFrom: Jakub Pawlak <[email protected]>
Add sw counter to track dropped unsupported packets. Report unsupported packets drop as the RcvError.
--- drivers/infiniband/hw/hfi1/chip.c | 31 +++++++++++++++++++++++++++---- drivers/infiniband/hw/hfi1/driver.c | 1 + drivers/infiniband/hw/hfi1/hfi.h | 3 ++- drivers/infiniband/hw/hfi1/mad.c | 3 ++- 4 files changed, 32 insertions(+), 6 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +27 -4
@@ -238,6 +238,9 @@ struct flag_table {/* all CceStatus sub-block RXE pause bits */ #define ALL_RXE_PAUSE CCE_STATUS_RXE_PAUSED_SMASK +#define CNTR_MAX 0xFFFFFFFFFFFFFFFFULL +#define CNTR_32BIT_MAX 0x00000000FFFFFFFF +/* * CCE Error flags. */
@@ -3947,6 +3950,28 @@ static u64 access_sdma_wrong_dw_err_cnt(const struct cntr_entry *entry,return dd->sw_send_dma_eng_err_status_cnt[0 ]; } +static u64 access_dc_rcv_err_cnt (const struct cntr_entry *entry, +void *context,int vl,int mode, +u64 data) +{ +struct hfi1_devdata *dd = (struct hfi1_devdata *)context; + +u64 val =0 ; +u64 csr = entry->csr; + + val =read_write_csr (dd, csr, mode, data); +if (mode ==CNTR_MODE_R ) { + val = val >CNTR_MAX - dd->sw_rcv_bypass_packet_errors ? +CNTR_MAX : val + dd->sw_rcv_bypass_packet_errors; + }else if (mode ==CNTR_MODE_W ) { + dd->sw_rcv_bypass_packet_errors =0 ; + }else { +dd_dev_err (dd,"Invalid cntr register access mode" ); +return 0 ; + } +return val; +} +#define def_access_sw_cpu (cntr) \ static u64 access_sw_cpu_##cntr(const struct cntr_entry *entry, \ void *context, int vl, int mode, u64 data) \
@@ -4020,7 +4045,8 @@ static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = { CCE_SEND_CREDIT_INT_CNT, CNTR_NORMAL), [C_DC_UNC_ERR ] =DC_PERF_CNTR (DcUnctblErr,DCC_ERR_UNCORRECTABLE_CNT , CNTR_SYNTH), -[C_DC_RCV_ERR] = DC_PERF_CNTR(DcRecvErr, DCC_ERR_PORTRCV_ERR_CNT, CNTR_SYNTH), +[C_DC_RCV_ERR ] =CNTR_ELEM ("DcRecvErr" ,DCC_ERR_PORTRCV_ERR_CNT ,0 ,CNTR_SYNTH , + access_dc_rcv_err_cnt), [C_DC_FM_CFG_ERR ] =DC_PERF_CNTR (DcFmCfgErr,DCC_ERR_FMCONFIG_ERR_CNT , CNTR_SYNTH), [C_DC_RMT_PHY_ERR] = DC_PERF_CNTR(DcRmtPhyErr, DCC_ERR_RCVREMOTE_PHY_ERR_CNT,
@@ -11668,9 +11694,6 @@ static void free_cntrs(struct hfi1_devdata *dd) dd->cntrnames =NULL ; } -#define CNTR_MAX 0xFFFFFFFFFFFFFFFFULL -#define CNTR_32BIT_MAX 0x00000000FFFFFFFF -static u64 read_dev_port_cntr (struct hfi1_devdata *dd,struct cntr_entry *entry,u64 *psval,void *context,int vl) {
drivers/infiniband/hw/hfi1/driver.c +1 -0
@@ -1362,6 +1362,7 @@ int process_receive_bypass(struct hfi1_packet *packet)dd_dev_err (packet->rcd->dd,"Bypass packets are not supported in normal operation. Dropping\n" ); +incr_cntr64 (&packet->rcd->dd->sw_rcv_bypass_packet_errors);return RHF_RCV_CONTINUE ; }
drivers/infiniband/hw/hfi1/hfi.h +2 -1
@@ -1128,7 +1128,8 @@ struct hfi1_devdata { NUM_SEND_DMA_ENG_ERR_STATUS_COUNTERS];/* Software counter that aggregates all cce_err_status errors */ u64 sw_cce_err_status_aggregate; - +/* Software counter that aggregates all bypass packet rcv errors */ +u64 sw_rcv_bypass_packet_errors;/* receive interrupt functions */ rhf_rcv_function_ptr *rhf_rcv_function_map;rhf_rcv_function_ptr normal_rhf_rcv_functions[8 ];
drivers/infiniband/hw/hfi1/mad.c +2 -1
@@ -2874,7 +2874,8 @@ static int pma_get_opa_porterrors(struct opa_pma_mad *pmp, tmp =read_dev_cntr (dd,C_DC_UNC_ERR ,CNTR_INVALID_VL ); rsp->uncorrectable_errors = tmp <0x100 ? (tmp &0xff ) :0xff ; - + rsp->port_rcv_errors = +cpu_to_be64 (read_dev_cntr (dd,C_DC_RCV_ERR ,CNTR_INVALID_VL )); vlinfo = &rsp->vls[0 ]; vfi =0 ; vl_select_mask =be32_to_cpu (req->vl_select_mask);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/18 IB/hfi1: Add global structure for affinity assignments
In reply to a message not in the archiveFrom: Sebastian Sanchez <[email protected]>
When HFI units get initialized, they each use their own mask copy for affinity assignments. On a multi-HFI system, affinity assignments overbook CPU cores as each HFI doesn't have knowledge of affinity assignments for other HFI units. Therefore, some CPU cores are never used for interrupt handlers in systems with high number of CPU cores per NUMA node.
For multi-HFI systems, SDMA engine interrupt assignments start all over from the first CPU in the local NUMA node after the first HFI initialization. This change allows assignments to continue where the last HFI unit left off.
Add global structure for affinity assignments for multiple HFIs to share affinity mask.
--- drivers/infiniband/hw/hfi1/affinity.c | 250 +++++++++++++++++++++++---------- drivers/infiniband/hw/hfi1/affinity.h | 25 +++ drivers/infiniband/hw/hfi1/chip.c | 20 +-- drivers/infiniband/hw/hfi1/init.c | 5 + 4 files changed, 201 insertions(+), 99 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +171 -79
@@ -53,6 +53,11 @@#include "sdma.h" #include "trace.h" +struct hfi1_affinity_node_list node_affinity = { + .list =LIST_HEAD_INIT (node_affinity.list), + .lock =__SPIN_LOCK_UNLOCKED (&node_affinity.lock), +}; +/* Name of IRQ types, indexed by enum irq_type */ static const char *const irq_type_names[] = {"SDMA" ,
@@ -69,45 +74,100 @@ static inline void init_cpu_mask_set(struct cpu_mask_set *set) }/* Initialize non-HT cpu cores mask */ -int init_real_cpu_mask (struct hfi1_devdata *dd) +void init_real_cpu_mask (void ) { -struct hfi1_affinity *info;int possible, curr_cpu, i, ht; - info =kzalloc (sizeof (*info),GFP_KERNEL ); -if (!info) -return -ENOMEM ; - -cpumask_clear (&info->real_cpu_mask); +cpumask_clear (&node_affinity.real_cpu_mask);/* Start with cpu online mask as the real cpu mask */ -cpumask_copy (&info->real_cpu_mask, cpu_online_mask); +cpumask_copy (&node_affinity.real_cpu_mask, cpu_online_mask);/* * Remove HT cores from the real cpu mask. Do this in two steps below. */ - possible =cpumask_weight (&info->real_cpu_mask); + possible =cpumask_weight (&node_affinity.real_cpu_mask); ht =cpumask_weight (topology_sibling_cpumask ( -cpumask_first (&info->real_cpu_mask))); +cpumask_first (&node_affinity.real_cpu_mask)));/* * Step 1. Skip over the first N HT siblings and use them as the * "real" cores. Assumes that HT cores are not enumerated in * succession (except in the single core case). */ - curr_cpu =cpumask_first (&info->real_cpu_mask); + curr_cpu =cpumask_first (&node_affinity.real_cpu_mask);for (i =0 ; i < possible / ht; i++) - curr_cpu =cpumask_next (curr_cpu, &info->real_cpu_mask); + curr_cpu =cpumask_next (curr_cpu, &node_affinity.real_cpu_mask);/* * Step 2. Remove the remaining HT siblings. Use cpumask_next() to * skip any gaps. */ for (; i < possible; i++) { -cpumask_clear_cpu (curr_cpu, &info->real_cpu_mask); - curr_cpu =cpumask_next (curr_cpu, &info->real_cpu_mask); +cpumask_clear_cpu (curr_cpu, &node_affinity.real_cpu_mask); + curr_cpu =cpumask_next (curr_cpu, &node_affinity.real_cpu_mask); } +} - dd->affinity = info; -return 0 ; +void node_affinity_init (void ) +{ +cpumask_copy (&node_affinity.proc.mask, cpu_online_mask); +/* +* The real cpu mask is part of the affinity struct but it has to be +* initialized early. It is needed to calculate the number of user +* contexts in set_up_context_variables(). +*/ +init_real_cpu_mask (); +} + +void node_affinity_destroy (void ) +{ +struct list_head *pos, *q; +struct hfi1_affinity_node *entry; + +spin_lock (&node_affinity.lock); +list_for_each_safe (pos, q, &node_affinity.list) { + entry = list_entry(pos, struct hfi1_affinity_node, + list); +list_del (pos); +kfree (entry); + } +spin_unlock (&node_affinity.lock); +} + +static struct hfi1_affinity_node *node_affinity_allocate (int node) +{ +struct hfi1_affinity_node *entry; + + entry =kzalloc (sizeof (*entry),GFP_KERNEL ); +if (!entry) +return NULL ; + entry->node = node; +INIT_LIST_HEAD (&entry->list); + +return entry; +} + +/* +* It appends an entry to the list. +* It *must* be called with node_affinity.lock held. +*/ +static void node_affinity_add_tail (struct hfi1_affinity_node *entry) +{ +list_add_tail (&entry->list, &node_affinity.list); +} + +/* It must be called with node_affinity.lock held */ +static struct hfi1_affinity_node *node_affinity_lookup (int node) +{ +struct list_head *pos; +struct hfi1_affinity_node *entry; + +list_for_each (pos, &node_affinity.list) { + entry = list_entry(pos, struct hfi1_affinity_node, list); +if (entry->node == node) +return entry; + } + +return NULL ; }/*
@@ -121,10 +181,10 @@ int init_real_cpu_mask(struct hfi1_devdata *dd)* to the node relative 1 as necessary. * */ -void hfi1_dev_affinity_init (struct hfi1_devdata *dd) +int hfi1_dev_affinity_init (struct hfi1_devdata *dd) {int node =pcibus_to_node (dd->pcidev->bus); -struct hfi1_affinity *info = dd->affinity; +struct hfi1_affinity_node *entry;const struct cpumask *local_mask;int curr_cpu, possible, i;
@@ -132,55 +192,75 @@ void hfi1_dev_affinity_init(struct hfi1_devdata *dd) node =numa_node_id (); dd->node = node; -spin_lock_init (&info->lock); - -init_cpu_mask_set (&info->def_intr); -init_cpu_mask_set (&info->rcv_intr); -init_cpu_mask_set (&info->proc); - local_mask =cpumask_of_node (dd->node);if (cpumask_first (local_mask) >= nr_cpu_ids) local_mask =topology_core_cpumask (0 ); -/* Use the "real" cpu mask of this node as the default */ -cpumask_and (&info->def_intr.mask, &info->real_cpu_mask, local_mask); - -/* fill in the receive list */ - possible =cpumask_weight (&info->def_intr.mask); - curr_cpu =cpumask_first (&info->def_intr.mask); -if (possible ==1 ) { -/* only one CPU, everyone will use it */ -cpumask_set_cpu (curr_cpu, &info->rcv_intr.mask); - }else { -/* -* Retain the first CPU in the default list for the control -* context. -*/ - curr_cpu =cpumask_next (curr_cpu, &info->def_intr.mask); -/* -* Remove the remaining kernel receive queues from -* the default list and add them to the receive list. -*/ -for (i =0 ; i < dd->n_krcv_queues -1 ; i++) { -cpumask_clear_cpu (curr_cpu, &info->def_intr.mask); -cpumask_set_cpu (curr_cpu, &info->rcv_intr.mask); - curr_cpu =cpumask_next (curr_cpu, &info->def_intr.mask); -if (curr_cpu >= nr_cpu_ids) -break ; + +spin_lock (&node_affinity.lock); + entry =node_affinity_lookup (dd->node); +spin_unlock (&node_affinity.lock); + +/* +* If this is the first time this NUMA node's affinity is used, +* create an entry in the global affinity structure and initialize it. +*/ +if (!entry) { + entry =node_affinity_allocate (node); +if (!entry) { +dd_dev_err (dd, +"Unable to allocate global affinity node\n" ); +return -ENOMEM ; } - } +init_cpu_mask_set (&entry->def_intr); +init_cpu_mask_set (&entry->rcv_intr); +/* Use the "real" cpu mask of this node as the default */ +cpumask_and (&entry->def_intr.mask, &node_affinity.real_cpu_mask, + local_mask); + +/* fill in the receive list */ + possible =cpumask_weight (&entry->def_intr.mask); + curr_cpu =cpumask_first (&entry->def_intr.mask); + +if (possible ==1 ) { +/* only one CPU, everyone will use it */ +cpumask_set_cpu (curr_cpu, &entry->rcv_intr.mask); + }else { +/* +* Retain the first CPU in the default list for the +* control context. +*/ + curr_cpu =cpumask_next (curr_cpu, + &entry->def_intr.mask); -cpumask_copy (&info->proc.mask, cpu_online_mask); -} +/* +* Remove the remaining kernel receive queues from +* the default list and add them to the receive list. +*/ +for (i =0 ; i < dd->n_krcv_queues -1 ; i++) { +cpumask_clear_cpu (curr_cpu, + &entry->def_intr.mask); +cpumask_set_cpu (curr_cpu, + &entry->rcv_intr.mask); + curr_cpu =cpumask_next (curr_cpu, + &entry->def_intr.mask); +if (curr_cpu >= nr_cpu_ids) +break ; + } + } -void hfi1_dev_affinity_free (struct hfi1_devdata *dd) -{ -kfree (dd->affinity); +spin_lock (&node_affinity.lock); +node_affinity_add_tail (entry); +spin_unlock (&node_affinity.lock); + } + +return 0 ; }int hfi1_get_irq_affinity (struct hfi1_devdata *dd,struct hfi1_msix_entry *msix) {int ret;cpumask_var_t diff; +struct hfi1_affinity_node *entry;struct cpu_mask_set *set;struct sdma_engine *sde =NULL ;struct hfi1_ctxtdata *rcd =NULL ;
@@ -194,21 +274,25 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)if (!ret)return -ENOMEM ; +spin_lock (&node_affinity.lock); + entry =node_affinity_lookup (dd->node); +spin_unlock (&node_affinity.lock); +switch (msix->type) {case IRQ_SDMA : sde = (struct sdma_engine *)msix->arg;scnprintf (extra,64 ,"engine %u" , sde->this_idx);/* fall through */ case IRQ_GENERAL : - set = &dd->affinity->def_intr; + set = &entry->def_intr;break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg;if (rcd->ctxt ==HFI1_CTRL_CTXT ) { - set = &dd->affinity->def_intr; + set = &entry->def_intr; cpu =cpumask_first (&set->mask); }else { - set = &dd->affinity->rcv_intr; + set = &entry->rcv_intr; }scnprintf (extra,64 ,"ctxt %u" , rcd->ctxt);break ;
@@ -222,8 +306,8 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)* is set above. Skip accounting for it. Everything else finds its * CPU here. */ -if (cpu ==-1 ) { -spin_lock (&dd->affinity->lock); +if (cpu ==-1 && set) { +spin_lock (&node_affinity.lock);if (cpumask_equal (&set->mask, &set->used)) {/* * We've used up all the CPUs, bump up the generation
@@ -235,7 +319,7 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)cpumask_andnot (diff, &set->mask, &set->used); cpu =cpumask_first (diff);cpumask_set_cpu (cpu, &set->used); -spin_unlock (&dd->affinity->lock); +spin_unlock (&node_affinity.lock); }switch (msix->type) {
@@ -263,30 +347,35 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd, {struct cpu_mask_set *set =NULL ;struct hfi1_ctxtdata *rcd; +struct hfi1_affinity_node *entry; + +spin_lock (&node_affinity.lock); + entry =node_affinity_lookup (dd->node); +spin_unlock (&node_affinity.lock);switch (msix->type) {case IRQ_SDMA :case IRQ_GENERAL : - set = &dd->affinity->def_intr; + set = &entry->def_intr;break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg;/* only do accounting for non control contexts */ if (rcd->ctxt !=HFI1_CTRL_CTXT ) - set = &dd->affinity->rcv_intr; + set = &entry->rcv_intr;break ;default :return ; }if (set) { -spin_lock (&dd->affinity->lock); +spin_lock (&node_affinity.lock);cpumask_andnot (&set->used, &set->used, &msix->mask);if (cpumask_empty (&set->used) && set->gen) { set->gen--;cpumask_copy (&set->used, &set->mask); } -spin_unlock (&dd->affinity->lock); +spin_unlock (&node_affinity.lock); }irq_set_affinity_hint (msix->msix.vector,NULL );
@@ -297,9 +386,11 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node) {int cpu =-1 , ret;cpumask_var_t diff, mask, intrs; +struct hfi1_affinity_node *entry;const struct cpumask *node_mask, *proc_mask =tsk_cpus_allowed (current); -struct cpu_mask_set *set = &dd->affinity->proc; +struct cpu_mask_set *set = &node_affinity.proc; +char buf[1024 ];/* * check whether process/context affinity has already
@@ -338,7 +429,7 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)if (!ret) goto free_mask; -spin_lock (&dd->affinity->lock); +spin_lock (&node_affinity.lock);/* * If we've used all available CPUs, clear the mask and start * overloading.
@@ -348,15 +439,16 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)cpumask_clear (&set->used); } + entry =node_affinity_lookup (dd->node);/* CPUs used by interrupt handlers */ -cpumask_copy (intrs, (dd->affinity->def_intr.gen ? - &dd->affinity->def_intr.mask : - &dd->affinity->def_intr.used)); -cpumask_or (intrs, intrs, (dd->affinity->rcv_intr.gen ? - &dd->affinity->rcv_intr.mask : - &dd->affinity->rcv_intr.used)); -hfi1_cdbg (PROC ,"CPUs used by interrupts: %*pbl" , -cpumask_pr_args (intrs)); +cpumask_copy (intrs, (entry->def_intr.gen ? + &entry->def_intr.mask : + &entry->def_intr.used)); +cpumask_or (intrs, intrs, (entry->rcv_intr.gen ? + &entry->rcv_intr.mask : + &entry->rcv_intr.used)); +scnprintf (buf,sizeof (buf),"%*pbl" ,cpumask_pr_args (intrs)); +hfi1_cdbg (PROC ,"CPUs used by interrupts: %s" , buf);/* * If we don't have a NUMA node requested, preference is towards
@@ -400,7 +492,7 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node) cpu =-1 ; else cpumask_set_cpu(cpu, &set->used); -spin_unlock (&dd->affinity->lock); +spin_unlock (&node_affinity.lock);free_cpumask_var (intrs); free_mask:
@@ -413,16 +505,16 @@ done:void hfi1_put_proc_affinity (struct hfi1_devdata *dd,int cpu) { -struct cpu_mask_set *set = &dd->affinity->proc; +struct cpu_mask_set *set = &node_affinity.proc;if (cpu <0 )return ; -spin_lock (&dd->affinity->lock); +spin_lock (&node_affinity.lock);cpumask_clear_cpu (cpu, &set->used);if (cpumask_empty (&set->used) && set->gen) { set->gen--;cpumask_copy (&set->used, &set->mask); } -spin_unlock (&dd->affinity->lock); +spin_unlock (&node_affinity.lock); }
drivers/infiniband/hw/hfi1/affinity.h +21 -4
@@ -82,11 +82,9 @@ struct hfi1_affinity {struct hfi1_msix_entry ;/* Initialize non-HT cpu cores mask */ -int init_real_cpu_mask (struct hfi1_devdata *); +void init_real_cpu_mask (void );/* Initialize driver affinity data */ -void hfi1_dev_affinity_init (struct hfi1_devdata *); -/* Free driver affinity data */ -void hfi1_dev_affinity_free (struct hfi1_devdata *); +int hfi1_dev_affinity_init (struct hfi1_devdata *);/* * Set IRQ affinity to a CPU. The function will determine the * CPU and set the affinity to it.
@@ -105,4 +103,23 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *, int);/* Release a CPU used by a user process. */ void hfi1_put_proc_affinity (struct hfi1_devdata *,int ); +struct hfi1_affinity_node { +int node; +struct cpu_mask_set def_intr; +struct cpu_mask_set rcv_intr; +struct list_head list; +}; + +struct hfi1_affinity_node_list { +struct list_head list; +struct cpumask real_cpu_mask; +struct cpu_mask_set proc; +/* protect affinity node list */ +spinlock_t lock; +}; + +void node_affinity_init (void ); +void node_affinity_destroy (void ); +extern struct hfi1_affinity_node_list node_affinity; +#endif /* _HFI1_AFFINITY_H */
drivers/infiniband/hw/hfi1/chip.c +5 -15
@@ -63,6 +63,7 @@#include "efivar.h" #include "platform.h" #include "aspm.h" +#include "affinity.h" #define NUM_IB_PORTS 1
@@ -12838,7 +12839,7 @@ static int set_up_context_variables(struct hfi1_devdata *dd)*/ if (num_user_contexts <0 ) num_user_contexts = -cpumask_weight (&dd->affinity->real_cpu_mask); +cpumask_weight (&node_affinity.real_cpu_mask); total_contexts = num_kernel_contexts + num_user_contexts;
@@ -14473,19 +14474,6 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev, (dd->revision >>CCE_REVISION_SW_SHIFT ) & CCE_REVISION_SW_MASK); -/* -* The real cpu mask is part of the affinity struct but has to be -* initialized earlier than the rest of the affinity struct because it -* is needed to calculate the number of user contexts in -* set_up_context_variables(). However, hfi1_dev_affinity_init(), -* which initializes the rest of the affinity struct members, -* depends on set_up_context_variables() for the number of kernel -* contexts, so it cannot be called before set_up_context_variables(). -*/ - ret =init_real_cpu_mask (dd); -if (ret) - goto bail_cleanup; - ret =set_up_context_variables (dd);if (ret) goto bail_cleanup;
@@ -14499,7 +14487,9 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev,/* set up KDETH QP prefix in both RX and TX CSRs */ init_kdeth_qp (dd); -hfi1_dev_affinity_init (dd); + ret =hfi1_dev_affinity_init (dd); +if (ret) + goto bail_cleanup;/* send contexts must be set up before receive contexts */ ret =init_send_contexts (dd);
drivers/infiniband/hw/hfi1/init.c +4 -1
@@ -64,6 +64,7 @@#include "debugfs.h" #include "verbs.h" #include "aspm.h" +#include "affinity.h" #undef pr_fmt#define pr_fmt (fmt) DRIVER_NAME ": " fmt
@@ -1004,7 +1005,6 @@ static void __hfi1_free_devdata(struct kobject *kobj)rcu_barrier ();/* wait for rcu callbacks to complete */ free_percpu (dd->int_counter);free_percpu (dd->rcv_limit); -hfi1_dev_affinity_free (dd);free_percpu (dd->send_schedule);rvt_dealloc_device (&dd->verbs_dev.rdi); }
@@ -1198,6 +1198,8 @@ static int __init hfi1_mod_init(void)if (ret) goto bail; +node_affinity_init (); +/* validate max MTU before any devices start */ if (!valid_opa_max_mtu (hfi1_max_mtu)) { pr_err("Invalid max_mtu 0x%x, using 0x%x instead\n",
@@ -1278,6 +1280,7 @@ module_init(hfi1_mod_init); static void __exit hfi1_mod_cleanup(void) {pci_unregister_driver (&hfi1_pci_driver); +node_affinity_destroy ();hfi1_wss_exit ();hfi1_dbg_exit (); hfi1_cpulist_count =0 ;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/18 IB/hfi1: Reserve and collapse CPU cores for contexts
In reply to a message not in the archiveFrom: Sebastian Sanchez <[email protected]>
Kernel receive queues oversubscribe CPU cores on multi-HFI systems. To prevent this, the kernel receive queues are separated onto different cores, and the SDMA engine interrupts are constrained to a lesser number of cores.
hfi1s_on_numa_node*krcvqs is the number of CPU cores that are reserved for kernel receive queues for all HFIs. Each HFI initializes its kernel receive queues to one of the reserved CPU cores. If there ends up being 0 CPU cores leftover for SDMA engines, use the same CPU cores as receive contexts.
In addition, general and control contexts are assigned to their own CPU core, however, both types of contexts tend to have low traffic. To save CPU cores, collapse general and control contexts to one CPU core for all HFI units. This change prevents SDMA engine interrupts from wrapping around general contexts.
--- drivers/infiniband/hw/hfi1/affinity.c | 101 +++++++++++++++++++++++++-------- drivers/infiniband/hw/hfi1/affinity.h | 3 + drivers/infiniband/hw/hfi1/hfi.h | 2 + drivers/infiniband/hw/hfi1/init.c | 6 +- 4 files changed, 84 insertions(+), 28 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +76 -25
@@ -66,6 +66,9 @@ static const char * const irq_type_names[] = { "OTHER", }; +/* Per NUMA node count of HFI devices */ +static unsigned int *hfi1_per_node_cntr; +static inline void init_cpu_mask_set (struct cpu_mask_set *set) {cpumask_clear (&set->mask);
@@ -107,8 +110,12 @@ void init_real_cpu_mask(void) } } -void node_affinity_init (void ) +int node_affinity_init (void ) { +int node; +struct pci_dev *dev =NULL ; +const struct pci_device_id *ids = hfi1_pci_tbl; +cpumask_copy (&node_affinity.proc.mask, cpu_online_mask);/* * The real cpu mask is part of the affinity struct but it has to be
@@ -116,6 +123,25 @@ void node_affinity_init(void)* contexts in set_up_context_variables(). */ init_real_cpu_mask (); + + hfi1_per_node_cntr =kcalloc (num_possible_nodes (), +sizeof (*hfi1_per_node_cntr),GFP_KERNEL ); +if (!hfi1_per_node_cntr) +return -ENOMEM ; + +while (ids->vendor) { + dev =NULL ; +while ((dev =pci_get_device (ids->vendor, ids->device, dev))) { + node =pcibus_to_node (dev->bus); +if (node <0 ) + node =numa_node_id (); + + hfi1_per_node_cntr[node]++; + } + ids++; + } + +return 0 ; }void node_affinity_destroy (void )
@@ -131,6 +157,7 @@ void node_affinity_destroy(void)kfree (entry); }spin_unlock (&node_affinity.lock); +kfree (hfi1_per_node_cntr); }static struct hfi1_affinity_node *node_affinity_allocate (int node)
@@ -213,6 +240,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd) }init_cpu_mask_set (&entry->def_intr);init_cpu_mask_set (&entry->rcv_intr); +cpumask_clear (&entry->general_intr_mask);/* Use the "real" cpu mask of this node as the default */ cpumask_and (&entry->def_intr.mask, &node_affinity.real_cpu_mask, local_mask);
@@ -224,11 +252,15 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)if (possible ==1 ) {/* only one CPU, everyone will use it */ cpumask_set_cpu (curr_cpu, &entry->rcv_intr.mask); +cpumask_set_cpu (curr_cpu, &entry->general_intr_mask); }else {/* -* Retain the first CPU in the default list for the -* control context. +* The general/control context will be the first CPU in +* the default list, so it is removed from the default +* list and added to the general interrupt list. */ +cpumask_clear_cpu (curr_cpu, &entry->def_intr.mask); +cpumask_set_cpu (curr_cpu, &entry->general_intr_mask); curr_cpu =cpumask_next (curr_cpu, &entry->def_intr.mask);
@@ -236,7 +268,10 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)* Remove the remaining kernel receive queues from * the default list and add them to the receive list. */ -for (i =0 ; i < dd->n_krcv_queues -1 ; i++) { +for (i =0 ; + i < (dd->n_krcv_queues -1 ) * + hfi1_per_node_cntr[dd->node]; + i++) {cpumask_clear_cpu (curr_cpu, &entry->def_intr.mask); cpumask_set_cpu(curr_cpu,
@@ -246,6 +281,15 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)if (curr_cpu >= nr_cpu_ids)break ; } + +/* +* If there ends up being 0 CPU cores leftover for SDMA +* engines, use the same CPU cores as general/control +* context. +*/ +if (cpumask_weight (&entry->def_intr.mask) ==0 ) +cpumask_copy (&entry->def_intr.mask, + &entry->general_intr_mask); }spin_lock (&node_affinity.lock);
@@ -261,7 +305,7 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)int ret;cpumask_var_t diff;struct hfi1_affinity_node *entry; -struct cpu_mask_set *set; +struct cpu_mask_set *set =NULL ;struct sdma_engine *sde =NULL ;struct hfi1_ctxtdata *rcd =NULL ;char extra[64 ];
@@ -282,18 +326,17 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)case IRQ_SDMA : sde = (struct sdma_engine *)msix->arg;scnprintf (extra,64 ,"engine %u" , sde->this_idx); -/* fall through */ -case IRQ_GENERAL : set = &entry->def_intr;break ; +case IRQ_GENERAL : + cpu =cpumask_first (&entry->general_intr_mask); +break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg; -if (rcd->ctxt ==HFI1_CTRL_CTXT ) { - set = &entry->def_intr; - cpu =cpumask_first (&set->mask); - }else { +if (rcd->ctxt ==HFI1_CTRL_CTXT ) + cpu =cpumask_first (&entry->general_intr_mask); +else set = &entry->rcv_intr; - }scnprintf (extra,64 ,"ctxt %u" , rcd->ctxt);break ;default :
@@ -302,9 +345,9 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix) }/* -* The control receive context is placed on a particular CPU, which -* is set above. Skip accounting for it. Everything else finds its -* CPU here. +* The general and control contexts are placed on a particular +* CPU, which is set above. Skip accounting for it. Everything else +* finds its CPU here. */ if (cpu ==-1 && set) {spin_lock (&node_affinity.lock);
@@ -355,12 +398,14 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd,switch (msix->type) {case IRQ_SDMA : -case IRQ_GENERAL : set = &entry->def_intr;break ; +case IRQ_GENERAL : +/* Don't accounting for general contexts */ +break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg; -/* only do accounting for non control contexts */ +/* Don't do accounting for control contexts */ if (rcd->ctxt !=HFI1_CTRL_CTXT ) set = &entry->rcv_intr;break ;
@@ -439,14 +484,20 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)cpumask_clear (&set->used); } - entry =node_affinity_lookup (dd->node); -/* CPUs used by interrupt handlers */ -cpumask_copy (intrs, (entry->def_intr.gen ? - &entry->def_intr.mask : - &entry->def_intr.used)); -cpumask_or (intrs, intrs, (entry->rcv_intr.gen ? - &entry->rcv_intr.mask : - &entry->rcv_intr.used)); +/* +* If NUMA node has CPUs used by interrupt handlers, include them in the +* interrupt handler mask. +*/ + entry =node_affinity_lookup (node); +if (entry) { +cpumask_copy (intrs, (entry->def_intr.gen ? + &entry->def_intr.mask : + &entry->def_intr.used)); +cpumask_or (intrs, intrs, (entry->rcv_intr.gen ? + &entry->rcv_intr.mask : + &entry->rcv_intr.used)); +cpumask_or (intrs, intrs, &entry->general_intr_mask); + }scnprintf (buf,sizeof (buf),"%*pbl" ,cpumask_pr_args (intrs));hfi1_cdbg (PROC ,"CPUs used by interrupts: %s" , buf);
drivers/infiniband/hw/hfi1/affinity.h +2 -1
@@ -107,6 +107,7 @@ struct hfi1_affinity_node {int node;struct cpu_mask_set def_intr;struct cpu_mask_set rcv_intr; +struct cpumask general_intr_mask;struct list_head list; };
@@ -118,7 +119,7 @@ struct hfi1_affinity_node_list {spinlock_t lock; }; -void node_affinity_init (void ); +int node_affinity_init (void );void node_affinity_destroy (void );extern struct hfi1_affinity_node_list node_affinity;
drivers/infiniband/hw/hfi1/hfi.h +2 -0
@@ -1235,6 +1235,8 @@ int handle_receive_interrupt_nodma_rtail(struct hfi1_ctxtdata *, int);int handle_receive_interrupt_dma_rtail (struct hfi1_ctxtdata *,int );void set_all_slowpath (struct hfi1_devdata *dd); +extern const struct pci_device_id hfi1_pci_tbl[]; +/* receive packet handler dispositions */ #define RCV_PKT_OK 0x0/* keep going */ #define RCV_PKT_LIMIT 0x1/* stop, hit limit, start thread */
drivers/infiniband/hw/hfi1/init.c +4 -2
@@ -1162,7 +1162,7 @@ static int init_one(struct pci_dev *, const struct pci_device_id *);#define DRIVER_LOAD_MSG "Intel " DRIVER_NAME " loaded: "#define PFX DRIVER_NAME ": " -static const struct pci_device_id hfi1_pci_tbl[] = { +const struct pci_device_id hfi1_pci_tbl[] = { {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL0 ) }, {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL1 ) }, {0 , }
@@ -1198,7 +1198,9 @@ static int __init hfi1_mod_init(void)if (ret) goto bail; -node_affinity_init (); + ret =node_affinity_init (); +if (ret) + goto bail;/* validate max MTU before any devices start */ if (!valid_opa_max_mtu (hfi1_max_mtu)) {
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 10/18 IB/hfi1: Refine user process affinity algorithm
In reply to a message not in the archiveFrom: Sebastian Sanchez <[email protected]>
When performing process affinity recommendations for MPI ranks, the current algorithm doesn't take into account multiple HFI units. Also, real cores and HT cores are not distinguished from one another. Therefore, all HT cores are recommended to be assigned first within the local NUMA node before recommending the assignments of cores in other NUMA nodes. It's ideal to assign all real cores across all NUMA nodes first, then all HT 1 cores, then all HT 2 cores, and so on to balance CPU workload. CPU cores in other NUMA nodes could be running interrupt handlers, and this is not taken into account.
To balance the CPU workload for user processes, the following recommendation algorithm is used:
For each user process that is opening a context on HFI Y:
a) If all cores are assigned to user processes, start assignments all over from the first core
b) Assign real cores first, then HT cores (First set of HT cores on all physical cores, then second set of HT cores, and, so on) in the following order:
1. Same NUMA node as HFI Y and not running an IRQ handler
2. Same NUMA node as HFI Y and running an IRQ handler
3. Different NUMA node to HFI Y and not running an IRQ handler
4. Different NUMA node to HFI Y and running an IRQ handler
c) Mark core as assigned in the global affinity structure. As user processes are done, remove core assignments from global affinity structure.
This implementation allows an arbitrary number of HT cores and provides support for multiple HFIs.
This is being included in the kernel rather than user space due to the fact that user space has no way of knowing the CPU recommendations for contexts running as part of other jobs.
--- drivers/infiniband/hw/hfi1/affinity.c | 235 +++++++++++++++++++++++++-------- drivers/infiniband/hw/hfi1/affinity.h | 8 + drivers/infiniband/hw/hfi1/file_ops.c | 15 +- 3 files changed, 191 insertions(+), 67 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +176 -59
@@ -116,7 +116,17 @@ int node_affinity_init(void)struct pci_dev *dev =NULL ;const struct pci_device_id *ids = hfi1_pci_tbl; +cpumask_clear (&node_affinity.proc.used);cpumask_copy (&node_affinity.proc.mask, cpu_online_mask); + + node_affinity.proc.gen =0 ; + node_affinity.num_core_siblings = +cpumask_weight (topology_sibling_cpumask ( +cpumask_first (&node_affinity.proc.mask) + )); + node_affinity.num_online_nodes =num_online_nodes (); + node_affinity.num_online_cpus =num_online_cpus (); +/* * The real cpu mask is part of the affinity struct but it has to be * initialized early. It is needed to calculate the number of user
@@ -401,7 +411,7 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd, set = &entry->def_intr;break ;case IRQ_GENERAL : -/* Don't accounting for general contexts */ +/* Don't do accounting for general contexts */ break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg;
@@ -427,14 +437,47 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd,cpumask_clear (&msix->mask); } -int hfi1_get_proc_affinity (struct hfi1_devdata *dd,int node) +/* This should be called with node_affinity.lock held */ +static void find_hw_thread_mask (uint hw_thread_no,cpumask_var_t hw_thread_mask, +struct hfi1_affinity_node_list *affinity) +{ +int possible, curr_cpu, i; +uint num_cores_per_socket = node_affinity.num_online_cpus / + affinity->num_core_siblings / + node_affinity.num_online_nodes; + +cpumask_copy (hw_thread_mask, &affinity->proc.mask); +if (affinity->num_core_siblings >0 ) { +/* Removing other siblings not needed for now */ + possible =cpumask_weight (hw_thread_mask); + curr_cpu =cpumask_first (hw_thread_mask); +for (i =0 ; + i < num_cores_per_socket * node_affinity.num_online_nodes; + i++) + curr_cpu =cpumask_next (curr_cpu, hw_thread_mask); + +for (; i < possible; i++) { +cpumask_clear_cpu (curr_cpu, hw_thread_mask); + curr_cpu =cpumask_next (curr_cpu, hw_thread_mask); + } + +/* Identifying correct HW threads within physical cores */ +cpumask_shift_left (hw_thread_mask, hw_thread_mask, + num_cores_per_socket * + node_affinity.num_online_nodes * + hw_thread_no); + } +} + +int hfi1_get_proc_affinity (int node) { -int cpu =-1 , ret; -cpumask_var_t diff, mask, intrs; +int cpu =-1 , ret, i;struct hfi1_affinity_node *entry; +cpumask_var_t diff, hw_thread_mask, available_mask, intrs_mask;const struct cpumask *node_mask, *proc_mask =tsk_cpus_allowed (current); -struct cpu_mask_set *set = &node_affinity.proc; +struct hfi1_affinity_node_list *affinity = &node_affinity; +struct cpu_mask_set *set = &affinity->proc;char buf[1024 ];/*
@@ -442,9 +485,10 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)* been set */ if (cpumask_weight (proc_mask) ==1 ) { -hfi1_cdbg (PROC ,"PID %u %s affinity set to CPU %*pbl" , - current->pid, current->comm, +scnprintf (buf,sizeof (buf),"%*pbl" ,cpumask_pr_args (proc_mask)); +hfi1_cdbg (PROC ,"PID %u %s affinity set to CPU %s" , + current->pid, current->comm, buf);/* * Mark the pre-set CPU as used. This is atomic so we don't * need the lock
@@ -453,30 +497,50 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)cpumask_set_cpu (cpu, &set->used); goto done; }else if (cpumask_weight (proc_mask) <cpumask_weight (&set->mask)) { -hfi1_cdbg (PROC ,"PID %u %s affinity set to CPU set(s) %*pbl" , - current->pid, current->comm, +scnprintf (buf,sizeof (buf),"%*pbl" ,cpumask_pr_args (proc_mask)); +hfi1_cdbg (PROC ,"PID %u %s affinity set to CPU set(s) %s" , + current->pid, current->comm, buf); goto done; }/* * The process does not have a preset CPU affinity so find one to -* recommend. We prefer CPUs on the same NUMA as the device. +* recommend using the following algorithm: +* +* For each user process that is opening a context on HFI Y: +* a) If all cores are filled, reinitialize the bitmask +* b) Fill real cores first, then HT cores (First set of HT +* cores on all physical cores, then second set of HT core, +* and, so on) in the following order: +* +* 1. Same NUMA node as HFI Y and not running an IRQ +* handler +* 2. Same NUMA node as HFI Y and running an IRQ handler +* 3. Different NUMA node to HFI Y and not running an IRQ +* handler +* 4. Different NUMA node to HFI Y and running an IRQ +* handler +* c) Mark core as filled in the bitmask. As user processes are +* done, clear cores from the bitmask. */ ret =zalloc_cpumask_var (&diff,GFP_KERNEL );if (!ret) goto done; - ret =zalloc_cpumask_var (&mask,GFP_KERNEL ); + ret =zalloc_cpumask_var (&hw_thread_mask,GFP_KERNEL );if (!ret) goto free_diff; - ret =zalloc_cpumask_var (&intrs,GFP_KERNEL ); + ret =zalloc_cpumask_var (&available_mask,GFP_KERNEL ); +if (!ret) + goto free_hw_thread_mask; + ret =zalloc_cpumask_var (&intrs_mask,GFP_KERNEL );if (!ret) - goto free_mask; + goto free_available_mask; -spin_lock (&node_affinity.lock); +spin_lock (&affinity->lock);/* -* If we've used all available CPUs, clear the mask and start +* If we've used all available HW threads, clear the mask and start * overloading. */ if (cpumask_equal (&set->mask, &set->used)) {
@@ -490,82 +554,135 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)*/ entry =node_affinity_lookup (node);if (entry) { -cpumask_copy (intrs, (entry->def_intr.gen ? - &entry->def_intr.mask : - &entry->def_intr.used)); -cpumask_or (intrs, intrs, (entry->rcv_intr.gen ? - &entry->rcv_intr.mask : - &entry->rcv_intr.used)); -cpumask_or (intrs, intrs, &entry->general_intr_mask); +cpumask_copy (intrs_mask, (entry->def_intr.gen ? + &entry->def_intr.mask : + &entry->def_intr.used)); +cpumask_or (intrs_mask, intrs_mask, (entry->rcv_intr.gen ? + &entry->rcv_intr.mask : + &entry->rcv_intr.used)); +cpumask_or (intrs_mask, intrs_mask, &entry->general_intr_mask); } -scnprintf (buf,sizeof (buf),"%*pbl" ,cpumask_pr_args (intrs)); +scnprintf (buf,sizeof (buf),"%*pbl" ,cpumask_pr_args (intrs_mask));hfi1_cdbg (PROC ,"CPUs used by interrupts: %s" , buf); +cpumask_copy (hw_thread_mask, &set->mask); +/* -* If we don't have a NUMA node requested, preference is towards -* device NUMA node +* If HT cores are enabled, identify which HW threads within the +* physical cores should be used. */ -if (node ==-1 ) - node = dd->node; - node_mask =cpumask_of_node (node); -hfi1_cdbg (PROC ,"device on NUMA %u, CPUs %*pbl" , node, -cpumask_pr_args (node_mask)); +if (affinity->num_core_siblings >0 ) { +for (i =0 ; i < affinity->num_core_siblings; i++) { +find_hw_thread_mask (i, hw_thread_mask, affinity); + +/* +* If there's at least one available core for this HW +* thread number, stop looking for a core. +* +* diff will always be not empty at least once in this +* loop as the used mask gets reset when +* (set->mask == set->used) before this loop. +*/ +cpumask_andnot (diff, hw_thread_mask, &set->used); +if (!cpumask_empty (diff)) +break ; + } + } +if (!scnprintf (buf,sizeof (buf),"%*pbl" , +cpumask_pr_args (hw_thread_mask))) +snprintf (buf,sizeof (buf),"None" ); +hfi1_cdbg (PROC ,"Same available HW thread on all physical CPUs: %s" , + buf); -/* diff will hold all unused cpus */ -cpumask_andnot (diff, &set->mask, &set->used); -hfi1_cdbg (PROC ,"unused CPUs (all) %*pbl" ,cpumask_pr_args (diff)); + node_mask =cpumask_of_node (node); +scnprintf (buf,1024 ,"%*pbl" ,cpumask_pr_args (node_mask)); +hfi1_cdbg (PROC ,"Device on NUMA %u, CPUs %s" , node, buf); -/* get cpumask of available CPUs on preferred NUMA */ -cpumask_and (mask, diff, node_mask); -hfi1_cdbg (PROC ,"available cpus on NUMA %*pbl" ,cpumask_pr_args (mask)); +/* Get cpumask of available CPUs on preferred NUMA */ +cpumask_and (available_mask, hw_thread_mask, node_mask); +cpumask_andnot (available_mask, available_mask, &set->used); +if (!scnprintf (buf,sizeof (buf),"%*pbl" , +cpumask_pr_args (available_mask))) +snprintf (buf,sizeof (buf),"None" ); +hfi1_cdbg (PROC ,"Available CPUs on NUMA %u: %s" , node, buf);/* * At first, we don't want to place processes on the same -* CPUs as interrupt handlers. +* CPUs as interrupt handlers. Then, CPUs running interrupt +* handlers are used. +* +* 1) If diff is not empty, then there are CPUs not running +* non-interrupt handlers available, so diff gets copied +* over to available_mask. +* 2) If diff is empty, then all CPUs not running interrupt +* handlers are taken, so available_mask contains all +* available CPUs running interrupt handlers. +* 3) If available_mask is empty, then all CPUs on the +* preferred NUMA node are taken, so other NUMA nodes are +* used for process assignments using the same method as +* the preferred NUMA node. */ -cpumask_andnot (diff, mask, intrs); +cpumask_andnot (diff, available_mask, intrs_mask);if (!cpumask_empty (diff)) -cpumask_copy (mask, diff); +cpumask_copy (available_mask, diff); + +/* If we don't have CPUs on the preferred node, use other NUMA nodes */ +if (cpumask_empty (available_mask)) { +cpumask_andnot (available_mask, hw_thread_mask, &set->used); +/* Excluding preferred NUMA cores */ +cpumask_andnot (available_mask, available_mask, node_mask); +if (!scnprintf (buf,sizeof (buf),"%*pbl" , +cpumask_pr_args (available_mask))) +snprintf (buf,sizeof (buf),"None" ); +hfi1_cdbg (PROC , +"Preferred NUMA node cores are taken, cores available in other NUMA nodes: %s" , + buf); -/* -* if we don't have a cpu on the preferred NUMA, get -* the list of the remaining available CPUs -*/ -if (cpumask_empty (mask)) { -cpumask_andnot (diff, &set->mask, &set->used); -cpumask_andnot (mask, diff, node_mask); +/* +* At first, we don't want to place processes on the same +* CPUs as interrupt handlers. +*/ +cpumask_andnot (diff, available_mask, intrs_mask); +if (!cpumask_empty (diff)) +cpumask_copy (available_mask, diff); } -hfi1_cdbg (PROC ,"possible CPUs for process %*pbl" , -cpumask_pr_args (mask)); +if (!scnprintf (buf,sizeof (buf),"%*pbl" , +cpumask_pr_args (available_mask))) +snprintf (buf,sizeof (buf),"None" ); +hfi1_cdbg (PROC ,"Possible CPUs for process: %s" , buf); - cpu =cpumask_first (mask); + cpu =cpumask_first (available_mask);if (cpu >= nr_cpu_ids)/* empty */ cpu =-1 ;else cpumask_set_cpu (cpu, &set->used); -spin_unlock (&node_affinity.lock); - -free_cpumask_var (intrs); -free_mask: -free_cpumask_var (mask); +spin_unlock (&affinity->lock); +hfi1_cdbg (PROC ,"Process assigned to CPU %d" , cpu); + +free_cpumask_var (intrs_mask); +free_available_mask: +free_cpumask_var (available_mask); +free_hw_thread_mask: +free_cpumask_var (hw_thread_mask); free_diff:free_cpumask_var (diff); done:return cpu; } -void hfi1_put_proc_affinity (struct hfi1_devdata *dd,int cpu) +void hfi1_put_proc_affinity (int cpu) { -struct cpu_mask_set *set = &node_affinity.proc; +struct hfi1_affinity_node_list *affinity = &node_affinity; +struct cpu_mask_set *set = &affinity->proc;if (cpu <0 )return ; -spin_lock (&node_affinity.lock); +spin_lock (&affinity->lock);cpumask_clear_cpu (cpu, &set->used); +hfi1_cdbg (PROC ,"Returning CPU %d for future process assignment" , cpu);if (cpumask_empty (&set->used) && set->gen) { set->gen--;cpumask_copy (&set->used, &set->mask); } -spin_unlock (&node_affinity.lock); +spin_unlock (&affinity->lock); } -
drivers/infiniband/hw/hfi1/affinity.h +5 -3
@@ -73,7 +73,6 @@ struct cpu_mask_set {struct hfi1_affinity {struct cpu_mask_set def_intr;struct cpu_mask_set rcv_intr; -struct cpu_mask_set proc;struct cpumask real_cpu_mask;/* spin lock to protect affinity struct */ spinlock_t lock;
@@ -99,9 +98,9 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *, struct hfi1_msix_entry *);* Determine a CPU affinity for a user process, if the process does not * have an affinity set yet. */ -int hfi1_get_proc_affinity (struct hfi1_devdata *,int ); +int hfi1_get_proc_affinity (int );/* Release a CPU used by a user process. */ -void hfi1_put_proc_affinity (struct hfi1_devdata *,int ); +void hfi1_put_proc_affinity (int );struct hfi1_affinity_node {int node;
@@ -115,6 +114,9 @@ struct hfi1_affinity_node_list {struct list_head list;struct cpumask real_cpu_mask;struct cpu_mask_set proc; +int num_core_siblings; +int num_online_nodes; +int num_online_cpus;/* protect affinity node list */ spinlock_t lock; };
drivers/infiniband/hw/hfi1/file_ops.c +10 -5
@@ -715,7 +715,7 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)hfi1_user_sdma_free_queues (fdata);/* release the cpu */ -hfi1_put_proc_affinity (dd, fdata->rec_cpu_num); +hfi1_put_proc_affinity (fdata->rec_cpu_num);/* * Clear any left over, unhandled events so the next process that
@@ -815,9 +815,10 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo) ret =find_shared_ctxt (fp, uinfo);if (ret <0 ) goto done_unlock; -if (ret) - fd->rec_cpu_num =hfi1_get_proc_affinity ( - fd->uctxt->dd, fd->uctxt->numa_id); +if (ret) { + fd->rec_cpu_num = +hfi1_get_proc_affinity (fd->uctxt->numa_id); + } }/*
@@ -929,7 +930,11 @@ static int allocate_ctxt(struct file *fp, struct hfi1_devdata *dd,if (ctxt == dd->num_rcv_contexts)return -EBUSY ; - fd->rec_cpu_num =hfi1_get_proc_affinity (dd,-1 ); +/* +* If we don't have a NUMA node requested, preference is towards +* device NUMA node. +*/ + fd->rec_cpu_num =hfi1_get_proc_affinity (dd->node);if (fd->rec_cpu_num !=-1 ) numa =cpu_to_node (fd->rec_cpu_num);else
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 11/18 IB/hfi1: Use built-in i2c bit-shift bus adapter
In reply to a message not in the archiveFrom: Dean Luick <[email protected]>
Use built-in i2c bit-shift bus adapter to control the i2c busses on the chip.
--- drivers/infiniband/hw/hfi1/Kconfig | 3 drivers/infiniband/hw/hfi1/hfi.h | 11 + drivers/infiniband/hw/hfi1/init.c | 27 ++ drivers/infiniband/hw/hfi1/qsfp.c | 407 +++++++++++++++++++++++++++--------- drivers/infiniband/hw/hfi1/qsfp.h | 3 5 files changed, 336 insertions(+), 115 deletions(-)
drivers/infiniband/hw/hfi1/Kconfig +2 -1
@@ -1,8 +1,9 @@ config INFINIBAND_HFI1 tristate "Intel OPA Gen1 support" - depends on X86_64 && INFINIBAND_RDMAVT + depends on X86_64 && INFINIBAND_RDMAVT && I2C select MMU_NOTIFIER select CRC32 + select I2C_ALGOBIT default m ---help--- This is a low-level driver for Intel OPA Gen1 adapter.
drivers/infiniband/hw/hfi1/hfi.h +11 -0
@@ -62,6 +62,8 @@#include <linux/cdev.h> #include <linux/delay.h> #include <linux/kthread.h> +#include <linux/i2c.h> +#include <linux/i2c-algo-bit.h> #include <rdma/rdma_vt.h> #include "chip_registers.h"
@@ -805,10 +807,19 @@ struct hfi1_temp {u8 triggers;/* temperature triggers */ }; +struct hfi1_i2c_bus { +struct hfi1_devdata *controlling_dd;/* current controlling device */ +struct i2c_adapter adapter;/* bus details */ +struct i2c_algo_bit_data algo;/* bus algorithm details */ +int num;/* bus number, 0 or 1 */ +}; +/* common data between shared ASIC HFIs */ struct hfi1_asic_data {struct hfi1_devdata *dds[2 ];/* back pointers */ struct mutex asic_resource_mutex; +struct hfi1_i2c_bus *i2c_bus0; +struct hfi1_i2c_bus *i2c_bus1; };/* device data struct now contains only "general per-device" info.
drivers/infiniband/hw/hfi1/init.c +19 -8
@@ -973,34 +973,45 @@ void hfi1_free_ctxtdata(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd)/* * Release our hold on the shared asic data. If we are the last one, -* free the structure. Must be holding hfi1_devs_lock. +* return the structure to be finalized outside the lock. Must be +* holding hfi1_devs_lock. */ -static void release_asic_data (struct hfi1_devdata *dd) +static struct hfi1_asic_data *release_asic_data (struct hfi1_devdata *dd) { +struct hfi1_asic_data *ad;int other;if (!dd->asic_data) -return ; +return NULL ; dd->asic_data->dds[dd->hfi1_id] =NULL ; other = dd->hfi1_id ?0 :1 ; -if (!dd->asic_data->dds[other]) { -/* we are the last holder, free it */ -kfree (dd->asic_data); - } + ad = dd->asic_data; dd->asic_data =NULL ; +/* return NULL if the other dd still has a link */ +return ad->dds[other] ?NULL : ad; +} + +static void finalize_asic_data (struct hfi1_devdata *dd, +struct hfi1_asic_data *ad) +{ +clean_up_i2c (dd, ad); +kfree (ad); }static void __hfi1_free_devdata (struct kobject *kobj) {struct hfi1_devdata *dd = container_of(kobj, struct hfi1_devdata, kobj); +struct hfi1_asic_data *ad;unsigned long flags;spin_lock_irqsave (&hfi1_devs_lock, flags);idr_remove (&hfi1_unit_table, dd->unit);list_del (&dd->list); -release_asic_data (dd); + ad =release_asic_data (dd);spin_unlock_irqrestore (&hfi1_devs_lock, flags); +if (ad) +finalize_asic_data (dd, ad);free_platform_config (dd);rcu_barrier ();/* wait for rcu callbacks to complete */ free_percpu (dd->int_counter);
drivers/infiniband/hw/hfi1/qsfp.c +301 -106
528 lines not on this page · raw message
drivers/infiniband/hw/hfi1/qsfp.h +3 -0
@@ -238,3 +238,6 @@ int one_qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp, int len);int one_qsfp_read (struct hfi1_pportdata *ppd,u32 target,int addr,void *bp,int len); +struct hfi1_asic_data ; +int set_up_i2c (struct hfi1_devdata *dd,struct hfi1_asic_data *ad); +void clean_up_i2c (struct hfi1_devdata *dd,struct hfi1_asic_data *ad);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 12/18 IB/hfi1: Remove TWSI references
In reply to a message not in the archiveFrom: Dean Luick <[email protected]>
Remove the TWSI code. The driver now uses the kernel's built-in i2c bit bus module.
--- drivers/infiniband/hw/hfi1/Makefile | 2 drivers/infiniband/hw/hfi1/chip.c | 31 -- drivers/infiniband/hw/hfi1/chip.h | 2 drivers/infiniband/hw/hfi1/twsi.c | 489 ----------------------------------- drivers/infiniband/hw/hfi1/twsi.h | 65 ----- 5 files changed, 1 insertions(+), 588 deletions(-) delete mode 100644 drivers/infiniband/hw/hfi1/twsi.c delete mode 100644 drivers/infiniband/hw/hfi1/twsi.h
drivers/infiniband/hw/hfi1/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-$(CONFIG_INFINIBAND_HFI1) += hfi1.o hfi1-y := affinity.o chip.o device.o driver.o efivar.o \ eprom.o file_ops.o firmware.o \ init.o intr.o mad.o mmu_rb.o pcie.o pio.o pio_copy.o platform.o \ - qp.o qsfp.o rc.o ruc.o sdma.o sysfs.o trace.o twsi.o \ + qp.o qsfp.o rc.o ruc.o sdma.o sysfs.o trace.o \ uc.o ud.o user_exp_rcv.o user_pages.o user_sdma.o verbs.o \ verbs_txreq.o hfi1-$(CONFIG_DEBUG_FS) += debugfs.o
drivers/infiniband/hw/hfi1/chip.c +0 -31
@@ -12349,37 +12349,6 @@ u8 hfi1_ibphys_portstate(struct hfi1_pportdata *ppd)return ib_pstate; } -/* -* Read/modify/write ASIC_QSFP register bits as selected by mask -* data: 0 or 1 in the positions depending on what needs to be written -* dir: 0 for read, 1 for write -* mask: select by setting -* I2CCLK (bit 0) -* I2CDATA (bit 1) -*/ -u64 hfi1_gpio_mod (struct hfi1_devdata *dd,u32 target,u32 data,u32 dir, -u32 mask) -{ -u64 qsfp_oe, target_oe; - - target_oe = target ?ASIC_QSFP2_OE :ASIC_QSFP1_OE ; -if (mask) { -/* We are writing register bits, so lock access */ - dir &= mask; - data &= mask; - - qsfp_oe =read_csr (dd, target_oe); - qsfp_oe = (qsfp_oe & ~(u64 )mask) | (u64 )dir; -write_csr (dd, target_oe, qsfp_oe); - } -/* We are exclusively reading bits here, but it is unlikely -* we'll get valid data when we set the direction of the pin -* in the same call, so read should call this function again -* to get valid data -*/ -return read_csr (dd, target ?ASIC_QSFP2_IN :ASIC_QSFP1_IN ); -} -#define CLEAR_STATIC_RATE_CONTROL_SMASK (r) \ (r &= ~SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK)
drivers/infiniband/hw/hfi1/chip.h +0 -2
@@ -1338,8 +1338,6 @@ struct hfi1_message_header *hfi1_get_msgheader( struct hfi1_devdata *dd, __le32 *rhf_addr);int hfi1_get_base_kinfo (struct hfi1_ctxtdata *rcd,struct hfi1_ctxt_info *kinfo); -u64 hfi1_gpio_mod (struct hfi1_devdata *dd,u32 target,u32 data,u32 dir, -u32 mask);int hfi1_init_ctxt (struct send_context *sc);void hfi1_put_tid (struct hfi1_devdata *dd,u32 index,u32 type,unsigned long pa,u16 order);
drivers/infiniband/hw/hfi1/twsi.c deleted +0 -489
489 lines not on this page · raw message
drivers/infiniband/hw/hfi1/twsi.h deleted +0 -65
65 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 13/18 IB/hfi1: Improve SDMA engine assignment for user SDMA
In reply to a message not in the archiveFrom: Jianxin Xiong <[email protected]>
Currently each user context is assigned a single SDMA engine based on the VL, context id, and subcontext id. That means for MPI applications, each rank can only use one SDMA engine for all messages. This may create unwanted backup for independent messages going to different destinations upon congestion at one destination.
This patch adds the packet "dlid" to the formula of SDMA engine selection for user SDMA requests. A simple hash table is used to maintain even distribution among the available SDMA engines regardless how the "dlid" values are distributed.
--- drivers/infiniband/hw/hfi1/user_sdma.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/user_sdma.c +28 -1
@@ -496,6 +496,27 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd)return 0 ; } +static u8 dlid_to_selector (u16 dlid) +{ +static u8 mapping[256 ]; +static int initialized; +static u8 next; +int hash; + +if (!initialized) { +memset (mapping,0xFF ,256 ); + initialized =1 ; + } + + hash = ((dlid >>8 ) ^ dlid) &0xFF ; +if (mapping[hash] ==0xFF ) { + mapping[hash] = next; + next = (next +1 ) &0x7F ; + } + +return mapping[hash]; +} +int hfi1_user_sdma_process_request (struct file *fp,struct iovec *iovec,unsigned long dim,unsigned long *count) {
@@ -511,6 +532,8 @@ int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec,struct user_sdma_request *req;u8 opcode, sc, vl;int req_queued =0 ; +u16 dlid; +u8 selector;if (iovec[idx].iov_len <sizeof (info) +sizeof (req->hdr)) { hfi1_cdbg(
@@ -686,9 +709,13 @@ int hfi1_user_sdma_process_request(struct file *fp, struct iovec *iovec, idx++; } + dlid =be16_to_cpu (req->hdr.lrh[1 ]); + selector =dlid_to_selector (dlid); +/* Have to select the engine */ req->sde =sdma_select_engine_vl (dd, - (u32)(uctxt->ctxt + fd->subctxt), + (u32)(uctxt->ctxt + fd->subctxt + + selector), vl);if (!req->sde || !sdma_running (req->sde)) { ret = -ECOMM ;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 14/18 IB/hfi1: Correct receive packet handler assignment
In reply to a message not in the archiveFrom: Jakub Pawlak <[email protected]>
Prevent processing receive packet in case when opcode is accepted by QP but handler for this type of packet is not defined.
--- drivers/infiniband/hw/hfi1/verbs.c | 29 ++++++++++++++++------------- 1 files changed, 16 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hfi1/verbs.c +16 -13
@@ -540,19 +540,15 @@ void hfi1_skip_sge(struct rvt_sge_state *ss, u32 length, int release)/* * Make sure the QP is ready and able to accept the given opcode. */ -static inline int qp_ok (int opcode,struct hfi1_packet *packet) +static inline opcode_handler qp_ok (int opcode,struct hfi1_packet *packet) { -struct hfi1_ibport *ibp; -if (!(ib_rvt_state_ops[packet->qp->state] &RVT_PROCESS_RECV_OK )) - goto dropit; +return NULL ;if (((opcode &RVT_OPCODE_QP_MASK ) == packet->qp->allowed_ops) || (opcode ==IB_OPCODE_CNP )) -return 1 ; -dropit: - ibp = &packet->rcd->ppd->ibport_data; - ibp->rvp.n_pkt_drops++; -return 0 ; +return opcode_handler_tbl[opcode]; + +return NULL ; }/**
@@ -571,6 +567,7 @@ void hfi1_ib_rcv(struct hfi1_packet *packet)struct hfi1_pportdata *ppd = rcd->ppd;struct hfi1_ibport *ibp = &ppd->ibport_data;struct rvt_dev_info *rdi = &ppd->dd->verbs_dev.rdi; +opcode_handler packet_handler;unsigned long flags;u32 qp_num;int lnh;
@@ -616,8 +613,11 @@ void hfi1_ib_rcv(struct hfi1_packet *packet)list_for_each_entry_rcu (p, &mcast->qp_list, list) { packet->qp = p->qp;spin_lock_irqsave (&packet->qp->r_lock, flags); -if (likely ((qp_ok (opcode, packet)))) - opcode_handler_tbl[opcode](packet); + packet_handler =qp_ok (opcode, packet); +if (likely (packet_handler)) +packet_handler (packet); +else + ibp->rvp.n_pkt_drops++;spin_unlock_irqrestore (&packet->qp->r_lock, flags); }/*
@@ -634,8 +634,11 @@ void hfi1_ib_rcv(struct hfi1_packet *packet) goto drop; }spin_lock_irqsave (&packet->qp->r_lock, flags); -if (likely ((qp_ok (opcode, packet)))) - opcode_handler_tbl[opcode](packet); + packet_handler =qp_ok (opcode, packet); +if (likely (packet_handler)) +packet_handler (packet); +else + ibp->rvp.n_pkt_drops++;spin_unlock_irqrestore (&packet->qp->r_lock, flags);rcu_read_unlock (); }
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 15/18 IB/rdmavt: Add data structures and routines for table driven post send
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
Add flexibility for driver dependent operations in post send because different drivers will have differing post send operation support.
This includes data structure definitions to support a table driven scheme along with the necessary validation routine using the new table.
--- drivers/infiniband/sw/rdmavt/qp.c | 67 ++++++++++++++++++++++++++++++++++--- include/rdma/rdma_vt.h | 3 ++ include/rdma/rdmavt_qp.h | 28 +++++++++++++-- 3 files changed, 89 insertions(+), 9 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +62 -5
@@ -613,6 +613,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,struct rvt_dev_info *rdi =ib_to_rvt (ibpd->device);void *priv =NULL ;gfp_t gfp; +size_t sqsize;if (!rdi)return ERR_PTR (-EINVAL );
@@ -643,7 +644,8 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, init_attr->cap.max_recv_wr == 0)return ERR_PTR (-EINVAL ); } - + sqsize = + init_attr->cap.max_send_wr +1 ;switch (init_attr->qp_type) {case IB_QPT_SMI :case IB_QPT_GSI :
@@ -658,11 +660,11 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,sizeof (struct rvt_swqe );if (gfp ==GFP_NOIO ) swq =__vmalloc ( - (init_attr->cap.max_send_wr +1 ) * sz, + sqsize * sz, gfp | __GFP_ZERO,PAGE_KERNEL );else swq =vzalloc_node ( - (init_attr->cap.max_send_wr +1 ) * sz, + sqsize * sz, rdi->dparms.node);if (!swq)return ERR_PTR (-ENOMEM );
@@ -747,7 +749,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,INIT_LIST_HEAD (&qp->rspwait); qp->state =IB_QPS_RESET ; qp->s_wq = swq; - qp->s_size = init_attr->cap.max_send_wr +1 ; + qp->s_size = sqsize; qp->s_avail = init_attr->cap.max_send_wr; qp->s_max_sge = init_attr->cap.max_send_sge;if (init_attr->sq_sig_type ==IB_SIGNAL_REQ_WR )
@@ -1440,12 +1442,65 @@ int rvt_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, }/** -* qp_get_savail - return number of avail send entries +* rvt_qp_valid_operation - validate post send wr request +* @qp - the qp +* @post-parms - the post send table for the driver +* @wr - the work request * +* The routine validates the operation based on the +* validation table an returns the length of the operation +* which can extend beyond the ib_send_bw. Operation +* dependent flags key atomic operation validation. +* +* There is an exception for UD qps that validates the pd and +* overrides the length to include the additional UD specific +* length. +* +* Returns a negative error or the length of the work request +* for building the swqe. +*/ +static inline int rvt_qp_valid_operation ( +struct rvt_qp *qp, +const struct rvt_operation_params *post_parms, +struct ib_send_wr *wr) +{ +int len; + +if (wr->opcode >=RVT_OPERATION_MAX || !post_parms[wr->opcode].length) +return -EINVAL ; +if (!(post_parms[wr->opcode].qpt_support &BIT (qp->ibqp.qp_type))) +return -EINVAL ; +if ((post_parms[wr->opcode].flags &RVT_OPERATION_PRIV ) && +ibpd_to_rvtpd (qp->ibqp.pd)->user) +return -EINVAL ; +if (post_parms[wr->opcode].flags &RVT_OPERATION_ATOMIC_SGE && + (wr->num_sge ==0 || + wr->sg_list[0 ].length <sizeof (u64) || + wr->sg_list[0 ].addr & (sizeof (u64) -1 ))) +return -EINVAL ; +if (post_parms[wr->opcode].flags &RVT_OPERATION_ATOMIC && + !qp->s_max_rd_atomic) +return -EINVAL ; + len = post_parms[wr->opcode].length; +/* UD specific */ +if (qp->ibqp.qp_type !=IB_QPT_UC && + qp->ibqp.qp_type !=IB_QPT_RC ) { +if (qp->ibqp.pd !=ud_wr (wr)->ah->pd) +return -EINVAL ; + len =sizeof (struct ib_ud_wr ); + } +return len; +} + +/** +* qp_get_savail - return number of avail send entries * @qp - the qp * * This assumes the s_hlock is held but the s_last * qp variable is uncontrolled. +* +* The return is adjusted to not count device specific +* reserved operations. */ static inline u32 qp_get_savail (struct rvt_qp *qp) {
@@ -1481,6 +1536,8 @@ static int rvt_post_one_wr(struct rvt_qp *qp,u8 log_pmtu;int ret; +BUILD_BUG_ON (IB_QPT_MAX >= (sizeof (u32) *BITS_PER_BYTE )); +/* IB spec says that num_sge == 0 is OK. */ if (unlikely (wr->num_sge > qp->s_max_sge))return -EINVAL ;
include/rdma/rdma_vt.h +3 -0
@@ -351,6 +351,9 @@ struct rvt_dev_info {/* Driver specific properties */ struct rvt_driver_params dparms; +/* post send table */ +const struct rvt_operation_params *post_parms; +struct rvt_mregion __rcu *dma_mr;struct rvt_lkey_table lkey_table;
include/rdma/rdmavt_qp.h +24 -4
@@ -228,11 +228,31 @@ struct rvt_ack_entry {#define RC_QP_SCALING_INTERVAL 5 -/* -* Variables prefixed with s_ are for the requester (sender). -* Variables prefixed with r_ are for the responder (receiver). -* Variables prefixed with ack_ are for responder replies. +#define RVT_OPERATION_PRIV 0x00000001 +#define RVT_OPERATION_ATOMIC 0x00000002 +#define RVT_OPERATION_ATOMIC_SGE 0x00000004 + +#define RVT_OPERATION_MAX (IB_WR_RESERVED10 + 1) + +/** +* rvt_operation_params - op table entry +* @length - the length to copy into the swqe entry +* @qpt_support - a bit mask indicating QP type support +* @flags - RVT_OPERATION flags (see above) +* +* This supports table driven post send so that +* the driver can have differing an potentially +* different sets of operations. * +**/ + +struct rvt_operation_params { +size_t length; +u32 qpt_support; +u32 flags; +}; + +/* * Common variables are protected by both r_rq.lock and s_lock in that order * which only happens in modify_qp() or changing the QP 'state'. */
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 16/18 IB/hfi1: Add hfi1 post send tables
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
Add initial table for table driven post_send support.
--- drivers/infiniband/hw/hfi1/qp.c | 44 ++++++++++++++++++++++++++++++++++++ drivers/infiniband/hw/hfi1/qp.h | 2 ++ drivers/infiniband/hw/hfi1/verbs.c | 3 ++ 3 files changed, 49 insertions(+), 0 deletions(-)
drivers/infiniband/hw/hfi1/qp.c +44 -0
@@ -52,6 +52,7 @@#include <linux/seq_file.h> #include <rdma/rdma_vt.h> #include <rdma/rdmavt_qp.h> +#include <rdma/ib_verbs.h> #include "hfi.h" #include "qp.h"
@@ -115,6 +116,49 @@ static const u16 credit_table[31] = { 32768 /* 1E */ }; +const struct rvt_operation_params hfi1_post_parms[RVT_OPERATION_MAX ] = { +[IB_WR_RDMA_WRITE ] = { + .length =sizeof (struct ib_rdma_wr ), + .qpt_support =BIT (IB_QPT_UC ) |BIT (IB_QPT_RC ), +}, + +[IB_WR_RDMA_READ ] = { + .length =sizeof (struct ib_rdma_wr ), + .qpt_support =BIT (IB_QPT_RC ), + .flags =RVT_OPERATION_ATOMIC , +}, + +[IB_WR_ATOMIC_CMP_AND_SWP ] = { + .length =sizeof (struct ib_atomic_wr ), + .qpt_support =BIT (IB_QPT_RC ), + .flags =RVT_OPERATION_ATOMIC |RVT_OPERATION_ATOMIC_SGE , +}, + +[IB_WR_ATOMIC_FETCH_AND_ADD ] = { + .length =sizeof (struct ib_atomic_wr ), + .qpt_support =BIT (IB_QPT_RC ), + .flags =RVT_OPERATION_ATOMIC |RVT_OPERATION_ATOMIC_SGE , +}, + +[IB_WR_RDMA_WRITE_WITH_IMM ] = { + .length =sizeof (struct ib_rdma_wr ), + .qpt_support =BIT (IB_QPT_UC ) |BIT (IB_QPT_RC ), +}, + +[IB_WR_SEND ] = { + .length =sizeof (struct ib_send_wr ), + .qpt_support =BIT (IB_QPT_UD ) |BIT (IB_QPT_SMI ) |BIT (IB_QPT_GSI ) | +BIT (IB_QPT_UC ) |BIT (IB_QPT_RC ), +}, + +[IB_WR_SEND_WITH_IMM ] = { + .length =sizeof (struct ib_send_wr ), + .qpt_support =BIT (IB_QPT_UD ) |BIT (IB_QPT_SMI ) |BIT (IB_QPT_GSI ) | +BIT (IB_QPT_UC ) |BIT (IB_QPT_RC ), +}, + +}; +static void flush_tx_list (struct rvt_qp *qp) {struct hfi1_qp_priv *priv = qp->priv;
drivers/infiniband/hw/hfi1/qp.h +2 -0
@@ -54,6 +54,8 @@extern unsigned int hfi1_qp_table_size; +extern const struct rvt_operation_params hfi1_post_parms[]; +/* * free_ahg - clear ahg from QP */
drivers/infiniband/hw/hfi1/verbs.c +3 -0
@@ -1683,6 +1683,9 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd) dd->verbs_dev.rdi.dparms.nports = dd->num_pports; dd->verbs_dev.rdi.dparms.npkeys =hfi1_get_npkeys (dd); +/* post send table */ + dd->verbs_dev.rdi.post_parms = hfi1_post_parms; + ppd = dd->pport;for (i =0 ; i < dd->num_pports; i++, ppd++) rvt_init_port(&dd->verbs_dev.rdi,
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 17/18 IB/qib: Add qib post send table
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
Add initial table for table driven post_send support.
--- drivers/infiniband/hw/qib/qib_qp.c | 43 +++++++++++++++++++++++++++++++++ drivers/infiniband/hw/qib/qib_verbs.c | 2 ++ drivers/infiniband/hw/qib/qib_verbs.h | 2 ++ 3 files changed, 47 insertions(+), 0 deletions(-)
drivers/infiniband/hw/qib/qib_qp.c +43 -0
@@ -106,6 +106,49 @@ static u32 credit_table[31] = { 32768 /* 1E */ }; +const struct rvt_operation_params qib_post_parms[RVT_OPERATION_MAX ] = { +[IB_WR_RDMA_WRITE ] = { + .length =sizeof (struct ib_rdma_wr ), + .qpt_support =BIT (IB_QPT_UC ) |BIT (IB_QPT_RC ), +}, + +[IB_WR_RDMA_READ ] = { + .length =sizeof (struct ib_rdma_wr ), + .qpt_support =BIT (IB_QPT_RC ), + .flags =RVT_OPERATION_ATOMIC , +}, + +[IB_WR_ATOMIC_CMP_AND_SWP ] = { + .length =sizeof (struct ib_atomic_wr ), + .qpt_support =BIT (IB_QPT_RC ), + .flags =RVT_OPERATION_ATOMIC |RVT_OPERATION_ATOMIC_SGE , +}, + +[IB_WR_ATOMIC_FETCH_AND_ADD ] = { + .length =sizeof (struct ib_atomic_wr ), + .qpt_support =BIT (IB_QPT_RC ), + .flags =RVT_OPERATION_ATOMIC |RVT_OPERATION_ATOMIC_SGE , +}, + +[IB_WR_RDMA_WRITE_WITH_IMM ] = { + .length =sizeof (struct ib_rdma_wr ), + .qpt_support =BIT (IB_QPT_UC ) |BIT (IB_QPT_RC ), +}, + +[IB_WR_SEND ] = { + .length =sizeof (struct ib_send_wr ), + .qpt_support =BIT (IB_QPT_UD ) |BIT (IB_QPT_SMI ) |BIT (IB_QPT_GSI ) | +BIT (IB_QPT_UC ) |BIT (IB_QPT_RC ), +}, + +[IB_WR_SEND_WITH_IMM ] = { + .length =sizeof (struct ib_send_wr ), + .qpt_support =BIT (IB_QPT_UD ) |BIT (IB_QPT_SMI ) |BIT (IB_QPT_GSI ) | +BIT (IB_QPT_UC ) |BIT (IB_QPT_RC ), +}, + +}; +static void get_map_page (struct rvt_qpn_table *qpt,struct rvt_qpn_map *map,gfp_t gfp) {
drivers/infiniband/hw/qib/qib_verbs.c +2 -0
@@ -1582,6 +1582,8 @@ static void qib_fill_device_attr(struct qib_devdata *dd) rdi->dparms.props.max_total_mcast_qp_attach = rdi->dparms.props.max_mcast_qp_attach * rdi->dparms.props.max_mcast_grp; +/* post send table */ + dd->verbs_dev.rdi.post_parms = qib_post_parms; }/**
drivers/infiniband/hw/qib/qib_verbs.h +2 -0
@@ -497,4 +497,6 @@ extern unsigned int ib_qib_max_srq_wrs;extern const u32 ib_qib_rnr_table[]; +extern const struct rvt_operation_params qib_post_parms[]; +#endif /* QIB_VERBS_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 18/18 IB/rdmavt: Use new driver specific post send table
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
Change rvt_post_one_wr to use the new table mechanism for post send.
Validate that each low level driver specifies the table.
--- drivers/infiniband/sw/rdmavt/qp.c | 46 ++++++------------------------------- drivers/infiniband/sw/rdmavt/vt.c | 3 ++ 2 files changed, 10 insertions(+), 39 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +8 -38
@@ -1535,6 +1535,7 @@ static int rvt_post_one_wr(struct rvt_qp *qp,struct rvt_dev_info *rdi =ib_to_rvt (qp->ibqp.device);u8 log_pmtu;int ret; +size_t cplen;BUILD_BUG_ON (IB_QPT_MAX >= (sizeof (u32) *BITS_PER_BYTE ));
@@ -1542,32 +1543,11 @@ static int rvt_post_one_wr(struct rvt_qp *qp,if (unlikely (wr->num_sge > qp->s_max_sge))return -EINVAL ; -/* -* Don't allow RDMA reads or atomic operations on UC or -* undefined operations. -* Make sure buffer is large enough to hold the result for atomics. -*/ -if (qp->ibqp.qp_type ==IB_QPT_UC ) { -if ((unsigned )wr->opcode >=IB_WR_RDMA_READ ) -return -EINVAL ; - }else if (qp->ibqp.qp_type !=IB_QPT_RC ) { -/* Check IB_QPT_SMI, IB_QPT_GSI, IB_QPT_UD opcode */ -if (wr->opcode !=IB_WR_SEND && - wr->opcode !=IB_WR_SEND_WITH_IMM ) -return -EINVAL ; -/* Check UD destination address PD */ -if (qp->ibqp.pd !=ud_wr (wr)->ah->pd) -return -EINVAL ; - }else if ((unsigned )wr->opcode >IB_WR_ATOMIC_FETCH_AND_ADD ) { -return -EINVAL ; - }else if (wr->opcode >=IB_WR_ATOMIC_CMP_AND_SWP && - (wr->num_sge ==0 || - wr->sg_list[0 ].length <sizeof (u64) || - wr->sg_list[0 ].addr & (sizeof (u64) -1 ))) { -return -EINVAL ; - }else if (wr->opcode >=IB_WR_RDMA_READ && !qp->s_max_rd_atomic) { -return -EINVAL ; - } + ret =rvt_qp_valid_operation (qp, rdi->post_parms, wr); +if (ret <0 ) +return ret; + cplen = ret; +/* check for avail */ if (unlikely (!qp->s_avail)) { qp->s_avail =qp_get_savail (qp);
@@ -1588,18 +1568,8 @@ static int rvt_post_one_wr(struct rvt_qp *qp, pd =ibpd_to_rvtpd (qp->ibqp.pd); wqe =rvt_get_swqe_ptr (qp, qp->s_head); -if (qp->ibqp.qp_type !=IB_QPT_UC && - qp->ibqp.qp_type !=IB_QPT_RC ) -memcpy (&wqe->ud_wr,ud_wr (wr),sizeof (wqe->ud_wr)); -else if (wr->opcode ==IB_WR_RDMA_WRITE_WITH_IMM || - wr->opcode ==IB_WR_RDMA_WRITE || - wr->opcode ==IB_WR_RDMA_READ ) -memcpy (&wqe->rdma_wr,rdma_wr (wr),sizeof (wqe->rdma_wr)); -else if (wr->opcode ==IB_WR_ATOMIC_CMP_AND_SWP || - wr->opcode ==IB_WR_ATOMIC_FETCH_AND_ADD ) -memcpy (&wqe->atomic_wr,atomic_wr (wr),sizeof (wqe->atomic_wr)); -else -memcpy (&wqe->wr, wr,sizeof (wqe->wr)); +/* cplen has length from above */ +memcpy (&wqe->wr, wr, cplen); wqe->length =0 ; j =0 ;
drivers/infiniband/sw/rdmavt/vt.c +2 -1
@@ -528,7 +528,8 @@ static noinline int check_support(struct rvt_dev_info *rdi, int verb) post_send), rvt_post_send))if (!rdi->driver_f.schedule_send || - !rdi->driver_f.do_send) + !rdi->driver_f.do_send || + !rdi->post_parms)return -EINVAL ;break ;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 IB/hfi1: Add global structure for affinity assignments
In reply to a message not in the archiveWhen HFI units get initialized, they each use their own mask copy for affinity assignments. On a multi-HFI system, affinity assignments overbook CPU cores as each HFI doesn't have knowledge of affinity assignments for other HFI units. Therefore, some CPU cores are never used for interrupt handlers in systems with high number of CPU cores per NUMA node.
For multi-HFI systems, SDMA engine interrupt assignments start all over from the first CPU in the local NUMA node after the first HFI initialization. This change allows assignments to continue where the last HFI unit left off.
Add global structure for affinity assignments for multiple HFIs to share affinity mask.
--
changes since v1:
-----------------
Remove char buf[] that was accidentally put back after being removed in another patch [1]. Also patch up one of the trace messages to not need scnprintf().
--- drivers/infiniband/hw/hfi1/affinity.c | 245 +++++++++++++++++++++++---------- drivers/infiniband/hw/hfi1/affinity.h | 25 +++ drivers/infiniband/hw/hfi1/chip.c | 20 +-- drivers/infiniband/hw/hfi1/init.c | 5 + 4 files changed, 198 insertions(+), 97 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +168 -77
@@ -53,6 +53,11 @@#include "sdma.h" #include "trace.h" +struct hfi1_affinity_node_list node_affinity = { + .list =LIST_HEAD_INIT (node_affinity.list), + .lock =__SPIN_LOCK_UNLOCKED (&node_affinity.lock), +}; +/* Name of IRQ types, indexed by enum irq_type */ static const char *const irq_type_names[] = {"SDMA" ,
@@ -69,45 +74,100 @@ static inline void init_cpu_mask_set(struct cpu_mask_set *set) }/* Initialize non-HT cpu cores mask */ -int init_real_cpu_mask (struct hfi1_devdata *dd) +void init_real_cpu_mask (void ) { -struct hfi1_affinity *info;int possible, curr_cpu, i, ht; - info =kzalloc (sizeof (*info),GFP_KERNEL ); -if (!info) -return -ENOMEM ; - -cpumask_clear (&info->real_cpu_mask); +cpumask_clear (&node_affinity.real_cpu_mask);/* Start with cpu online mask as the real cpu mask */ -cpumask_copy (&info->real_cpu_mask, cpu_online_mask); +cpumask_copy (&node_affinity.real_cpu_mask, cpu_online_mask);/* * Remove HT cores from the real cpu mask. Do this in two steps below. */ - possible =cpumask_weight (&info->real_cpu_mask); + possible =cpumask_weight (&node_affinity.real_cpu_mask); ht =cpumask_weight (topology_sibling_cpumask ( -cpumask_first (&info->real_cpu_mask))); +cpumask_first (&node_affinity.real_cpu_mask)));/* * Step 1. Skip over the first N HT siblings and use them as the * "real" cores. Assumes that HT cores are not enumerated in * succession (except in the single core case). */ - curr_cpu =cpumask_first (&info->real_cpu_mask); + curr_cpu =cpumask_first (&node_affinity.real_cpu_mask);for (i =0 ; i < possible / ht; i++) - curr_cpu =cpumask_next (curr_cpu, &info->real_cpu_mask); + curr_cpu =cpumask_next (curr_cpu, &node_affinity.real_cpu_mask);/* * Step 2. Remove the remaining HT siblings. Use cpumask_next() to * skip any gaps. */ for (; i < possible; i++) { -cpumask_clear_cpu (curr_cpu, &info->real_cpu_mask); - curr_cpu =cpumask_next (curr_cpu, &info->real_cpu_mask); +cpumask_clear_cpu (curr_cpu, &node_affinity.real_cpu_mask); + curr_cpu =cpumask_next (curr_cpu, &node_affinity.real_cpu_mask); } +} - dd->affinity = info; -return 0 ; +void node_affinity_init (void ) +{ +cpumask_copy (&node_affinity.proc.mask, cpu_online_mask); +/* +* The real cpu mask is part of the affinity struct but it has to be +* initialized early. It is needed to calculate the number of user +* contexts in set_up_context_variables(). +*/ +init_real_cpu_mask (); +} + +void node_affinity_destroy (void ) +{ +struct list_head *pos, *q; +struct hfi1_affinity_node *entry; + +spin_lock (&node_affinity.lock); +list_for_each_safe (pos, q, &node_affinity.list) { + entry = list_entry(pos, struct hfi1_affinity_node, + list); +list_del (pos); +kfree (entry); + } +spin_unlock (&node_affinity.lock); +} + +static struct hfi1_affinity_node *node_affinity_allocate (int node) +{ +struct hfi1_affinity_node *entry; + + entry =kzalloc (sizeof (*entry),GFP_KERNEL ); +if (!entry) +return NULL ; + entry->node = node; +INIT_LIST_HEAD (&entry->list); + +return entry; +} + +/* +* It appends an entry to the list. +* It *must* be called with node_affinity.lock held. +*/ +static void node_affinity_add_tail (struct hfi1_affinity_node *entry) +{ +list_add_tail (&entry->list, &node_affinity.list); +} + +/* It must be called with node_affinity.lock held */ +static struct hfi1_affinity_node *node_affinity_lookup (int node) +{ +struct list_head *pos; +struct hfi1_affinity_node *entry; + +list_for_each (pos, &node_affinity.list) { + entry = list_entry(pos, struct hfi1_affinity_node, list); +if (entry->node == node) +return entry; + } + +return NULL ; }/*
@@ -121,10 +181,10 @@ int init_real_cpu_mask(struct hfi1_devdata *dd)* to the node relative 1 as necessary. * */ -void hfi1_dev_affinity_init (struct hfi1_devdata *dd) +int hfi1_dev_affinity_init (struct hfi1_devdata *dd) {int node =pcibus_to_node (dd->pcidev->bus); -struct hfi1_affinity *info = dd->affinity; +struct hfi1_affinity_node *entry;const struct cpumask *local_mask;int curr_cpu, possible, i;
@@ -132,55 +192,75 @@ void hfi1_dev_affinity_init(struct hfi1_devdata *dd) node =numa_node_id (); dd->node = node; -spin_lock_init (&info->lock); - -init_cpu_mask_set (&info->def_intr); -init_cpu_mask_set (&info->rcv_intr); -init_cpu_mask_set (&info->proc); - local_mask =cpumask_of_node (dd->node);if (cpumask_first (local_mask) >= nr_cpu_ids) local_mask =topology_core_cpumask (0 ); -/* Use the "real" cpu mask of this node as the default */ -cpumask_and (&info->def_intr.mask, &info->real_cpu_mask, local_mask); - -/* fill in the receive list */ - possible =cpumask_weight (&info->def_intr.mask); - curr_cpu =cpumask_first (&info->def_intr.mask); -if (possible ==1 ) { -/* only one CPU, everyone will use it */ -cpumask_set_cpu (curr_cpu, &info->rcv_intr.mask); - }else { -/* -* Retain the first CPU in the default list for the control -* context. -*/ - curr_cpu =cpumask_next (curr_cpu, &info->def_intr.mask); -/* -* Remove the remaining kernel receive queues from -* the default list and add them to the receive list. -*/ -for (i =0 ; i < dd->n_krcv_queues -1 ; i++) { -cpumask_clear_cpu (curr_cpu, &info->def_intr.mask); -cpumask_set_cpu (curr_cpu, &info->rcv_intr.mask); - curr_cpu =cpumask_next (curr_cpu, &info->def_intr.mask); -if (curr_cpu >= nr_cpu_ids) -break ; + +spin_lock (&node_affinity.lock); + entry =node_affinity_lookup (dd->node); +spin_unlock (&node_affinity.lock); + +/* +* If this is the first time this NUMA node's affinity is used, +* create an entry in the global affinity structure and initialize it. +*/ +if (!entry) { + entry =node_affinity_allocate (node); +if (!entry) { +dd_dev_err (dd, +"Unable to allocate global affinity node\n" ); +return -ENOMEM ; } - } +init_cpu_mask_set (&entry->def_intr); +init_cpu_mask_set (&entry->rcv_intr); +/* Use the "real" cpu mask of this node as the default */ +cpumask_and (&entry->def_intr.mask, &node_affinity.real_cpu_mask, + local_mask); + +/* fill in the receive list */ + possible =cpumask_weight (&entry->def_intr.mask); + curr_cpu =cpumask_first (&entry->def_intr.mask); + +if (possible ==1 ) { +/* only one CPU, everyone will use it */ +cpumask_set_cpu (curr_cpu, &entry->rcv_intr.mask); + }else { +/* +* Retain the first CPU in the default list for the +* control context. +*/ + curr_cpu =cpumask_next (curr_cpu, + &entry->def_intr.mask); -cpumask_copy (&info->proc.mask, cpu_online_mask); -} +/* +* Remove the remaining kernel receive queues from +* the default list and add them to the receive list. +*/ +for (i =0 ; i < dd->n_krcv_queues -1 ; i++) { +cpumask_clear_cpu (curr_cpu, + &entry->def_intr.mask); +cpumask_set_cpu (curr_cpu, + &entry->rcv_intr.mask); + curr_cpu =cpumask_next (curr_cpu, + &entry->def_intr.mask); +if (curr_cpu >= nr_cpu_ids) +break ; + } + } -void hfi1_dev_affinity_free (struct hfi1_devdata *dd) -{ -kfree (dd->affinity); +spin_lock (&node_affinity.lock); +node_affinity_add_tail (entry); +spin_unlock (&node_affinity.lock); + } + +return 0 ; }int hfi1_get_irq_affinity (struct hfi1_devdata *dd,struct hfi1_msix_entry *msix) {int ret;cpumask_var_t diff; +struct hfi1_affinity_node *entry;struct cpu_mask_set *set;struct sdma_engine *sde =NULL ;struct hfi1_ctxtdata *rcd =NULL ;
@@ -194,21 +274,25 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)if (!ret)return -ENOMEM ; +spin_lock (&node_affinity.lock); + entry =node_affinity_lookup (dd->node); +spin_unlock (&node_affinity.lock); +switch (msix->type) {case IRQ_SDMA : sde = (struct sdma_engine *)msix->arg;scnprintf (extra,64 ,"engine %u" , sde->this_idx);/* fall through */ case IRQ_GENERAL : - set = &dd->affinity->def_intr; + set = &entry->def_intr;break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg;if (rcd->ctxt ==HFI1_CTRL_CTXT ) { - set = &dd->affinity->def_intr; + set = &entry->def_intr; cpu =cpumask_first (&set->mask); }else { - set = &dd->affinity->rcv_intr; + set = &entry->rcv_intr; }scnprintf (extra,64 ,"ctxt %u" , rcd->ctxt);break ;
@@ -222,8 +306,8 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)* is set above. Skip accounting for it. Everything else finds its * CPU here. */ -if (cpu ==-1 ) { -spin_lock (&dd->affinity->lock); +if (cpu ==-1 && set) { +spin_lock (&node_affinity.lock);if (cpumask_equal (&set->mask, &set->used)) {/* * We've used up all the CPUs, bump up the generation
@@ -235,7 +319,7 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)cpumask_andnot (diff, &set->mask, &set->used); cpu =cpumask_first (diff);cpumask_set_cpu (cpu, &set->used); -spin_unlock (&dd->affinity->lock); +spin_unlock (&node_affinity.lock); }switch (msix->type) {
@@ -263,30 +347,35 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd, {struct cpu_mask_set *set =NULL ;struct hfi1_ctxtdata *rcd; +struct hfi1_affinity_node *entry; + +spin_lock (&node_affinity.lock); + entry =node_affinity_lookup (dd->node); +spin_unlock (&node_affinity.lock);switch (msix->type) {case IRQ_SDMA :case IRQ_GENERAL : - set = &dd->affinity->def_intr; + set = &entry->def_intr;break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg;/* only do accounting for non control contexts */ if (rcd->ctxt !=HFI1_CTRL_CTXT ) - set = &dd->affinity->rcv_intr; + set = &entry->rcv_intr;break ;default :return ; }if (set) { -spin_lock (&dd->affinity->lock); +spin_lock (&node_affinity.lock);cpumask_andnot (&set->used, &set->used, &msix->mask);if (cpumask_empty (&set->used) && set->gen) { set->gen--;cpumask_copy (&set->used, &set->mask); } -spin_unlock (&dd->affinity->lock); +spin_unlock (&node_affinity.lock); }irq_set_affinity_hint (msix->msix.vector,NULL );
@@ -297,9 +386,10 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node) {int cpu =-1 , ret;cpumask_var_t diff, mask, intrs; +struct hfi1_affinity_node *entry;const struct cpumask *node_mask, *proc_mask =tsk_cpus_allowed (current); -struct cpu_mask_set *set = &dd->affinity->proc; +struct cpu_mask_set *set = &node_affinity.proc;/* * check whether process/context affinity has already
@@ -338,7 +428,7 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)if (!ret) goto free_mask; -spin_lock (&dd->affinity->lock); +spin_lock (&node_affinity.lock);/* * If we've used all available CPUs, clear the mask and start * overloading.
@@ -348,13 +438,14 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)cpumask_clear (&set->used); } + entry =node_affinity_lookup (dd->node);/* CPUs used by interrupt handlers */ -cpumask_copy (intrs, (dd->affinity->def_intr.gen ? - &dd->affinity->def_intr.mask : - &dd->affinity->def_intr.used)); -cpumask_or (intrs, intrs, (dd->affinity->rcv_intr.gen ? - &dd->affinity->rcv_intr.mask : - &dd->affinity->rcv_intr.used)); +cpumask_copy (intrs, (entry->def_intr.gen ? + &entry->def_intr.mask : + &entry->def_intr.used)); +cpumask_or (intrs, intrs, (entry->rcv_intr.gen ? + &entry->rcv_intr.mask : + &entry->rcv_intr.used));hfi1_cdbg (PROC ,"CPUs used by interrupts: %*pbl" ,cpumask_pr_args (intrs));
@@ -400,7 +491,7 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node) cpu =-1 ; else cpumask_set_cpu(cpu, &set->used); -spin_unlock (&dd->affinity->lock); +spin_unlock (&node_affinity.lock);free_cpumask_var (intrs); free_mask:
@@ -413,16 +504,16 @@ done:void hfi1_put_proc_affinity (struct hfi1_devdata *dd,int cpu) { -struct cpu_mask_set *set = &dd->affinity->proc; +struct cpu_mask_set *set = &node_affinity.proc;if (cpu <0 )return ; -spin_lock (&dd->affinity->lock); +spin_lock (&node_affinity.lock);cpumask_clear_cpu (cpu, &set->used);if (cpumask_empty (&set->used) && set->gen) { set->gen--;cpumask_copy (&set->used, &set->mask); } -spin_unlock (&dd->affinity->lock); +spin_unlock (&node_affinity.lock); }
drivers/infiniband/hw/hfi1/affinity.h +21 -4
@@ -82,11 +82,9 @@ struct hfi1_affinity {struct hfi1_msix_entry ;/* Initialize non-HT cpu cores mask */ -int init_real_cpu_mask (struct hfi1_devdata *); +void init_real_cpu_mask (void );/* Initialize driver affinity data */ -void hfi1_dev_affinity_init (struct hfi1_devdata *); -/* Free driver affinity data */ -void hfi1_dev_affinity_free (struct hfi1_devdata *); +int hfi1_dev_affinity_init (struct hfi1_devdata *);/* * Set IRQ affinity to a CPU. The function will determine the * CPU and set the affinity to it.
@@ -105,4 +103,23 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *, int);/* Release a CPU used by a user process. */ void hfi1_put_proc_affinity (struct hfi1_devdata *,int ); +struct hfi1_affinity_node { +int node; +struct cpu_mask_set def_intr; +struct cpu_mask_set rcv_intr; +struct list_head list; +}; + +struct hfi1_affinity_node_list { +struct list_head list; +struct cpumask real_cpu_mask; +struct cpu_mask_set proc; +/* protect affinity node list */ +spinlock_t lock; +}; + +void node_affinity_init (void ); +void node_affinity_destroy (void ); +extern struct hfi1_affinity_node_list node_affinity; +#endif /* _HFI1_AFFINITY_H */
drivers/infiniband/hw/hfi1/chip.c +5 -15
@@ -63,6 +63,7 @@#include "efivar.h" #include "platform.h" #include "aspm.h" +#include "affinity.h" #define NUM_IB_PORTS 1
@@ -12838,7 +12839,7 @@ static int set_up_context_variables(struct hfi1_devdata *dd)*/ if (num_user_contexts <0 ) num_user_contexts = -cpumask_weight (&dd->affinity->real_cpu_mask); +cpumask_weight (&node_affinity.real_cpu_mask); total_contexts = num_kernel_contexts + num_user_contexts;
@@ -14468,19 +14469,6 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev, (dd->revision >>CCE_REVISION_SW_SHIFT ) & CCE_REVISION_SW_MASK); -/* -* The real cpu mask is part of the affinity struct but has to be -* initialized earlier than the rest of the affinity struct because it -* is needed to calculate the number of user contexts in -* set_up_context_variables(). However, hfi1_dev_affinity_init(), -* which initializes the rest of the affinity struct members, -* depends on set_up_context_variables() for the number of kernel -* contexts, so it cannot be called before set_up_context_variables(). -*/ - ret =init_real_cpu_mask (dd); -if (ret) - goto bail_cleanup; - ret =set_up_context_variables (dd);if (ret) goto bail_cleanup;
@@ -14494,7 +14482,9 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev,/* set up KDETH QP prefix in both RX and TX CSRs */ init_kdeth_qp (dd); -hfi1_dev_affinity_init (dd); + ret =hfi1_dev_affinity_init (dd); +if (ret) + goto bail_cleanup;/* send contexts must be set up before receive contexts */ ret =init_send_contexts (dd);
drivers/infiniband/hw/hfi1/init.c +4 -1
@@ -64,6 +64,7 @@#include "debugfs.h" #include "verbs.h" #include "aspm.h" +#include "affinity.h" #undef pr_fmt#define pr_fmt (fmt) DRIVER_NAME ": " fmt
@@ -1004,7 +1005,6 @@ static void __hfi1_free_devdata(struct kobject *kobj)rcu_barrier ();/* wait for rcu callbacks to complete */ free_percpu (dd->int_counter);free_percpu (dd->rcv_limit); -hfi1_dev_affinity_free (dd);free_percpu (dd->send_schedule);rvt_dealloc_device (&dd->verbs_dev.rdi); }
@@ -1198,6 +1198,8 @@ static int __init hfi1_mod_init(void)if (ret) goto bail; +node_affinity_init (); +/* validate max MTU before any devices start */ if (!valid_opa_max_mtu (hfi1_max_mtu)) { pr_err("Invalid max_mtu 0x%x, using 0x%x instead\n",
@@ -1278,6 +1280,7 @@ module_init(hfi1_mod_init); static void __exit hfi1_mod_cleanup(void) {pci_unregister_driver (&hfi1_pci_driver); +node_affinity_destroy ();hfi1_wss_exit ();hfi1_dbg_exit (); hfi1_cpulist_count =0 ;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 IB/hfi1: Reserve and collapse CPU cores for contexts
In reply to a message not in the archiveFrom: Sebastian Sanchez <[email protected]>
Kernel receive queues oversubscribe CPU cores on multi-HFI systems. To prevent this, the kernel receive queues are separated onto different cores, and the SDMA engine interrupts are constrained to a lesser number of cores.
hfi1s_on_numa_node*krcvqs is the number of CPU cores that are reserved for kernel receive queues for all HFIs. Each HFI initializes its kernel receive queues to one of the reserved CPU cores. If there ends up being 0 CPU cores leftover for SDMA engines, use the same CPU cores as receive contexts.
In addition, general and control contexts are assigned to their own CPU core, however, both types of contexts tend to have low traffic. To save CPU cores, collapse general and control contexts to one CPU core for all HFI units. This change prevents SDMA engine interrupts from wrapping around general contexts.
--
Changes since v1
----------------
Resolve conflict due to v2 of previous patch.
--- drivers/infiniband/hw/hfi1/affinity.c | 101 +++++++++++++++++++++++++-------- drivers/infiniband/hw/hfi1/affinity.h | 3 + drivers/infiniband/hw/hfi1/hfi.h | 2 + drivers/infiniband/hw/hfi1/init.c | 6 +- 4 files changed, 84 insertions(+), 28 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +76 -25
@@ -66,6 +66,9 @@ static const char * const irq_type_names[] = { "OTHER", }; +/* Per NUMA node count of HFI devices */ +static unsigned int *hfi1_per_node_cntr; +static inline void init_cpu_mask_set (struct cpu_mask_set *set) {cpumask_clear (&set->mask);
@@ -107,8 +110,12 @@ void init_real_cpu_mask(void) } } -void node_affinity_init (void ) +int node_affinity_init (void ) { +int node; +struct pci_dev *dev =NULL ; +const struct pci_device_id *ids = hfi1_pci_tbl; +cpumask_copy (&node_affinity.proc.mask, cpu_online_mask);/* * The real cpu mask is part of the affinity struct but it has to be
@@ -116,6 +123,25 @@ void node_affinity_init(void)* contexts in set_up_context_variables(). */ init_real_cpu_mask (); + + hfi1_per_node_cntr =kcalloc (num_possible_nodes (), +sizeof (*hfi1_per_node_cntr),GFP_KERNEL ); +if (!hfi1_per_node_cntr) +return -ENOMEM ; + +while (ids->vendor) { + dev =NULL ; +while ((dev =pci_get_device (ids->vendor, ids->device, dev))) { + node =pcibus_to_node (dev->bus); +if (node <0 ) + node =numa_node_id (); + + hfi1_per_node_cntr[node]++; + } + ids++; + } + +return 0 ; }void node_affinity_destroy (void )
@@ -131,6 +157,7 @@ void node_affinity_destroy(void)kfree (entry); }spin_unlock (&node_affinity.lock); +kfree (hfi1_per_node_cntr); }static struct hfi1_affinity_node *node_affinity_allocate (int node)
@@ -213,6 +240,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd) }init_cpu_mask_set (&entry->def_intr);init_cpu_mask_set (&entry->rcv_intr); +cpumask_clear (&entry->general_intr_mask);/* Use the "real" cpu mask of this node as the default */ cpumask_and (&entry->def_intr.mask, &node_affinity.real_cpu_mask, local_mask);
@@ -224,11 +252,15 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)if (possible ==1 ) {/* only one CPU, everyone will use it */ cpumask_set_cpu (curr_cpu, &entry->rcv_intr.mask); +cpumask_set_cpu (curr_cpu, &entry->general_intr_mask); }else {/* -* Retain the first CPU in the default list for the -* control context. +* The general/control context will be the first CPU in +* the default list, so it is removed from the default +* list and added to the general interrupt list. */ +cpumask_clear_cpu (curr_cpu, &entry->def_intr.mask); +cpumask_set_cpu (curr_cpu, &entry->general_intr_mask); curr_cpu =cpumask_next (curr_cpu, &entry->def_intr.mask);
@@ -236,7 +268,10 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)* Remove the remaining kernel receive queues from * the default list and add them to the receive list. */ -for (i =0 ; i < dd->n_krcv_queues -1 ; i++) { +for (i =0 ; + i < (dd->n_krcv_queues -1 ) * + hfi1_per_node_cntr[dd->node]; + i++) {cpumask_clear_cpu (curr_cpu, &entry->def_intr.mask); cpumask_set_cpu(curr_cpu,
@@ -246,6 +281,15 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)if (curr_cpu >= nr_cpu_ids)break ; } + +/* +* If there ends up being 0 CPU cores leftover for SDMA +* engines, use the same CPU cores as general/control +* context. +*/ +if (cpumask_weight (&entry->def_intr.mask) ==0 ) +cpumask_copy (&entry->def_intr.mask, + &entry->general_intr_mask); }spin_lock (&node_affinity.lock);
@@ -261,7 +305,7 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)int ret;cpumask_var_t diff;struct hfi1_affinity_node *entry; -struct cpu_mask_set *set; +struct cpu_mask_set *set =NULL ;struct sdma_engine *sde =NULL ;struct hfi1_ctxtdata *rcd =NULL ;char extra[64 ];
@@ -282,18 +326,17 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix)case IRQ_SDMA : sde = (struct sdma_engine *)msix->arg;scnprintf (extra,64 ,"engine %u" , sde->this_idx); -/* fall through */ -case IRQ_GENERAL : set = &entry->def_intr;break ; +case IRQ_GENERAL : + cpu =cpumask_first (&entry->general_intr_mask); +break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg; -if (rcd->ctxt ==HFI1_CTRL_CTXT ) { - set = &entry->def_intr; - cpu =cpumask_first (&set->mask); - }else { +if (rcd->ctxt ==HFI1_CTRL_CTXT ) + cpu =cpumask_first (&entry->general_intr_mask); +else set = &entry->rcv_intr; - }scnprintf (extra,64 ,"ctxt %u" , rcd->ctxt);break ;default :
@@ -302,9 +345,9 @@ int hfi1_get_irq_affinity(struct hfi1_devdata *dd, struct hfi1_msix_entry *msix) }/* -* The control receive context is placed on a particular CPU, which -* is set above. Skip accounting for it. Everything else finds its -* CPU here. +* The general and control contexts are placed on a particular +* CPU, which is set above. Skip accounting for it. Everything else +* finds its CPU here. */ if (cpu ==-1 && set) {spin_lock (&node_affinity.lock);
@@ -355,12 +398,14 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd,switch (msix->type) {case IRQ_SDMA : -case IRQ_GENERAL : set = &entry->def_intr;break ; +case IRQ_GENERAL : +/* Don't accounting for general contexts */ +break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg; -/* only do accounting for non control contexts */ +/* Don't do accounting for control contexts */ if (rcd->ctxt !=HFI1_CTRL_CTXT ) set = &entry->rcv_intr;break ;
@@ -438,14 +483,20 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)cpumask_clear (&set->used); } - entry =node_affinity_lookup (dd->node); -/* CPUs used by interrupt handlers */ -cpumask_copy (intrs, (entry->def_intr.gen ? - &entry->def_intr.mask : - &entry->def_intr.used)); -cpumask_or (intrs, intrs, (entry->rcv_intr.gen ? - &entry->rcv_intr.mask : - &entry->rcv_intr.used)); +/* +* If NUMA node has CPUs used by interrupt handlers, include them in the +* interrupt handler mask. +*/ + entry =node_affinity_lookup (node); +if (entry) { +cpumask_copy (intrs, (entry->def_intr.gen ? + &entry->def_intr.mask : + &entry->def_intr.used)); +cpumask_or (intrs, intrs, (entry->rcv_intr.gen ? + &entry->rcv_intr.mask : + &entry->rcv_intr.used)); +cpumask_or (intrs, intrs, &entry->general_intr_mask); + }hfi1_cdbg (PROC ,"CPUs used by interrupts: %*pbl" ,cpumask_pr_args (intrs));
drivers/infiniband/hw/hfi1/affinity.h +2 -1
@@ -107,6 +107,7 @@ struct hfi1_affinity_node {int node;struct cpu_mask_set def_intr;struct cpu_mask_set rcv_intr; +struct cpumask general_intr_mask;struct list_head list; };
@@ -118,7 +119,7 @@ struct hfi1_affinity_node_list {spinlock_t lock; }; -void node_affinity_init (void ); +int node_affinity_init (void );void node_affinity_destroy (void );extern struct hfi1_affinity_node_list node_affinity;
drivers/infiniband/hw/hfi1/hfi.h +2 -0
@@ -1235,6 +1235,8 @@ int handle_receive_interrupt_nodma_rtail(struct hfi1_ctxtdata *, int);int handle_receive_interrupt_dma_rtail (struct hfi1_ctxtdata *,int );void set_all_slowpath (struct hfi1_devdata *dd); +extern const struct pci_device_id hfi1_pci_tbl[]; +/* receive packet handler dispositions */ #define RCV_PKT_OK 0x0/* keep going */ #define RCV_PKT_LIMIT 0x1/* stop, hit limit, start thread */
drivers/infiniband/hw/hfi1/init.c +4 -2
@@ -1162,7 +1162,7 @@ static int init_one(struct pci_dev *, const struct pci_device_id *);#define DRIVER_LOAD_MSG "Intel " DRIVER_NAME " loaded: "#define PFX DRIVER_NAME ": " -static const struct pci_device_id hfi1_pci_tbl[] = { +const struct pci_device_id hfi1_pci_tbl[] = { {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL0 ) }, {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL1 ) }, {0 , }
@@ -1198,7 +1198,9 @@ static int __init hfi1_mod_init(void)if (ret) goto bail; -node_affinity_init (); + ret =node_affinity_init (); +if (ret) + goto bail;/* validate max MTU before any devices start */ if (!valid_opa_max_mtu (hfi1_max_mtu)) {
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 IB/hfi1: Refine user process affinity algorithm
In reply to a message not in the archiveFrom: Sebastian Sanchez <[email protected]>
When performing process affinity recommendations for MPI ranks, the current algorithm doesn't take into account multiple HFI units. Also, real cores and HT cores are not distinguished from one another. Therefore, all HT cores are recommended to be assigned first within the local NUMA node before recommending the assignments of cores in other NUMA nodes. It's ideal to assign all real cores across all NUMA nodes first, then all HT 1 cores, then all HT 2 cores, and so on to balance CPU workload. CPU cores in other NUMA nodes could be running interrupt handlers, and this is not taken into account.
To balance the CPU workload for user processes, the following recommendation algorithm is used:
For each user process that is opening a context on HFI Y:
a) If all cores are assigned to user processes, start assignments all over from the first core
b) Assign real cores first, then HT cores (First set of HT cores on all physical cores, then second set of HT cores, and, so on) in the following order:
1. Same NUMA node as HFI Y and not running an IRQ handler
2. Same NUMA node as HFI Y and running an IRQ handler
3. Different NUMA node to HFI Y and not running an IRQ handler
4. Different NUMA node to HFI Y and running an IRQ handler
c) Mark core as assigned in the global affinity structure. As user processes are done, remove core assignments from global affinity structure.
This implementation allows an arbitrary number of HT cores and provides support for multiple HFIs.
This is being included in the kernel rather than user space due to the fact that user space has no way of knowing the CPU recommendations for contexts running as part of other jobs.
--
Changes since v1:
----------------
Resolve conflicts introduced by the previous two patches.
--- drivers/infiniband/hw/hfi1/affinity.c | 213 +++++++++++++++++++++++++-------- drivers/infiniband/hw/hfi1/affinity.h | 8 + drivers/infiniband/hw/hfi1/file_ops.c | 15 ++ 3 files changed, 174 insertions(+), 62 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +159 -54
@@ -116,7 +116,17 @@ int node_affinity_init(void)struct pci_dev *dev =NULL ;const struct pci_device_id *ids = hfi1_pci_tbl; +cpumask_clear (&node_affinity.proc.used);cpumask_copy (&node_affinity.proc.mask, cpu_online_mask); + + node_affinity.proc.gen =0 ; + node_affinity.num_core_siblings = +cpumask_weight (topology_sibling_cpumask ( +cpumask_first (&node_affinity.proc.mask) + )); + node_affinity.num_online_nodes =num_online_nodes (); + node_affinity.num_online_cpus =num_online_cpus (); +/* * The real cpu mask is part of the affinity struct but it has to be * initialized early. It is needed to calculate the number of user
@@ -401,7 +411,7 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd, set = &entry->def_intr;break ;case IRQ_GENERAL : -/* Don't accounting for general contexts */ +/* Don't do accounting for general contexts */ break ;case IRQ_RCVCTXT : rcd = (struct hfi1_ctxtdata *)msix->arg;
@@ -427,14 +437,47 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd,cpumask_clear (&msix->mask); } -int hfi1_get_proc_affinity (struct hfi1_devdata *dd,int node) +/* This should be called with node_affinity.lock held */ +static void find_hw_thread_mask (uint hw_thread_no,cpumask_var_t hw_thread_mask, +struct hfi1_affinity_node_list *affinity) +{ +int possible, curr_cpu, i; +uint num_cores_per_socket = node_affinity.num_online_cpus / + affinity->num_core_siblings / + node_affinity.num_online_nodes; + +cpumask_copy (hw_thread_mask, &affinity->proc.mask); +if (affinity->num_core_siblings >0 ) { +/* Removing other siblings not needed for now */ + possible =cpumask_weight (hw_thread_mask); + curr_cpu =cpumask_first (hw_thread_mask); +for (i =0 ; + i < num_cores_per_socket * node_affinity.num_online_nodes; + i++) + curr_cpu =cpumask_next (curr_cpu, hw_thread_mask); + +for (; i < possible; i++) { +cpumask_clear_cpu (curr_cpu, hw_thread_mask); + curr_cpu =cpumask_next (curr_cpu, hw_thread_mask); + } + +/* Identifying correct HW threads within physical cores */ +cpumask_shift_left (hw_thread_mask, hw_thread_mask, + num_cores_per_socket * + node_affinity.num_online_nodes * + hw_thread_no); + } +} + +int hfi1_get_proc_affinity (int node) { -int cpu =-1 , ret; -cpumask_var_t diff, mask, intrs; +int cpu =-1 , ret, i;struct hfi1_affinity_node *entry; +cpumask_var_t diff, hw_thread_mask, available_mask, intrs_mask;const struct cpumask *node_mask, *proc_mask =tsk_cpus_allowed (current); -struct cpu_mask_set *set = &node_affinity.proc; +struct hfi1_affinity_node_list *affinity = &node_affinity; +struct cpu_mask_set *set = &affinity->proc;/* * check whether process/context affinity has already
@@ -460,22 +503,41 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)/* * The process does not have a preset CPU affinity so find one to -* recommend. We prefer CPUs on the same NUMA as the device. +* recommend using the following algorithm: +* +* For each user process that is opening a context on HFI Y: +* a) If all cores are filled, reinitialize the bitmask +* b) Fill real cores first, then HT cores (First set of HT +* cores on all physical cores, then second set of HT core, +* and, so on) in the following order: +* +* 1. Same NUMA node as HFI Y and not running an IRQ +* handler +* 2. Same NUMA node as HFI Y and running an IRQ handler +* 3. Different NUMA node to HFI Y and not running an IRQ +* handler +* 4. Different NUMA node to HFI Y and running an IRQ +* handler +* c) Mark core as filled in the bitmask. As user processes are +* done, clear cores from the bitmask. */ ret =zalloc_cpumask_var (&diff,GFP_KERNEL );if (!ret) goto done; - ret =zalloc_cpumask_var (&mask,GFP_KERNEL ); + ret =zalloc_cpumask_var (&hw_thread_mask,GFP_KERNEL );if (!ret) goto free_diff; - ret =zalloc_cpumask_var (&intrs,GFP_KERNEL ); + ret =zalloc_cpumask_var (&available_mask,GFP_KERNEL );if (!ret) - goto free_mask; + goto free_hw_thread_mask; + ret =zalloc_cpumask_var (&intrs_mask,GFP_KERNEL ); +if (!ret) + goto free_available_mask; -spin_lock (&node_affinity.lock); +spin_lock (&affinity->lock);/* -* If we've used all available CPUs, clear the mask and start +* If we've used all available HW threads, clear the mask and start * overloading. */ if (cpumask_equal (&set->mask, &set->used)) {
@@ -489,82 +551,125 @@ int hfi1_get_proc_affinity(struct hfi1_devdata *dd, int node)*/ entry =node_affinity_lookup (node);if (entry) { -cpumask_copy (intrs, (entry->def_intr.gen ? - &entry->def_intr.mask : - &entry->def_intr.used)); -cpumask_or (intrs, intrs, (entry->rcv_intr.gen ? - &entry->rcv_intr.mask : - &entry->rcv_intr.used)); -cpumask_or (intrs, intrs, &entry->general_intr_mask); +cpumask_copy (intrs_mask, (entry->def_intr.gen ? + &entry->def_intr.mask : + &entry->def_intr.used)); +cpumask_or (intrs_mask, intrs_mask, (entry->rcv_intr.gen ? + &entry->rcv_intr.mask : + &entry->rcv_intr.used)); +cpumask_or (intrs_mask, intrs_mask, &entry->general_intr_mask); }hfi1_cdbg (PROC ,"CPUs used by interrupts: %*pbl" , -cpumask_pr_args (intrs)); +cpumask_pr_args (intrs_mask)); + +cpumask_copy (hw_thread_mask, &set->mask);/* -* If we don't have a NUMA node requested, preference is towards -* device NUMA node +* If HT cores are enabled, identify which HW threads within the +* physical cores should be used. */ -if (node ==-1 ) - node = dd->node; +if (affinity->num_core_siblings >0 ) { +for (i =0 ; i < affinity->num_core_siblings; i++) { +find_hw_thread_mask (i, hw_thread_mask, affinity); + +/* +* If there's at least one available core for this HW +* thread number, stop looking for a core. +* +* diff will always be not empty at least once in this +* loop as the used mask gets reset when +* (set->mask == set->used) before this loop. +*/ +cpumask_andnot (diff, hw_thread_mask, &set->used); +if (!cpumask_empty (diff)) +break ; + } + } +hfi1_cdbg (PROC ,"Same available HW thread on all physical CPUs: %*pbl" , +cpumask_pr_args (hw_thread_mask)); + node_mask =cpumask_of_node (node); -hfi1_cdbg (PROC ,"device on NUMA %u, CPUs %*pbl" , node, +hfi1_cdbg (PROC ,"Device on NUMA %u, CPUs %*pbl" , node,cpumask_pr_args (node_mask)); -/* diff will hold all unused cpus */ -cpumask_andnot (diff, &set->mask, &set->used); -hfi1_cdbg (PROC ,"unused CPUs (all) %*pbl" ,cpumask_pr_args (diff)); - -/* get cpumask of available CPUs on preferred NUMA */ -cpumask_and (mask, diff, node_mask); -hfi1_cdbg (PROC ,"available cpus on NUMA %*pbl" ,cpumask_pr_args (mask)); +/* Get cpumask of available CPUs on preferred NUMA */ +cpumask_and (available_mask, hw_thread_mask, node_mask); +cpumask_andnot (available_mask, available_mask, &set->used); +hfi1_cdbg (PROC ,"Available CPUs on NUMA %u: %*pbl" , node, +cpumask_pr_args (available_mask));/* * At first, we don't want to place processes on the same -* CPUs as interrupt handlers. +* CPUs as interrupt handlers. Then, CPUs running interrupt +* handlers are used. +* +* 1) If diff is not empty, then there are CPUs not running +* non-interrupt handlers available, so diff gets copied +* over to available_mask. +* 2) If diff is empty, then all CPUs not running interrupt +* handlers are taken, so available_mask contains all +* available CPUs running interrupt handlers. +* 3) If available_mask is empty, then all CPUs on the +* preferred NUMA node are taken, so other NUMA nodes are +* used for process assignments using the same method as +* the preferred NUMA node. */ -cpumask_andnot (diff, mask, intrs); +cpumask_andnot (diff, available_mask, intrs_mask);if (!cpumask_empty (diff)) -cpumask_copy (mask, diff); +cpumask_copy (available_mask, diff); -/* -* if we don't have a cpu on the preferred NUMA, get -* the list of the remaining available CPUs -*/ -if (cpumask_empty (mask)) { -cpumask_andnot (diff, &set->mask, &set->used); -cpumask_andnot (mask, diff, node_mask); +/* If we don't have CPUs on the preferred node, use other NUMA nodes */ +if (cpumask_empty (available_mask)) { +cpumask_andnot (available_mask, hw_thread_mask, &set->used); +/* Excluding preferred NUMA cores */ +cpumask_andnot (available_mask, available_mask, node_mask); +hfi1_cdbg (PROC , +"Preferred NUMA node cores are taken, cores available in other NUMA nodes: %*pbl" , +cpumask_pr_args (available_mask)); + +/* +* At first, we don't want to place processes on the same +* CPUs as interrupt handlers. +*/ +cpumask_andnot (diff, available_mask, intrs_mask); +if (!cpumask_empty (diff)) +cpumask_copy (available_mask, diff); } -hfi1_cdbg (PROC ,"possible CPUs for process %*pbl" , -cpumask_pr_args (mask)); +hfi1_cdbg (PROC ,"Possible CPUs for process: %*pbl" , +cpumask_pr_args (available_mask)); - cpu =cpumask_first (mask); + cpu =cpumask_first (available_mask);if (cpu >= nr_cpu_ids)/* empty */ cpu =-1 ;else cpumask_set_cpu (cpu, &set->used); -spin_unlock (&node_affinity.lock); - -free_cpumask_var (intrs); -free_mask: -free_cpumask_var (mask); +spin_unlock (&affinity->lock); +hfi1_cdbg (PROC ,"Process assigned to CPU %d" , cpu); + +free_cpumask_var (intrs_mask); +free_available_mask: +free_cpumask_var (available_mask); +free_hw_thread_mask: +free_cpumask_var (hw_thread_mask); free_diff:free_cpumask_var (diff); done:return cpu; } -void hfi1_put_proc_affinity (struct hfi1_devdata *dd,int cpu) +void hfi1_put_proc_affinity (int cpu) { -struct cpu_mask_set *set = &node_affinity.proc; +struct hfi1_affinity_node_list *affinity = &node_affinity; +struct cpu_mask_set *set = &affinity->proc;if (cpu <0 )return ; -spin_lock (&node_affinity.lock); +spin_lock (&affinity->lock);cpumask_clear_cpu (cpu, &set->used); +hfi1_cdbg (PROC ,"Returning CPU %d for future process assignment" , cpu);if (cpumask_empty (&set->used) && set->gen) { set->gen--;cpumask_copy (&set->used, &set->mask); } -spin_unlock (&node_affinity.lock); +spin_unlock (&affinity->lock); } -
drivers/infiniband/hw/hfi1/affinity.h +5 -3
@@ -73,7 +73,6 @@ struct cpu_mask_set {struct hfi1_affinity {struct cpu_mask_set def_intr;struct cpu_mask_set rcv_intr; -struct cpu_mask_set proc;struct cpumask real_cpu_mask;/* spin lock to protect affinity struct */ spinlock_t lock;
@@ -99,9 +98,9 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *, struct hfi1_msix_entry *);* Determine a CPU affinity for a user process, if the process does not * have an affinity set yet. */ -int hfi1_get_proc_affinity (struct hfi1_devdata *,int ); +int hfi1_get_proc_affinity (int );/* Release a CPU used by a user process. */ -void hfi1_put_proc_affinity (struct hfi1_devdata *,int ); +void hfi1_put_proc_affinity (int );struct hfi1_affinity_node {int node;
@@ -115,6 +114,9 @@ struct hfi1_affinity_node_list {struct list_head list;struct cpumask real_cpu_mask;struct cpu_mask_set proc; +int num_core_siblings; +int num_online_nodes; +int num_online_cpus;/* protect affinity node list */ spinlock_t lock; };
drivers/infiniband/hw/hfi1/file_ops.c +10 -5
@@ -715,7 +715,7 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)hfi1_user_sdma_free_queues (fdata);/* release the cpu */ -hfi1_put_proc_affinity (dd, fdata->rec_cpu_num); +hfi1_put_proc_affinity (fdata->rec_cpu_num);/* * Clear any left over, unhandled events so the next process that
@@ -815,9 +815,10 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo) ret =find_shared_ctxt (fp, uinfo);if (ret <0 ) goto done_unlock; -if (ret) - fd->rec_cpu_num =hfi1_get_proc_affinity ( - fd->uctxt->dd, fd->uctxt->numa_id); +if (ret) { + fd->rec_cpu_num = +hfi1_get_proc_affinity (fd->uctxt->numa_id); + } }/*
@@ -929,7 +930,11 @@ static int allocate_ctxt(struct file *fp, struct hfi1_devdata *dd,if (ctxt == dd->num_rcv_contexts)return -EBUSY ; - fd->rec_cpu_num =hfi1_get_proc_affinity (dd,-1 ); +/* +* If we don't have a NUMA node requested, preference is towards +* device NUMA node. +*/ + fd->rec_cpu_num =hfi1_get_proc_affinity (dd->node);if (fd->rec_cpu_num !=-1 ) numa =cpu_to_node (fd->rec_cpu_num);else
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 23 lines · Dennis Dalessandro
Hi Doug,
Here is a set of fixes and improvmenets that would be for the next release. They
apply onto of the last set of RC fixes previously posted.Of particular note in here is the twsi code clean up that was asked for
previously while we were in staging. I think this does the job of not duplicating what is already present in the kernel. These are the two patches
from Dean.The patches from Mike improve rdmavt and make the posting of sends more friendly
to work with and extend.There are also performance improvement patches in this bunch as well as well as
a couple minor fixes that we felt are more appropriate for the next merge cycle
rather than RC.
Quoted 7 lines
These patches have been added to my GitHub branch and have passed zero day
builds.
Hi Denny,
These are in. I had to rebase in order to rip out the V1 of patches 8, 9, and 10, and then put the v2 in their place, but that's done as well.
Signature · 2 lines
Doug Ledford <[email protected]> GPG KeyID: 0E572FDD