From patchwork Tue Oct 25 07:19:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 13018613 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 D8DBDC04A95 for ; Tue, 25 Oct 2022 07:19:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FE428000A; Tue, 25 Oct 2022 03:19:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AE9680007; Tue, 25 Oct 2022 03:19:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 576758000A; Tue, 25 Oct 2022 03:19:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4157980007 for ; Tue, 25 Oct 2022 03:19:32 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 01530160D21 for ; Tue, 25 Oct 2022 07:19:31 +0000 (UTC) X-FDA: 80058621384.03.F794D9A Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf14.hostedemail.com (Postfix) with ESMTP id B2F41100031 for ; Tue, 25 Oct 2022 07:19:30 +0000 (UTC) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-36ab1ae386bso80357787b3.16 for ; Tue, 25 Oct 2022 00:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=KA5AmQjfCAbtpdHkGDjwVts9T7CuDkkry+0zPgKF0lM=; b=ho9NvHEqLfDplAjRx3uXKJiU3DoSROQtKqQ8jRhFd0Ck3bp2UOpw8N9lYdxjatKuYv co/P5Nk6CLcK/+U9EK4lL66rumOXMbWTwndY1+zqeBCGNIjWtMZexvP1r8fzZLGhIbkU URsp7CuLP4czyMYdx7nshdoj5wFvyKDgBctnpRho0U/7PipKMJWU+msjlZHwvoClSw6O EvgkK+rfUfDrf/fynysJgKuFNt/SnjNJ/7x0wc8t7u3GvmcbGHIzDOGamTDQO4RMxpdU hh8nQ1fXv3LVNN0nD4AItp5Or8XNWSODER0ITRmk2Az9YLODBHDSLXNZo3mhj/LYKCQs eyxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KA5AmQjfCAbtpdHkGDjwVts9T7CuDkkry+0zPgKF0lM=; b=wnKD4O4HZ3etI37iVB6KyTnH7VUK+K2ZIQjGJNxXo9SblnxKCsyS69iZgrkpWm4/A7 5I44ROpO3RIzWV753+sshnm/DJINbZHE19TZQm88H4wLSeuEG+dXx5+OeWR3uMGjzkKT enubRoSa3p/HF3fzRUxfZXnbWF82eEaPLOm/bFMR/dCx0Z56E2mGsUQp8j18SyowqIsz /f3w8NtgjLGRv3NxSb+ToUAtSjJ0gMcipRq960bPP0JjCNKVUwGpr3YWZTOhrHa/NNsl Ngyc0Z29BGFEJye7Q5v34MfOYkcOdIWSrrVExcURDz0BCRk7Iudrh3ZnNRJrlqDbognr BqoA== X-Gm-Message-State: ACrzQf2I1DRprFfApoYYkG1vZNfljul7KKDpk/xC6RpcekF7m7Re8gzb t27SR+0i3O00HrP4J1kVtZwXfNd0dHAi1g== X-Google-Smtp-Source: AMsMyM6F8n0cf6ZN6EOjJAyPYC15rg0ifDjy+Yi3k90H65/ao6P/DBifaGO+L8XRdtun64inb2rPoXzES3FOCQ== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a81:6907:0:b0:34a:51ce:3b38 with SMTP id e7-20020a816907000000b0034a51ce3b38mr32787158ywc.151.1666682369948; Tue, 25 Oct 2022 00:19:29 -0700 (PDT) Date: Tue, 25 Oct 2022 15:19:07 +0800 In-Reply-To: <20221025071907.1251820-1-davidgow@google.com> Mime-Version: 1.0 References: <20221025071907.1251820-1-davidgow@google.com> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog Message-ID: <20221025071907.1251820-3-davidgow@google.com> Subject: [PATCH v2 3/3] mm: slub: test: Use the kunit_get_current_test() function From: David Gow To: Brendan Higgins , Daniel Latypov , Shuah Khan Cc: David Gow , 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, Oliver Glitta , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Christoph Lameter , Vlastimil Babka , David Rientjes , Andrew Morton ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666682370; 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=KA5AmQjfCAbtpdHkGDjwVts9T7CuDkkry+0zPgKF0lM=; b=Wi3Q+82ujBfix/pHlvHqLxQGGZcv5YksZGDRVLRZY8zopiKbwFbVQ5uj0TpPsC4MaAyTJN gcjkRXvWCadkuS1xZriMrjWmcb5k29PbIeEvtbTHQfuXnBE4feDKebYODGQUgoPc+xAVhV 80xjpCtVaoHctPZtHDA3MiJknjVa+z0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ho9NvHEq; spf=pass (imf14.hostedemail.com: domain of 3AY5XYwgKCJw96RE9CKSCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--davidgow.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3AY5XYwgKCJw96RE9CKSCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--davidgow.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666682370; a=rsa-sha256; cv=none; b=C4CKqiQ5AXAQOlSFyGcSJlIsK54vRkC9KYf1YJBDTuPKFtwAJJJuDhtbrqQ2byQLYwzS1+ cktwqWsQVI9uslm5KuSDLy96Ack40SPH7/JRFD1N8yCpx35IrfyI2NUQrmlv6FMjrMnIPo 14xoKrKv1TtU4PYVHIiON48a7LfClaE= X-Rspamd-Queue-Id: B2F41100031 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ho9NvHEq; spf=pass (imf14.hostedemail.com: domain of 3AY5XYwgKCJw96RE9CKSCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--davidgow.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3AY5XYwgKCJw96RE9CKSCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--davidgow.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: f4m3waxsxhxmo54y5u3wdxjp78pax3o8 X-HE-Tag: 1666682370-14448 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use the newly-added function kunit_get_current_test() instead of accessing current->kunit_test directly. This function uses a static key to return more quickly when KUnit is enabled, but no tests are actively running. There should therefore be a negligible performance impact to enabling the slub KUnit tests. Other than the performance improvement, this should be a no-op. Cc: Oliver Glitta Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Christoph Lameter Cc: Vlastimil Babka Cc: David Rientjes Cc: Andrew Morton Signed-off-by: David Gow Acked-by: Vlastimil Babka --- This is intended as an example use of the new function. Other users (such as KASAN) will be updated separately, as there would otherwise be conflicts. Assuming there are no objections, we'll take this whole series via the kselftest/kunit tree. There was no v1 of this patch. v1 of the series can be found here: https://lore.kernel.org/linux-kselftest/20221021072854.333010-1-davidgow@google.com/T/#u --- lib/slub_kunit.c | 1 + mm/slub.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c index 7a0564d7cb7a..8fd19c8301ad 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include diff --git a/mm/slub.c b/mm/slub.c index 157527d7101b..15d10d250ef2 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -603,10 +604,10 @@ static bool slab_add_kunit_errors(void) { struct kunit_resource *resource; - if (likely(!current->kunit_test)) + if (likely(!kunit_get_current_test())) return false; - resource = kunit_find_named_resource(current->kunit_test, "slab_errors"); + resource = kunit_find_named_resource(kunit_get_current_test(), "slab_errors"); if (!resource) return false;