Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7128047rwr; Tue, 25 Apr 2023 08:26:51 -0700 (PDT) X-Google-Smtp-Source: AKy350Z8VGeXUWwnSp5oBVo+EtykAIGskYr3gRDNCyvUDIMW6Vmm8EWKlOuFSxixPdtpdHFEqWSI X-Received: by 2002:a17:903:1249:b0:1a6:b140:9d2 with SMTP id u9-20020a170903124900b001a6b14009d2mr23089911plh.61.1682436410623; Tue, 25 Apr 2023 08:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682436410; cv=none; d=google.com; s=arc-20160816; b=ssehPKqOP/+ES/sc9lV53WbFHj9MjEw/5iHK3p98o4hocdYx7TbCeFlMfVx/ikFEAD zhbcgNoHQBBGLb9heZrW4dvkSSN7lk8XOMgfgbZkQOsuDH4n+qvEXxTQXKQgnI2aUQJ8 8hzp9V8KIat2oWH3mYzZi/Bk8cccw4ehp2XyE2kgJcjrdLAQN+rr47ctKQkiZVpyeGcf rGpErQu6sAEX1STp5V/MeKdkwitz51Nj3UNYZHGE6d0JHreOCDjR+XQF5C76OnxgkQ7w 3nT/+376eDjqTEN6UD6EsWk41zfMDEZ/axB5p9Y72EN+PxfiG3gl6LCMtr5AqJ79YdBy iCrw== 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=ie+kwy29np8Lu3Cx0FWF+CbrsbBORKaPAuFe21CfxZE=; b=KdetS9m/m149Dit0VMFS4Ggz3Abh3q+MJUhsLApLR+pPv963UBYks/l3yRg1ItGfjp pnAZvcvbZaJhq/aeQy8exdesV+N8YC7iY8apHTYKH5vCnjSBOssSqtCQB8vsf1FEtNZf ydkmtOLEbY2GcRIwEqDt5bHejYVAnV/2/uLy99UPDtsbju0rol87u5BWDTzgWxbXgTa/ jM3z0KklzXEkYNsANh6lpCFDspWZzRd4vhiZG6IKsw9cMxkFB1QiJ0z0Rw1Zg7Z4xLuR ZtqM9xb+5VE5mH71qouWCcjZMJ+RH+h5K7llzpfmVhFuAJgtWXm7WppCN4tMHh2X2Ps7 PL/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b="EXp/Q8bH"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=CrSQOm6J; 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 i13-20020a170902c94d00b001a64fba3382si14782868pla.148.2023.04.25.08.26.36; Tue, 25 Apr 2023 08:26:50 -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="EXp/Q8bH"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=CrSQOm6J; 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 S234436AbjDYPYC (ORCPT + 99 others); Tue, 25 Apr 2023 11:24:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234186AbjDYPYA (ORCPT ); Tue, 25 Apr 2023 11:24:00 -0400 Received: from wnew2-smtp.messagingengine.com (wnew2-smtp.messagingengine.com [64.147.123.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8483CA5F5; Tue, 25 Apr 2023 08:23:59 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id CF8232B061E1; Tue, 25 Apr 2023 11:23:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 25 Apr 2023 11:23:57 -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=1682436234; x=1682443434; bh=ie +kwy29np8Lu3Cx0FWF+CbrsbBORKaPAuFe21CfxZE=; b=EXp/Q8bHo7P+3qC8bM 5VDVYZBe4ELBbbCfMb5+4wNueWe1iYMU6aaW3CIxrwpcXqUUhd7hghKxZ09CuhK/ QMnIkfEtrwqN1586XPmr0SvjG7Rc2/DjKSXd8I8AHdLsJyjc/3mwLt4itQD8dpK8 FH+iz9zymDZhVC+Fl6/0p4Y/31F5cV9czUxZdOtwLq7UOxC3ahhFtzOmY2uocxXO QiS6rGUHxlqcKUptdmmBfhPv+P5n4LF6SgiCQXKGq671tcTf7DEm+SyUMsiHBT2q fUJGosGOFwEGKavCaNG1s9NsS4/uyrcEJbo0k0gMr+6Xl7PcHD7aq4D/HZSB8c4P K6mA== 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=1682436234; x=1682443434; bh=ie+kwy29np8Lu 3Cx0FWF+CbrsbBORKaPAuFe21CfxZE=; b=CrSQOm6Jg028X3LsVqROL4eT6pydQ WT375bIrqh4Lng37wujwE0K6P9iL2P+OA5UDOFJnk0qfxJ6vHHkCTHUqK6vKwdGT HHaNR5mlsFC2qphfD5pMFWs7ChQaa0zARDN71PbKnkMjnz3hyrGqhFJBiq6SYFq7 dQpiehkZl7CqfIZ+5Xp44BpEPYkFRXI+iqFebGM/TXBpvsX0mCvoYGLmRTMcONbQ 9CILIrb56MwAZzf1zpJD5oYG33QsqNKF0+HDPQXQrQwY+9Cugzjgs11P2MBiAGGO G+YkIebivQBBd1iwBzbHznh+70D+0yAVVmmv9qGWZ1RwyUm4Kfs+9WOfA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeduvddgkeejucetufdoteggodetrfdotf 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:23:52 -0400 (EDT) Date: Tue, 25 Apr 2023 17:23:50 +0200 From: Maxime Ripard To: David Gow Cc: Matti Vaittinen , Brendan Higgins , Stephen Boyd , Shuah Khan , Daniel Latypov , Rae Moar , Benjamin Berg , Greg Kroah-Hartman , "Rafael J . Wysocki" , Heikki Krogerus , Jonathan Cameron , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Subject: Re: [PATCH v1 0/3] kunit: Deferred action helpers Message-ID: References: <20230421084226.2278282-1-davidgow@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rb5lfax26rs5huyx" Content-Disposition: inline In-Reply-To: <20230421084226.2278282-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 --rb5lfax26rs5huyx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Fri, Apr 21, 2023 at 04:42:23PM +0800, David Gow wrote: > This is v1 of the KUnit deferred actions API, which implements an > equivalent of devm_add_action[1] on top of KUnit managed resources. This > provides a simple way of scheduling a function to run when the test > terminates (whether successfully, or with an error). It's therefore very > useful for freeing resources, or otherwise cleaning up. >=20 > The notable changes since RFCv2[2] are: > - Got rid of the 'cancellation token' concept. It was overcomplicated, > and we can add it back if we need to. > - kunit_add_action() therefore now returns 0 on success, and an error > otherwise (like devm_add_action()). Though you may wish to use: > - Added kunit_add_action_or_reset(), which will call the deferred > function if an error occurs. (See devm_add_action_or_reset()). This > also returns an error on failure, which can be asserted safely. > - Got rid of the function pointer typedef. Personally, I liked it, but > it's more typedef-y than most kernel code. > - Got rid of the 'internal_gfp' argument: all internal state is now > allocated with GFP_KERNEL. The main KUnit resource API can be used > instead if this doesn't work for your use-case. >=20 > I'd love to hear any further thoughts! I've converted the KMS kunit tests to use that API when relevant, and it works like a charm and is super usable, thanks so much. One improvement we could do as a second step is to provide a kunit_action_t type or something to make casting kfree-like functions easier, but it's already great overall. Reviewed-by: Maxime Ripard Tested-by: Maxime Ripard Thanks again, Maxime --rb5lfax26rs5huyx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZEfwhgAKCRDj7w1vZxhR xcAtAP4prqqqC77VuBSmZ2OPTWVaV2lVYsHKC9qTunwwWG+JxgEA8xbRD6OKfxOH ctUpY5UfYbzXWLDYjOBC+h0ylhFx1Ac= =uD/b -----END PGP SIGNATURE----- --rb5lfax26rs5huyx--