Hi lijiang

Changed 5,19,0 done.

arm64/pgtable: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE

Let's use one of the type bits: core-mm only supports 5, so there is no
need to consume 6.

Note that we might be able to reuse bit 1, but reusing bit 1 turned out
problematic in the past for PROT_NONE handling; so let's play safe and use
another bit.

Link: https://lkml.kernel.org/r/20220329164329.208407-5-david@redhat.com

Before:
crash> vtop 70504000
VIRTUAL     PHYSICAL
70504000    (not mapped)

PAGE DIRECTORY: ffffff80f265c000
   PGD: ffffff80f265c008 => 800000141537003
   PMD: ffffff8101537c10 => 800000141538003
   PTE: ffffff8101538820 => 12bc3e04

  PTE     vtop: cannot determine swap location

After:
crash> vtop 70504000
VIRTUAL     PHYSICAL
70504000    (not mapped)

PAGE DIRECTORY: ffffff80f265c000
   PGD: ffffff80f265c008 => 800000141537003
   PMD: ffffff8101537c10 => 800000141538003
   PTE: ffffff8101538820 => 12bc3e04

  PTE                     SWAP                  OFFSET
12bc3e04  /first_stage_ramdisk/dev/block/zram0  1227838

      VMA           START       END     FLAGS FILE
ffffff80dfe7b578   70504000   707bd000 100073

SWAP: /first_stage_ramdisk/dev/block/zram0  OFFSET: 1227838

Signed-off-by: chenguanyou <chenguanyou@xiaomi.com>
---
 arm64.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)


diff --git a/arm64.c b/arm64.c
index 39d5f04..ea1b51b 100644
--- a/arm64.c
+++ b/arm64.c
@@ -468,8 +468,16 @@ arm64_init(int when)
            }
        }

-
-       if (THIS_KERNEL_VERSION >= LINUX(4,0,0)) {
+       if (THIS_KERNEL_VERSION >= LINUX(5,19,0)) {
+           ms->__SWP_TYPE_BITS = 5;
+           ms->__SWP_TYPE_SHIFT = 3;
+           ms->__SWP_TYPE_MASK = ((1UL << ms->__SWP_TYPE_BITS) - 1);
+           ms->__SWP_OFFSET_SHIFT = (ms->__SWP_TYPE_BITS + ms->__SWP_TYPE_SHIFT);
+           ms->__SWP_OFFSET_BITS = 50;
+           ms->__SWP_OFFSET_MASK = ((1UL << ms->__SWP_OFFSET_BITS) - 1);
+           ms->PTE_PROT_NONE = (1UL << 58);
+           ms->PTE_FILE = 0;  /* unused */
+       } else if (THIS_KERNEL_VERSION >= LINUX(4,0,0)) {
            ms->__SWP_TYPE_BITS = 6;
            ms->__SWP_TYPE_SHIFT = 2;
            ms->__SWP_TYPE_MASK = ((1UL << ms->__SWP_TYPE_BITS) - 1);
-- 
2.39.0

--
Crash-utility mailing list
Crash-utility@redhat.com
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki


发件人: 陈冠有
发送时间: 2023年9月26日 19:57:02
收件人: lijiang; Discussion list for crash utility usage, maintenance and development
主题: 答复: [External Mail]Re: [PATCH] Fix "vtop" command to display the swapinfo for arm64 kernel 6.1+
 

arm64/pgtable: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE

Let's use one of the type bits: core-mm only supports 5, so there is no
need to consume 6.

Note that we might be able to reuse bit 1, but reusing bit 1 turned out
problematic in the past for PROT_NONE handling; so let's play safe and use
another bit.

Link: https://lkml.kernel.org/r/20220329164329.208407-5-david@redhat.com

Before:
crash> vtop 70504000
VIRTUAL     PHYSICAL
70504000    (not mapped)

PAGE DIRECTORY: ffffff80f265c000
   PGD: ffffff80f265c008 => 800000141537003
   PMD: ffffff8101537c10 => 800000141538003
   PTE: ffffff8101538820 => 12bc3e04

  PTE     vtop: cannot determine swap location

After:
crash> vtop 70504000
VIRTUAL     PHYSICAL
70504000    (not mapped)

PAGE DIRECTORY: ffffff80f265c000
   PGD: ffffff80f265c008 => 800000141537003
   PMD: ffffff8101537c10 => 800000141538003
   PTE: ffffff8101538820 => 12bc3e04

  PTE                     SWAP                  OFFSET
12bc3e04  /first_stage_ramdisk/dev/block/zram0  1227838

      VMA           START       END     FLAGS FILE
ffffff80dfe7b578   70504000   707bd000 100073

SWAP: /first_stage_ramdisk/dev/block/zram0  OFFSET: 1227838

Signed-off-by: chenguanyou <chenguanyou@xiaomi.com>
---
 arm64.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)


diff --git a/arm64.c b/arm64.c
index 39d5f04..ea1b51b 100644
--- a/arm64.c
+++ b/arm64.c
@@ -468,8 +468,16 @@ arm64_init(int when)
            }
        }

-
-       if (THIS_KERNEL_VERSION >= LINUX(4,0,0)) {
+       if (THIS_KERNEL_VERSION >= LINUX(6,1,0)) {
+           ms->__SWP_TYPE_BITS = 5;
+           ms->__SWP_TYPE_SHIFT = 3;
+           ms->__SWP_TYPE_MASK = ((1UL << ms->__SWP_TYPE_BITS) - 1);
+           ms->__SWP_OFFSET_SHIFT = (ms->__SWP_TYPE_BITS + ms->__SWP_TYPE_SHIFT);
+           ms->__SWP_OFFSET_BITS = 50;
+           ms->__SWP_OFFSET_MASK = ((1UL << ms->__SWP_OFFSET_BITS) - 1);
+           ms->PTE_PROT_NONE = (1UL << 58);
+           ms->PTE_FILE = 0;  /* unused */
+       } else if (THIS_KERNEL_VERSION >= LINUX(4,0,0)) {
            ms->__SWP_TYPE_BITS = 6;
            ms->__SWP_TYPE_SHIFT = 2;
            ms->__SWP_TYPE_MASK = ((1UL << ms->__SWP_TYPE_BITS) - 1);
-- 
2.39.0

--
Crash-utility mailing list
Crash-utility@redhat.com
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

发件人: lijiang <lijiang@redhat.com>
发送时间: 2023年9月26日 19:44:43
收件人: Discussion list for crash utility usage, maintenance and development
抄送: 陈冠有
主题: [External Mail]Re: [PATCH] Fix "vtop" command to display the swapinfo for arm64 kernel 6.1+
 

[外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec@xiaomi.com进行反馈

Hi, Cheng
Thank you for the fix.
On Thu, Sep 14, 2023 at 4:05 PM <crash-utility-request@redhat.com> wrote:
Date: Thu, 14 Sep 2023 07:51:31 +0000
From: ??? <chenguanyou@xiaomi.com>
To: "crash-utility@redhat.com" <crash-utility@redhat.com>
Cc: "lijiang@redhat.com" <lijiang@redhat.com>, "k-hagio-ab@nec.com"
        <k-hagio-ab@nec.com>
Subject: [Crash-utility] [PATCH] Fix "vtop" command to display the
        swapinfo for arm64 kernel 6.1+
Message-ID: <bba8281d4e4f41308ce095c89fe04d1c@xiaomi.com>
Content-Type: text/plain; charset="gb2312"

#define __SWP_TYPE_SHIFT    3
#define __SWP_TYPE_BITS     5


Can you help to add the related kernel commit to the patch log? For this one, it should be the following commit:
570ef363509b ("arm64/pgtable: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE")

Before:
crash> vtop 70504000
VIRTUAL     PHYSICAL
70504000    (not mapped)

PAGE DIRECTORY: ffffff80f265c000
   PGD: ffffff80f265c008 => 800000141537003
   PMD: ffffff8101537c10 => 800000141538003
   PTE: ffffff8101538820 => 12bc3e04

  PTE     vtop: cannot determine swap location

After:
crash> vtop 70504000
VIRTUAL     PHYSICAL
70504000    (not mapped)

PAGE DIRECTORY: ffffff80f265c000
   PGD: ffffff80f265c008 => 800000141537003
   PMD: ffffff8101537c10 => 800000141538003
   PTE: ffffff8101538820 => 12bc3e04

  PTE                     SWAP                  OFFSET
12bc3e04  /first_stage_ramdisk/dev/block/zram0  1227838

      VMA           START       END     FLAGS FILE
ffffff80dfe7b578   70504000   707bd000 100073

SWAP: /first_stage_ramdisk/dev/block/zram0  OFFSET: 1227838

Signed-off-by: chenguanyou <chenguanyou@xiaomi.com>
---
 arm64.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arm64.c b/arm64.c
index 39d5f04..ea1b51b 100644
--- a/arm64.c
+++ b/arm64.c
@@ -468,8 +468,16 @@ arm64_init(int when)
            }
        }

-
-       if (THIS_KERNEL_VERSION >= LINUX(4,0,0)) {
+       if (THIS_KERNEL_VERSION >= LINUX(6,1,0)) {

In addition, the related kernel change was done in v5.19-rc1, not in the linux 6.1.0.

$ git describe --contains 570ef363509b031966ed669fa002c8441dff273c
v5.19-rc1~138^2~226

So it should be the '>=LINUX(5,19,0)', can you also help to confirm this one?
 
Thanks
Lianbo

+           ms->__SWP_TYPE_BITS = 5;
+           ms->__SWP_TYPE_SHIFT = 3;
+           ms->__SWP_TYPE_MASK = ((1UL << ms->__SWP_TYPE_BITS) - 1);
+           ms->__SWP_OFFSET_SHIFT = (ms->__SWP_TYPE_BITS + ms->__SWP_TYPE_SHIFT);
+           ms->__SWP_OFFSET_BITS = 50;
+           ms->__SWP_OFFSET_MASK = ((1UL << ms->__SWP_OFFSET_BITS) - 1);
+           ms->PTE_PROT_NONE = (1UL << 58);
+           ms->PTE_FILE = 0;  /* unused */
+       } else if (THIS_KERNEL_VERSION >= LINUX(4,0,0)) {
            ms->__SWP_TYPE_BITS = 6;
            ms->__SWP_TYPE_SHIFT = 2;
            ms->__SWP_TYPE_MASK = ((1UL << ms->__SWP_TYPE_BITS) - 1);
--
2.39.0
#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! 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!******/#