From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: 2024-06-20 15:36:10
Hi,
this is follow up to the previous posting, making the lock
unconditionally. The original problem with bit spinlock is that it
disabled preemption and the following operations (within the atomic
section) perform operations that may sleep on PREEMPT_RT. Mike expressed
that he would like to keep using zram on PREEMPT_RT.
v1…v2: https://lore.kernel.org/all/20240619150814.BRAvaziM@linutronix.de/:
- Add the spinlock_t unconditionally
- Remove ZRAM_LOCK since it has no user after the lock has been added.
- Make zram_table_entry::flags an integer so struct zram_table_entry
does not gain additional weight.
Sebastian
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: 2024-06-20 15:36:10
From: Mike Galbraith <redacted>
The bit spinlock disables preemption. The spinlock_t lock becomes a sleeping
lock on PREEMPT_RT and it can not be acquired in this context. In this locked
section, zs_free() acquires a zs_pool::lock, and there is access to
zram::wb_limit_lock.
Add a spinlock_t for locking. Keep the set/ clear ZRAM_LOCK bit after
the lock has been acquired/ dropped. The size of struct zram_table_entry
increases by 4 bytes due to lock and additional 4 bytes padding with
CONFIG_ZRAM_TRACK_ENTRY_ACTIME enabled.
Signed-off-by: Mike Galbraith <redacted>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/block/zram/zram_drv.c | 22 +++++++++++++++++++---
drivers/block/zram/zram_drv.h | 1 +
2 files changed, 20 insertions(+), 3 deletions(-)
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: 2024-06-20 15:36:11
The ZRAM_LOCK was used for locking and after the addition of spinlock_t
the bit set and cleared but there no reader of it.
Remove the ZRAM_LOCK bit.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/block/zram/zram_drv.c | 11 ++---------
drivers/block/zram/zram_drv.h | 4 +---
2 files changed, 3 insertions(+), 12 deletions(-)
@@ -45,9 +45,7 @@/* Flags for zram pages (table[page_no].flags) */enumzram_pageflags{-/* zram slot is locked */-ZRAM_LOCK=ZRAM_FLAG_SHIFT,-ZRAM_SAME,/* Page consists the same element */+ZRAM_SAME=ZRAM_FLAG_SHIFT,/* Page consists the same element */ZRAM_WB,/* page is stored on backing_device */ZRAM_UNDER_WB,/* page is under writeback */ZRAM_HUGE,/* Incompressible page */
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: 2024-06-20 15:36:11
The zram_table_entry::flags member is of type long and uses 8 bytes on a
64bit architecture. With a PAGE_SIZE of 256KiB we have PAGE_SHIFT of 18
which in turn leads to __NR_ZRAM_PAGEFLAGS = 27. This still fits in an
ordinary integer.
By reducing it the size of `flags' to four bytes, the size of the struct
goes back to 16 bytes. The padding between the lock and ac_time (if
enabled) is also gone.
Make zram_table_entry::flags an unsigned int and update the build test
to reflect the change.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/block/zram/zram_drv.c | 3 ++-
drivers/block/zram/zram_drv.h | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
On (24/06/20 17:28), Sebastian Andrzej Siewior wrote:
this is follow up to the previous posting, making the lock
unconditionally. The original problem with bit spinlock is that it
disabled preemption and the following operations (within the atomic
section) perform operations that may sleep on PREEMPT_RT. Mike expressed
that he would like to keep using zram on PREEMPT_RT.
Sorry for the delay.
I guess this works for me, FWIW:
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Minchan, any objections?
From: Alexander Lobakin <aleksander.lobakin@intel.com> Date: 2024-07-04 11:38:22
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 20 Jun 2024 17:28:50 +0200
quoted hunk
From: Mike Galbraith <redacted>
The bit spinlock disables preemption. The spinlock_t lock becomes a sleeping
lock on PREEMPT_RT and it can not be acquired in this context. In this locked
section, zs_free() acquires a zs_pool::lock, and there is access to
zram::wb_limit_lock.
Add a spinlock_t for locking. Keep the set/ clear ZRAM_LOCK bit after
the lock has been acquired/ dropped. The size of struct zram_table_entry
increases by 4 bytes due to lock and additional 4 bytes padding with
CONFIG_ZRAM_TRACK_ENTRY_ACTIME enabled.
Signed-off-by: Mike Galbraith <redacted>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/block/zram/zram_drv.c | 22 +++++++++++++++++++---
drivers/block/zram/zram_drv.h | 1 +
2 files changed, 20 insertions(+), 3 deletions(-)