Skip to content

Commit 4d2bcef

Browse files
Matthew Wilcox (Oracle)tehcaster
authored andcommitted
mm: Reduce the number of slab->folio casts
Mark a few more folio functions as taking a const folio pointer, which allows us to remove a few places in slab which cast away the const. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent a0a44d9 commit 4d2bcef

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

include/linux/mm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ static inline unsigned int compound_order(struct page *page)
11051105
*
11061106
* Return: The order of the folio.
11071107
*/
1108-
static inline unsigned int folio_order(struct folio *folio)
1108+
static inline unsigned int folio_order(const struct folio *folio)
11091109
{
11101110
if (!folio_test_large(folio))
11111111
return 0;
@@ -2145,7 +2145,7 @@ static inline struct folio *folio_next(struct folio *folio)
21452145
* it from being split. It is not necessary for the folio to be locked.
21462146
* Return: The base-2 logarithm of the size of this folio.
21472147
*/
2148-
static inline unsigned int folio_shift(struct folio *folio)
2148+
static inline unsigned int folio_shift(const struct folio *folio)
21492149
{
21502150
return PAGE_SHIFT + folio_order(folio);
21512151
}
@@ -2158,7 +2158,7 @@ static inline unsigned int folio_shift(struct folio *folio)
21582158
* it from being split. It is not necessary for the folio to be locked.
21592159
* Return: The number of bytes in this folio.
21602160
*/
2161-
static inline size_t folio_size(struct folio *folio)
2161+
static inline size_t folio_size(const struct folio *folio)
21622162
{
21632163
return PAGE_SIZE << folio_order(folio);
21642164
}

mm/slab.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static_assert(IS_ALIGNED(offsetof(struct slab, freelist), sizeof(freelist_aba_t)
166166
*/
167167
static inline bool slab_test_pfmemalloc(const struct slab *slab)
168168
{
169-
return folio_test_active((struct folio *)slab_folio(slab));
169+
return folio_test_active(slab_folio(slab));
170170
}
171171

172172
static inline void slab_set_pfmemalloc(struct slab *slab)
@@ -211,7 +211,7 @@ static inline struct slab *virt_to_slab(const void *addr)
211211

212212
static inline int slab_order(const struct slab *slab)
213213
{
214-
return folio_order((struct folio *)slab_folio(slab));
214+
return folio_order(slab_folio(slab));
215215
}
216216

217217
static inline size_t slab_size(const struct slab *slab)

mm/slub.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -962,11 +962,9 @@ void print_tracking(struct kmem_cache *s, void *object)
962962

963963
static void print_slab_info(const struct slab *slab)
964964
{
965-
struct folio *folio = (struct folio *)slab_folio(slab);
966-
967965
pr_err("Slab 0x%p objects=%u used=%u fp=0x%p flags=%pGp\n",
968966
slab, slab->objects, slab->inuse, slab->freelist,
969-
folio_flags(folio, 0));
967+
&slab->__page_flags);
970968
}
971969

972970
/*
@@ -2532,7 +2530,7 @@ static void discard_slab(struct kmem_cache *s, struct slab *slab)
25322530
*/
25332531
static inline bool slab_test_node_partial(const struct slab *slab)
25342532
{
2535-
return folio_test_workingset((struct folio *)slab_folio(slab));
2533+
return folio_test_workingset(slab_folio(slab));
25362534
}
25372535

25382536
static inline void slab_set_node_partial(struct slab *slab)

0 commit comments

Comments
 (0)