Received: by 10.192.165.148 with SMTP id m20csp3903825imm; Mon, 7 May 2018 22:42:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqNM9KMa+kY+fdeoJLlOOrweoUWHJuR1wRbXYIw+32McmqLCA7l1QGwU0hl8oFcCaNMpoTc X-Received: by 2002:a17:902:7c18:: with SMTP id x24-v6mr25395868pll.173.1525758157134; Mon, 07 May 2018 22:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525758157; cv=none; d=google.com; s=arc-20160816; b=yG5P1zpic1SpHMXL6lw8znvD+LJ+6Vj9wzph1G7JxTSknkAW49KonKJ6Bj9E/8AH+v doyfFA+fnXTSBoQZhOgeWvJPFCcTBj7Wdu3xvfi+zQ/pkDkLa0di9UsHXY0ELA+iUCg7 qUrJ+lxKJDzwZvY0esVji3m6SFvONVPa0L6VnLKji4fPDowbwIEFoPUA+O5KCmhKrgsb i+eLUMBWSOdaR+vCa8NSjzZrJcB2Xx1kupwqaywomiQnqmzCpoo6hR5zXUMwo0hI/+eM dl6a8LG0PgcWWnP9Wu5c38khHFiAeQrEI83Uii3lsBBahsFcLY+rtSbSOiWr4F1A1qxq jKpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:arc-authentication-results; bh=CCUmrz1QzKlFUsORCqExAUI0aB7xiDtshyZlD5wggmA=; b=QeQw+eohOUiv0kWsBSnd1N06lueKWTab5y+RfJZ9xrYCQGMkoU2qJucu111nLSJTyW sfA3aYozaeq34Lyqw++xXJx5Q2JQ1TjydUFudEyFipsZXooOlUsaeR+bVfpgAZDOFAnv dJJskpsnsYczID4WmXyo0KUN9J27AKC7X+HyKGaFNLU/XlBZ5gtlhKuPDCLLI55Smeb+ wDUcjAfZfYbpDGwkL01kiN4mOiGRe+VQEkYH77lNFIFYstfqs1gvxhr9JRQVeJtS8+SA nRrLIqLkeLhxg/y+oYNtrtSdoYaig+m1JzU99fd2xlB9q9Ibnr6AobdMK9JuffLVBtxL PtlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v19-v6si18838972pgc.694.2018.05.07.22.42.22; Mon, 07 May 2018 22:42:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753856AbeEHFky (ORCPT + 99 others); Tue, 8 May 2018 01:40:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57218 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752546AbeEHFkw (ORCPT ); Tue, 8 May 2018 01:40:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E24DC818F6E5; Tue, 8 May 2018 05:40:51 +0000 (UTC) Received: from [10.72.12.122] (ovpn-12-122.pek2.redhat.com [10.72.12.122]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4665784420; Tue, 8 May 2018 05:40:43 +0000 (UTC) Subject: Re: [RFC v3 4/5] virtio_ring: add event idx support in packed ring From: Jason Wang To: Tiwei Bie Cc: "Michael S. Tsirkin" , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, wexu@redhat.com, jfreimann@redhat.com References: <20180425051550.24342-5-tiwei.bie@intel.com> <34781052-df9f-e505-cd3f-08e460b34dcc@redhat.com> <20180502072819.mf5l3dypk6dwx2s7@debian> <20180502164828-mutt-send-email-mst@kernel.org> <20180502151255.h3x6rhszxa3euinl@debian> <20180502184015-mutt-send-email-mst@kernel.org> <20180503011116.qvoyblcpklinrk26@debian> <20180503044218-mutt-send-email-mst@kernel.org> <20180503020949.5u3qz32gsk33z6vk@debian> <9f0b4e37-63ff-42f9-f2e6-3747a19a0206@redhat.com> <20180503135430.lbtvn4p4lyu3ksqo@debian> Message-ID: <12ede490-f674-2b89-d639-266b5fe15466@redhat.com> Date: Tue, 8 May 2018 13:40:40 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 08 May 2018 05:40:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 08 May 2018 05:40:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jasowang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018年05月08日 11:05, Jason Wang wrote: >> >> Because in virtqueue_enable_cb_delayed(), we may set an >> event_off which is bigger than new and both of them have >> wrapped. And in this case, although new is smaller than >> event_off (i.e. the third param -- old), new shouldn't >> add vq->num, and actually we are expecting a very big >> idx diff. > > Yes, so to calculate distance correctly between event and new, we just > need to compare the warp counter and return false if it doesn't match > without the need to try to add vq.num here. > > Thanks Sorry, looks like the following should work, we need add vq.num if used_wrap_counter does not match: static bool vhost_vring_packed_need_event(struct vhost_virtqueue *vq,                       __u16 off_wrap, __u16 new,                       __u16 old) {     bool wrap = off_wrap >> 15;     int off = off_wrap & ~(1 << 15);     __u16 d1, d2;     if (wrap != vq->used_wrap_counter)         d1 = new + vq->num - off - 1;     else         d1 = new - off - 1;     if (new > old)         d2 = new - old;     else         d2 = new + vq->num - old;     return d1 < d2; } Thanks