From: Kazuhito Hagio <k-hagio...@nec.com>

Kernel commit 7863dcc72d0f ("pid: allow pid_max to be set per pid
namespace") moved the pid_max variable into init_pid_ns.  Without the
patch, the "log -c" option fails with the following error:

  crash> log -c
  log: cannot resolve: "pid_max"

While it is possible to track the pid_max value to init_pid_ns.pid_max,
considering the option's availability, it might be better not to do so
just for the sake of printing width.  Furthermore, the current
PID_MAX_LIMIT is 4194304, which does not exceed PID_CHARS_DEFAULT(8).

Signed-off-by: Kazuhito Hagio <k-hagio...@nec.com>
---
 printk.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/printk.c b/printk.c
index be842a759549..95db7e607e4c 100644
--- a/printk.c
+++ b/printk.c
@@ -285,8 +285,9 @@ dump_lockless_record_log(int msg_flags)
        if (msg_flags & SHOW_LOG_CALLER) {
                unsigned int pidmax;
 
-               get_symbol_data("pid_max", sizeof(pidmax), &pidmax);
-               if (pidmax <= 99999)
+               if (!try_get_symbol_data("pid_max", sizeof(pidmax), &pidmax))
+                       m.pid_max_chars = PID_CHARS_DEFAULT;
+               else if (pidmax <= 99999)
                        m.pid_max_chars = 6;
                else if (pidmax <= 999999)
                        m.pid_max_chars = 7;
-- 
2.31.1
--
Crash-utility mailing list -- devel@lists.crash-utility.osci.io
To unsubscribe send an email to devel-le...@lists.crash-utility.osci.io
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

Reply via email to