* [PATCH 1/2] zram: split memory-tracking and ac-time tracking
@ 2023-11-15 2:42 Sergey Senozhatsky
2023-11-15 2:42 ` [PATCH 2/2] zram: tweak writeback config help Sergey Senozhatsky
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-11-15 2:42 UTC (permalink / raw)
To: Minchan Kim; +Cc: Andrew Morton, linux-block, Sergey Senozhatsky
ZRAM_MEMORY_TRACKING enables two features:
- per-entry ac-time tracking
- debugfs interface
The latter one is the reason why memory-tracking depends
on DEBUG_FS, while the former one is used far beyond debugging
these days. Namely ac-time is used for fine-grained writeback
of idle entries (pages).
Move ac-time tracking under its own config option so that
it can be enabled (along with writeback) on systems without
DEBUG_FS.
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
Documentation/admin-guide/blockdev/zram.rst | 2 +-
drivers/block/zram/Kconfig | 11 ++++++++-
drivers/block/zram/zram_drv.c | 27 ++++++++++-----------
drivers/block/zram/zram_drv.h | 2 +-
4 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/Documentation/admin-guide/blockdev/zram.rst b/Documentation/admin-guide/blockdev/zram.rst
index e4551579cb12..ee2b0030d416 100644
--- a/Documentation/admin-guide/blockdev/zram.rst
+++ b/Documentation/admin-guide/blockdev/zram.rst
@@ -328,7 +328,7 @@ as idle::
From now on, any pages on zram are idle pages. The idle mark
will be removed until someone requests access of the block.
IOW, unless there is access request, those pages are still idle pages.
-Additionally, when CONFIG_ZRAM_MEMORY_TRACKING is enabled pages can be
+Additionally, when CONFIG_ZRAM_TRACK_ENTRY_ACTIME is enabled pages can be
marked as idle based on how long (in seconds) it's been since they were
last accessed::
diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig
index 0386b7da02aa..af201392ed52 100644
--- a/drivers/block/zram/Kconfig
+++ b/drivers/block/zram/Kconfig
@@ -69,9 +69,18 @@ config ZRAM_WRITEBACK
See Documentation/admin-guide/blockdev/zram.rst for more information.
+config ZRAM_TRACK_ENTRY_ACTIME
+ bool "Track access time of zram entries"
+ depends on ZRAM
+ help
+ With this feature zram tracks access time of every stored
+ entry (page), which can be used for a more fine-grained IDLE
+ pages writeback.
+
config ZRAM_MEMORY_TRACKING
bool "Track zRam block status"
depends on ZRAM && DEBUG_FS
+ select ZRAM_TRACK_ENTRY_ACTIME
help
With this feature, admin can track the state of allocated blocks
of zRAM. Admin could see the information via
@@ -86,4 +95,4 @@ config ZRAM_MULTI_COMP
This will enable multi-compression streams, so that ZRAM can
re-compress pages using a potentially slower but more effective
compression algorithm. Note, that IDLE page recompression
- requires ZRAM_MEMORY_TRACKING.
+ requires ZRAM_TRACK_ENTRY_ACTIME.
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index d77d3664ca08..68e0a8187783 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -174,6 +174,14 @@ static inline u32 zram_get_priority(struct zram *zram, u32 index)
return prio & ZRAM_COMP_PRIORITY_MASK;
}
+static void zram_accessed(struct zram *zram, u32 index)
+{
+ zram_clear_flag(zram, index, ZRAM_IDLE);
+#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
+ zram->table[index].ac_time = ktime_get_boottime();
+#endif
+}
+
static inline void update_used_max(struct zram *zram,
const unsigned long pages)
{
@@ -293,8 +301,9 @@ static void mark_idle(struct zram *zram, ktime_t cutoff)
zram_slot_lock(zram, index);
if (zram_allocated(zram, index) &&
!zram_test_flag(zram, index, ZRAM_UNDER_WB)) {
-#ifdef CONFIG_ZRAM_MEMORY_TRACKING
- is_idle = !cutoff || ktime_after(cutoff, zram->table[index].ac_time);
+#ifdef ZRAM_TRACK_ENTRY_ACTIME
+ is_idle = !cutoff || ktime_after(cutoff,
+ zram->table[index].ac_time);
#endif
if (is_idle)
zram_set_flag(zram, index, ZRAM_IDLE);
@@ -317,7 +326,7 @@ static ssize_t idle_store(struct device *dev,
*/
u64 age_sec;
- if (IS_ENABLED(CONFIG_ZRAM_MEMORY_TRACKING) && !kstrtoull(buf, 0, &age_sec))
+ if (IS_ENABLED(CONFIG_ZRAM_TRACK_ENTRY_ACTIME) && !kstrtoull(buf, 0, &age_sec))
cutoff_time = ktime_sub(ktime_get_boottime(),
ns_to_ktime(age_sec * NSEC_PER_SEC));
else
@@ -841,12 +850,6 @@ static void zram_debugfs_destroy(void)
debugfs_remove_recursive(zram_debugfs_root);
}
-static void zram_accessed(struct zram *zram, u32 index)
-{
- zram_clear_flag(zram, index, ZRAM_IDLE);
- zram->table[index].ac_time = ktime_get_boottime();
-}
-
static ssize_t read_block_state(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
@@ -930,10 +933,6 @@ static void zram_debugfs_unregister(struct zram *zram)
#else
static void zram_debugfs_create(void) {};
static void zram_debugfs_destroy(void) {};
-static void zram_accessed(struct zram *zram, u32 index)
-{
- zram_clear_flag(zram, index, ZRAM_IDLE);
-};
static void zram_debugfs_register(struct zram *zram) {};
static void zram_debugfs_unregister(struct zram *zram) {};
#endif
@@ -1254,7 +1253,7 @@ static void zram_free_page(struct zram *zram, size_t index)
{
unsigned long handle;
-#ifdef CONFIG_ZRAM_MEMORY_TRACKING
+#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
zram->table[index].ac_time = 0;
#endif
if (zram_test_flag(zram, index, ZRAM_IDLE))
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index d090753f97be..3b94d12f41b4 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -69,7 +69,7 @@ struct zram_table_entry {
unsigned long element;
};
unsigned long flags;
-#ifdef CONFIG_ZRAM_MEMORY_TRACKING
+#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
ktime_t ac_time;
#endif
};
--
2.43.0.rc0.421.g78406f8d94-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] zram: tweak writeback config help
2023-11-15 2:42 [PATCH 1/2] zram: split memory-tracking and ac-time tracking Sergey Senozhatsky
@ 2023-11-15 2:42 ` Sergey Senozhatsky
2023-11-16 14:27 ` [PATCH 1/2] zram: split memory-tracking and ac-time tracking Dmytro Maluka
2023-11-17 1:35 ` [PATCHv2 " Sergey Senozhatsky
2 siblings, 0 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-11-15 2:42 UTC (permalink / raw)
To: Minchan Kim; +Cc: Andrew Morton, linux-block, Sergey Senozhatsky
Writeback is for incompressible and idle zram pages.
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
drivers/block/zram/Kconfig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig
index af201392ed52..7b29cce60ab2 100644
--- a/drivers/block/zram/Kconfig
+++ b/drivers/block/zram/Kconfig
@@ -59,8 +59,8 @@ config ZRAM_WRITEBACK
bool "Write back incompressible or idle page to backing device"
depends on ZRAM
help
- With incompressible page, there is no memory saving to keep it
- in memory. Instead, write it out to backing device.
+ This lets zram entries (incompressible or idle pages) be written
+ back to a backing device, helping save memory.
For this feature, admin should set up backing device via
/sys/block/zramX/backing_dev.
--
2.43.0.rc0.421.g78406f8d94-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] zram: split memory-tracking and ac-time tracking
2023-11-15 2:42 [PATCH 1/2] zram: split memory-tracking and ac-time tracking Sergey Senozhatsky
2023-11-15 2:42 ` [PATCH 2/2] zram: tweak writeback config help Sergey Senozhatsky
@ 2023-11-16 14:27 ` Dmytro Maluka
2023-11-17 1:33 ` Sergey Senozhatsky
2023-11-17 1:35 ` [PATCHv2 " Sergey Senozhatsky
2 siblings, 1 reply; 5+ messages in thread
From: Dmytro Maluka @ 2023-11-16 14:27 UTC (permalink / raw)
To: Sergey Senozhatsky, Minchan Kim; +Cc: Andrew Morton, linux-block
On 11/15/23 03:42, Sergey Senozhatsky wrote:
> @@ -293,8 +301,9 @@ static void mark_idle(struct zram *zram, ktime_t cutoff)
> zram_slot_lock(zram, index);
> if (zram_allocated(zram, index) &&
> !zram_test_flag(zram, index, ZRAM_UNDER_WB)) {
> -#ifdef CONFIG_ZRAM_MEMORY_TRACKING
> - is_idle = !cutoff || ktime_after(cutoff, zram->table[index].ac_time);
> +#ifdef ZRAM_TRACK_ENTRY_ACTIME
CONFIG_ZRAM_TRACK_ENTRY_ACTIME?
> + is_idle = !cutoff || ktime_after(cutoff,
> + zram->table[index].ac_time);
> #endif
> if (is_idle)
> zram_set_flag(zram, index, ZRAM_IDLE);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] zram: split memory-tracking and ac-time tracking
2023-11-16 14:27 ` [PATCH 1/2] zram: split memory-tracking and ac-time tracking Dmytro Maluka
@ 2023-11-17 1:33 ` Sergey Senozhatsky
0 siblings, 0 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-11-17 1:33 UTC (permalink / raw)
To: Dmytro Maluka; +Cc: Sergey Senozhatsky, Minchan Kim, Andrew Morton, linux-block
On (23/11/16 15:27), Dmytro Maluka wrote:
> On 11/15/23 03:42, Sergey Senozhatsky wrote:
> > @@ -293,8 +301,9 @@ static void mark_idle(struct zram *zram, ktime_t cutoff)
> > zram_slot_lock(zram, index);
> > if (zram_allocated(zram, index) &&
> > !zram_test_flag(zram, index, ZRAM_UNDER_WB)) {
> > -#ifdef CONFIG_ZRAM_MEMORY_TRACKING
> > - is_idle = !cutoff || ktime_after(cutoff, zram->table[index].ac_time);
> > +#ifdef ZRAM_TRACK_ENTRY_ACTIME
>
> CONFIG_ZRAM_TRACK_ENTRY_ACTIME?
Thanks for spotting this.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCHv2 1/2] zram: split memory-tracking and ac-time tracking
2023-11-15 2:42 [PATCH 1/2] zram: split memory-tracking and ac-time tracking Sergey Senozhatsky
2023-11-15 2:42 ` [PATCH 2/2] zram: tweak writeback config help Sergey Senozhatsky
2023-11-16 14:27 ` [PATCH 1/2] zram: split memory-tracking and ac-time tracking Dmytro Maluka
@ 2023-11-17 1:35 ` Sergey Senozhatsky
2 siblings, 0 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-11-17 1:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: Minchan Kim, Dmytro Maluka, linux-block, Sergey Senozhatsky
ZRAM_MEMORY_TRACKING enables two features:
- per-entry ac-time tracking
- debugfs interface
The latter one is the reason why memory-tracking depends
on DEBUG_FS, while the former one is used far beyond debugging
these days. Namely ac-time is used for fine grained writeback
of idle entries (pages).
Move ac-time tracking under its own config option so that
it can be enabled (along with writeback) on systems without
DEBUG_FS.
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
Documentation/admin-guide/blockdev/zram.rst | 2 +-
drivers/block/zram/Kconfig | 11 ++++++++-
drivers/block/zram/zram_drv.c | 27 ++++++++++-----------
drivers/block/zram/zram_drv.h | 2 +-
4 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/Documentation/admin-guide/blockdev/zram.rst b/Documentation/admin-guide/blockdev/zram.rst
index e4551579cb12..ee2b0030d416 100644
--- a/Documentation/admin-guide/blockdev/zram.rst
+++ b/Documentation/admin-guide/blockdev/zram.rst
@@ -328,7 +328,7 @@ as idle::
From now on, any pages on zram are idle pages. The idle mark
will be removed until someone requests access of the block.
IOW, unless there is access request, those pages are still idle pages.
-Additionally, when CONFIG_ZRAM_MEMORY_TRACKING is enabled pages can be
+Additionally, when CONFIG_ZRAM_TRACK_ENTRY_ACTIME is enabled pages can be
marked as idle based on how long (in seconds) it's been since they were
last accessed::
diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig
index 0386b7da02aa..af201392ed52 100644
--- a/drivers/block/zram/Kconfig
+++ b/drivers/block/zram/Kconfig
@@ -69,9 +69,18 @@ config ZRAM_WRITEBACK
See Documentation/admin-guide/blockdev/zram.rst for more information.
+config ZRAM_TRACK_ENTRY_ACTIME
+ bool "Track access time of zram entries"
+ depends on ZRAM
+ help
+ With this feature zram tracks access time of every stored
+ entry (page), which can be used for a more fine grained IDLE
+ pages writeback.
+
config ZRAM_MEMORY_TRACKING
bool "Track zRam block status"
depends on ZRAM && DEBUG_FS
+ select ZRAM_TRACK_ENTRY_ACTIME
help
With this feature, admin can track the state of allocated blocks
of zRAM. Admin could see the information via
@@ -86,4 +95,4 @@ config ZRAM_MULTI_COMP
This will enable multi-compression streams, so that ZRAM can
re-compress pages using a potentially slower but more effective
compression algorithm. Note, that IDLE page recompression
- requires ZRAM_MEMORY_TRACKING.
+ requires ZRAM_TRACK_ENTRY_ACTIME.
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index d77d3664ca08..f6b286e7f310 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -174,6 +174,14 @@ static inline u32 zram_get_priority(struct zram *zram, u32 index)
return prio & ZRAM_COMP_PRIORITY_MASK;
}
+static void zram_accessed(struct zram *zram, u32 index)
+{
+ zram_clear_flag(zram, index, ZRAM_IDLE);
+#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
+ zram->table[index].ac_time = ktime_get_boottime();
+#endif
+}
+
static inline void update_used_max(struct zram *zram,
const unsigned long pages)
{
@@ -293,8 +301,9 @@ static void mark_idle(struct zram *zram, ktime_t cutoff)
zram_slot_lock(zram, index);
if (zram_allocated(zram, index) &&
!zram_test_flag(zram, index, ZRAM_UNDER_WB)) {
-#ifdef CONFIG_ZRAM_MEMORY_TRACKING
- is_idle = !cutoff || ktime_after(cutoff, zram->table[index].ac_time);
+#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
+ is_idle = !cutoff || ktime_after(cutoff,
+ zram->table[index].ac_time);
#endif
if (is_idle)
zram_set_flag(zram, index, ZRAM_IDLE);
@@ -317,7 +326,7 @@ static ssize_t idle_store(struct device *dev,
*/
u64 age_sec;
- if (IS_ENABLED(CONFIG_ZRAM_MEMORY_TRACKING) && !kstrtoull(buf, 0, &age_sec))
+ if (IS_ENABLED(CONFIG_ZRAM_TRACK_ENTRY_ACTIME) && !kstrtoull(buf, 0, &age_sec))
cutoff_time = ktime_sub(ktime_get_boottime(),
ns_to_ktime(age_sec * NSEC_PER_SEC));
else
@@ -841,12 +850,6 @@ static void zram_debugfs_destroy(void)
debugfs_remove_recursive(zram_debugfs_root);
}
-static void zram_accessed(struct zram *zram, u32 index)
-{
- zram_clear_flag(zram, index, ZRAM_IDLE);
- zram->table[index].ac_time = ktime_get_boottime();
-}
-
static ssize_t read_block_state(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
@@ -930,10 +933,6 @@ static void zram_debugfs_unregister(struct zram *zram)
#else
static void zram_debugfs_create(void) {};
static void zram_debugfs_destroy(void) {};
-static void zram_accessed(struct zram *zram, u32 index)
-{
- zram_clear_flag(zram, index, ZRAM_IDLE);
-};
static void zram_debugfs_register(struct zram *zram) {};
static void zram_debugfs_unregister(struct zram *zram) {};
#endif
@@ -1254,7 +1253,7 @@ static void zram_free_page(struct zram *zram, size_t index)
{
unsigned long handle;
-#ifdef CONFIG_ZRAM_MEMORY_TRACKING
+#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
zram->table[index].ac_time = 0;
#endif
if (zram_test_flag(zram, index, ZRAM_IDLE))
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index d090753f97be..3b94d12f41b4 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -69,7 +69,7 @@ struct zram_table_entry {
unsigned long element;
};
unsigned long flags;
-#ifdef CONFIG_ZRAM_MEMORY_TRACKING
+#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
ktime_t ac_time;
#endif
};
--
2.43.0.rc0.421.g78406f8d94-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-17 1:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-15 2:42 [PATCH 1/2] zram: split memory-tracking and ac-time tracking Sergey Senozhatsky
2023-11-15 2:42 ` [PATCH 2/2] zram: tweak writeback config help Sergey Senozhatsky
2023-11-16 14:27 ` [PATCH 1/2] zram: split memory-tracking and ac-time tracking Dmytro Maluka
2023-11-17 1:33 ` Sergey Senozhatsky
2023-11-17 1:35 ` [PATCHv2 " Sergey Senozhatsky
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.