[Crash-utility] Re: [BUG FIXED]fix bug of CACHED in kmem -i show memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023/12/07 16:57, Lianbo Jiang wrote:

>>> (gdb)  p nr_swapper_spaces
>>> $4 = <optimized out>
>> Thank you folks, for the various information.
>>
>> Apparently the data of nr_swapper_spaces exists in the kernel, but its
>> symbol does not exist.  I think this means that we cannot calculate the
>> number of pages from swapper_spaces[] with such a debuginfo, because we
>> cannot get the array size of a swapper_spaces entry.
> 
> That's correct, Kazu.
> 
> 
>> So I'd like to go with Johan's patch.
>>
>> cc -c -g -DX86_64 -DLZO -DSNAPPY -DGDB_10_2  memory.c -Wall -O2
>> -Wstrict-prototypes -Wmissing-prototypes -fstack-protector
>> -Wformat-security
>> memory.c: In function dump_kmeminfo:
>> memory.c:8612:50: warning: pointer targets in passing argument 2 of
>> dump_vm_stat differ in signedness [-Wpointer-sign]
>>    8612 |                 if (dump_vm_stat("NR_SWAPCACHE",
>> &swapper_space_nrpages, 0)) {
>>         |
>> ^~~~~~~~~~~~~~~~~~~~~~
>>         |                                                  |
>>         |                                                  ulong * {aka
>> long unsigned int *}
>> memory.c:298:33: note: expected long int * but argument is of type ulong
>> * {aka long unsigned int *}
>>     298 | static int dump_vm_stat(char *, long *, ulong);
>>         |                                 ^~~~~~
>>
>> So with the following,
>>
>> -       ulong swapper_space_nrpages;
>> +       long swapper_space_nrpages;
> 
> Looks good. Maybe the patch log also needs to be improved a little bit.
> 
> Although the checking of kernel version looks not very good, seems no 
> better way.

hmm, this sounds strange.  My ack is for Johan's patch (attached), which 
does not have kernel version check, is this ok?  sorry for confusing.

Johan, your patch does not have your Signed-off-by tag, could I have it?

Thanks,
Kazu
From 1ba60970180866f1bdb2ef8cacf6f600e5dad4ef Mon Sep 17 00:00:00 2001
From: Johan Erlandsson <johan.erlandsson@xxxxxxxx>
Date: Wed, 19 Apr 2023 11:26:04 +0200
Subject: [PATCH] read swapcache usage when nr_swapper_spaces isn't available

In 5.12 the following change was introduced:
b6038942480e574c697ea1a80019bbe586c1d654

Then the variable 'nr_swapper_spaces' is not read (unless
CONFIG_DEBUG_VM=y).  In GKI builds this variable is then optimized
out. But the same change provided a new way to obtain the same
information, using NR_SWAPCACHE.
---
 memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/memory.c b/memory.c
index 791194a..439e6e3 100644
--- a/memory.c
+++ b/memory.c
@@ -8609,7 +8609,8 @@ dump_kmeminfo(void)
 		char *swapper_space = GETBUF(SIZE(address_space));
 
 		swapper_space_nrpages = 0;
-		if (symbol_exists("nr_swapper_spaces") &&
+		if (dump_vm_stat("NR_SWAPCACHE", &swapper_space_nrpages, 0)) {
+		} else if (symbol_exists("nr_swapper_spaces") &&
 			(len = get_array_length("nr_swapper_spaces",
 				NULL, 0))) {
 			char *nr_swapper_space =
-- 
2.42.0

--
Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux