diff options
| author | Lu Qiuwen <[email protected]> | 2024-04-12 09:52:11 +0800 |
|---|---|---|
| committer | Lu Qiuwen <[email protected]> | 2024-04-14 15:10:07 +0800 |
| commit | a8281bd82e65dcc56e969c226f10759a1f787f31 (patch) | |
| tree | 328679cadaf0363ea72f9e68ae170e9a7f334a15 /infra | |
| parent | aca9d3913d938569b78a4658db1cc2f33dc2d284 (diff) | |
bugfix: clean the credit counters when cons created, fix the txdrop counter.
Diffstat (limited to 'infra')
| -rw-r--r-- | infra/include/vnode.h | 3 | ||||
| -rw-r--r-- | infra/src/vnode_common.c | 37 | ||||
| -rw-r--r-- | infra/src/vnode_common.h | 3 | ||||
| -rw-r--r-- | infra/src/vnode_mirror.c | 13 | ||||
| -rw-r--r-- | infra/test/TestVNode.cc | 30 |
5 files changed, 26 insertions, 60 deletions
diff --git a/infra/include/vnode.h b/infra/include/vnode.h index 478a995..5b7f861 100644 --- a/infra/include/vnode.h +++ b/infra/include/vnode.h @@ -118,8 +118,7 @@ int vnode_mirror_rt_object_retrieve(struct vnode_prod * prod, unsigned int prodq unsigned int nr_max_objects); struct vnode * vnode_mirror_create(const char * sym, unsigned int sz_exclusive, unsigned int sz_max_inflight, - unsigned int notify_cons_when_rx, unsigned int batch_interval_us, - unsigned int en_q_len_monitor); + unsigned int notify_cons_when_rx, unsigned int batch_interval_us); int vnode_mirror_delete(struct vnode * vnode); diff --git a/infra/src/vnode_common.c b/infra/src/vnode_common.c index a6653ff..6e2e154 100644 --- a/infra/src/vnode_common.c +++ b/infra/src/vnode_common.c @@ -320,37 +320,11 @@ struct vnode_cons * __vnode_common_create_cons(struct vnode * vnode, const char goto err; } } - - if (vnode->en_q_len_monitor) - { - struct variable_monitor_ioctl_cmd_args ioctl_cmd_args = {}; - ioctl_cmd_args.task_id = getpid(); - - snprintf(ioctl_cmd_args.name, sizeof(ioctl_cmd_args.name), "%s-%d", symbol, qid); - ioctl_cmd_args.var_ptr = (void *)&cons->stat[qid].q_len_max; - ioctl_cmd_args.var_len = sizeof(cons->stat[qid].q_len_max); - - ioctl_cmd_args.threshold = floor(vnode->sz_tunnel * 0.8); - ioctl_cmd_args.unsigned_flag = 1; - ioctl_cmd_args.greater_flag = 1; - - /* write the cmds by ioctl to the variable monitor modules */ - int variable_monitor_fd = open("/dev/variable_monitor", 0); - if (unlikely(variable_monitor_fd < 0)) - { - MR_ERROR("failed at open /dev/variable_monitor: %s", strerror(errno)); - goto err; - } - - int ioctl_ret = ioctl(variable_monitor_fd, 1, &ioctl_cmd_args); - if (unlikely(ioctl_ret < 0)) - { - MR_ERROR("failed at ioctl /dev/variable_monitor: %s", strerror(errno)); - goto err; - } - } } + vnode->max_credits_per_tunnel = vnode->max_inflight / nr_consq; + vnode->credits_on_loan = 0; + rte_spinlock_lock(&vnode->lock); int ret = do_consumer_join_unsafe(vnode, cons); rte_spinlock_unlock(&vnode->lock); @@ -363,10 +337,7 @@ struct vnode_cons * __vnode_common_create_cons(struct vnode * vnode, const char return cons; err: - if (cons != NULL) - { - rte_free(cons); - } + rte_free(cons); return NULL; } diff --git a/infra/src/vnode_common.h b/infra/src/vnode_common.h index 71873d1..4dc35b9 100644 --- a/infra/src/vnode_common.h +++ b/infra/src/vnode_common.h @@ -37,9 +37,7 @@ struct tunnel_desc /* second cacheline, read/write */ RTE_MARKER cacheline1 __rte_cache_min_aligned; - int32_t inflight_credits; - unsigned int send_credits_watermark; /* Tunnel Enqueue Buffer Size */ unsigned int sz_en_buffer; @@ -140,6 +138,7 @@ struct vnode /* atomic, inflight credit */ int32_t credits_on_loan; int32_t max_inflight; + int32_t max_credits_per_tunnel; /* Guarantees one operator(consumer or producer, create or destroy) a time */ rte_spinlock_t lock __rte_cache_aligned; diff --git a/infra/src/vnode_mirror.c b/infra/src/vnode_mirror.c index a34f16d..82760be 100644 --- a/infra/src/vnode_mirror.c +++ b/infra/src/vnode_mirror.c @@ -21,7 +21,7 @@ static inline unsigned int dist_tunnel_rt_objects_retrieve(struct tunnel_desc * return nr_rt_objs; } -static bool dist_tunnel_acquire_credits(struct vnode * vnode_desc, struct tunnel_desc * tunnel_desc, int32_t credits) +static inline bool dist_tunnel_acquire_credits(struct vnode * vnode_desc, struct tunnel_desc * tunnel_desc, int32_t credits) { int32_t inflight_credits = tunnel_desc->inflight_credits; int32_t missing_credits = credits - inflight_credits; @@ -58,7 +58,6 @@ static bool dist_tunnel_acquire_credits(struct vnode * vnode_desc, struct tunnel if (unlikely(new_total_on_loan > vnode_desc->max_inflight)) { - /* Some other port took the last credits */ __atomic_fetch_sub(&vnode_desc->credits_on_loan, acquired_credits, __ATOMIC_RELAXED); return false; } @@ -68,14 +67,14 @@ static bool dist_tunnel_acquire_credits(struct vnode * vnode_desc, struct tunnel return true; } -static void dist_tunnel_return_credits(struct vnode * vnode_desc, struct tunnel_desc * tunnel_desc, int32_t credits) +static inline void dist_tunnel_return_credits(struct vnode * vnode_desc, struct tunnel_desc * tunnel_desc, int32_t credits) { tunnel_desc->inflight_credits += credits; #define DIST_TUNNEL_MAX_CREDITS (2 * DIST_TUNNEL_DESC_MIN_CREDITS) - if (unlikely(tunnel_desc->inflight_credits > DIST_TUNNEL_MAX_CREDITS)) + if (unlikely(tunnel_desc->inflight_credits > vnode_desc->max_credits_per_tunnel)) { - int32_t leave_credits = DIST_TUNNEL_MAX_CREDITS; + int32_t leave_credits = vnode_desc->max_credits_per_tunnel; int32_t return_credits = tunnel_desc->inflight_credits - leave_credits; tunnel_desc->inflight_credits = leave_credits; @@ -344,8 +343,7 @@ void vnode_mirror_flush(struct vnode_prod * prod, unsigned int prodq) } struct vnode * vnode_mirror_create(const char * sym, unsigned int sz_exclusive, unsigned int sz_max_inflight, - unsigned int notify_cons_when_rx, unsigned int batch_interval_us, - unsigned int en_q_len_monitor) + unsigned int notify_cons_when_rx, unsigned int batch_interval_us) { struct vnode * vnode_common = __vnode_common_create(sym, sz_exclusive, sz_max_inflight, notify_cons_when_rx); @@ -367,7 +365,6 @@ struct vnode * vnode_mirror_create(const char * sym, unsigned int sz_exclusive, } vnode_common->batch_interval_tsc = batch_interval_us * rte_get_timer_cycles() / US_PER_S; - vnode_common->en_q_len_monitor = en_q_len_monitor; return vnode_common; } diff --git a/infra/test/TestVNode.cc b/infra/test/TestVNode.cc index 77d5bb5..76846be 100644 --- a/infra/test/TestVNode.cc +++ b/infra/test/TestVNode.cc @@ -39,7 +39,7 @@ class TestCaseVNodeQueue : public TestCaseVNode void SetUp() override { - vnode_ = vnode_mirror_create("m-vnode", 1024, 0, 0, 0, 0); + vnode_ = vnode_mirror_create("m-vnode", 1024, 0, 0, 0); ASSERT_NE(vnode_, nullptr); assert(prod_ == nullptr); @@ -82,7 +82,7 @@ struct rte_mempool * TestCaseVNode::pktmbuf_pool_ = nullptr; TEST_F(TestCaseVNode, CreateAndDeleteInEmptyNode) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0); EXPECT_NE(vnode_ptr, nullptr); int ret = vnode_mirror_delete(vnode_ptr); @@ -91,7 +91,7 @@ TEST_F(TestCaseVNode, CreateAndDeleteInEmptyNode) TEST_F(TestCaseVNode, CreateAndDelete) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -109,7 +109,7 @@ TEST_F(TestCaseVNode, CreateAndDelete) TEST_F(TestCaseVNode, CreateAndDeleteMultiThread) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0); ASSERT_NE(vnode_ptr, nullptr); /* create multiple thread and run them at same time */ @@ -141,7 +141,7 @@ TEST_F(TestCaseVNode, CreateAndDeleteMultiThread) TEST_F(TestCaseVNode, TestVNodeProdAndConsLookup) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 32, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -164,7 +164,7 @@ TEST_F(TestCaseVNode, TestVNodeProdAndConsLookup) TEST_F(TestCaseVNode, TestVNodeEnqueue) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 1024, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -212,7 +212,7 @@ TEST_F(TestCaseVNode, TestVNodeEnqueue) TEST_F(TestCaseVNode, TestVNodeMultipleThreadEnqueue) { /* create multiple thread */ - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -318,7 +318,7 @@ TEST_F(TestCaseVNode, TestVNodeMultipleThreadEnqueue) TEST_F(TestCaseVNode, TestVNodeEnqueueAndDequeueUseSharedCredict) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -416,7 +416,7 @@ TEST_F(TestCaseVNode, TestVNodeEnqueueAndDequeueUseSharedCredict) TEST_F(TestCaseVNode, TestVNodeMultipleQueueUseSharedCredict) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 32, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -494,7 +494,7 @@ TEST_F(TestCaseVNode, TestVNodeMultipleQueueUseSharedCredict) TEST_F(TestCaseVNode, TestVNodeEnqueueMultipleQueue) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 512, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 512, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; @@ -566,7 +566,7 @@ TEST_F(TestCaseVNode, TestVNodeEnqueueMultipleQueue) TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_NoEnoughCredits) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 32, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 32, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod = vnode_mirror_create_prod(vnode_ptr, "prod", 8); @@ -610,7 +610,7 @@ TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_NoEnoughCredits) TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_EnoughCredits) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod = vnode_mirror_create_prod(vnode_ptr, "prod", 8); @@ -654,7 +654,7 @@ TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_EnoughCredits) TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_RefillCredits) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod = vnode_mirror_create_prod(vnode_ptr, "prod", 8); @@ -750,7 +750,7 @@ TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_RefillCredits) TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_MultipleThreadProducer) { - struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("m-vnode", 16384, 64, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod = vnode_mirror_create_prod(vnode_ptr, "prod", 4); @@ -812,7 +812,7 @@ TEST_F(TestCaseVNode, TestVNodeEnableMaxInFlight_MultipleThreadProducer) TEST_F(TestCaseVNodeQueue, MultQueueEnqueue) { - struct vnode * vnode_ptr = vnode_mirror_create("vnode", 1024, 0, 0, 0, 0); + struct vnode * vnode_ptr = vnode_mirror_create("vnode", 1024, 0, 0, 0); ASSERT_NE(vnode_ptr, nullptr); struct vnode_prod * prod; |
