Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp451483ybb; Fri, 3 Apr 2020 06:01:32 -0700 (PDT) X-Google-Smtp-Source: APiQypJqW5mWWodhZva7vOgfA/U8Qw7oeq0lYS71TLrj542alxxChZDjDxfgbsDFSgXnYNSGov1K X-Received: by 2002:a9d:d52:: with SMTP id 76mr6261805oti.307.1585918892687; Fri, 03 Apr 2020 06:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585918892; cv=none; d=google.com; s=arc-20160816; b=lL+BVmJglKP2uKLE3gqN5DsnDZ06yqLLxdSA/SG0OzFpQyosGJ9CqoQOLzBPum6Xta BdatZHHrxNGpYfOtD2GVCXyQMd5DKtkIJwjRCohEKlAZeITVuuxx5gJaDN+d8p7aZRH4 IjWD3I6SURe1M0gvkwGty7QhUzDCDEz971Ke/yFMaLjIav6ISh7qWSo1vmdn5FQbzY91 jURDCl3u3j41uRttI/UefU06WyxiHHDFagfexkcDpLzQLuKmFmmeUySEyyF0A3asUMjK xfloLt0WvjPlubEL5VTpmGCYef0Nv6dibjUmZZ9RD8buT1JyC0L4cvdLCRkH822xNL7R LBXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=4UoTuchVPcQbessFRne4dgixRRmQ3IULpwTbXSdSKjI=; b=toIalZmXS3pJVOy5WJ7p1spKgItp6a9ZCClNyHq0jTFBwbSFOWItdhmJrx1Q35FB/G om1HpnPaS+hCso4/JwrvH+zJVgBxWYtArJ9Az0z/1KNgeeDaIYPvZPk7McxhFAm8w5qh 3iGZQzS2WCM3jvvs9FxsPsmNGfV9iUm0VIf/Vv3Q5Jr0lQ9PgP6auob3/rm2l/2LrSpS 5s6CRmv4ty73G5eWw7NwrzSywbIfwGG76vIlpAM3E0vLY6FvDZJEfgrEDCp+E56VZv+P ltXoLXKlaZcz/N2DF+HW8cVgSskVjuV4A4o6MJVLcK6HmGDbSv6XSfa4Q6jvchaC8H/9 Flpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ptml5nxS; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s28si3765467oij.120.2020.04.03.06.01.18; Fri, 03 Apr 2020 06:01:32 -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; dkim=pass header.i=@linaro.org header.s=google header.b=ptml5nxS; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728119AbgDCMkD (ORCPT + 99 others); Fri, 3 Apr 2020 08:40:03 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37907 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728049AbgDCMkC (ORCPT ); Fri, 3 Apr 2020 08:40:02 -0400 Received: by mail-wr1-f68.google.com with SMTP id c7so8328236wrx.5 for ; Fri, 03 Apr 2020 05:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4UoTuchVPcQbessFRne4dgixRRmQ3IULpwTbXSdSKjI=; b=ptml5nxSRSHJqKFQi24/vBmgB1JRiVOfz6FKiC4gpmUxkWrdbIyK3uvOqzLg5W8uwh yk1CyLp9obg1oU+Hr7N6V0Qazv6OJMEPqjaiFOV+KsBE1iJSqdyMfGbI2Rl+ueZPP0RD q7v1i7bZgnoLW05nP9LCgF1a+3JHpfALZxf0xfNQn1SzUNgm31+sKib0d1IHusr6S6GN S3M6fCUQu+ra4TFkCP3PW0+YRlA/SrhwExhXWORiYZ0CKq/Y1szY6G0V/0lW1/+ql3PT vjcqmIc/VrpfqtHRjppi/1GU3b/+N4+HcwayMIoWnVrI9mhF+z3SZAPdivgHOcuQhmg3 M9WA== 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:references :mime-version:content-disposition:in-reply-to; bh=4UoTuchVPcQbessFRne4dgixRRmQ3IULpwTbXSdSKjI=; b=ious6ABn5EHvB+ph9EdeTxF2xGvWC8LisJwE9ah9eTn3f8Vj6FNBz3B8TfRNHK6jrW pmN/dMj2CO0eUJpQS3NNQ22bZFZpZN/eZoZ1dstfJ0i8+DeAEVUBCYe981QGQiXtE537 h6tVCmMedmy7S8gWe8HhMiG2tiPKDZKYlRO5isGcn7iZ3aalso4ehZU/uasuNnp6Dms/ i/Nh5ka+hz+Pyw2C5lPNujuN/gGmpgTrzBoCP7aQcJz35Q0rZyY+VYhdIgqJbZchj6Ng o4YciBj986tiAUMBnpn8mY9Hm9LK5l10FajJWNxrnEs9YJ3v8sCXFwpYk5WiW9mEdlE7 n4fw== X-Gm-Message-State: AGi0PuaatSPkafrs4fIFdwM6zgPKNewRw+fNonpWJiAJAuU4+M5VPR7K YWs3Uo1Rz/MED2ntxXbPqPIWTw== X-Received: by 2002:a5d:44c3:: with SMTP id z3mr8800515wrr.284.1585917599670; Fri, 03 Apr 2020 05:39:59 -0700 (PDT) Received: from myrica ([2001:171b:226b:54a0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id 91sm5994296wrf.79.2020.04.03.05.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 05:39:59 -0700 (PDT) Date: Fri, 3 Apr 2020 14:39:51 +0200 From: Jean-Philippe Brucker To: "Liu, Yi L" Cc: "alex.williamson@redhat.com" , "eric.auger@redhat.com" , "Tian, Kevin" , "jacob.jun.pan@linux.intel.com" , "joro@8bytes.org" , "Raj, Ashok" , "Tian, Jun J" , "Sun, Yi Y" , "peterx@redhat.com" , "iommu@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Wu, Hao" Subject: Re: [PATCH v1 1/8] vfio: Add VFIO_IOMMU_PASID_REQUEST(alloc/free) Message-ID: <20200403123951.GA1410438@myrica> References: <1584880325-10561-1-git-send-email-yi.l.liu@intel.com> <1584880325-10561-2-git-send-email-yi.l.liu@intel.com> <20200402135240.GE1176452@myrica> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 03, 2020 at 11:56:09AM +0000, Liu, Yi L wrote: > > > /** > > > + * VFIO_MM objects - create, release, get, put, search > > > + * Caller of the function should have held vfio.vfio_mm_lock. > > > + */ > > > +static struct vfio_mm *vfio_create_mm(struct mm_struct *mm) > > > +{ > > > + struct vfio_mm *vmm; > > > + struct vfio_mm_token *token; > > > + int ret = 0; > > > + > > > + vmm = kzalloc(sizeof(*vmm), GFP_KERNEL); > > > + if (!vmm) > > > + return ERR_PTR(-ENOMEM); > > > + > > > + /* Per mm IOASID set used for quota control and group operations */ > > > + ret = ioasid_alloc_set((struct ioasid_set *) mm, > > > > Hmm, either we need to change the token of ioasid_alloc_set() to "void *", > > or pass an actual ioasid_set struct, but this cast doesn't look good :) > > > > As I commented on the IOASID series, I think we could embed a struct > > ioasid_set into vfio_mm, pass that struct to all other ioasid_* functions, > > and get rid of ioasid_sid. > > I think change to "void *" is better as we needs the token to ensure all > threads within a single VM share the same ioasid_set. Don't they share the same vfio_mm? Thanks, Jean > > > > + VFIO_DEFAULT_PASID_QUOTA, &vmm->ioasid_sid); > > > + if (ret) { > > > + kfree(vmm); > > > + return ERR_PTR(ret); > > > + } > > > + > > > + kref_init(&vmm->kref); > > > + token = &vmm->token; > > > + token->val = mm; > > > > Why the intermediate token struct? Could we just store the mm_struct > > pointer within vfio_mm? > > Hmm, here we only want to use the pointer as a token, instead of using > the structure behind the pointer. If store the mm_struct directly, may > leave a space to further use its content, this is not good. > > Regards, > Yi Liu >