All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] memcontrol03: Account for process size in cgroup allocation
Date: Wed, 7 May 2025 16:23:30 +0200	[thread overview]
Message-ID: <aBts4kDaqLKLJUuw@yuki.lan> (raw)
In-Reply-To: <20250505105310.15072-1-mdoucha@suse.cz>

Hi!
> The first trunk_G allocation has 2MB safety margin to avoid triggering
> OOM killer. However, on systems with 64K pagesize, this may not be enough.
> Account for process size as reported by cgroup memory stats before
> allocating memory in child processes.

Is there a reason to keep the 2MB safety after this patch?

Or can we do:

diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
index b5bbb9954..e7f126880 100644
--- a/testcases/kernel/controllers/memcg/memcontrol03.c
+++ b/testcases/kernel/controllers/memcg/memcontrol03.c
@@ -200,7 +200,7 @@ static void test_memcg_min(void)
                sleep(1);
        }

-       alloc_anon_in_child(trunk_cg[G], MB(148), 0);
+       alloc_anon_in_child(trunk_cg[G], MB(150), 0);

        SAFE_CG_SCANF(trunk_cg[B], "memory.current", "%ld", c);
        TST_EXP_EXPR(values_close(c[0], MB(50), 5),

> --- a/testcases/kernel/controllers/memcg/memcontrol03.c
> +++ b/testcases/kernel/controllers/memcg/memcontrol03.c
> @@ -94,17 +94,23 @@ static void cleanup_sub_groups(void)
>  }
>  
>  static void alloc_anon_in_child(const struct tst_cg_group *const cg,
> -				const size_t size, const int expect_oom)
> +	size_t size, const int expect_oom)
>  {
>  	int status;
>  	const pid_t pid = SAFE_FORK();
> +	size_t cgmem;
>  
>  	if (!pid) {
>  		SAFE_CG_PRINTF(cg, "cgroup.procs", "%d", getpid());
> +		SAFE_CG_SCANF(cg, "memory.current", "%zu", &cgmem);
> +		size = size > cgmem ? size - cgmem : 0;

Here we depend on the fact that process memory has been properly
accounted for when it starts running its code. Are you sure that we can
rely on this or does this just happen to work?

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2025-05-07 14:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-05 10:53 [LTP] [PATCH] memcontrol03: Account for process size in cgroup allocation Martin Doucha
2025-05-06  6:59 ` Li Wang via ltp
2025-05-07 14:23 ` Cyril Hrubis [this message]
2025-05-07 15:36   ` Martin Doucha
2025-05-09  9:21     ` Cyril Hrubis
2025-05-09  9:40       ` Martin Doucha
2025-05-09 10:01         ` Cyril Hrubis
2025-05-09 10:11           ` Martin Doucha
2025-05-20 15:29             ` Martin Doucha
     [not found]           ` <qbca5sxzfw53o6nku5ulu2dl2xygxqghgsuerjjjfoea62bacs@a5qm6cl7hhnu>
2025-05-09 14:41             ` Martin Doucha
2025-05-20 17:57               ` ALOK TIWARI via ltp
2025-05-26 13:52                 ` Martin Doucha
     [not found]               ` <6msduqbs42k7lnysck7oxoqyicbo6yzktstxdjan5ktpv4qzrx@s2xpicy3johi>
2025-05-28 12:04                 ` [LTP] [TEST PATCH] memcontrol: Wait for draining of remote stocks when charging Martin Doucha
2025-05-30 11:44                 ` Martin Doucha
2025-07-03  9:36                 ` Martin Doucha
2025-09-03  9:19 ` [LTP] [PATCH] memcontrol03: Account for process size in cgroup allocation Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aBts4kDaqLKLJUuw@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=mdoucha@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.