kernel: add support for getting percpu variables that belong to other CPUs

This commit is contained in:
2023-05-04 21:42:51 +01:00
parent 3f91c96050
commit bb524c1576
6 changed files with 49 additions and 4 deletions

View File

@@ -30,8 +30,12 @@ struct cpu_data {
#define this_cpu() (ml_cpu_block_get_id(ml_this_cpu()))
extern struct cpu_data *get_this_cpu(void);
extern struct cpu_data *get_cpu(unsigned int id);
extern void put_cpu(struct cpu_data *cpu);
extern bool cpu_is_available(unsigned int cpu_id);
extern bool cpu_is_online(unsigned int cpu_id);
extern void cpu_set_available(unsigned int cpu_id);
extern void cpu_set_online(unsigned int cpu_id);

View File

@@ -15,13 +15,19 @@ extern "C" {
#define percpu_get(var) \
__extension__({ \
preempt_disable(); \
__percpu_get(var); \
__percpu_get(this_cpu(), var); \
})
#define percpu_get_from(cpu, var) \
__extension__({ \
preempt_disable(); \
__percpu_get(cpu, var); \
})
#define percpu_put(var) preempt_enable();
extern kern_status_t init_per_cpu_areas(void);
extern void *__percpu_get(void *var);
extern void *__percpu_get(unsigned int cpu, void *var);
#ifdef __cplusplus
}

View File

@@ -127,6 +127,7 @@ static inline void rq_unlock(struct runqueue *rq, unsigned long flags)
{
spin_unlock_irqrestore(&rq->rq_lock, flags);
}
extern struct runqueue *cpu_rq(unsigned int cpu);
extern struct task *task_alloc(void);
static inline struct task *task_ref(struct task *task) { return (struct task *)object_data(object_ref(object_header(task))); }