Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7165335rwr; Tue, 25 Apr 2023 08:59:26 -0700 (PDT) X-Google-Smtp-Source: AKy350YB4d8+2bk2UnuAPWOsLKDzlNm/FF7o8tM0+CaLC0f2vj57u/ZM1My+nbzgPpTN7yt/RFxq X-Received: by 2002:a05:6a00:1749:b0:634:970e:ca09 with SMTP id j9-20020a056a00174900b00634970eca09mr24673862pfc.30.1682438365995; Tue, 25 Apr 2023 08:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682438365; cv=none; d=google.com; s=arc-20160816; b=TQ5J4T7NTBFjF93mDFsU8/sdB8O6C9wM0pRIR9Ws/S05OwTKc//SgWOZFqss7H+TEE Wzm5j597roWe9N4kuGwdcKjzDqCp7+68VfIeMJL7mGUBCcffZ4zj5qkl+w8aVm9o31ot VjARvLfYHVwh0v23jtBHrY8GhkIYY2QwF0ZHos00EUgojmGFN5mJyPA2AA6OilgucYi/ YYY8+XFmvLZwZ5/IZ44yVAvdAUpQN8umI4NxZcLB9FbmeZD6x7IMd3/QjRH7Uq+M0mPK jbDLOPVtjReEGbfxRS6e5xRh5UzhKcBAEPgqYnfsrlcpw+b22GEPvifNJBE3b1yGLtP8 /RgA== 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:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=+/XKcjKrBYNMWbprccyz7nA7lIfjchnB0B9EnEgI4Ak=; b=Ll/fMSa3xGjqdgnwcSMi5hP0fJ7I6zxfSYGaQ4uSxQ5zK2o8Rd9CD+8Jqk2GOrTfUr mC09GGbzk1rDa+uKVSlo62uWj8iOiH2UXq9jHCLKR4cFkHSuYfJpzyEPbw5slg0Zml9Y Y/TbfwlP74bjrfupPc93Y4/BceI9ISRUMYQgtlSqh0FP2EXl2w0GMNlt+7WcbGiC7aYL LDyXIQlUAmr6OhOdJ3cK6bb1GlZYASnY71J12vp6J0OxQbDrCHzFMlJjRf6Yh9pCBHJi Ry1mVupmw43lGQLckucz4qq0saOX9bCWnCyshvwLIXO6nC7ey7gwRi1y76cmTOm+s0WT RDIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=D8yd29yb; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=HIGtPOWR; 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=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p14-20020a63fe0e000000b0052856cec949si3724855pgh.875.2023.04.25.08.59.12; Tue, 25 Apr 2023 08:59:25 -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=@cerno.tech header.s=fm2 header.b=D8yd29yb; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=HIGtPOWR; 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=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234489AbjDYPrU (ORCPT + 99 others); Tue, 25 Apr 2023 11:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233799AbjDYPrS (ORCPT ); Tue, 25 Apr 2023 11:47:18 -0400 Received: from wnew2-smtp.messagingengine.com (wnew2-smtp.messagingengine.com [64.147.123.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3C971BD6; Tue, 25 Apr 2023 08:47:16 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 9ADD62B067C0; Tue, 25 Apr 2023 11:47:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 25 Apr 2023 11:47:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1682437634; x=1682444834; bh=+/ XKcjKrBYNMWbprccyz7nA7lIfjchnB0B9EnEgI4Ak=; b=D8yd29ybuQFZIaBp65 nnQQBAQPAy0o2t/dQP0i+h4ktrybLSxygK1NhFRY/KIFdNwezspf5m5cp/kAhVRL oAlnOD1waJ4UZy40wvfhByRmZ4hblbuu7aDYQGnC370Ntq+tz/HViGEUMVteMMmj M91RirqtYE0xRhPLkF0GberrHPFS+YgA53vHrvOXQJbe+CkZsSR6e3+TiFjR45fr I3yfumMJ62cwfys0RILOW5OhNmgKPjT/oa4GlkYzlFMOfUsPsjxMWxL3zUNEChd5 h3EkTiYXg3scTgCKbtaGTLw4722h4yck71n1W2P88ZbzJXmzjC5NU+fhVlBmzeZ1 FmTw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1682437634; x=1682444834; bh=+/XKcjKrBYNMW bprccyz7nA7lIfjchnB0B9EnEgI4Ak=; b=HIGtPOWRm3DbLvvy30nvn2nBHnvxZ G2nlTgmf82KI3Vt78B0hz/UAiYmF+JlNWTEnru8pEK02E7QsSHYgCVmFdDs62UIT 3p+sJK5yUDqls75GwI2IUJtS8WQ4vI8tHcpm0MtAsGtrxsCnrQRQ9/J+MhgNPmTn YOIS/F8ghzk52/9oxZeRc2eIf1PfIUbIpTvy4S+GGlBk6dVRDP9p4hdawO5AQzTn y4tEju9iuDFOtj87EAu6OgnQnapzwsT5tMDSmORtrnOZpBMUItkIAykzAPfP7lZf HB2G0fRM4c/OpaFQOfo5TmAzYgduJxcplFeCPEwt86vJdLgDBNmi40XSA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeduvddgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtsfertddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeeuveduheeutdekvefgudevjeeufedvvdevhfejgfelgfdtkeevueegteek gfelfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Apr 2023 11:47:13 -0400 (EDT) Date: Tue, 25 Apr 2023 17:47:11 +0200 From: Maxime Ripard To: David Gow Cc: Benjamin Berg , Brendan Higgins , Shuah Khan , Rae Moar , Daniel Latypov , Stephen Boyd , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Sadiya Kazi Subject: Re: [PATCH v3 1/4] kunit: Always run cleanup from a test kthread Message-ID: References: <20230421040218.2156548-1-davidgow@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="t7kvs675m2vml6sl" Content-Disposition: inline In-Reply-To: <20230421040218.2156548-1-davidgow@google.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 --t7kvs675m2vml6sl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 21, 2023 at 12:02:15PM +0800, David Gow wrote: > KUnit tests run in a kthread, with the current->kunit_test pointer set > to the test's context. This allows the kunit_get_current_test() and > kunit_fail_current_test() macros to work. Normally, this pointer is > still valid during test shutdown (i.e., the suite->exit function, and > any resource cleanup). However, if the test has exited early (e.g., due > to a failed assertion), the cleanup is done in the parent KUnit thread, > which does not have an active context. >=20 > Instead, in the event test terminates early, run the test exit and > cleanup from a new 'cleanup' kthread, which sets current->kunit_test, > and better isolates the rest of KUnit from issues which arise in test > cleanup. >=20 > If a test cleanup function itself aborts (e.g., due to an assertion > failing), there will be no further attempts to clean up: an error will > be logged and the test failed. For example: > # example_simple_test: test aborted during cleanup. continuing without = cleaning up >=20 > This should also make it easier to get access to the KUnit context, > particularly from within resource cleanup functions, which may, for > example, need access to data in test->priv. >=20 > Signed-off-by: David Gow Thanks for doing this. I've tested it with an action that needs the test priv pointer, and it works as expected Reviewed-by: Maxime Ripard Tested-by: Maxime Ripard Thanks! Maxime --t7kvs675m2vml6sl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZEf1/wAKCRDj7w1vZxhR xXLCAP4+nmIiGMTkvl6NDkhzxZl5fYLgenEzcCQXyW3kF3QnsAEAuERclbus30rc 1i5UTw/t/svBmP/hBwxq2PVNT96RwQU= =VQOD -----END PGP SIGNATURE----- --t7kvs675m2vml6sl--