RE: [PATCH RFC iproute-next 4/5] rdma: Add MR resource tracking information
> -Original Message- > From: Leon Romanovsky [mailto:l...@kernel.org] > Sent: Tuesday, February 20, 2018 8:12 AM > To: Steve Wise <sw...@opengridcomputing.com> > Cc: dsah...@gmail.com; step...@networkplumber.org; > netdev@vger.kernel.org; linux-r...@vger.kernel.org > Subject: Re: [PATCH RFC iproute-next 4/5] rdma: Add MR resource tracking > information > > On Wed, Feb 14, 2018 at 01:07:01PM -0800, Steve Wise wrote: > > Sample output: > > > > # rdma resource show mr > > link cxgb4_0/- rkey 0x5e0e lkey 0x5e0e iova 0x7f9b60001c80 mrlen 64 > pgsize 4096 pid 30503 comm rping > > link cxgb4_0/- rkey 0x510d lkey 0x510d iova 0x17c7ee0 mrlen 16 pgsize > 4096 pid 30503 comm rping > > link cxgb4_0/- rkey 0x4a0c lkey 0x4a0c iova 0x17c7e38 mrlen 16 pgsize 4096 > pid 30503 comm rping > > link cxgb4_0/- rkey 0x480b lkey 0x480b iova 0x224b3f0 mrlen 64 pgsize > 4096 pid 30498 comm rping > > link cxgb4_0/- rkey 0x460a lkey 0x460a iova 0x224b350 mrlen 64 pgsize > 4096 pid 30498 comm rping > > link cxgb4_0/- rkey 0x4509 lkey 0x4509 iova 0x2245890 mrlen 16 pgsize > 4096 pid 30498 comm rping > > link cxgb4_0/- rkey 0x4208 lkey 0x4208 iova 0x22457e8 mrlen 16 pgsize > 4096 pid 30498 comm rping > > link mlx4_0/- rkey 0x38010700 lkey 0x38010700 iova 0x7f9b5c002f90 mrlen > 64 pgsize 4096 pid 30494 comm rping > > link mlx4_0/- rkey 0x38010600 lkey 0x38010600 iova 0x17c6c80 mrlen 16 > pgsize 4096 pid 30494 comm rping > > link mlx4_0/- rkey 0x38010500 lkey 0x38010500 iova 0x17c6bd8 mrlen 16 > pgsize 4096 pid 30494 comm rping > > link mlx4_0/- rkey 0x38010400 lkey 0x38010400 iova 0x1b68430 mrlen 64 > pgsize 4096 pid 30489 comm rping > > link mlx4_0/- rkey 0x38010300 lkey 0x38010300 iova 0x1b683a0 mrlen 64 > pgsize 4096 pid 30489 comm rping > > link mlx4_0/- rkey 0x38010200 lkey 0x38010200 iova 0x1b62890 mrlen 16 > pgsize 4096 pid 30489 comm rping > > link mlx4_0/- rkey 0x38010100 lkey 0x38010100 iova 0x1b627e8 mrlen 16 > pgsize 4096 pid 30489 comm rping > > > > Signed-off-by: Steve Wise <sw...@opengridcomputing.com> > > --- > > include/json_writer.h | 2 + > > lib/json_writer.c | 11 + > > rdma/res.c| 126 > ++ > > rdma/utils.c | 7 +++ > > 4 files changed, 146 insertions(+) > > > > diff --git a/include/json_writer.h b/include/json_writer.h > > index 1516aaf..34f2ccc 100644 > > --- a/include/json_writer.h > > +++ b/include/json_writer.h > > @@ -39,6 +39,7 @@ void jsonw_bool(json_writer_t *self, bool value); > > void jsonw_float(json_writer_t *self, double number); > > void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num); > > void jsonw_uint(json_writer_t *self, uint64_t number); > > +void jsonw_xint(json_writer_t *self, uint64_t number); > > void jsonw_hu(json_writer_t *self, unsigned short number); > > void jsonw_int(json_writer_t *self, int64_t number); > > void jsonw_null(json_writer_t *self); > > @@ -49,6 +50,7 @@ void jsonw_string_field(json_writer_t *self, const char > *prop, const char *val); > > void jsonw_bool_field(json_writer_t *self, const char *prop, bool value); > > void jsonw_float_field(json_writer_t *self, const char *prop, double num); > > void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t > num); > > +void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t > num); > > void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short > num); > > void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num); > > void jsonw_null_field(json_writer_t *self, const char *prop); > > diff --git a/lib/json_writer.c b/lib/json_writer.c > > index f3eeaf7..6d73a1b 100644 > > --- a/lib/json_writer.c > > +++ b/lib/json_writer.c > > @@ -224,6 +224,11 @@ void jsonw_uint(json_writer_t *self, uint64_t > num) > > jsonw_printf(self, "%"PRIu64, num); > > } > > > > +void jsonw_xint(json_writer_t *self, uint64_t num) > > +{ > > + jsonw_printf(self, "%"PRIx64, num); > > +} > > + > > void jsonw_lluint(json_writer_t *self, unsigned long long int num) > > { > > jsonw_printf(self, "%llu", num); > > @@ -268,6 +273,12 @@ void jsonw_uint_field(json_writer_t *self, const > char *prop, uint64_t num) > > jsonw_uint(self, num); > > } > > > > +void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num) > > +{ > > + jsonw_name(self, prop); > > + jsonw_xint(self, num); > > +} > > + >
Re: [PATCH RFC iproute-next 4/5] rdma: Add MR resource tracking information
On Wed, Feb 14, 2018 at 01:07:01PM -0800, Steve Wise wrote: > Sample output: > > # rdma resource show mr > link cxgb4_0/- rkey 0x5e0e lkey 0x5e0e iova 0x7f9b60001c80 mrlen 64 pgsize > 4096 pid 30503 comm rping > link cxgb4_0/- rkey 0x510d lkey 0x510d iova 0x17c7ee0 mrlen 16 pgsize 4096 > pid 30503 comm rping > link cxgb4_0/- rkey 0x4a0c lkey 0x4a0c iova 0x17c7e38 mrlen 16 pgsize 4096 > pid 30503 comm rping > link cxgb4_0/- rkey 0x480b lkey 0x480b iova 0x224b3f0 mrlen 64 pgsize 4096 > pid 30498 comm rping > link cxgb4_0/- rkey 0x460a lkey 0x460a iova 0x224b350 mrlen 64 pgsize 4096 > pid 30498 comm rping > link cxgb4_0/- rkey 0x4509 lkey 0x4509 iova 0x2245890 mrlen 16 pgsize 4096 > pid 30498 comm rping > link cxgb4_0/- rkey 0x4208 lkey 0x4208 iova 0x22457e8 mrlen 16 pgsize 4096 > pid 30498 comm rping > link mlx4_0/- rkey 0x38010700 lkey 0x38010700 iova 0x7f9b5c002f90 mrlen 64 > pgsize 4096 pid 30494 comm rping > link mlx4_0/- rkey 0x38010600 lkey 0x38010600 iova 0x17c6c80 mrlen 16 pgsize > 4096 pid 30494 comm rping > link mlx4_0/- rkey 0x38010500 lkey 0x38010500 iova 0x17c6bd8 mrlen 16 pgsize > 4096 pid 30494 comm rping > link mlx4_0/- rkey 0x38010400 lkey 0x38010400 iova 0x1b68430 mrlen 64 pgsize > 4096 pid 30489 comm rping > link mlx4_0/- rkey 0x38010300 lkey 0x38010300 iova 0x1b683a0 mrlen 64 pgsize > 4096 pid 30489 comm rping > link mlx4_0/- rkey 0x38010200 lkey 0x38010200 iova 0x1b62890 mrlen 16 pgsize > 4096 pid 30489 comm rping > link mlx4_0/- rkey 0x38010100 lkey 0x38010100 iova 0x1b627e8 mrlen 16 pgsize > 4096 pid 30489 comm rping > > Signed-off-by: Steve Wise> --- > include/json_writer.h | 2 + > lib/json_writer.c | 11 + > rdma/res.c| 126 > ++ > rdma/utils.c | 7 +++ > 4 files changed, 146 insertions(+) > > diff --git a/include/json_writer.h b/include/json_writer.h > index 1516aaf..34f2ccc 100644 > --- a/include/json_writer.h > +++ b/include/json_writer.h > @@ -39,6 +39,7 @@ void jsonw_bool(json_writer_t *self, bool value); > void jsonw_float(json_writer_t *self, double number); > void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num); > void jsonw_uint(json_writer_t *self, uint64_t number); > +void jsonw_xint(json_writer_t *self, uint64_t number); > void jsonw_hu(json_writer_t *self, unsigned short number); > void jsonw_int(json_writer_t *self, int64_t number); > void jsonw_null(json_writer_t *self); > @@ -49,6 +50,7 @@ void jsonw_string_field(json_writer_t *self, const char > *prop, const char *val); > void jsonw_bool_field(json_writer_t *self, const char *prop, bool value); > void jsonw_float_field(json_writer_t *self, const char *prop, double num); > void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num); > +void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num); > void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short > num); > void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num); > void jsonw_null_field(json_writer_t *self, const char *prop); > diff --git a/lib/json_writer.c b/lib/json_writer.c > index f3eeaf7..6d73a1b 100644 > --- a/lib/json_writer.c > +++ b/lib/json_writer.c > @@ -224,6 +224,11 @@ void jsonw_uint(json_writer_t *self, uint64_t num) > jsonw_printf(self, "%"PRIu64, num); > } > > +void jsonw_xint(json_writer_t *self, uint64_t num) > +{ > + jsonw_printf(self, "%"PRIx64, num); > +} > + > void jsonw_lluint(json_writer_t *self, unsigned long long int num) > { > jsonw_printf(self, "%llu", num); > @@ -268,6 +273,12 @@ void jsonw_uint_field(json_writer_t *self, const char > *prop, uint64_t num) > jsonw_uint(self, num); > } > > +void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num) > +{ > + jsonw_name(self, prop); > + jsonw_xint(self, num); > +} > + > void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short > num) > { > jsonw_name(self, prop); > diff --git a/rdma/res.c b/rdma/res.c > index 27c1efd..2b67d25 100644 > --- a/rdma/res.c > +++ b/rdma/res.c > @@ -819,6 +819,119 @@ static int res_cq_parse_cb(const struct nlmsghdr *nlh, > void *data) > return MNL_CB_OK; > } > > +static void print_key(struct rd *rd, const char *name, uint32_t val) > +{ > + if (rd->json_output) > + jsonw_xint_field(rd->jw, name, val); > + else > + pr_out("%s 0x%x ", name, val); > +} > + > +static void print_iova(struct rd *rd, uint64_t val) > +{ > + if (rd->json_output) > + jsonw_xint_field(rd->jw, "iova", val); > + else > + pr_out("iova 0x%" PRIx64 " ", val); > +} > + > +static void print_mrlen(struct rd *rd, uint64_t val) > +{ > + if (rd->json_output) > + jsonw_uint_field(rd->jw, "mrlen", val); > + else > + pr_out("mrlen %" PRIu64 " ", val); > +} > + > +static void print_pgsize(struct rd *rd,
[PATCH RFC iproute-next 4/5] rdma: Add MR resource tracking information
Sample output: # rdma resource show mr link cxgb4_0/- rkey 0x5e0e lkey 0x5e0e iova 0x7f9b60001c80 mrlen 64 pgsize 4096 pid 30503 comm rping link cxgb4_0/- rkey 0x510d lkey 0x510d iova 0x17c7ee0 mrlen 16 pgsize 4096 pid 30503 comm rping link cxgb4_0/- rkey 0x4a0c lkey 0x4a0c iova 0x17c7e38 mrlen 16 pgsize 4096 pid 30503 comm rping link cxgb4_0/- rkey 0x480b lkey 0x480b iova 0x224b3f0 mrlen 64 pgsize 4096 pid 30498 comm rping link cxgb4_0/- rkey 0x460a lkey 0x460a iova 0x224b350 mrlen 64 pgsize 4096 pid 30498 comm rping link cxgb4_0/- rkey 0x4509 lkey 0x4509 iova 0x2245890 mrlen 16 pgsize 4096 pid 30498 comm rping link cxgb4_0/- rkey 0x4208 lkey 0x4208 iova 0x22457e8 mrlen 16 pgsize 4096 pid 30498 comm rping link mlx4_0/- rkey 0x38010700 lkey 0x38010700 iova 0x7f9b5c002f90 mrlen 64 pgsize 4096 pid 30494 comm rping link mlx4_0/- rkey 0x38010600 lkey 0x38010600 iova 0x17c6c80 mrlen 16 pgsize 4096 pid 30494 comm rping link mlx4_0/- rkey 0x38010500 lkey 0x38010500 iova 0x17c6bd8 mrlen 16 pgsize 4096 pid 30494 comm rping link mlx4_0/- rkey 0x38010400 lkey 0x38010400 iova 0x1b68430 mrlen 64 pgsize 4096 pid 30489 comm rping link mlx4_0/- rkey 0x38010300 lkey 0x38010300 iova 0x1b683a0 mrlen 64 pgsize 4096 pid 30489 comm rping link mlx4_0/- rkey 0x38010200 lkey 0x38010200 iova 0x1b62890 mrlen 16 pgsize 4096 pid 30489 comm rping link mlx4_0/- rkey 0x38010100 lkey 0x38010100 iova 0x1b627e8 mrlen 16 pgsize 4096 pid 30489 comm rping Signed-off-by: Steve Wise--- include/json_writer.h | 2 + lib/json_writer.c | 11 + rdma/res.c| 126 ++ rdma/utils.c | 7 +++ 4 files changed, 146 insertions(+) diff --git a/include/json_writer.h b/include/json_writer.h index 1516aaf..34f2ccc 100644 --- a/include/json_writer.h +++ b/include/json_writer.h @@ -39,6 +39,7 @@ void jsonw_bool(json_writer_t *self, bool value); void jsonw_float(json_writer_t *self, double number); void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num); void jsonw_uint(json_writer_t *self, uint64_t number); +void jsonw_xint(json_writer_t *self, uint64_t number); void jsonw_hu(json_writer_t *self, unsigned short number); void jsonw_int(json_writer_t *self, int64_t number); void jsonw_null(json_writer_t *self); @@ -49,6 +50,7 @@ void jsonw_string_field(json_writer_t *self, const char *prop, const char *val); void jsonw_bool_field(json_writer_t *self, const char *prop, bool value); void jsonw_float_field(json_writer_t *self, const char *prop, double num); void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num); +void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num); void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num); void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num); void jsonw_null_field(json_writer_t *self, const char *prop); diff --git a/lib/json_writer.c b/lib/json_writer.c index f3eeaf7..6d73a1b 100644 --- a/lib/json_writer.c +++ b/lib/json_writer.c @@ -224,6 +224,11 @@ void jsonw_uint(json_writer_t *self, uint64_t num) jsonw_printf(self, "%"PRIu64, num); } +void jsonw_xint(json_writer_t *self, uint64_t num) +{ + jsonw_printf(self, "%"PRIx64, num); +} + void jsonw_lluint(json_writer_t *self, unsigned long long int num) { jsonw_printf(self, "%llu", num); @@ -268,6 +273,12 @@ void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num) jsonw_uint(self, num); } +void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num) +{ + jsonw_name(self, prop); + jsonw_xint(self, num); +} + void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num) { jsonw_name(self, prop); diff --git a/rdma/res.c b/rdma/res.c index 27c1efd..2b67d25 100644 --- a/rdma/res.c +++ b/rdma/res.c @@ -819,6 +819,119 @@ static int res_cq_parse_cb(const struct nlmsghdr *nlh, void *data) return MNL_CB_OK; } +static void print_key(struct rd *rd, const char *name, uint32_t val) +{ + if (rd->json_output) + jsonw_xint_field(rd->jw, name, val); + else + pr_out("%s 0x%x ", name, val); +} + +static void print_iova(struct rd *rd, uint64_t val) +{ + if (rd->json_output) + jsonw_xint_field(rd->jw, "iova", val); + else + pr_out("iova 0x%" PRIx64 " ", val); +} + +static void print_mrlen(struct rd *rd, uint64_t val) +{ + if (rd->json_output) + jsonw_uint_field(rd->jw, "mrlen", val); + else + pr_out("mrlen %" PRIu64 " ", val); +} + +static void print_pgsize(struct rd *rd, uint32_t val) +{ + if (rd->json_output) + jsonw_uint_field(rd->jw, "pgsize", val); + else + pr_out("pgsize %u ", val); +} + +static int res_mr_parse_cb(const struct nlmsghdr *nlh, void *data) +{ + struct nlattr