On 2023/10/18 21:05, lijiang wrote:
On Tue, Oct 17, 2023 at 3:52 PM HAGIO KAZUHITO(萩尾 一仁)
<k-hagio-ab(a)nec.com>
wrote:
>> ---
>> defs.h | 26 +++++++++++++++++++++
>> diskdump.c | 66 ++++++++++++++++++++++++++++++++++++++++++++----------
>> 2 files changed, 80 insertions(+), 12 deletions(-)
>>
>> diff --git a/defs.h b/defs.h
>> index 96a7a2a..2038351 100644
>> --- a/defs.h
>> +++ b/defs.h
>> @@ -2225,6 +2225,7 @@ struct offset_table { /* stash
> of commonly-used offsets */
>> long module_memory_base;
>> long module_memory_size;
>> long irq_data_irq;
>> + long zspage_huge;
>> };
>>
>> struct size_table { /* stash of commonly-used sizes */
>> @@ -7210,6 +7211,19 @@ ulong try_zram_decompress(ulonglong pte_val,
> unsigned char *buf, ulong len, ulon
>> #define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT)
>> #define ZRAM_FLAG_SHIFT (1<<24)
>> #define ZRAM_FLAG_SAME_BIT (1<<25)
>> +
>> +struct zram_pageflags {
>> + long ZRAM_LOCK;
>> + long ZRAM_SAME;
>> +};
>> +
>> +/*
>> + * diskdump.c
>> + */
>> +extern struct zram_pageflags zram_pageflags;
>> +#define ZRAM_PAGEFLAG_INIT(X, Y) (zram_pageflags.X = Y)
>> +#define ZRAM_PAGEFLAG_VALUE(X) (zram_pageflags.X)
>
> Thank you for the update.
>
> I don't think these macros are necessary, so simplified the patch on my
> end. With rethinking the names, kept "ZRAM_FLAG_SHIFT" and
> "ZRAM_FLAG_SAME_BIT" as they are, and made some tweaks.
>
> Guanyou and Lianbo, is this attached patch OK?
>
>
The attached patch looks good to me, only two suggestions:
(I copied the following code block from the attached patch)
+static long ZRAM_FLAG_SHIFT;
+static long ZRAM_FLAG_SAME_BIT;
The ulong is good to me.
Ah, agree.
The former ZRAM_LOCK was a shift value and set by enumerator_value(char
*, long *) so it was long. I changed it to a mask value, so a vestige.
+
static void
zram_init(void)
{
+ long zram_lock;
+
MEMBER_OFFSET_INIT(zram_mempoll, "zram", "mem_pool");
MEMBER_OFFSET_INIT(zram_compressor, "zram", "compressor");
MEMBER_OFFSET_INIT(zram_table_flag, "zram_table_entry",
"flags");
if (INVALID_MEMBER(zram_table_flag))
MEMBER_OFFSET_INIT(zram_table_flag, "zram_table_entry",
"value");
STRUCT_SIZE_INIT(zram_table_entry, "zram_table_entry");
+ MEMBER_OFFSET_INIT(zspoll_size_class, "zs_pool",
"size_class");
+ MEMBER_OFFSET_INIT(size_class_size, "size_class", "size");
+ MEMBER_OFFSET_INIT(zspage_huge, "zspage", "huge");
+
+ if (enumerator_value("ZRAM_LOCK", &zram_lock))
+ ZRAM_FLAG_SHIFT = 1 << zram_lock;
+ else if (THIS_KERNEL_VERSION >= LINUX(6,1,0))
This depends on kernel version number, it might be more friendly for the
distribution to output some debug info as below:
if (CRASHDEBUG(1))
error(INFO, "ZRAM_FLAG_SHIFT=%lu\n", ZRAM_FLAG_SHIFT);
Once the related kernel patches are backported to an old kernel, the
similar checking may fail. But, at least we can know a little more with the
crash debug info.
Sounds good, then I would like to show the shift value instead of mask
value, so changed a little. Is the attached patch OK?
6.1:
crash> rd 7fb60bdff000
zram_flag_shift: 13
...
RHEL8:
crash> rd 7ff668048000
zram_flag_shift: 24
4.18 and later kernels has ZRAM_LOCK, so I think usually the else-if
block isn't used and it's kind of a fail-safe for a future change.
Anyway, thank you for the good comments.
Thanks,
Kazu