From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id B97B71066 for ; Wed, 18 Apr 2018 09:24:27 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 330134022909; Wed, 18 Apr 2018 07:24:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 658C2215CDC8; Wed, 18 Apr 2018 07:24:26 +0000 (UTC) From: Maxime Coquelin To: bluca@debian.org, stable@dpdk.org Cc: Maxime Coquelin Date: Wed, 18 Apr 2018 09:24:08 +0200 Message-Id: <20180418072408.18143-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 18 Apr 2018 07:24:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 18 Apr 2018 07:24:27 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:'' Subject: [dpdk-stable] [PATCH v16.11 LTS] vhost: avoid concurrency when logging dirty pages 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: Wed, 18 Apr 2018 07:24:28 -0000 [ backported from upstream commit 394313fff39d0f994325c47f7eab39daf5dc9e11 ] This patch aims at fixing a migration performance regression faced since atomic operation is used to log pages as dirty when doing live migration. Instead of setting a single bit by doing an atomic read-modify-write operation to log a page as dirty, this patch write 0xFF to the corresponding byte, and so logs 8 page as dirty. The advantage is that it avoids concurrent atomic operations by multiple PMD threads, the drawback is that some clean pages are marked as dirty and so are transferred twice. Fixes: 6bf02ab821fb ("vhost: make page logging atomic") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Reviewed-by: Jianfeng Tan Conflicts: lib/librte_vhost/vhost.h --- Hi Luca, This patch is backported from upstream master, I propose it as the backport requires some conflicts to be fixed. Cheers, Maxime lib/librte_vhost/virtio_net.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 0024f729e..ebcb56a91 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -52,18 +52,14 @@ #define VHOST_LOG_PAGE 4096 /* - * Atomically set a bit in memory. - */ -static inline void __attribute__((always_inline)) -vhost_set_bit(unsigned int nr, volatile uint8_t *addr) -{ - __sync_fetch_and_or_8(addr, (1U << nr)); -} - + * Mark all pages belonging to the same dirty log bitmap byte + * as dirty. The goal is to avoid concurrency between different + * threads doing atomic read-modify-writes on the same byte. +*/ static inline void __attribute__((always_inline)) vhost_log_page(uint8_t *log_base, uint64_t page) { - vhost_set_bit(page % 8, &log_base[page / 8]); + log_base[page / 8] = 0xff; } static inline void __attribute__((always_inline)) -- 2.14.3