diff options
Diffstat (limited to 'mm/zbud.c')
-rw-r--r-- | mm/zbud.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -60,15 +60,17 @@ | |||
60 | * NCHUNKS_ORDER determines the internal allocation granularity, effectively | 60 | * NCHUNKS_ORDER determines the internal allocation granularity, effectively |
61 | * adjusting internal fragmentation. It also determines the number of | 61 | * adjusting internal fragmentation. It also determines the number of |
62 | * freelists maintained in each pool. NCHUNKS_ORDER of 6 means that the | 62 | * freelists maintained in each pool. NCHUNKS_ORDER of 6 means that the |
63 | * allocation granularity will be in chunks of size PAGE_SIZE/64, and there | 63 | * allocation granularity will be in chunks of size PAGE_SIZE/64. As one chunk |
64 | * will be 64 freelists per pool. | 64 | * in allocated page is occupied by zbud header, NCHUNKS will be calculated to |
65 | * 63 which shows the max number of free chunks in zbud page, also there will be | ||
66 | * 63 freelists per pool. | ||
65 | */ | 67 | */ |
66 | #define NCHUNKS_ORDER 6 | 68 | #define NCHUNKS_ORDER 6 |
67 | 69 | ||
68 | #define CHUNK_SHIFT (PAGE_SHIFT - NCHUNKS_ORDER) | 70 | #define CHUNK_SHIFT (PAGE_SHIFT - NCHUNKS_ORDER) |
69 | #define CHUNK_SIZE (1 << CHUNK_SHIFT) | 71 | #define CHUNK_SIZE (1 << CHUNK_SHIFT) |
70 | #define NCHUNKS (PAGE_SIZE >> CHUNK_SHIFT) | ||
71 | #define ZHDR_SIZE_ALIGNED CHUNK_SIZE | 72 | #define ZHDR_SIZE_ALIGNED CHUNK_SIZE |
73 | #define NCHUNKS ((PAGE_SIZE - ZHDR_SIZE_ALIGNED) >> CHUNK_SHIFT) | ||
72 | 74 | ||
73 | /** | 75 | /** |
74 | * struct zbud_pool - stores metadata for each zbud pool | 76 | * struct zbud_pool - stores metadata for each zbud pool |
@@ -268,10 +270,9 @@ static int num_free_chunks(struct zbud_header *zhdr) | |||
268 | { | 270 | { |
269 | /* | 271 | /* |
270 | * Rather than branch for different situations, just use the fact that | 272 | * Rather than branch for different situations, just use the fact that |
271 | * free buddies have a length of zero to simplify everything. -1 at the | 273 | * free buddies have a length of zero to simplify everything. |
272 | * end for the zbud header. | ||
273 | */ | 274 | */ |
274 | return NCHUNKS - zhdr->first_chunks - zhdr->last_chunks - 1; | 275 | return NCHUNKS - zhdr->first_chunks - zhdr->last_chunks; |
275 | } | 276 | } |
276 | 277 | ||
277 | /***************** | 278 | /***************** |