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: 131270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cbc7:0:b0:3e9:de7a:15be with SMTP id f7csp1881837vqv; Fri, 4 Aug 2023 10:34:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwkiPqVew+JLeX5v87aBGphIak+AB9c4PE2EOXLBJV2g8pshdzVFKXRBdyfjQKr2e2fqoH X-Received: by 2002:a05:6a21:7795:b0:126:a80d:4960 with SMTP id bd21-20020a056a21779500b00126a80d4960mr2338330pzc.30.1691170454715; Fri, 04 Aug 2023 10:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691170454; cv=none; d=google.com; s=arc-20160816; b=oU0xOWWpKwUVKnU43rHStV3ZkVbdAGl463ZkdE1nWsjXBvAKxaA879eiofhc7Gjjov RQ0ozJy4HQWxAZ+8muk5C0Fy0m5dF+9r7yKifOr+n0c/R1oi8PbnVfVdsyGQ74g4u92+ Z5XVh/1tymmpjba0XlOjoaxjcCD5/TFfNEMtGafwm1Sml9pp0ONhXyJAcGFTGVlQyHaN xx+S1LaMf12KIPHZBbX036V/aE1SUpJQ3FOwfGGX4NGolBmPI5zHb+2LVk2tRdcMlfRa iIaKDDyfExAXcTVGZCeY+Td6S/THGV3/ygueIxYQjZ0CSTwh3fTkWsglH+EIY6BrMzZU FETA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=sWUCadNhtS5nrUCHR//9fr6i9W+VBU3reP6ArzIMKD4=; fh=9XXgHxlTCvaNzyqA2lfG2ipwZ+M9BkQwDdXD6g0UlK0=; b=yuExVqWh5FcR3OvTsBMTEvF8phE76eNJXQI/GVqmWdV9R/rhACHoWxZMGDX1+u+n3a 8tWfnHYXinv0SZGIMLVFfXx06M40N3PYuk4S/ytfL1k+xWN6o92rHOFf9lKO17NA2nc8 NnU/gBwXXfwZfM4Q2f18UKrEN8IUrc/F09pRY4mWLOAACj0IFcM1QtxMjgj3eMKEW1bp riBr1KAIVxiiH6nqncc+HNXjlYMMtpcQ2wzD+9XlXN7XAySnU1FvWs/+3TzIAR2s0axO cX5nt1A0Hr0GB8Z6e6S0eYPIqaOgZydyV86FE4iT9X9J0ZyDSzlOUwspfWQMHGxxxjGr FJJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IXgb4SEG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h128-20020a636c86000000b00563de165964si1996052pgc.43.2023.08.04.10.33.30; Fri, 04 Aug 2023 10:34:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IXgb4SEG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbjHDPif (ORCPT + 99 others); Fri, 4 Aug 2023 11:38:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbjHDPi1 (ORCPT ); Fri, 4 Aug 2023 11:38:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3790A171D for ; Fri, 4 Aug 2023 08:37:46 -0700 (PDT) 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-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-xTAwajXsO0OuR_KHSaGnUQ-1; Fri, 04 Aug 2023 11:37:44 -0400 X-MC-Unique: xTAwajXsO0OuR_KHSaGnUQ-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-763c36d4748so235191085a.0 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=AlIZ6j7ISvAzO5rooCjhsJk2M4++EwKlPC/ZJRePnTr2YvzHBLl9ZBU5w1wNyk4l7c nDUWVlad9uqqawFwF9kUqgBZKJ9OL7L1gXDWlvwkrXNKfQpUDh3u2qr1lSRQUX5ERLU3 5BajKrIPZ6+8HZvEiWQMwvKDH273cZhIaK5zN0d3qVKIxbEQMrWs9ecsY7QuQK3qV+jz 6s3EzptRiv9yVEA+Ofcw+TeVQl3umbU4cHl+aUajd585HzyWJakP5KRyj+FRl24cY/Q0 tjf/H1Nm6zHU+vKkFIqv1Sf0DvYCtOhp7Vj5q3ZWNrI2fX8SPQ9MLwhSS96dotLGr8h0 Ew0A== X-Gm-Message-State: AOJu0Yw1clFU8+qAfCKWQdWYM+MN6663XSPAEsPeG+SUDUWeOi8AoByJ F/I4qQb67thOMHpSPWSyTqeq0wIonBWb8y6BpCf9W2EGKgbSPOTZ3O/Sm36EW7r6P7LYpiSpMjh lOfoBLIkgndBTBrCdjnWYa9j0 X-Received: by 2002:a05:620a:4116:b0:76c:9884:4dce with SMTP id j22-20020a05620a411600b0076c98844dcemr2754751qko.63.1691163463729; Fri, 04 Aug 2023 08:37:43 -0700 (PDT) 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 Content-Disposition: inline User-Agent: NeoMutt/20230517 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773318748044552133 X-GMAIL-MSGID: 1773320750719812517 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 ");