Skip to content

Commit aa6b4fd

Browse files
shakeelbakpm00
authored andcommitted
memcg-v1: fully deprecate move_charge_at_immigrate
Patch series "memcg-v1: fully deprecate charge moving". The memcg v1's charge moving feature has been deprecated for almost 2 years and the kernel warns if someone try to use it. This warning has been backported to all stable kernel and there have not been any report of the warning or the request to support this feature anymore. Let's proceed to fully deprecate this feature. This patch (of 6): Proceed with the complete deprecation of memcg v1's charge moving feature. The deprecation warning has been in the kernel for almost two years and has been ported to all stable kernel since. Now is the time to fully deprecate this feature. Link: https://lkml.kernel.org/r/20241025012304.2473312-1-shakeel.butt@linux.dev Link: https://lkml.kernel.org/r/20241025012304.2473312-2-shakeel.butt@linux.dev Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev> Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev> Acked-by: Michal Hocko <mhocko@suse.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Hugh Dickins <hughd@google.com> Cc: Muchun Song <muchun.song@linux.dev> Cc: Yosry Ahmed <yosryahmed@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 729881f commit aa6b4fd

File tree

2 files changed

+5
-91
lines changed

2 files changed

+5
-91
lines changed

Documentation/admin-guide/cgroup-v1/memory.rst

Lines changed: 3 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ Brief summary of control files.
9090
used.
9191
memory.swappiness set/show swappiness parameter of vmscan
9292
(See sysctl's vm.swappiness)
93-
memory.move_charge_at_immigrate set/show controls of moving charges
94-
This knob is deprecated and shouldn't be
95-
used.
93+
memory.move_charge_at_immigrate This knob is deprecated.
9694
memory.oom_control set/show oom controls.
9795
This knob is deprecated and shouldn't be
9896
used.
@@ -243,10 +241,6 @@ behind this approach is that a cgroup that aggressively uses a shared
243241
page will eventually get charged for it (once it is uncharged from
244242
the cgroup that brought it in -- this will happen on memory pressure).
245243

246-
But see :ref:`section 8.2 <cgroup-v1-memory-movable-charges>` when moving a
247-
task to another cgroup, its pages may be recharged to the new cgroup, if
248-
move_charge_at_immigrate has been chosen.
249-
250244
2.4 Swap Extension
251245
--------------------------------------
252246

@@ -756,78 +750,8 @@ If we want to change this to 1G, we can at any time use::
756750

757751
THIS IS DEPRECATED!
758752

759-
It's expensive and unreliable! It's better practice to launch workload
760-
tasks directly from inside their target cgroup. Use dedicated workload
761-
cgroups to allow fine-grained policy adjustments without having to
762-
move physical pages between control domains.
763-
764-
Users can move charges associated with a task along with task migration, that
765-
is, uncharge task's pages from the old cgroup and charge them to the new cgroup.
766-
This feature is not supported in !CONFIG_MMU environments because of lack of
767-
page tables.
768-
769-
8.1 Interface
770-
-------------
771-
772-
This feature is disabled by default. It can be enabled (and disabled again) by
773-
writing to memory.move_charge_at_immigrate of the destination cgroup.
774-
775-
If you want to enable it::
776-
777-
# echo (some positive value) > memory.move_charge_at_immigrate
778-
779-
.. note::
780-
Each bits of move_charge_at_immigrate has its own meaning about what type
781-
of charges should be moved. See :ref:`section 8.2
782-
<cgroup-v1-memory-movable-charges>` for details.
783-
784-
.. note::
785-
Charges are moved only when you move mm->owner, in other words,
786-
a leader of a thread group.
787-
788-
.. note::
789-
If we cannot find enough space for the task in the destination cgroup, we
790-
try to make space by reclaiming memory. Task migration may fail if we
791-
cannot make enough space.
792-
793-
.. note::
794-
It can take several seconds if you move charges much.
795-
796-
And if you want disable it again::
797-
798-
# echo 0 > memory.move_charge_at_immigrate
799-
800-
.. _cgroup-v1-memory-movable-charges:
801-
802-
8.2 Type of charges which can be moved
803-
--------------------------------------
804-
805-
Each bit in move_charge_at_immigrate has its own meaning about what type of
806-
charges should be moved. But in any case, it must be noted that an account of
807-
a page or a swap can be moved only when it is charged to the task's current
808-
(old) memory cgroup.
809-
810-
+---+--------------------------------------------------------------------------+
811-
|bit| what type of charges would be moved ? |
812-
+===+==========================================================================+
813-
| 0 | A charge of an anonymous page (or swap of it) used by the target task. |
814-
| | You must enable Swap Extension (see 2.4) to enable move of swap charges. |
815-
+---+--------------------------------------------------------------------------+
816-
| 1 | A charge of file pages (normal file, tmpfs file (e.g. ipc shared memory) |
817-
| | and swaps of tmpfs file) mmapped by the target task. Unlike the case of |
818-
| | anonymous pages, file pages (and swaps) in the range mmapped by the task |
819-
| | will be moved even if the task hasn't done page fault, i.e. they might |
820-
| | not be the task's "RSS", but other task's "RSS" that maps the same file. |
821-
| | The mapcount of the page is ignored (the page can be moved independent |
822-
| | of the mapcount). You must enable Swap Extension (see 2.4) to |
823-
| | enable move of swap charges. |
824-
+---+--------------------------------------------------------------------------+
825-
826-
8.3 TODO
827-
--------
828-
829-
- All of moving charge operations are done under cgroup_mutex. It's not good
830-
behavior to hold the mutex too long, so we may need some trick.
753+
Reading memory.move_charge_at_immigrate will always return 0 and writing
754+
to it will always return -EINVAL.
831755

832756
9. Memory thresholds
833757
====================

mm/memcontrol-v1.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -593,29 +593,19 @@ static inline int mem_cgroup_move_swap_account(swp_entry_t entry,
593593
static u64 mem_cgroup_move_charge_read(struct cgroup_subsys_state *css,
594594
struct cftype *cft)
595595
{
596-
return mem_cgroup_from_css(css)->move_charge_at_immigrate;
596+
return 0;
597597
}
598598

599599
#ifdef CONFIG_MMU
600600
static int mem_cgroup_move_charge_write(struct cgroup_subsys_state *css,
601601
struct cftype *cft, u64 val)
602602
{
603-
struct mem_cgroup *memcg = mem_cgroup_from_css(css);
604-
605603
pr_warn_once("Cgroup memory moving (move_charge_at_immigrate) is deprecated. "
606604
"Please report your usecase to linux-mm@kvack.org if you "
607605
"depend on this functionality.\n");
608606

609-
if (val & ~MOVE_MASK)
607+
if (val != 0)
610608
return -EINVAL;
611-
612-
/*
613-
* No kind of locking is needed in here, because ->can_attach() will
614-
* check this value once in the beginning of the process, and then carry
615-
* on with stale data. This means that changes to this value will only
616-
* affect task migrations starting after the change.
617-
*/
618-
memcg->move_charge_at_immigrate = val;
619609
return 0;
620610
}
621611
#else

0 commit comments

Comments
 (0)