hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * ION Page Pool kernel interface header
 *
 * Copyright (C) 2011 Google, Inc.
 */
 
#ifndef _ION_PAGE_POOL_H
#define _ION_PAGE_POOL_H
 
#include <linux/mm_types.h>
#include <linux/mutex.h>
#include <linux/shrinker.h>
#include <linux/types.h>
 
/**
 * functions for creating and destroying a heap pool -- allows you
 * to keep a pool of pre allocated memory to use from your heap.  Keeping
 * a pool of memory that is ready for dma, ie any cached mapping have been
 * invalidated from the cache, provides a significant performance benefit on
 * many systems
 */
 
/**
 * struct ion_page_pool - pagepool struct
 * @high_count:        number of highmem items in the pool
 * @low_count:        number of lowmem items in the pool
 * @high_items:        list of highmem items
 * @low_items:        list of lowmem items
 * @mutex:        lock protecting this struct and especially the count
 *            item list
 * @gfp_mask:        gfp_mask to use from alloc
 * @order:        order of pages in the pool
 * @list:        plist node for list of pools
 *
 * Allows you to keep a pool of pre allocated pages to use from your heap.
 * Keeping a pool of pages that is ready for dma, ie any cached mapping have
 * been invalidated from the cache, provides a significant performance benefit
 * on many systems
 */
struct ion_page_pool {
   int high_count;
   int low_count;
   struct list_head high_items;
   struct list_head low_items;
   struct mutex mutex;
   gfp_t gfp_mask;
   unsigned int order;
   struct plist_node list;
};
 
struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order);
void ion_page_pool_destroy(struct ion_page_pool *pool);
struct page *ion_page_pool_alloc(struct ion_page_pool *pool);
void ion_page_pool_free(struct ion_page_pool *pool, struct page *page);
int ion_page_pool_nr_pages(struct ion_page_pool *pool);
 
/** ion_page_pool_shrink - shrinks the size of the memory cached in the pool
 * @pool:        the pool
 * @gfp_mask:        the memory type to reclaim
 * @nr_to_scan:        number of items to shrink in pages
 *
 * returns the number of items freed in pages
 */
int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
            int nr_to_scan);
#endif /* _ION_PAGE_POOL_H */