Skip to content

Commit c42ce4b

Browse files
committed
mm: memcontrol: use generic mod_memcg_page_state for kmem pages
The kmem-specific functions do the same thing. Switch and drop. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Johannes Weiner <[email protected]> Acked-by: Vladimir Davydov <[email protected]> Cc: Josef Bacik <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Rik van Riel <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 9715dd8 commit c42ce4b

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed

include/linux/memcontrol.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -929,19 +929,6 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg)
929929
return memcg ? memcg->kmemcg_id : -1;
930930
}
931931

932-
/**
933-
* memcg_kmem_update_page_stat - update kmem page state statistics
934-
* @page: the page
935-
* @idx: page state item to account
936-
* @val: number of pages (positive or negative)
937-
*/
938-
static inline void memcg_kmem_update_page_stat(struct page *page,
939-
enum memcg_stat_item idx, int val)
940-
{
941-
if (memcg_kmem_enabled() && page->mem_cgroup)
942-
this_cpu_add(page->mem_cgroup->stat->count[idx], val);
943-
}
944-
945932
#else
946933
#define for_each_memcg_cache_index(_idx) \
947934
for (; NULL; )
@@ -964,10 +951,6 @@ static inline void memcg_put_cache_ids(void)
964951
{
965952
}
966953

967-
static inline void memcg_kmem_update_page_stat(struct page *page,
968-
enum memcg_stat_item idx, int val)
969-
{
970-
}
971954
#endif /* CONFIG_MEMCG && !CONFIG_SLOB */
972955

973956
#endif /* _LINUX_MEMCONTROL_H */

kernel/fork.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ static void account_kernel_stack(struct task_struct *tsk, int account)
326326
}
327327

328328
/* All stack pages belong to the same memcg. */
329-
memcg_kmem_update_page_stat(vm->pages[0], MEMCG_KERNEL_STACK_KB,
330-
account * (THREAD_SIZE / 1024));
329+
mod_memcg_page_state(vm->pages[0], MEMCG_KERNEL_STACK_KB,
330+
account * (THREAD_SIZE / 1024));
331331
} else {
332332
/*
333333
* All stack pages are in the same zone and belong to the
@@ -338,8 +338,8 @@ static void account_kernel_stack(struct task_struct *tsk, int account)
338338
mod_zone_page_state(page_zone(first_page), NR_KERNEL_STACK_KB,
339339
THREAD_SIZE / 1024 * account);
340340

341-
memcg_kmem_update_page_stat(first_page, MEMCG_KERNEL_STACK_KB,
342-
account * (THREAD_SIZE / 1024));
341+
mod_memcg_page_state(first_page, MEMCG_KERNEL_STACK_KB,
342+
account * (THREAD_SIZE / 1024));
343343
}
344344
}
345345

mm/slab.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@ static __always_inline int memcg_charge_slab(struct page *page,
285285
if (ret)
286286
return ret;
287287

288-
memcg_kmem_update_page_stat(page,
289-
(s->flags & SLAB_RECLAIM_ACCOUNT) ?
290-
NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
291-
1 << order);
288+
mod_memcg_page_state(page,
289+
(s->flags & SLAB_RECLAIM_ACCOUNT) ?
290+
NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
291+
1 << order);
292292
return 0;
293293
}
294294

@@ -298,10 +298,10 @@ static __always_inline void memcg_uncharge_slab(struct page *page, int order,
298298
if (!memcg_kmem_enabled())
299299
return;
300300

301-
memcg_kmem_update_page_stat(page,
302-
(s->flags & SLAB_RECLAIM_ACCOUNT) ?
303-
NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
304-
-(1 << order));
301+
mod_memcg_page_state(page,
302+
(s->flags & SLAB_RECLAIM_ACCOUNT) ?
303+
NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
304+
-(1 << order));
305305
memcg_kmem_uncharge(page, order);
306306
}
307307

0 commit comments

Comments
 (0)