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 X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 865CBC433ED for ; Thu, 13 May 2021 08:54:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 032AB6142E for ; Thu, 13 May 2021 08:54:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 032AB6142E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8D73E6B0036; Thu, 13 May 2021 04:54:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8ADF86B006E; Thu, 13 May 2021 04:54:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74F366B0070; Thu, 13 May 2021 04:54:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 44FAA6B0036 for ; Thu, 13 May 2021 04:54:26 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E5473815E for ; Thu, 13 May 2021 08:54:25 +0000 (UTC) X-FDA: 78135596490.32.ABBE1EA Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by imf27.hostedemail.com (Postfix) with ESMTP id 6597880192E7 for ; Thu, 13 May 2021 08:54:24 +0000 (UTC) Received: by mail-oi1-f180.google.com with SMTP id c3so24687308oic.8 for ; Thu, 13 May 2021 01:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jG12S413O8fUiJ8iykc3p7wvxXhef9ESdPVA0acK7/k=; b=NDyBX09Om2k3j1J6yBIltr0QKv4OUv8wA0NvZw9OdVOa8L4npbuGF1BDzMwBnDlcFZ Emb2fYN5KnXR76wk9o6ekppMI2W02qXSielDjKiz5A9HWTDAsqY6IEUj/iq1zYpf0ZuO HT7HGrSG+U6CkeBqg9IRNWEKaqFdWKFZIpdNq7Kv/osIe24YLUttO+KE6LIq8rZHo+AQ V3c7QCOxyC8eAMi4Tx9XCh5dlaFDBoKvcv9OUpZnPFUeK7A1Ip4XFavPbBrEfCv3AIjT CUoMXrjvc51Y6VaEUD3KTznAsmgh+J5UGPXOrcs+8MGp9Lhca21EuNpoigsG1En/TsSS 6LHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jG12S413O8fUiJ8iykc3p7wvxXhef9ESdPVA0acK7/k=; b=FIjuBZ9W+L12z6HAlWgt56IcFJA1/0CPvWro//EogROZOMGbRj9hAJZ1GW65rlrcai MMSivZ3Icthpsd6+FcWYrgvM3tHJ3QgggR6SsXi026OMPU5LBSbsAlHIF8TIQTvJH4yG xkb/Ako/HWMEdPmIklGusvmGMdy84KOiNRcpJG1C1qM2ovxVfR8c1jGQh+EqFwWMTx2e 3Q4x2OoMY81SGwNjDGQO8S4h/D7998Q2tYJ42IbZl0ip2wemhJ9QB5tffSDuF/xZV6dh Cqs4TOXeK/zAnKKOuPjynLXM+E0WzuY+QzfRBySSNgCfOHWUxw/XUjM8acCw7VuoN8H6 +veQ== X-Gm-Message-State: AOAM530cgpYysyFAMsVTcWuOTayzJ6V+m5FKZ+v3hY/+Wj3QsjGVLk+k UKvlLkU981hNnbcV54USpty3vlYTgjbT1tNY8PMEKQ== X-Google-Smtp-Source: ABdhPJzHbpIRee5o3M7Noz/2xtZ/nvLm3qNZBmwciNfe+ShxEPtJ4vKwUXcLPEDWB5FuedQBvKHbHbp+yAy/eLxI/jI= X-Received: by 2002:aca:bb06:: with SMTP id l6mr29564018oif.121.1620896064734; Thu, 13 May 2021 01:54:24 -0700 (PDT) MIME-Version: 1.0 References: <20210511150734.3492-1-glittao@gmail.com> <20210511150734.3492-2-glittao@gmail.com> <20210512214440.e2cb47f751137db9802da62e@linux-foundation.org> In-Reply-To: <20210512214440.e2cb47f751137db9802da62e@linux-foundation.org> From: Marco Elver Date: Thu, 13 May 2021 10:54:13 +0200 Message-ID: Subject: Re: [PATCH v5 2/3] mm/slub, kunit: add a KUnit test for SLUB debugging functionality To: Andrew Morton Cc: Oliver Glitta , Brendan Higgins , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , LKML , "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux Memory Management List , Daniel Latypov Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=NDyBX09O; spf=pass (imf27.hostedemail.com: domain of elver@google.com designates 209.85.167.180 as permitted sender) smtp.mailfrom=elver@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6597880192E7 X-Stat-Signature: b8on7odjxrwhsfer55sfiqjisiy3ec47 Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf27; identity=mailfrom; envelope-from=""; helo=mail-oi1-f180.google.com; client-ip=209.85.167.180 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620896064-441306 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: On Thu, 13 May 2021 at 06:44, Andrew Morton wrote: > On Tue, 11 May 2021 17:07:33 +0200 glittao@gmail.com wrote: > > From: Oliver Glitta > > > > SLUB has resiliency_test() function which is hidden behind #ifdef > > SLUB_RESILIENCY_TEST that is not part of Kconfig, so nobody > > runs it. KUnit should be a proper replacement for it. > > > > Try changing byte in redzone after allocation and changing > > pointer to next free node, first byte, 50th byte and redzone > > byte. Check if validation finds errors. > > > > There are several differences from the original resiliency test: > > Tests create own caches with known state instead of corrupting > > shared kmalloc caches. > > > > The corruption of freepointer uses correct offset, the original > > resiliency test got broken with freepointer changes. > > > > Scratch changing random byte test, because it does not have > > meaning in this form where we need deterministic results. > > > > Add new option CONFIG_SLUB_KUNIT_TEST in Kconfig. > > Tests next_pointer, first_word and clobber_50th_byte do not run > > with KASAN option on. Because the test deliberately modifies non-allocated > > objects. > > > > Use kunit_resource to count errors in cache and silence bug reports. > > Count error whenever slab_bug() or slab_fix() is called or when > > the count of pages is wrong. > > > > ... > > > > lib/slub_kunit.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++ > > mm/slab.h | 1 + > > mm/slub.c | 46 +++++++++++++- > > 5 files changed, 212 insertions(+), 3 deletions(-) > > create mode 100644 lib/slub_kunit.c > > > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > > index 678c13967580..7723f58a9394 100644 > > --- a/lib/Kconfig.debug > > +++ b/lib/Kconfig.debug > > @@ -2429,6 +2429,18 @@ config BITS_TEST > > > > If unsure, say N. > > > > +config SLUB_KUNIT_TEST > > + tristate "KUnit test for SLUB cache error detection" if !KUNIT_ALL_TESTS > > This means it can be compiled as a kernel module. Did you runtime test the > code as a module? > > ERROR: modpost: "kasan_enable_current" [lib/slub_kunit.ko] undefined! > ERROR: modpost: "kasan_disable_current" [lib/slub_kunit.ko] undefined! > > --- a/mm/kasan/common.c~a > +++ a/mm/kasan/common.c > @@ -51,11 +51,14 @@ void kasan_enable_current(void) > { > current->kasan_depth++; > } > +EXPORT_SYMBOL(kasan_enable_current); > > void kasan_disable_current(void) > { > current->kasan_depth--; > } > +EXPORT_SYMBOL(kasan_disable_current); > + > #endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */ > > void __kasan_unpoison_range(const void *address, size_t size) > _ Acked-by: Marco Elver