Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1231653ybg; Thu, 11 Jun 2020 04:37:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOKJTnZiJ213FoOKMRe/TMH1H7nRQVrsbhlHopxGVXxL7vfIHfYHrZLTJi2C3QER31HkmP X-Received: by 2002:a50:b2a1:: with SMTP id p30mr6755646edd.199.1591875450830; Thu, 11 Jun 2020 04:37:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591875450; cv=none; d=google.com; s=arc-20160816; b=J7YRTKKw87j9So0BNa7dTLclFXvAvvpOZPNXAPxCZDRKISj3ws5AW745yY/Xue+i15 2CwCQCvBtg8NJMAk7fEO0ojBYC3S4jIIfOT7cJ2CaP1PBPq/N2nlqFj9fJLPeN6MvvKI vYjVpBImB2mNxjbkoL04okiwU3jkL3L0k030b/aRCB0vCmVxpS9mgf6b6ovaURyImxMH rRhQ9mfWtjtLpO0/ta7s/hhgH3b5y7ha0PCYkRL05qVZYXB155GzjrSxfcJ94x8jMD+1 Caatu2a3ADOZhO8/Capj8NLfgmoCyprMdomOrmF5uGkmUlpSnVdZEXr97QxU/dKKkNKh 55Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=kvOkZNSYFeD+43Sy08lFqOoYp/OFi1aiv2h8v9KKAP4=; b=jJn8kV1TmMj0L0laxHvLI6E89fWQ8O2ByT1pVS/uZdQwuKJxSkSyFqEpU9dBaADUOu 8MYZC2kxH5ZCKsba+3ja8lDO465oI+UQLc5Yx65RASSzDSB7yHL2UhWkNy9VghaVO20T xq3HTYnP4r2s7/mJhZxtAITV/7lIotvvT7VptmePXX1+k2RvC5W879/dGj7mhWr7koxD RATiDXLgHzHA9Rk/J9ym3jtzSta3/NVrnTkD4Y9nEUNnp/sn4evczynf8xYWujCYgtar jxYhyNp6NYvIVS1ok3nO54yOT0oKL9I0Vp/pxQrHXonM6SDI+GnlASN0t2wOJ2Z5uHFl Rheg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OjMgwzQz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si1373667edy.470.2020.06.11.04.37.08; Thu, 11 Jun 2020 04:37:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OjMgwzQz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbgFKLeW (ORCPT + 99 others); Thu, 11 Jun 2020 07:34:22 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:39954 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727109AbgFKLeV (ORCPT ); Thu, 11 Jun 2020 07:34:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591875260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=kvOkZNSYFeD+43Sy08lFqOoYp/OFi1aiv2h8v9KKAP4=; b=OjMgwzQzSg1JytLc2ue1MicyXMwsUb3YsVYufc3+QL1xSkgnsr9301ptlAFhofYdWMhhze VMuORscLd/Kwx1oRKMlFZZ/0hhmAXWBch/tyzIMDzDHlZaQFFe8hYSdK1exRCBpgbpMyf4 ovkIbQbSiXxzzAKx2fQIDZj2qsnWsMs= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-R3lgsAQ2OHm6_IPc4jW4yQ-1; Thu, 11 Jun 2020 07:34:18 -0400 X-MC-Unique: R3lgsAQ2OHm6_IPc4jW4yQ-1 Received: by mail-wr1-f72.google.com with SMTP id x15so1080069wru.21 for ; Thu, 11 Jun 2020 04:34:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=kvOkZNSYFeD+43Sy08lFqOoYp/OFi1aiv2h8v9KKAP4=; b=MyC+hjZP7hRSfZkxVOrh6f0QFEpXH4iw7hF1a4Q2b9c9WjJbvkrmrFI+/nRqFEgtLc IjClqT1pnXbB4w/wEbOMHCoPbjbtcyHvrDW7i1tOA5oL6B/VksYnLb+4gv4aMTsZjX2j /1nb9rRQ8mceH3No31mrnWix2eq2GzBNrp3xqCy1mbxgt0y0fCD7vzr/7iqJxjaqka7o dyeUYB5VAAA0OXy1HWRkTN9fX8TWyGaNaTubl/GnJyScXNXV0BXYjaqSI5O58Lzasp+o lXcVZUFIH52rkhKQE3RFpWGrnDK75qDfO6TazsUliIATpT1MJdyAbJ4838Utm8lwQ1ap rHrA== X-Gm-Message-State: AOAM530J7TVXVl6Fp6orRODYHzlzSIFSjwwvV0ao0YIJ99+zQ/ToVrXA zg7OVg5pfQhcUvKKuKMhmkutvZpfXEiVj1L+c5VUdootA9Gvv2HH2DdBrKYGprfmnmHAlgJY+9A kVwOoo2ZHX/7cDI8qOpokrQ0q X-Received: by 2002:adf:afc7:: with SMTP id y7mr9022431wrd.173.1591875256651; Thu, 11 Jun 2020 04:34:16 -0700 (PDT) X-Received: by 2002:adf:afc7:: with SMTP id y7mr9022405wrd.173.1591875256447; Thu, 11 Jun 2020 04:34:16 -0700 (PDT) Received: from redhat.com (bzq-79-181-55-232.red.bezeqint.net. [79.181.55.232]) by smtp.gmail.com with ESMTPSA id k12sm4673844wrn.42.2020.06.11.04.34.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 04:34:15 -0700 (PDT) Date: Thu, 11 Jun 2020 07:34:14 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Jason Wang , eperezma@redhat.com Subject: [PATCH RFC v8 00/11] vhost: ring format independence Message-ID: <20200611113404.17810-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This still causes corruption issues for people so don't try to use in production please. Posting to expedite debugging. This adds infrastructure required for supporting multiple ring formats. The idea is as follows: we convert descriptors to an independent format first, and process that converting to iov later. Used ring is similar: we fetch into an independent struct first, convert that to IOV later. The point is that we have a tight loop that fetches descriptors, which is good for cache utilization. This will also allow all kind of batching tricks - e.g. it seems possible to keep SMAP disabled while we are fetching multiple descriptors. For used descriptors, this allows keeping track of the buffer length without need to rescan IOV. This seems to perform exactly the same as the original code based on a microbenchmark. Lightly tested. More testing would be very much appreciated. changes from v8: - squashed in fixes. no longer hangs but still known to cause data corruption for some people. under debug. changes from v6: - fixes some bugs introduced in v6 and v5 changes from v5: - addressed comments by Jason: squashed API changes, fixed up discard changes from v4: - added used descriptor format independence - addressed comments by jason - fixed a crash detected by the lkp robot. changes from v3: - fixed error handling in case of indirect descriptors - add BUG_ON to detect buffer overflow in case of bugs in response to comment by Jason Wang - minor code tweaks Changes from v2: - fixed indirect descriptor batching reported by Jason Wang Changes from v1: - typo fixes Michael S. Tsirkin (14): vhost: option to fetch descriptors through an independent struct fixup! vhost: option to fetch descriptors through an independent struct Michael S. Tsirkin (11): vhost: option to fetch descriptors through an independent struct vhost: use batched get_vq_desc version vhost/net: pass net specific struct pointer vhost: reorder functions vhost: format-independent API for used buffers vhost/net: convert to new API: heads->bufs vhost/net: avoid iov length math vhost/test: convert to the buf API vhost/scsi: switch to buf APIs vhost/vsock: switch to the buf API vhost: drop head based APIs drivers/vhost/net.c | 174 +++++++++---------- drivers/vhost/scsi.c | 73 ++++---- drivers/vhost/test.c | 22 +-- drivers/vhost/vhost.c | 378 +++++++++++++++++++++++++++--------------- drivers/vhost/vhost.h | 44 +++-- drivers/vhost/vsock.c | 30 ++-- 6 files changed, 439 insertions(+), 282 deletions(-) -- MST