Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2543860rwo; Thu, 3 Aug 2023 10:55:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlEexALe9tCITS8YNsQ/1x/S5A4l2Jku/1Tf+Is+IJnzk5Ko9fVGuMR01V6AUEIhkkGxw75a X-Received: by 2002:adf:e90a:0:b0:317:5b99:d3d7 with SMTP id f10-20020adfe90a000000b003175b99d3d7mr7978535wrm.34.1691085303002; Thu, 03 Aug 2023 10:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691085302; cv=none; d=google.com; s=arc-20160816; b=imuH4f9JRnoWofUhJvi8vDGNJhYnk/PQCuJwKoJqof65rJOGX5GvjkT16bmSWGuj06 MxTE2FSuC/Y/fl5NmrIbejL2tRrzviOrrPeI+/KQoqwwRDWeHQx1dYihUhLthL7PQrDW lgiOYjcSJN5HwTX9t74vOP5LEjwbY/Aqe3l1GiSDlQXqwwBXAuNR+JJtI3bxhOE48yJi F1Wbd3IRSxsL1bDfbLxBQfU/S/X1b13L9RdfgKSMY2C8Cz+uk2rOX/mTfDuriYSLn5aS 6pZWjpZ7xbQP1mtfxERn3kGb5tNd5I/t4hEJjIobzo13jfyJ16OxDuPhayA1X4z56Lds L8KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=uYbzj0g/4Qgf0B5sJ0nbhq9xa2DQZbXiKOB4SB+YMcU=; fh=POMNYmjbP2pVDL3SIN20z2Dqi0r8eoaOre+WLIHZukI=; b=uzYWRu+ihdVTc66+avFfH+98jF9WoYeRfdp1+A82TctihUepi6wwqTmWTJpJbOpfPk a1OHw9khK6u+WmXVIUCJOx0pfQ/0xqxY/91leu9wfwlaQ73CiroL1QaWEMtctfZrU6pD BLf6+xEj5y6QrTnR4hw2SovpkdYUvQcaGvkzQDinCcdbau/XlQW93u4WdV+eZu3dC+X+ oRG5d2MI87gI90MZ6O73R71Z/m4Pdh2YROmg4x1Xwp6014H3s/j2asMmgbWRmzVxrKbq qyaCX3KAJCtM1+kjZ6rQnuDm62pSK607H+vkdVSGncSmS4uwilxAX5QQ1UoHntIrv2DF rQew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MsBEdHdx; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l8-20020a17090612c800b0098df1cbe2b1si150909ejb.925.2023.08.03.10.54.38; Thu, 03 Aug 2023 10:55:02 -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=@kernel.org header.s=k20201202 header.b=MsBEdHdx; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234367AbjHCRTl (ORCPT + 99 others); Thu, 3 Aug 2023 13:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234257AbjHCRTj (ORCPT ); Thu, 3 Aug 2023 13:19:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE88B3A97; Thu, 3 Aug 2023 10:19:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 225E761E54; Thu, 3 Aug 2023 17:19:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78F83C433C8; Thu, 3 Aug 2023 17:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691083175; bh=rGBR/A6wmiGr7kQr72xa+WcmnICxmO1tIDp2ngWhxZk=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=MsBEdHdxEHN4vLWoAOVU+s9ykjbclLv+OIzSCl0C49tgmsjHVJQ5ygWIYZDE/EIPs qjnLWeIeQ4xYSqhpqyj2qe7RMhzZBvtpBKf3PZdpt2AUe35AjEiiSYpSu/Z8FXEm8v sUS+N1kCbVWGfKLR4dFlsI+gbROM2nLPrC3iwviqvfTB1a8GmhD8ICzfUa3X7pxuUN B5z4LVC5/Fsm4WLBLm5liBnKMFa4CEio/QvQuHKNznGf9bB6OIH7j698jBReX4XMYe DMn38IrJOroMIVUB3bDKwIOYsmInDp751Y/jtYXs6WWDrgtTCNLbvvn4WNnyAtsPrt 1Fmz7qE6uWYxg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 11523CE0C8E; Thu, 3 Aug 2023 10:19:35 -0700 (PDT) Date: Thu, 3 Aug 2023 10:19:35 -0700 From: "Paul E. McKenney" To: Lucas Karpinski Cc: Johannes Weiner , Andrew Morton , Roman Gushchin , Michal Hocko , linux-kselftest@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] selftests: cgroup: fix test_kmem_basic false positives Message-ID: <0a2b5245-0c81-4492-a846-b35fb85b227e@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20230801135632.1768830-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Thu, Aug 03, 2023 at 12:13:26PM -0400, Lucas Karpinski wrote: > On Tue, Aug 01, 2023 at 09:39:28AM -0700, Paul E. McKenney wrote: > > On Tue, Aug 01, 2023 at 09:56:32AM -0400, Johannes Weiner wrote: > > > This test fails routinely in our prod testing environment, and I can > > > reproduce it locally as well. > > > > > > The test allocates dcache inside a cgroup, then drops the memory limit > > > and checks that usage drops correspondingly. 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 dropping the limit. This should be good > > > enough, assuming that machines running those tests are otherwise not > > > very busy. > > > > > > Signed-off-by: Johannes Weiner > > > > I am putting together something more formal, but this will certainly > > improve things, as Johannes says, assuming the system goes mostly > > idle during that one-second wait. So: > > > > Acked-by: Paul E. McKenney > > > > Yes, there are corner cases, such as the system having millions of > > RCU callbacks queued and being unable to invoke them all during that > > one-second interval. But that is a corner case, and that is exactly > > why I will be putting together something more formal. ;-) > > > > Thanx, Paul > > > > > --- > > > tools/testing/selftests/cgroup/test_kmem.c | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/selftests/cgroup/test_kmem.c > > > index 258ddc565deb..1b2cec9d18a4 100644 > > > --- a/tools/testing/selftests/cgroup/test_kmem.c > > > +++ b/tools/testing/selftests/cgroup/test_kmem.c > > > @@ -70,6 +70,10 @@ static int test_kmem_basic(const char *root) > > > goto cleanup; > > > > > > cg_write(cg, "memory.high", "1M"); > > > + > > > + /* wait for RCU freeing */ > > > + sleep(1); > > > + > > > slab1 = cg_read_key_long(cg, "memory.stat", "slab "); > > > if (slab1 <= 0) > > > goto cleanup; > > > -- > > > 2.41.0 > > > > > The same issue exists in the test case test_kmem_memcg_deletion. I > wouldn't mind posting the patch, but it seems you want to propose > something more formal. Let me know your opinion. I am proposing a /sys/module/rcutree/parameters/do_rcu_barrier file. Writing a "1" into this file results in an rcu_barrier() in the kernel, but set up so that there is no more than a single rcu_barrier() call per second. So you could do the following: run-a-test echo 1 > /sys/module/rcutree/parameters/do_rcu_barrier # As root # All RCU callbacks from run-a-test have now been invoked run-another-test Please note that this handles only RCU, as in call_rcu(), and not SRCU, Tasks RCU, and so on. Thanx, Paul