From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7CBE6A0542 for ; Thu, 8 Sep 2022 16:34:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 026D140697; Thu, 8 Sep 2022 16:34:57 +0200 (CEST) Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) by mails.dpdk.org (Postfix) with ESMTP id 0F52F4021F for ; Thu, 8 Sep 2022 16:34:56 +0200 (CEST) Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-3321c2a8d4cso167153697b3.5 for ; Thu, 08 Sep 2022 07:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date; bh=4iGbIw8sfXAGAyHmI/AU6KfD6bebouwmV12DxV6XsmU=; b=TKACXT3FkYNaFTUoF9wVAOpza1axJm0YHDu0BqkWijSo2ZYEBPxnglfg8JthCtQgLM 9JBjg2nBB0cbbe86oVUPrsD/Z5AnBwuqndzgOTMfcAl5oSsau+l5612NRuqslNSsU6EG T+hjFrXuMrcuDm52PgepZYp2PjYPLNpBvByGoMTfCfiydO+YB5AlRfxzP1oWPmSrylAI J4z9RrxhOfZz1t0DzuCe1FzcsyWqLMU36UZyJGkXSw+Tf/a3PzcEaQDz3uZFUzJkoybK 7MkjlNeUyRO0dbEroAmLNNsD2AncKNIi7jid21rfUzisDLyvLsy9DxSC5irXi34hp2lx SBbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date; bh=4iGbIw8sfXAGAyHmI/AU6KfD6bebouwmV12DxV6XsmU=; b=1V/vAJkds5II14QIKQqxMdrYxuVk3zK0rS5rNNll2RhHS7U8Y/TqQCv8vdAvHPxFQQ N3N6GCG6VZO8buhbaN0OLxpJ3XEChDGAs6i7TS+5FOVwml48aV2Tq/33biJGTf0FPYX3 r2CiLs+7kkedo+G++9B6IxpswsEM0Xq7vlVl+SHXavhzp6A4krXKzKuhKF1uuxXGqzKk BUi2Cwal9xBfainapD2sztxybtGBaXA9EoW9ZjcndXgCdtf2HiDBlywrtTW9OI8n9QgQ PFVID3PnbNkHbIc01Vo/VP7q6XtCLCymtOwZw1vu5cZWrKyqmeuYo9GreUSkQjEgIqtR gv9Q== X-Gm-Message-State: ACgBeo1AURZvwDe+Qo4kgPa8uUTca4fhQiRWhK9h95MmU4Z+Fqc9ymTR IhfD2tRxTL/heGWem7dio7EGzxD+AtHcnd3aHS8Dt/Dy0TAH4A== X-Google-Smtp-Source: AA6agR6IinGnSdy10tPP6gdolM9uO01CwM0pMnra+cHXyteHa1y0J2INoK9ZrtqxVBaa75wgyvY797AGxxCnOPeTRZo= X-Received: by 2002:a81:446:0:b0:348:ac22:d6e2 with SMTP id 67-20020a810446000000b00348ac22d6e2mr1613390ywe.479.1662647695088; Thu, 08 Sep 2022 07:34:55 -0700 (PDT) MIME-Version: 1.0 From: Antonio Di Bacco Date: Thu, 8 Sep 2022 16:34:43 +0200 Message-ID: Subject: Deadlock while allocating memory from two different primaries To: users@dpdk.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org I have a primary that spawns another primary that will only run for a few seconds and then exit. While spawning the "son" primary (using system call) the "father" primary continues to allocate memory using rte_memzone_reserve(). After a few spawnings, I get a lock: simple_mem_mp 5542 FLOCK WRITE* 0 0 0 /dev/hugepages2M... simple_mem_mp 5542 FLOCK WRITE 0 0 0 /dev/hugepages2M... During these tests I got the impression that the lock doesn't arise from the concurrency of the calls to allocate memory but from the concurrency of allocations and rte_eal_init of the spawned process. This is the reference code: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "mp_commands.h" #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1 volatile int quit = 0; static int lcore_alloc_forever(__rte_unused void *arg) { unsigned lcore_id = rte_lcore_id(); printf("Starting core on primary lcore %u\n", lcore_id); while (!quit) { char mem_name[64]; sprintf(mem_name, "%s%d", "mymem", rand()); rte_delay_ms(10); const struct rte_memzone* memzone = rte_memzone_reserve_aligned(mem_name, 1024*1024, rand()%2, RTE_MEMZONE_256KB | RTE_MEMZONE_SIZE_HINT_ONLY | RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE); if (memzone == NULL) printf("Cannot allocate\n"); rte_delay_ms(10); //printf("lcore %u hugepages size %ld\n", lcore_id, memzone->hugepage_sz); rte_memzone_free(memzone); } return 0; } static int lcore_alloc_time_limited(__rte_unused void *arg) { unsigned lcore_id = rte_lcore_id(); char mem_name[32]; printf("Starting core %u \n", lcore_id); for (int i = 0; i < 200; i++) { sprintf(mem_name, "%s%d", "mymem", rand()); rte_delay_ms(rand() % 20); const struct rte_memzone* memzone = rte_memzone_reserve_aligned(mem_name, 1024*1024, rand()%2, RTE_MEMZONE_256KB | RTE_MEMZONE_SIZE_HINT_ONLY | RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE); if (memzone == NULL) printf("Cannot allocate\n"); rte_delay_ms(rand() % 20); //printf("hugepages size %ld\n", memzone->hugepage_sz); rte_memzone_free(memzone); } printf("Exiting core %u \n", lcore_id); return 0; } int main(int argc, char **argv) { const unsigned flags = 0; const unsigned priv_data_sz = 0; int ret; unsigned lcore_id; int numa = 0; ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Cannot init EAL\n"); argc -= ret; argv += ret; /* Start of ring structure. 8< */ if (rte_eal_process_type() == RTE_PROC_PRIMARY) { RTE_LOG(INFO, APP, "Finished Process Init.\n"); int second_process = (argv[1] != NULL) && (strcmp(argv[1], "second") == 0); if (!second_process) { RTE_LCORE_FOREACH_WORKER(lcore_id) { rte_eal_remote_launch(lcore_alloc_forever, NULL, lcore_id); } while (true) { printf("Launching process\n"); system("build/simple_mem_mp --file-prefix bb -l 5-15 --proc-type primary -- second"); #define MAX_2M_PAGES 512 struct rte_memzone* memzones[MAX_2M_PAGES]; for (int i = 0; i < MAX_2M_PAGES; i++) { char mem_name[32]; sprintf(mem_name, "%s%d", "mymem", rand()); memzones[i] = rte_memzone_reserve_aligned(mem_name, 1024*1024, rand()%2, RTE_MEMZONE_256KB | RTE_MEMZONE_SIZE_HINT_ONLY | RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE); if (memzones[i] == NULL) printf("Cannot allocate\n"); } rte_delay_ms(rand() % 20); for (int i = 0; i < MAX_2M_PAGES; i++) { rte_memzone_free(memzones[i]); } rte_delay_ms(10000); } } else { RTE_LCORE_FOREACH_WORKER(lcore_id) { rte_eal_remote_launch(lcore_alloc_time_limited, NULL, lcore_id); } } } else { /* call lcore_recv() on every worker lcore */ RTE_LCORE_FOREACH_WORKER(lcore_id) { rte_eal_remote_launch(lcore_alloc_time_limited, NULL, lcore_id); } printf("Secondary started\n"); } rte_eal_mp_wait_lcore(); /* clean up the EAL */ rte_eal_cleanup(); printf("Proc type %d exiting\n", rte_eal_process_type()); return 0; }