From: Alistair Popple <apopple@nvidia•com>
To: "Michael S. Tsirkin" <mst@redhat•com>
Cc: linux-mm@kvack•org, cgroups@vger•kernel.org,
linux-kernel@vger•kernel.org, jgg@nvidia•com,
jhubbard@nvidia•com, tjmercier@google•com, hannes@cmpxchg•org,
surenb@google•com, mkoutny@suse•com, daniel@ffwll•ch,
Jason Wang <jasowang@redhat•com>,
kvm@vger•kernel.org, virtualization@lists•linux-foundation.org,
netdev@vger•kernel.org
Subject: Re: [RFC PATCH 02/19] drivers/vhost: Convert to use vm_account
Date: Mon, 30 Jan 2023 21:43:52 +1100 [thread overview]
Message-ID: <87357s1dwf.fsf@nvidia.com> (raw)
In-Reply-To: <20230124005356-mutt-send-email-mst@kernel.org>
"Michael S. Tsirkin" <mst@redhat•com> writes:
> On Tue, Jan 24, 2023 at 04:42:31PM +1100, Alistair Popple wrote:
>> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
>> index ec32f78..a31dd53 100644
>> --- a/drivers/vhost/vdpa.c
>> +++ b/drivers/vhost/vdpa.c
>
> ...
>
>> @@ -780,6 +780,10 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb,
>> u32 asid = iotlb_to_asid(iotlb);
>> int r = 0;
>>
>> + if (!vdpa->use_va)
>> + if (vm_account_pinned(&dev->vm_account, PFN_DOWN(size)))
>> + return -ENOMEM;
>> +
>> r = vhost_iotlb_add_range_ctx(iotlb, iova, iova + size - 1,
>> pa, perm, opaque);
>> if (r)
>
> I suspect some error handling will have to be reworked then, no?
Thanks. I had meant to go back and double check some of these driver
conversions. Will add something like below:
@@ -787,7 +787,7 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb,
r = vhost_iotlb_add_range_ctx(iotlb, iova, iova + size - 1,
pa, perm, opaque);
if (r)
- return r;
+ goto out_unaccount;
if (ops->dma_map) {
r = ops->dma_map(vdpa, asid, iova, size, pa, perm, opaque);
@@ -798,12 +798,14 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb,
r = iommu_map(v->domain, iova, pa, size,
perm_to_iommu_flags(perm));
}
- if (r) {
+ if (r)
vhost_iotlb_del_range(iotlb, iova, iova + size - 1);
- return r;
- }
- return 0;
+out_unaccount:
+ if (!vdpa->use_va)
+ vm_unaccount_pinned(&dev->vm_account, PFN_DOWN(size));
+
+ return r;
}
static void vhost_vdpa_unmap(struct vhost_vdpa *v,
>> --
>> git-series 0.9.1
next prev parent reply other threads:[~2023-01-30 11:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.f52b9eb2792bccb8a9ecd6bc95055705cfe2ae03.1674538665.git-series.apopple@nvidia.com>
2023-01-24 5:42 ` [RFC PATCH 01/19] mm: Introduce vm_account Alistair Popple
2023-01-24 6:29 ` Christoph Hellwig
2023-01-24 14:32 ` Jason Gunthorpe
2023-01-30 11:36 ` Alistair Popple
2023-01-31 14:00 ` David Hildenbrand
2023-01-24 5:42 ` [RFC PATCH 02/19] drivers/vhost: Convert to use vm_account Alistair Popple
2023-01-24 5:55 ` Michael S. Tsirkin
2023-01-30 10:43 ` Alistair Popple [this message]
2023-01-24 14:34 ` Jason Gunthorpe
2023-01-24 5:42 ` [RFC PATCH 10/19] net: skb: Switch to using vm_account Alistair Popple
2023-01-24 14:51 ` Jason Gunthorpe
2023-01-30 11:17 ` Alistair Popple
2023-02-06 4:36 ` Alistair Popple
2023-02-06 13:14 ` Jason Gunthorpe
2023-01-24 5:42 ` [RFC PATCH 11/19] xdp: convert to use vm_account Alistair Popple
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=87357s1dwf.fsf@nvidia.com \
--to=apopple@nvidia$(echo .)com \
--cc=cgroups@vger$(echo .)kernel.org \
--cc=daniel@ffwll$(echo .)ch \
--cc=hannes@cmpxchg$(echo .)org \
--cc=jasowang@redhat$(echo .)com \
--cc=jgg@nvidia$(echo .)com \
--cc=jhubbard@nvidia$(echo .)com \
--cc=kvm@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-mm@kvack$(echo .)org \
--cc=mkoutny@suse$(echo .)com \
--cc=mst@redhat$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=surenb@google$(echo .)com \
--cc=tjmercier@google$(echo .)com \
--cc=virtualization@lists$(echo .)linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox