xref: /linux-6.15/include/linux/mm_types.h (revision 173d6681)
1 #ifndef _LINUX_MM_TYPES_H
2 #define _LINUX_MM_TYPES_H
3 
4 #include <linux/types.h>
5 #include <linux/threads.h>
6 #include <linux/list.h>
7 #include <linux/spinlock.h>
8 
9 struct address_space;
10 
11 /*
12  * Each physical page in the system has a struct page associated with
13  * it to keep track of whatever it is we are using the page for at the
14  * moment. Note that we have no way to track which tasks are using
15  * a page, though if it is a pagecache page, rmap structures can tell us
16  * who is mapping it.
17  */
18 struct page {
19 	unsigned long flags;		/* Atomic flags, some possibly
20 					 * updated asynchronously */
21 	atomic_t _count;		/* Usage count, see below. */
22 	atomic_t _mapcount;		/* Count of ptes mapped in mms,
23 					 * to show when page is mapped
24 					 * & limit reverse map searches.
25 					 */
26 	union {
27 	    struct {
28 		unsigned long private;		/* Mapping-private opaque data:
29 					 	 * usually used for buffer_heads
30 						 * if PagePrivate set; used for
31 						 * swp_entry_t if PageSwapCache;
32 						 * indicates order in the buddy
33 						 * system if PG_buddy is set.
34 						 */
35 		struct address_space *mapping;	/* If low bit clear, points to
36 						 * inode address_space, or NULL.
37 						 * If page mapped as anonymous
38 						 * memory, low bit is set, and
39 						 * it points to anon_vma object:
40 						 * see PAGE_MAPPING_ANON below.
41 						 */
42 	    };
43 #if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
44 	    spinlock_t ptl;
45 #endif
46 	};
47 	pgoff_t index;			/* Our offset within mapping. */
48 	struct list_head lru;		/* Pageout list, eg. active_list
49 					 * protected by zone->lru_lock !
50 					 */
51 	/*
52 	 * On machines where all RAM is mapped into kernel address space,
53 	 * we can simply calculate the virtual address. On machines with
54 	 * highmem some memory is mapped into kernel virtual memory
55 	 * dynamically, so we need a place to store that address.
56 	 * Note that this field could be 16 bits on x86 ... ;)
57 	 *
58 	 * Architectures with slow multiplication can define
59 	 * WANT_PAGE_VIRTUAL in asm/page.h
60 	 */
61 #if defined(WANT_PAGE_VIRTUAL)
62 	void *virtual;			/* Kernel virtual address (NULL if
63 					   not kmapped, ie. highmem) */
64 #endif /* WANT_PAGE_VIRTUAL */
65 };
66 
67 #endif /* _LINUX_MM_TYPES_H */
68