From 7db95a6a92973ccb2460e0c6a035311f23a6e5ef Mon Sep 17 00:00:00 2001 From: Qizhen Zhang Date: Mon, 11 Dec 2023 19:38:09 -0800 Subject: [PATCH] Graceful exit --- .../RingBuffer/DPU/Source/RequestBackEnd.c | 6 ++--- .../RingBuffer/DPU/Source/ResponseBackEnd.c | 6 ++--- DPDPU/Common/Include/DPU/BackEndControl.h | 4 ++++ DPDPU/Common/Include/DPU/FileService.h | 3 +-- DPDPU/Common/Source/DPU/FileService.c | 4 ++-- DPDPU/NetworkEngine/Include/PEPOTLDKTCP.h | 7 ------ DPDPU/NetworkEngine/Source/DDSBOWPipeline.c | 24 ------------------- DPDPU/NetworkEngine/Source/PEPOLinuxTCP.c | 2 +- DPDPU/NetworkEngine/Source/PEPOTLDKTCP.c | 20 ++++------------ .../DDSBackEndDPUService/Include/DPUBackEnd.h | 2 +- .../DDSBackEndDPUService/Source/FileBackEnd.c | 8 +++---- .../DDSBackEndDPUService/Source/bdev.c | 3 ++- 12 files changed, 25 insertions(+), 64 deletions(-) create mode 100644 DPDPU/Common/Include/DPU/BackEndControl.h diff --git a/DPDPU/Benchmarks/RingBuffer/DPU/Source/RequestBackEnd.c b/DPDPU/Benchmarks/RingBuffer/DPU/Source/RequestBackEnd.c index 78c983b..b630406 100644 --- a/DPDPU/Benchmarks/RingBuffer/DPU/Source/RequestBackEnd.c +++ b/DPDPU/Benchmarks/RingBuffer/DPU/Source/RequestBackEnd.c @@ -17,7 +17,7 @@ #define TRUE 1 #define FALSE 0 -static volatile int ForceQuitFileBackEnd = 0; +static volatile int ForceQuitStorageEngine = 0; // // Set a CM channel to be non-blocking @@ -176,7 +176,7 @@ SignalHandler( ) { if (SigNum == SIGINT || SigNum == SIGTERM) { fprintf(stdout, "Received signal to exit\n"); - ForceQuitFileBackEnd = 1; + ForceQuitStorageEngine = 1; } } @@ -2261,7 +2261,7 @@ int RunBenchmarkRequestBackEnd( signal(SIGINT, SignalHandler); signal(SIGTERM, SignalHandler); - while (ForceQuitFileBackEnd == 0) { + while (ForceQuitStorageEngine == 0) { // // Process connection events // diff --git a/DPDPU/Benchmarks/RingBuffer/DPU/Source/ResponseBackEnd.c b/DPDPU/Benchmarks/RingBuffer/DPU/Source/ResponseBackEnd.c index d3e150c..49fb6eb 100644 --- a/DPDPU/Benchmarks/RingBuffer/DPU/Source/ResponseBackEnd.c +++ b/DPDPU/Benchmarks/RingBuffer/DPU/Source/ResponseBackEnd.c @@ -25,7 +25,7 @@ #define TOTAL_RESPONSES 100000 #endif -static volatile int ForceQuitFileBackEnd = 0; +static volatile int ForceQuitStorageEngine = 0; static struct Profiler Prof; struct Response { @@ -197,7 +197,7 @@ SignalHandler( ) { if (SigNum == SIGINT || SigNum == SIGTERM) { fprintf(stdout, "Received signal to exit\n"); - ForceQuitFileBackEnd = 1; + ForceQuitStorageEngine = 1; } } @@ -1646,7 +1646,7 @@ int RunBenchmarkResponseBackEnd( signal(SIGINT, SignalHandler); signal(SIGTERM, SignalHandler); - while (ForceQuitFileBackEnd == 0) { + while (ForceQuitStorageEngine == 0) { // // Process connection events // diff --git a/DPDPU/Common/Include/DPU/BackEndControl.h b/DPDPU/Common/Include/DPU/BackEndControl.h new file mode 100644 index 0000000..3d2faab --- /dev/null +++ b/DPDPU/Common/Include/DPU/BackEndControl.h @@ -0,0 +1,4 @@ +#pragma once + +extern volatile int ForceQuitStorageEngine; +extern volatile int ForceQuitNetworkEngine; \ No newline at end of file diff --git a/DPDPU/Common/Include/DPU/FileService.h b/DPDPU/Common/Include/DPU/FileService.h index c36b995..104a7bf 100644 --- a/DPDPU/Common/Include/DPU/FileService.h +++ b/DPDPU/Common/Include/DPU/FileService.h @@ -1,13 +1,12 @@ #pragma once +#include "BackEndControl.h" #include "BackEndTypes.h" #include "Zmalloc.h" #include "DataPlaneHandlers.h" #define WORKER_THREAD_COUNT 1 -extern volatile int ForceQuitFileBackEnd; - // // File service running on the DPU // diff --git a/DPDPU/Common/Source/DPU/FileService.c b/DPDPU/Common/Source/DPU/FileService.c index 62fc6d2..9413787 100644 --- a/DPDPU/Common/Source/DPU/FileService.c +++ b/DPDPU/Common/Source/DPU/FileService.c @@ -18,7 +18,7 @@ struct DPUStorage *Sto; char *G_BDEV_NAME = "malloc_delay"; FileService* FS; extern bool G_INITIALIZATION_DONE; -extern volatile int ForceQuitFileBackEnd; +extern volatile int ForceQuitStorageEngine; int WorkerId = 0; // @@ -336,7 +336,7 @@ DeallocateFileService( // void SignalFileBackEndToExit() { - ForceQuitFileBackEnd = 1; + ForceQuitStorageEngine = 1; } // diff --git a/DPDPU/NetworkEngine/Include/PEPOTLDKTCP.h b/DPDPU/NetworkEngine/Include/PEPOTLDKTCP.h index ea9f3cb..f4cdb52 100644 --- a/DPDPU/NetworkEngine/Include/PEPOTLDKTCP.h +++ b/DPDPU/NetworkEngine/Include/PEPOTLDKTCP.h @@ -383,13 +383,6 @@ PEPOTLDKTCPRun( void* StorageEngineArg ); -// -// Stop the PEPO -// -// -int -PEPOTLDKTCPStop(void); - // // Destroy the PEPO // diff --git a/DPDPU/NetworkEngine/Source/DDSBOWPipeline.c b/DPDPU/NetworkEngine/Source/DDSBOWPipeline.c index 2facd99..f85f4c5 100644 --- a/DPDPU/NetworkEngine/Source/DDSBOWPipeline.c +++ b/DPDPU/NetworkEngine/Source/DDSBOWPipeline.c @@ -20,28 +20,6 @@ DOCA_LOG_REGISTER(DDSBOW_PIPELINE); struct DDSBOWConfig AppCfg = { 0 }; -/* - * Signal handler - * - * @SigNum: The signal received to handle - */ -static void -SignalHandler( - int SigNum -) { - if (SigNum == SIGINT) { - DOCA_LOG_INFO("Signal %d received, preparing to exit...", SigNum); - if (AppCfg.UseDPDK) { - PEPOTLDKTCPStop(); - } - else { - PEPOLinuxTCPStop(); - } - - SignalFileBackEndToExit(); - } -} - /* * DDS BOW pipeline main function * @@ -92,8 +70,6 @@ RunBOW( doca_argp_destroy(); return EXIT_FAILURE; } - - signal(SIGINT, SignalHandler); if (AppCfg.UseDPDK) { // diff --git a/DPDPU/NetworkEngine/Source/PEPOLinuxTCP.c b/DPDPU/NetworkEngine/Source/PEPOLinuxTCP.c index e5e6291..9b38431 100644 --- a/DPDPU/NetworkEngine/Source/PEPOLinuxTCP.c +++ b/DPDPU/NetworkEngine/Source/PEPOLinuxTCP.c @@ -297,5 +297,5 @@ PEPOLinuxTCPStop(void) { // int PEPOLinuxTCPDestroy(void) { - return 0; + return PEPOLinuxTCPStop(); } diff --git a/DPDPU/NetworkEngine/Source/PEPOTLDKTCP.c b/DPDPU/NetworkEngine/Source/PEPOTLDKTCP.c index 4e65431..cc6f04b 100644 --- a/DPDPU/NetworkEngine/Source/PEPOTLDKTCP.c +++ b/DPDPU/NetworkEngine/Source/PEPOTLDKTCP.c @@ -44,7 +44,7 @@ static struct NetfeLcoreParam FeParam; static struct LcoreParam CoreParam[RTE_MAX_LCORE]; static int PEPOVerbose = 0; -static volatile int ForceQuit = 0; +static volatile int ForceQuitNetworkEngine = 0; // // Check out the paper below for the mapping between the hash key and TCP header fields @@ -69,7 +69,7 @@ SigHandler( int SigNum ) { RTE_LOG(ERR, USER1, "%s(%d)\n", __func__, SigNum); - ForceQuit = 1; + ForceQuitNetworkEngine = 1; } // @@ -3066,7 +3066,7 @@ PEPOLcoreMain( SigHandler(SIGQUIT); } - while (ForceQuit == 0) { + while (ForceQuitNetworkEngine == 0) { // // 1. Process TCP syn events // @@ -3734,9 +3734,8 @@ PEPOTLDKTCPRun( // Wait for all lcores to finish // // - signal(SIGINT, SigHandler); - while (!ForceQuit) { + while (!ForceQuitNetworkEngine) { sleep(1); } @@ -3747,17 +3746,6 @@ PEPOTLDKTCPRun( return 0; } -// -// Stop the PEPO -// -// -int -PEPOTLDKTCPStop(void) { - ForceQuit = 1; - - return 0; -} - // // Clean all lcores for the front end // diff --git a/DPDPU/StorageEngine/DDSBackEndDPUService/Include/DPUBackEnd.h b/DPDPU/StorageEngine/DDSBackEndDPUService/Include/DPUBackEnd.h index 737ae76..ac9cc0a 100644 --- a/DPDPU/StorageEngine/DDSBackEndDPUService/Include/DPUBackEnd.h +++ b/DPDPU/StorageEngine/DDSBackEndDPUService/Include/DPUBackEnd.h @@ -107,4 +107,4 @@ extern bool G_INITIALIZATION_DONE; // will be set to true when reserved seg is // The variable for the main agent loop // // -extern volatile int ForceQuitFileBackEnd; \ No newline at end of file +extern volatile int ForceQuitStorageEngine; \ No newline at end of file diff --git a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/FileBackEnd.c b/DPDPU/StorageEngine/DDSBackEndDPUService/Source/FileBackEnd.c index 5420e3a..08c4297 100644 --- a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/FileBackEnd.c +++ b/DPDPU/StorageEngine/DDSBackEndDPUService/Source/FileBackEnd.c @@ -25,7 +25,7 @@ static inline void DebugPrint(const char* Fmt, ...) { } #endif -volatile int ForceQuitFileBackEnd = 0; +volatile int ForceQuitStorageEngine = 0; bool G_INITIALIZATION_DONE = false; // @@ -194,7 +194,7 @@ SignalHandler( ) { if (SigNum == SIGINT || SigNum == SIGTERM) { fprintf(stdout, "Received signal to exit\n"); - ForceQuitFileBackEnd = 1; + ForceQuitStorageEngine = 1; } } @@ -2749,7 +2749,7 @@ void* DMAAgentThread( return NULL; } - while (ForceQuitFileBackEnd == 0) { + while (ForceQuitStorageEngine == 0) { if (dataPlaneCounter == 0) { // // Process connection events @@ -2911,7 +2911,7 @@ int RunFileBackEnd( // // int StopFileBackEnd() { - ForceQuitFileBackEnd = 1; + ForceQuitStorageEngine = 1; return 0; } diff --git a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/bdev.c b/DPDPU/StorageEngine/DDSBackEndDPUService/Source/bdev.c index 2893d63..b00d613 100644 --- a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/bdev.c +++ b/DPDPU/StorageEngine/DDSBackEndDPUService/Source/bdev.c @@ -324,7 +324,8 @@ SpdkBdevEventCb( ) { if (type == 0) { SPDK_NOTICELOG("bdev event: type 0, exiting...\n"); - ForceQuitFileBackEnd = 1; + ForceQuitStorageEngine = 1; + ForceQuitNetworkEngine = 1; return; } SPDK_NOTICELOG("Unsupported bdev event: type %d\n", type);