Skip to content

Commit 05f5b40

Browse files
committed
UCP/CORE: Optional warnings about unused config modifications.
1 parent 03245a7 commit 05f5b40

File tree

4 files changed

+49
-18
lines changed

4 files changed

+49
-18
lines changed

src/ucp/core/ucp_context.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,11 @@ static ucs_config_field_t ucp_context_config_table[] = {
592592
"resulting performance.",
593593
ucs_offsetof(ucp_context_config_t, node_local_id), UCS_CONFIG_TYPE_ULUNITS},
594594

595+
{UCP_WARN_UNUSED_CONFIG_MODIFICATIONS, "y",
596+
"Issue a warning about configuration modifications which were not applied.",
597+
ucs_offsetof(ucp_context_config_t, warn_unused_config_modifications),
598+
UCS_CONFIG_TYPE_BOOL},
599+
595600
{NULL}
596601
};
597602

src/ucp/core/ucp_context.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ typedef struct ucp_context_config {
221221
int proto_use_single_net_device;
222222
/** Local identificator on a single node */
223223
unsigned long node_local_id;
224+
/** Issue a warning in case of unused configuration modifications */
225+
int warn_unused_config_modifications;
224226
} ucp_context_config_t;
225227

226228

@@ -594,6 +596,9 @@ typedef struct ucp_tl_iface_atomic_flags {
594596
ucs_assert(ucp_memory_type_detect(_context, _buffer, _length) == (_mem_type))
595597

596598

599+
#define UCP_WARN_UNUSED_CONFIG_MODIFICATIONS "WARN_UNUSED_CONFIG_MODIFICATIONS"
600+
601+
597602
extern ucp_am_handler_t *ucp_am_handlers[];
598603
extern const char *ucp_feature_str[];
599604

src/ucp/core/ucp_worker.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,30 +2294,37 @@ ucs_thread_mode_t ucp_worker_get_thread_mode(uint64_t worker_flags)
22942294
return UCS_THREAD_MODE_SINGLE;
22952295
}
22962296

2297-
static void ucp_warn_unused_uct_config(ucp_context_h context)
2297+
static void ucp_warn_unused_config_modifications(const ucp_context_h context)
22982298
{
2299-
unsigned num_unused_cached_kv = 0;
2300-
ucs_string_buffer_t unused_cached_uct_cfg;
2301-
ucs_config_cached_key_t *key_val;
2299+
const ucs_config_cached_key_t *key;
2300+
ucs_string_buffer_t unused_modifications;
2301+
unsigned num_unused_modifications;
23022302

2303-
ucs_string_buffer_init(&unused_cached_uct_cfg);
2303+
if (!context->config.ext.warn_unused_config_modifications) {
2304+
return;
2305+
}
2306+
2307+
ucs_string_buffer_init(&unused_modifications);
2308+
num_unused_modifications = 0;
23042309

2305-
ucs_list_for_each(key_val, &context->cached_key_list, list) {
2306-
if (!key_val->used) {
2307-
ucs_string_buffer_appendf(&unused_cached_uct_cfg, "%s=%s,",
2308-
key_val->key, key_val->value);
2309-
++num_unused_cached_kv;
2310+
ucs_list_for_each(key, &context->cached_key_list, list) {
2311+
if (!key->used) {
2312+
ucs_string_buffer_appendf(&unused_modifications, "%s=%s,", key->key,
2313+
key->value);
2314+
++num_unused_modifications;
23102315
}
23112316
}
23122317

2313-
if (num_unused_cached_kv > 0) {
2314-
ucs_string_buffer_rtrim(&unused_cached_uct_cfg , ",");
2315-
ucs_warn("invalid configuration%s: %s",
2316-
(num_unused_cached_kv > 1) ? "s" : "",
2317-
ucs_string_buffer_cstr(&unused_cached_uct_cfg));
2318+
if (num_unused_modifications > 0) {
2319+
ucs_string_buffer_rtrim(&unused_modifications , ",");
2320+
ucs_warn("unused configuration%s: %s\n"
2321+
"(set %s%s=n to suppress this warning)",
2322+
(num_unused_modifications > 1) ? "s" : "",
2323+
ucs_string_buffer_cstr(&unused_modifications),
2324+
UCS_DEFAULT_ENV_PREFIX, UCP_WARN_UNUSED_CONFIG_MODIFICATIONS);
23182325
}
23192326

2320-
ucs_string_buffer_cleanup(&unused_cached_uct_cfg);
2327+
ucs_string_buffer_cleanup(&unused_modifications);
23212328
}
23222329

23232330
static void
@@ -2677,8 +2684,7 @@ ucs_status_t ucp_worker_create(ucp_context_h context,
26772684
*/
26782685
ucs_config_parser_print_env_vars_once(context->config.env_prefix);
26792686

2680-
/* Warn unused cached uct configuration */
2681-
ucp_warn_unused_uct_config(context);
2687+
ucp_warn_unused_config_modifications(context);
26822688

26832689
ucp_worker_set_max_am_header(worker);
26842690

test/gtest/ucp/test_ucp_worker.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,3 +1008,18 @@ UCS_TEST_P(test_worker_cpu_mask, all_cpus)
10081008
}
10091009

10101010
UCP_INSTANTIATE_TEST_CASE_TLS(test_worker_cpu_mask, all, "all")
1011+
1012+
class test_unused_config_modifications : public test_ucp_context {
1013+
public:
1014+
test_unused_config_modifications()
1015+
{
1016+
ucp_config_modify(m_ucp_config, "QWERTY", "QWERTY");
1017+
ucp_config_modify(m_ucp_config, "WARN_UNUSED_CONFIG_MODIFICATIONS",
1018+
"n");
1019+
}
1020+
};
1021+
1022+
UCS_TEST_P(test_unused_config_modifications, hidden_warning)
1023+
{}
1024+
1025+
UCP_INSTANTIATE_TEST_CASE_TLS(test_unused_config_modifications, self, "self")

0 commit comments

Comments
 (0)