mm/percpu-internal.h

Source file repositories/reference/linux-study-clean/mm/percpu-internal.h

File Facts

System
Linux kernel
Corpus path
mm/percpu-internal.h
Extension
.h
Size
7895 bytes
Lines
289
Domain
Core OS
Bucket
Memory Management
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct pcpu_block_md {
	int			scan_hint;	/* scan hint for block */
	int			scan_hint_start; /* block relative starting
						    position of the scan hint */
	int                     contig_hint;    /* contig hint for block */
	int                     contig_hint_start; /* block relative starting
						      position of the contig hint */
	int                     left_free;      /* size of free space along
						   the left side of the block */
	int                     right_free;     /* size of free space along
						   the right side of the block */
	int                     first_free;     /* block position of first free */
	int			nr_bits;	/* total bits responsible for */
};

struct pcpuobj_ext {
#ifdef CONFIG_MEMCG
	struct obj_cgroup	*cgroup;
#endif
#ifdef CONFIG_MEM_ALLOC_PROFILING
	union codetag_ref	tag;
#endif
};

#if defined(CONFIG_MEMCG) || defined(CONFIG_MEM_ALLOC_PROFILING)
#define NEED_PCPUOBJ_EXT
#endif

struct pcpu_chunk {
#ifdef CONFIG_PERCPU_STATS
	int			nr_alloc;	/* # of allocations */
	size_t			max_alloc_size; /* largest allocation size */
#endif

	struct list_head	list;		/* linked to pcpu_slot lists */
	int			free_bytes;	/* free bytes in the chunk */
	struct pcpu_block_md	chunk_md;
	unsigned long		*bound_map;	/* boundary map */

	/*
	 * base_addr is the base address of this chunk.
	 * To reduce false sharing, current layout is optimized to make sure
	 * base_addr locate in the different cacheline with free_bytes and
	 * chunk_md.
	 */
	void			*base_addr ____cacheline_aligned_in_smp;

	unsigned long		*alloc_map;	/* allocation map */
	struct pcpu_block_md	*md_blocks;	/* metadata blocks */

	void			*data;		/* chunk data */
	bool			immutable;	/* no [de]population allowed */
	bool			isolated;	/* isolated from active chunk
						   slots */
	int			start_offset;	/* the overlap with the previous
						   region to have a page aligned
						   base_addr */
	int			end_offset;	/* additional area required to
						   have the region end page
						   aligned */
	int			nr_pages;	/* # of pages served by this chunk */
	int			nr_populated;	/* # of populated pages */
	int                     nr_empty_pop_pages; /* # of empty populated pages */
#ifdef NEED_PCPUOBJ_EXT
	struct pcpuobj_ext	*obj_exts;	/* vector of object cgroups */
#endif

	unsigned long		populated[];	/* populated bitmap */
};

static inline bool need_pcpuobj_ext(void)
{
	if (IS_ENABLED(CONFIG_MEM_ALLOC_PROFILING))
		return true;
	if (!mem_cgroup_kmem_disabled())
		return true;
	return false;
}

extern spinlock_t pcpu_lock;

extern struct list_head *pcpu_chunk_lists;
extern int pcpu_nr_slots;
extern int pcpu_sidelined_slot;
extern int pcpu_to_depopulate_slot;
extern int pcpu_nr_empty_pop_pages;

extern struct pcpu_chunk *pcpu_first_chunk;
extern struct pcpu_chunk *pcpu_reserved_chunk;

Annotation

Implementation Notes