Hi I have also seen this problem on GKI kernel [1]. They are for instance built with clang, might have an impact. So the 'nr_swapper_spaces' appear to be optimized out. Probably because of change [2]. I made a change to try handle the case, patch attached. Regards Johan - [1] https://source.android.com/docs/core/architecture/kernel/gki-android13-5_15-release-builds - [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b6038942480e574c697ea1a80019bbe586c1d654 ________________________________________ From: 薛国伦 <xueguolun@xxxxxxxxxx> Sent: Friday, 1 December 2023 09:07 To: HAGIO KAZUHITO(萩尾 一仁); devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx Cc: Lianbo Jiang Subject: [Crash-utility] Re: [External Mail]Re: [BUG FIXED]fix bug of CACHED in kmem -i show memory Hi kazu: 1. I know that kernel have nr_swapper_spaces since kernel 4. 11 which brought into kernel with struct address_space *swapper_spaces[] my team think GKI vmlinux did not have nr_swapper_spaces this symbol, may due to compile rule changed ZjQcmQRYFpfptBannerStart Caution : This email originated from outside of Sony. Do not click links or open any attachments unless you recognize the sender and know the content is safe. Please report phishing if unsure. ZjQcmQRYFpfptBannerEnd Hi kazu: 1. I know that kernel have nr_swapper_spaces since kernel 4.11 which brought into kernel with struct address_space *swapper_spaces[] my team think GKI vmlinux did not have nr_swapper_spaces this symbol, may due to compile rule changed in AOSP code. we will try to find the root cause of vmlinux without symbol name nr_swappera_space. >> RELEASE: 6.1.25-android14-11-maybe-dirty-qki-consolidate >> crash> nr_swapper_spaces >> crash: command not found: nr_swapper_spaces 2. I printf log of crash when execute kmem -i, it run into branch of "symbol_exists("swapper_spaces")", also can not find nr_swapper_spaces if (symbol_exists("nr_swapper_spaces") { ...... } else if (symbol_exists("swapper_spaces") { ...... } else if (symbol_exists("swapper_space") { ...... } 3. using my patch, it can fix output log of kmem -i which CACHED show not right. Fix before: crash> kmem -i PAGES TOTAL PERCENTAGE TOTAL MEM 2854115 10.9 GB ---- FREE 169699 662.9 MB 5% of TOTAL MEM USED 2684416 10.2 GB 94% of TOTAL MEM SHARED 891094 3.4 GB 31% of TOTAL MEM BUFFERS 329 1.3 MB 0% of TOTAL MEM CACHED 873327085626 3331478.4 GB 30598875% of TOTAL MEM SLAB 230128 898.9 MB 8% of TOTAL MEM Fix after: crash> kmem -i PAGES TOTAL PERCENTAGE TOTAL MEM 2854115 10.9 GB ---- FREE 169699 662.9 MB 5% of TOTAL MEM USED 2684416 10.2 GB 94% of TOTAL MEM SHARED 891094 3.4 GB 31% of TOTAL MEM BUFFERS 329 1.3 MB 0% of TOTAL MEM CACHED 1729018 6.6 GB 60% of TOTAL MEM SLAB 230128 898.9 MB 8% of TOTAL MEM I think crash tools without my patch, maybe miss some situation like this which symbol miss in kenrel vmlinux. I think that using both branch of symbol_exist("nr_swapper_spaces") and symbol_exists("swapper_spaces") means to double check the situation of all kinds of kernel and vmlinux. It seen that bring my patch can deal with more unusual situation and make crash tool more compatible. Thanks! Best Regards ________________________________ From: HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@xxxxxxx> Sent: Friday, December 1, 2023 3:08:03 PM To: 薛国伦; devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx Cc: Lianbo Jiang Subject: Re: [External Mail]Re: [Crash-utility] [BUG FIXED]fix bug of CACHED in kmem -i show memory [外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec@xxxxxxxxxx进行反馈 On 2023/11/30 22:05, 薛国伦 wrote: > Hi kazu: > > > 1. I found that vmlinux of kernel-6.1 did not have symbol nr_swapper_spaces but only have swapper_spaces > > Also check in GKI vmlinux, can not find nr_swapper_spaces Hmm, upstream kernel 6.1 has it. $ git show v6.1:mm/swap_state.c struct address_space *swapper_spaces[MAX_SWAPFILES] __read_mostly; static unsigned int nr_swapper_spaces[MAX_SWAPFILES] __read_mostly; > > It may have some problem in symbol of nr_swapper_spaces > > > 2. I think that crash tools will check nr_swapper_spaces first and then check *swapper_spaces, swaper_space[] last. > > so first check nr_swapper_spaces not found, crash tool can use *swapper_spaces to enhance compatibility. > > The patch i send can resolve this situation which nr_swapper_spaces symbols can not found. But I cannot determine whether your patch is correct and should be applied, without kernel patches or the cause of no nr_swapper_spaces. Could you please find the information (e.g. links) of the related kernel patches? Thanks, Kazu #/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#
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