Skip to content

Commit 55ab834

Browse files
Michal Hockoakpm00
authored andcommitted
Revert "mm: add nodes= arg to memory.reclaim"
This reverts commit 12a5d39. Although it is recognized that a finer grained pro-active reclaim is something we need and want the semantic of this implementation is really ambiguous. In a follow up discussion it became clear that there are two essential usecases here. One is to use memory.reclaim to pro-actively reclaim memory and expectation is that the requested and reported amount of memory is uncharged from the memcg. Another usecase focuses on pro-active demotion when the memory is merely shuffled around to demotion targets while the overall charged memory stays unchanged. The current implementation considers demoted pages as reclaimed and that break both usecases. [1] has tried to address the reporting part but there are more issues with that summarized in [2] and follow up emails. Let's revert the nodemask based extension of the memcg pro-active reclaim for now until we settle with a more robust semantic. [1] http://lkml.kernel.org/r/http://lkml.kernel.org/r/[email protected] [2] http://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 12a5d39 ("mm: add nodes= arg to memory.reclaim") Signed-off-by: Michal Hocko <[email protected]> Cc: Bagas Sanjaya <[email protected]> Cc: Huang Ying <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Mina Almasry <[email protected]> Cc: Muchun Song <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Wei Xu <[email protected]> Cc: Yang Shi <[email protected]> Cc: Yosry Ahmed <[email protected]> Cc: zefan li <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 85b3258 commit 55ab834

File tree

4 files changed

+21
-68
lines changed

4 files changed

+21
-68
lines changed

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,13 +1245,17 @@ PAGE_SIZE multiple when read back.
12451245
This is a simple interface to trigger memory reclaim in the
12461246
target cgroup.
12471247

1248-
This file accepts a string which contains the number of bytes to
1249-
reclaim.
1248+
This file accepts a single key, the number of bytes to reclaim.
1249+
No nested keys are currently supported.
12501250

12511251
Example::
12521252

12531253
echo "1G" > memory.reclaim
12541254

1255+
The interface can be later extended with nested keys to
1256+
configure the reclaim behavior. For example, specify the
1257+
type of memory to reclaim from (anon, file, ..).
1258+
12551259
Please note that the kernel can over or under reclaim from
12561260
the target cgroup. If less bytes are reclaimed than the
12571261
specified amount, -EAGAIN is returned.
@@ -1263,13 +1267,6 @@ PAGE_SIZE multiple when read back.
12631267
This means that the networking layer will not adapt based on
12641268
reclaim induced by memory.reclaim.
12651269

1266-
This file also allows the user to specify the nodes to reclaim from,
1267-
via the 'nodes=' key, for example::
1268-
1269-
echo "1G nodes=0,1" > memory.reclaim
1270-
1271-
The above instructs the kernel to reclaim memory from nodes 0,1.
1272-
12731270
memory.peak
12741271
A read-only single value file which exists on non-root
12751272
cgroups.

include/linux/swap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,7 @@ extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
418418
extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,
419419
unsigned long nr_pages,
420420
gfp_t gfp_mask,
421-
unsigned int reclaim_options,
422-
nodemask_t *nodemask);
421+
unsigned int reclaim_options);
423422
extern unsigned long mem_cgroup_shrink_node(struct mem_cgroup *mem,
424423
gfp_t gfp_mask, bool noswap,
425424
pg_data_t *pgdat,

mm/memcontrol.c

Lines changed: 13 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
#include <linux/resume_user_mode.h>
6464
#include <linux/psi.h>
6565
#include <linux/seq_buf.h>
66-
#include <linux/parser.h>
6766
#include "internal.h"
6867
#include <net/sock.h>
6968
#include <net/ip.h>
@@ -2393,8 +2392,7 @@ static unsigned long reclaim_high(struct mem_cgroup *memcg,
23932392
psi_memstall_enter(&pflags);
23942393
nr_reclaimed += try_to_free_mem_cgroup_pages(memcg, nr_pages,
23952394
gfp_mask,
2396-
MEMCG_RECLAIM_MAY_SWAP,
2397-
NULL);
2395+
MEMCG_RECLAIM_MAY_SWAP);
23982396
psi_memstall_leave(&pflags);
23992397
} while ((memcg = parent_mem_cgroup(memcg)) &&
24002398
!mem_cgroup_is_root(memcg));
@@ -2685,8 +2683,7 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
26852683

26862684
psi_memstall_enter(&pflags);
26872685
nr_reclaimed = try_to_free_mem_cgroup_pages(mem_over_limit, nr_pages,
2688-
gfp_mask, reclaim_options,
2689-
NULL);
2686+
gfp_mask, reclaim_options);
26902687
psi_memstall_leave(&pflags);
26912688

26922689
if (mem_cgroup_margin(mem_over_limit) >= nr_pages)
@@ -3506,8 +3503,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
35063503
}
35073504

35083505
if (!try_to_free_mem_cgroup_pages(memcg, 1, GFP_KERNEL,
3509-
memsw ? 0 : MEMCG_RECLAIM_MAY_SWAP,
3510-
NULL)) {
3506+
memsw ? 0 : MEMCG_RECLAIM_MAY_SWAP)) {
35113507
ret = -EBUSY;
35123508
break;
35133509
}
@@ -3618,8 +3614,7 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg)
36183614
return -EINTR;
36193615

36203616
if (!try_to_free_mem_cgroup_pages(memcg, 1, GFP_KERNEL,
3621-
MEMCG_RECLAIM_MAY_SWAP,
3622-
NULL))
3617+
MEMCG_RECLAIM_MAY_SWAP))
36233618
nr_retries--;
36243619
}
36253620

@@ -6429,8 +6424,7 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
64296424
}
64306425

64316426
reclaimed = try_to_free_mem_cgroup_pages(memcg, nr_pages - high,
6432-
GFP_KERNEL, MEMCG_RECLAIM_MAY_SWAP,
6433-
NULL);
6427+
GFP_KERNEL, MEMCG_RECLAIM_MAY_SWAP);
64346428

64356429
if (!reclaimed && !nr_retries--)
64366430
break;
@@ -6479,8 +6473,7 @@ static ssize_t memory_max_write(struct kernfs_open_file *of,
64796473

64806474
if (nr_reclaims) {
64816475
if (!try_to_free_mem_cgroup_pages(memcg, nr_pages - max,
6482-
GFP_KERNEL, MEMCG_RECLAIM_MAY_SWAP,
6483-
NULL))
6476+
GFP_KERNEL, MEMCG_RECLAIM_MAY_SWAP))
64846477
nr_reclaims--;
64856478
continue;
64866479
}
@@ -6603,54 +6596,21 @@ static ssize_t memory_oom_group_write(struct kernfs_open_file *of,
66036596
return nbytes;
66046597
}
66056598

6606-
enum {
6607-
MEMORY_RECLAIM_NODES = 0,
6608-
MEMORY_RECLAIM_NULL,
6609-
};
6610-
6611-
static const match_table_t if_tokens = {
6612-
{ MEMORY_RECLAIM_NODES, "nodes=%s" },
6613-
{ MEMORY_RECLAIM_NULL, NULL },
6614-
};
6615-
66166599
static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf,
66176600
size_t nbytes, loff_t off)
66186601
{
66196602
struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
66206603
unsigned int nr_retries = MAX_RECLAIM_RETRIES;
66216604
unsigned long nr_to_reclaim, nr_reclaimed = 0;
6622-
unsigned int reclaim_options = MEMCG_RECLAIM_MAY_SWAP |
6623-
MEMCG_RECLAIM_PROACTIVE;
6624-
char *old_buf, *start;
6625-
substring_t args[MAX_OPT_ARGS];
6626-
int token;
6627-
char value[256];
6628-
nodemask_t nodemask = NODE_MASK_ALL;
6629-
6630-
buf = strstrip(buf);
6631-
6632-
old_buf = buf;
6633-
nr_to_reclaim = memparse(buf, &buf) / PAGE_SIZE;
6634-
if (buf == old_buf)
6635-
return -EINVAL;
6605+
unsigned int reclaim_options;
6606+
int err;
66366607

66376608
buf = strstrip(buf);
6609+
err = page_counter_memparse(buf, "", &nr_to_reclaim);
6610+
if (err)
6611+
return err;
66386612

6639-
while ((start = strsep(&buf, " ")) != NULL) {
6640-
if (!strlen(start))
6641-
continue;
6642-
token = match_token(start, if_tokens, args);
6643-
match_strlcpy(value, args, sizeof(value));
6644-
switch (token) {
6645-
case MEMORY_RECLAIM_NODES:
6646-
if (nodelist_parse(value, nodemask) < 0)
6647-
return -EINVAL;
6648-
break;
6649-
default:
6650-
return -EINVAL;
6651-
}
6652-
}
6653-
6613+
reclaim_options = MEMCG_RECLAIM_MAY_SWAP | MEMCG_RECLAIM_PROACTIVE;
66546614
while (nr_reclaimed < nr_to_reclaim) {
66556615
unsigned long reclaimed;
66566616

@@ -6667,8 +6627,7 @@ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf,
66676627

66686628
reclaimed = try_to_free_mem_cgroup_pages(memcg,
66696629
nr_to_reclaim - nr_reclaimed,
6670-
GFP_KERNEL, reclaim_options,
6671-
&nodemask);
6630+
GFP_KERNEL, reclaim_options);
66726631

66736632
if (!reclaimed && !nr_retries--)
66746633
return -EAGAIN;

mm/vmscan.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6754,8 +6754,7 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg,
67546754
unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,
67556755
unsigned long nr_pages,
67566756
gfp_t gfp_mask,
6757-
unsigned int reclaim_options,
6758-
nodemask_t *nodemask)
6757+
unsigned int reclaim_options)
67596758
{
67606759
unsigned long nr_reclaimed;
67616760
unsigned int noreclaim_flag;
@@ -6770,7 +6769,6 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,
67706769
.may_unmap = 1,
67716770
.may_swap = !!(reclaim_options & MEMCG_RECLAIM_MAY_SWAP),
67726771
.proactive = !!(reclaim_options & MEMCG_RECLAIM_PROACTIVE),
6773-
.nodemask = nodemask,
67746772
};
67756773
/*
67766774
* Traverse the ZONELIST_FALLBACK zonelist of the current node to put

0 commit comments

Comments
 (0)