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

RDMA/restrack: Consolidate task name updates in one place

Unify task update and kernel name set in one place.

Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com>
Reviewed-by: Yossi Itigin <yosefe@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Leon Romanovsky and committed by
Jason Gunthorpe
2165fc26 363ad355

+16 -17
+2 -8
drivers/infiniband/core/cma.c
··· 875 875 if (!id_priv) 876 876 return ERR_PTR(-ENOMEM); 877 877 878 - if (caller) 879 - id_priv->res.kern_name = caller; 880 - else 881 - rdma_restrack_set_task(&id_priv->res, current); 878 + rdma_restrack_set_task(&id_priv->res, caller); 882 879 id_priv->res.type = RDMA_RESTRACK_CM_ID; 883 880 id_priv->state = RDMA_CM_IDLE; 884 881 id_priv->id.context = context; ··· 3942 3945 3943 3946 id_priv = container_of(id, struct rdma_id_private, id); 3944 3947 3945 - if (caller) 3946 - id_priv->res.kern_name = caller; 3947 - else 3948 - rdma_restrack_set_task(&id_priv->res, current); 3948 + rdma_restrack_set_task(&id_priv->res, caller); 3949 3949 3950 3950 if (!cma_comp(id_priv, RDMA_CM_CONNECT)) 3951 3951 return -EINVAL;
+1 -1
drivers/infiniband/core/cq.c
··· 161 161 goto out_destroy_cq; 162 162 163 163 cq->res.type = RDMA_RESTRACK_CQ; 164 - cq->res.kern_name = caller; 164 + rdma_restrack_set_task(&cq->res, caller); 165 165 rdma_restrack_add(&cq->res); 166 166 167 167 switch (cq->poll_ctx) {
+9 -4
drivers/infiniband/core/restrack.c
··· 156 156 } 157 157 158 158 void rdma_restrack_set_task(struct rdma_restrack_entry *res, 159 - struct task_struct *task) 159 + const char *caller) 160 160 { 161 + if (caller) { 162 + res->kern_name = caller; 163 + return; 164 + } 165 + 161 166 if (res->task) 162 167 put_task_struct(res->task); 163 - get_task_struct(task); 164 - res->task = task; 168 + get_task_struct(current); 169 + res->task = current; 165 170 } 166 171 EXPORT_SYMBOL(rdma_restrack_set_task); 167 172 ··· 182 177 183 178 if (res_is_user(res)) { 184 179 if (!res->task) 185 - rdma_restrack_set_task(res, current); 180 + rdma_restrack_set_task(res, NULL); 186 181 res->kern_name = NULL; 187 182 } else { 188 183 set_kern_name(res);
+2 -2
drivers/infiniband/core/verbs.c
··· 264 264 } 265 265 266 266 pd->res.type = RDMA_RESTRACK_PD; 267 - pd->res.kern_name = caller; 267 + rdma_restrack_set_task(&pd->res, caller); 268 268 rdma_restrack_add(&pd->res); 269 269 270 270 if (mr_access_flags) { ··· 1889 1889 cq->cq_context = cq_context; 1890 1890 atomic_set(&cq->usecnt, 0); 1891 1891 cq->res.type = RDMA_RESTRACK_CQ; 1892 - cq->res.kern_name = caller; 1892 + rdma_restrack_set_task(&cq->res, caller); 1893 1893 rdma_restrack_add(&cq->res); 1894 1894 } 1895 1895
+2 -2
include/rdma/restrack.h
··· 173 173 /** 174 174 * rdma_restrack_set_task() - set the task for this resource 175 175 * @res: resource entry 176 - * @task: task struct 176 + * @caller: kernel name, the current task will be used if the caller is NULL. 177 177 */ 178 178 void rdma_restrack_set_task(struct rdma_restrack_entry *res, 179 - struct task_struct *task); 179 + const char *caller); 180 180 181 181 /* 182 182 * Helper functions for rdma drivers when filling out