On Wed, Mar 21, 2018 at 05:12:42PM +0200, Leon Romanovsky wrote: > From: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > The restrack clean routine had simple, but powerful WARN_ON check > to see if all resources are cleared prior to releasing device. > > The WARN_ON check performed very well, but lack of information > which device caused to resource leak, the object type and origin > made debug to be fun and challenging at the same time. > > The fact that all dumps were the same because restrack_clean() is > called in dealloc() didn't help either. > > So let's fix spelling error and convert WARN_ON to be more debug > friendly. The dmesg cut below gives example of how the output > will look output for the case fixed in patch [1] > > [ 438.421372] restrack: ------------[ cut here ]------------ > [ 438.423448] restrack: BUG: RESTRACK detected leak of resources on mlx5_2 > [ 438.425600] restrack: Kernel PD object allocated by mlx5_ib is not freed > [ 438.427753] restrack: Kernel CQ object allocated by mlx5_ib is not freed > [ 438.429660] restrack: ------------[ cut here ]------------ > > [1] https://patchwork.kernel.org/patch/10298695/ > > Cc: Michal Kalderon <Michal.Kalderon@xxxxxxxxxx> > Cc: Chuck Lever <chuck.lever@xxxxxxxxxx> > Reviewed-by: Mark Bloch <markb@xxxxxxxxxxxx> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > --- > drivers/infiniband/core/restrack.c | 44 +++++++++++++++++++++++++++++++++++++- > include/rdma/restrack.h | 2 +- > 2 files changed, 44 insertions(+), 2 deletions(-) > > -- > 2.14.3 Applied to for-next > diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c > index 4cad0cd9aa0c..fbeba80eb9b0 100644 > --- a/drivers/infiniband/core/restrack.c > +++ b/drivers/infiniband/core/restrack.c > @@ -17,9 +17,51 @@ void rdma_restrack_init(struct rdma_restrack_root *res) > init_rwsem(&res->rwsem); > } > > +static const char *type2str(enum rdma_restrack_type type) > +{ > + static const char *names[RDMA_RESTRACK_MAX] = { Switched this to static const char * const names[RDMA_RESTRACK_MAX] = { To make sure the array goes to .rodata Interestingly gcc-7 with -O2 figures out that the array is never written to in this case and moves it to .rodata automatically. Neat. Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html