@@ -64,6 +64,7 @@ struct ucp_proto_perf_node {
6464
6565/* Protocol information table */
6666typedef struct {
67+ char counter_str [32 ];
6768 char range_str [32 ];
6869 char desc [UCP_PROTO_DESC_STR_MAX ];
6970 char config [UCP_PROTO_CONFIG_STR_MAX ];
@@ -156,16 +157,22 @@ static void ucp_proto_table_row_separator(ucs_string_buffer_t *strb,
156157}
157158
158159static int ucp_proto_debug_is_info_enabled (ucp_context_h context ,
159- const char * select_param_str )
160+ const char * select_param_str ,
161+ int show_used )
160162{
161163 const char * proto_info_config = context -> config .ext .proto_info ;
162164 int bool_value ;
163165
166+ /* Handle "used" */
167+ if (show_used ) {
168+ return context -> config .trace_used_proto_selections ;
169+ }
170+
164171 /* Handle "auto" - enable when log level is DEBUG or higher */
165172 if (!strcasecmp (proto_info_config , "auto" )) {
166173 return ucs_log_is_enabled (UCS_LOG_LEVEL_DEBUG );
167174 }
168-
175+
169176 /* Handle boolean */
170177 if (ucs_config_sscanf_bool (proto_info_config , & bool_value , NULL )) {
171178 return bool_value ;
@@ -175,29 +182,67 @@ static int ucp_proto_debug_is_info_enabled(ucp_context_h context,
175182 return fnmatch (proto_info_config , select_param_str , FNM_CASEFOLD ) == 0 ;
176183}
177184
178- void ucp_proto_select_elem_info (ucp_worker_h worker ,
179- ucp_worker_cfg_index_t ep_cfg_index ,
180- ucp_worker_cfg_index_t rkey_cfg_index ,
181- const ucp_proto_select_param_t * select_param ,
182- const ucp_proto_select_elem_t * select_elem ,
183- int show_all , ucs_string_buffer_t * strb )
185+ static inline int
186+ ucp_proto_select_elem_has_selections (const ucp_proto_select_elem_t * select_elem )
187+ {
188+ const ucp_proto_threshold_elem_t * thresh_elem = select_elem -> thresholds ;
189+
190+ do {
191+ if (thresh_elem -> proto_config .selections > 0 ) {
192+ return 1 ;
193+ }
194+ } while ((thresh_elem ++ )-> max_msg_length < SIZE_MAX );
195+
196+ return 0 ;
197+ }
198+
199+ static void
200+ ucp_proto_selections_dump (const ucp_proto_query_attr_t * proto_attr ,
201+ char * counter_str , size_t size , int show_used )
202+ {
203+ unsigned max_selections ;
204+
205+ if (!show_used ) {
206+ * counter_str = '\0' ;
207+ return ;
208+ }
209+
210+ max_selections = (strstr (proto_attr -> desc , "short" ) != NULL ) ?
211+ 1 : UCP_PROTO_SELECTIONS_COUNT_MAX ;
212+
213+ ucs_snprintf_safe (counter_str , size , "%u%s " , proto_attr -> selections ,
214+ (proto_attr -> selections >= max_selections ? "+" : "" ));
215+ }
216+
217+ void
218+ ucp_proto_select_elem_info (ucp_worker_h worker ,
219+ ucp_worker_cfg_index_t ep_cfg_index ,
220+ ucp_worker_cfg_index_t rkey_cfg_index ,
221+ const ucp_proto_select_param_t * select_param ,
222+ const ucp_proto_select_elem_t * select_elem ,
223+ int show_all , int show_used , ucs_string_buffer_t * strb )
184224{
185225 UCS_STRING_BUFFER_ONSTACK (ep_cfg_strb , UCP_PROTO_CONFIG_STR_MAX );
186226 UCS_STRING_BUFFER_ONSTACK (sel_param_strb , UCP_PROTO_CONFIG_STR_MAX );
187- static const char * info_row_fmt = "| %*s | %-*s | %-*s |\n" ;
227+ static const char * info_row_fmt = "| %s% *s | %-*s | %-*s |\n" ;
188228 ucp_proto_info_table_t table ;
189229 int hdr_col_width [2 ], col_width [3 ];
190230 ucp_proto_query_attr_t proto_attr ;
191231 ucp_proto_info_row_t * row_elem ;
192232 size_t range_start , range_end ;
193233 int proto_valid ;
194234
235+ if (show_used && !ucp_proto_select_elem_has_selections (select_elem )) {
236+ return ;
237+ }
238+
195239 ucp_proto_select_param_dump (worker , ep_cfg_index , rkey_cfg_index ,
196240 select_param , ucp_operation_descs , & ep_cfg_strb ,
197241 & sel_param_strb );
198242 if (!show_all &&
199243 !ucp_proto_debug_is_info_enabled (
200- worker -> context , ucs_string_buffer_cstr (& sel_param_strb ))) {
244+ worker -> context , ucs_string_buffer_cstr (& sel_param_strb ),
245+ show_used )) {
201246 return ;
202247 }
203248
@@ -228,7 +273,11 @@ void ucp_proto_select_elem_info(ucp_worker_h worker,
228273 ucs_memunits_range_str (range_start , range_end , row_elem -> range_str ,
229274 sizeof (row_elem -> range_str ));
230275
231- col_width [0 ] = ucs_max (col_width [0 ], strlen (row_elem -> range_str ));
276+ ucp_proto_selections_dump (& proto_attr , row_elem -> counter_str ,
277+ sizeof (row_elem -> counter_str ), show_used );
278+
279+ col_width [0 ] = ucs_max (col_width [0 ], strlen (row_elem -> counter_str ) +
280+ strlen (row_elem -> range_str ));
232281 col_width [1 ] = ucs_max (col_width [1 ], strlen (row_elem -> desc ));
233282 col_width [2 ] = ucs_max (col_width [2 ], strlen (row_elem -> config ));
234283 } while (range_end != SIZE_MAX );
@@ -250,7 +299,8 @@ void ucp_proto_select_elem_info(ucp_worker_h worker,
250299 /* Print contents */
251300 ucp_proto_table_row_separator (strb , col_width , 3 );
252301 ucs_array_for_each (row_elem , & table ) {
253- ucs_string_buffer_appendf (strb , info_row_fmt , col_width [0 ],
302+ ucs_string_buffer_appendf (strb , info_row_fmt , row_elem -> counter_str ,
303+ col_width [0 ] - strlen (row_elem -> counter_str ),
254304 row_elem -> range_str , col_width [1 ],
255305 row_elem -> desc , col_width [2 ],
256306 row_elem -> config );
@@ -271,7 +321,7 @@ void ucp_proto_select_info(ucp_worker_h worker,
271321
272322 kh_foreach (proto_select -> hash , key .u64 , select_elem ,
273323 ucp_proto_select_elem_info (worker , ep_cfg_index , rkey_cfg_index ,
274- & key .param , & select_elem , show_all ,
324+ & key .param , & select_elem , show_all , 0 ,
275325 strb );
276326 ucs_string_buffer_appendf (strb , "\n" ))
277327}
@@ -973,7 +1023,7 @@ ucp_proto_select_write_info(ucp_worker_h worker,
9731023 ucp_operation_names , & ep_cfg_strb ,
9741024 & sel_param_strb );
9751025 if (!ucp_proto_debug_is_info_enabled (
976- worker -> context , ucs_string_buffer_cstr (& sel_param_strb ))) {
1026+ worker -> context , ucs_string_buffer_cstr (& sel_param_strb ), 0 )) {
9771027 goto out ;
9781028 }
9791029
@@ -1038,17 +1088,19 @@ ucp_proto_select_write_info(ucp_worker_h worker,
10381088}
10391089
10401090void ucp_proto_select_elem_trace (ucp_worker_h worker ,
1041- ucp_worker_cfg_index_t ep_cfg_index ,
1042- ucp_worker_cfg_index_t rkey_cfg_index ,
10431091 const ucp_proto_select_param_t * select_param ,
1044- ucp_proto_select_elem_t * select_elem )
1092+ const ucp_proto_select_elem_t * select_elem ,
1093+ int show_used )
10451094{
1046- ucs_string_buffer_t strb = UCS_STRING_BUFFER_INITIALIZER ;
1095+ const ucp_proto_config_t * proto_config = & select_elem -> thresholds [0 ].proto_config ;
1096+ ucp_worker_cfg_index_t ep_cfg_index = proto_config -> ep_cfg_index ;
1097+ ucp_worker_cfg_index_t rkey_cfg_index = proto_config -> rkey_cfg_index ;
1098+ ucs_string_buffer_t strb = UCS_STRING_BUFFER_INITIALIZER ;
10471099 char * line ;
10481100
10491101 /* Print human-readable protocol selection table to the log */
10501102 ucp_proto_select_elem_info (worker , ep_cfg_index , rkey_cfg_index ,
1051- select_param , select_elem , 0 , & strb );
1103+ select_param , select_elem , 0 , show_used , & strb );
10521104 ucs_string_buffer_for_each_token (line , & strb , "\n" ) {
10531105 ucs_log_print_compact (line );
10541106 }
0 commit comments