From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by dpdk.org (Postfix) with ESMTP id 5A68C5398 for ; Wed, 9 Aug 2017 05:48:01 +0200 (CEST) Received: by mail-pf0-f179.google.com with SMTP id c28so22528272pfe.3 for ; Tue, 08 Aug 2017 20:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8panarjGYuZ4SBNSprvaDL/mSl/pOVeSb/ElcXcVtbM=; b=ZOBgDhN4dnBgulQFCx1E+AlUr85RskLucx9dmAPOeSHJ3LXoKyUfrdMWAh8Mv1ovyI Q7itj/Gxe0rY+SppbDQVMwpDcI0Da+St3uFYuVJ8zWS1ziTfkSjIp7YzTYPaivE1uF3j yYQWzyMLw/VWMSQyQy/tVIu+hwcMStAazWcgg0kgPrqxQw5uLd+55MPZjrSKvfW8Gxal KBXFy5rh481EUUadKXgO8mo+1VmQvBCW9ne1QoOxt4o50Qf+HL+4prAfcu85d0hRmNOb 1CRyCIyXkUPX1+pPncQl8knVsDh3kq/vvJk1ClfrySPKxSo6QO9sIQOJ2RTIwbRe7ZFi lnYg== 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=8panarjGYuZ4SBNSprvaDL/mSl/pOVeSb/ElcXcVtbM=; b=pZB5AbY14htjBH0bI/EXa8OQinErwwDan52BDRuixBgi97uG3StMjCVo7DWsvj3Shy keTqlDvJqGPnnQRSGBA6TqBPg2XNiROhZorC2CUHvfqJ0GTcyP77xuxCYXYfNuVAy7JZ ktvlgka1CKF5ml4/xK47ayIxqFE4VMG+ybuHQWwjfbXxjeifq9Ot8obW9hosN6V2fFlZ E3IWFAb+lKQ7QVjV6Rumh+z/zgK3MWoKAvZ1NmiuvW4f6DWTP4IzkzMCp1EatmKC540P z7WwcRAgEu5j64lWropebJhjq2FLxXwT2dYW1ZPjIVeZ6bx38jN2vg3RCUvUuly3/Oun B39w== X-Gm-Message-State: AHYfb5gpGN60IKpVwJ5luFMOCAfR5+h84Fug6xEXfWfnfi9PxsEA3IfJ FPTsmg49O4aGLG/I8i0W2g== X-Received: by 10.99.117.7 with SMTP id q7mr6246942pgc.265.1502250480684; Tue, 08 Aug 2017 20:48:00 -0700 (PDT) Received: from localhost.localdomain ([45.63.61.64]) by smtp.gmail.com with ESMTPSA id q3sm5093921pfl.89.2017.08.08.20.47.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Aug 2017 20:47:59 -0700 (PDT) From: Yuanhan Liu To: Tiwei Bie Cc: Xiao Wang , Maxime Coquelin , dpdk stable , Yuanhan Liu Date: Wed, 9 Aug 2017 11:44:00 +0800 Message-Id: <1502250240-6599-18-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502250240-6599-1-git-send-email-yliu@fridaylinux.org> References: <1502250240-6599-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'vhost: make page logging atomic' has been queued to LTS release 16.11.3 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, 09 Aug 2017 03:48:01 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/11/17. So please shout if anyone has objections. Thanks. --yliu --- >>From c2d9c76b26d6626979ada03206a268b55d8f1248 Mon Sep 17 00:00:00 2001 From: Tiwei Bie Date: Tue, 1 Aug 2017 17:01:21 +0800 Subject: [PATCH] vhost: make page logging atomic [ backported from upstream commit 897f13a1f726cefdc68762da83f9d2225a85c27e ] Each dirty page logging operation should be atomic. But it's not atomic in current implementation. So it's possible that some dirty pages can't be logged successfully when different threads try to log different pages into the same byte of the log buffer concurrently. This patch fixes this issue. Fixes: b171fad1ffa5 ("vhost: log used vring changes") Reported-by: Xiao Wang Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin --- lib/librte_vhost/virtio_net.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index ec9f1e5..0027f39 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -50,10 +50,19 @@ #define MAX_PKT_BURST 32 #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)); +} + static inline void __attribute__((always_inline)) vhost_log_page(uint8_t *log_base, uint64_t page) { - log_base[page / 8] |= 1 << (page % 8); + vhost_set_bit(page % 8, &log_base[page / 8]); } static inline void __attribute__((always_inline)) -- 2.7.4