Skip to content

Commit 7612833

Browse files
Alexei Starovoitovtehcaster
authored andcommitted
slab: Reuse first bit for OBJEXTS_ALLOC_FAIL
Since the combination of valid upper bits in slab->obj_exts with OBJEXTS_ALLOC_FAIL bit can never happen, use OBJEXTS_ALLOC_FAIL == (1ull << 0) as a magic sentinel instead of (1ull << 2) to free up bit 2. Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Shakeel Butt <[email protected]> Reviewed-by: Harry Yoo <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 83382af commit 7612833

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

include/linux/memcontrol.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,17 +341,23 @@ enum page_memcg_data_flags {
341341
__NR_MEMCG_DATA_FLAGS = (1UL << 2),
342342
};
343343

344+
#define __OBJEXTS_ALLOC_FAIL MEMCG_DATA_OBJEXTS
344345
#define __FIRST_OBJEXT_FLAG __NR_MEMCG_DATA_FLAGS
345346

346347
#else /* CONFIG_MEMCG */
347348

349+
#define __OBJEXTS_ALLOC_FAIL (1UL << 0)
348350
#define __FIRST_OBJEXT_FLAG (1UL << 0)
349351

350352
#endif /* CONFIG_MEMCG */
351353

352354
enum objext_flags {
353-
/* slabobj_ext vector failed to allocate */
354-
OBJEXTS_ALLOC_FAIL = __FIRST_OBJEXT_FLAG,
355+
/*
356+
* Use bit 0 with zero other bits to signal that slabobj_ext vector
357+
* failed to allocate. The same bit 0 with valid upper bits means
358+
* MEMCG_DATA_OBJEXTS.
359+
*/
360+
OBJEXTS_ALLOC_FAIL = __OBJEXTS_ALLOC_FAIL,
355361
/* the next bit after the last actual flag */
356362
__NR_OBJEXTS_FLAGS = (__FIRST_OBJEXT_FLAG << 1),
357363
};

mm/slub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,7 @@ static inline void handle_failed_objexts_alloc(unsigned long obj_exts,
20462046
* objects with no tag reference. Mark all references in this
20472047
* vector as empty to avoid warnings later on.
20482048
*/
2049-
if (obj_exts & OBJEXTS_ALLOC_FAIL) {
2049+
if (obj_exts == OBJEXTS_ALLOC_FAIL) {
20502050
unsigned int i;
20512051

20522052
for (i = 0; i < objects; i++)

0 commit comments

Comments
 (0)