diff options
author | Juergen Gross <jgross@suse.com> | 2020-12-07 08:31:22 +0100 |
---|---|---|
committer | Juergen Gross <jgross@suse.com> | 2020-12-09 10:31:37 +0100 |
commit | ca33479cc7be2c9b5f8be078c8bf3ac26b7d6186 (patch) | |
tree | 8877168fff59f8955f29ddaf37a0ac6a0cb3d9fd /include/xen | |
parent | a68a0262abdaa251e12c53715f48e698a18ef402 (diff) | |
download | lwn-ca33479cc7be2c9b5f8be078c8bf3ac26b7d6186.tar.gz lwn-ca33479cc7be2c9b5f8be078c8bf3ac26b7d6186.zip |
xen: add helpers for caching grant mapping pages
Instead of having similar helpers in multiple backend drivers use
common helpers for caching pages allocated via gnttab_alloc_pages().
Make use of those helpers in blkback and scsiback.
Cc: <stable@vger.kernel.org> # 5.9
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovksy@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Diffstat (limited to 'include/xen')
-rw-r--r-- | include/xen/grant_table.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h index 9bc5bc07d4d3..c6ef8ffc1a09 100644 --- a/include/xen/grant_table.h +++ b/include/xen/grant_table.h @@ -198,6 +198,19 @@ void gnttab_free_auto_xlat_frames(void); int gnttab_alloc_pages(int nr_pages, struct page **pages); void gnttab_free_pages(int nr_pages, struct page **pages); +struct gnttab_page_cache { + spinlock_t lock; + struct list_head pages; + unsigned int num_pages; +}; + +void gnttab_page_cache_init(struct gnttab_page_cache *cache); +int gnttab_page_cache_get(struct gnttab_page_cache *cache, struct page **page); +void gnttab_page_cache_put(struct gnttab_page_cache *cache, struct page **page, + unsigned int num); +void gnttab_page_cache_shrink(struct gnttab_page_cache *cache, + unsigned int num); + #ifdef CONFIG_XEN_GRANT_DMA_ALLOC struct gnttab_dma_alloc_args { /* Device for which DMA memory will be/was allocated. */ |