Message ID | 20230114005408.never.756-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp49202wrn; Fri, 13 Jan 2023 17:01:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXtNItsa5840U8Kw6HXVqrfPP+5O9kZTaIoh2YN6eowKevCW/p9hm5GiaottpNTupF8xkSFq X-Received: by 2002:a17:907:9a85:b0:81b:fc79:be51 with SMTP id km5-20020a1709079a8500b0081bfc79be51mr75524785ejc.50.1673658117861; Fri, 13 Jan 2023 17:01:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673658117; cv=none; d=google.com; s=arc-20160816; b=UZ806ycy9Tuscfz890JdRJ5NMACZHOKUK2maJTsV3xkncNiOdHDBccNNqDW3fzNwNC QQyvBCgk9NmllCWkYVwPDjdOwL/puiZ1hyPGz/Pcim3fAtffGSTCjpm8EV21G7b+L/ey VcTx4PkpMoW+ROa55APG+unuJzIo28ZiXu+5BVHvlAF/Hg7hOBU0ehTxtBmj8LSuoqVU PsFn5VAMW/tgRsVjD5CN6xPNFzaxnFAbndLH+Opg20JUvpdIAKs8GjSIQhsmS5MaaY/t qvkhVuRpTTbNjfw98AEzL+sB+HhUWbdTHyzSzCuZE6CeyZgj/ddGRS4yy2SZb/TeUWP1 H5tw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=OtT80bwMFSi1TX04ncn3aOT9AB2TEcPEld78kv25IDk=; b=EpzbwL5LJRA1N+qypvUoycajbpHLxS3+PIup7jxVEImhSAN1wEggRBLb2QMFHMZYx7 e2wsccXyvsdDINLgxcSIiH3itIzX8oS5LuZX7tFhPVzCIPq55LC+le6PXLpJAZOZovmM ykdAAmCOXUn40aplMG4WvAnQvhlJrZ0rre8ZAxTT87TutKXCq5qZ+64BCpSC5TW630zj ffyh4rR4ibCnEqLpL+b9TaGjSr0dM+7DgSMhbkZBQcjWinIOfdn/iV+pjPYjgeN2HvQU CHGvq+TJEN45RgLgKMM9Y9+c+qp1HRHv3M0r8OKVUQCvpkKF7u6k816/zRaN4WIt9cLA l6Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mHJYdSLc; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a17090655cf00b007c500a2f33asi16709760ejp.208.2023.01.13.17.01.34; Fri, 13 Jan 2023 17:01:57 -0800 (PST) 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=@chromium.org header.s=google header.b=mHJYdSLc; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230525AbjANAyV (ORCPT <rfc822;stefanalexe48@gmail.com> + 99 others); Fri, 13 Jan 2023 19:54:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229870AbjANAyT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Jan 2023 19:54:19 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4FD87EC9C for <linux-kernel@vger.kernel.org>; Fri, 13 Jan 2023 16:54:18 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id 7so16081103pga.1 for <linux-kernel@vger.kernel.org>; Fri, 13 Jan 2023 16:54:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OtT80bwMFSi1TX04ncn3aOT9AB2TEcPEld78kv25IDk=; b=mHJYdSLc6iXM53tj8HapzvxN5xiNNTdHJPjLOWr3t+vAF+Ch6vAD2xhScGZKM781FR pW2A6UKJFAPzftLJlrhJE1lzR6U/xgqRoN3ie13fOgNTPr96nOaect0+0VH5lowoNVNL MvKx7ofMJHS0M6+9M9sZeGVkbPSFELUVIvpNc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OtT80bwMFSi1TX04ncn3aOT9AB2TEcPEld78kv25IDk=; b=bvBqTuYBwm0DcLHAgBcNZH4giWKIzUGEuAy6PbVUJZQuNF36kjsR+F5GxnVzqC/1xk y5e357mZWZVuqBdOP3dST37qR2rcOe6TYLAItymTrNIA5DR4ehFhambErO+yAjgh5zn3 3W7zocP6tLNVESUzOXIY7vurRnvUlpXRDwng/jyt++tUEhnOJlmuD5aeK3JzA2XW0JJM gllt8R9gpendThPNAxXtVSu7KKpNXgNNbhJwWY/wvAwf5wtllpTYtpGC6wW+8X3JDnLx /ZdBOcHw9FROMWa7YRAsPr4oG2FX1kVjt//t+lQiYf9pEWxfbim+dZw8Rg2UvocW3yXQ E60A== X-Gm-Message-State: AFqh2krvHzH8+ePe+HRFGkWlkAWxam6YsCV2jVgQI+ZxPe53UyVh3LX9 oqotvalg9Ob/RxIBSVe5i3VzJw== X-Received: by 2002:a62:1c90:0:b0:58b:a309:b7c7 with SMTP id c138-20020a621c90000000b0058ba309b7c7mr8505657pfc.16.1673657658453; Fri, 13 Jan 2023 16:54:18 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id r4-20020aa79624000000b0056bd1bf4243sm14313552pfg.53.2023.01.13.16.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 16:54:18 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Andrew Morton <akpm@linux-foundation.org>, Guenter Roeck <linux@roeck-us.net> Cc: Kees Cook <keescook@chromium.org>, Nick Desaulniers <ndesaulniers@google.com>, David Gow <davidgow@google.com>, Nathan Chancellor <nathan@kernel.org>, linux-hardening@vger.kernel.org, Vlastimil Babka <vbabka@suse.cz>, Daniel Latypov <dlatypov@google.com>, Josh Poimboeuf <jpoimboe@kernel.org>, Geert Uytterhoeven <geert+renesas@glider.be>, Miguel Ojeda <ojeda@kernel.org>, Isabella Basso <isabbasso@riseup.net>, Dan Williams <dan.j.williams@intel.com>, Rasmus Villemoes <linux@rasmusvillemoes.dk>, linux-kernel@vger.kernel.org Subject: [PATCH] kunit: memcpy: Split slow memcpy tests into MEMCPY_SLOW_KUNIT_TEST Date: Fri, 13 Jan 2023 16:54:12 -0800 Message-Id: <20230114005408.never.756-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3048; h=from:subject:message-id; bh=8xeMvtElsjKDZOz/S0Mopn8nlPXq3OS7Nh6P7UNbvxk=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjwf0zQRlWtRfMmxr6kATuvVn6AuvVcB0GZiq+rX09 kqohRZ2JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY8H9MwAKCRCJcvTf3G3AJmBrEA CFrU7VuS8XfYRW8wwbgxw0fqKkGJws6CAXjDuEH8vBbAsG1Byfhr5SjDoaxgUW3cV8C50re/eyRfZM /WaZc1ObvGeCcfvXESkpU/jZtnREVb1dPZu+4ZBQ7VjjniPX8Y+MeMZ9v6vmgX8WfkiImsStSiRxYg B8WqM5FcNNu50WjEDfDZrG7sMNJf1gQVli6bFEMMxxUdDauaZY+2UxRr66ogVNGolplIRxhqr4nirL ONbs67vHnSO5iLOIxU5ZWtQnbDYHznAbPQKdkwXZl68AzoLrG1x5IFDCtDRVbizU4rQav7xEnxSJf4 3CqbS+ybPjoyLv0A4NiIhd5bxQXrD/FZYocM+7511TAoL0cwRRsuKbN2nd8j4sz3af8JLJvSKc7A3U eGtxW9Q76Sy1lxgBdpQ9wCC0anDE7G5C65J9R1awTm/c63Q3b4vsoEC2+UzBpDNbEEmNjoKgesgZGn dZ4Pjy25q0cbC08jtvQwCUz62VsVz27AnthhkfWNQ8+8VNrQXAaLCkGcKYc3ZxGFkfL3sUjHdQZP5A MYUizoJA39EnMk5cufAeB4fDA9eHu43MK0xj7QVcYelV7DeeOLDZNQ5eMpPoYpkvfRxa1VbCviCjav 557bLTPI4rf1CjGX93wh1jEh/dzPXwFlP3cTV0n34BFaZTO1BaniasLEsqYg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754957734690326486?= X-GMAIL-MSGID: =?utf-8?q?1754957734690326486?= |
Series |
kunit: memcpy: Split slow memcpy tests into MEMCPY_SLOW_KUNIT_TEST
|
|
Commit Message
Kees Cook
Jan. 14, 2023, 12:54 a.m. UTC
Since the long memcpy tests may stall a system for tens of seconds in virtualized architecture environments, split those tests off under CONFIG_MEMCPY_SLOW_KUNIT_TEST so they can be separately disabled. Reported-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/lkml/20221226195206.GA2626419@roeck-us.net Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-and-tested-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: David Gow <davidgow@google.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Nathan Chancellor <nathan@kernel.org> Cc: linux-hardening@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> --- v2: fix tristate to bool v1: https://lore.kernel.org/lkml/20230107040203.never.112-kees@kernel.org --- lib/Kconfig.debug | 9 +++++++++ lib/memcpy_kunit.c | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-)
Comments
gah. this is actually v2. :( On Fri, Jan 13, 2023 at 04:54:12PM -0800, Kees Cook wrote: > Since the long memcpy tests may stall a system for tens of seconds > in virtualized architecture environments, split those tests off under > CONFIG_MEMCPY_SLOW_KUNIT_TEST so they can be separately disabled. > > Reported-by: Guenter Roeck <linux@roeck-us.net> > Link: https://lore.kernel.org/lkml/20221226195206.GA2626419@roeck-us.net > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > Reviewed-and-tested-by: Guenter Roeck <linux@roeck-us.net> > Reviewed-by: David Gow <davidgow@google.com> > Cc: Andrew Morton <akpm@linux-foundation.org> > Cc: Nathan Chancellor <nathan@kernel.org> > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> > --- > v2: fix tristate to bool > v1: https://lore.kernel.org/lkml/20230107040203.never.112-kees@kernel.org > --- > lib/Kconfig.debug | 9 +++++++++ > lib/memcpy_kunit.c | 15 ++++++++++++--- > 2 files changed, 21 insertions(+), 3 deletions(-) > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index c2c78d0e761c..f90637171453 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -2621,6 +2621,15 @@ config MEMCPY_KUNIT_TEST > > If unsure, say N. > > +config MEMCPY_SLOW_KUNIT_TEST > + bool "Include exhaustive memcpy tests" if !KUNIT_ALL_TESTS > + depends on MEMCPY_KUNIT_TEST > + default KUNIT_ALL_TESTS > + help > + Some memcpy tests are quite exhaustive in checking for overlaps > + and bit ranges. These can be very slow, so they are split out > + as a separate config. > + > config IS_SIGNED_TYPE_KUNIT_TEST > tristate "Test is_signed_type() macro" if !KUNIT_ALL_TESTS > depends on KUNIT > diff --git a/lib/memcpy_kunit.c b/lib/memcpy_kunit.c > index 89128551448d..5a545e1b5dbb 100644 > --- a/lib/memcpy_kunit.c > +++ b/lib/memcpy_kunit.c > @@ -307,8 +307,12 @@ static void set_random_nonzero(struct kunit *test, u8 *byte) > } > } > > -static void init_large(struct kunit *test) > +static int init_large(struct kunit *test) > { > + if (!IS_ENABLED(CONFIG_MEMCPY_SLOW_KUNIT_TEST)) { > + kunit_skip(test, "Slow test skipped. Enable with CONFIG_MEMCPY_SLOW_KUNIT_TEST=y"); > + return -EBUSY; > + } > > /* Get many bit patterns. */ > get_random_bytes(large_src, ARRAY_SIZE(large_src)); > @@ -319,6 +323,8 @@ static void init_large(struct kunit *test) > > /* Explicitly zero the entire destination. */ > memset(large_dst, 0, ARRAY_SIZE(large_dst)); > + > + return 0; > } > > /* > @@ -327,7 +333,9 @@ static void init_large(struct kunit *test) > */ > static void copy_large_test(struct kunit *test, bool use_memmove) > { > - init_large(test); > + > + if (init_large(test)) > + return; > > /* Copy a growing number of non-overlapping bytes ... */ > for (int bytes = 1; bytes <= ARRAY_SIZE(large_src); bytes++) { > @@ -472,7 +480,8 @@ static void memmove_overlap_test(struct kunit *test) > static const int bytes_start = 1; > static const int bytes_end = ARRAY_SIZE(large_src) + 1; > > - init_large(test); > + if (init_large(test)) > + return; > > /* Copy a growing number of overlapping bytes ... */ > for (int bytes = bytes_start; bytes < bytes_end; > -- > 2.34.1 >
On Fri, Jan 13, 2023 at 4:54 PM Kees Cook <keescook@chromium.org> wrote: > diff --git a/lib/memcpy_kunit.c b/lib/memcpy_kunit.c > index 89128551448d..5a545e1b5dbb 100644 > --- a/lib/memcpy_kunit.c > +++ b/lib/memcpy_kunit.c > @@ -307,8 +307,12 @@ static void set_random_nonzero(struct kunit *test, u8 *byte) > } > } > > -static void init_large(struct kunit *test) > +static int init_large(struct kunit *test) > { > + if (!IS_ENABLED(CONFIG_MEMCPY_SLOW_KUNIT_TEST)) { > + kunit_skip(test, "Slow test skipped. Enable with CONFIG_MEMCPY_SLOW_KUNIT_TEST=y"); > + return -EBUSY; Note: kunit_skip() here means you don't need explicit returns in the test cases. kunit_skip() is basically kunit_mark_skipped(test, "reason"); kthread_complete_and_exit(...); So the diff in this file could be reduced down to just these 2 lines if (!IS_ENABLED(...)) kunit_skip(test, "...") But I can see the appeal of being more explicit about the control flow. In that case, you could switch kunit_mark_skipped(), which just sets the status and doesn't affect control flow at all. Daniel
On Sat, 14 Jan 2023 at 08:54, Kees Cook <keescook@chromium.org> wrote: > > Since the long memcpy tests may stall a system for tens of seconds > in virtualized architecture environments, split those tests off under > CONFIG_MEMCPY_SLOW_KUNIT_TEST so they can be separately disabled. > > Reported-by: Guenter Roeck <linux@roeck-us.net> > Link: https://lore.kernel.org/lkml/20221226195206.GA2626419@roeck-us.net > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > Reviewed-and-tested-by: Guenter Roeck <linux@roeck-us.net> > Reviewed-by: David Gow <davidgow@google.com> > Cc: Andrew Morton <akpm@linux-foundation.org> > Cc: Nathan Chancellor <nathan@kernel.org> > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> > --- Thanks: this is okay as-is, but I left a few suggestions below, having tried it out a bit more. Daniel's comment about kunit_skip() aborting the test is the only real fix, but depending on how easy you'd want to make turning these tests off, there are a couple of possible tweaks to the Kconfig option. Cheers, -- David > v2: fix tristate to bool > v1: https://lore.kernel.org/lkml/20230107040203.never.112-kees@kernel.org > --- > lib/Kconfig.debug | 9 +++++++++ > lib/memcpy_kunit.c | 15 ++++++++++++--- > 2 files changed, 21 insertions(+), 3 deletions(-) > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index c2c78d0e761c..f90637171453 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -2621,6 +2621,15 @@ config MEMCPY_KUNIT_TEST > > If unsure, say N. > > +config MEMCPY_SLOW_KUNIT_TEST > + bool "Include exhaustive memcpy tests" if !KUNIT_ALL_TESTS I think it'd be better to not include the "if !KUNIT_ALL_TESTS" here, because it's very convenient to be able to use: ./tools/testing/kunit/kunit.py run memcpy --kconfig_add CONFIG_MEMCPY_SLOW_KUNIT_TEST=n to override it. That does undermine the way KUNIT_ALL_TESTS works a bit, though it depends if you want to consider this a new set of tests, or just an option for the existing ones. > + depends on MEMCPY_KUNIT_TEST > + default KUNIT_ALL_TESTS Does this default work for everyone? Personally, I think these tests aren't slow enough that we'd want them disabled from an "all tests" build by default. So I'd keep it as-is. > + help > + Some memcpy tests are quite exhaustive in checking for overlaps > + and bit ranges. These can be very slow, so they are split out > + as a separate config. > + > config IS_SIGNED_TYPE_KUNIT_TEST > tristate "Test is_signed_type() macro" if !KUNIT_ALL_TESTS > depends on KUNIT > diff --git a/lib/memcpy_kunit.c b/lib/memcpy_kunit.c > index 89128551448d..5a545e1b5dbb 100644 > --- a/lib/memcpy_kunit.c > +++ b/lib/memcpy_kunit.c > @@ -307,8 +307,12 @@ static void set_random_nonzero(struct kunit *test, u8 *byte) > } > } > > -static void init_large(struct kunit *test) > +static int init_large(struct kunit *test) > { > + if (!IS_ENABLED(CONFIG_MEMCPY_SLOW_KUNIT_TEST)) { > + kunit_skip(test, "Slow test skipped. Enable with CONFIG_MEMCPY_SLOW_KUNIT_TEST=y"); > + return -EBUSY; As Daniel notes, it shouldn't be necessary to return here, as kunit_skip() will abort the test. (It's a macro, so isn't marked __noreturn itself, but kunit_try_catch_throw(), which it uses, is.) > + } > > /* Get many bit patterns. */ > get_random_bytes(large_src, ARRAY_SIZE(large_src)); > @@ -319,6 +323,8 @@ static void init_large(struct kunit *test) > > /* Explicitly zero the entire destination. */ > memset(large_dst, 0, ARRAY_SIZE(large_dst)); > + > + return 0; > } > > /* > @@ -327,7 +333,9 @@ static void init_large(struct kunit *test) > */ > static void copy_large_test(struct kunit *test, bool use_memmove) > { > - init_large(test); > + > + if (init_large(test)) > + return; > > /* Copy a growing number of non-overlapping bytes ... */ > for (int bytes = 1; bytes <= ARRAY_SIZE(large_src); bytes++) { > @@ -472,7 +480,8 @@ static void memmove_overlap_test(struct kunit *test) > static const int bytes_start = 1; > static const int bytes_end = ARRAY_SIZE(large_src) + 1; > > - init_large(test); > + if (init_large(test)) > + return; > > /* Copy a growing number of overlapping bytes ... */ > for (int bytes = bytes_start; bytes < bytes_end; > -- > 2.34.1 >
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index c2c78d0e761c..f90637171453 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2621,6 +2621,15 @@ config MEMCPY_KUNIT_TEST If unsure, say N. +config MEMCPY_SLOW_KUNIT_TEST + bool "Include exhaustive memcpy tests" if !KUNIT_ALL_TESTS + depends on MEMCPY_KUNIT_TEST + default KUNIT_ALL_TESTS + help + Some memcpy tests are quite exhaustive in checking for overlaps + and bit ranges. These can be very slow, so they are split out + as a separate config. + config IS_SIGNED_TYPE_KUNIT_TEST tristate "Test is_signed_type() macro" if !KUNIT_ALL_TESTS depends on KUNIT diff --git a/lib/memcpy_kunit.c b/lib/memcpy_kunit.c index 89128551448d..5a545e1b5dbb 100644 --- a/lib/memcpy_kunit.c +++ b/lib/memcpy_kunit.c @@ -307,8 +307,12 @@ static void set_random_nonzero(struct kunit *test, u8 *byte) } } -static void init_large(struct kunit *test) +static int init_large(struct kunit *test) { + if (!IS_ENABLED(CONFIG_MEMCPY_SLOW_KUNIT_TEST)) { + kunit_skip(test, "Slow test skipped. Enable with CONFIG_MEMCPY_SLOW_KUNIT_TEST=y"); + return -EBUSY; + } /* Get many bit patterns. */ get_random_bytes(large_src, ARRAY_SIZE(large_src)); @@ -319,6 +323,8 @@ static void init_large(struct kunit *test) /* Explicitly zero the entire destination. */ memset(large_dst, 0, ARRAY_SIZE(large_dst)); + + return 0; } /* @@ -327,7 +333,9 @@ static void init_large(struct kunit *test) */ static void copy_large_test(struct kunit *test, bool use_memmove) { - init_large(test); + + if (init_large(test)) + return; /* Copy a growing number of non-overlapping bytes ... */ for (int bytes = 1; bytes <= ARRAY_SIZE(large_src); bytes++) { @@ -472,7 +480,8 @@ static void memmove_overlap_test(struct kunit *test) static const int bytes_start = 1; static const int bytes_end = ARRAY_SIZE(large_src) + 1; - init_large(test); + if (init_large(test)) + return; /* Copy a growing number of overlapping bytes ... */ for (int bytes = bytes_start; bytes < bytes_end;