Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1306485pxf; Fri, 19 Mar 2021 04:21:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs3I1gd1Apy6aoOOQ65Bl4I9eXWje+9iV2M8YM6CtpoIorz2evzU3ThPj2rPNl0Vn/hU9J X-Received: by 2002:a05:6402:46:: with SMTP id f6mr8909735edu.252.1616152918120; Fri, 19 Mar 2021 04:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616152918; cv=none; d=google.com; s=arc-20160816; b=olQWbrzIqUgjj469/Kr81BI/hRGOrzb9lxkiR5GsluU6G39TN4vsHisuIintFZaR+s Wf0gDX318ZTDhBY2I+8NGkXm0KwM26vd2yZpYEkP+Mon1t+GUlMak/2gBGjNAsWwgbAE PsceFTKVJx/DUoFX6/bxLdPVMzm9HZfoJ8MgwxOocGUMrhUXZz1sfZykBRfcvE9SNGwJ DRUJDGH0P4atBv4idZ3C2Z6i+5NNKSO/wKvk62Ok0mAxQSPm9PWIO7+YdjzNavY0bz8s khtxL/0QSWtrJFF97WZy7zu8KV5a4DLty61R0evqlb6oGRCgtm6Zf34COIoKBiujRdpB aOoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=563BAybzVyHEsgNkhjo3Ec3csusCS7gRQaGdAB7Gmag=; b=luKpteZVtd/0yOMuRRZmQbiz0w++5Supos2eGXZTHRRJ7baLl2xCnTLIweStSvuxco +2e/uOmqmemkl3uhqXoGdA5uNFMAUuKUobR1gGB3KaCND65/B3rTMuJOTDSb8URvo8Fn TkwmZXVQE52ohxkrAhQPMaDvpc4Xxiq+gLIphIuRGnuCFXi5cjzPDeGULgWvCfCFyiwU PNaP0M37bdUQ5DW8h8sbGxSBqnmNGllQZpYMnxVm9QrUEbQgrNNf9dtcuI29OtgfCbC6 JhIzlWzqoQK7qYBY6pSTNgwXv/b5W2ibJuyPrbV/mFR1wDx8SvXhbIOTaOv8I88bJwPM WgPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GwMpeYjU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si3976889ejm.138.2021.03.19.04.21.34; Fri, 19 Mar 2021 04:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GwMpeYjU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229893AbhCSLUi (ORCPT + 99 others); Fri, 19 Mar 2021 07:20:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbhCSLUL (ORCPT ); Fri, 19 Mar 2021 07:20:11 -0400 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE6BAC06175F for ; Fri, 19 Mar 2021 04:20:10 -0700 (PDT) Received: by mail-oo1-xc32.google.com with SMTP id q127-20020a4a33850000b02901b646aa81b1so2201575ooq.8 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=GNXXY9qBivGHKMt7388jOKO4N62t31zWWC520YpoN+zxxB1Nyc0LWITa2Yym5xmXuC 5PZ/qEnBPqVOuZuHSSJ3kMMS1mvkrl8a/tvCroUP5+7YmhUzjAIPmeMCzD5zk1I+51Fd DBuomw/Gx4orKbOt5ZSoZR6+wFY9JD5t+UUf8jd9gBlTvX08R0/yhNlTCSKf9Qqvb2Ps 4aviBMQ96QFRgAT2jr0MMOLc82/9WDcSvUo1TlAk3OgWj8SbK9Jx860SLffWbcN4GbwU lQYqEgvmXkuuifpWdi9XWAJ9OAw4fFnFIlLEFJ88nORD5n+VAwBWvN099Qt7+30GglBt +imQ== X-Gm-Message-State: AOAM530VQ9pOZ4IhCXXteUo/X1vEYK7wBg6mOteYa56Ly4ND4uEdD6d8 nvzA/k0M4YeVUSkhDPzPWhMbgz1cw8tAQYcOwa8feg== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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