Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

zram: rename internal slot API

We have a somewhat confusing internal API naming. E.g. the following
code:

zram_slot_lock()
if (zram_allocated())
zram_set_flag()
zram_slot_unlock()

may look like it does something on zram device level, but in fact it tests
and sets slot entry flags, not the device ones.

Rename API to explicitly distinguish functions that operate on the slot
level from functions that operate on the zram device level.

While at it, fixup some coding styles.

[senozhatsky@chromium.org: fix up mark_slot_accessed()]
Link: https://lkml.kernel.org/r/20260115031922.3813659-1-senozhatsky@chromium.org
Link: https://lkml.kernel.org/r/775a0b1a0ace5caf1f05965d8bc637c1192820fa.1765775954.git.senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Brian Geffon <bgeffon@google.com>
Cc: David Stevens <stevensd@google.com>
Cc: Minchan Kim <minchan@google.com>
Cc: Richard Chang <richardycc@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sergey Senozhatsky and committed by
Andrew Morton
bde60fe7 2e8ff2f5

+182 -181
+182 -181
drivers/block/zram/zram_drv.c
··· 56 56 57 57 static const struct block_device_operations zram_devops; 58 58 59 - static void zram_slot_free(struct zram *zram, u32 index); 59 + static void slot_free(struct zram *zram, u32 index); 60 60 #define slot_dep_map(zram, index) (&(zram)->table[(index)].dep_map) 61 61 62 - static void zram_slot_lock_init(struct zram *zram, u32 index) 62 + static void slot_lock_init(struct zram *zram, u32 index) 63 63 { 64 64 static struct lock_class_key __key; 65 65 ··· 79 79 * 4) Use TRY lock variant when in atomic context 80 80 * - must check return value and handle locking failers 81 81 */ 82 - static __must_check bool zram_slot_trylock(struct zram *zram, u32 index) 82 + static __must_check bool slot_trylock(struct zram *zram, u32 index) 83 83 { 84 84 unsigned long *lock = &zram->table[index].__lock; 85 85 ··· 92 92 return false; 93 93 } 94 94 95 - static void zram_slot_lock(struct zram *zram, u32 index) 95 + static void slot_lock(struct zram *zram, u32 index) 96 96 { 97 97 unsigned long *lock = &zram->table[index].__lock; 98 98 ··· 101 101 lock_acquired(slot_dep_map(zram, index), _RET_IP_); 102 102 } 103 103 104 - static void zram_slot_unlock(struct zram *zram, u32 index) 104 + static void slot_unlock(struct zram *zram, u32 index) 105 105 { 106 106 unsigned long *lock = &zram->table[index].__lock; 107 107 ··· 119 119 return (struct zram *)dev_to_disk(dev)->private_data; 120 120 } 121 121 122 - static unsigned long zram_get_handle(struct zram *zram, u32 index) 122 + static unsigned long get_slot_handle(struct zram *zram, u32 index) 123 123 { 124 124 return zram->table[index].handle; 125 125 } 126 126 127 - static void zram_set_handle(struct zram *zram, u32 index, unsigned long handle) 127 + static void set_slot_handle(struct zram *zram, u32 index, unsigned long handle) 128 128 { 129 129 zram->table[index].handle = handle; 130 130 } 131 131 132 - static bool zram_test_flag(struct zram *zram, u32 index, 132 + static bool test_slot_flag(struct zram *zram, u32 index, 133 133 enum zram_pageflags flag) 134 134 { 135 135 return zram->table[index].attr.flags & BIT(flag); 136 136 } 137 137 138 - static void zram_set_flag(struct zram *zram, u32 index, 138 + static void set_slot_flag(struct zram *zram, u32 index, 139 139 enum zram_pageflags flag) 140 140 { 141 141 zram->table[index].attr.flags |= BIT(flag); 142 142 } 143 143 144 - static void zram_clear_flag(struct zram *zram, u32 index, 144 + static void clear_slot_flag(struct zram *zram, u32 index, 145 145 enum zram_pageflags flag) 146 146 { 147 147 zram->table[index].attr.flags &= ~BIT(flag); 148 148 } 149 149 150 - static size_t zram_get_obj_size(struct zram *zram, u32 index) 150 + static size_t get_slot_size(struct zram *zram, u32 index) 151 151 { 152 152 return zram->table[index].attr.flags & (BIT(ZRAM_FLAG_SHIFT) - 1); 153 153 } 154 154 155 - static void zram_set_obj_size(struct zram *zram, u32 index, size_t size) 155 + static void set_slot_size(struct zram *zram, u32 index, size_t size) 156 156 { 157 157 unsigned long flags = zram->table[index].attr.flags >> ZRAM_FLAG_SHIFT; 158 158 159 159 zram->table[index].attr.flags = (flags << ZRAM_FLAG_SHIFT) | size; 160 160 } 161 161 162 - static inline bool zram_allocated(struct zram *zram, u32 index) 162 + static inline bool slot_allocated(struct zram *zram, u32 index) 163 163 { 164 - return zram_get_obj_size(zram, index) || 165 - zram_test_flag(zram, index, ZRAM_SAME) || 166 - zram_test_flag(zram, index, ZRAM_WB); 164 + return get_slot_size(zram, index) || 165 + test_slot_flag(zram, index, ZRAM_SAME) || 166 + test_slot_flag(zram, index, ZRAM_WB); 167 + } 168 + 169 + static inline void set_slot_comp_priority(struct zram *zram, u32 index, 170 + u32 prio) 171 + { 172 + prio &= ZRAM_COMP_PRIORITY_MASK; 173 + /* 174 + * Clear previous priority value first, in case if we recompress 175 + * further an already recompressed page 176 + */ 177 + zram->table[index].attr.flags &= ~(ZRAM_COMP_PRIORITY_MASK << 178 + ZRAM_COMP_PRIORITY_BIT1); 179 + zram->table[index].attr.flags |= (prio << ZRAM_COMP_PRIORITY_BIT1); 180 + } 181 + 182 + static inline u32 get_slot_comp_priority(struct zram *zram, u32 index) 183 + { 184 + u32 prio = zram->table[index].attr.flags >> ZRAM_COMP_PRIORITY_BIT1; 185 + 186 + return prio & ZRAM_COMP_PRIORITY_MASK; 187 + } 188 + 189 + static void mark_slot_accessed(struct zram *zram, u32 index) 190 + { 191 + clear_slot_flag(zram, index, ZRAM_IDLE); 192 + clear_slot_flag(zram, index, ZRAM_PP_SLOT); 193 + #ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME 194 + zram->table[index].attr.ac_time = (u32)ktime_get_boottime_seconds(); 195 + #endif 167 196 } 168 197 169 198 static inline void update_used_max(struct zram *zram, const unsigned long pages) ··· 229 200 } 230 201 #endif 231 202 232 - static inline void zram_set_priority(struct zram *zram, u32 index, u32 prio) 233 - { 234 - prio &= ZRAM_COMP_PRIORITY_MASK; 235 - /* 236 - * Clear previous priority value first, in case if we recompress 237 - * further an already recompressed page 238 - */ 239 - zram->table[index].attr.flags &= ~(ZRAM_COMP_PRIORITY_MASK << 240 - ZRAM_COMP_PRIORITY_BIT1); 241 - zram->table[index].attr.flags |= (prio << ZRAM_COMP_PRIORITY_BIT1); 242 - } 243 - 244 - static inline u32 zram_get_priority(struct zram *zram, u32 index) 245 - { 246 - u32 prio = zram->table[index].attr.flags >> ZRAM_COMP_PRIORITY_BIT1; 247 - 248 - return prio & ZRAM_COMP_PRIORITY_MASK; 249 - } 250 - 251 - static void zram_accessed(struct zram *zram, u32 index) 252 - { 253 - zram_clear_flag(zram, index, ZRAM_IDLE); 254 - zram_clear_flag(zram, index, ZRAM_PP_SLOT); 255 - #ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME 256 - zram->table[index].attr.ac_time = (u32)ktime_get_boottime_seconds(); 257 - #endif 258 - } 259 - 260 203 #if defined CONFIG_ZRAM_WRITEBACK || defined CONFIG_ZRAM_MULTI_COMP 261 204 struct zram_pp_slot { 262 205 unsigned long index; ··· 264 263 { 265 264 list_del_init(&pps->entry); 266 265 267 - zram_slot_lock(zram, pps->index); 268 - zram_clear_flag(zram, pps->index, ZRAM_PP_SLOT); 269 - zram_slot_unlock(zram, pps->index); 266 + slot_lock(zram, pps->index); 267 + clear_slot_flag(zram, pps->index, ZRAM_PP_SLOT); 268 + slot_unlock(zram, pps->index); 270 269 271 270 kfree(pps); 272 271 } ··· 305 304 INIT_LIST_HEAD(&pps->entry); 306 305 pps->index = index; 307 306 308 - bid = zram_get_obj_size(zram, pps->index) / PP_BUCKET_SIZE_RANGE; 307 + bid = get_slot_size(zram, pps->index) / PP_BUCKET_SIZE_RANGE; 309 308 list_add(&pps->entry, &ctl->pp_buckets[bid]); 310 309 311 - zram_set_flag(zram, pps->index, ZRAM_PP_SLOT); 310 + set_slot_flag(zram, pps->index, ZRAM_PP_SLOT); 312 311 return true; 313 312 } 314 313 ··· 437 436 * 438 437 * And ZRAM_WB slots simply cannot be ZRAM_IDLE. 439 438 */ 440 - zram_slot_lock(zram, index); 441 - if (!zram_allocated(zram, index) || 442 - zram_test_flag(zram, index, ZRAM_WB) || 443 - zram_test_flag(zram, index, ZRAM_SAME)) { 444 - zram_slot_unlock(zram, index); 439 + slot_lock(zram, index); 440 + if (!slot_allocated(zram, index) || 441 + test_slot_flag(zram, index, ZRAM_WB) || 442 + test_slot_flag(zram, index, ZRAM_SAME)) { 443 + slot_unlock(zram, index); 445 444 continue; 446 445 } 447 446 ··· 450 449 ktime_after(cutoff, zram->table[index].attr.ac_time); 451 450 #endif 452 451 if (is_idle) 453 - zram_set_flag(zram, index, ZRAM_IDLE); 452 + set_slot_flag(zram, index, ZRAM_IDLE); 454 453 else 455 - zram_clear_flag(zram, index, ZRAM_IDLE); 456 - zram_slot_unlock(zram, index); 454 + clear_slot_flag(zram, index, ZRAM_IDLE); 455 + slot_unlock(zram, index); 457 456 } 458 457 } 459 458 ··· 934 933 } 935 934 936 935 atomic64_inc(&zram->stats.bd_writes); 937 - zram_slot_lock(zram, index); 936 + slot_lock(zram, index); 938 937 /* 939 938 * We release slot lock during writeback so slot can change under us: 940 939 * slot_free() or slot_free() and zram_write_page(). In both cases ··· 942 941 * set ZRAM_PP_SLOT on such slots until current post-processing 943 942 * finishes. 944 943 */ 945 - if (!zram_test_flag(zram, index, ZRAM_PP_SLOT)) { 944 + if (!test_slot_flag(zram, index, ZRAM_PP_SLOT)) { 946 945 zram_release_bdev_block(zram, req->blk_idx); 947 946 goto out; 948 947 } ··· 952 951 * ZRAM_WB slots get freed, we need to preserve data required 953 952 * for read decompression. 954 953 */ 955 - size = zram_get_obj_size(zram, index); 956 - prio = zram_get_priority(zram, index); 957 - huge = zram_test_flag(zram, index, ZRAM_HUGE); 954 + size = get_slot_size(zram, index); 955 + prio = get_slot_comp_priority(zram, index); 956 + huge = test_slot_flag(zram, index, ZRAM_HUGE); 958 957 } 959 958 960 - zram_slot_free(zram, index); 961 - zram_set_flag(zram, index, ZRAM_WB); 962 - zram_set_handle(zram, index, req->blk_idx); 959 + slot_free(zram, index); 960 + set_slot_flag(zram, index, ZRAM_WB); 961 + set_slot_handle(zram, index, req->blk_idx); 963 962 964 963 if (zram->wb_compressed) { 965 964 if (huge) 966 - zram_set_flag(zram, index, ZRAM_HUGE); 967 - zram_set_obj_size(zram, index, size); 968 - zram_set_priority(zram, index, prio); 965 + set_slot_flag(zram, index, ZRAM_HUGE); 966 + set_slot_size(zram, index, size); 967 + set_slot_comp_priority(zram, index, prio); 969 968 } 970 969 971 970 atomic64_inc(&zram->stats.pages_stored); 972 971 973 972 out: 974 - zram_slot_unlock(zram, index); 973 + slot_unlock(zram, index); 975 974 return 0; 976 975 } 977 976 ··· 1092 1091 } 1093 1092 1094 1093 index = pps->index; 1095 - zram_slot_lock(zram, index); 1094 + slot_lock(zram, index); 1096 1095 /* 1097 1096 * scan_slots() sets ZRAM_PP_SLOT and releases slot lock, so 1098 1097 * slots can change in the meantime. If slots are accessed or 1099 1098 * freed they lose ZRAM_PP_SLOT flag and hence we don't 1100 1099 * post-process them. 1101 1100 */ 1102 - if (!zram_test_flag(zram, index, ZRAM_PP_SLOT)) 1101 + if (!test_slot_flag(zram, index, ZRAM_PP_SLOT)) 1103 1102 goto next; 1104 1103 if (zram->wb_compressed) 1105 1104 err = read_from_zspool_raw(zram, req->page, index); ··· 1107 1106 err = read_from_zspool(zram, req->page, index); 1108 1107 if (err) 1109 1108 goto next; 1110 - zram_slot_unlock(zram, index); 1109 + slot_unlock(zram, index); 1111 1110 1112 1111 /* 1113 1112 * From now on pp-slot is owned by the req, remove it from ··· 1129 1128 continue; 1130 1129 1131 1130 next: 1132 - zram_slot_unlock(zram, index); 1131 + slot_unlock(zram, index); 1133 1132 release_pp_slot(zram, pps); 1134 1133 } 1135 1134 ··· 1222 1221 while (index < hi) { 1223 1222 bool ok = true; 1224 1223 1225 - zram_slot_lock(zram, index); 1226 - if (!zram_allocated(zram, index)) 1224 + slot_lock(zram, index); 1225 + if (!slot_allocated(zram, index)) 1227 1226 goto next; 1228 1227 1229 - if (zram_test_flag(zram, index, ZRAM_WB) || 1230 - zram_test_flag(zram, index, ZRAM_SAME)) 1228 + if (test_slot_flag(zram, index, ZRAM_WB) || 1229 + test_slot_flag(zram, index, ZRAM_SAME)) 1231 1230 goto next; 1232 1231 1233 1232 if (mode & IDLE_WRITEBACK && 1234 - !zram_test_flag(zram, index, ZRAM_IDLE)) 1233 + !test_slot_flag(zram, index, ZRAM_IDLE)) 1235 1234 goto next; 1236 1235 if (mode & HUGE_WRITEBACK && 1237 - !zram_test_flag(zram, index, ZRAM_HUGE)) 1236 + !test_slot_flag(zram, index, ZRAM_HUGE)) 1238 1237 goto next; 1239 1238 if (mode & INCOMPRESSIBLE_WRITEBACK && 1240 - !zram_test_flag(zram, index, ZRAM_INCOMPRESSIBLE)) 1239 + !test_slot_flag(zram, index, ZRAM_INCOMPRESSIBLE)) 1241 1240 goto next; 1242 1241 1243 1242 ok = place_pp_slot(zram, ctl, index); 1244 1243 next: 1245 - zram_slot_unlock(zram, index); 1244 + slot_unlock(zram, index); 1246 1245 if (!ok) 1247 1246 break; 1248 1247 index++; ··· 1370 1369 int ret, prio; 1371 1370 void *src; 1372 1371 1373 - zram_slot_lock(zram, index); 1372 + slot_lock(zram, index); 1374 1373 /* Since slot was unlocked we need to make sure it's still ZRAM_WB */ 1375 - if (!zram_test_flag(zram, index, ZRAM_WB)) { 1376 - zram_slot_unlock(zram, index); 1374 + if (!test_slot_flag(zram, index, ZRAM_WB)) { 1375 + slot_unlock(zram, index); 1377 1376 /* We read some stale data, zero it out */ 1378 1377 memset_page(page, 0, 0, PAGE_SIZE); 1379 1378 return -EIO; 1380 1379 } 1381 1380 1382 - if (zram_test_flag(zram, index, ZRAM_HUGE)) { 1383 - zram_slot_unlock(zram, index); 1381 + if (test_slot_flag(zram, index, ZRAM_HUGE)) { 1382 + slot_unlock(zram, index); 1384 1383 return 0; 1385 1384 } 1386 1385 1387 - size = zram_get_obj_size(zram, index); 1388 - prio = zram_get_priority(zram, index); 1386 + size = get_slot_size(zram, index); 1387 + prio = get_slot_comp_priority(zram, index); 1389 1388 1390 1389 zstrm = zcomp_stream_get(zram->comps[prio]); 1391 1390 src = kmap_local_page(page); ··· 1395 1394 copy_page(src, zstrm->local_copy); 1396 1395 kunmap_local(src); 1397 1396 zcomp_stream_put(zstrm); 1398 - zram_slot_unlock(zram, index); 1397 + slot_unlock(zram, index); 1399 1398 1400 1399 return ret; 1401 1400 } ··· 1585 1584 for (index = *ppos; index < nr_pages; index++) { 1586 1585 int copied; 1587 1586 1588 - zram_slot_lock(zram, index); 1589 - if (!zram_allocated(zram, index)) 1587 + slot_lock(zram, index); 1588 + if (!slot_allocated(zram, index)) 1590 1589 goto next; 1591 1590 1592 1591 ts = ktime_to_timespec64(zram->table[index].attr.ac_time); ··· 1594 1593 "%12zd %12lld.%06lu %c%c%c%c%c%c\n", 1595 1594 index, (s64)ts.tv_sec, 1596 1595 ts.tv_nsec / NSEC_PER_USEC, 1597 - zram_test_flag(zram, index, ZRAM_SAME) ? 's' : '.', 1598 - zram_test_flag(zram, index, ZRAM_WB) ? 'w' : '.', 1599 - zram_test_flag(zram, index, ZRAM_HUGE) ? 'h' : '.', 1600 - zram_test_flag(zram, index, ZRAM_IDLE) ? 'i' : '.', 1601 - zram_get_priority(zram, index) ? 'r' : '.', 1602 - zram_test_flag(zram, index, 1596 + test_slot_flag(zram, index, ZRAM_SAME) ? 's' : '.', 1597 + test_slot_flag(zram, index, ZRAM_WB) ? 'w' : '.', 1598 + test_slot_flag(zram, index, ZRAM_HUGE) ? 'h' : '.', 1599 + test_slot_flag(zram, index, ZRAM_IDLE) ? 'i' : '.', 1600 + get_slot_comp_priority(zram, index) ? 'r' : '.', 1601 + test_slot_flag(zram, index, 1603 1602 ZRAM_INCOMPRESSIBLE) ? 'n' : '.'); 1604 1603 1605 1604 if (count <= copied) { 1606 - zram_slot_unlock(zram, index); 1605 + slot_unlock(zram, index); 1607 1606 break; 1608 1607 } 1609 1608 written += copied; 1610 1609 count -= copied; 1611 1610 next: 1612 - zram_slot_unlock(zram, index); 1611 + slot_unlock(zram, index); 1613 1612 *ppos += 1; 1614 1613 } 1615 1614 ··· 1977 1976 1978 1977 /* Free all pages that are still in this zram device */ 1979 1978 for (index = 0; index < num_pages; index++) 1980 - zram_slot_free(zram, index); 1979 + slot_free(zram, index); 1981 1980 1982 1981 zs_destroy_pool(zram->mem_pool); 1983 1982 vfree(zram->table); ··· 2004 2003 huge_class_size = zs_huge_class_size(zram->mem_pool); 2005 2004 2006 2005 for (index = 0; index < num_pages; index++) 2007 - zram_slot_lock_init(zram, index); 2006 + slot_lock_init(zram, index); 2008 2007 2009 2008 return true; 2010 2009 } 2011 2010 2012 - static void zram_slot_free(struct zram *zram, u32 index) 2011 + static void slot_free(struct zram *zram, u32 index) 2013 2012 { 2014 2013 unsigned long handle; 2015 2014 ··· 2017 2016 zram->table[index].attr.ac_time = 0; 2018 2017 #endif 2019 2018 2020 - zram_clear_flag(zram, index, ZRAM_IDLE); 2021 - zram_clear_flag(zram, index, ZRAM_INCOMPRESSIBLE); 2022 - zram_clear_flag(zram, index, ZRAM_PP_SLOT); 2023 - zram_set_priority(zram, index, 0); 2019 + clear_slot_flag(zram, index, ZRAM_IDLE); 2020 + clear_slot_flag(zram, index, ZRAM_INCOMPRESSIBLE); 2021 + clear_slot_flag(zram, index, ZRAM_PP_SLOT); 2022 + set_slot_comp_priority(zram, index, 0); 2024 2023 2025 - if (zram_test_flag(zram, index, ZRAM_HUGE)) { 2026 - zram_clear_flag(zram, index, ZRAM_HUGE); 2024 + if (test_slot_flag(zram, index, ZRAM_HUGE)) { 2025 + clear_slot_flag(zram, index, ZRAM_HUGE); 2027 2026 atomic64_dec(&zram->stats.huge_pages); 2028 2027 } 2029 2028 2030 - if (zram_test_flag(zram, index, ZRAM_WB)) { 2031 - zram_clear_flag(zram, index, ZRAM_WB); 2032 - zram_release_bdev_block(zram, zram_get_handle(zram, index)); 2029 + if (test_slot_flag(zram, index, ZRAM_WB)) { 2030 + clear_slot_flag(zram, index, ZRAM_WB); 2031 + zram_release_bdev_block(zram, get_slot_handle(zram, index)); 2033 2032 goto out; 2034 2033 } 2035 2034 ··· 2037 2036 * No memory is allocated for same element filled pages. 2038 2037 * Simply clear same page flag. 2039 2038 */ 2040 - if (zram_test_flag(zram, index, ZRAM_SAME)) { 2041 - zram_clear_flag(zram, index, ZRAM_SAME); 2039 + if (test_slot_flag(zram, index, ZRAM_SAME)) { 2040 + clear_slot_flag(zram, index, ZRAM_SAME); 2042 2041 atomic64_dec(&zram->stats.same_pages); 2043 2042 goto out; 2044 2043 } 2045 2044 2046 - handle = zram_get_handle(zram, index); 2045 + handle = get_slot_handle(zram, index); 2047 2046 if (!handle) 2048 2047 return; 2049 2048 2050 2049 zs_free(zram->mem_pool, handle); 2051 2050 2052 - atomic64_sub(zram_get_obj_size(zram, index), 2051 + atomic64_sub(get_slot_size(zram, index), 2053 2052 &zram->stats.compr_data_size); 2054 2053 out: 2055 2054 atomic64_dec(&zram->stats.pages_stored); 2056 - zram_set_handle(zram, index, 0); 2057 - zram_set_obj_size(zram, index, 0); 2055 + set_slot_handle(zram, index, 0); 2056 + set_slot_size(zram, index, 0); 2058 2057 } 2059 2058 2060 2059 static int read_same_filled_page(struct zram *zram, struct page *page, ··· 2063 2062 void *mem; 2064 2063 2065 2064 mem = kmap_local_page(page); 2066 - zram_fill_page(mem, PAGE_SIZE, zram_get_handle(zram, index)); 2065 + zram_fill_page(mem, PAGE_SIZE, get_slot_handle(zram, index)); 2067 2066 kunmap_local(mem); 2068 2067 return 0; 2069 2068 } ··· 2074 2073 unsigned long handle; 2075 2074 void *src, *dst; 2076 2075 2077 - handle = zram_get_handle(zram, index); 2076 + handle = get_slot_handle(zram, index); 2078 2077 src = zs_obj_read_begin(zram->mem_pool, handle, NULL); 2079 2078 dst = kmap_local_page(page); 2080 2079 copy_page(dst, src); ··· 2092 2091 void *src, *dst; 2093 2092 int ret, prio; 2094 2093 2095 - handle = zram_get_handle(zram, index); 2096 - size = zram_get_obj_size(zram, index); 2097 - prio = zram_get_priority(zram, index); 2094 + handle = get_slot_handle(zram, index); 2095 + size = get_slot_size(zram, index); 2096 + prio = get_slot_comp_priority(zram, index); 2098 2097 2099 2098 zstrm = zcomp_stream_get(zram->comps[prio]); 2100 2099 src = zs_obj_read_begin(zram->mem_pool, handle, zstrm->local_copy); ··· 2115 2114 unsigned int size; 2116 2115 void *src; 2117 2116 2118 - handle = zram_get_handle(zram, index); 2119 - size = zram_get_obj_size(zram, index); 2117 + handle = get_slot_handle(zram, index); 2118 + size = get_slot_size(zram, index); 2120 2119 2121 2120 /* 2122 2121 * We need to get stream just for ->local_copy buffer, in ··· 2139 2138 */ 2140 2139 static int read_from_zspool(struct zram *zram, struct page *page, u32 index) 2141 2140 { 2142 - if (zram_test_flag(zram, index, ZRAM_SAME) || 2143 - !zram_get_handle(zram, index)) 2141 + if (test_slot_flag(zram, index, ZRAM_SAME) || 2142 + !get_slot_handle(zram, index)) 2144 2143 return read_same_filled_page(zram, page, index); 2145 2144 2146 - if (!zram_test_flag(zram, index, ZRAM_HUGE)) 2145 + if (!test_slot_flag(zram, index, ZRAM_HUGE)) 2147 2146 return read_compressed_page(zram, page, index); 2148 2147 else 2149 2148 return read_incompressible_page(zram, page, index); ··· 2154 2153 { 2155 2154 int ret; 2156 2155 2157 - zram_slot_lock(zram, index); 2158 - if (!zram_test_flag(zram, index, ZRAM_WB)) { 2156 + slot_lock(zram, index); 2157 + if (!test_slot_flag(zram, index, ZRAM_WB)) { 2159 2158 /* Slot should be locked through out the function call */ 2160 2159 ret = read_from_zspool(zram, page, index); 2161 - zram_slot_unlock(zram, index); 2160 + slot_unlock(zram, index); 2162 2161 } else { 2163 - unsigned long blk_idx = zram_get_handle(zram, index); 2162 + unsigned long blk_idx = get_slot_handle(zram, index); 2164 2163 2165 2164 /* 2166 2165 * The slot should be unlocked before reading from the backing 2167 2166 * device. 2168 2167 */ 2169 - zram_slot_unlock(zram, index); 2168 + slot_unlock(zram, index); 2170 2169 ret = read_from_bdev(zram, page, index, blk_idx, parent); 2171 2170 } 2172 2171 ··· 2207 2206 static int write_same_filled_page(struct zram *zram, unsigned long fill, 2208 2207 u32 index) 2209 2208 { 2210 - zram_slot_lock(zram, index); 2211 - zram_slot_free(zram, index); 2212 - zram_set_flag(zram, index, ZRAM_SAME); 2213 - zram_set_handle(zram, index, fill); 2214 - zram_slot_unlock(zram, index); 2209 + slot_lock(zram, index); 2210 + slot_free(zram, index); 2211 + set_slot_flag(zram, index, ZRAM_SAME); 2212 + set_slot_handle(zram, index, fill); 2213 + slot_unlock(zram, index); 2215 2214 2216 2215 atomic64_inc(&zram->stats.same_pages); 2217 2216 atomic64_inc(&zram->stats.pages_stored); ··· 2245 2244 zs_obj_write(zram->mem_pool, handle, src, PAGE_SIZE); 2246 2245 kunmap_local(src); 2247 2246 2248 - zram_slot_lock(zram, index); 2249 - zram_slot_free(zram, index); 2250 - zram_set_flag(zram, index, ZRAM_HUGE); 2251 - zram_set_handle(zram, index, handle); 2252 - zram_set_obj_size(zram, index, PAGE_SIZE); 2253 - zram_slot_unlock(zram, index); 2247 + slot_lock(zram, index); 2248 + slot_free(zram, index); 2249 + set_slot_flag(zram, index, ZRAM_HUGE); 2250 + set_slot_handle(zram, index, handle); 2251 + set_slot_size(zram, index, PAGE_SIZE); 2252 + slot_unlock(zram, index); 2254 2253 2255 2254 atomic64_add(PAGE_SIZE, &zram->stats.compr_data_size); 2256 2255 atomic64_inc(&zram->stats.huge_pages); ··· 2310 2309 zs_obj_write(zram->mem_pool, handle, zstrm->buffer, comp_len); 2311 2310 zcomp_stream_put(zstrm); 2312 2311 2313 - zram_slot_lock(zram, index); 2314 - zram_slot_free(zram, index); 2315 - zram_set_handle(zram, index, handle); 2316 - zram_set_obj_size(zram, index, comp_len); 2317 - zram_slot_unlock(zram, index); 2312 + slot_lock(zram, index); 2313 + slot_free(zram, index); 2314 + set_slot_handle(zram, index, handle); 2315 + set_slot_size(zram, index, comp_len); 2316 + slot_unlock(zram, index); 2318 2317 2319 2318 /* Update stats */ 2320 2319 atomic64_inc(&zram->stats.pages_stored); ··· 2365 2364 for (index = 0; index < nr_pages; index++) { 2366 2365 bool ok = true; 2367 2366 2368 - zram_slot_lock(zram, index); 2369 - if (!zram_allocated(zram, index)) 2367 + slot_lock(zram, index); 2368 + if (!slot_allocated(zram, index)) 2370 2369 goto next; 2371 2370 2372 2371 if (mode & RECOMPRESS_IDLE && 2373 - !zram_test_flag(zram, index, ZRAM_IDLE)) 2372 + !test_slot_flag(zram, index, ZRAM_IDLE)) 2374 2373 goto next; 2375 2374 2376 2375 if (mode & RECOMPRESS_HUGE && 2377 - !zram_test_flag(zram, index, ZRAM_HUGE)) 2376 + !test_slot_flag(zram, index, ZRAM_HUGE)) 2378 2377 goto next; 2379 2378 2380 - if (zram_test_flag(zram, index, ZRAM_WB) || 2381 - zram_test_flag(zram, index, ZRAM_SAME) || 2382 - zram_test_flag(zram, index, ZRAM_INCOMPRESSIBLE)) 2379 + if (test_slot_flag(zram, index, ZRAM_WB) || 2380 + test_slot_flag(zram, index, ZRAM_SAME) || 2381 + test_slot_flag(zram, index, ZRAM_INCOMPRESSIBLE)) 2383 2382 goto next; 2384 2383 2385 2384 /* Already compressed with same of higher priority */ 2386 - if (zram_get_priority(zram, index) + 1 >= prio_max) 2385 + if (get_slot_comp_priority(zram, index) + 1 >= prio_max) 2387 2386 goto next; 2388 2387 2389 2388 ok = place_pp_slot(zram, ctl, index); 2390 2389 next: 2391 - zram_slot_unlock(zram, index); 2390 + slot_unlock(zram, index); 2392 2391 if (!ok) 2393 2392 break; 2394 2393 } ··· 2417 2416 void *src; 2418 2417 int ret = 0; 2419 2418 2420 - handle_old = zram_get_handle(zram, index); 2419 + handle_old = get_slot_handle(zram, index); 2421 2420 if (!handle_old) 2422 2421 return -EINVAL; 2423 2422 2424 - comp_len_old = zram_get_obj_size(zram, index); 2423 + comp_len_old = get_slot_size(zram, index); 2425 2424 /* 2426 2425 * Do not recompress objects that are already "small enough". 2427 2426 */ ··· 2437 2436 * we don't preserve IDLE flag and don't incorrectly pick this entry 2438 2437 * for different post-processing type (e.g. writeback). 2439 2438 */ 2440 - zram_clear_flag(zram, index, ZRAM_IDLE); 2439 + clear_slot_flag(zram, index, ZRAM_IDLE); 2441 2440 2442 2441 class_index_old = zs_lookup_class_index(zram->mem_pool, comp_len_old); 2443 2442 2444 - prio = max(prio, zram_get_priority(zram, index) + 1); 2443 + prio = max(prio, get_slot_comp_priority(zram, index) + 1); 2445 2444 /* 2446 2445 * Recompression slots scan should not select slots that are 2447 2446 * already compressed with a higher priority algorithm, but ··· 2508 2507 */ 2509 2508 if (prio < zram->num_active_comps) 2510 2509 return 0; 2511 - zram_set_flag(zram, index, ZRAM_INCOMPRESSIBLE); 2510 + set_slot_flag(zram, index, ZRAM_INCOMPRESSIBLE); 2512 2511 return 0; 2513 2512 } 2514 2513 ··· 2533 2532 zs_obj_write(zram->mem_pool, handle_new, zstrm->buffer, comp_len_new); 2534 2533 zcomp_stream_put(zstrm); 2535 2534 2536 - zram_slot_free(zram, index); 2537 - zram_set_handle(zram, index, handle_new); 2538 - zram_set_obj_size(zram, index, comp_len_new); 2539 - zram_set_priority(zram, index, prio); 2535 + slot_free(zram, index); 2536 + set_slot_handle(zram, index, handle_new); 2537 + set_slot_size(zram, index, comp_len_new); 2538 + set_slot_comp_priority(zram, index, prio); 2540 2539 2541 2540 atomic64_add(comp_len_new, &zram->stats.compr_data_size); 2542 2541 atomic64_inc(&zram->stats.pages_stored); ··· 2676 2675 if (!num_recomp_pages) 2677 2676 break; 2678 2677 2679 - zram_slot_lock(zram, pps->index); 2680 - if (!zram_test_flag(zram, pps->index, ZRAM_PP_SLOT)) 2678 + slot_lock(zram, pps->index); 2679 + if (!test_slot_flag(zram, pps->index, ZRAM_PP_SLOT)) 2681 2680 goto next; 2682 2681 2683 2682 err = recompress_slot(zram, pps->index, page, 2684 2683 &num_recomp_pages, threshold, 2685 2684 prio, prio_max); 2686 2685 next: 2687 - zram_slot_unlock(zram, pps->index); 2686 + slot_unlock(zram, pps->index); 2688 2687 release_pp_slot(zram, pps); 2689 2688 2690 2689 if (err) { ··· 2730 2729 } 2731 2730 2732 2731 while (n >= PAGE_SIZE) { 2733 - zram_slot_lock(zram, index); 2734 - zram_slot_free(zram, index); 2735 - zram_slot_unlock(zram, index); 2732 + slot_lock(zram, index); 2733 + slot_free(zram, index); 2734 + slot_unlock(zram, index); 2736 2735 atomic64_inc(&zram->stats.notify_free); 2737 2736 index++; 2738 2737 n -= PAGE_SIZE; ··· 2761 2760 } 2762 2761 flush_dcache_page(bv.bv_page); 2763 2762 2764 - zram_slot_lock(zram, index); 2765 - zram_accessed(zram, index); 2766 - zram_slot_unlock(zram, index); 2763 + slot_lock(zram, index); 2764 + mark_slot_accessed(zram, index); 2765 + slot_unlock(zram, index); 2767 2766 2768 2767 bio_advance_iter_single(bio, &iter, bv.bv_len); 2769 2768 } while (iter.bi_size); ··· 2791 2790 break; 2792 2791 } 2793 2792 2794 - zram_slot_lock(zram, index); 2795 - zram_accessed(zram, index); 2796 - zram_slot_unlock(zram, index); 2793 + slot_lock(zram, index); 2794 + mark_slot_accessed(zram, index); 2795 + slot_unlock(zram, index); 2797 2796 2798 2797 bio_advance_iter_single(bio, &iter, bv.bv_len); 2799 2798 } while (iter.bi_size); ··· 2834 2833 zram = bdev->bd_disk->private_data; 2835 2834 2836 2835 atomic64_inc(&zram->stats.notify_free); 2837 - if (!zram_slot_trylock(zram, index)) { 2836 + if (!slot_trylock(zram, index)) { 2838 2837 atomic64_inc(&zram->stats.miss_free); 2839 2838 return; 2840 2839 } 2841 2840 2842 - zram_slot_free(zram, index); 2843 - zram_slot_unlock(zram, index); 2841 + slot_free(zram, index); 2842 + slot_unlock(zram, index); 2844 2843 } 2845 2844 2846 2845 static void zram_comp_params_reset(struct zram *zram)