Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5527886rwr; Mon, 24 Apr 2023 05:43:18 -0700 (PDT) X-Google-Smtp-Source: AKy350Yg1oYmhtvsXuZvRQjUGJ527SPB0enZbFDkluIu3zyjW9pCf61aRJz7oa7j5ctwwzp2U7VS X-Received: by 2002:a05:6a00:114f:b0:63d:2343:f9b with SMTP id b15-20020a056a00114f00b0063d23430f9bmr15919344pfm.19.1682340198393; Mon, 24 Apr 2023 05:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682340198; cv=none; d=google.com; s=arc-20160816; b=XAGhv81fqxGFmCrjbQWE9TgWHg1GQQlS1/w6ZcK5NPuffw7jyqSPR9MYgbBXfpbAK0 qyADq6lwRS9Ms1bWUaS69K3YN2bfppJWH84AZ/YyXiqiNyzekqQe+1ZfMzR5pvRUpSIl p2tWAPfMXYdmfh77xhV6pZTKnmoOtfKxPr+5SJ6k32X77uSM5bcDl7IpcNELahAzEt8q Ekt1pAT+Uq46VUKyV5Sxs1qUQ07lc0No9CXuIvo5s7ecWqVlFHK+1q0r4gKoThFkPQz+ EvlFAepQQfHYoUCgfgLZrMlybf4TqkV57MmBVpK+bF+Gz2W48ijJ+PE4DHjiAmmDr7z5 IxTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=+AKUr/16XMPYHadRWyJapkJc4/eIA0iPZIHyUWZAMxw=; b=fmiBWUhzs+iclf5cq9QR8lfpTKqpGXSHQIDzCKeKSgpFvSSP99Sgbu9hQODdIvOYJz QqWaj2B9kR1UtXy51eX2wmggQofedvG4MiyvqrWzi6kSPHQut83bxaiXpEp/gQ3uvbBP oq6ylpZ34l3DIlP35rTC8OsVovVdGqQxzmQgqAM0SXgV5+KBtgBROJJNyB+gLjVAK4jy DRehlgjE8BjE6wHAT27IKfAvr5QSZmcCdv788QV/CoXI+vXQBaogRzerpRcIR6pk2CtE dJdOrxJNBoYZ5VX3fI68rHJoEkkZumiDgb6bVX7SHfO8oZr2Dcu/XiRDQiADcYHp8Ic5 ASsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b="fo9wBJH/"; 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=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v24-20020a63f218000000b0051b313bdebesi8631220pgh.1.2023.04.24.05.43.04; Mon, 24 Apr 2023 05:43:18 -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=@sipsolutions.net header.s=mail header.b="fo9wBJH/"; 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=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231809AbjDXMcq (ORCPT + 99 others); Mon, 24 Apr 2023 08:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231366AbjDXMck (ORCPT ); Mon, 24 Apr 2023 08:32:40 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754B830C5; Mon, 24 Apr 2023 05:32:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=+AKUr/16XMPYHadRWyJapkJc4/eIA0iPZIHyUWZAMxw=; t=1682339556; x=1683549156; b=fo9wBJH/aRA46Ibx+Yn00VHxm+pn2ibQHFo60wRroMUtdKW nBhVwrRfAwJku6B3kbW5GBvuvoWhx9ayvm2UNMOzKiZc90INo9uNmvHTODnhdqk+G0EyIFtslnyIs 2EYuqQXk4oA6lUTxDFaS2JuwK+odEPayTVG8JxSKEiY6iX7nx52SB0M9DDFOcf4texQfoYsLdPvt8 6mzSkTykLjp3A5m5e1xZS2R94tUy6U8OaUZNu91sNSRdcQDvGtqntg9ILGBSxf6bGcyCmU0pX+RiS 9F+NH1VdPul95uTwHK9UkvQ9Ler4gh4K20+tmtYUF50x3AzUALA9vS03zk84r6VA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1pqvMg-007EaT-2q; Mon, 24 Apr 2023 14:32:19 +0200 Message-ID: <54b49d4ddf371d0581f3b795f50f7f6673557a96.camel@sipsolutions.net> Subject: Re: [PATCH v1 0/3] kunit: Deferred action helpers From: Benjamin Berg To: David Gow , Matti Vaittinen , Maxime Ripard , Brendan Higgins , Stephen Boyd , Shuah Khan , Daniel Latypov , Rae Moar Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , Heikki Krogerus , Jonathan Cameron , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Date: Mon, 24 Apr 2023 14:32:16 +0200 In-Reply-To: <20230421084226.2278282-1-davidgow@google.com> References: <20230421084226.2278282-1-davidgow@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-malware-bazaar: not-scanned X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 Fri, 2023-04-21 at 16:42 +0800, 'David Gow' via KUnit Development 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, > =C2=A0 and we can add it back if we need to. > - kunit_add_action() therefore now returns 0 on success, and an error > =C2=A0 otherwise (like devm_add_action()). Though you may wish to use: > - Added kunit_add_action_or_reset(), which will call the deferred > =C2=A0 function if an error occurs. (See devm_add_action_or_reset()). Thi= s > =C2=A0 also returns an error on failure, which can be asserted safely. > - Got rid of the function pointer typedef. Personally, I liked it, but > =C2=A0 it's more typedef-y than most kernel code. > - Got rid of the 'internal_gfp' argument: all internal state is now > =C2=A0 allocated with GFP_KERNEL. The main KUnit resource API can be used > =C2=A0 instead if this doesn't work for your use-case. >=20 > I'd love to hear any further thoughts! I am happy with it as-is. Reviewed-By: Benjamin Berg >=20 > Cheers, > -- David >=20 > [1]: https://docs.kernel.org/driver-api/basics.html#c.devm_add_action > [2]: https://patchwork.kernel.org/project/linux-kselftest/list/?series=3D= 735720 >=20 >=20 > David Gow (3): > =C2=A0 kunit: Add kunit_add_action() to defer a call until test exit > =C2=A0 kunit: executor_test: Use kunit_add_action() > =C2=A0 kunit: kmalloc_array: Use kunit_add_action() >=20 > =C2=A0include/kunit/resource.h=C2=A0 | 76 +++++++++++++++++++++++++++++++ > =C2=A0include/kunit/test.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 10 ++++- > =C2=A0lib/kunit/executor_test.c | 11 ++--- > =C2=A0lib/kunit/kunit-test.c=C2=A0=C2=A0=C2=A0 | 88 +++++++++++++++++++++= ++++++++++++++- > =C2=A0lib/kunit/resource.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 95 +++++++++++= ++++++++++++++++++++++++++++ > =C2=A0lib/kunit/test.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 | 48 ++++---------------- > =C2=A06 files changed, 279 insertions(+), 49 deletions(-) >=20 > --=20 > 2.40.0.634.g4ca3ef3211-goog >=20