From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0251A04E0; Wed, 27 Nov 2019 09:48:39 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BC3201BE86; Wed, 27 Nov 2019 09:48:37 +0100 (CET) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 103D31BDAC for ; Wed, 27 Nov 2019 09:48:35 +0100 (CET) Received: by mail-pl1-f195.google.com with SMTP id w7so9426838plz.12 for ; Wed, 27 Nov 2019 00:48:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E2owshsU77/p6fU9EnhCNRWEW8TuRgS6uHbkanjHwbk=; b=Cgex5LF5EdmJeh8H98T3egprvxB0gsXFBg36BkR/2/Lz67E29D1AJLohRi+OOvdm59 YzECzMb1aNyT6rWRyL3zkwamhNvpkbraYk2KKzSXbAo6MX7HU9xbc23xXngJJZvqXRcn DswKI8d9aYB3BZXCT/IuC2LenGwNZJij/hB5qin05HJ0W/pmwyL8eaQ/u5gGidJ07H0k FRoITh+DXTFNcp/1K8/9D2IK6zQKg/xNE5Tcq6Zy0eHKEB/t9YOqwLMAVbgYrqxC88KP UINwhIPG+GTjWRSIFqoDemPcb29TMGwX7+jgKivFm0tyzllDkdMipZ+RCgIjq6koj+Gf 7ayw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=E2owshsU77/p6fU9EnhCNRWEW8TuRgS6uHbkanjHwbk=; b=kOiRlpcZctew9eF95Xi2pqi9umUJ7nq61M6JFHv4wL9vWJjMhgELh3QxvsPGOWBVuc MU6Cckq7tkUSNeNcqdrXxZHpBchuTicRusWQnGDpoVHdf4tM6sOFMwrw40lGypKzqbzh eZqFbMjXqrwQyrzv4Zc10B9gGpm1O2+DtI6TZnwmh5wMf6/ZWM63DLZUHnwFTtWyzBv/ gHLmB1e09NjWudPoaiEkxqnyEh3zpCy+ei66zleIT7LxhvftrxY1FHSX+MKUQ4ebvKHR PIw+ClAEZKP8CdWANzBDK24FWkf6DMJ024ylLvJH+hkneqscN0uhoEvbPf+b3ijaFDJQ F6WQ== X-Gm-Message-State: APjAAAWaqgSLaCEwB8xsRXO97zx+sImOxmt7E7aq34JeA7JtfAve/GWA 69nnID2kLrgcTgJ+pcHMbrM= X-Google-Smtp-Source: APXvYqyGAJFDi9rG3+/sO4W0+W7M/1EaFejTjktVHvFo14i4NdA4FLbExGwInmdj/10wuW2osYhokw== X-Received: by 2002:a17:90a:9b84:: with SMTP id g4mr4637310pjp.76.1574844514251; Wed, 27 Nov 2019 00:48:34 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c8c2:de00:45ab:5a00:e90c:7c6b]) by smtp.gmail.com with ESMTPSA id t27sm15902108pfq.169.2019.11.27.00.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 00:48:33 -0800 (PST) From: Yasufumi Ogawa To: anatoly.burakov@intel.com, konstantin.ananyev@intel.com, david.marchand@redhat.com, dev@dpdk.org Cc: yasufumi.ogawa.gy@hco.ntt.co.jp, Yasufumi Ogawa Date: Wed, 27 Nov 2019 17:48:26 +0900 Message-Id: <20191127084826.3519-2-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191127084826.3519-1-yasufum.o@gmail.com> References: <20191113214346.33749-1-yasufum.o@gmail.com> <20191127084826.3519-1-yasufum.o@gmail.com> Subject: [dpdk-dev] [PATCH v8 1/1] fbarray: fix duplicated fbarray file in secondary X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yasufumi Ogawa In secondary_msl_create_walk(), it creates a file for fbarrays with its PID for reserving unique name among secondary processes. However, it does not work if several secondaries run as app containers because each of containerized secondary has PID 1, and failed to reserve unique name other than first one. To reserve unique name in each of containers, use hostname in addition to PID. Signed-off-by: Yasufumi Ogawa --- lib/librte_eal/common/include/rte_fbarray.h | 7 ++++++- lib/librte_eal/linux/eal/eal_memalloc.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/include/rte_fbarray.h b/lib/librte_eal/common/include/rte_fbarray.h index 6dccdbec9..df003b8dc 100644 --- a/lib/librte_eal/common/include/rte_fbarray.h +++ b/lib/librte_eal/common/include/rte_fbarray.h @@ -39,7 +39,12 @@ extern "C" { #include #include -#define RTE_FBARRAY_NAME_LEN 64 +/* Filename of fbarray is defined as a combination of several params + * such as "fbarray_memseg-1048576k-0-0_PID_HOSTNAME". + * The length of string before PID can be 32bytes, and the length of + * PID can be 7bytes maximamly. Final 1 byte is for null terminator. + */ +#define RTE_FBARRAY_NAME_LEN (32 + 7 + 1 + HOST_NAME_MAX + 1) struct rte_fbarray { char name[RTE_FBARRAY_NAME_LEN]; /**< name associated with an array */ diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c index af6d0d023..8c50d3355 100644 --- a/lib/librte_eal/linux/eal/eal_memalloc.c +++ b/lib/librte_eal/linux/eal/eal_memalloc.c @@ -1365,6 +1365,7 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl, struct rte_memseg_list *primary_msl, *local_msl; char name[PATH_MAX]; int msl_idx, ret; + char hostname[HOST_NAME_MAX+1] = { 0 }; if (msl->external) return 0; @@ -1373,9 +1374,13 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl, primary_msl = &mcfg->memsegs[msl_idx]; local_msl = &local_memsegs[msl_idx]; - /* create distinct fbarrays for each secondary */ - snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%i", - primary_msl->memseg_arr.name, getpid()); + /* Create distinct fbarrays for each secondary by using PID and + * hostname. The reason why using hostname is because PID could be + * duplicated among secondaries if it is launched in a container. + */ + gethostname(hostname, sizeof(hostname)); + snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%d_%s", + primary_msl->memseg_arr.name, (int)getpid(), hostname); ret = rte_fbarray_init(&local_msl->memseg_arr, name, primary_msl->memseg_arr.len, -- 2.17.1