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 2FD1EA00B8 for ; Mon, 28 Oct 2019 09:08:00 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DAF841BF2F; Mon, 28 Oct 2019 09:07:59 +0100 (CET) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 8C5711BEFA; Mon, 28 Oct 2019 09:07:53 +0100 (CET) Received: by mail-pf1-f196.google.com with SMTP id q26so2747139pfn.11; Mon, 28 Oct 2019 01:07:53 -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=N6bQivgoOuG90JxskGsugIZLegY58Hw3NB2AezHGokU=; b=rzKmVVpMujZ9Gr+45W1wskfeLT5VEnOiTNmLH5pPYN3YU8PYujrHtEPabzjaTOw97A 51NqPc3UU8WFXQEUSNVLcbzDT1UFrWwaxCjj+W8EQqsHIVzmYJN/IGcWLMvkLlKGLVVq ybRpG06+Y7ENxdNJTB+b7gYnU6/mhlit3GWQFeP8oXCVnaqL+V+WJMfHchUFhI5D0zOC 9Morv19AYUGk0goa3YmXFSw37ZifAgZAiLP5yBK+1ef7QtyUEtwp3rXql5AlTTO5Qz3S dc2v6qjdVg7GzUOaE5ViRa/oE4CK/QBFJ3E2KWBLPgBhKgkTYwYzlROV+h5LGhtyZ6xJ 1QcQ== 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=N6bQivgoOuG90JxskGsugIZLegY58Hw3NB2AezHGokU=; b=Yz3CWf9CUfTaBpqq6y89d5fMfxnV/xALq150Ex8P/WE8VY9NafV1ip5K3ENBKPZH4r +nDJZAAxV6MzJO+H4x5Pujyhy3yhUE3CN2VzlXQuSYFSpDejTkN34pCgUSPVJO2plAUW xJ4QqgyoCSbeOiBR+qyFOApDu4V+KEg0QGVVoGdiIhOjPOitVyJO1PKZntsl7jtEN2lr BQszn3pbvXFYqgC5JPi+QwU6cYh1Z7lHgAyupbg/vyw66uroVcTYe25RSUNG3qEKUcMS CczTcTjokQex93UH54Y+gmdkq8dNwJLNO/5jgC2AmufkctgHdrAsYnNttELgcNa+SOqA PFRQ== X-Gm-Message-State: APjAAAVyhNbBnxOxrdhVeOVHQAZD5o7Wp4DU26QFM7mMpHJeMbxssFO3 u6+zs+2AiiQIRS0uX0qpHhk= X-Google-Smtp-Source: APXvYqzjwuXUzwNqx+DtNWmqwadTckEvs++3NurZSKZAOLCq8GSMO7IkuQOWuKcYEQy90/Ft1UEZaQ== X-Received: by 2002:a63:ff56:: with SMTP id s22mr19278261pgk.44.1572250072747; Mon, 28 Oct 2019 01:07:52 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id y24sm3786847pfr.116.2019.10.28.01.07.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Oct 2019 01:07:52 -0700 (PDT) From: yasufum.o@gmail.com To: anatoly.burakov@intel.com, david.marchand@redhat.com Cc: dev@dpdk.org, stable@dpdk.org, yasufum.o@gmail.com, Yasufumi Ogawa Date: Mon, 28 Oct 2019 17:07:45 +0900 Message-Id: <20191028080745.43425-2-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028080745.43425-1-yasufum.o@gmail.com> References: <20190724082031.45546-1-yasufum.o@gmail.com> <20191028080745.43425-1-yasufum.o@gmail.com> Subject: [dpdk-stable] [PATCH v5 1/1] fbarray: fix duplicated fbarray file in 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 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 instead of PID only if PID is 1. Cc: stable@dpdk.org Signed-off-by: Yasufumi Ogawa --- lib/librte_eal/linux/eal/eal_memalloc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c index af6d0d023..699079791 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 proc_id[HOST_NAME_MAX] = { 0 }; if (msl->external) return 0; @@ -1374,8 +1375,18 @@ 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) + gethostname(proc_id, HOST_NAME_MAX); + 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