Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp274188qtg; Fri, 31 Mar 2023 01:09:53 -0700 (PDT) X-Google-Smtp-Source: AKy350agLU7Tzr53Tyo9iicoQcYDe2UzUEz+l9XBDSMk3If9WHbWZjWhmDDNuMolzmdrGsIWaTlZ X-Received: by 2002:a17:906:49:b0:930:aa02:f9cf with SMTP id 9-20020a170906004900b00930aa02f9cfmr4358562ejg.2.1680250193539; Fri, 31 Mar 2023 01:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680250193; cv=none; d=google.com; s=arc-20160816; b=jxRWP79trpmNxYdBEV4l66pHkYI0YPns4P3j+xaLL8uTnbRU3PhJldzfgYEjp9uuoX BpYWjYHFRzTvHLIM3AF017Q9M+gzqllzTco9vilzg7HM49EAgCjVbBQoBSdVE14Uv6qk +CuOs8VmKz+KYLpdjR82kGSD8T8SrTM1uKUI/OGbTjptzMX6GJSkDn/2wL5CtX4l7h9S lM3ru/Ir2Uo4wpnshZ660SHiROOGNJDflbvOqjiDbgl7ZwnmUdqtORyou9Uy06AMWPkN bMWPipkeC3m9i/b+T0qQR6ydPuX2+mW5XPaEJrJV1uz6hy8w3cGp5UnQX2YmpYv2rogC edLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=al17D1L4XTbs4pYJ8zF9ZEmB1iUe7QZQUslg7cjDk8k=; b=PnONot9EQdNRFijUGpB6EI5+alKoMWguNvClu38J3UK01OoYeQ7a/bBGN9R93tF2/A Fak5L7B6zGTYEmXh7lVrFlfoV4zFqDVId5gA22glR0iZrT2D16Z5TwVi3DSV7hnXi+ir TuLGT07svd6qNdouqsRXvUOrCNp7DL5pFONnGycbQcaRk/2gCZWht1UQHpGYNyyCxxCf p/3WAkAMvlnkDxQNP7rxxDETLhVGv9w9dVQInQuFP9s5O6WQfsTZFiO9PA/mxKSWrDXM 3VBHlngBpm8zkjF3NANwmgAhNKec2B/mznusu3wL/yrufyrcn3rmHhw+FI2CnwWk4C4j qTgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=NN5rllUn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bl10-20020a170906c24a00b0093429d37a34si1275337ejb.272.2023.03.31.01.09.28; Fri, 31 Mar 2023 01:09:53 -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=@google.com header.s=20210112 header.b=NN5rllUn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231300AbjCaIE2 (ORCPT + 99 others); Fri, 31 Mar 2023 04:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbjCaIE0 (ORCPT ); Fri, 31 Mar 2023 04:04:26 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B0A11720 for ; Fri, 31 Mar 2023 01:04:24 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-544781e30easo210630547b3.1 for ; Fri, 31 Mar 2023 01:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680249863; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=al17D1L4XTbs4pYJ8zF9ZEmB1iUe7QZQUslg7cjDk8k=; b=NN5rllUn7z5cAukKAQhp1rwdUXUdXZCk6Agwukpukqrju6mzhYQD89E0c0Z5tmy59G 8Vs1PvmVRMYA+fl3fDiKvm6z9SobcVYWtJaIxBneiAHptry7HDItaF0wiobXVPAvvQk6 /ggYZ7qPZGfiN2lWSJx6uF21Q1Qr+t396NThNAZvx/KVgm3+o/AFnvmghY+4mX+aDi39 ER8ElTBFLcYwMmwX0VfE4kWGeoc9Vd3tS6vWCh01voFFWuugYoN2HpKYoYxcEkm2yWvV UdXlm4UNrhb/QrcsuCJmI2gFkx74A6PsTBly7tMU0tGIyWdNwnjdg3qfbTRG40ylN1Ri YbGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680249863; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=al17D1L4XTbs4pYJ8zF9ZEmB1iUe7QZQUslg7cjDk8k=; b=5/Jv/EsJVsbnBTs/lhmIwirMj6lihwxgHHomYakjLlDt8rUZltGOY2GyEQOM1bo+3j LlqmSWEkrqzVNh5KwD0JRHFGGtvi3jJTdrIVwH3bdoIiI+mKbj3/eOsV81V1FRdXtlmc EGum6xOGC73kqsx6I9xY+mzsrSBdidgOUXgEl/bFgIJkcbQ5FgpfjPgkdkQbDvAf13NT cvDz4Cmqomi5cSityK15CtNqXtUR2rUKQznZEFazwBVL0ApY55DFtG/MMXPlVyKl5VBD 1yQXElcGQjtB9uMpUzZHrD+nqMYjSehvyxDaAnUjFggFRp8yqfGnx7Hsfzo2nVGZMrgz APwQ== X-Gm-Message-State: AAQBX9e6OCCuIT8ZFyJ6WicQKMGbZzhh6EboTVz6rjh/1BsAliL0lm5/ vHm6rUfYBH2g8umoDzQq0nM4xCp1eX5aSg== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a81:b349:0:b0:544:b7ff:b0df with SMTP id r70-20020a81b349000000b00544b7ffb0dfmr13295561ywh.2.1680249863505; Fri, 31 Mar 2023 01:04:23 -0700 (PDT) Date: Fri, 31 Mar 2023 16:04:08 +0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230331080411.981038-1-davidgow@google.com> Subject: [RFC PATCH v2 0/3] kunit: Deferred action helpers From: David Gow To: Matti Vaittinen , Maxime Ripard , Brendan Higgins , Stephen Boyd , Shuah Khan , Daniel Latypov , Rae Moar , Benjamin Berg Cc: David Gow , Greg Kroah-Hartman , "Rafael J . Wysocki" , Heikki Krogerus , Jonathan Cameron , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 This is a follow-up to the kunit_defer() parts of 'KUnit device API proposal'[1], with a number of changes suggested by Matti Vaittinen, Maxime Ripard and Benjamin Berg. Most notably, kunit_defer() has been renamed to kunit_add_action(), in order to match the equivalent devres API[2]. Likewise: kunit_defer_cancel() has become kunit_remove_action(), and kunit_defer_trigger() has become kunit_release_action(). The _token() versions of these APIs remain, for the moment, even though they're a bit more awkward and less useful, as they have two advantages: 1. They're faster, as the action doesn't need to be looked up. 2. They provide more flexibility in the ordering of actions in cases where several identical actions are interleaved with other, different actions. Similarly, the internal_gfp argument remains for now, as this is useful in implementing kunit_kalloc() and similar. The implementation now uses a single allocation for both the kunit_resource and the kunit_action_ctx (previously kunit_defer_ctx). The 'cancellation token' is now of type 'struct kunit_action_ctx', instead of void*. Tests have been added to the kunit-resource-test suite which exercise this functionality. Similarly, the kunit executor tests and kunit allocation functions have been updated to make use of this API. I'd love to hear any further thoughts! Cheers, -- David [1]: https://lore.kernel.org/linux-kselftest/20230325043104.3761770-1-davidgow@google.com/ [2]: https://docs.kernel.org/driver-api/basics.html#c.devm_add_action David Gow (3): kunit: Add kunit_add_action() to defer a call until test exit kunit: executor_test: Use kunit_add_action() kunit: kmalloc_array: Use kunit_add_action() include/kunit/resource.h | 89 +++++++++++++++++++++++++++ lib/kunit/executor_test.c | 12 ++-- lib/kunit/kunit-test.c | 123 +++++++++++++++++++++++++++++++++++++- lib/kunit/resource.c | 99 ++++++++++++++++++++++++++++++ lib/kunit/test.c | 48 +++------------ 5 files changed, 323 insertions(+), 48 deletions(-) -- 2.40.0.348.gf938b09366-goog