mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
e1b6705bcf
Now that cpumask types are split out to a separate smaller header, many frequently included core headers may switch to using it. Link: https://lkml.kernel.org/r/20240528005648.182376-7-yury.norov@gmail.com Signed-off-by: Yury Norov <yury.norov@gmail.com> Cc: Amit Daniel Kachhap <amit.kachhap@gmail.com> Cc: Anna-Maria Behnsen <anna-maria@linutronix.de> Cc: Christoph Lameter <cl@linux.com> Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Cc: Dennis Zhou <dennis@kernel.org> Cc: Frederic Weisbecker <frederic@kernel.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rafael J. Wysocki <rafael@kernel.org> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ulf Hansson <ulf.hansson@linaro.org> Cc: Vincent Guittot <vincent.guittot@linaro.org> Cc: Viresh Kumar <viresh.kumar@linaro.org> Cc: Yury Norov <yury.norov@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
67 lines
1.7 KiB
C
67 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef __LINUX_CPU_RMAP_H
|
|
#define __LINUX_CPU_RMAP_H
|
|
|
|
/*
|
|
* cpu_rmap.c: CPU affinity reverse-map support
|
|
* Copyright 2011 Solarflare Communications Inc.
|
|
*/
|
|
|
|
#include <linux/cpumask_types.h>
|
|
#include <linux/gfp.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/kref.h>
|
|
|
|
/**
|
|
* struct cpu_rmap - CPU affinity reverse-map
|
|
* @refcount: kref for object
|
|
* @size: Number of objects to be reverse-mapped
|
|
* @obj: Pointer to array of object pointers
|
|
* @near: For each CPU, the index and distance to the nearest object,
|
|
* based on affinity masks
|
|
*/
|
|
struct cpu_rmap {
|
|
struct kref refcount;
|
|
u16 size;
|
|
void **obj;
|
|
struct {
|
|
u16 index;
|
|
u16 dist;
|
|
} near[];
|
|
};
|
|
#define CPU_RMAP_DIST_INF 0xffff
|
|
|
|
extern struct cpu_rmap *alloc_cpu_rmap(unsigned int size, gfp_t flags);
|
|
extern int cpu_rmap_put(struct cpu_rmap *rmap);
|
|
|
|
extern int cpu_rmap_add(struct cpu_rmap *rmap, void *obj);
|
|
extern int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,
|
|
const struct cpumask *affinity);
|
|
|
|
static inline u16 cpu_rmap_lookup_index(struct cpu_rmap *rmap, unsigned int cpu)
|
|
{
|
|
return rmap->near[cpu].index;
|
|
}
|
|
|
|
static inline void *cpu_rmap_lookup_obj(struct cpu_rmap *rmap, unsigned int cpu)
|
|
{
|
|
return rmap->obj[rmap->near[cpu].index];
|
|
}
|
|
|
|
/**
|
|
* alloc_irq_cpu_rmap - allocate CPU affinity reverse-map for IRQs
|
|
* @size: Number of objects to be mapped
|
|
*
|
|
* Must be called in process context.
|
|
*/
|
|
static inline struct cpu_rmap *alloc_irq_cpu_rmap(unsigned int size)
|
|
{
|
|
return alloc_cpu_rmap(size, GFP_KERNEL);
|
|
}
|
|
extern void free_irq_cpu_rmap(struct cpu_rmap *rmap);
|
|
|
|
int irq_cpu_rmap_remove(struct cpu_rmap *rmap, int irq);
|
|
extern int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq);
|
|
|
|
#endif /* __LINUX_CPU_RMAP_H */
|