From patchwork Fri Apr 22 15:57:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vernet X-Patchwork-Id: 12823695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B083AC4332F for ; Fri, 22 Apr 2022 15:57:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E5A76B009F; Fri, 22 Apr 2022 11:57:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 197406B00A0; Fri, 22 Apr 2022 11:57:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E662F6B00A1; Fri, 22 Apr 2022 11:57:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id D57D66B009F for ; Fri, 22 Apr 2022 11:57:51 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id B73361206EE for ; Fri, 22 Apr 2022 15:57:51 +0000 (UTC) X-FDA: 79384970742.05.81B5DDA Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by imf21.hostedemail.com (Postfix) with ESMTP id 762A11C002A for ; Fri, 22 Apr 2022 15:57:49 +0000 (UTC) Received: by mail-qk1-f178.google.com with SMTP id 204so6102725qkg.5 for ; Fri, 22 Apr 2022 08:57:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SQtAE3ZcQpFqrp+bASWhDiZvk53BS0iYnbojqFdBn7s=; b=jdMWpnEkeYx9mMFGUkId7KjH5l3jMxC+xfnYCW3qsOeFPPTHEc46Km7pt1OmFyF0Mj GhKkZICUfwP1qd9erSbv24Bu8MtsP5RLQN1p/YYxkT8Z8y8GOW1GvD9sE0jzSSy0Vly3 4GghbPNSwt5Pvnyox7Zbda/n6Jn6tq3jzKeUVMzooU9Ev9zmPBgD+9aJK9oF/fc/bCwb N8TwKtsIHXPsG35vGV2CF54y/UaGTIzt8J8AiuD7l9tg+9cKsPoA00Uk7dkHfzGVQwDF QIMi/8aH59SCAKNYt31HBukkPQAzGKkujXsH2Y8bklK7DiGNFiD0t5UdfuxPD59WwNTd KP6Q== X-Gm-Message-State: AOAM531LvYSqSoxB9KTJW+GfPfMEFzcRv1/bD8U0k59M+58UusKLfR57 Dh8iPCRwLIPGp3t1rrySI2E= X-Google-Smtp-Source: ABdhPJyEzJRX9vnV3+Z6TRD9kwrLPpVaz5L36ZFL4C9MSpyDrjP37pubNs3ib3cwHPc3pShEIIcIkA== X-Received: by 2002:a37:987:0:b0:69e:927e:756f with SMTP id 129-20020a370987000000b0069e927e756fmr3142409qkj.699.1650643070358; Fri, 22 Apr 2022 08:57:50 -0700 (PDT) Received: from localhost (fwdproxy-ash-018.fbsv.net. [2a03:2880:20ff:12::face:b00c]) by smtp.gmail.com with ESMTPSA id e23-20020a05620a12d700b0069ec181a0b2sm1033549qkl.69.2022.04.22.08.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 08:57:50 -0700 (PDT) From: David Vernet To: akpm@linux-foundation.org Cc: tj@kernel.org, roman.gushchin@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, shakeelb@google.com, kernel-team@fb.com, void@manifault.com Subject: [PATCH 4/5] cgroup: Removing racy check in test_memcg_sock() Date: Fri, 22 Apr 2022 08:57:28 -0700 Message-Id: <20220422155728.3055914-5-void@manifault.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220422155728.3055914-1-void@manifault.com> References: <20220422155728.3055914-1-void@manifault.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 762A11C002A X-Stat-Signature: iy7ctozqyr6qgqu7g5fk9tkmecxmzdnz Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf21.hostedemail.com: domain of dcvernet@gmail.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=dcvernet@gmail.com X-Rspam-User: X-HE-Tag: 1650643069-997498 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: test_memcg_sock() in the cgroup memcg tests, verifies expected memory accounting for sockets. The test forks a process which functions as a TCP server, and sends large buffers back and forth between itself (as the TCP client) and the forked TCP server. While doing so, it verifies that memory.current and memory.stat.sock look correct. There is currently a check in tcp_client() which asserts memory.current >= memory.stat.sock. This check is racy, as between memory.current and memory.stat.sock being queried, a packet could come in which causes mem_cgroup_charge_skmem() to be invoked. This could cause memory.stat.sock to exceed memory.current. Reversing the order of querying doesn't address the problem either, as memory may be reclaimed between the two calls. Instead, this patch just removes that assertion altogether, and instead relies on the values_close() check that follows to validate the expected accounting. Signed-off-by: David Vernet Acked-by: Roman Gushchin --- tools/testing/selftests/cgroup/test_memcontrol.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index d88e0ca3f3d1..c4735fa36a3d 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -993,9 +993,6 @@ static int tcp_client(const char *cgroup, unsigned short port) if (current < 0 || sock < 0) goto close_sk; - if (current < sock) - goto close_sk; - if (values_close(current, sock, 10)) { ret = KSFT_PASS; break;