tools/virtio/linux/kernel.h
Source file repositories/reference/linux-study-clean/tools/virtio/linux/kernel.h
File Facts
- System
- Linux kernel
- Corpus path
tools/virtio/linux/kernel.h- Extension
.h- Size
- 3833 bytes
- Lines
- 167
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdbool.hstdlib.hstddef.hstdio.hstring.hassert.hstdarg.hlinux/compiler.h../../../include/linux/container_of.hlinux/log2.hlinux/types.hlinux/overflow.hlinux/limits.hlinux/list.hlinux/printk.hlinux/bug.herrno.hunistd.hasm/barrier.h
Detected Declarations
struct pagefunction kfreefunction free_pages_exactfunction __get_free_pagefunction free_pagefunction is_vmalloc_addrfunction synchronize_rcu
Annotated Snippet
struct page {
unsigned long long dummy;
};
/* Physical == Virtual */
#define virt_to_phys(p) ((unsigned long)p)
#define phys_to_virt(a) ((void *)(unsigned long)(a))
/* Page address: Virtual / 4K */
#define page_to_phys(p) ((dma_addr_t)(unsigned long)(p))
#define virt_to_page(p) ((struct page *)((unsigned long)p & PAGE_MASK))
#define offset_in_page(p) (((unsigned long)p) % PAGE_SIZE)
#define __printf(a,b) __attribute__((format(printf,a,b)))
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
extern void *__kmalloc_fake, *__kfree_ignore_start, *__kfree_ignore_end;
static inline void *kmalloc(size_t s, gfp_t gfp)
{
if (__kmalloc_fake)
return __kmalloc_fake;
return malloc(s);
}
static inline void *kmalloc_array(unsigned n, size_t s, gfp_t gfp)
{
return kmalloc(n * s, gfp);
}
#define kmalloc_obj(VAR_OR_TYPE, ...) \
((typeof(VAR_OR_TYPE) *)kmalloc(sizeof(typeof(VAR_OR_TYPE)), 0))
#define kmalloc_objs(VAR_OR_TYPE, COUNT, ...) \
((typeof(VAR_OR_TYPE) *)kmalloc(sizeof(typeof(VAR_OR_TYPE)) * (COUNT), 0))
static inline void *kzalloc(size_t s, gfp_t gfp)
{
void *p = kmalloc(s, gfp);
memset(p, 0, s);
return p;
}
static inline void *alloc_pages_exact(size_t s, gfp_t gfp)
{
return kmalloc(s, gfp);
}
static inline void kfree(void *p)
{
if (p >= __kfree_ignore_start && p < __kfree_ignore_end)
return;
free(p);
}
static inline void free_pages_exact(void *p, size_t s)
{
kfree(p);
}
static inline void *krealloc(void *p, size_t s, gfp_t gfp)
{
return realloc(p, s);
}
static inline unsigned long __get_free_page(gfp_t gfp)
{
void *p;
posix_memalign(&p, PAGE_SIZE, PAGE_SIZE);
return (unsigned long)p;
}
static inline void free_page(unsigned long addr)
{
free((void *)addr);
}
# ifndef likely
# define likely(x) (__builtin_expect(!!(x), 1))
# endif
# ifndef unlikely
# define unlikely(x) (__builtin_expect(!!(x), 0))
# endif
static inline void *krealloc_array(void *p, size_t new_n, size_t new_size, gfp_t gfp)
{
size_t bytes;
Annotation
- Immediate include surface: `stdbool.h`, `stdlib.h`, `stddef.h`, `stdio.h`, `string.h`, `assert.h`, `stdarg.h`, `linux/compiler.h`.
- Detected declarations: `struct page`, `function kfree`, `function free_pages_exact`, `function __get_free_page`, `function free_page`, `function is_vmalloc_addr`, `function synchronize_rcu`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.