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.

Dependency Surface

Detected Declarations

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

Implementation Notes