From 127cbd6d8694fa69b4a16214f8353ad56257535a Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Wed, 11 Jan 2023 19:34:26 +0100 Subject: [PATCH] client/server: add /proc/sys/mars/[cs]*_count --- kernel/mars_client.c | 8 ++++++++ kernel/mars_client.h | 3 +++ kernel/mars_server.c | 6 ++++++ kernel/mars_server.h | 1 + kernel/sy_old/mars_proc.c | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/kernel/mars_client.c b/kernel/mars_client.c index 23f5d277..1d9c90dd 100644 --- a/kernel/mars_client.c +++ b/kernel/mars_client.c @@ -34,6 +34,9 @@ #include "brick_wait.h" #include "mars.h" +atomic_t client_sender_count = ATOMIC_INIT(0); +atomic_t client_receiver_count = ATOMIC_INIT(0); + ///////////////////////// own type definitions //////////////////////// #include "mars_client.h" @@ -180,6 +183,7 @@ int _setup_channel(struct client_bundle *bundle, int ch_nr) goto done; } ch->is_used = true; + atomic_inc(&client_receiver_count); done: if (status < 0) { @@ -375,6 +379,8 @@ int _setup_bundle(struct client_bundle *bundle, const char *str) goto done; } + atomic_inc(&client_sender_count); + status = 0; done: @@ -741,6 +747,7 @@ int receiver_thread(void *data) mars_shutdown_socket(&ch->socket); atomic_dec(&brick->receiver_count); + atomic_dec(&client_receiver_count); mars_trigger(); return status; } @@ -1019,6 +1026,7 @@ static int sender_thread(void *data) brick_wake_smp(&output->bundle.sender_event); MARS_DBG("sender terminated\n"); atomic_dec(&brick->sender_count); + atomic_dec(&client_sender_count); return status; } diff --git a/kernel/mars_client.h b/kernel/mars_client.h index 2d0994ac..bed95862 100644 --- a/kernel/mars_client.h +++ b/kernel/mars_client.h @@ -34,6 +34,9 @@ extern int mars_client_abort; extern int max_client_channels; extern int max_client_bulk; +extern atomic_t client_sender_count; +extern atomic_t client_receiver_count; + #define MAX_CLIENT_CHANNELS 4 struct client_mref_aspect { diff --git a/kernel/mars_server.c b/kernel/mars_server.c index f056f617..cb42e907 100644 --- a/kernel/mars_server.c +++ b/kernel/mars_server.c @@ -65,6 +65,9 @@ static struct server_cookie server_cookie[MARS_TRAFFIC_MAX] = { static struct task_struct *server_thread[MARS_TRAFFIC_MAX] = {}; +atomic_t server_callback_count = ATOMIC_INIT(0); +EXPORT_SYMBOL_GPL(server_callback_count); + atomic_t server_handler_count = ATOMIC_INIT(0); EXPORT_SYMBOL_GPL(server_handler_count); @@ -107,6 +110,8 @@ int cb_thread(void *data) bool ok = mars_get_socket(sock); int status = -EINVAL; + atomic_inc(&server_callback_count); + MARS_DBG("--------------- cb_thread starting on socket #%d, ok = %d\n", sock->s_debug_nr, ok); if (!ok) goto done; @@ -230,6 +235,7 @@ int cb_thread(void *data) done: MARS_DBG("---------- cb_thread terminating, status = %d\n", status); brick_wake_smp(&brick->startup_event); + atomic_dec(&server_callback_count); return status; } diff --git a/kernel/mars_server.h b/kernel/mars_server.h index 916192f4..cc4ad8cb 100644 --- a/kernel/mars_server.h +++ b/kernel/mars_server.h @@ -36,6 +36,7 @@ extern int dent_limit; extern int dent_retry; extern int handler_limit; +extern atomic_t server_callback_count; extern atomic_t server_handler_count; struct server_mref_aspect { diff --git a/kernel/sy_old/mars_proc.c b/kernel/sy_old/mars_proc.c index 7746c54f..c1764e87 100644 --- a/kernel/sy_old/mars_proc.c +++ b/kernel/sy_old/mars_proc.c @@ -688,6 +688,10 @@ struct ctl_table mars_table[] = { INT_ENTRY("handler_dent_limit", dent_limit, 0600), INT_ENTRY("handler_dent_retry", dent_retry, 0600), INT_ENTRY("handler_limit", handler_limit, 0600), + INT_ENTRY("client_sender_count", client_sender_count, 0400), + INT_ENTRY("client_receiver_count", client_receiver_count, 0400), + INT_ENTRY("server_callback_count", server_callback_count, 0400), + INT_ENTRY("server_handler_count", server_handler_count, 0400), INT_ENTRY("mars_emergency_mode", mars_emergency_mode, 0600), INT_ENTRY("mars_reset_emergency", mars_reset_emergency, 0600), INT_ENTRY("mars_keep_msg_s", mars_keep_msg, 0600),