Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp595847iob; Wed, 18 May 2022 08:48:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU9udODXZO0V5a4K5jZ3PZO4uhCm8NqYWZdA1GCXyuAQWQhKsRD/RN7bQdrAlkLlJr8VBA X-Received: by 2002:a63:914c:0:b0:3ab:894d:60e7 with SMTP id l73-20020a63914c000000b003ab894d60e7mr127448pge.176.1652888910164; Wed, 18 May 2022 08:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652888910; cv=none; d=google.com; s=arc-20160816; b=YldzB2eTahT3wSkXz9nEGujd2BTFBKnUJou6z6rF7VIOdBoPoPGPavseLE1s0tu5mY Tf2gAp7gqqrpg/o9aEtE5xgIJbcaeGJSCk3P40LCyMCZdxZrgnpvDPzOLwAervlcA/X2 KE2XTIMVIoqmkz8dh2NeStAd6Ea6ciT4TmhUSoi4mj5j4yDHhjGBX67HICzkrbNnrAZY 5sLXG2lkBuu4195TJ7OWcvrp4EOk/SL3OCpNj2ECSnhj5wxZCAAa1qbny++S3AUNDW5t pvP7fQqcz8RWKfcYP9JKp5ZTFCvJJY/+TDsax9xcIB95ZrDaIKC7KgnXMY1OFi4eK6Y6 oYNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p/VfT98eDaSoE5VMKiC0q6OouDpijrF5gH7LM1N1KeA=; b=j4NDsLJlDJrK3LoVcxl1vIiwaQ0d+4mi2o84iEqNf88eCDVNY/8E1t8MISsj/5BVhx SVYvWsMelppP0SwupiX76gWgKAP0BoZb05YwMuUaZ+VjBWCZMIfgBEF5qL9Ud5HWH9BW IgFvlmAH7xS7dWzK2FHk+xRH8SscaSOyUkWG4w9snCNJMgKEvxmd7UgHmZEbibFZmu7C KUHEYcuofIZZ9pvjmhbqxTXOQe8bYGuhfDU02fyg+m/3200Zwrw6qxjQe4FKhXGQmVKF +x6apWjQ3HhCpTQ+61PAc882ahQTyCilOluwFg4em8TzwKf7GSbbok/kZEOD7BBWJC2s Zxug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=k2d+vXCB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id fs12-20020a17090af28c00b001cd4990ce8esi3091180pjb.121.2022.05.18.08.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 08:48:30 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=k2d+vXCB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8F745AFADA; Wed, 18 May 2022 08:41:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239602AbiERPlM (ORCPT + 99 others); Wed, 18 May 2022 11:41:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239509AbiERPkx (ORCPT ); Wed, 18 May 2022 11:40:53 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46AD52E9C2; Wed, 18 May 2022 08:40:49 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BB77A1F8CD; Wed, 18 May 2022 15:40:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1652888447; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p/VfT98eDaSoE5VMKiC0q6OouDpijrF5gH7LM1N1KeA=; b=k2d+vXCBAm/e+L/WEhM4ig/Az5Mm4+rmJrHEMYxxue2I23dt8xecICNQ2v5ID3l+LK6epR awB4numSb8SgyTXxoNR0VrKF0ze7zsp6jXtQKezfLUuWVv/S6BgX1aYtPu9KNvFtOnQ+8y tiE8oXjgMdidP4GubiG3j7iSm0CF/A0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8BE4013ADC; Wed, 18 May 2022 15:40:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EKYKIX8ThWJDUgAAMHmgww (envelope-from ); Wed, 18 May 2022 15:40:47 +0000 From: =?UTF-8?q?Michal=20Koutn=C3=BD?= To: cgroups@vger.kernel.org, linux-mm@kvack.org Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Richard Palethorpe Subject: [PATCH 3/4] selftests: memcg: Adjust expected reclaim values of protected cgroups Date: Wed, 18 May 2022 17:40:36 +0200 Message-Id: <20220518154037.18819-4-mkoutny@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220518154037.18819-1-mkoutny@suse.com> References: <20220518154037.18819-1-mkoutny@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The numbers are not easy to derive in a closed form (certainly mere protections ratios do not apply), therefore use a simulation to obtain expected numbers. The new values make the protection tests succeed more precisely. % run as: octave-cli script % % Input configurations % ------------------- % E parent effective protection % n nominal protection of siblings set at the givel level % c current consumption -,,- % example from testcase (values in GB) E = 50 / 1024; n = [75 25 0 500 ] / 1024; c = [50 50 50 0] / 1024; % Reclaim parameters % ------------------ % Minimal reclaim amount (GB) cluster = 32*4 / 2**20; % Reclaim coefficient (think as 0.5^sc->priority) alpha = .1 % Simulation parameters % --------------------- epsilon = 1e-7; timeout = 1000; % Simulation loop % --------------------- % Simulation assumes siblings consumed the initial amount of memory (w/out % reclaim) and then the reclaim starts, all memory is reclaimable, i.e. treated % same. It simulates only non-low reclaim and assumes all memory.min = 0. ch = []; eh = []; rh = []; for t = 1:timeout % low_usage u = min(c, n); siblings = sum(u); % effective_protection() protected = min(n, c); % start with nominal e = protected * min(1, E / siblings); % normalize overcommit % recursive protection unclaimed = max(0, E - siblings); parent_overuse = sum(c) - siblings; if (unclaimed > 0 && parent_overuse > 0) overuse = max(0, c - protected); e += unclaimed * (overuse / parent_overuse); endif % get_scan_count() r = alpha * c; % assume all memory is in a single LRU list % commit 1bc63fb1272b ("mm, memcg: make scan aggression always exclude protection") sz = max(e, c); r .*= (1 - (e+epsilon) ./ (sz+epsilon)); % uncomment to debug prints % e, c, r % nothing to reclaim, reached equilibrium if max(r) < epsilon break; endif % SWAP_CLUSTER_MAX r = max(r, (r > epsilon) .* cluster); % XXX here I do parallel reclaim of all siblings % in reality reclaim is serialized and each sibling recalculates own residual c = max(c - r, 0); ch = [ch ; c]; eh = [eh ; e]; rh = [rh ; r]; endfor t c, e Signed-off-by: Michal Koutný --- .../selftests/cgroup/test_memcontrol.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index eba252fa64ac..9ffacf024bbd 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -260,9 +260,9 @@ static int cg_test_proc_killed(const char *cgroup) * memory pressure in it. * * A/B memory.current ~= 50M - * A/B/C memory.current ~= 33M - * A/B/D memory.current ~= 17M - * A/B/F memory.current ~= 0 + * A/B/C memory.current ~= 29M + * A/B/D memory.current ~= 21M + * A/B/E memory.current ~= 0 * * After that it tries to allocate more than there is * unprotected memory in A available, and checks @@ -365,10 +365,10 @@ static int test_memcg_min(const char *root) for (i = 0; i < ARRAY_SIZE(children); i++) c[i] = cg_read_long(children[i], "memory.current"); - if (!values_close(c[0], MB(33), 10)) + if (!values_close(c[0], MB(29), 10)) goto cleanup; - if (!values_close(c[1], MB(17), 10)) + if (!values_close(c[1], MB(21), 10)) goto cleanup; if (c[3] != 0) @@ -417,9 +417,9 @@ static int test_memcg_min(const char *root) * * Then it checks actual memory usages and expects that: * A/B memory.current ~= 50M - * A/B/ memory.current ~= 33M - * A/B/D memory.current ~= 17M - * A/B/F memory.current ~= 0 + * A/B/ memory.current ~= 29M + * A/B/D memory.current ~= 21M + * A/B/E memory.current ~= 0 * * After that it tries to allocate more than there is * unprotected memory in A available, @@ -512,10 +512,10 @@ static int test_memcg_low(const char *root) for (i = 0; i < ARRAY_SIZE(children); i++) c[i] = cg_read_long(children[i], "memory.current"); - if (!values_close(c[0], MB(33), 10)) + if (!values_close(c[0], MB(29), 10)) goto cleanup; - if (!values_close(c[1], MB(17), 10)) + if (!values_close(c[1], MB(21), 10)) goto cleanup; if (c[3] != 0) -- 2.35.3