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 709BEA04C4; Wed, 13 Nov 2019 22:44:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AECE02BC8; Wed, 13 Nov 2019 22:44:01 +0100 (CET) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id B54ED2B99; Wed, 13 Nov 2019 22:43:59 +0100 (CET) Received: by mail-pf1-f193.google.com with SMTP id r4so2548829pfl.7; Wed, 13 Nov 2019 13:43:59 -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=tyWhwIk+UcERkbBX++hSVNBBi4lK10YrKeojT1jKCpE=; b=Z8VrfQSGXAeXq/sbPH7kQH/XMJjJ8foqJ4rrCNIfFxA1OqbxzNLUT1sUJNhr7MqF0k FXiE4YLy3bH5ZjS36qJAHeGyaaX+9T2RuYj/sS/4Yl1kCL6irizQiGl6ZgDK9Qg6+xNO 4DWGPkHSDyZ6Rgm3lqxMN0ywLLDsHqtflTQKuTlTTU3jRrmVjg0R/YWMtzdBuyWNURMl X5JMsrao1QraeaPVACAC2WguB0mH5ya1ArAmyfWs+HdVwy/QCpmbCPAu8oWbYjFOSnYS A0BVh04mmAarw03LaQCPOIqziMwFHueUGtVh6YHOq4oblje/9zhMP36eHdaD/p+H+KmU Ld5w== 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=tyWhwIk+UcERkbBX++hSVNBBi4lK10YrKeojT1jKCpE=; b=kdBJcVQBGnYcXkG8C7NxwpwGNvamqkMw1baVXYK74wboeR4D+wZ9Jh88c5I2CyI8gq CZblkHzLb1XpRlyN+Yi1p57IkVS2Y8yF1WjVhtDH8CJpTxg88YUu9PGv03fHfoxxEwdk QkBVO0bJXqzCyUxU3KUzt9/z9jqsPFIakdxR+B1UOZFMxpIM57V2t9mKO2p66DUSC2qM 4vr3pXUNGxNzJQZrGz741YDOFg+a6KUPVmZQnF/RkM98s2xSREuhoAvIkXAnjrMRW1uG eMb42fJYxvyIep4tFbtjroaEzWFgrynYxS0BF2GEpyU42uyKBTEQFqxbBbq6RtTy1fxw bFLg== X-Gm-Message-State: APjAAAWDHHlbIaRSIST5ugyCtSfUP26cd3wHuLJFo+0+EcJTEF6o0DpD ven1EQCUz1b8qYxJgIqv1GM= X-Google-Smtp-Source: APXvYqwrjzrCdHSi9OPZwsG7h16GKJyk5U5XJa6g3quzeX6bvDYbR/Y/BYgMn4QkepGAZhMingUqUQ== X-Received: by 2002:a17:90a:5d0e:: with SMTP id s14mr7566659pji.55.1573681438437; Wed, 13 Nov 2019 13:43:58 -0800 (PST) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id r68sm3789538pfr.78.2019.11.13.13.43.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 13:43:57 -0800 (PST) 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: Thu, 14 Nov 2019 06:43:46 +0900 Message-Id: <20191113214346.33749-2-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191113214346.33749-1-yasufum.o@gmail.com> References: <20190724082031.45546-1-yasufum.o@gmail.com> <20191113214346.33749-1-yasufum.o@gmail.com> Subject: [dpdk-dev] [PATCH v7 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/linux/eal/eal_memalloc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c index af6d0d023..11de6d4d6 100644 --- a/lib/librte_eal/linux/eal/eal_memalloc.c +++ b/lib/librte_eal/linux/eal/eal_memalloc.c @@ -1365,6 +1365,12 @@ 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 }; + /* filename of secondary's fbarray is defined such as + * "fbarray_memseg-1048576k-0-0_PID_HOSTNAME" and length of PID + * can be 7 digits maximumly. + */ + int fbarray_sec_name_len = 32 + 7 + 1 + HOST_NAME_MAX + 1; if (msl->external) return 0; @@ -1373,9 +1379,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, fbarray_sec_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