Skip to contentSkip to conversation

kernel/pid: Remove default pid_max value

PATCH In review Michal Koutný 4 participants 13 messages Apr 8, 2024 – May 13, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover kernel/pid: Remove default pid_max value

TL;DR excerpt from commit 02/03:

The kernel provides mechanisms, while it should not imply policies -- default pid_max seems to be an example of the policy that does not fit all. At the same time pid_max must have some value assigned, so use the end of the allowed range -- pid_max_max.

More details are in that commit's message. The other two commits are related preparation and less related refresh in code that somewhat references pid_max.

Michal Koutný (3):
tracing: Remove dependency of saved_cmdlines_buffer on PID_MAX_DEFAULT kernel/pid: Remove default pid_max value
tracing: Compare pid_max against pid_list capacity

 include/linux/pid.h               |  4 ++--
 include/linux/threads.h           | 15 ++++-----------
 kernel/pid.c                      |  8 +++-----
 kernel/trace/pid_list.c           |  6 +++---
 kernel/trace/pid_list.h           |  4 ++--
 kernel/trace/trace_sched_switch.c | 11 ++++++-----
 6 files changed, 20 insertions(+), 28 deletions(-)

base-commit: fec50db7033ea478773b159e0e2efb135270e3b7

Signature · 1 line
2.44.0
#1 lore raw

PATCH 1/3 tracing: Remove dependency of saved_cmdlines_buffer on PID_MAX_DEFAULT

Calculations into map_pid_to_cmdline use PID_MAX_DEFAULT but they actually depend on the size of map_pid_to_cmdline. The size of the map may be arbitrary. First, refer to the map size where necessary, second, pick a good value for the size of the map.
Since the buffer is allocated at boot (i.e. user cannot affect its size later), accounting for full PID_MAX_LIMIT would inflate map's size unnecessarily (4*4M) for all users. Stick to the original value of 4*32k, the commit 785e3c0a3a87 ("tracing: Map all PIDs to command lines") explains why it still works for higher pids.

The point of this exercise is to remove dependency on PID_MAX_DEFAULT.

---
 kernel/trace/trace_sched_switch.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
kernel/trace/trace_sched_switch.c +6 -5
index 8a407adb0e1c..aca2dafdd97a 100644
@@ -161,6 +161,7 @@ static size_t tgid_map_max;
 
 #define SAVED_CMDLINES_DEFAULT 128
 #define NO_CMDLINE_MAP UINT_MAX
+#define PID_MAP_SIZE (CONFIG_BASE_SMALL ? 0x1000 : 0x8000)
 /*
  * Preemption must be disabled before acquiring trace_cmdline_lock.
  * The various trace_arrays' max_lock must be acquired in a context
@@ -168,7 +169,7 @@ static size_t tgid_map_max;
  */
 static arch_spinlock_t trace_cmdline_lock = __ARCH_SPIN_LOCK_UNLOCKED;
 struct saved_cmdlines_buffer {
-	unsigned map_pid_to_cmdline[PID_MAX_DEFAULT+1];
+	unsigned map_pid_to_cmdline[PID_MAP_SIZE];
 	unsigned *map_cmdline_to_pid;
 	unsigned cmdline_num;
 	int cmdline_idx;
@@ -248,7 +249,7 @@ int trace_save_cmdline(struct task_struct *tsk)
 	if (!tsk->pid)
 		return 1;
 
-	tpid = tsk->pid & (PID_MAX_DEFAULT - 1);
+	tpid = tsk->pid % PID_MAP_SIZE;
 
 	/*
 	 * It's not the end of the world if we don't get
@@ -294,7 +295,7 @@ static void __trace_find_cmdline(int pid, char comm[])
 		return;
 	}
 
-	tpid = pid & (PID_MAX_DEFAULT - 1);
+	tpid = pid % PID_MAP_SIZE;
 	map = savedcmd->map_pid_to_cmdline[tpid];
 	if (map != NO_CMDLINE_MAP) {
 		tpid = savedcmd->map_cmdline_to_pid[map];
@@ -645,8 +646,8 @@ tracing_saved_cmdlines_size_write(struct file *filp, const char __user *ubuf,
 	if (ret)
 		return ret;
 
-	/* must have at least 1 entry or less than PID_MAX_DEFAULT */
-	if (!val || val > PID_MAX_DEFAULT)
+	/* must have at least 1 entry or fit into map_pid_to_cmdline */
+	if (!val || val >= PID_MAP_SIZE)
 		return -EINVAL;
 
 	ret = tracing_resize_saved_cmdlines((unsigned int)val);
Signature · 1 line
2.44.0
maintainer
#2 lore raw

Re: [PATCH 1/3] tracing: Remove dependency of saved_cmdlines_buffer on PID_MAX_DEFAULT

kernel/trace/trace_sched_switch.c static void __trace_find_cmdline(int pid, char comm[]) · line 298

Quoted 6 lines · On Mon, 8 Apr 2024 16:58:17 +0200 Michal Koutný <[email protected]> wrote:
kernel/trace/trace_sched_switch.c +1 -1
@@ -294,7 +295,7 @@ static void __trace_find_cmdline(int pid, char comm[])
 		return;
 	}
 
-	tpid = pid & (PID_MAX_DEFAULT - 1);
+	tpid = pid % PID_MAP_SIZE;

Does that compile to the same? This is a fast path.

-- Steve

Quoted 3 lines
kernel/trace/trace_sched_switch.c +0 -0
 	map = savedcmd->map_pid_to_cmdline[tpid];
 	if (map != NO_CMDLINE_MAP) {
 		tpid = savedcmd->map_cmdline_to_pid[map];
#3 lore raw

Re: [PATCH 1/3] tracing: Remove dependency of saved_cmdlines_buffer on PID_MAX_DEFAULT

Quoted 4 lines · Steven Rostedt

kernel/trace/trace_sched_switch.c static void __trace_find_cmdline(int pid, char comm[]) · line 298

Quoted 2 lines
kernel/trace/trace_sched_switch.c +1 -1
-	tpid = pid & (PID_MAX_DEFAULT - 1);
+	tpid = pid % PID_MAP_SIZE;

Does that compile to the same? This is a fast path.

I didn't check.
If fast is the intetion, I would change it to something like BUILD_BUG_ON(!(PID_MAP_SIZE % 2)) and keep the bit operation without reliance on compiler optimizations.

Thanks for the response (I may not follow up on this single commit though).

Michal

#4 lore raw

PATCH 2/3 kernel/pid: Remove default pid_max value

In reply to Michal Koutný

pid_max is a per-pidns (thus global too) limit on a number of tasks the kernel admits. The knob can be configured by admin in the range between pid_max_min and pid_max_max (sic). The default value sits between those and it typically equals max(32k, 1k*nr_cpus).

The nr_cpu scaling was introduced in commit 72680a191b93 ("pids:
increase pid_max based on num_possible_cpus") to accommodate kernel's own helper tasks (before workqueues). Generally, 1024 tasks/cpu cap is too much if they were all running and it is also too little when they are idle (memory being bottleneck).

The kernel also provides other mechanisms to restrict number of tasks -- threads-max sysctl and RLIMIT_NPROC with memory-scaled defaults and generic pids cgroup controller (the last one being the solution of fork-bombs, with qualified limits set up by admin).

The kernel provides mechanisms, while it should not imply policies -- default pid_max seems to be an example of the policy that does not fit all. At the same time pid_max must have some value assigned, so use the end of the allowed range -- pid_max_max.

This change thus increases initial pid_max from 32k to 4M (x86_64 defconfig).

This has effect on size of structure that alloc_pid/idr_alloc_cyclic eventually uses and structure that kernel tracing uses with 'record-tgid' (~16 MiB).

---
 include/linux/pid.h     |  4 ++--
 include/linux/threads.h | 15 ++++-----------
 kernel/pid.c            |  8 +++-----
 3 files changed, 9 insertions(+), 18 deletions(-)
include/linux/pid.h +2 -2
index a3aad9b4074c..0d191ac02958 100644
@@ -106,8 +106,8 @@ extern void exchange_tids(struct task_struct *task, struct task_struct *old);
 extern void transfer_pid(struct task_struct *old, struct task_struct *new,
 			 enum pid_type);
 
-extern int pid_max;
-extern int pid_max_min, pid_max_max;
+extern int pid_max_min, pid_max;
+extern const int pid_max_max;
 
 /*
  * look up a PID in the hash table. Must be called with the tasklist_lock
include/linux/threads.h +4 -11
index c34173e6c5f1..43f8f38a0c13 100644
@@ -22,25 +22,18 @@
 
 #define MIN_THREADS_LEFT_FOR_ROOT 4
 
-/*
- * This controls the default maximum pid allocated to a process
- */
-#define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000)
-
 /*
  * A maximum of 4 million PIDs should be enough for a while.
  * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.]
  */
 #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \
-	(sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT))
+	(sizeof(long) > 4 ? 4 * 1024 * 1024 : 0x8000))
 
 /*
- * Define a minimum number of pids per cpu.  Heuristically based
- * on original pid max of 32k for 32 cpus.  Also, increase the
- * minimum settable value for pid_max on the running system based
- * on similar defaults.  See kernel/pid.c:pid_idr_init() for details.
+ * Define a minimum number of pids per cpu. Mainly to accommodate
+ * smpboot_register_percpu_thread() kernel threads.
+ * See kernel/pid.c:pid_idr_init() for details.
  */
-#define PIDS_PER_CPU_DEFAULT	1024
 #define PIDS_PER_CPU_MIN	8
 
 #endif
kernel/pid.c +3 -5
index da76ed1873f7..24ae505ac3b0 100644
@@ -60,10 +60,10 @@ struct pid init_struct_pid = {
 	}, }
 };
 
-int pid_max = PID_MAX_DEFAULT;
+int pid_max = PID_MAX_LIMIT;
 
 int pid_max_min = RESERVED_PIDS + 1;
-int pid_max_max = PID_MAX_LIMIT;
+const int pid_max_max = PID_MAX_LIMIT;
 /*
  * Pseudo filesystems start inode numbering after one. We use Reserved
  * PIDs as a natural offset.
@@ -652,9 +652,7 @@ void __init pid_idr_init(void)
 	/* Verify no one has done anything silly: */
 	BUILD_BUG_ON(PID_MAX_LIMIT >= PIDNS_ADDING);
 
-	/* bump default and minimum pid_max based on number of cpus */
-	pid_max = min(pid_max_max, max_t(int, pid_max,
-				PIDS_PER_CPU_DEFAULT * num_possible_cpus()));
+	/* bump minimum pid_max based on number of cpus */
 	pid_max_min = max_t(int, pid_max_min,
 				PIDS_PER_CPU_MIN * num_possible_cpus());
 	pr_info("pid_max: default: %u minimum: %u\n", pid_max, pid_max_min);
Signature · 1 line
2.44.0
maintainer
#5 lore raw
Quoted 7 lines · On Mon, 8 Apr 2024 16:58:18 +0200 Michal Koutný <[email protected]> wrote:

The kernel provides mechanisms, while it should not imply policies -- default pid_max seems to be an example of the policy that does not fit all. At the same time pid_max must have some value assigned, so use the end of the allowed range -- pid_max_max.

This change thus increases initial pid_max from 32k to 4M (x86_64 defconfig).

That seems like a large change.

It isn't clear why we'd want to merge this patchset. Does it improve anyone's life and if so, how?

#6 lore raw

Hello.

Quoted 1 line · Andrew Morton

That seems like a large change.

In what sense is it large?

I tried to lookup the code parts that depend on this default and either add the other patches or mention the impact (that part could be more thorough) in the commit message.

Quoted 2 lines

It isn't clear why we'd want to merge this patchset. Does it improve anyone's life and if so, how?

- kernel devs who don't care about policy
- policy should be decided by distros/users, not in kernel

- users who need many threads
- current default is too low
- this is one more place to look at when configuring

- users who want to prevent fork-bombs
- current default is ineffective (too high), false feeling of safety
- i.e. they should configure appropriate mechanism appropriately

I thought that the first point alone would be convincing and that only scaling impact might need clarification.

Regards,
Michal

maintainer
#7 lore raw
Quoted 6 lines · On Thu, 11 Apr 2024 17:40:02 +0200 Michal Koutný <[email protected]> wrote:

Hello.

Quoted 1 line · Andrew Morton

That seems like a large change.

In what sense is it large?

A large increase in the maximum number of processes. Or did I misinterpret?

#8 lore raw
Quoted 1 line · Andrew Morton

A large increase in the maximum number of processes.

The change from (some) default to effective infinity is the crux of the change. Because that is only a number.
(Thus I don't find the number's 12700% increase alone a big change.)

Actual maximum amount of processes is "workload dependent" and hence should be determined based on the particular workload.

Quoted 1 line

Or did I misinterpret?

I thought you saw an issue with projection of that number into sizings based on the default. Which of them comprises the large change in your eyes?

Thanks,
Michal

#9 lore raw
In reply to Michal Koutný
kernel test robot noticed the following build warnings:

Hi Michal,

kernel test robot noticed the following build warnings:

[auto build test WARNING on fec50db7033ea478773b159e0e2efb135270e3b7]

url:    https://github.com/intel-lab-lkp/linux/commits/Michal-Koutn/tracing-Remove-dependency-of-saved_cmdlines_buffer-on-PID_MAX_DEFAULT/20240408-230031
base:   fec50db7033ea478773b159e0e2efb135270e3b7
patch link:    https://lore.kernel.org/r/20240408145819.8787-3-mkoutny%40suse.com
patch subject: [PATCH 2/3] kernel/pid: Remove default pid_max value
config: alpha-allnoconfig (https://download.01.org/0day-ci/archive/20240409/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240409/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> kernel/sysctl.c:1819:35: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

1819 | .extra2 = &pid_max_max,
| ^

vim +/const +1819 kernel/sysctl.c

f461d2dcd511c0 Christoph Hellwig   2020-04-24  1617  
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1618  static struct ctl_table kern_table[] = {
^1da177e4c3f41 Linus Torvalds      2005-04-16  1619  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1620  		.procname	= "panic",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1621  		.data		= &panic_timeout,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1622  		.maxlen		= sizeof(int),
49f0ce5f92321c Jerome Marchand     2014-01-21  1623  		.mode		= 0644,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1624  		.proc_handler	= proc_dointvec,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1625  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1626  #ifdef CONFIG_PROC_SYSCTL
^1da177e4c3f41 Linus Torvalds      2005-04-16  1627  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1628  		.procname	= "tainted",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1629  		.maxlen 	= sizeof(long),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1630  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1631  		.proc_handler	= proc_taint,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1632  	},
2da02997e08d3e David Rientjes      2009-01-06  1633  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1634  		.procname	= "sysctl_writes_strict",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1635  		.data		= &sysctl_writes_strict,
9e3961a0979817 Prarit Bhargava     2014-12-10  1636  		.maxlen		= sizeof(int),
2da02997e08d3e David Rientjes      2009-01-06  1637  		.mode		= 0644,
9e3961a0979817 Prarit Bhargava     2014-12-10  1638  		.proc_handler	= proc_dointvec_minmax,
78e36f3b0dae58 Xiaoming Ni         2022-01-21  1639  		.extra1		= SYSCTL_NEG_ONE,
eec4844fae7c03 Matteo Croce        2019-07-18  1640  		.extra2		= SYSCTL_ONE,
2da02997e08d3e David Rientjes      2009-01-06  1641  	},
964c9dff009189 Alexander Popov     2018-08-17  1642  #endif
1efff914afac8a Theodore Ts'o       2015-03-17  1643  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1644  		.procname	= "print-fatal-signals",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1645  		.data		= &print_fatal_signals,
964c9dff009189 Alexander Popov     2018-08-17  1646  		.maxlen		= sizeof(int),
1efff914afac8a Theodore Ts'o       2015-03-17  1647  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1648  		.proc_handler	= proc_dointvec,
1efff914afac8a Theodore Ts'o       2015-03-17  1649  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1650  #ifdef CONFIG_SPARC
^1da177e4c3f41 Linus Torvalds      2005-04-16  1651  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1652  		.procname	= "reboot-cmd",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1653  		.data		= reboot_command,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1654  		.maxlen		= 256,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1655  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1656  		.proc_handler	= proc_dostring,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1657  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1658  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1659  		.procname	= "stop-a",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1660  		.data		= &stop_a_enabled,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1661  		.maxlen		= sizeof (int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1662  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1663  		.proc_handler	= proc_dointvec,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1664  	},
06808b0827e1cd Lee Schermerhorn    2009-12-14  1665  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1666  		.procname	= "scons-poweroff",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1667  		.data		= &scons_pwroff,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1668  		.maxlen		= sizeof (int),
06808b0827e1cd Lee Schermerhorn    2009-12-14  1669  		.mode		= 0644,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1670  		.proc_handler	= proc_dointvec,
06808b0827e1cd Lee Schermerhorn    2009-12-14  1671  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1672  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1673  #ifdef CONFIG_SPARC64
4518085e127dff Kemi Wang           2017-11-15  1674  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1675  		.procname	= "tsb-ratio",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1676  		.data		= &sysctl_tsb_ratio,
4518085e127dff Kemi Wang           2017-11-15  1677  		.maxlen		= sizeof (int),
4518085e127dff Kemi Wang           2017-11-15  1678  		.mode		= 0644,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1679  		.proc_handler	= proc_dointvec,
4518085e127dff Kemi Wang           2017-11-15  1680  	},
06808b0827e1cd Lee Schermerhorn    2009-12-14  1681  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1682  #ifdef CONFIG_PARISC
^1da177e4c3f41 Linus Torvalds      2005-04-16  1683  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1684  		.procname	= "soft-power",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1685  		.data		= &pwrsw_enabled,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1686  		.maxlen		= sizeof (int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1687  		.mode		= 0644,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1688  		.proc_handler	= proc_dointvec,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1689  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1690  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1691  #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
d1c3fb1f8f29c4 Nishanth Aravamudan 2007-12-17  1692  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1693  		.procname	= "unaligned-trap",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1694  		.data		= &unaligned_enabled,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1695  		.maxlen		= sizeof (int),
d1c3fb1f8f29c4 Nishanth Aravamudan 2007-12-17  1696  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1697  		.proc_handler	= proc_dointvec,
d1c3fb1f8f29c4 Nishanth Aravamudan 2007-12-17  1698  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1699  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1700  #ifdef CONFIG_STACK_TRACER
76ab0f530e4a01 Mel Gorman          2010-05-24  1701  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1702  		.procname	= "stack_tracer_enabled",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1703  		.data		= &stack_tracer_enabled,
76ab0f530e4a01 Mel Gorman          2010-05-24  1704  		.maxlen		= sizeof(int),
2da02997e08d3e David Rientjes      2009-01-06  1705  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1706  		.proc_handler	= stack_trace_sysctl,
76ab0f530e4a01 Mel Gorman          2010-05-24  1707  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1708  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1709  #ifdef CONFIG_TRACING
5e7719058079a1 Mel Gorman          2010-05-24  1710  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1711  		.procname	= "ftrace_dump_on_oops",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1712  		.data		= &ftrace_dump_on_oops,
19f0423fd55c30 Huang Yiwei         2024-02-23  1713  		.maxlen		= MAX_TRACER_SIZE,
5e7719058079a1 Mel Gorman          2010-05-24  1714  		.mode		= 0644,
19f0423fd55c30 Huang Yiwei         2024-02-23  1715  		.proc_handler	= proc_dostring,
5e7719058079a1 Mel Gorman          2010-05-24  1716  	},
5bbe3547aa3ba5 Eric B Munson       2015-04-15  1717  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1718  		.procname	= "traceoff_on_warning",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1719  		.data		= &__disable_trace_on_warning,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1720  		.maxlen		= sizeof(__disable_trace_on_warning),
5bbe3547aa3ba5 Eric B Munson       2015-04-15  1721  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1722  		.proc_handler	= proc_dointvec,
5bbe3547aa3ba5 Eric B Munson       2015-04-15  1723  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1724  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1725  		.procname	= "tracepoint_printk",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1726  		.data		= &tracepoint_printk,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1727  		.maxlen		= sizeof(tracepoint_printk),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1728  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1729  		.proc_handler	= tracepoint_printk_sysctl,
1c30844d2dfe27 Mel Gorman          2018-12-28  1730  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1731  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1732  #ifdef CONFIG_MODULES
8ad4b1fb820534 Rohit Seth          2006-01-08  1733  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1734  		.procname	= "modprobe",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1735  		.data		= &modprobe_path,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1736  		.maxlen		= KMOD_PATH_LEN,
8ad4b1fb820534 Rohit Seth          2006-01-08  1737  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1738  		.proc_handler	= proc_dostring,
8ad4b1fb820534 Rohit Seth          2006-01-08  1739  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1740  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1741  		.procname	= "modules_disabled",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1742  		.data		= &modules_disabled,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1743  		.maxlen		= sizeof(int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1744  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1745  		/* only handle a transition from default "0" to "1" */
3e26120cc7c819 WANG Cong           2009-12-17  1746  		.proc_handler	= proc_dointvec_minmax,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1747  		.extra1		= SYSCTL_ONE,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1748  		.extra2		= SYSCTL_ONE,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1749  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1750  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1751  #ifdef CONFIG_UEVENT_HELPER
dd8632a12e500a Paul Mundt          2009-01-08  1752  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1753  		.procname	= "hotplug",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1754  		.data		= &uevent_helper,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1755  		.maxlen		= UEVENT_HELPER_PATH_LEN,
dd8632a12e500a Paul Mundt          2009-01-08  1756  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1757  		.proc_handler	= proc_dostring,
dd8632a12e500a Paul Mundt          2009-01-08  1758  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1759  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1760  #ifdef CONFIG_MAGIC_SYSRQ
^1da177e4c3f41 Linus Torvalds      2005-04-16  1761  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1762  		.procname	= "sysrq",
e5ff215941d59f Andi Kleen          2008-07-23  1763  		.data		= NULL,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1764  		.maxlen		= sizeof (int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1765  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1766  		.proc_handler	= sysrq_sysctl_handler,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1767  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1768  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1769  #ifdef CONFIG_PROC_SYSCTL
^1da177e4c3f41 Linus Torvalds      2005-04-16  1770  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1771  		.procname	= "cad_pid",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1772  		.data		= NULL,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1773  		.maxlen		= sizeof (int),
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1774  		.mode		= 0600,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1775  		.proc_handler	= proc_do_cad_pid,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1776  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1777  #endif
9d0243bca345d5 Andrew Morton       2006-01-08  1778  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1779  		.procname	= "threads-max",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1780  		.data		= NULL,
9d0243bca345d5 Andrew Morton       2006-01-08  1781  		.maxlen		= sizeof(int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1782  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1783  		.proc_handler	= sysctl_max_threads,
9d0243bca345d5 Andrew Morton       2006-01-08  1784  	},
1743660b911bfb Christoph Lameter   2006-01-18  1785  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1786  		.procname	= "overflowuid",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1787  		.data		= &overflowuid,
5e7719058079a1 Mel Gorman          2010-05-24  1788  		.maxlen		= sizeof(int),
1743660b911bfb Christoph Lameter   2006-01-18  1789  		.mode		= 0644,
6b7e5cad651a2b Matthew Wilcox      2019-03-05  1790  		.proc_handler	= proc_dointvec_minmax,
2452dcb9f7f2ba Xiaoming Ni         2022-01-21  1791  		.extra1		= SYSCTL_ZERO,
54771613e8a7db Luis Chamberlain    2022-01-21  1792  		.extra2		= SYSCTL_MAXOLDUID,
1743660b911bfb Christoph Lameter   2006-01-18  1793  	},
9614634fe6a138 Christoph Lameter   2006-07-03  1794  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1795  		.procname	= "overflowgid",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1796  		.data		= &overflowgid,
5bbe3547aa3ba5 Eric B Munson       2015-04-15  1797  		.maxlen		= sizeof(int),
9614634fe6a138 Christoph Lameter   2006-07-03  1798  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1799  		.proc_handler	= proc_dointvec_minmax,
2452dcb9f7f2ba Xiaoming Ni         2022-01-21  1800  		.extra1		= SYSCTL_ZERO,
54771613e8a7db Luis Chamberlain    2022-01-21  1801  		.extra2		= SYSCTL_MAXOLDUID,
9614634fe6a138 Christoph Lameter   2006-07-03  1802  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1803  #ifdef CONFIG_S390
0ff38490c836dc Christoph Lameter   2006-09-25  1804  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1805  		.procname	= "userprocess_debug",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1806  		.data		= &show_unhandled_signals,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1807  		.maxlen		= sizeof(int),
0ff38490c836dc Christoph Lameter   2006-09-25  1808  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1809  		.proc_handler	= proc_dointvec,
0ff38490c836dc Christoph Lameter   2006-09-25  1810  	},
e6e5494cb23d19 Ingo Molnar         2006-06-27  1811  #endif
77461ab33229d4 Christoph Lameter   2007-05-09  1812  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1813  		.procname	= "pid_max",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1814  		.data		= &pid_max,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1815  		.maxlen		= sizeof (int),
77461ab33229d4 Christoph Lameter   2007-05-09  1816  		.mode		= 0644,
26363af5643490 Christoph Hellwig   2020-04-24  1817  		.proc_handler	= proc_dointvec_minmax,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1818  		.extra1		= &pid_max_min,
f461d2dcd511c0 Christoph Hellwig   2020-04-24 @1819  		.extra2		= &pid_max_max,
77461ab33229d4 Christoph Lameter   2007-05-09  1820  	},
52b6f46bc163ee Hugh Dickins        2016-05-19  1821  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1822  		.procname	= "panic_on_oops",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1823  		.data		= &panic_on_oops,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1824  		.maxlen		= sizeof(int),
795ae7a0de6b83 Johannes Weiner     2016-03-17  1825  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1826  		.proc_handler	= proc_dointvec,
52b6f46bc163ee Hugh Dickins        2016-05-19  1827  	},
ed0321895182ff Eric Paris          2007-06-28  1828  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1829  		.procname	= "panic_print",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1830  		.data		= &panic_print,
ed0321895182ff Eric Paris          2007-06-28  1831  		.maxlen		= sizeof(unsigned long),
ed0321895182ff Eric Paris          2007-06-28  1832  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1833  		.proc_handler	= proc_doulongvec_minmax,
ed0321895182ff Eric Paris          2007-06-28  1834  	},
c9b1d0981fcce3 Andrew Shewmaker    2013-04-29  1835  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1836  		.procname	= "ngroups_max",
f628867da46f88 Stephen Kitt        2022-01-21  1837  		.data		= (void *)&ngroups_max,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1838  		.maxlen		= sizeof (int),
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1839  		.mode		= 0444,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1840  		.proc_handler	= proc_dointvec,
1743660b911bfb Christoph Lameter   2006-01-18  1841  	},
9614634fe6a138 Christoph Lameter   2006-07-03  1842  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1843  		.procname	= "cap_last_cap",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1844  		.data		= (void *)&cap_last_cap,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1845  		.maxlen		= sizeof(int),
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1846  		.mode		= 0444,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1847  		.proc_handler	= proc_dointvec,
9614634fe6a138 Christoph Lameter   2006-07-03  1848  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1849  #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
^1da177e4c3f41 Linus Torvalds      2005-04-16  1850  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1851  		.procname       = "unknown_nmi_panic",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1852  		.data           = &unknown_nmi_panic,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1853  		.maxlen         = sizeof (int),
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1854  		.mode           = 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1855  		.proc_handler   = proc_dointvec,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1856  	},
6a46079cf57a7f Andi Kleen          2009-09-16  1857  #endif
cb8e59cc87201a Linus Torvalds      2020-06-03  1858  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#10 lore raw
In reply to Michal Koutný
kernel test robot noticed the following build errors:

Hi Michal,

kernel test robot noticed the following build errors:

[auto build test ERROR on fec50db7033ea478773b159e0e2efb135270e3b7]

url:    https://github.com/intel-lab-lkp/linux/commits/Michal-Koutn/tracing-Remove-dependency-of-saved_cmdlines_buffer-on-PID_MAX_DEFAULT/20240408-230031
base:   fec50db7033ea478773b159e0e2efb135270e3b7
patch link:    https://lore.kernel.org/r/20240408145819.8787-3-mkoutny%40suse.com
patch subject: [PATCH 2/3] kernel/pid: Remove default pid_max value
config: arm-allnoconfig (https://download.01.org/0day-ci/archive/20240409/[email protected]/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 8b3b4a92adee40483c27f26c478a384cd69c6f05)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240409/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from kernel/sysctl.c:23:
In file included from include/linux/mm.h:2208:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     522 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
>> kernel/sysctl.c:1819:14: error: initializing 'void *' with an expression of type 'const int *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]

1819 | .extra2 = &pid_max_max,
| ^~~~~~~~~~~~
1 warning and 1 error generated.

vim +1819 kernel/sysctl.c

f461d2dcd511c0 Christoph Hellwig   2020-04-24  1617  
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1618  static struct ctl_table kern_table[] = {
^1da177e4c3f41 Linus Torvalds      2005-04-16  1619  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1620  		.procname	= "panic",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1621  		.data		= &panic_timeout,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1622  		.maxlen		= sizeof(int),
49f0ce5f92321c Jerome Marchand     2014-01-21  1623  		.mode		= 0644,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1624  		.proc_handler	= proc_dointvec,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1625  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1626  #ifdef CONFIG_PROC_SYSCTL
^1da177e4c3f41 Linus Torvalds      2005-04-16  1627  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1628  		.procname	= "tainted",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1629  		.maxlen 	= sizeof(long),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1630  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1631  		.proc_handler	= proc_taint,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1632  	},
2da02997e08d3e David Rientjes      2009-01-06  1633  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1634  		.procname	= "sysctl_writes_strict",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1635  		.data		= &sysctl_writes_strict,
9e3961a0979817 Prarit Bhargava     2014-12-10  1636  		.maxlen		= sizeof(int),
2da02997e08d3e David Rientjes      2009-01-06  1637  		.mode		= 0644,
9e3961a0979817 Prarit Bhargava     2014-12-10  1638  		.proc_handler	= proc_dointvec_minmax,
78e36f3b0dae58 Xiaoming Ni         2022-01-21  1639  		.extra1		= SYSCTL_NEG_ONE,
eec4844fae7c03 Matteo Croce        2019-07-18  1640  		.extra2		= SYSCTL_ONE,
2da02997e08d3e David Rientjes      2009-01-06  1641  	},
964c9dff009189 Alexander Popov     2018-08-17  1642  #endif
1efff914afac8a Theodore Ts'o       2015-03-17  1643  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1644  		.procname	= "print-fatal-signals",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1645  		.data		= &print_fatal_signals,
964c9dff009189 Alexander Popov     2018-08-17  1646  		.maxlen		= sizeof(int),
1efff914afac8a Theodore Ts'o       2015-03-17  1647  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1648  		.proc_handler	= proc_dointvec,
1efff914afac8a Theodore Ts'o       2015-03-17  1649  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1650  #ifdef CONFIG_SPARC
^1da177e4c3f41 Linus Torvalds      2005-04-16  1651  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1652  		.procname	= "reboot-cmd",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1653  		.data		= reboot_command,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1654  		.maxlen		= 256,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1655  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1656  		.proc_handler	= proc_dostring,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1657  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1658  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1659  		.procname	= "stop-a",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1660  		.data		= &stop_a_enabled,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1661  		.maxlen		= sizeof (int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1662  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1663  		.proc_handler	= proc_dointvec,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1664  	},
06808b0827e1cd Lee Schermerhorn    2009-12-14  1665  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1666  		.procname	= "scons-poweroff",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1667  		.data		= &scons_pwroff,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1668  		.maxlen		= sizeof (int),
06808b0827e1cd Lee Schermerhorn    2009-12-14  1669  		.mode		= 0644,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1670  		.proc_handler	= proc_dointvec,
06808b0827e1cd Lee Schermerhorn    2009-12-14  1671  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1672  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1673  #ifdef CONFIG_SPARC64
4518085e127dff Kemi Wang           2017-11-15  1674  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1675  		.procname	= "tsb-ratio",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1676  		.data		= &sysctl_tsb_ratio,
4518085e127dff Kemi Wang           2017-11-15  1677  		.maxlen		= sizeof (int),
4518085e127dff Kemi Wang           2017-11-15  1678  		.mode		= 0644,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1679  		.proc_handler	= proc_dointvec,
4518085e127dff Kemi Wang           2017-11-15  1680  	},
06808b0827e1cd Lee Schermerhorn    2009-12-14  1681  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1682  #ifdef CONFIG_PARISC
^1da177e4c3f41 Linus Torvalds      2005-04-16  1683  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1684  		.procname	= "soft-power",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1685  		.data		= &pwrsw_enabled,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1686  		.maxlen		= sizeof (int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1687  		.mode		= 0644,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1688  		.proc_handler	= proc_dointvec,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1689  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1690  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1691  #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
d1c3fb1f8f29c4 Nishanth Aravamudan 2007-12-17  1692  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1693  		.procname	= "unaligned-trap",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1694  		.data		= &unaligned_enabled,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1695  		.maxlen		= sizeof (int),
d1c3fb1f8f29c4 Nishanth Aravamudan 2007-12-17  1696  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1697  		.proc_handler	= proc_dointvec,
d1c3fb1f8f29c4 Nishanth Aravamudan 2007-12-17  1698  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1699  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1700  #ifdef CONFIG_STACK_TRACER
76ab0f530e4a01 Mel Gorman          2010-05-24  1701  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1702  		.procname	= "stack_tracer_enabled",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1703  		.data		= &stack_tracer_enabled,
76ab0f530e4a01 Mel Gorman          2010-05-24  1704  		.maxlen		= sizeof(int),
2da02997e08d3e David Rientjes      2009-01-06  1705  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1706  		.proc_handler	= stack_trace_sysctl,
76ab0f530e4a01 Mel Gorman          2010-05-24  1707  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1708  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1709  #ifdef CONFIG_TRACING
5e7719058079a1 Mel Gorman          2010-05-24  1710  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1711  		.procname	= "ftrace_dump_on_oops",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1712  		.data		= &ftrace_dump_on_oops,
19f0423fd55c30 Huang Yiwei         2024-02-23  1713  		.maxlen		= MAX_TRACER_SIZE,
5e7719058079a1 Mel Gorman          2010-05-24  1714  		.mode		= 0644,
19f0423fd55c30 Huang Yiwei         2024-02-23  1715  		.proc_handler	= proc_dostring,
5e7719058079a1 Mel Gorman          2010-05-24  1716  	},
5bbe3547aa3ba5 Eric B Munson       2015-04-15  1717  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1718  		.procname	= "traceoff_on_warning",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1719  		.data		= &__disable_trace_on_warning,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1720  		.maxlen		= sizeof(__disable_trace_on_warning),
5bbe3547aa3ba5 Eric B Munson       2015-04-15  1721  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1722  		.proc_handler	= proc_dointvec,
5bbe3547aa3ba5 Eric B Munson       2015-04-15  1723  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1724  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1725  		.procname	= "tracepoint_printk",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1726  		.data		= &tracepoint_printk,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1727  		.maxlen		= sizeof(tracepoint_printk),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1728  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1729  		.proc_handler	= tracepoint_printk_sysctl,
1c30844d2dfe27 Mel Gorman          2018-12-28  1730  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1731  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1732  #ifdef CONFIG_MODULES
8ad4b1fb820534 Rohit Seth          2006-01-08  1733  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1734  		.procname	= "modprobe",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1735  		.data		= &modprobe_path,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1736  		.maxlen		= KMOD_PATH_LEN,
8ad4b1fb820534 Rohit Seth          2006-01-08  1737  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1738  		.proc_handler	= proc_dostring,
8ad4b1fb820534 Rohit Seth          2006-01-08  1739  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1740  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1741  		.procname	= "modules_disabled",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1742  		.data		= &modules_disabled,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1743  		.maxlen		= sizeof(int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1744  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1745  		/* only handle a transition from default "0" to "1" */
3e26120cc7c819 WANG Cong           2009-12-17  1746  		.proc_handler	= proc_dointvec_minmax,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1747  		.extra1		= SYSCTL_ONE,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1748  		.extra2		= SYSCTL_ONE,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1749  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1750  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1751  #ifdef CONFIG_UEVENT_HELPER
dd8632a12e500a Paul Mundt          2009-01-08  1752  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1753  		.procname	= "hotplug",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1754  		.data		= &uevent_helper,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1755  		.maxlen		= UEVENT_HELPER_PATH_LEN,
dd8632a12e500a Paul Mundt          2009-01-08  1756  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1757  		.proc_handler	= proc_dostring,
dd8632a12e500a Paul Mundt          2009-01-08  1758  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1759  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1760  #ifdef CONFIG_MAGIC_SYSRQ
^1da177e4c3f41 Linus Torvalds      2005-04-16  1761  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1762  		.procname	= "sysrq",
e5ff215941d59f Andi Kleen          2008-07-23  1763  		.data		= NULL,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1764  		.maxlen		= sizeof (int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1765  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1766  		.proc_handler	= sysrq_sysctl_handler,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1767  	},
^1da177e4c3f41 Linus Torvalds      2005-04-16  1768  #endif
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1769  #ifdef CONFIG_PROC_SYSCTL
^1da177e4c3f41 Linus Torvalds      2005-04-16  1770  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1771  		.procname	= "cad_pid",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1772  		.data		= NULL,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1773  		.maxlen		= sizeof (int),
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1774  		.mode		= 0600,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1775  		.proc_handler	= proc_do_cad_pid,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1776  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1777  #endif
9d0243bca345d5 Andrew Morton       2006-01-08  1778  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1779  		.procname	= "threads-max",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1780  		.data		= NULL,
9d0243bca345d5 Andrew Morton       2006-01-08  1781  		.maxlen		= sizeof(int),
^1da177e4c3f41 Linus Torvalds      2005-04-16  1782  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1783  		.proc_handler	= sysctl_max_threads,
9d0243bca345d5 Andrew Morton       2006-01-08  1784  	},
1743660b911bfb Christoph Lameter   2006-01-18  1785  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1786  		.procname	= "overflowuid",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1787  		.data		= &overflowuid,
5e7719058079a1 Mel Gorman          2010-05-24  1788  		.maxlen		= sizeof(int),
1743660b911bfb Christoph Lameter   2006-01-18  1789  		.mode		= 0644,
6b7e5cad651a2b Matthew Wilcox      2019-03-05  1790  		.proc_handler	= proc_dointvec_minmax,
2452dcb9f7f2ba Xiaoming Ni         2022-01-21  1791  		.extra1		= SYSCTL_ZERO,
54771613e8a7db Luis Chamberlain    2022-01-21  1792  		.extra2		= SYSCTL_MAXOLDUID,
1743660b911bfb Christoph Lameter   2006-01-18  1793  	},
9614634fe6a138 Christoph Lameter   2006-07-03  1794  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1795  		.procname	= "overflowgid",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1796  		.data		= &overflowgid,
5bbe3547aa3ba5 Eric B Munson       2015-04-15  1797  		.maxlen		= sizeof(int),
9614634fe6a138 Christoph Lameter   2006-07-03  1798  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1799  		.proc_handler	= proc_dointvec_minmax,
2452dcb9f7f2ba Xiaoming Ni         2022-01-21  1800  		.extra1		= SYSCTL_ZERO,
54771613e8a7db Luis Chamberlain    2022-01-21  1801  		.extra2		= SYSCTL_MAXOLDUID,
9614634fe6a138 Christoph Lameter   2006-07-03  1802  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1803  #ifdef CONFIG_S390
0ff38490c836dc Christoph Lameter   2006-09-25  1804  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1805  		.procname	= "userprocess_debug",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1806  		.data		= &show_unhandled_signals,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1807  		.maxlen		= sizeof(int),
0ff38490c836dc Christoph Lameter   2006-09-25  1808  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1809  		.proc_handler	= proc_dointvec,
0ff38490c836dc Christoph Lameter   2006-09-25  1810  	},
e6e5494cb23d19 Ingo Molnar         2006-06-27  1811  #endif
77461ab33229d4 Christoph Lameter   2007-05-09  1812  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1813  		.procname	= "pid_max",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1814  		.data		= &pid_max,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1815  		.maxlen		= sizeof (int),
77461ab33229d4 Christoph Lameter   2007-05-09  1816  		.mode		= 0644,
26363af5643490 Christoph Hellwig   2020-04-24  1817  		.proc_handler	= proc_dointvec_minmax,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1818  		.extra1		= &pid_max_min,
f461d2dcd511c0 Christoph Hellwig   2020-04-24 @1819  		.extra2		= &pid_max_max,
77461ab33229d4 Christoph Lameter   2007-05-09  1820  	},
52b6f46bc163ee Hugh Dickins        2016-05-19  1821  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1822  		.procname	= "panic_on_oops",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1823  		.data		= &panic_on_oops,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1824  		.maxlen		= sizeof(int),
795ae7a0de6b83 Johannes Weiner     2016-03-17  1825  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1826  		.proc_handler	= proc_dointvec,
52b6f46bc163ee Hugh Dickins        2016-05-19  1827  	},
ed0321895182ff Eric Paris          2007-06-28  1828  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1829  		.procname	= "panic_print",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1830  		.data		= &panic_print,
ed0321895182ff Eric Paris          2007-06-28  1831  		.maxlen		= sizeof(unsigned long),
ed0321895182ff Eric Paris          2007-06-28  1832  		.mode		= 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1833  		.proc_handler	= proc_doulongvec_minmax,
ed0321895182ff Eric Paris          2007-06-28  1834  	},
c9b1d0981fcce3 Andrew Shewmaker    2013-04-29  1835  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1836  		.procname	= "ngroups_max",
f628867da46f88 Stephen Kitt        2022-01-21  1837  		.data		= (void *)&ngroups_max,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1838  		.maxlen		= sizeof (int),
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1839  		.mode		= 0444,
6d4561110a3e9f Eric W. Biederman   2009-11-16  1840  		.proc_handler	= proc_dointvec,
1743660b911bfb Christoph Lameter   2006-01-18  1841  	},
9614634fe6a138 Christoph Lameter   2006-07-03  1842  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1843  		.procname	= "cap_last_cap",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1844  		.data		= (void *)&cap_last_cap,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1845  		.maxlen		= sizeof(int),
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1846  		.mode		= 0444,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1847  		.proc_handler	= proc_dointvec,
9614634fe6a138 Christoph Lameter   2006-07-03  1848  	},
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1849  #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
^1da177e4c3f41 Linus Torvalds      2005-04-16  1850  	{
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1851  		.procname       = "unknown_nmi_panic",
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1852  		.data           = &unknown_nmi_panic,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1853  		.maxlen         = sizeof (int),
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1854  		.mode           = 0644,
f461d2dcd511c0 Christoph Hellwig   2020-04-24  1855  		.proc_handler   = proc_dointvec,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1856  	},
6a46079cf57a7f Andi Kleen          2009-09-16  1857  #endif
cb8e59cc87201a Linus Torvalds      2020-06-03  1858  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#11 lore raw
In reply to Michal Koutný
Quoted 7 lines · Michal Koutný

The kernel provides mechanisms, while it should not imply policies -- default pid_max seems to be an example of the policy that does not fit all. At the same time pid_max must have some value assigned, so use the end of the allowed range -- pid_max_max.

This change thus increases initial pid_max from 32k to 4M (x86_64 defconfig).

Out of curiosity I dug out the commit

	acdc721fe26d ("[PATCH] pid-max-2.5.33-A0") v2.5.34~5

that introduced the 32k default. The commit message doesn't say why such a sudden change though.
Previously, the limit was 1G of pids (i.e. effectively no default limit like the intention of this series).

Honestly, I expected more enthusiasm or reasons against removing the default value of pid_max. Is this really not of interest to anyone?

(Thanks, Andrew, for your responses. I don't plan to pursue this further should there be no more interest in having less default limit values in kernel.)

Regards,
Michal

#12 lore raw

PATCH 3/3 tracing: Compare pid_max against pid_list capacity

In reply to Michal Koutný

trace_pid_list_alloc() checks pid_max against a magic number referencing an (obsolete) source file when it actually should check against the capacity of pid_list tree. Turn definition of MAX_PID around -- derive it from tree parameters and replace references to magic value and header files with so defined MAX_PID.
Should PID_MAX_LIMIT change in future or pid_max escapes PID_MAX_LIMIT, appropriate checks remain in place. No functional change intended.

---
 kernel/trace/pid_list.c | 6 +++---
 kernel/trace/pid_list.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
kernel/trace/pid_list.c +3 -3
index 95106d02b32d..b968f0b65dc1 100644
@@ -93,7 +93,7 @@ static inline bool upper_empty(union upper_chunk *chunk)
 static inline int pid_split(unsigned int pid, unsigned int *upper1,
 			     unsigned int *upper2, unsigned int *lower)
 {
-	/* MAX_PID should cover all pids */
+	/* MAX_PID must cover all possible pids */
 	BUILD_BUG_ON(MAX_PID < PID_MAX_LIMIT);
 
 	/* In case a bad pid is passed in, then fail */
@@ -413,8 +413,8 @@ struct trace_pid_list *trace_pid_list_alloc(void)
 	struct trace_pid_list *pid_list;
 	int i;
 
-	/* According to linux/thread.h, pids can be no bigger that 30 bits */
-	WARN_ON_ONCE(pid_max > (1 << 30));
+	/* See pid_split(), equal to pid_max > PID_MAX_LIMIT */
+	WARN_ON_ONCE(pid_max > MAX_PID);
 
 	pid_list = kzalloc(sizeof(*pid_list), GFP_KERNEL);
 	if (!pid_list)
kernel/trace/pid_list.h +2 -2
index 62e73f1ac85f..28562a9a3d01 100644
@@ -56,8 +56,8 @@
 
 #define UPPER_MASK	(UPPER_MAX - 1)
 
-/* According to linux/thread.h pids can not be bigger than or equal to 1 << 30 */
-#define MAX_PID		(1 << 30)
+/* Structure can hold only pids strictly below this limit */
+#define MAX_PID		(1 << (UPPER_BITS + UPPER_BITS + LOWER_BITS))
 
 /* Just keep 6 chunks of both upper and lower in the cache on alloc */
 #define CHUNK_ALLOC 6
Signature · 1 line
2.44.0