Skip to content

Commit

Permalink
mm/memcontrol: remove __mod_lruvec_page_state()
Browse files Browse the repository at this point in the history
There are no more callers of __mod_lruvec_page_state(), so convert the
implementation to __lruvec_stat_mod_folio(), removing two calls to
compound_head() (one explicit, one hidden inside page_memcg()).

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Reviewed-by: Zi Yan <[email protected]>
Acked-by: Shakeel Butt <[email protected]>
Reviewed-by: Vlastimil Babka <[email protected]>
Cc: Hyeonggon Yoo <[email protected]>
Cc: Johannes Weiner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) authored and akpm00 committed Jan 5, 2024
1 parent b54d60b commit c701123
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
36 changes: 18 additions & 18 deletions include/linux/vmstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,19 +556,25 @@ static inline void mod_lruvec_state(struct lruvec *lruvec,
local_irq_restore(flags);
}

void __mod_lruvec_page_state(struct page *page,
void __lruvec_stat_mod_folio(struct folio *folio,
enum node_stat_item idx, int val);

static inline void mod_lruvec_page_state(struct page *page,
static inline void lruvec_stat_mod_folio(struct folio *folio,
enum node_stat_item idx, int val)
{
unsigned long flags;

local_irq_save(flags);
__mod_lruvec_page_state(page, idx, val);
__lruvec_stat_mod_folio(folio, idx, val);
local_irq_restore(flags);
}

static inline void mod_lruvec_page_state(struct page *page,
enum node_stat_item idx, int val)
{
lruvec_stat_mod_folio(page_folio(page), idx, val);
}

#else

static inline void __mod_lruvec_state(struct lruvec *lruvec,
Expand All @@ -583,10 +589,16 @@ static inline void mod_lruvec_state(struct lruvec *lruvec,
mod_node_page_state(lruvec_pgdat(lruvec), idx, val);
}

static inline void __mod_lruvec_page_state(struct page *page,
enum node_stat_item idx, int val)
static inline void __lruvec_stat_mod_folio(struct folio *folio,
enum node_stat_item idx, int val)
{
__mod_node_page_state(page_pgdat(page), idx, val);
__mod_node_page_state(folio_pgdat(folio), idx, val);
}

static inline void lruvec_stat_mod_folio(struct folio *folio,
enum node_stat_item idx, int val)
{
mod_node_page_state(folio_pgdat(folio), idx, val);
}

static inline void mod_lruvec_page_state(struct page *page,
Expand All @@ -597,12 +609,6 @@ static inline void mod_lruvec_page_state(struct page *page,

#endif /* CONFIG_MEMCG */

static inline void __lruvec_stat_mod_folio(struct folio *folio,
enum node_stat_item idx, int val)
{
__mod_lruvec_page_state(&folio->page, idx, val);
}

static inline void __lruvec_stat_add_folio(struct folio *folio,
enum node_stat_item idx)
{
Expand All @@ -615,12 +621,6 @@ static inline void __lruvec_stat_sub_folio(struct folio *folio,
__lruvec_stat_mod_folio(folio, idx, -folio_nr_pages(folio));
}

static inline void lruvec_stat_mod_folio(struct folio *folio,
enum node_stat_item idx, int val)
{
mod_lruvec_page_state(&folio->page, idx, val);
}

static inline void lruvec_stat_add_folio(struct folio *folio,
enum node_stat_item idx)
{
Expand Down
9 changes: 4 additions & 5 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,16 +890,15 @@ void __mod_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx,
__mod_memcg_lruvec_state(lruvec, idx, val);
}

void __mod_lruvec_page_state(struct page *page, enum node_stat_item idx,
void __lruvec_stat_mod_folio(struct folio *folio, enum node_stat_item idx,
int val)
{
struct page *head = compound_head(page); /* rmap on tail pages */
struct mem_cgroup *memcg;
pg_data_t *pgdat = page_pgdat(page);
pg_data_t *pgdat = folio_pgdat(folio);
struct lruvec *lruvec;

rcu_read_lock();
memcg = page_memcg(head);
memcg = folio_memcg(folio);
/* Untracked pages have no memcg, no lruvec. Update only the node */
if (!memcg) {
rcu_read_unlock();
Expand All @@ -911,7 +910,7 @@ void __mod_lruvec_page_state(struct page *page, enum node_stat_item idx,
__mod_lruvec_state(lruvec, idx, val);
rcu_read_unlock();
}
EXPORT_SYMBOL(__mod_lruvec_page_state);
EXPORT_SYMBOL(__lruvec_stat_mod_folio);

void __mod_lruvec_kmem_state(void *p, enum node_stat_item idx, int val)
{
Expand Down

0 comments on commit c701123

Please sign in to comment.