All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: Steve Sistare <steven.sistare@oracle.com>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	Alex Williamson <alex.williamson@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>
Subject: Re: [PATCH V4 3/4] iommufd: Add IOMMU_IOAS_CHANGE_PROCESS
Date: Wed, 13 Nov 2024 10:08:12 -0400	[thread overview]
Message-ID: <20241113140812.GH35230@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB52762A7D90A52DB3FB434F008C5A2@BN9PR11MB5276.namprd11.prod.outlook.com>

On Wed, Nov 13, 2024 at 08:25:45AM +0000, Tian, Kevin wrote:
> > From: Steve Sistare <steven.sistare@oracle.com>
> > Sent: Friday, November 8, 2024 5:47 AM
> > 
> > +int iommufd_ioas_change_process(struct iommufd_ucmd *ucmd)
> > +{
> > +	struct iommu_ioas_change_process *cmd = ucmd->cmd;
> > +	struct iommufd_ctx *ictx = ucmd->ictx;
> > +	unsigned long all_npinned[IOPT_PAGES_ACCOUNT_MODE_NUM] = {};
> > +	struct iommufd_ioas *ioas;
> > +	struct iopt_area *area;
> > +	struct iopt_pages *pages;
> > +	struct xarray ioas_list;
> > +	unsigned long index;
> > +	int rc;
> > +
> > +	if (cmd->__reserved)
> > +		return -EOPNOTSUPP;
> > +
> > +	xa_init(&ioas_list);
> > +	rc = iommufd_take_all_iova_rwsem(ictx, &ioas_list);
> > +	if (rc)
> > +		return rc;
> > +
> > +	for_each_ioas_area(&ioas_list, index, ioas, area)  {
> > +		if (area->pages->type != IOPT_ADDRESS_FILE) {
> > +			rc = -EINVAL;
> > +			goto out;
> > +		}
> > +	}
> 
> this and next loop could be merged into one. It's not a bad idea
> to add cost to a wrong operation while making it slightly more
> efficient in a normal path.

The next loop messes up pages->last_npinned, so if you merge them then
you also have to do a partial restoration of last_npinned and when I
wrote this I thought that restoration was complex enough to be not
worth the optimization..

Jason

  reply	other threads:[~2024-11-13 14:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 21:46 [PATCH V4 0/4] iommufd live update Steve Sistare
2024-11-07 21:46 ` [PATCH V4 1/4] iommufd: Export do_update_pinned Steve Sistare
2024-11-13  8:00   ` Tian, Kevin
2024-11-07 21:46 ` [PATCH V4 2/4] iommufd: Lock all objects Steve Sistare
2024-11-13  8:12   ` Tian, Kevin
2024-11-07 21:46 ` [PATCH V4 3/4] iommufd: Add IOMMU_IOAS_CHANGE_PROCESS Steve Sistare
2024-11-13  8:25   ` Tian, Kevin
2024-11-13 14:08     ` Jason Gunthorpe [this message]
2024-11-07 21:46 ` [PATCH V4 4/4] iommufd: IOMMU_IOAS_CHANGE_PROCESS selftest Steve Sistare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241113140812.GH35230@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=iommu@lists.linux.dev \
    --cc=kevin.tian@intel.com \
    --cc=steven.sistare@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.