mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 14:30:06 -04:00
Merge tag 'percpu-for-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu
Pull percpu updates from Dennis Zhou:
"One bigger change to percpu_counter's api allowing for init and
destroy of multiple counters via percpu_counter_init_many() and
percpu_counter_destroy_many(). This is used to help begin remediating
a performance regression with percpu rss stats.
Additionally, it seems larger core count machines are feeling the
burden of the single threaded allocation of percpu. Mateusz is
thinking about it and I will spend some time on it too.
percpu:
- A couple cleanups by Baoquan He and Bibo Mao. The only behavior
change is to start printing messages if we're under the warn limit
for failed atomic allocations.
percpu_counter:
- Shakeel introduced percpu counters into mm_struct which caused
percpu allocations be on the hot path [1]. Originally I spent some
time trying to improve the percpu allocator, but instead preferred
what Mateusz Guzik proposed grouping at the allocation site,
percpu_counter_init_many(). This allows a single percpu allocation
to be shared by the counters. I like this approach because it
creates a shared lifetime by the allocations. Additionally, I
believe many inits have higher level synchronization requirements,
like percpu_counter does against HOTPLUG_CPU. Therefore we can
group these optimizations together"
Link: https://lore.kernel.org/linux-mm/20221024052841.3291983-1-shakeelb@google.com/ [1]
* tag 'percpu-for-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu:
kernel/fork: group allocation/free of per-cpu counters for mm struct
pcpcntr: add group allocation/free
mm/percpu.c: print error message too if atomic alloc failed
mm/percpu.c: optimize the code in pcpu_setup_first_chunk() a little bit
mm/percpu.c: remove redundant check
mm/percpu: Remove some local variables in pcpu_populate_pte
This commit is contained in:
@@ -30,17 +30,28 @@ struct percpu_counter {
|
||||
|
||||
extern int percpu_counter_batch;
|
||||
|
||||
int __percpu_counter_init(struct percpu_counter *fbc, s64 amount, gfp_t gfp,
|
||||
struct lock_class_key *key);
|
||||
int __percpu_counter_init_many(struct percpu_counter *fbc, s64 amount,
|
||||
gfp_t gfp, u32 nr_counters,
|
||||
struct lock_class_key *key);
|
||||
|
||||
#define percpu_counter_init(fbc, value, gfp) \
|
||||
#define percpu_counter_init_many(fbc, value, gfp, nr_counters) \
|
||||
({ \
|
||||
static struct lock_class_key __key; \
|
||||
\
|
||||
__percpu_counter_init(fbc, value, gfp, &__key); \
|
||||
__percpu_counter_init_many(fbc, value, gfp, nr_counters,\
|
||||
&__key); \
|
||||
})
|
||||
|
||||
void percpu_counter_destroy(struct percpu_counter *fbc);
|
||||
|
||||
#define percpu_counter_init(fbc, value, gfp) \
|
||||
percpu_counter_init_many(fbc, value, gfp, 1)
|
||||
|
||||
void percpu_counter_destroy_many(struct percpu_counter *fbc, u32 nr_counters);
|
||||
static inline void percpu_counter_destroy(struct percpu_counter *fbc)
|
||||
{
|
||||
percpu_counter_destroy_many(fbc, 1);
|
||||
}
|
||||
|
||||
void percpu_counter_set(struct percpu_counter *fbc, s64 amount);
|
||||
void percpu_counter_add_batch(struct percpu_counter *fbc, s64 amount,
|
||||
s32 batch);
|
||||
@@ -116,11 +127,27 @@ struct percpu_counter {
|
||||
s64 count;
|
||||
};
|
||||
|
||||
static inline int percpu_counter_init_many(struct percpu_counter *fbc,
|
||||
s64 amount, gfp_t gfp,
|
||||
u32 nr_counters)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < nr_counters; i++)
|
||||
fbc[i].count = amount;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int percpu_counter_init(struct percpu_counter *fbc, s64 amount,
|
||||
gfp_t gfp)
|
||||
{
|
||||
fbc->count = amount;
|
||||
return 0;
|
||||
return percpu_counter_init_many(fbc, amount, gfp, 1);
|
||||
}
|
||||
|
||||
static inline void percpu_counter_destroy_many(struct percpu_counter *fbc,
|
||||
u32 nr_counters)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void percpu_counter_destroy(struct percpu_counter *fbc)
|
||||
|
||||
Reference in New Issue
Block a user