From patchwork Wed Mar 7 14:28:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 882634 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3zxGGh5R3bz9sfF; Thu, 8 Mar 2018 01:28:44 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1eta3d-0008BU-36; Wed, 07 Mar 2018 14:28:41 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1eta3b-0008AT-0L for kernel-team@lists.ubuntu.com; Wed, 07 Mar 2018 14:28:39 +0000 Received: from mail-wm0-f71.google.com ([74.125.82.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1eta3a-00024G-P6 for kernel-team@lists.ubuntu.com; Wed, 07 Mar 2018 14:28:38 +0000 Received: by mail-wm0-f71.google.com with SMTP id m78so1221630wma.7 for ; Wed, 07 Mar 2018 06:28:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=jpmtEVoQ3DtgETTO+eAjnH/S4kBlVJawn/B6CvYFd8M=; b=FzS3hKhQ/DqgT4DMbcoLTl/EZ72OeP4WUYlLt17jtfkKcMa9GC9eoOemQCbNq0TTXw OVgPoi17TATtZ4Ef2IC60kDBWCAguz/YaecdVJDmuPglj37OYXun4718byNVEvH7ljcl Hs/FwAwfsJCI1o7b1QMgFzUd+Vgub08pFSRZxG2CGX+XvTwv91ATNzveXJLJmCmexZ0R TfTUYH0Q70BB0Ndvqe2SyQ5ZsNfseDt5C/Hdc3fE/JMK7c6fBLo3c1ylkXRDbQoUes0Y eOyCBF5pI9dqzMGUsVDoyB22lpoA7txnqqrutdrYIwm5WLjXU8T+iX71z819ovn7yM1I BzKg== X-Gm-Message-State: APf1xPBfiL/3d4gRqaFrD/MrgjKU+tJpq5EWkas5ec+dpLL0h5KzE9wt t8NqHZDOIJTllr8SmlkTkziJIrovTft6fwt7OtxUFGXWweZj/d+gWVknmx6TUmivl4pXdQ4lXuA mBpF8ArgX6wFvhL006FcgvbkSymV8mzXvpPxLQFHd X-Received: by 10.223.170.153 with SMTP id h25mr18930318wrc.236.1520432917978; Wed, 07 Mar 2018 06:28:37 -0800 (PST) X-Google-Smtp-Source: AG47ELtyHREgUo/YuBc+ZOzXKTHaDe23N5z0h0kvOIpo1X4rAF8Z563l4ZZChnJ03ggXZV5MPBzLkA== X-Received: by 10.223.170.153 with SMTP id h25mr18930303wrc.236.1520432917690; Wed, 07 Mar 2018 06:28:37 -0800 (PST) Received: from localhost.localdomain ([37.220.133.201]) by smtp.gmail.com with ESMTPSA id 4sm10124603wmz.31.2018.03.07.06.28.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Mar 2018 06:28:36 -0800 (PST) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure:x][PATCH v2 2/4] Revert "UBUNTU: SAUCE: vmbus: simplify packet iterator" Date: Wed, 7 Mar 2018 11:28:29 -0300 Message-Id: <1520432911-4667-3-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520432911-4667-1-git-send-email-marcelo.cerri@canonical.com> References: <1520432911-4667-1-git-send-email-marcelo.cerri@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: http://bugs.launchpad.net/bugs/1748662 This reverts commit 6e76d0d699a8effd941fa7732e18edf4173a6db0. Signed-off-by: Marcelo Henrique Cerri --- drivers/hv/ring_buffer.c | 42 ++++++++++++++++-------------------------- include/linux/hyperv.h | 2 +- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 8214042757cb..2f80666583c4 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -389,28 +389,18 @@ __hv_pkt_iter_next(struct vmbus_channel *channel, if (rbi->priv_read_index >= dsize) rbi->priv_read_index -= dsize; + /* more data? */ return hv_pkt_iter_first(channel); } EXPORT_SYMBOL_GPL(__hv_pkt_iter_next); /* * Update host ring buffer after iterating over packets. - * - * Avoid unnecessary signaling of the host by making sure that all - * data is read, and the host has not masked off the interrupt. - * - * In addition, in Windows 8 or later there is an extension for the - * host to indicate how much space needs to be available before - * signaling. The hos sets pending_send_sz to the number of bytes - * that it is waiting to send. */ void hv_pkt_iter_close(struct vmbus_channel *channel) { struct hv_ring_buffer_info *rbi = &channel->inbound; - u32 orig_write_sz; - - /* Available space before read_index update */ - orig_write_sz = hv_get_bytes_to_write(rbi); + u32 orig_write_sz = hv_get_bytes_to_write(rbi); /* * Make sure all reads are done before we update the read index since @@ -418,29 +408,29 @@ void hv_pkt_iter_close(struct vmbus_channel *channel) * is updated. */ virt_rmb(); - - /* Update the position where ring buffer has been read from */ rbi->ring_buffer->read_index = rbi->priv_read_index; - /* If more data is available then no need to signal */ - if (hv_get_bytes_to_read(rbi)) - return; - /* - * If the reading of the pend_sz were to be reordered and read - * before we commit the new read index. - * Then we could have if the host were to set the pending_sz - * after we have already sampled pending_sz. + * Issue a full memory barrier before making the signaling decision. + * Here is the reason for having this barrier: + * If the reading of the pend_sz (in this function) + * were to be reordered and read before we commit the new read + * index (in the calling function) we could + * have a problem. If the host were to set the pending_sz after we + * have sampled pending_sz and go to sleep before we commit the + * read index, we could miss sending the interrupt. Issue a full + * memory barrier to address this. */ - virt_wmb(); + virt_mb(); if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) { u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); /* - * If there was space before we began iteration, then - * host was not blocked. Also handles the case where - * pending_sz is zero because host has nothing pending. + * If there was space before we began iteration, + * then host was not blocked. Also handles case where + * pending_sz is zero then host has nothing pending + * and does not need to be signaled. */ if (orig_write_sz > pending_sz) return; diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 822c7a3a4efc..dd3e59116ace 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -126,7 +126,7 @@ struct hv_ring_buffer_info { u32 ring_datasize; /* < ring_size */ u32 ring_data_startoffset; u32 priv_write_index; - u32 priv_read_index; /* read cursor */ + u32 priv_read_index; }; /*