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 5A58EA00E6 for ; Thu, 11 Jul 2019 12:32:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2B4861B9A7; Thu, 11 Jul 2019 12:32:00 +0200 (CEST) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 0174C1B970; Thu, 11 Jul 2019 12:31:56 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id l21so2736670pgm.3; Thu, 11 Jul 2019 03:31:56 -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=8y8N5jksSqJw7XFc0uCnIpBDgVSoYHA5lGImaN4AcZo=; b=qZHveWpX0zAALV9GAc5oTWJoMVGkwe5T9i7IPkZEBtdMr/+aPQGORtqTHCOsc6mNZV Nxe8uq4XMHB7QpyA8s7xkGOiG5t31UAMRYCrD1o+6L4W4Jnw8e/673aNJhvJI05I448g IEjoCP09ZVvl73H7eLOdH3HG+wKsv8Aa7l7S8AopeL6xOu6M2m80Z4jlK3S6BbTvnTHt TF2M00XVV7tbElS8KMLVJIzQ7c4W755Gb2ZsV9uOsNFbWpLedkPatTxq/3be8O4KVvdm RevmpODBaeqGFPpeW1MCkQ0jSvlVVr6qhM6QAKT3w+BjcVY8Qd+cHXXxwHvyrNcLw0CA Cnqg== 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=8y8N5jksSqJw7XFc0uCnIpBDgVSoYHA5lGImaN4AcZo=; b=pXlkNpJfTcKPWhsjW5rpAC/N6tAlnvEJ6YC5H6rlMCeoU5Sp6jcdfOGVbqHSb/O5mB Sff7sbmDmP/ob7/e90COkqAucHdkkREc+XvD9Yjgn5oSY+AOarop0Xmua1p4QRoX3aJO tHRRnNHRqNP0R9EOPwDsrjD7ZkXXe9uu/5Ao8N/JHJTY1N4OJw64KcbGqoIlPKF7Rxiy uSOeMQq7p9qfMvlKoEDS80oqp1jM7IlE4tSO5o9BfujpYs9a11EAjARQRGwtbSBkHUa0 lgGu832lqEvrepGvZmpvyl1EFDzrn0JlB7y/EGxi9zb1ZPQgAfxJ1DOtocB7mr6jngXC VgNA== X-Gm-Message-State: APjAAAUmscBtICtkHAW7WK+JUz6bQHG05JXh/8wQ2Y29i1J17GtWa6q0 xDhkE1wlsAi4znJU1dhgS0I= X-Google-Smtp-Source: APXvYqwy8LBL+SbpKz+nqfO3pN746jcYng7fyiINh+FCRBPnhirSs5c0moSsuMdQ6ZbZyVgeBq4nyA== X-Received: by 2002:a17:90a:30cf:: with SMTP id h73mr4109940pjb.42.1562841116234; Thu, 11 Jul 2019 03:31:56 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id b29sm9575461pfr.159.2019.07.11.03.31.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2019 03:31:55 -0700 (PDT) From: yasufum.o@gmail.com To: anatoly.burakov@intel.com, david.marchand@redhat.com Cc: dev@dpdk.org, stable@dpdk.org, Yasufumi Ogawa Date: Thu, 11 Jul 2019 19:31:48 +0900 Message-Id: <20190711103148.9187-2-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190711103148.9187-1-yasufum.o@gmail.com> References: <1555379952-23517-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> <20190711103148.9187-1-yasufum.o@gmail.com> Subject: [dpdk-stable] [PATCH v3 1/1] fbarray: get fbarrays from containerized secondary X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 secondary is run as app container because each of containerized secondary has PID 1. To reserve unique name, use hostname instead of PID because hostname is assigned as a short form of 64 digits full container ID in docker. Cc: stable@dpdk.org Signed-off-by: Yasufumi Ogawa --- lib/librte_eal/linux/eal/eal_memalloc.c | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c index 1f6a7c18f..7cbc80718 100644 --- a/lib/librte_eal/linux/eal/eal_memalloc.c +++ b/lib/librte_eal/linux/eal/eal_memalloc.c @@ -1366,6 +1366,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 proc_id[16]; if (msl->external) return 0; @@ -1375,8 +1376,31 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl, 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()); + /* If run secondary in a container, the name of fbarray file should + * not be decided with pid because getpid() always returns 1. + * In docker, hostname is assigned as a short form of full container + * ID. So use hostname as unique ID among containers instead. + */ + if (getpid() == 1) { + FILE *hn_fp; + hn_fp = fopen("/etc/hostname", "r"); + if (hn_fp == NULL) { + RTE_LOG(ERR, EAL, + "Cannot open '/etc/hostname' for secondary\n"); + return -1; + } + + /* with docker, /etc/hostname just has one entry of hostname */ + if (fscanf(hn_fp, "%s", proc_id) == EOF) { + fclose(hn_fp); + return -1; + } + fclose(hn_fp); + } else + sprintf(proc_id, "%d", (int)getpid()); + + snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%s", + primary_msl->memseg_arr.name, proc_id); ret = rte_fbarray_init(&local_msl->memseg_arr, name, primary_msl->memseg_arr.len, -- 2.17.1