Skip to content

Commit 75376c6

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
mm: convert mem_cgroup_css_from_page() to mem_cgroup_css_from_folio()
Only one caller doesn't have a folio, so move the page_folio() call to that one caller from mem_cgroup_css_from_folio(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 9cfb816 commit 75376c6

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

fs/fs-writeback.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void __inode_attach_wb(struct inode *inode, struct folio *folio)
246246
struct cgroup_subsys_state *memcg_css;
247247

248248
if (folio) {
249-
memcg_css = mem_cgroup_css_from_page(&folio->page);
249+
memcg_css = mem_cgroup_css_from_folio(folio);
250250
wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC);
251251
} else {
252252
/* must pin memcg_css, see wb_get_create() */
@@ -859,6 +859,7 @@ EXPORT_SYMBOL_GPL(wbc_detach_inode);
859859
void wbc_account_cgroup_owner(struct writeback_control *wbc, struct page *page,
860860
size_t bytes)
861861
{
862+
struct folio *folio;
862863
struct cgroup_subsys_state *css;
863864
int id;
864865

@@ -871,7 +872,8 @@ void wbc_account_cgroup_owner(struct writeback_control *wbc, struct page *page,
871872
if (!wbc->wb || wbc->no_cgroup_owner)
872873
return;
873874

874-
css = mem_cgroup_css_from_page(page);
875+
folio = page_folio(page);
876+
css = mem_cgroup_css_from_folio(folio);
875877
/* dead cgroups shouldn't contribute to inode ownership arbitration */
876878
if (!(css->flags & CSS_ONLINE))
877879
return;

include/linux/memcontrol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ static inline bool mm_match_cgroup(struct mm_struct *mm,
890890
return match;
891891
}
892892

893-
struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page);
893+
struct cgroup_subsys_state *mem_cgroup_css_from_folio(struct folio *folio);
894894
ino_t page_cgroup_ino(struct page *page);
895895

896896
static inline bool mem_cgroup_online(struct mem_cgroup *memcg)

mm/memcontrol.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,21 +350,19 @@ EXPORT_SYMBOL(memcg_kmem_enabled_key);
350350
#endif
351351

352352
/**
353-
* mem_cgroup_css_from_page - css of the memcg associated with a page
354-
* @page: page of interest
353+
* mem_cgroup_css_from_folio - css of the memcg associated with a folio
354+
* @folio: folio of interest
355355
*
356356
* If memcg is bound to the default hierarchy, css of the memcg associated
357-
* with @page is returned. The returned css remains associated with @page
357+
* with @folio is returned. The returned css remains associated with @folio
358358
* until it is released.
359359
*
360360
* If memcg is bound to a traditional hierarchy, the css of root_mem_cgroup
361361
* is returned.
362362
*/
363-
struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page)
363+
struct cgroup_subsys_state *mem_cgroup_css_from_folio(struct folio *folio)
364364
{
365-
struct mem_cgroup *memcg;
366-
367-
memcg = page_memcg(page);
365+
struct mem_cgroup *memcg = folio_memcg(folio);
368366

369367
if (!memcg || !cgroup_subsys_on_dfl(memory_cgrp_subsys))
370368
memcg = root_mem_cgroup;

0 commit comments

Comments
 (0)