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 8DE8FA00BE; Fri, 1 Nov 2019 10:04:34 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5FA91E4EC; Fri, 1 Nov 2019 10:04:23 +0100 (CET) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 24FE51DFEA; Fri, 1 Nov 2019 10:04:22 +0100 (CET) Received: by mail-pg1-f194.google.com with SMTP id j30so2607837pgn.5; Fri, 01 Nov 2019 02:04:22 -0700 (PDT) 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=f85zaR8cJ7A8hjhLdSu7v7eBvL4ZKWuyY9SSCHFcSrA=; b=bKUaWTnMxaNGh2k57Fq4o66goh2nUwe40kSlYB/7ZpOR7oCttwkxL/u2LgABgRD9tN GJKYwl1qdRVmdoEZUF5AGffMdhpU5a4YH9lOuqNXylXY4n1XmXF8Ge23suAflRSvS/yX 4gLzI4FocyBOFNEu9urNmfL5ynXHOCj+3ujWjF6KrKwMfQUzwS8cH/kPQSStzpRIB1ox WY7loeGNfVUpbMSlcBgKstDooWCKld1gsHB0uD4jnzodZjtX6MqEyxoZ5eJxfGX0VgxS m3cREY15V5u9bXBAcUwojYZJOXmzIdyCtl+00oeUGIZdGDvaHZDvRyC7V4/zRnKnjcon r/og== 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=f85zaR8cJ7A8hjhLdSu7v7eBvL4ZKWuyY9SSCHFcSrA=; b=rkmb7tez2CqXmQ7ZDRyZ6eRO7LBwyrXzpv4F/9CP1oc9WSVcHVidO53KVHIu25BWOu mj4DLGDF4jl6c1WqGOFeeri62YNeBZygAV0vHvuNWDoVPVb00M5YSUIBkWDj60sOkU04 WiXfv0BsFS8m9v58Zy4uylmAvR9N9AGHkFVZ8mUEfPPc+SvT08IH7JtWZSNFf7wcsz9B STmJoEGshN/uvGO+s/H2RFEzdBQONkaiOWpvTprdenG1nm29LmSzbA5miGNUr7CZinO5 hjmqgXCzDmfFnDmXPyqu2IKESOYzYY9bufq28Ioa2MBne579h2WmyEMb7DlH/V/2tL14 PqmQ== X-Gm-Message-State: APjAAAWQaBr8/CX6GT4NLb/EqEhh9STemrBl5Afkd07yXyL68QY0mZRM vR+hreeEr4ecqWV8SZw3/xA= X-Google-Smtp-Source: APXvYqyH0OPDHUdxfxnYuwAPkACe5MaISlDT0D9XIiqTc/vj4NNI3TXKIU+BMUxIQ7H3L2iC5ancDg== X-Received: by 2002:a63:200e:: with SMTP id g14mr12129505pgg.91.1572599061319; Fri, 01 Nov 2019 02:04:21 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id s2sm5527426pgi.47.2019.11.01.02.04.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Nov 2019 02:04:20 -0700 (PDT) From: yasufum.o@gmail.com To: anatoly.burakov@intel.com, david.marchand@redhat.com, konstantin.ananyev@intel.com Cc: dev@dpdk.org, stable@dpdk.org, yasufum.o@gmail.com, Yasufumi Ogawa Date: Fri, 1 Nov 2019 18:04:13 +0900 Message-Id: <20191101090413.17997-2-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101090413.17997-1-yasufum.o@gmail.com> References: <20190724082031.45546-1-yasufum.o@gmail.com> <20191101090413.17997-1-yasufum.o@gmail.com> Subject: [dpdk-dev] [PATCH v6 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. Cc: stable@dpdk.org Signed-off-by: Yasufumi Ogawa --- lib/librte_eal/common/include/rte_fbarray.h | 2 +- lib/librte_eal/linux/eal/eal_memalloc.c | 11 ++++++++--- 2 files changed, 9 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..5c2815093 100644 --- a/lib/librte_eal/common/include/rte_fbarray.h +++ b/lib/librte_eal/common/include/rte_fbarray.h @@ -39,7 +39,7 @@ extern "C" { #include #include -#define RTE_FBARRAY_NAME_LEN 64 +#define RTE_FBARRAY_NAME_LEN NAME_MAX 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..24f0275c9 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] = { 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, HOST_NAME_MAX); + snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%s_%d", + primary_msl->memseg_arr.name, hostname, (int)getpid()); ret = rte_fbarray_init(&local_msl->memseg_arr, name, primary_msl->memseg_arr.len, -- 2.17.1