Lines Matching refs:entry

694 static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry)  in mem_cgroup_from_entry()  argument
696 return entry->objcg ? obj_cgroup_memcg(entry->objcg) : NULL; in mem_cgroup_from_entry()
699 static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry) in mem_cgroup_from_entry() argument
705 static inline int entry_to_nid(struct zswap_entry *entry) in entry_to_nid() argument
707 return page_to_nid(virt_to_page(entry)); in entry_to_nid()
710 static void zswap_lru_add(struct list_lru *list_lru, struct zswap_entry *entry) in zswap_lru_add() argument
712 int nid = entry_to_nid(entry); in zswap_lru_add()
727 memcg = mem_cgroup_from_entry(entry); in zswap_lru_add()
729 list_lru_add(list_lru, &entry->lru, nid, memcg); in zswap_lru_add()
733 static void zswap_lru_del(struct list_lru *list_lru, struct zswap_entry *entry) in zswap_lru_del() argument
735 int nid = entry_to_nid(entry); in zswap_lru_del()
739 memcg = mem_cgroup_from_entry(entry); in zswap_lru_del()
741 list_lru_del(list_lru, &entry->lru, nid, memcg); in zswap_lru_del()
789 struct zswap_entry *entry; in zswap_entry_cache_alloc() local
790 entry = kmem_cache_alloc_node(zswap_entry_cache, gfp, nid); in zswap_entry_cache_alloc()
791 if (!entry) in zswap_entry_cache_alloc()
793 return entry; in zswap_entry_cache_alloc()
796 static void zswap_entry_cache_free(struct zswap_entry *entry) in zswap_entry_cache_free() argument
798 kmem_cache_free(zswap_entry_cache, entry); in zswap_entry_cache_free()
805 static void zswap_entry_free(struct zswap_entry *entry) in zswap_entry_free() argument
807 zswap_lru_del(&zswap_list_lru, entry); in zswap_entry_free()
808 zpool_free(entry->pool->zpool, entry->handle); in zswap_entry_free()
809 zswap_pool_put(entry->pool); in zswap_entry_free()
810 if (entry->objcg) { in zswap_entry_free()
811 obj_cgroup_uncharge_zswap(entry->objcg, entry->length); in zswap_entry_free()
812 obj_cgroup_put(entry->objcg); in zswap_entry_free()
814 zswap_entry_cache_free(entry); in zswap_entry_free()
940 static bool zswap_compress(struct page *page, struct zswap_entry *entry, in zswap_compress() argument
989 entry->handle = handle; in zswap_compress()
990 entry->length = dlen; in zswap_compress()
1004 static bool zswap_decompress(struct zswap_entry *entry, struct folio *folio) in zswap_decompress() argument
1006 struct zpool *zpool = entry->pool->zpool; in zswap_decompress()
1012 acomp_ctx = acomp_ctx_get_cpu_lock(entry->pool); in zswap_decompress()
1013 obj = zpool_obj_read_begin(zpool, entry->handle, acomp_ctx->buffer); in zswap_decompress()
1024 memcpy(acomp_ctx->buffer, obj, entry->length); in zswap_decompress()
1028 sg_init_one(&input, src, entry->length); in zswap_decompress()
1031 acomp_request_set_params(acomp_ctx->req, &input, &output, entry->length, PAGE_SIZE); in zswap_decompress()
1035 zpool_obj_read_end(zpool, entry->handle, obj); in zswap_decompress()
1043 swp_type(entry->swpentry), in zswap_decompress()
1044 swp_offset(entry->swpentry), in zswap_decompress()
1045 entry->pool->tfm_name, entry->length, dlen); in zswap_decompress()
1064 static int zswap_writeback_entry(struct zswap_entry *entry, in zswap_writeback_entry() argument
1109 if (entry != xa_load(tree, offset)) { in zswap_writeback_entry()
1114 if (!zswap_decompress(entry, folio)) { in zswap_writeback_entry()
1122 if (entry->objcg) in zswap_writeback_entry()
1123 count_objcg_events(entry->objcg, ZSWPWB, 1); in zswap_writeback_entry()
1125 zswap_entry_free(entry); in zswap_writeback_entry()
1173 struct zswap_entry *entry = container_of(item, struct zswap_entry, lru); in shrink_memcg_cb() local
1184 if (entry->referenced) { in shrink_memcg_cb()
1185 entry->referenced = false; in shrink_memcg_cb()
1221 swpentry = entry->swpentry; in shrink_memcg_cb()
1229 writeback_result = zswap_writeback_entry(entry, swpentry); in shrink_memcg_cb()
1483 struct zswap_entry *entry, *old; in zswap_store_page() local
1486 entry = zswap_entry_cache_alloc(GFP_KERNEL, page_to_nid(page)); in zswap_store_page()
1487 if (!entry) { in zswap_store_page()
1492 if (!zswap_compress(page, entry, pool)) in zswap_store_page()
1497 entry, GFP_KERNEL); in zswap_store_page()
1524 obj_cgroup_charge_zswap(objcg, entry->length); in zswap_store_page()
1538 entry->pool = pool; in zswap_store_page()
1539 entry->swpentry = page_swpentry; in zswap_store_page()
1540 entry->objcg = objcg; in zswap_store_page()
1541 entry->referenced = true; in zswap_store_page()
1542 if (entry->length) { in zswap_store_page()
1543 INIT_LIST_HEAD(&entry->lru); in zswap_store_page()
1544 zswap_lru_add(&zswap_list_lru, entry); in zswap_store_page()
1550 zpool_free(pool->zpool, entry->handle); in zswap_store_page()
1552 zswap_entry_cache_free(entry); in zswap_store_page()
1628 struct zswap_entry *entry; in zswap_store() local
1633 entry = xa_erase(tree, offset + index); in zswap_store()
1634 if (entry) in zswap_store()
1635 zswap_entry_free(entry); in zswap_store()
1668 struct zswap_entry *entry; in zswap_load() local
1685 entry = xa_load(tree, offset); in zswap_load()
1686 if (!entry) in zswap_load()
1689 if (!zswap_decompress(entry, folio)) { in zswap_load()
1697 if (entry->objcg) in zswap_load()
1698 count_objcg_events(entry->objcg, ZSWPIN, 1); in zswap_load()
1715 zswap_entry_free(entry); in zswap_load()
1726 struct zswap_entry *entry; in zswap_invalidate() local
1731 entry = xa_erase(tree, offset); in zswap_invalidate()
1732 if (entry) in zswap_invalidate()
1733 zswap_entry_free(entry); in zswap_invalidate()