From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33ACBC4332F for ; Tue, 22 Nov 2022 01:31:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7159B6B0071; Mon, 21 Nov 2022 20:31:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 69E206B0073; Mon, 21 Nov 2022 20:31:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53EA76B0074; Mon, 21 Nov 2022 20:31:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 402C96B0071 for ; Mon, 21 Nov 2022 20:31:16 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1819C1A0F11 for ; Tue, 22 Nov 2022 01:31:16 +0000 (UTC) X-FDA: 80159350152.23.E109553 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by imf03.hostedemail.com (Postfix) with ESMTP id B25E72000E for ; Tue, 22 Nov 2022 01:31:15 +0000 (UTC) Received: by mail-yb1-f172.google.com with SMTP id c15so15665445ybf.1 for ; Mon, 21 Nov 2022 17:31:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=IYRjBqU3ZoHV4i/knmVPjtRYVyj2wBtBdprE9kY1bXY=; b=g5eszoEulUfrD1WqxBnLIM3gUgku3IJD6GBT91ItK1iQ3CxkGoNjn4a2GWvTpmdSFi lVPxF9/dWFtr1nFuFXhSuZJw4FsGD+qKgco89uA/o5CL0rOWhS6iLjHimnSuvw+Zbr3M hd9XngwctwS8u8UKW5cxJm3NuK1i1QaV6Ff5SoqsmPl2knL0bPLiF4P3bruDRLe+ZoBX L/9ygwEcgsHydEymZYpk6EmBs2aPgOYUl33sXvPNl77s93ZF6cTkx57vBtmi9Z2wHKdN 2iT20/pBA0ALqF1gCn54EBl5r80A+JsvDMLC+Y4DhkhDE/AKhjh2aazXYzDejfWdkeCy JNew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IYRjBqU3ZoHV4i/knmVPjtRYVyj2wBtBdprE9kY1bXY=; b=iVMKPERqsqWAROv8v6MzyDRvHGMYBARH8D2wcmB1zpa7lIKATgXOHiRQsyHyFV48YU +VI2rZjfprLhJ38Av3Gu4fE8KZknscZxUQUPNqxStEK556sdQ8PESr1TaACaqxUQzACd ssRKyUaAKcW326hxqodP/IRBGJPrBytVLbq3LST5RDyZykUZeIapK0vqfI47LUZ8j8mA HjYUI5ht52DG2n4KtztiiE+W95ujzf5zRyQTDuNxPBTloKm7wQB0ncn5h/oORpT1pXB6 mCwGkNav0JZNwPZ4mGeozt0YJNJbVGYG+KgdLq3jcoJ2BeN+7ig7Ky5FDVtLMg4aYeZW eCdA== X-Gm-Message-State: ANoB5plj3bxkWIMaq3l6H8DOY9Ujoi2zdZKGLPO5VUjPZLsZkXsB2z4X ndzwlsUuC0tOpXzjVfhB5sB57Tmx+Xpo5AmC2y2MoQ== X-Google-Smtp-Source: AA0mqf4BKdfRzMVGdYVC78GLj287VlFFPylImBY9mMzZlCVRzwhU/woID2KDtu9GDCYShjObFVE7+ndAAu8aVAdZGaQ= X-Received: by 2002:a25:d2cf:0:b0:6cf:e761:43e1 with SMTP id j198-20020a25d2cf000000b006cfe76143e1mr20115372ybg.650.1669080674817; Mon, 21 Nov 2022 17:31:14 -0800 (PST) MIME-Version: 1.0 References: <20221119081252.3864249-1-davidgow@google.com> In-Reply-To: <20221119081252.3864249-1-davidgow@google.com> From: Daniel Latypov Date: Mon, 21 Nov 2022 17:31:03 -0800 Message-ID: Subject: Re: [PATCH v3 1/3] kunit: Provide a static key to check if KUnit is actively running tests To: David Gow Cc: Brendan Higgins , Shuah Khan , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , linux-doc@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669080675; a=rsa-sha256; cv=none; b=figHc88Qek8t/oiuh7gOmTRG5mCDt2903TAoyipjLZIDjOZ9UGHafACz4Z9hS7DqKZPmZg YOoDf7T76Ram6TJop0K3LvU9ty9XK/tnv5KQzvOC1UYTdwXEciq7mpeEWXURoSfW/kVV7m CkrJUzXX5ZYBlkFaehpTslIIMqGG9lM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=g5eszoEu; spf=pass (imf03.hostedemail.com: domain of dlatypov@google.com designates 209.85.219.172 as permitted sender) smtp.mailfrom=dlatypov@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669080675; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IYRjBqU3ZoHV4i/knmVPjtRYVyj2wBtBdprE9kY1bXY=; b=0/cfododI2dB40ESs+8kOrAVMdor4h25tgb4Pq2M39ujhLtfjU7GvqPWPli3lzd/8Kw+Kk q5FCm8wxVHczmknXpjcp9o9Q+Ikh2yrqzWbw8vuJ5Em+qf8vadWW9347Q0PPdEZZTLLiv3 LCp7wwwtQvYt959oGfIF522HQbKqWss= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B25E72000E Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=g5eszoEu; spf=pass (imf03.hostedemail.com: domain of dlatypov@google.com designates 209.85.219.172 as permitted sender) smtp.mailfrom=dlatypov@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Stat-Signature: zqoc131piq973ikcroh9y3suerqh1mdf X-HE-Tag: 1669080675-378157 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001714, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Nov 19, 2022 at 12:13 AM David Gow wrote: > > KUnit does a few expensive things when enabled. This hasn't been a > problem because KUnit was only enabled on test kernels, but with a few > people enabling (but not _using_) KUnit on production systems, we need a > runtime way of handling this. > > Provide a 'kunit_running' static key (defaulting to false), which allows > us to hide any KUnit code behind a static branch. This should reduce the > performance impact (on other code) of having KUnit enabled to a single > NOP when no tests are running. > > Note that, while it looks unintuitive, tests always run entirely within > __kunit_test_suites_init(), so it's safe to decrement the static key at > the end of this function, rather than in __kunit_test_suites_exit(), > which is only there to clean up results in debugfs. > > Signed-off-by: David Gow Reviewed-by: Daniel Latypov I didn't know anything about the static key support in the kernel before this patch. But from what I read and saw of other uses, this looks good to me. One small question/nit about how we declare the key below. > +/* Static key: true if any KUnit tests are currently running */ > +extern struct static_key_false kunit_running; Is there any documented preference between this and DECLARE_STATIC_KEY_FALSE(kunit_running); ? I see 89 instances of this macro and 45 of `extern struct static_key_false`. So I'd vote for the macro since it seems like the newer approach and more common. Daniel