include/linux/folio_queue.h
Source file repositories/reference/linux-study-clean/include/linux/folio_queue.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/folio_queue.h- Extension
.h- Size
- 8856 bytes
- Lines
- 283
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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
linux/folio_batch.hlinux/mm.h
Detected Declarations
struct folio_queuefunction folioq_initfunction folioq_nr_slotsfunction folioq_countfunction folioq_fullfunction folioq_is_markedfunction folioq_markfunction folioq_unmarkfunction folioq_is_marked2function folioq_mark2function folioq_unmark2function folioq_appendfunction folioq_append_markfunction folioq_folio_orderfunction folioq_folio_sizefunction folioq_clear
Annotated Snippet
struct folio_queue {
struct folio_batch vec; /* Folios in the queue segment */
u8 orders[FOLIO_BATCH_SIZE]; /* Order of each folio */
struct folio_queue *next; /* Next queue segment or NULL */
struct folio_queue *prev; /* Previous queue segment of NULL */
unsigned long marks; /* 1-bit mark per folio */
unsigned long marks2; /* Second 1-bit mark per folio */
#if FOLIO_BATCH_SIZE > BITS_PER_LONG
#error marks is not big enough
#endif
unsigned int rreq_id;
unsigned int debug_id;
};
/**
* folioq_init - Initialise a folio queue segment
* @folioq: The segment to initialise
* @rreq_id: The request identifier to use in tracelines.
*
* Initialise a folio queue segment and set an identifier to be used in traces.
*
* Note that the folio pointers are left uninitialised.
*/
static inline void folioq_init(struct folio_queue *folioq, unsigned int rreq_id)
{
folio_batch_init(&folioq->vec);
folioq->next = NULL;
folioq->prev = NULL;
folioq->marks = 0;
folioq->marks2 = 0;
folioq->rreq_id = rreq_id;
folioq->debug_id = 0;
}
/**
* folioq_nr_slots: Query the capacity of a folio queue segment
* @folioq: The segment to query
*
* Query the number of folios that a particular folio queue segment might hold.
* [!] NOTE: This must not be assumed to be the same for every segment!
*/
static inline unsigned int folioq_nr_slots(const struct folio_queue *folioq)
{
return FOLIO_BATCH_SIZE;
}
/**
* folioq_count: Query the occupancy of a folio queue segment
* @folioq: The segment to query
*
* Query the number of folios that have been added to a folio queue segment.
* Note that this is not decreased as folios are removed from a segment.
*/
static inline unsigned int folioq_count(struct folio_queue *folioq)
{
return folio_batch_count(&folioq->vec);
}
/**
* folioq_full: Query if a folio queue segment is full
* @folioq: The segment to query
*
* Query if a folio queue segment is fully occupied. Note that this does not
* change if folios are removed from a segment.
*/
static inline bool folioq_full(struct folio_queue *folioq)
{
//return !folio_batch_space(&folioq->vec);
return folioq_count(folioq) >= folioq_nr_slots(folioq);
}
/**
* folioq_is_marked: Check first folio mark in a folio queue segment
* @folioq: The segment to query
* @slot: The slot number of the folio to query
*
* Determine if the first mark is set for the folio in the specified slot in a
* folio queue segment.
*/
static inline bool folioq_is_marked(const struct folio_queue *folioq, unsigned int slot)
{
return test_bit(slot, &folioq->marks);
}
/**
* folioq_mark: Set the first mark on a folio in a folio queue segment
* @folioq: The segment to modify
* @slot: The slot number of the folio to modify
*
* Set the first mark for the folio in the specified slot in a folio queue
Annotation
- Immediate include surface: `linux/folio_batch.h`, `linux/mm.h`.
- Detected declarations: `struct folio_queue`, `function folioq_init`, `function folioq_nr_slots`, `function folioq_count`, `function folioq_full`, `function folioq_is_marked`, `function folioq_mark`, `function folioq_unmark`, `function folioq_is_marked2`, `function folioq_mark2`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.