ns-pad-refcount.patch removed from -mm tree
The quilt patch titled
Subject: ns: pad refcount
has been removed from the -mm tree. Its filename was
ns-pad-refcount.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Mateusz Guzik <[email protected]>
Subject: ns: pad refcount
Date: Sat, 6 Dec 2025 14:19:54 +0100
Patch series "further damage-control lack of clone scalability", v3.
When spawning and killing threads in separate processes in parallel the primary bottleneck on the stock kernel is pidmap_lock, largely because of a back-to-back acquire in the common case.
Benchmark code at the end.
With this patchset alloc_pid() only takes the lock once and consequently alleviates the problem. While scalability improves, the lock remains the primary bottleneck by a large margin.
I believe idr is a poor choice for the task at hand to begin with, but sorting out that out beyond the scope of this patchset. At the same time any replacement would be best evaluated against a state where the above relock problem is fixed.
Performance improvement varies between reboots. When benchmarking with 20 processes creating and killing threads in a loop, the unpatched baseline hovers around 465k ops/s, while patched is anything between ~510k ops/s and ~560k depending on false-sharing (which I only minimally sanitized). So this is at least 10% if you are unlucky.
Bench from will-it-scale:
#include <assert.h>
#include <pthread.h>
char *testcase_description = "Thread creation and teardown";
static void *worker(void *arg)
{
return (NULL);
}void testcase(unsigned long long *iterations, unsigned long nr)
{
pthread_t thread[1];
int error;
while (1) {
for (int i = 0; i < 1; i++) {
error = pthread_create(&thread[i], NULL, worker, NULL);
assert(error == 0);
}
for (int i = 0; i < 1; i++) {
error = pthread_join(thread[i], NULL);
assert(error == 0);
}
(*iterations)++;
}
}This patch (of 2):
Note no effort is made to make sure structs embedding the namespace are themselves aligned, so this is not guaranteed to eliminate cacheline bouncing due to refcount management.
---
include/linux/ns/ns_common_types.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/linux/ns/ns_common_types.h renamed from include/linux/ns/ns_common_types.h~ns-pad-refcount +3 -1
@@ -108,11 +108,13 @@ extern const struct proc_ns_operations u* @ns_tree: namespace tree nodes and active reference count */ struct ns_common { +struct { +refcount_t __ns_ref;/* do not use directly */ + }____cacheline_aligned_in_smp ;u32 ns_type;struct dentry *stashed;const struct proc_ns_operations *ops;unsigned int inum; -refcount_t __ns_ref;/* do not use directly */ union {struct ns_tree ;struct rcu_head ns_rcu;
_
Patches currently in -mm which might be from [email protected] are
pid-only-take-pidmap_lock-once-on-alloc.patch