From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id BC0FA1B868 for ; Tue, 15 May 2018 15:48:55 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id q3-v6so221549wrj.6 for ; Tue, 15 May 2018 06:48:55 -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=6YBoeBJt8uoUFXbrelpZDPwTQ8w+qeFcaqgWYt0Yi+w=; b=ZoP2DQIRqdYvlomQ12Mi0Ze37/r8DUXVmbevpysudpjjJsY4lkWwfPftFjbX9m9W9p BoDojYMwkhm3mno0a9dWQ3DB+cAtaWeR9fUOnYsNaCgFsZGbu2/4YWCb4coG4rW5PfAO PdGBXvLFB6RCmAzck+FM20a/PYDR+sp/HJDatePOwSd8MUSpUBxyD2ghO4NP7/x2AMEa 9GSf3dwbcttKAPaPgvEf4+I4HGSMHN3Q8rhJAQdyuF1moLLOdIcFP1gGN8WHUatcfG3u 7NUMWNtxd0azkYTg2LxGUPMiFawyZle5HRO4kwx5lcNbKx5OswjyCVnY1mXFW8CEt5d6 RCiQ== 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=6YBoeBJt8uoUFXbrelpZDPwTQ8w+qeFcaqgWYt0Yi+w=; b=b7LAWHl6s7KrnSts4GV5895fXjYuIi4KQVgdx0KqqQLcYAPso0Vml8sc7R16ddkpmL gYKItSjg8ujU9CFLudByTO3X20+c/6LwcNOXdFFACDL4eJll1dPzbeO23KzXT4GNISk2 lU9gndJjkd8xGGYb4t7Z0dg1nq/e8lxZ176DH4ClrGlD1tdFWB268F75op0LjDmuvfyz yjVAEctOIEflFJJAUQwu4sbKKmiYxTP0nbZ6C7YTR5nKul1uOFxR6Tm3x8iY8qO9kaIa y7NN7qS5U7R5vYeOJJjs6hvgzQUs6mhUoONJwcQK9M9gj1i7GY5qahgLNM33yFSlHtlK M7rg== X-Gm-Message-State: ALKqPwfE1egLItYciOPxd8kENnFyt0qN7YqLWuyv58zNDRpuhLwHXggZ OzGL+BIl3qTAjIgavoeJ2IQ= X-Google-Smtp-Source: AB8JxZoNIQUhCwl1n8jP0rmKUc5d3M3bKrxIBTaLGS5tHgMyF7djbAaojJIa0IcF7wA0dI/0oLUJNQ== X-Received: by 2002:adf:abc6:: with SMTP id s64-v6mr10659886wrc.66.1526392135460; Tue, 15 May 2018 06:48:55 -0700 (PDT) Received: from localhost (slip139-92-244-193.lon.uk.prserv.net. [139.92.244.193]) by smtp.gmail.com with ESMTPSA id 141-v6sm684093wmf.35.2018.05.15.06.48.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 06:48:54 -0700 (PDT) From: luca.boccassi@gmail.com To: Jianfeng Tan Cc: Maxime Coquelin , dpdk stable Date: Tue, 15 May 2018 14:46:55 +0100 Message-Id: <20180515134731.9337-44-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180515134731.9337-1-luca.boccassi@gmail.com> References: <20180503110612.12146-2-luca.boccassi@gmail.com> <20180515134731.9337-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'net/virtio-user: fix hugepage files enumeration' has been queued to stable release 18.02.2 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 13:48:55 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 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 becbf25bf99968d3153475ea339008334185fb83 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 --- .../howto/virtio_user_for_container_networking.rst | 3 ++- drivers/net/virtio/virtio_user/vhost_user.c | 28 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/guides/howto/virtio_user_for_container_networking.rst b/doc/guides/howto/virtio_user_for_container_networking.rst index aa68b5315..476ce3a63 100644 --- a/doc/guides/howto/virtio_user_for_container_networking.rst +++ b/doc/guides/howto/virtio_user_for_container_networking.rst @@ -109,7 +109,8 @@ We have below limitations in this solution: * Cannot work with --no-huge option. Currently, DPDK uses anonymous mapping under this option which cannot be reopened to share with vhost backend. * Cannot work when there are more than VHOST_MEMORY_MAX_NREGIONS(8) hugepages. - In another word, do not use 2MB hugepage so far. + If you have more regions (especially when 2MB hugepages are used), the option, + --single-file-segments, can help to reduce the number of shared files. * Applications should not use file name like HUGEFILE_FMT ("%smap_%d"). That will bring confusion when sharing hugepage files with backend by name. * Root privilege is a must. DPDK resolves physical addresses of hugepages diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index 91c6449bb..163bf93ea 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -138,12 +138,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) { @@ -183,16 +184,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