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: drop ->num_active_comps

It's not entirely correct to use ->num_active_comps for max-prio limit, as
->num_active_comps just tells the number of configured algorithms, not the
max configured priority. For instance, in the following theoretical
example:

[lz4] [nil] [nil] [deflate]

->num_active_comps is 2, while the actual max-prio is 3.

Drop ->num_active_comps and use ZRAM_MAX_COMPS instead.

Link: https://lkml.kernel.org/r/20260311084312.1766036-4-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Suggested-by: Minchan Kim <minchan@kernel.org>
Cc: Brian Geffon <bgeffon@google.com>
Cc: gao xu <gaoxu2@honor.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sergey Senozhatsky and committed by
Andrew Morton
5004a27e ed19b9d5

+16 -14
+16 -13
drivers/block/zram/zram_drv.c
··· 2324 2324 #define RECOMPRESS_IDLE (1 << 0) 2325 2325 #define RECOMPRESS_HUGE (1 << 1) 2326 2326 2327 + static bool highest_priority_algorithm(struct zram *zram, u32 prio) 2328 + { 2329 + u32 p; 2330 + 2331 + for (p = prio + 1; p < ZRAM_MAX_COMPS; p++) { 2332 + if (zram->comp_algs[p]) 2333 + return false; 2334 + } 2335 + 2336 + return true; 2337 + } 2338 + 2327 2339 static int scan_slots_for_recompress(struct zram *zram, u32 mode, u32 prio_max, 2328 2340 struct zram_pp_ctl *ctl) 2329 2341 { ··· 2483 2471 * Secondary algorithms failed to re-compress the page 2484 2472 * in a way that would save memory. 2485 2473 * 2486 - * Mark the object incompressible if the max-priority 2487 - * algorithm couldn't re-compress it. 2474 + * Mark the object incompressible if the max-priority (the 2475 + * last configured one) algorithm couldn't re-compress it. 2488 2476 */ 2489 - if (prio < zram->num_active_comps) 2490 - return 0; 2491 - set_slot_flag(zram, index, ZRAM_INCOMPRESSIBLE); 2477 + if (highest_priority_algorithm(zram, prio)) 2478 + set_slot_flag(zram, index, ZRAM_INCOMPRESSIBLE); 2492 2479 return 0; 2493 2480 } 2494 2481 ··· 2617 2606 ret = -EINVAL; 2618 2607 goto out; 2619 2608 } 2620 - } 2621 - 2622 - prio_max = min(prio_max, (u32)zram->num_active_comps); 2623 - if (prio >= prio_max) { 2624 - ret = -EINVAL; 2625 - goto out; 2626 2609 } 2627 2610 2628 2611 if (prio < ZRAM_SECONDARY_COMP || prio >= ZRAM_MAX_COMPS) { ··· 2831 2826 if (!comp) 2832 2827 continue; 2833 2828 zcomp_destroy(comp); 2834 - zram->num_active_comps--; 2835 2829 } 2836 2830 2837 2831 for (prio = ZRAM_PRIMARY_COMP; prio < ZRAM_MAX_COMPS; prio++) ··· 2895 2891 } 2896 2892 2897 2893 zram->comps[prio] = comp; 2898 - zram->num_active_comps++; 2899 2894 } 2900 2895 zram->disksize = disksize; 2901 2896 set_capacity_and_notify(zram->disk, zram->disksize >> SECTOR_SHIFT);
-1
drivers/block/zram/zram_drv.h
··· 125 125 */ 126 126 u64 disksize; /* bytes */ 127 127 const char *comp_algs[ZRAM_MAX_COMPS]; 128 - s8 num_active_comps; 129 128 /* 130 129 * zram is claimed so open request will be failed 131 130 */