Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit ea982d9

Browse files
committed
Merge branch 'slab/struct-page' into slab/next
2 parents d56791b + 7e00735 commit ea982d9

File tree

4 files changed

+243
-365
lines changed

4 files changed

+243
-365
lines changed

include/linux/mm_types.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,22 @@ struct page {
4242
/* First double word block */
4343
unsigned long flags; /* Atomic flags, some possibly
4444
* updated asynchronously */
45-
struct address_space *mapping; /* If low bit clear, points to
46-
* inode address_space, or NULL.
47-
* If page mapped as anonymous
48-
* memory, low bit is set, and
49-
* it points to anon_vma object:
50-
* see PAGE_MAPPING_ANON below.
51-
*/
45+
union {
46+
struct address_space *mapping; /* If low bit clear, points to
47+
* inode address_space, or NULL.
48+
* If page mapped as anonymous
49+
* memory, low bit is set, and
50+
* it points to anon_vma object:
51+
* see PAGE_MAPPING_ANON below.
52+
*/
53+
void *s_mem; /* slab first object */
54+
};
55+
5256
/* Second double word */
5357
struct {
5458
union {
5559
pgoff_t index; /* Our offset within mapping. */
56-
void *freelist; /* slub/slob first free object */
60+
void *freelist; /* sl[aou]b first free object */
5761
bool pfmemalloc; /* If set by the page allocator,
5862
* ALLOC_NO_WATERMARKS was set
5963
* and the low watermark was not
@@ -109,6 +113,7 @@ struct page {
109113
};
110114
atomic_t _count; /* Usage count, see below. */
111115
};
116+
unsigned int active; /* SLAB */
112117
};
113118
};
114119

@@ -130,6 +135,9 @@ struct page {
130135

131136
struct list_head list; /* slobs list of pages */
132137
struct slab *slab_page; /* slab fields */
138+
struct rcu_head rcu_head; /* Used by SLAB
139+
* when destroying via RCU
140+
*/
133141
};
134142

135143
/* Remainder is not double word aligned */

include/linux/slab.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@
5151
* }
5252
* rcu_read_unlock();
5353
*
54-
* See also the comment on struct slab_rcu in mm/slab.c.
54+
* This is useful if we need to approach a kernel structure obliquely,
55+
* from its address obtained without the usual locking. We can lock
56+
* the structure to stabilize it and check it's still at the given address,
57+
* only if we can be sure that the memory has not been meanwhile reused
58+
* for some other kind of object (which our subsystem's lock might corrupt).
59+
*
60+
* rcu_read_lock before reading the address, then rcu_read_unlock after
61+
* taking the spinlock within the structure expected at that address.
5562
*/
5663
#define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */
5764
#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */

include/linux/slab_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ struct kmem_cache {
4141

4242
size_t colour; /* cache colouring range */
4343
unsigned int colour_off; /* colour offset */
44-
struct kmem_cache *slabp_cache;
45-
unsigned int slab_size;
44+
struct kmem_cache *freelist_cache;
45+
unsigned int freelist_size;
4646

4747
/* constructor func */
4848
void (*ctor)(void *obj);

0 commit comments

Comments
 (0)