Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/counter: Add PID category support in auto mode

With the "PID" category QPs have same PID will be bound to same counter;
If this category is not set then QPs have different PIDs will be bound
to same counter.

This is implemented for 2 reasons:
1. The counter is a limited resource, while there may be dozens of
applications, each of which creates several types of QPs, which means
it may doesn't have enough counter.
2. The system administrator needs all QPs created by all applications
with same type bound to one counter.

The counter name and PID is only make sense when "PID" category are
configured.

This category can also be used in combine with others, e.g. QP type.

Link: https://lore.kernel.org/r/20200702082933.424537-2-leon@kernel.org
Signed-off-by: Mark Zhang <markz@mellanox.com>
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Mark Zhang and committed by
Jason Gunthorpe
7c97f3ad 6c72a038

+12 -17
+5 -15
drivers/infiniband/core/counters.c
··· 8 8 #include "core_priv.h" 9 9 #include "restrack.h" 10 10 11 - #define ALL_AUTO_MODE_MASKS (RDMA_COUNTER_MASK_QP_TYPE) 11 + #define ALL_AUTO_MODE_MASKS (RDMA_COUNTER_MASK_QP_TYPE | RDMA_COUNTER_MASK_PID) 12 12 13 13 static int __counter_set_mode(struct rdma_counter_mode *curr, 14 14 enum rdma_nl_counter_mode new_mode, ··· 149 149 struct auto_mode_param *param = &counter->mode.param; 150 150 bool match = true; 151 151 152 - /* 153 - * Ensure that counter belongs to the right PID. This operation can 154 - * race with user space which kills the process and leaves QP and 155 - * counters orphans. 156 - * 157 - * It is not a big deal because exitted task will leave both QP and 158 - * counter in the same bucket of zombie process. Just ensure that 159 - * process is still alive before procedding. 160 - * 161 - */ 162 - if (task_pid_nr(counter->res.task) != task_pid_nr(qp->res.task) || 163 - !task_pid_nr(qp->res.task)) 164 - return false; 165 - 166 152 if (auto_mask & RDMA_COUNTER_MASK_QP_TYPE) 167 153 match &= (param->qp_type == qp->qp_type); 154 + 155 + if (auto_mask & RDMA_COUNTER_MASK_PID) 156 + match &= (task_pid_nr(counter->res.task) == 157 + task_pid_nr(qp->res.task)); 168 158 169 159 return match; 170 160 }
+6 -2
drivers/infiniband/core/nldev.c
··· 711 711 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_STAT_MODE, m->mode)) 712 712 return -EMSGSIZE; 713 713 714 - if (m->mode == RDMA_COUNTER_MODE_AUTO) 714 + if (m->mode == RDMA_COUNTER_MODE_AUTO) { 715 715 if ((m->mask & RDMA_COUNTER_MASK_QP_TYPE) && 716 716 nla_put_u8(msg, RDMA_NLDEV_ATTR_RES_TYPE, m->param.qp_type)) 717 717 return -EMSGSIZE; 718 + 719 + if ((m->mask & RDMA_COUNTER_MASK_PID) && 720 + fill_res_name_pid(msg, &counter->res)) 721 + return -EMSGSIZE; 722 + } 718 723 719 724 return 0; 720 725 } ··· 860 855 861 856 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, counter->port) || 862 857 nla_put_u32(msg, RDMA_NLDEV_ATTR_STAT_COUNTER_ID, counter->id) || 863 - fill_res_name_pid(msg, &counter->res) || 864 858 fill_stat_counter_mode(msg, counter) || 865 859 fill_stat_counter_qps(msg, counter) || 866 860 fill_stat_counter_hwcounters(msg, counter))
+1
include/uapi/rdma/rdma_netlink.h
··· 569 569 */ 570 570 enum rdma_nl_counter_mask { 571 571 RDMA_COUNTER_MASK_QP_TYPE = 1, 572 + RDMA_COUNTER_MASK_PID = 1 << 1, 572 573 }; 573 574 #endif /* _UAPI_RDMA_NETLINK_H */