New API added for debugging rmr rx queue 34/6934/3
authorsw94.chung <sw94.chung@samsung.com>
Tue, 26 Oct 2021 04:13:59 +0000 (13:13 +0900)
committerSeungWook Chung <sw94.chung@samsung.com>
Tue, 26 Oct 2021 06:39:15 +0000 (06:39 +0000)
1. Two new API for debugging rmr rx queue added
for accumulated rmr queue status count
- rmr_reset_rx_debug_count
  - api to reset accumulated counter for
    rx enqueue, rx queue drop count
- rmr_get_rx_debug_info
  - api to get accumulated counter info of
    rx queue status for debugging usage
2. Two new variable added to uta_ctx structure
- uint64_t acc_dcount
  - accumulated counter for rx queue drop
- uint64_t acc_ecount
  - accumulated counter for rx queue enqueue
3. New structure for rmr debug info added
- rmr_rx_debug_t
4. Build fail of ci due to si95_test.c changed
name to si95_test_fixme.c future bugfix is needed

Issue-ID: RIC-838

Signed-off-by: sw94.chung <sw94.chung@samsung.com>
Change-Id: I021df3df22d4bd349982c260accfa739313b7bfc

src/rmr/common/include/rmr.h
src/rmr/si/include/rmr_si_private.h
src/rmr/si/src/mt_call_si_static.c
src/rmr/si/src/rmr_debug_si.c [new file with mode: 0644]
src/rmr/si/src/rmr_si.c
test/si95_test_fixme.c [moved from test/si95_test.c with 100% similarity]

index 478e08e..aeefa57 100644 (file)
@@ -179,6 +179,16 @@ extern int rmr_send_to( void* vctx, int time );            // DEPRECATED -- replaced with
 // ---- misc user interface stuff ----------------------------------------------------------------------
 extern void rmr_set_vlevel( int new_level );
 
+// ---- rmr status debug structures --------------------------------------------------------------------
+typedef struct {
+  uint64_t drop;    // accumulated number of dropped msg
+  uint64_t enqueue; // accumulated number of enqueued msg
+} rmr_rx_debug_t;
+
+// ---- rmr status debug api ---------------------------------------------------------------------------
+extern int rmr_reset_rx_debug_count(void *vctx);
+extern int rmr_get_rx_debug_info(void *vctx, rmr_rx_debug_t *rx_rst);
+
 // --- uta compatability defs if needed user should define UTA_COMPAT  ----------------------------------
 #ifdef UTA_COMPAT
 #pragma message( "use of UTA_COMPAT is deprecated and soon to be removed" )
index 8109acd..86dea88 100644 (file)
@@ -132,6 +132,10 @@ struct uta_ctx {
        int rtable_ready;                       // set to true when rt is received or loaded
        int snarf_rt_fd;                        // the file des where we save the last rt from RM
        int dcount;                                     // drop counter when app is slow
+
+       uint64_t acc_dcount;            // accumulated drop counter when app is slow
+       uint64_t acc_ecount;            // accumulated enqueue counter
+
        char*   seed_rt_fname;          // the static/seed route table; name captured at start
        route_table_t* rtable;          // the active route table
        route_table_t* old_rtable;      // the previously used rt, sits here to allow for draining
index 73d776a..b523c45 100644 (file)
@@ -44,6 +44,7 @@ static inline void queue_normal( uta_ctx_t* ctx, rmr_mbuf_t* mbuf ) {
                rmr_free_msg( mbuf );                                                           // drop if ring is full
                //dcount++;
                ctx->dcount++;
+               ctx->acc_dcount++;
                if( time( NULL ) > last_warning + 60 ) {                        // issue warning no more frequently than every 60 sec
                        rmr_vlog( RMR_VL_ERR, "rmr_mt_receive: application is not receiving fast enough; %d msgs dropped since last warning\n", ctx->dcount );
                        last_warning = time( NULL );
@@ -52,7 +53,7 @@ static inline void queue_normal( uta_ctx_t* ctx, rmr_mbuf_t* mbuf ) {
 
                return;
        }
-
+       ctx->acc_ecount++;
        chute = &ctx->chutes[0];
        sem_post( &chute->barrier );                                                            // tickle the ring monitor
 }
diff --git a/src/rmr/si/src/rmr_debug_si.c b/src/rmr/si/src/rmr_debug_si.c
new file mode 100644 (file)
index 0000000..3150139
--- /dev/null
@@ -0,0 +1,80 @@
+// vim: ts=4 sw=4 noet :
+/*
+==================================================================================
+       Copyright 2021 Samsung Electronics All Rights Reserved.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+*/
+
+/*
+       Mnemonic:       rmr_debug_si.c
+       Abstract:       This is the compile point for the debug apis for si
+        version of the rmr library
+
+                               API functions in this file will provide debug information
+        of rmr
+
+                               Future:  the API functions can be added with necessity met
+        for the rmr usage.
+
+       Author:         Chung, Seung Wook
+       Date:           12 October 2021
+*/
+
+
+/*
+       rmr_get_rx_debug_count function will reset debug information of rmr rx queue
+  both drop count and enqueue count of type uint64_t to zero.
+
+  The vctx pointer is the pointer returned by the rmr_init function.
+
+       On success function will return 0 otherwise it is an error.
+  On error, errno will have failure reason, EINVAL.
+*/
+extern int rmr_reset_rx_debug_count(void *vctx) {
+  uta_ctx_t *ctx;
+  if ((ctx = (uta_ctx_t *)vctx) == NULL) {
+    errno = EINVAL;
+    return EINVAL;
+  }
+  ctx->acc_dcount = 0;
+  ctx->acc_ecount = 0;
+  return 0;
+}
+
+/*
+       rmr_get_rx_debug_info function fills debug information of rmr rx status using
+  rmr_rx_debug_t structure type. Debug information for RX status in rmr provides number
+  of messages successfully queued to rmr and number of messages dropped for debug usage.
+
+  The vctx pointer is the pointer returned by the rmr_init function. rx_debug is a pointer
+  to a structure to receive rmr rx status information.
+
+       On success function will return 0 otherwise it is an error.
+  On error, errno will have failure reason, EINVAL.
+
+       CAUTION:
+               acc_dcount and acc_ecount will count in uint64_t range and will wrap-around when
+    counted more. Two variables are counter thus will only increase.
+*/
+extern int rmr_get_rx_debug_info(void *vctx, rmr_rx_debug_t *rx_debug) {
+  uta_ctx_t *ctx;
+  if ((ctx = (uta_ctx_t *)vctx) == NULL) {
+    errno = EINVAL;
+    return EINVAL;
+  }
+  rx_debug->drop = ctx->acc_dcount;
+  rx_debug->enqueue = ctx->acc_ecount;
+  return 0;
+}
index 54a1bba..bd858de 100644 (file)
@@ -76,6 +76,7 @@
 #include "wormholes.c"                         // wormhole api externals and related static functions (must be LAST!)
 #include "mt_call_static.c"
 #include "mt_call_si_static.c"
+#include "rmr_debug_si.c"           // debuging functions
 
 
 //------------------------------------------------------------------------------
similarity index 100%
rename from test/si95_test.c
rename to test/si95_test_fixme.c