Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp823364ybv; Thu, 13 Feb 2020 10:09:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzgCKOoNY6k3CUpxoQ7u2PqIvZIvXAQnLDGOTctzF6gGuiwMj4ku4AifUNTTYR/qRw60V4o X-Received: by 2002:aca:dc04:: with SMTP id t4mr3639356oig.51.1581617366331; Thu, 13 Feb 2020 10:09:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581617366; cv=none; d=google.com; s=arc-20160816; b=qluHgklxvLnVT1RwJEVSEBsvf1LJO7mNjo0WCXAYL/gISJdLZfW/C3U7AXGLS48IaP 79HABb2FdEriSrWgpIPUKYWShODIbat4kDHugNBIOQMKpT3dhxKkhwgbwfu5bVLeAP2y 5b8POY32ax5q7jmxtsUKqzXoaCgtbn4xyyO6/y5AaFEe7TjZCKkGWcComEJkx6ag5QUt 9nDCgTVyvnqSRZOIDCj/0xqC5xDybfm4cGlacVTxm/53Paq2tyUkiUlfrnmIDkebtY77 Yu6NMhcho6riTKs1q68r0A1ma9g+5zPqwh5EzbWjZH0bXCiKsZsL2VGhPMnGkf1VR9Pt oihg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=deHttPInqFs6xYAV0uYMAcNgDa9/Kd+C12ssa7guPmc=; b=rIPua/CKa+mn/kbeQys2myjxMUKbBx8mu0TKBSaSCWjTp7l4wt4Mab9b1a1uXIMukP rPo0etUtJSUKwsq8MYdXpKC1kMt+AHKIsNLpkCY24lnH1fWda6h6PkiDeuDepNso8GIa aDlKLj3ASZ8D/0PgGcBsFJ299VYIuGLHGCPNp2ABYC5MdF7Hl0QT9Q99F8NtFUidjyQ6 o46btOHlvN0ODUsz61dOn0+wWVUwf6hI/CJM2nRizqvhVPLR35fXJDNs9LAENiYB8D2s Oe9QaEUFAEn1RXoJCN1rQyj+kntncXIn8ouNvDJ9kuYAItbqWHjRBu5vpvnsv42QMKlb AXmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AVDeWbsg; 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=pass (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 l14si1438574oic.222.2020.02.13.10.09.13; Thu, 13 Feb 2020 10:09:26 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AVDeWbsg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727803AbgBMSI3 (ORCPT + 99 others); Thu, 13 Feb 2020 13:08:29 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:51352 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727669AbgBMSI2 (ORCPT ); Thu, 13 Feb 2020 13:08:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581617305; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=deHttPInqFs6xYAV0uYMAcNgDa9/Kd+C12ssa7guPmc=; b=AVDeWbsgsxiMA6Au4vxlvEpfXcxDgNnRiYttHE1ra50tLdYcyoV0XwRFprDpzhxEkTSA9/ WNQrOVQn4zka0Qx1Pm2tFiExmczqGTZGPEeb2j95WtBRZeMbo+Z9AE6CJaEKiMX0PogwEQ Vqd9yKvdh9LaQo1SXqBnJwN8OUfQWcU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-iTjufJ3TOB2pFQOEgpdEsg-1; Thu, 13 Feb 2020 13:08:23 -0500 X-MC-Unique: iTjufJ3TOB2pFQOEgpdEsg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8AA217A583; Thu, 13 Feb 2020 18:08:21 +0000 (UTC) Received: from gondolin (ovpn-117-100.ams2.redhat.com [10.36.117.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DF891000325; Thu, 13 Feb 2020 18:08:16 +0000 (UTC) Date: Thu, 13 Feb 2020 19:08:13 +0100 From: Cornelia Huck To: Alex Williamson Cc: kvm@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, dev@dpdk.org, mtosatti@redhat.com, thomas@monjalon.net, bluca@debian.org, jerinjacobk@gmail.com, bruce.richardson@intel.com Subject: Re: [PATCH 4/7] vfio: Introduce VFIO_DEVICE_FEATURE ioctl and first user Message-ID: <20200213190813.1bcd1a15.cohuck@redhat.com> In-Reply-To: <20200213103957.0d75034b@w520.home> References: <158145472604.16827.15751375540102298130.stgit@gimli.home> <158146235133.16827.7215789038918853214.stgit@gimli.home> <20200213134121.54b8debb.cohuck@redhat.com> <20200213103957.0d75034b@w520.home> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Feb 2020 10:39:57 -0700 Alex Williamson wrote: > On Thu, 13 Feb 2020 13:41:21 +0100 > Cornelia Huck wrote: > > > On Tue, 11 Feb 2020 16:05:51 -0700 > > Alex Williamson wrote: > > > +struct vfio_device_feature { > > > + __u32 argsz; > > > + __u32 flags; > > > +#define VFIO_DEVICE_FEATURE_MASK (0xffff) /* 16-bit feature index */ > > > +#define VFIO_DEVICE_FEATURE_GET (1 << 16) /* Get feature into data[] */ > > > +#define VFIO_DEVICE_FEATURE_SET (1 << 17) /* Set feature from data[] */ > > > +#define VFIO_DEVICE_FEATURE_PROBE (1 << 18) /* Probe feature support */ > > > + __u8 data[]; > > > +}; > > > > I'm not sure I'm a fan of cramming both feature selection and operation > > selection into flags. What about: > > > > struct vfio_device_feature { > > __u32 argsz; > > __u32 flags; > > /* GET/SET/PROBE #defines */ > > __u32 feature; > > __u8 data[]; > > }; > > Then data is unaligned so we either need to expand feature or add > padding. So this makes the structure at least 8 bytes bigger and buys > us...? What's so special about the bottom half of flags that we can't > designate it as the flags that specify the feature? We still have > another 13 bits of flags for future use. It is more my general dislike of bit fiddling here, no strong objection, certainly. > > > Getting/setting more than one feature at the same time does not sound > > like a common use case; you would need to specify some kind of > > algorithm for that anyway, and just doing it individually seems much > > easier than that. > > Yup. I just figured 2^16 features is a nice way to make use of the > structure vs 2^32 features and 4 bytes of padding or 2^64 features. I > don't think I'm being optimistic in thinking we'll have far less than > 16K features and we can always reserve feature 0xffff as an extended > feature where the first 8-bytes of data defines that extended feature > index. Agreed, we're probably not going to end up with a flood of features here. Anyway, much of this seems to be a matter of personal taste, so let's keep it as it is.