Skip to content

Commit 4cd09bb

Browse files
Nagamani PVSidraya Jayagond
authored andcommitted
smc-tools: Display sndbuf/RMB stats only if supported by the kernel
Recent smc-tools commits introduced the display of ring buffer usage statistics: 845ab35 smcd/smcr: Add statistics on ringbufs being used by smc conns 089d42e smcr/smcd: Add statistics of linkgroup ringbuf usage These features rely on kernel support added in the following commits: e0d103542b06 net/smc: Add statistics for ring buffer usage per network namespace d386d59b7c1a net/smc: Add statistics for allocated ring buffers within a link group On systems running kernels without these commits, smc-tools may report zero values for ring buffer usage and allocation. While zero is a valid statistic, in this context it may misleadingly suggest that no buffers are in use, rather than indicating a lack of kernel support. This patch ensures that sndbuf/RMB statistics are displayed only when the kernel provides explicit support for these metrics, thereby avoiding confusion on unsupported systems. Reviewed-by: Mahanta Jambigi <mjambigi@linux.ibm.com> Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com> Reviewed-by: Sidraya Jayagond <sidraya@linux.ibm.com> Signed-off-by: Nagamani PV <nagamani@linux.ibm.com>
1 parent 62c29af commit 4cd09bb

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

linkgroup.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,12 @@ static int fill_lgr_struct(struct smc_diag_lgr *lgr, struct nlattr **attrs)
321321
nla_get_string(lgr_attrs[SMC_NLA_LGR_R_PNETID]));
322322
if (lgr_attrs[SMC_NLA_LGR_R_SNDBUF_ALLOC])
323323
lgr->sndbuf_alloc = nl_attr_get_uint(lgr_attrs[SMC_NLA_LGR_R_SNDBUF_ALLOC]);
324+
else
325+
lgr->sndbuf_alloc = SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT;
324326
if (lgr_attrs[SMC_NLA_LGR_R_RMB_ALLOC])
325327
lgr->rmb_alloc = nl_attr_get_uint(lgr_attrs[SMC_NLA_LGR_R_RMB_ALLOC]);
328+
else
329+
lgr->rmb_alloc = SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT;
326330
if (lgr_attrs[SMC_NLA_LGR_R_V2_COMMON]) {
327331
struct nlattr *v2_lgr_attrs[SMC_NLA_LGR_V2_MAX + 1];
328332

@@ -371,8 +375,12 @@ static int fill_lgr_smcd_struct(struct smcd_diag_dmbinfo_v2 *lgr, struct nlattr
371375
nla_get_string(lgr_attrs[SMC_NLA_LGR_D_PNETID]));
372376
if (lgr_attrs[SMC_NLA_LGR_D_SNDBUF_ALLOC])
373377
lgr->sndbuf_alloc = nl_attr_get_uint(lgr_attrs[SMC_NLA_LGR_D_SNDBUF_ALLOC]);
378+
else
379+
lgr->sndbuf_alloc = SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT;
374380
if (lgr_attrs[SMC_NLA_LGR_D_DMB_ALLOC])
375381
lgr->dmb_alloc = nl_attr_get_uint(lgr_attrs[SMC_NLA_LGR_D_DMB_ALLOC]);
382+
else
383+
lgr->dmb_alloc = SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT;
376384
if (lgr_attrs[SMC_NLA_LGR_D_V2_COMMON]) {
377385
struct nlattr *v2_lgr_attrs[SMC_NLA_LGR_V2_MAX + 1];
378386

@@ -410,8 +418,10 @@ static void show_lgr_smcr_info_lgr_details(struct smc_diag_lgr *lgr)
410418
printf("EID : %s\n", lgr->v2_lgr_info.negotiated_eid);
411419
}
412420
printf("#Conns : %d\n", lgr->conns_num);
413-
printf("Sndbuf : %lld B\n", lgr->sndbuf_alloc);
414-
printf("RMB : %lld B\n", lgr->rmb_alloc);
421+
if (lgr->sndbuf_alloc != SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT)
422+
printf("Sndbuf : %lld B\n", lgr->sndbuf_alloc);
423+
if (lgr->rmb_alloc != SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT)
424+
printf("RMB : %lld B\n", lgr->rmb_alloc);
415425
}
416426

417427
static int show_lgr_smcr_info(struct nlattr **attr)
@@ -492,8 +502,10 @@ static void show_lgr_smcd_info_lgr_details(struct smcd_diag_dmbinfo_v2 *lgr)
492502
printf("EID : %s\n", lgr->v2_lgr_info.negotiated_eid);
493503
}
494504
printf("#Conns : %d\n", lgr->conns_num);
495-
printf("Sndbuf : %lld B\n", lgr->sndbuf_alloc);
496-
printf("DMB : %lld B\n", lgr->dmb_alloc);
505+
if (lgr->sndbuf_alloc != SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT)
506+
printf("Sndbuf : %lld B\n", lgr->sndbuf_alloc);
507+
if (lgr->dmb_alloc != SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT)
508+
printf("DMB : %lld B\n", lgr->dmb_alloc);
497509
}
498510

499511
static int show_lgr_smcd_info(struct nlattr **attr)

stats.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,10 @@ static void print_as_text()
399399
printf(" Data transmitted (Bytes) %14llu (%s)\n",
400400
smc_stat.smc[tech_type].rx_bytes, temp_str);
401401
printf(" Total requests %12llu\n", tech->rx_cnt);
402-
get_abbreviated(smc_stat.smc[tech_type].rx_rmbuse, 6, temp_str);
403-
printf(" Buffer usage (Bytes) %12llu (%s)\n", tech->rx_rmbuse, temp_str);
402+
if (smc_stat.smc[tech_type].rx_rmbuse != SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT) {
403+
get_abbreviated(smc_stat.smc[tech_type].rx_rmbuse, 6, temp_str);
404+
printf(" Buffer usage (Bytes) %12llu (%s)\n", tech->rx_rmbuse, temp_str);
405+
}
404406
printf(" Buffer full %12llu (%.2f%%)\n", tech->rmb_rx.buf_full_cnt,
405407
buf_rx_full);
406408
if (d_level) {
@@ -422,8 +424,10 @@ static void print_as_text()
422424
printf(" Data transmitted (Bytes) %14llu (%s)\n",
423425
smc_stat.smc[tech_type].tx_bytes, temp_str);
424426
printf(" Total requests %12llu\n", tech->tx_cnt);
425-
get_abbreviated(smc_stat.smc[tech_type].tx_rmbuse, 6, temp_str);
426-
printf(" Buffer usage (Bytes) %12llu (%s)\n", tech->tx_rmbuse, temp_str);
427+
if (smc_stat.smc[tech_type].tx_rmbuse != SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT) {
428+
get_abbreviated(smc_stat.smc[tech_type].tx_rmbuse, 6, temp_str);
429+
printf(" Buffer usage (Bytes) %12llu (%s)\n", tech->tx_rmbuse, temp_str);
430+
}
427431
printf(" Buffer full %12llu (%.2f%%)\n", tech->rmb_tx.buf_full_cnt,
428432
buf_full);
429433
printf(" Buffer full (remote) %12llu (%.2f%%)\n", tech->rmb_tx.buf_full_peer_cnt,
@@ -629,11 +633,13 @@ static int fill_tech_info(struct nlattr **attr, int type)
629633
if (tech_attrs[SMC_NLA_STATS_T_RX_RMB_USAGE]) {
630634
trgt = nl_attr_get_uint(tech_attrs[SMC_NLA_STATS_T_RX_RMB_USAGE]);
631635
smc_stat.smc[tech_type].rx_rmbuse = trgt;
632-
}
636+
} else
637+
smc_stat.smc[tech_type].rx_rmbuse = SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT;
633638
if (tech_attrs[SMC_NLA_STATS_T_TX_RMB_USAGE]) {
634639
trgt = nl_attr_get_uint(tech_attrs[SMC_NLA_STATS_T_TX_RMB_USAGE]);
635640
smc_stat.smc[tech_type].tx_rmbuse = trgt;
636-
}
641+
} else
642+
smc_stat.smc[tech_type].tx_rmbuse = SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT;
637643
if (tech_attrs[SMC_NLA_STATS_T_RX_CNT]) {
638644
trgt = nla_get_u64(tech_attrs[SMC_NLA_STATS_T_RX_CNT]);
639645
smc_stat.smc[tech_type].rx_cnt = trgt;

util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define SMC_OPTION_ABS -1
2222
#define SMC_OPTION_DETAIL_ABS -2
2323
#define SMC_TYPE_STR_MAX 5
24-
24+
#define SMC_BUFF_STATS_KERNEL_SUPPORT_ABSENT ((__u64) -1)
2525

2626
#define NEXT_ARG() do { argv++; argc--; } while(0)
2727
#define NEXT_ARG_OK() (argc - 1 > 0)

0 commit comments

Comments
 (0)