Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

memcg: manually uninline __memcg_memory_event

__memcg_memory_event() has been unnecessarily marked inline even when it
is not really performance critical. It is usually called to track extreme
conditions. Over the time, it has evolved to include more functionality
and inlining it is causing more harm.

Before the patch:
$ size mm/memcontrol.o net/ipv4/tcp_input.o net/ipv4/tcp_output.o
text data bss dec hex filename
35645 10574 4192 50411 c4eb mm/memcontrol.o
54738 1658 0 56396 dc4c net/ipv4/tcp_input.o
34644 1065 0 35709 8b7d net/ipv4/tcp_output.o

After the patch:
$ size mm/memcontrol.o net/ipv4/tcp_input.o net/ipv4/tcp_output.o
text data bss dec hex filename
35137 10446 4192 49775 c26f mm/memcontrol.o
54322 1562 0 55884 da4c net/ipv4/tcp_input.o
34492 1017 0 35509 8ab5 net/ipv4/tcp_output.o

[akpm@linux-foundation.org: use EXPORT_SYMBOL_GPL for __memcg_memory_event, per Michal and Christoph]
Link: https://lkml.kernel.org/r/20251021234425.1885471-1-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: SeongJae Park <sj@kernel.org>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Shakeel Butt and committed by
Andrew Morton
5ff592be a0615780

+33 -30
+2 -30
include/linux/memcontrol.h
··· 1002 1002 count_memcg_events_mm(mm, idx, 1); 1003 1003 } 1004 1004 1005 - static inline void __memcg_memory_event(struct mem_cgroup *memcg, 1006 - enum memcg_memory_event event, 1007 - bool allow_spinning) 1008 - { 1009 - bool swap_event = event == MEMCG_SWAP_HIGH || event == MEMCG_SWAP_MAX || 1010 - event == MEMCG_SWAP_FAIL; 1011 - 1012 - /* For now only MEMCG_MAX can happen with !allow_spinning context. */ 1013 - VM_WARN_ON_ONCE(!allow_spinning && event != MEMCG_MAX); 1014 - 1015 - atomic_long_inc(&memcg->memory_events_local[event]); 1016 - if (!swap_event && allow_spinning) 1017 - cgroup_file_notify(&memcg->events_local_file); 1018 - 1019 - do { 1020 - atomic_long_inc(&memcg->memory_events[event]); 1021 - if (allow_spinning) { 1022 - if (swap_event) 1023 - cgroup_file_notify(&memcg->swap_events_file); 1024 - else 1025 - cgroup_file_notify(&memcg->events_file); 1026 - } 1027 - 1028 - if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) 1029 - break; 1030 - if (cgrp_dfl_root.flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS) 1031 - break; 1032 - } while ((memcg = parent_mem_cgroup(memcg)) && 1033 - !mem_cgroup_is_root(memcg)); 1034 - } 1005 + void __memcg_memory_event(struct mem_cgroup *memcg, 1006 + enum memcg_memory_event event, bool allow_spinning); 1035 1007 1036 1008 static inline void memcg_memory_event(struct mem_cgroup *memcg, 1037 1009 enum memcg_memory_event event)
+31
mm/memcontrol.c
··· 1626 1626 return page_counter_read(&memcg->memory); 1627 1627 } 1628 1628 1629 + void __memcg_memory_event(struct mem_cgroup *memcg, 1630 + enum memcg_memory_event event, bool allow_spinning) 1631 + { 1632 + bool swap_event = event == MEMCG_SWAP_HIGH || event == MEMCG_SWAP_MAX || 1633 + event == MEMCG_SWAP_FAIL; 1634 + 1635 + /* For now only MEMCG_MAX can happen with !allow_spinning context. */ 1636 + VM_WARN_ON_ONCE(!allow_spinning && event != MEMCG_MAX); 1637 + 1638 + atomic_long_inc(&memcg->memory_events_local[event]); 1639 + if (!swap_event && allow_spinning) 1640 + cgroup_file_notify(&memcg->events_local_file); 1641 + 1642 + do { 1643 + atomic_long_inc(&memcg->memory_events[event]); 1644 + if (allow_spinning) { 1645 + if (swap_event) 1646 + cgroup_file_notify(&memcg->swap_events_file); 1647 + else 1648 + cgroup_file_notify(&memcg->events_file); 1649 + } 1650 + 1651 + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) 1652 + break; 1653 + if (cgrp_dfl_root.flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS) 1654 + break; 1655 + } while ((memcg = parent_mem_cgroup(memcg)) && 1656 + !mem_cgroup_is_root(memcg)); 1657 + } 1658 + EXPORT_SYMBOL_GPL(__memcg_memory_event); 1659 + 1629 1660 static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, 1630 1661 int order) 1631 1662 {