From patchwork Fri Aug 4 15:37:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Karpinski X-Patchwork-Id: 13342050 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 412B6C001DB for ; Fri, 4 Aug 2023 15:37:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C92748D0008; Fri, 4 Aug 2023 11:37:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C42A18D0006; Fri, 4 Aug 2023 11:37:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0A5B8D0008; Fri, 4 Aug 2023 11:37:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A22768D0006 for ; Fri, 4 Aug 2023 11:37:48 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3A6F9C1559 for ; Fri, 4 Aug 2023 15:37:48 +0000 (UTC) X-FDA: 81086827416.25.536F11A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 240E820031 for ; Fri, 4 Aug 2023 15:37:45 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IXgb4SEG; spf=pass (imf13.hostedemail.com: domain of lkarpins@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=lkarpins@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691163466; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=sWUCadNhtS5nrUCHR//9fr6i9W+VBU3reP6ArzIMKD4=; b=oxVDS3O+pPkeGW0LNvZevmM9BouUotQu6HWHR6P0yvGLkQSaYTAbuSTGGdh++K3rvTP5Oq iYCES0Qwx8zuM9v3dX3BA6hgsxQXikdcFm5yDNfV3bzkCXdTDEAMYYRLcm4dXls59ZYSLm e0qBJgAlgFZ6/EKmbr89c3haVVL31Dc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691163466; a=rsa-sha256; cv=none; b=z+7hZcaQODDcwOqEaTcze8lSF0aIJ0d+QVUYszynsqat/9JKLQAiBmtlyTOpr0op5FjUZ0 L1901+w4Ybns5/jXJ/fRz5oYni1z1iEb/98r7O2r8D+HMQRn1TmrbX63xg20zvfrn8nkCs 0JUhhUc/p7J6W2fwAnui2gHyntaMf3M= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IXgb4SEG; spf=pass (imf13.hostedemail.com: domain of lkarpins@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=lkarpins@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691163465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=sWUCadNhtS5nrUCHR//9fr6i9W+VBU3reP6ArzIMKD4=; b=IXgb4SEGI77dtLPfazeZyb8o4OIt5EX0rKx3Ymw8vmT0cOtpzk9FCHwKofKSPUKGPqgo27 AbpEKS5x1RPkIClfAlQhHrr97ZgQkXQ4njrVL7+Qoxg76PVUu1rlCT1jcAbba/SMeaNq4r Z5zPk3k7jncUHKJ+AP1XGANyEmFneYA= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-4fHX6SVnOFeT8eJemn_7QA-1; Fri, 04 Aug 2023 11:37:44 -0400 X-MC-Unique: 4fHX6SVnOFeT8eJemn_7QA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-76c93466e4cso232630785a.3 for ; Fri, 04 Aug 2023 08:37:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691163464; x=1691768264; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sWUCadNhtS5nrUCHR//9fr6i9W+VBU3reP6ArzIMKD4=; b=SzkE2B3LYEXjYX6HXNgJYyLip5+tOHjO3ZsS31BSZbk4X5i4ZDmFlzBzFuwnI5yY47 ZhMYiYuWxTZG2SmIkoD8huDexlOoCXjixDs6XLM37ixupSQFLs74ehn2ukwDPY2tgtX/ zAxKV+oUmjGzJHrt8mpGiPR7RI1FoReZrY89qzpo86IZ+GPd4a8WxBL68wIZI3V3FGUD R86vL9Z9L7rewhJdmPri1w6XGlGuRCEcIkwGNEbrmVX2ecrXkI0QRUMYiLdgwiUq6Wvb 9kASH8exKLCc7snRZWuYUgoCkdA45aa76pcYsjjGQBkRAzT9XZ/vasfu2nM/WDfZzv5z CB/w== X-Gm-Message-State: AOJu0YymjenmBI/eP7aBtVmzNx/btzTjrR0SPlfk4Uf/2RZYO9iOtMXg UXK/yYUVfP+Lth8a3otH9YgmgLapnungv4cuN5AmR3tpfcuSQkokHfqmQJ2WtG2ANfQleDVOGSl MQpchs+AfJcw= X-Received: by 2002:a05:620a:4116:b0:76c:9884:4dce with SMTP id j22-20020a05620a411600b0076c98844dcemr2754750qko.63.1691163463728; Fri, 04 Aug 2023 08:37:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESeoIlDIDyx7XJyX0j8/1BX2ln6R1WxXabBDCtJd/UHzVFZ/vkvY/Etd4WOnHu0SSFDWBpIQ== X-Received: by 2002:a05:620a:4116:b0:76c:9884:4dce with SMTP id j22-20020a05620a411600b0076c98844dcemr2754733qko.63.1691163463425; Fri, 04 Aug 2023 08:37:43 -0700 (PDT) Received: from fedora ([174.89.37.244]) by smtp.gmail.com with ESMTPSA id a4-20020a05620a124400b0076c71c1d2f5sm723985qkl.34.2023.08.04.08.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 08:37:42 -0700 (PDT) Date: Fri, 4 Aug 2023 11:37:33 -0400 From: Lucas Karpinski To: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Tejun Heo , Zefan Li , Shuah Khan Cc: Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests: cgroup: fix test_kmem_memcg_deletion false positives Message-ID: MIME-Version: 1.0 User-Agent: NeoMutt/20230517 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Rspamd-Queue-Id: 240E820031 X-Rspam-User: X-Stat-Signature: i9ghonxg4r5441ciorpas964k1kw7ii9 X-Rspamd-Server: rspam03 X-HE-Tag: 1691163465-607607 X-HE-Meta: U2FsdGVkX1+NSqSEzkMmitENif7OnmIqsibn561hJXD/dJbyUq7E2QcN+E8fPFgjrLyYM9r4151VXf1UEtq6hiTwojt0bNUR4rAEC4HZjOI9EUIWp3hGodfQDe1epji8oABgYkj678I1Q1rF9hoca/vNE0NT37vN4TbPZ2/vwJ/1UhsZ+p3R8wxMNMZZO4dAGBhKXfD6LD3nxydwSTO2dppZiVIBaAVCasgNDsfiruwwcWJK07YRY6jnI04O9dsJy04wtU3nlCLTRo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0Euhq6imGJZow6RGGfa5Ee0LYvPskNv2yMBspBetwiXByMI4R5yU2WdCiDW98VC7RRpLHF26tSwDRfdCmbudFaGWfwe4I8sV65YtLPbb/djXiMq+8dUVpHcpeq0mCqOsJNlViwtQKlFrgWvFwJzzMT/N/J5/Q3D51MQqXNIp5MFYANgWC8akKCPZlbY= 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: The test allocates dcache inside a cgroup, then destroys the cgroups and then checks the sanity of numbers on the parent level. The reason it fails is because dentries are freed with an RCU delay - a debugging sleep shows that usage drops as expected shortly after. Insert a 1s sleep after completing the cgroup creation/deletions. This should be good enough, assuming that machines running those tests are otherwise not very busy. This commit is directly inspired by Johannes over at the link below. Link: https://lore.kernel.org/all/20230801135632.1768830-1-hannes@cmpxchg.org/ Signed-off-by: Lucas Karpinski --- tools/testing/selftests/cgroup/test_kmem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/selftests/cgroup/test_kmem.c index 67cc0182058d..7ac384bbfdd5 100644 --- a/tools/testing/selftests/cgroup/test_kmem.c +++ b/tools/testing/selftests/cgroup/test_kmem.c @@ -183,6 +183,9 @@ static int test_kmem_memcg_deletion(const char *root) if (cg_run_in_subcgroups(parent, alloc_kmem_smp, NULL, 100)) goto cleanup; + /* wait for RCU freeing */ + sleep(1); + current = cg_read_long(parent, "memory.current"); slab = cg_read_key_long(parent, "memory.stat", "slab "); anon = cg_read_key_long(parent, "memory.stat", "anon ");