Re: [PATCH v5] zram: Introduce an aged idle interface

From: Brian Geffon
Date: Fri Sep 24 2021 - 16:16:08 EST


> Also this?
>
> --- a/drivers/block/zram/zram_drv.c~zram-introduce-an-aged-idle-interface-v5-fix
> +++ a/drivers/block/zram/zram_drv.c
> @@ -309,9 +309,8 @@ static void mark_idle(struct zram *zram,
> zram_slot_lock(zram, index);
> if (zram_allocated(zram, index) &&
> !zram_test_flag(zram, index, ZRAM_UNDER_WB)) {
> -#ifdef CONFIG_ZRAM_MEMORY_TRACKING
> + if (IS_ENABLED(CONFIG_ZRAM_MEMORY_TRACKING))
> is_idle = (!cutoff || ktime_after(cutoff, zram->table[index].ac_time));
> -#endif
> if (is_idle)
> zram_set_flag(zram, index, ZRAM_IDLE);
> }
> _
>

Hi Andrew,
As written that patch won't compile when
CONFIG_ZRAM_MEMORY_TRACKING=n, my guess is that the compiler pass that
removes the dead branch only happens after it attempts to compile the
branch itself. So it appears that even though IS_ENABLED(..) always
evaluates to 0, the compile will fail because table[index].ac_time
does not exist. You should get an error like this:

drivers/block/zram/zram_drv.c:314:57: error: no member named 'ac_time'
in 'struct zram_table_entry'
(!cutoff
|| ktime_after(cutoff, zram->table[index].ac_time)))

Brian