Lines Matching refs:size
133 * On systems with 4K page size, this gives 255 size classes! There is a
135 * - Large number of size classes is potentially wasteful as free page are
137 * - Small number of size classes causes large internal fragmentation
138 * - Probably its better to use specific size classes (empirically
191 int size;
369 static int zs_zpool_malloc(void *pool, size_t size, gfp_t gfp,
372 *handle = zs_malloc(pool, size, gfp);
504 * zsmalloc divides the pool into various size classes where each
507 * classes depending on its size. This function returns index of the
508 * size class which has chunk size big enough to hold the given size.
510 static int get_size_class_index(int size)
514 if (likely(size > ZS_MIN_ALLOC_SIZE))
515 idx = DIV_ROUND_UP(size - ZS_MIN_ALLOC_SIZE,
569 "class", "size", "10%", "20%", "30%", "40%",
583 seq_printf(s, " %5u %5u ", i, class->size);
660 * For each size class, zspages are divided into different groups
686 * Each size class maintains various freelists and zspages are assigned
714 * Each size class maintains zspages in different fullness groups depending
916 while ((off += class->size) < PAGE_SIZE) {
918 link += class->size / sizeof(*link);
978 * Allocate a zspage for the given size class
1054 struct page *pages[2], int off, int size)
1068 sizes[1] = size - sizes[0];
1082 struct page *pages[2], int off, int size)
1094 size -= ZS_HANDLE_SIZE;
1098 sizes[1] = size - sizes[0];
1152 * that hold objects of the provided size.
1154 * @size: object size
1159 * provided size.
1161 unsigned int zs_lookup_class_index(struct zs_pool *pool, unsigned int size)
1165 class = pool->size_class[get_size_class_index(size)];
1228 off = offset_in_page(class->size * obj_idx);
1233 if (off + class->size <= PAGE_SIZE) {
1245 ret = __zs_map_object(area, pages, off, class->size);
1268 off = offset_in_page(class->size * obj_idx);
1271 if (off + class->size <= PAGE_SIZE)
1280 __zs_unmap_object(area, pages, off, class->size);
1289 * zs_huge_class_size() - Returns the size (in bytes) of the first huge
1293 * The function returns the size of the first huge class - any object of equal
1294 * or bigger size will be stored in zspage consisting of a single physical
1299 * Return: the size (in bytes) of the first huge zsmalloc &size_class.
1323 offset = obj * class->size;
1351 * zs_malloc - Allocate block of given size from pool.
1353 * @size: size of block to allocate
1358 * Allocation requests with size > ZS_MAX_ALLOC_SIZE will fail.
1360 unsigned long zs_malloc(struct zs_pool *pool, size_t size, gfp_t gfp)
1367 if (unlikely(!size || size > ZS_MAX_ALLOC_SIZE))
1375 size += ZS_HANDLE_SIZE;
1376 class = pool->size_class[get_size_class_index(size)];
1467 obj_free(class->size, obj);
1485 int s_size, d_size, size;
1488 s_size = d_size = class->size;
1493 s_off = offset_in_page(class->size * s_objidx);
1494 d_off = offset_in_page(class->size * d_objidx);
1496 if (s_off + class->size > PAGE_SIZE)
1499 if (d_off + class->size > PAGE_SIZE)
1506 size = min(s_size, d_size);
1507 memcpy(d_addr + d_off, s_addr + s_off, size);
1508 written += size;
1510 if (written == class->size)
1513 s_off += size;
1514 s_size -= size;
1515 d_off += size;
1516 d_size -= size;
1531 s_size = class->size - written;
1539 d_size = class->size - written;
1561 offset += class->size * index;
1567 offset += class->size;
1602 obj_free(class->size, used_obj);
1846 addr += class->size) {
2191 * Iterate reversely, because, size of size_class that we want to use
2192 * for merging should be larger or equal to current size.
2195 int size;
2201 size = ZS_MIN_ALLOC_SIZE + i * ZS_SIZE_CLASS_DELTA;
2202 if (size > ZS_MAX_ALLOC_SIZE)
2203 size = ZS_MAX_ALLOC_SIZE;
2204 pages_per_zspage = calculate_zspage_chain_size(size);
2205 objs_per_zspage = pages_per_zspage * PAGE_SIZE / size;
2209 * so huge_class_size holds the size of the first huge
2215 huge_class_size = size;
2219 * unconditionally adds handle size before it performs
2220 * size class search - so object may be smaller than
2221 * huge class size, yet it still can end up in the huge
2230 * as alloc/free for that size. Although it is natural that we
2231 * have one size_class for each size, there is a chance that we
2248 class->size = size;
2305 class->size, fg);