@@ -466,34 +466,34 @@ static inline struct mem_cgroup *folio_memcg_rcu(struct folio *folio)
466
466
}
467
467
468
468
/*
469
- * page_memcg_check - get the memory cgroup associated with a page
470
- * @page: a pointer to the page struct
469
+ * folio_memcg_check - Get the memory cgroup associated with a folio.
470
+ * @folio: Pointer to the folio.
471
471
*
472
- * Returns a pointer to the memory cgroup associated with the page ,
473
- * or NULL. This function unlike page_memcg () can take any page
474
- * as an argument. It has to be used in cases when it's not known if a page
472
+ * Returns a pointer to the memory cgroup associated with the folio ,
473
+ * or NULL. This function unlike folio_memcg () can take any folio
474
+ * as an argument. It has to be used in cases when it's not known if a folio
475
475
* has an associated memory cgroup pointer or an object cgroups vector or
476
476
* an object cgroup.
477
477
*
478
- * For a non-kmem page any of the following ensures page and memcg binding
478
+ * For a non-kmem folio any of the following ensures folio and memcg binding
479
479
* stability:
480
480
*
481
- * - the page lock
481
+ * - the folio lock
482
482
* - LRU isolation
483
- * - lock_page_memcg ()
483
+ * - lock_folio_memcg ()
484
484
* - exclusive reference
485
485
* - mem_cgroup_trylock_pages()
486
486
*
487
- * For a kmem page a caller should hold an rcu read lock to protect memcg
488
- * associated with a kmem page from being released.
487
+ * For a kmem folio a caller should hold an rcu read lock to protect memcg
488
+ * associated with a kmem folio from being released.
489
489
*/
490
- static inline struct mem_cgroup * page_memcg_check (struct page * page )
490
+ static inline struct mem_cgroup * folio_memcg_check (struct folio * folio )
491
491
{
492
492
/*
493
- * Because page ->memcg_data might be changed asynchronously
494
- * for slab pages , READ_ONCE() should be used here.
493
+ * Because folio ->memcg_data might be changed asynchronously
494
+ * for slabs , READ_ONCE() should be used here.
495
495
*/
496
- unsigned long memcg_data = READ_ONCE (page -> memcg_data );
496
+ unsigned long memcg_data = READ_ONCE (folio -> memcg_data );
497
497
498
498
if (memcg_data & MEMCG_DATA_OBJCGS )
499
499
return NULL ;
@@ -508,6 +508,13 @@ static inline struct mem_cgroup *page_memcg_check(struct page *page)
508
508
return (struct mem_cgroup * )(memcg_data & ~MEMCG_DATA_FLAGS_MASK );
509
509
}
510
510
511
+ static inline struct mem_cgroup * page_memcg_check (struct page * page )
512
+ {
513
+ if (PageTail (page ))
514
+ return NULL ;
515
+ return folio_memcg_check ((struct folio * )page );
516
+ }
517
+
511
518
static inline struct mem_cgroup * get_mem_cgroup_from_objcg (struct obj_cgroup * objcg )
512
519
{
513
520
struct mem_cgroup * memcg ;
@@ -1170,6 +1177,11 @@ static inline struct mem_cgroup *folio_memcg_rcu(struct folio *folio)
1170
1177
return NULL ;
1171
1178
}
1172
1179
1180
+ static inline struct mem_cgroup * folio_memcg_check (struct folio * folio )
1181
+ {
1182
+ return NULL ;
1183
+ }
1184
+
1173
1185
static inline struct mem_cgroup * page_memcg_check (struct page * page )
1174
1186
{
1175
1187
return NULL ;
0 commit comments