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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FECEC32771 for ; Wed, 21 Sep 2022 11:30:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E8D06B0072; Wed, 21 Sep 2022 07:30:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 498386B0073; Wed, 21 Sep 2022 07:30:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3605C940007; Wed, 21 Sep 2022 07:30:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 26EB76B0072 for ; Wed, 21 Sep 2022 07:30:27 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AAF5E40AD5 for ; Wed, 21 Sep 2022 11:30:26 +0000 (UTC) X-FDA: 79935874452.27.9144248 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf07.hostedemail.com (Postfix) with ESMTP id 5AC8340025 for ; Wed, 21 Sep 2022 11:30:26 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id i15-20020a17090a4b8f00b0020073b4ac27so5487950pjh.3 for ; Wed, 21 Sep 2022 04:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=R/5/bZN4kuofLcqZ8N/8Nt9PsU4TMvL8T88QA1VrZP0=; b=D04zDq0hPLt8U2FZikbD41SLVhmsjzWj2wUhsq0GmlrqsjL5YUpnq0c9oxrMmprnQL 7A2jHPavxOTRJMQ5E3RLSyJlVkeIrBE4dmo6NtZuqQ8Eq+iqmHfbsy0//G/mP+3FN/3l FFp4LhRjfDSJOEVU6DbA8gsMrnYba5shkYu6x7kHyrlRCbh9/dRTgj9QCrT32AOZp5LR 6zGn+K8kJNNDTRm8zknLLNTvrfkRQizRoXDXocDV5FwylMI+LiZrB7dx1jQLzBw0cWNc s/lXtKFash+x7928kTm7arrLspMFO7P3k59ErqjooTI5Eyg54MkkcneRR1dShSCUhMCy 3/qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=R/5/bZN4kuofLcqZ8N/8Nt9PsU4TMvL8T88QA1VrZP0=; b=RsWzusqvXjQMSP+BIeuH94CLKBlFl+3my2EjujDFzEYIwJsC43kZKzWCR1wuYua3Rr RukVimgQTTYwdsA5ogNecpgOt5bY3ioBxIc5yWp1dUbW1irWpEah7iL15Yhh3Wh7U8Dm 6mUhVHeeaKHin3hqh2L49dahfWPsNT+PFOqo634GaWZae9KfPubL2Vorclu57AZNn5uo OtyHokgeqK7Ya0aQTLLfEeoMCvjS73jPav+3UJvH5e4Cz7yKDoe/zDCAeWLE9wLcw0oS oPzM/or92miZJvolvZvcIvfNEfSp8Xt1t6Rv+Dc5GVovtbx1TF4EEcs7b2nFU8qCQatY Cz2A== X-Gm-Message-State: ACrzQf1VEv1ewFtBFy/EXTl5mw3S7vMtPA23J3gDGyUoO8ZL0q6n49ej 88QSO175ZrfZeD2zQ3v1JK0= X-Google-Smtp-Source: AMsMyM40XX2EHRJ1cqVGM5ZxKo0btuWH/TwwFpusiJiH43zIDSFriOyWiT6twsWwEJIit1RFmXEKwA== X-Received: by 2002:a17:902:eb90:b0:178:25ab:b3ee with SMTP id q16-20020a170902eb9000b0017825abb3eemr4242909plg.23.1663759825282; Wed, 21 Sep 2022 04:30:25 -0700 (PDT) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id m17-20020a63f611000000b0041c0c9c0072sm1686609pgh.64.2022.09.21.04.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:30:24 -0700 (PDT) Date: Wed, 21 Sep 2022 20:30:12 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Alexander Atanasov Cc: Jonathan Corbet , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , kernel@openvz.org, Kees Cook , Roman Gushchin , Jann Horn , Vijayanand Jitta , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] mm: Make failslab writable again Message-ID: References: <20220920121111.1792905-1-alexander.atanasov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220920121111.1792905-1-alexander.atanasov@virtuozzo.com> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663759826; 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=R/5/bZN4kuofLcqZ8N/8Nt9PsU4TMvL8T88QA1VrZP0=; b=r5ESkzFXhV4/OYz6sFpTd1RhHRx4wqKYSbXbWbIHyEEBmCo8eNqcKypLq7qN/NRCRMdQV/ /zmri1k9dMMRAIPSNvoBxo+wLkKH/iVtZlApOptaAQNWE2yEfUCArcDrRlQ33wZ/HOWjQf zNjliu1P5d0zySeVoY+7x1FXEJEyWOg= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=D04zDq0h; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663759826; a=rsa-sha256; cv=none; b=hmW63DZNBaB7npZ8oVWXcTUDZwo8gyIzgDoOq155IkhR6RDEgJIzgd7HehRvJYhKbtelRw 4tN6BRs2QZXaunTcnxawbGTkVA6VHjHY+ZcBMN/fs8XZsp6/ZxV7FIS7yDWfN7DdyoYEK2 3aRFRaLVNcoFDVYef1ypSEt+2G7G6iw= Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=D04zDq0h; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: zxtm8yg5suxyuksmmbf8s9u1hnxoex8r X-Rspamd-Queue-Id: 5AC8340025 X-HE-Tag: 1663759826-355113 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 Tue, Sep 20, 2022 at 03:11:11PM +0300, Alexander Atanasov wrote: > In (060807f841ac mm, slub: make remaining slub_debug related attributes > read-only) failslab was made read-only. > I think it became a collateral victim to the two other options for which > the reasons are perfectly valid. > Here is why: > - sanity_checks and trace are slab internal debug options, > failslab is used for fault injection. > - for fault injections, which by presumption are random, it > does not matter if it is not set atomically. And you need to > set atleast one more option to trigger fault injection. > - in a testing scenario you may need to change it at runtime > example: module loading - you test all allocations limited > by the space option. Then you move to test only your module's > own slabs. > - when set by command line flags it effectively disables all > cache merges. Maybe we can make failslab= boot parameter to consider cache filtering? With that, just pass something like this: failslab=X,X,X,X,cache_filter slub_debug=A, Users should pass slub_debug=A, anyway to prevent cache merging. > > Cc: Vlastimil Babka > Cc: Andrew Morton > Cc: Kees Cook > Cc: Roman Gushchin > Cc: Christoph Lameter > Cc: Jann Horn > Cc: Vijayanand Jitta > Cc: David Rientjes > Cc: Joonsoo Kim > Cc: Pekka Enberg > Link: http://lkml.kernel.org/r/20200610163135.17364-5-vbabka@suse.cz > > Signed-off-by: Alexander Atanasov > --- > Documentation/mm/slub.rst | 2 ++ > mm/slub.c | 16 +++++++++++++++- > 2 files changed, 17 insertions(+), 1 deletion(-) > > V1->V2: Fixed commit message. Flags are set using WRITE_ONCE. > > diff --git a/Documentation/mm/slub.rst b/Documentation/mm/slub.rst > index 43063ade737a..86837073a39e 100644 > --- a/Documentation/mm/slub.rst > +++ b/Documentation/mm/slub.rst > @@ -116,6 +116,8 @@ options from the ``slub_debug`` parameter translate to the following files:: > T trace > A failslab > > +failslab file is writable, so writing 1 or 0 will enable or disable > +the option at runtime. Write returns -EINVAL if cache is an alias. > Careful with tracing: It may spew out lots of information and never stop if > used on the wrong slab. > > diff --git a/mm/slub.c b/mm/slub.c > index 862dbd9af4f5..57cf18936526 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -5617,7 +5617,21 @@ static ssize_t failslab_show(struct kmem_cache *s, char *buf) > { > return sysfs_emit(buf, "%d\n", !!(s->flags & SLAB_FAILSLAB)); > } > -SLAB_ATTR_RO(failslab); > + > +static ssize_t failslab_store(struct kmem_cache *s, const char *buf, > + size_t length) > +{ > + if (s->refcount > 1) > + return -EINVAL; > + > + if (buf[0] == '1') > + WRITE_ONCE(s->flags, s->flags | SLAB_FAILSLAB); > + else > + WRITE_ONCE(s->flags, s->flags & ~SLAB_FAILSLAB); > + > + return length; > +} > +SLAB_ATTR(failslab); > #endif > > static ssize_t shrink_show(struct kmem_cache *s, char *buf) > > base-commit: 80e78fcce86de0288793a0ef0f6acf37656ee4cf > -- > 2.31.1 > -- Thanks, Hyeonggon