[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ab87fe6056db226f92cff3dc76ad215d33fee1c7.1674538665.git-series.apopple@nvidia.com>
Date: Tue, 24 Jan 2023 16:42:42 +1100
From: Alistair Popple <apopple@...dia.com>
To: linux-mm@...ck.org, cgroups@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, jgg@...dia.com, jhubbard@...dia.com,
tjmercier@...gle.com, hannes@...xchg.org, surenb@...gle.com,
mkoutny@...e.com, daniel@...ll.ch,
Alistair Popple <apopple@...dia.com>,
Wu Hao <hao.wu@...el.com>, Tom Rix <trix@...hat.com>,
Moritz Fischer <mdf@...nel.org>, Xu Yilun <yilun.xu@...el.com>,
linux-fpga@...r.kernel.org
Subject: [RFC PATCH 13/19] fpga: dfl: afu: convert to use vm_account
To charge pinned pages against the pins cgroup drivers must use the
vm_account_pinned() functions which requires initialisation of a
struct vm_account. Convert the dfl-afu-region code to do this and
charge any pins to the pins cgroup.
Signed-off-by: Alistair Popple <apopple@...dia.com>
Cc: Wu Hao <hao.wu@...el.com>
Cc: Tom Rix <trix@...hat.com>
Cc: Moritz Fischer <mdf@...nel.org>
Cc: Xu Yilun <yilun.xu@...el.com>
Cc: linux-fpga@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
---
drivers/fpga/dfl-afu-dma-region.c | 11 ++++++++---
drivers/fpga/dfl-afu.h | 1 +
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c
index 02b60fd..3b99784 100644
--- a/drivers/fpga/dfl-afu-dma-region.c
+++ b/drivers/fpga/dfl-afu-dma-region.c
@@ -38,7 +38,7 @@ static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata,
struct device *dev = &pdata->dev->dev;
int ret, pinned;
- ret = account_locked_vm(current->mm, npages, true);
+ ret = vm_account_pinned(®ion->vm_account, npages);
if (ret)
return ret;
@@ -67,7 +67,7 @@ static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata,
free_pages:
kfree(region->pages);
unlock_vm:
- account_locked_vm(current->mm, npages, false);
+ vm_unaccount_pinned(®ion->vm_account, npages);
return ret;
}
@@ -87,7 +87,7 @@ static void afu_dma_unpin_pages(struct dfl_feature_platform_data *pdata,
unpin_user_pages(region->pages, npages);
kfree(region->pages);
- account_locked_vm(current->mm, npages, false);
+ vm_unaccount_pinned(®ion->vm_account, npages);
dev_dbg(dev, "%ld pages unpinned\n", npages);
}
@@ -223,6 +223,7 @@ void afu_dma_region_destroy(struct dfl_feature_platform_data *pdata)
afu_dma_unpin_pages(pdata, region);
node = rb_next(node);
+ vm_account_release(®ion->vm_account);
kfree(region);
}
}
@@ -322,6 +323,8 @@ int afu_dma_map_region(struct dfl_feature_platform_data *pdata,
region->user_addr = user_addr;
region->length = length;
+ vm_account_init_current(®ion->vm_account);
+
/* Pin the user memory region */
ret = afu_dma_pin_pages(pdata, region);
if (ret) {
@@ -365,6 +368,7 @@ int afu_dma_map_region(struct dfl_feature_platform_data *pdata,
unpin_pages:
afu_dma_unpin_pages(pdata, region);
free_region:
+ vm_account_release(®ion->vm_account);
kfree(region);
return ret;
}
@@ -399,6 +403,7 @@ int afu_dma_unmap_region(struct dfl_feature_platform_data *pdata, u64 iova)
dma_unmap_page(dfl_fpga_pdata_to_parent(pdata),
region->iova, region->length, DMA_BIDIRECTIONAL);
afu_dma_unpin_pages(pdata, region);
+ vm_account_release(®ion->vm_account);
kfree(region);
return 0;
diff --git a/drivers/fpga/dfl-afu.h b/drivers/fpga/dfl-afu.h
index e5020e2..b1554e0 100644
--- a/drivers/fpga/dfl-afu.h
+++ b/drivers/fpga/dfl-afu.h
@@ -51,6 +51,7 @@ struct dfl_afu_mmio_region {
* @in_use: flag to indicate if this region is in_use.
*/
struct dfl_afu_dma_region {
+ struct vm_account vm_account;
u64 user_addr;
u64 length;
u64 iova;
--
git-series 0.9.1
Powered by blists - more mailing lists