From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67865C606B0 for ; Tue, 9 Jul 2019 10:22:21 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id DA05220645 for ; Tue, 9 Jul 2019 10:22:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CR41cNAH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA05220645 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB6AA1B970; Tue, 9 Jul 2019 12:22:19 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 1F1F837A2; Tue, 9 Jul 2019 12:22:18 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id q4so9216851pgj.8; Tue, 09 Jul 2019 03:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=FXcWwWSpTZDg9m22xukk3whIYWbifDALyiORi+y6RHo=; b=CR41cNAHCvk6NKHDbsKCylKBTOQU8E2pvCkusUgZJC/MmwTFHkdK+8vHRqixFRWUm8 XJW74Ix5WIrPIjkqqyEg1rxVB8uELv9EmoI+69ImcN+NQFtTN2hjyIdzU+rHu3JH/uLb htLE0HtLwpLkJcuCabJfK5kYzHbDAKU1PuS+uyQcgxWIfvhlvPMJp/EK9VcxV0/rqYZt 5C/Fx4oT7jRy/XOSljQMLtqsXy7owwdI1+RcX9Tu2UTGUiVzy3HmEzqqqE/xEZgnQdSH KA8XFKgvW7tLmYLGM6OQOuS7aq9h1caHmWdrQaI++Y8Pr7XUaxrr6MZVtFVGORTeIvM8 YiDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FXcWwWSpTZDg9m22xukk3whIYWbifDALyiORi+y6RHo=; b=OrZYq6ovgGCcBo+tfKOyXHSLEiKVxSkbKTxxQBm7qCY/8EEjtM8ASdkyGOtSja4fNI 6WAvG3LogZEWh4sa1oAKbWt/IGYgud9ZRS44geXoAZS0A4pMErer/mKqfo5KyFCE11LM Kfxv1JEUh+4qIGB47TLMeGYzPO0TtFRjXWVSrE71ZSss1BO1iDmllf3Xd9tQ9obQC304 wFsW8mGD090FxbcBerlhOnX5E09U84fZKmySejq38XoqBFylIMASt7EfrI2J36DeHBUm uJBbVI7eqhjVr2x7A1axpqkDyd9DZycuHwfR+h26dhNlKxg5ORtxNMnCuix/ABjbl3Xd bXmA== X-Gm-Message-State: APjAAAUHDn+MzM63bHlP/ACAZH/CvKnHUX6rCXv0I9dnsFmxdHPGkCAZ z1N/xrsTDAbtWFZ7aPT6QjsG0z1A X-Google-Smtp-Source: APXvYqxLCmMJi9gq+AvvkgllsuMCo8SK+xLdTqHCtpU+iq1ydZBI1nMisvlTQ6cu/1iEXp+rWkbo/A== X-Received: by 2002:a63:593:: with SMTP id 141mr29137177pgf.78.1562667737071; Tue, 09 Jul 2019 03:22:17 -0700 (PDT) Received: from mugwort.local ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id h1sm17892409pgv.93.2019.07.09.03.22.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 03:22:16 -0700 (PDT) To: "Burakov, Anatoly" Cc: dev@dpdk.org, stable@dpdk.org References: <1555379952-23517-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> <1555386203-23776-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> <1555386203-23776-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> From: Yasufumi Ogawa Message-ID: <95821e91-33f1-686c-f4c1-8ce7a07646d4@gmail.com> Date: Tue, 9 Jul 2019 19:22:13 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 1/1] fbarray: get fbarrays from containerized 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" Hi Anatoly, On 2019/07/05 17:53, Burakov, Anatoly wrote: > On 16-Apr-19 4:43 AM, ogawa.yasufumi@lab.ntt.co.jp wrote: >> 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 if the value is 1. >> >> Cc: stable@dpdk.org >> >> Signed-off-by: Yasufumi Ogawa >> --- > > I'm not too well versed in containers - is this hostname 1) always set, > and 2) always unique? For docker, 1) hostname is always set. 2) The hostname is decided as short form of container ID, so it might not be unique even though very low possibility. I found that we can get whole container ID in `/proc/self/cgroup` as discussed [1]. I think using hostname is reasonable way without running many secondary processes. However, it might be better to use 64 digits full container ID instead of 12 digits short ID if ensure uniqueness strongly. What do yo think? [1] https://forums.docker.com/t/get-a-containers-full-id-from-inside-of-itself/37237 > > > >> +    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) >> +            return -1; > > Wouldn't an error in fscanf() leak the file handle? I think you need to > fclose() before checking the result. I would like to fix it. Regards, Yasufumi > >> +        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, >> > >