From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by dpdk.org (Postfix) with ESMTP id CDCA71B6ED for ; Tue, 15 May 2018 19:20:26 +0200 (CEST) Received: by mail-lf0-f66.google.com with SMTP id r2-v6so1398035lff.4 for ; Tue, 15 May 2018 10:20:26 -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=qx0bQve/GywaJa21+tEFMyh737xbfSox6XS7Il9SfNs=; b=G2VCOJ3n9aZ9K75BStdFxbTaNnLJL97WzfK9VpRQXmb7O94b1hC6wdD2yQmCrVcfgu E2/TcBcSkxDUcQYMSOmnKfmwo9yOEzWysMcTWFv8rLbxvW5++mSDof9SAztoziGP5f0n NjyfPKKEVba8UJjqiXkg70CGU0yCOBJI+nVyZB0EoCQzkQkq1ZwF5DxcDstRBiuhGCLj iTBDAI1vyfRTFNsi+JcdgSLq/O9T7m2U3EjWsrTUKOssJYB7beOTqbqrQn1itqE/SB/S rK2eszv0Y21teGX8Fz116P/9P66o+P5Ag7Vn+0U0kWrjAamdBt5B1NE9p2wV5mt0b8Nq prhg== 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=qx0bQve/GywaJa21+tEFMyh737xbfSox6XS7Il9SfNs=; b=EZ98upIC4fN/xBgDD7xr/9+2SrYZfsjlh12y1D5/izCOqYBiwBKRzrhrMRzbhvgAHG Bmhzuqh+cg5Blv3KBSSAg55x2QAAw6+5xb9JnV1yBHzDP9ciOx7fCHa4M/naLW/8Pq3c P7Z2uwpqk2b+Dz9r6s1qKus4DwHhqZWq3qh/GPmux3xSKhExEgXfDS/C0Z/rHAdm+2TM 9fX+pBATfeuDauFby09Yy2jqOdt28Aui6qiUUkY9Ew3ib2VA4ROPBwf80+jigRMjQ4FT tw9KIfXFP8JQiGM4GUaBwyTZskWOL0t2lBu376CNirTPcyTVRSxRRvqpRDrcRDRutqP5 KjOg== X-Gm-Message-State: ALKqPweTCGDEVAPJ3x4aIGzNmjxvivkxWVX7+x69JL9mng87gph+YY41 2c7UXFIQxnXriQV3tp6sJqc= X-Google-Smtp-Source: AB8JxZrDmRCQjjO80T/qLsT4SpUjgvFJQ4F7e0bvH41+4TzW8Sd+gptoKuVr3LbzC8Ug3+RtNAV+hA== X-Received: by 2002:a19:1498:: with SMTP id 24-v6mr12131457lfu.128.1526404826395; Tue, 15 May 2018 10:20:26 -0700 (PDT) Received: from localhost ([2a00:23c5:be9a:5200:ce4c:82c0:d567:ecbb]) by smtp.gmail.com with ESMTPSA id n16-v6sm129036lfe.37.2018.05.15.10.20.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 10:20:25 -0700 (PDT) From: luca.boccassi@gmail.com To: Jianfeng Tan Cc: Maxime Coquelin , dpdk stable Date: Tue, 15 May 2018 18:19:26 +0100 Message-Id: <20180515171933.12882-25-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180515171933.12882-1-luca.boccassi@gmail.com> References: <20180501104509.17238-46-luca.boccassi@gmail.com> <20180515171933.12882-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'net/virtio-user: fix hugepage files enumeration' has been queued to LTS release 16.11.7 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: , X-List-Received-Date: Tue, 15 May 2018 17:20:27 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/16/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From c219b721c2909d1e9c67a3de4c7ea7acf2b1b4a9 Mon Sep 17 00:00:00 2001 From: Jianfeng Tan Date: Thu, 26 Apr 2018 15:34:07 +0000 Subject: [PATCH] net/virtio-user: fix hugepage files enumeration [ upstream commit 169a9da64a859e1782e49886e7214982304a580f ] After the commit 2a04139f66b4 ("eal: add single file segments option"), one hugepage file could contain multiple hugepages which are further mapped to different memory regions. Original enumeration implementation cannot handle this situation. This patch filters out the duplicated files; and adjust the size after the enumeration. Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer") Signed-off-by: Jianfeng Tan Acked-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/vhost_user.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index 6f4845b70..a670da4dd 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -134,12 +134,13 @@ struct hugepage_file_info { static int get_hugepage_file_info(struct hugepage_file_info huges[], int max) { - int idx; + int idx, k, exist; FILE *f; char buf[BUFSIZ], *tmp, *tail; char *str_underline, *str_start; int huge_index; uint64_t v_start, v_end; + struct stat stats; f = fopen("/proc/self/maps", "r"); if (!f) { @@ -179,16 +180,39 @@ get_hugepage_file_info(struct hugepage_file_info huges[], int max) if (sscanf(str_start, "map_%d", &huge_index) != 1) continue; + /* skip duplicated file which is mapped to different regions */ + for (k = 0, exist = -1; k < idx; ++k) { + if (!strcmp(huges[k].path, tmp)) { + exist = k; + break; + } + } + if (exist >= 0) + continue; + if (idx >= max) { PMD_DRV_LOG(ERR, "Exceed maximum of %d", max); goto error; } + huges[idx].addr = v_start; - huges[idx].size = v_end - v_start; + huges[idx].size = v_end - v_start; /* To be corrected later */ snprintf(huges[idx].path, PATH_MAX, "%s", tmp); idx++; } + /* correct the size for files who have many regions */ + for (k = 0; k < idx; ++k) { + if (stat(huges[k].path, &stats) < 0) { + PMD_DRV_LOG(ERR, "Failed to stat %s, %s\n", + huges[k].path, strerror(errno)); + continue; + } + huges[k].size = stats.st_size; + PMD_DRV_LOG(INFO, "file %s, size %zx\n", + huges[k].path, huges[k].size); + } + fclose(f); return idx; -- 2.14.2