XenevaOS
Loading...
Searching...
No Matches
folio_batch.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * include/linux/folio_batch.h
4 *
5 * In many places it is efficient to batch an operation up against multiple
6 * folios. A folio_batch is a container which is used for that.
7 */
8
9#ifndef _LINUX_FOLIO_BATCH_H
10#define _LINUX_FOLIO_BATCH_H
11
12#include <linux/types.h>
13
14/* 31 pointers + header align the folio_batch structure to a power of two */
15#define FOLIO_BATCH_SIZE 31
16
17struct folio;
18
29 unsigned char nr;
30 unsigned char i;
33};
34
41static inline void folio_batch_init(struct folio_batch *fbatch)
42{
43 fbatch->nr = 0;
44 fbatch->i = 0;
45 fbatch->percpu_pvec_drained = false;
46}
47
48static inline void folio_batch_reinit(struct folio_batch *fbatch)
49{
50 fbatch->nr = 0;
51 fbatch->i = 0;
52}
53
54static inline unsigned int folio_batch_count(const struct folio_batch *fbatch)
55{
56 return fbatch->nr;
57}
58
59static inline unsigned int folio_batch_space(const struct folio_batch *fbatch)
60{
61 return FOLIO_BATCH_SIZE - fbatch->nr;
62}
63
74static inline unsigned folio_batch_add(struct folio_batch *fbatch,
75 struct folio *folio)
76{
77 fbatch->folios[fbatch->nr++] = folio;
78 return folio_batch_space(fbatch);
79}
80
89static inline struct folio *folio_batch_next(struct folio_batch *fbatch)
90{
91 if (fbatch->i == fbatch->nr)
92 return NULL;
93 return fbatch->folios[fbatch->i++];
94}
95
97
98static inline void folio_batch_release(struct folio_batch *fbatch)
99{
100 if (folio_batch_count(fbatch))
101 __folio_batch_release(fbatch);
102}
103
105#endif /* _LINUX_FOLIO_BATCH_H */
#define NULL
Definition actypes.h:561
void __folio_batch_release(struct folio_batch *fbatch)
void folio_batch_remove_exceptionals(struct folio_batch *fbatch)
#define FOLIO_BATCH_SIZE
Definition folio_batch.h:15
Definition folio_batch.h:28
bool percpu_pvec_drained
Definition folio_batch.h:31
unsigned char i
Definition folio_batch.h:30
unsigned char nr
Definition folio_batch.h:29
struct folio * folios[FOLIO_BATCH_SIZE]
Definition folio_batch.h:32
Definition mm_types.h:16