@@ -1367,57 +1367,60 @@ slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
1367
1367
* did not request dmaable memory, we might get it, but that
1368
1368
* would be relatively rare and ignorable.
1369
1369
*/
1370
- static struct page * kmem_getpages (struct kmem_cache * cachep , gfp_t flags ,
1370
+ static struct slab * kmem_getpages (struct kmem_cache * cachep , gfp_t flags ,
1371
1371
int nodeid )
1372
1372
{
1373
- struct page * page ;
1373
+ struct folio * folio ;
1374
+ struct slab * slab ;
1374
1375
1375
1376
flags |= cachep -> allocflags ;
1376
1377
1377
- page = __alloc_pages_node (nodeid , flags , cachep -> gfporder );
1378
- if (!page ) {
1378
+ folio = ( struct folio * ) __alloc_pages_node (nodeid , flags , cachep -> gfporder );
1379
+ if (!folio ) {
1379
1380
slab_out_of_memory (cachep , flags , nodeid );
1380
1381
return NULL ;
1381
1382
}
1382
1383
1383
- account_slab (page_slab (page ), cachep -> gfporder , cachep , flags );
1384
- __SetPageSlab (page );
1384
+ slab = folio_slab (folio );
1385
+
1386
+ account_slab (slab , cachep -> gfporder , cachep , flags );
1387
+ __folio_set_slab (folio );
1385
1388
/* Record if ALLOC_NO_WATERMARKS was set when allocating the slab */
1386
- if (sk_memalloc_socks () && page_is_pfmemalloc (page ))
1387
- SetPageSlabPfmemalloc ( page );
1389
+ if (sk_memalloc_socks () && page_is_pfmemalloc (folio_page ( folio , 0 ) ))
1390
+ slab_set_pfmemalloc ( slab );
1388
1391
1389
- return page ;
1392
+ return slab ;
1390
1393
}
1391
1394
1392
1395
/*
1393
1396
* Interface to system's page release.
1394
1397
*/
1395
- static void kmem_freepages (struct kmem_cache * cachep , struct page * page )
1398
+ static void kmem_freepages (struct kmem_cache * cachep , struct slab * slab )
1396
1399
{
1397
1400
int order = cachep -> gfporder ;
1401
+ struct folio * folio = slab_folio (slab );
1398
1402
1399
- BUG_ON (!PageSlab (page ));
1400
- __ClearPageSlabPfmemalloc (page );
1401
- __ClearPageSlab (page );
1402
- page_mapcount_reset (page );
1403
- /* In union with page->mapping where page allocator expects NULL */
1404
- page -> slab_cache = NULL ;
1403
+ BUG_ON (!folio_test_slab (folio ));
1404
+ __slab_clear_pfmemalloc (slab );
1405
+ __folio_clear_slab (folio );
1406
+ page_mapcount_reset (folio_page (folio , 0 ));
1407
+ folio -> mapping = NULL ;
1405
1408
1406
1409
if (current -> reclaim_state )
1407
1410
current -> reclaim_state -> reclaimed_slab += 1 << order ;
1408
- unaccount_slab (page_slab ( page ) , order , cachep );
1409
- __free_pages (page , order );
1411
+ unaccount_slab (slab , order , cachep );
1412
+ __free_pages (folio_page ( folio , 0 ) , order );
1410
1413
}
1411
1414
1412
1415
static void kmem_rcu_free (struct rcu_head * head )
1413
1416
{
1414
1417
struct kmem_cache * cachep ;
1415
- struct page * page ;
1418
+ struct slab * slab ;
1416
1419
1417
- page = container_of (head , struct page , rcu_head );
1418
- cachep = page -> slab_cache ;
1420
+ slab = container_of (head , struct slab , rcu_head );
1421
+ cachep = slab -> slab_cache ;
1419
1422
1420
- kmem_freepages (cachep , page );
1423
+ kmem_freepages (cachep , slab );
1421
1424
}
1422
1425
1423
1426
#if DEBUG
@@ -1624,7 +1627,7 @@ static void slab_destroy(struct kmem_cache *cachep, struct page *page)
1624
1627
if (unlikely (cachep -> flags & SLAB_TYPESAFE_BY_RCU ))
1625
1628
call_rcu (& page -> rcu_head , kmem_rcu_free );
1626
1629
else
1627
- kmem_freepages (cachep , page );
1630
+ kmem_freepages (cachep , page_slab ( page ) );
1628
1631
1629
1632
/*
1630
1633
* From now on, we don't use freelist
@@ -2578,7 +2581,7 @@ static struct page *cache_grow_begin(struct kmem_cache *cachep,
2578
2581
* Get mem for the objs. Attempt to allocate a physical page from
2579
2582
* 'nodeid'.
2580
2583
*/
2581
- page = kmem_getpages (cachep , local_flags , nodeid );
2584
+ page = slab_page ( kmem_getpages (cachep , local_flags , nodeid ) );
2582
2585
if (!page )
2583
2586
goto failed ;
2584
2587
@@ -2620,7 +2623,7 @@ static struct page *cache_grow_begin(struct kmem_cache *cachep,
2620
2623
return page ;
2621
2624
2622
2625
opps1 :
2623
- kmem_freepages (cachep , page );
2626
+ kmem_freepages (cachep , page_slab ( page ) );
2624
2627
failed :
2625
2628
if (gfpflags_allow_blocking (local_flags ))
2626
2629
local_irq_disable ();
0 commit comments