Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4705846imw; Tue, 19 Jul 2022 11:36:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v8DutnuSWBXrvHcCD0ytJrXsxjyHRMJGeIiGBO+HYyqpCCsw8qzdDJdfgFOeXE4X77+III X-Received: by 2002:a17:906:58c7:b0:722:f4bf:cb75 with SMTP id e7-20020a17090658c700b00722f4bfcb75mr32428034ejs.450.1658255780933; Tue, 19 Jul 2022 11:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658255780; cv=none; d=google.com; s=arc-20160816; b=WI1sohHVFTtfvG9VvQGWhNptNMtWc7SuNFBIWk1CUcGW4KSi+CB8HL4wFSqBYewicJ EhcWMVxBpVxkNL9937AW/hPb7R4m6enh2Ozv81aMzCw/KUjIlTvfqX5TqL07lofkjP6f N3ruuLy3toNRL9Ri3bQVXy/I5nAYh0lNP0k2c9E2G+27tD78OscvA/JjME5r3nHtT5/o zMfoM1Q+sReQQx9V4l6FdIEHDtuLja/5QK3JqzTBIwQpqWKvoV2MxnCX5K7qqYyHkdri hcIKXEMQfkBo6+48pTZ9lJuek7rThNaK240JuFMN3kS7JPXuZAUvVBXwUKHAdue5KSNL gbxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=V0qiTrhKb5cDn7xIAf2JVpihXBS1asZkPJ9Pieu4GWQ=; b=EbhXDQqfhnKc9riOMdMwSvGIVg2T6/LBW1lZCk3PVVec8zf6aR7CqLcFGoxvENT4MA VlY/6QbMIlF5PLabf2R9VFFRBwz0JXUb9S8uPq0wpamYBcibKXH1Y6RBtu81A1Qxxn4/ Hou/D+1c2PuMGIHuvq/+KjLXIiI8M/C0Z12c4bLhtasAw+9+3mNPck7/4uSjyH6E6v0L TZw7d/dxgSPomRhf3eqtA6gaqlcPU/Lg/HJo+TrUW1qXDakQUCjS/wnXI6smgmEdV/py 1Bc++pAedUuZVzWtJ4M9ZvgOlZbsMMRoyITbSEhDwEBRCgs7r9fAu0Z92uM63WSrZK/H bEdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=TLdQhm87; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a056402274500b0043a7077519dsi22864366edd.430.2022.07.19.11.35.56; Tue, 19 Jul 2022 11:36:20 -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=@infradead.org header.s=bombadil.20210309 header.b=TLdQhm87; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbiGSR6w (ORCPT + 99 others); Tue, 19 Jul 2022 13:58:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239615AbiGSR6u (ORCPT ); Tue, 19 Jul 2022 13:58:50 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47EE14D163; Tue, 19 Jul 2022 10:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=V0qiTrhKb5cDn7xIAf2JVpihXBS1asZkPJ9Pieu4GWQ=; b=TLdQhm87tVe/Km85VW344stqSW sGnhygUmoZeMCvY+KgA6lZ97rKTdlG4gdJ0pxREFFi5A+679pJNM3qKHlmlIH58qU2zL5bJyGs76V xw8+/fSGkRuqWq/8jpRptkA2FekKdawjW2AjvqNVN6wUhZXsEMatGmKeecDXx9Efww4Jbf+c6CXhh TTui8HWbn63uFSFS9R/3QEAaeEAcu3QZaIE7Je5Gsh6lRahE5QrdW2lEYbkK5oBCndywlf0SMMJ9+ tQNUgEZo+vsiFwQ5SkTogBj5c7u8UaV/rfzaOW8/04ix8bTyftX45GC5s/n60llqQrZogkF99fhpi ur5rOExA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDrUb-00B2xA-Ge; Tue, 19 Jul 2022 17:58:45 +0000 Date: Tue, 19 Jul 2022 10:58:45 -0700 From: Luis Chamberlain To: Daniel Latypov Cc: David Gow , Brendan Higgins , Shuah Khan , Jeremy Kerr , linux-modules@vger.kernel.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH] module: kunit: Load .kunit_test_suites section when CONFIG_KUNIT=m Message-ID: References: <20220713005221.1926290-1-davidgow@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE 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 Wed, Jul 13, 2022 at 08:24:32AM -0700, Daniel Latypov wrote: > On Tue, Jul 12, 2022 at 5:52 PM David Gow wrote: > > > > The new KUnit module handling has KUnit test suites listed in a > > .kunit_test_suites section of each module. This should be loaded when > > the module is, but at the moment this only happens if KUnit is built-in. > > > > Also load this when KUnit is enabled as a module: it'll not be usable > > unless KUnit is loaded, but such modules are likely to depend on KUnit > > anyway, so it's unlikely to ever be loaded needlessly. > > This seems reasonable to me. > > Question: what happens in this case? > 1. insmod > 2. insmod kunit > 3. rmmod > > I think on 3, we'll call the cleanup code, __kunit_test_suites_exit(), > for , I think? > But we never called __kunit_test_suites_init(). > My fear is what breaks as a result of this precondition break. > > E.g. In the case that CONFIG_KUNIT_DEBUGFS is enabled, this includes a > call to kunit_debugfs_destroy_suite() with no previous call to > kunit_debugfs_create_suite(). > That will include a call to debugfs_remove_recursive(suite->debugfs), > where suite->debugfs is an uninitialized pointer. > > Maybe we can treat it as "undefined behavior" for now and proceed with > this patch. > > In terms of long-term fixes, perhaps insmod kunit could trigger it to > 1. run all built-in tests (IIUC, it doesn't right now) > 2. run all the tests of currently loaded modules > 3. track which modules already ran so if you rmmod + insmod kunit > again, it won't rerun tests? Let's please address these considerations. Luis