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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, 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 495E3C433E0 for ; Fri, 19 Mar 2021 11:20:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B7D5664F69 for ; Fri, 19 Mar 2021 11:20:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7D5664F69 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 F11A76B006E; Fri, 19 Mar 2021 07:20:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC0686B0071; Fri, 19 Mar 2021 07:20:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3C516B0072; Fri, 19 Mar 2021 07:20:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id BB3E36B006E for ; Fri, 19 Mar 2021 07:20:11 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 66E6318026B38 for ; Fri, 19 Mar 2021 11:20:11 +0000 (UTC) X-FDA: 77936379822.31.AAEE2C1 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) by imf24.hostedemail.com (Postfix) with ESMTP id E0283A0009EA for ; Fri, 19 Mar 2021 11:20:10 +0000 (UTC) Received: by mail-oo1-f54.google.com with SMTP id n12-20020a4ad12c0000b02901b63e7bc1b4so2207160oor.5 for ; Fri, 19 Mar 2021 04:20:10 -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=563BAybzVyHEsgNkhjo3Ec3csusCS7gRQaGdAB7Gmag=; b=GwMpeYjU0UPUDm9dz3INLUYoGdgFNUt7NzD/7SI5sYjGE+9FyhjLK01joQgS5pc+CO bP5DgKDTqGjtUvrNBmKSoLe5aISbyJGEu0zIV8MV9UhPRRlYEf6RXbeMgdApY8e8cGfn ING6er4kHFjYi/y2G6v3WloSZAuluDdJ5C/HrtyzDz3b9XtYTZnRXbur2WZM1E5Pyz4j u0gT5ZJrNGM1MHlb5MO3hzAlpPmzQEOyzyvT4MbhcH0kXYcChKlsQMSG5iZ9AWvuPZrp gglcwl5xSFxAN5s7GpN/g8AQvt7Z3tXHmjOLQlHcuxy1NKQqqxR4qMH6eTYnkz+KTmBh FnSA== 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=563BAybzVyHEsgNkhjo3Ec3csusCS7gRQaGdAB7Gmag=; b=QfHqUELdZvPxMRH6icxchVr0Ll2kt5HHT19CMwcYFKkDYcBDO8hOifaqiKgNEVqXQh GsWNXEg7FqzCXuvfzgwjRGGiLO4YvEd3CP9Rb0TNGaaZNth0Y/kBHLyQTb43rPc2brE3 sts1sYaO6o0kMOwtOssshkOgQm/732p2L3olk+Dg33SHyohrT3feqILEAeqSZ/Pac774 6f0xkfrutfxPQcq5Y0uCTCtV3cDnmYo5Pvrw4GkJ88AXGlBqVmquyGAbKYRfGfeeYdHn 86dutqepwW3c8vluvifsTQsZjymcU99tuo2Qg/GXnccuZJuqT/Shbn74kklM+JFygjEp pEOw== X-Gm-Message-State: AOAM533XlpP2/sL5xQZDL3g6B64LGWliwnKI3HlfyIzMGyuTr1G5sQBt rQZz3XOSO41cGnI93EnQHaedVD2xnUE255MY1BR3PA== X-Google-Smtp-Source: ABdhPJxxLImaAPwO9waG0d7jrrqrIp8kbDzYx14Qc417p4oCxS11Mr56IHANMprCOhUvN7EIWCGQjbt6ugpIv1orY34= X-Received: by 2002:a05:6820:273:: with SMTP id c19mr993222ooe.54.1616152809948; Fri, 19 Mar 2021 04:20:09 -0700 (PDT) MIME-Version: 1.0 References: <20210316124118.6874-1-glittao@gmail.com> <3ba2228a-1442-40b4-578f-f693d9a054e7@suse.cz> In-Reply-To: <3ba2228a-1442-40b4-578f-f693d9a054e7@suse.cz> From: Marco Elver Date: Fri, 19 Mar 2021 12:19:58 +0100 Message-ID: Subject: Re: [PATCH 1/2] selftests: add a kselftest for SLUB debugging functionality To: Vlastimil Babka Cc: glittao@gmail.com, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Shuah Khan , LKML , Linux Memory Management List , "open list:KERNEL SELFTEST FRAMEWORK" Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: wyt64barxo9tjqhc1h61y1ukeqmmjqeo X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E0283A0009EA Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=mail-oo1-f54.google.com; client-ip=209.85.161.54 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616152810-744651 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 Fri, 19 Mar 2021 at 11:46, Vlastimil Babka wrote: > On 3/18/21 12:47 PM, Marco Elver wrote: > > On Tue, Mar 16, 2021 at 01:41PM +0100, 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. Kselftest should 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_TEST_SLUB in Kconfig. > >> > >> Add parameter to function validate_slab_cache() to return > >> number of errors in cache. > >> > >> Signed-off-by: Oliver Glitta > > > > No objection per-se, but have you considered a KUnit-based test instead? > > To be honest, we didn't realize about that option. > > > There is no user space portion required to run this test, and a pure > > in-kernel KUnit test would be cleaner. Various boiler-plate below, > > including pr_err()s, the kselftest script etc. would simply not be > > necessary. > > > > This is only a suggestion, but just want to make sure you've considered > > the option and weighed its pros/cons. > > Thanks for the suggestion. But I hope we would expand the tests later to e.g. > check the contents of various SLUB related sysfs files or even write to them, > and for that goal kselftest seems to be a better starting place? Not sure, but I would probably go about it this way: A. Anything that is purely in-kernel and doesn't require a user space component should be a KUnit test. B. For any test that requires a user space component, it'd be a kselftest. And I think the best design here would also clearly separate those 2 types of tests, and I wouldn't lump tests of type A into modules that are also used for B. That way, running tests of type A also is a bit easier, and if somebody wants to just quickly run those it's e.g. very quick to do so with kunit-tool. Thanks, -- Marco