Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4029307pxb; Wed, 13 Oct 2021 18:57:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/7iJOwopSJyaRn6ml7/SlALqPZz6iWMRRbM+QSL3cpz80pDJ194hYbUY3v6zJwq1HbKUB X-Received: by 2002:a17:90a:352:: with SMTP id 18mr3216186pjf.116.1634176643433; Wed, 13 Oct 2021 18:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634176643; cv=none; d=google.com; s=arc-20160816; b=fzu7hXH9d99H8Y+qCJKLp/oWulb5c596dINVyqN3CdZCU9AzDxyAHV6pPZ4w0zJ1Kh wFqqfUDwfU4xom1aRsPbnUBkiMHFm4r0TUqJRqpPGZ8E5PsczFHvu3BScqIpW6ODA+QG /FpmD5efQ8JPcFhvm/vL3mK1I+YzEncV8O0TupBHTGg4Lll2R6hxEoE7LjiOjBc4Rd1I 5heAVS9kh10J6IT7TTHL/T0nuhkTuoTSfDYSsxGxBuHvFMWq5zPZnzd4O0Vw40IdVg7t 1nU0xmGYCTCNeUclQhkJa9o7r0PaUF6UwNDWAzrNUo1MSGX7D61qzHnxkfZPVI2+cUHM I0Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=gj77jHExPF8JdhHlGPtXpBXayt9TX9KfFO9GYcnNc+s=; b=sguq4Pkfd7kQxe/46hpeuJYVWfkxZOSIuFmKSkgCSGf/i8wHVcAdYhzxeI8PsEFoQI fh/I7eJ+xLSsUzRRNteYyl1rG8hZNqA+PH2TA3Vg48BUd/80X3uCY4yPuGad9Roz4dX8 WO2U/gWYuvD5dkKmHTUXR9dLRAOjvRcQT3JDmwOeyJByl1bXwNOQTm92ccw0zYyQDCa4 4Fl39XfCbFZkomxE4CbmH6ZosSaRsO3PM/Alq2JyGBLiCMu/T2gdsAi7zPQt8ZN5RmxI FnVLV8IqSmiaHElDbf/Lffxmr37DcJQjf2LWBQ0RGknN3BMZ64MsNRMORVljFMks6ihX /MMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q123si1616192pgq.566.2021.10.13.18.57.01; Wed, 13 Oct 2021 18:57:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbhJNB5Q (ORCPT + 99 others); Wed, 13 Oct 2021 21:57:16 -0400 Received: from pi.codeconstruct.com.au ([203.29.241.158]:38528 "EHLO codeconstruct.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbhJNB5P (ORCPT ); Wed, 13 Oct 2021 21:57:15 -0400 Received: from [172.16.66.209] (unknown [49.255.141.98]) by mail.codeconstruct.com.au (Postfix) with ESMTPSA id 8B8072012D; Thu, 14 Oct 2021 09:55:08 +0800 (AWST) Message-ID: <0f85025124359304c8a2a97d007b66d5655645c1.camel@codeconstruct.com.au> Subject: Re: [RFC PATCH] kunit: flatten kunit_suite*** to kunit_suite** in executor From: Jeremy Kerr To: Daniel Latypov , Brendan Higgins Cc: davidgow@google.com, linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org Date: Thu, 14 Oct 2021 09:55:07 +0800 In-Reply-To: References: <20211013191320.2490913-1-dlatypov@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, > > I like it! This seems to make a lot of logic simpler (and from the > > sounds makes Jeremy's proposed module patch easier?). > > This would make the subsequent cleanup easier. > > Jemery, correct me if I misread, but it sounded like you were thinking > of leaving the current kunit_suite*** layout until afterwards. Then > we'd flatten it as a cleanup. Yep, that was my rough plan. From the current situation: An object (module or built-in) defines a: kunit_test_suite(my_suite) [or, equivalently, a kunit_test_suites(&my_suite). The only place that I can see where we add more than one suite through kunit_test_suites is the kunit code, so let's ignore that for now..] That expands to: static struct kunit_suite *unique_array[] = { &my_suite, NULL }; static struct kunit_suite **unique_suites __used __section(".kunit_test_suites") = unique_array; [assume actual unique values for unique_array & unique_suites] So the .kunit_test_suites section content ends up being: an array of pointers to (null-terminated) arrays of pointers to struct kunit_suite. But those latter arrays only have one entry anyway. Once we're reading the suites out of the section, we have the section size too, so can determine the number of "things" (suites/arrays-of-suites/whatever) from that. So, given we only have one entry in the array, we can probably drop the null-termination, and expand the kunit_test_suite() macro to: kunit_test_suite(my_suite) -> static struct kunit_suite *unique_array[] = { &my_suite }; kunit_test_suites_for_module(unique_array); static struct kunit_suite **unique_suites __used __section(".kunit_test_suites") = unique_array; Then, the array becomes pretty pointless, so we can reduce that to: kunit_test_suite(my_suite) -> static struct kunit_suite *unique_array = &my_suite; kunit_test_suites_for_module(unique_array); static struct kunit_suite *unique_suites __used __section(".kunit_test_suites") = unique_array; But then there's no need for the double pointers, so we could just do: kunit_test_suite(my_suite) -> static struct kunit_suite *unique_suite __used __section(".kunit_test_suites") = &my_suite; Resulting in the .kunit_test_suites section just being a set of contiguous pointers to struct kunit_suite. We get the number of suites from the section size. [We could go one step further and put the suites themselves in .kunit_test_suites, rather than the pointers. However, the downside there is that we'd need macros for the suite declarations, which isn't as clean] Modules with multiple suites (currently: kunit itself) can just have multiple occurrences of kunit_test_suite(), as they no longer conflict, and we'd no longer need kunit_test_suites() at all. That was my thinking, anyway. I think it probably makes sense to do that cleanup after the section patch, as that means we don't need any post-processing on the suites arrays. Cheers, Jeremy