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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB327C433FE for ; Thu, 30 Sep 2021 18:48:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 78CDF6135D for ; Thu, 30 Sep 2021 18:48:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 78CDF6135D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A56DC9400C3; Thu, 30 Sep 2021 14:48:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B81A94003A; Thu, 30 Sep 2021 14:48:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80A789400C3; Thu, 30 Sep 2021 14:48:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id 6CCD494003A for ; Thu, 30 Sep 2021 14:48:20 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2110B181C5C29 for ; Thu, 30 Sep 2021 18:48:20 +0000 (UTC) X-FDA: 78645125160.01.86E47B0 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf06.hostedemail.com (Postfix) with ESMTP id DEF53801AB2B for ; Thu, 30 Sep 2021 18:48:19 +0000 (UTC) Received: by mail-pg1-f177.google.com with SMTP id s11so7169676pgr.11 for ; Thu, 30 Sep 2021 11:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=sJFF8/1GlPuEUwN0VlLL/s/A+hGOPfTSgKTAVipRj/o=; b=QyFfNne9PMK7JPGenPXu/J4Ppw33qKynidqLdq9XPGDpBjfCxfcSeRZRUrBq0roF+A cCqEyUFm6FvgCUolg7SbTvYmHL25eZINm68Ya7z+PgS458fAl2U4qnoN+YWS4Cgn6Rpc yZxfoGN4go2HiDKvvjExJIiVFOdZOtImg0Z3gLUCE6XZZRnhOUePMlGIOP4UMYicgT+t Pf/kHavzNlZG3IFIzaRhqyscXxsAPs6iyNOAQxfoqiDmiGPgaQ9PaD73sMN5CXpeFWUp yFPVF2t+DtW0GhIVgIFXqu3J4MLtgfrzj0WjKfqGbEOwqeU5jpvqNt8HfodWIuLa3EbM GWFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sJFF8/1GlPuEUwN0VlLL/s/A+hGOPfTSgKTAVipRj/o=; b=PqU0c5A3gW2B1/MV/Y7BVvzrnchxnpEzmURVct93TyKomL4+/NjWLL2rmP/TT8LwlS EoXlzESxojVf52owc2/3BKO+++ecmgfWYZHsYgdZ9c3KtzC8YblWaZRUFe0XD4JwSuCc FeuCXcr8DD04e2HkO1stxWgjzmDaKuBkQAYd1HT2exgZ/Qp6Dwptss4YEc72usdK3ZX7 suUqB2GnMm7NVBQdAkubdD/x4MpMyTzEb87M/Mogdvmb5Efn8aDhPnd5h1BQQX1wDKBv qi4MBIQWB2ReRPqM8+J18K/IjvlmPncc1bz4hss5G44PMf0+WCZwO2Y8pN3wKfcFH2cj hknQ== X-Gm-Message-State: AOAM532BgVp++H99DP6BJlrMbKMWuAyD626rykOUJTqtltanjSDFUSZ2 hexvdD8yLMH+7JGCLL40Bx4= X-Google-Smtp-Source: ABdhPJzkJgaUuPXajizt5X6cfj7CNftU7P/7jMjamgEoLqx3JTN3GqJ3g243nMinTfvVwOBY6ulkVw== X-Received: by 2002:a63:af4b:: with SMTP id s11mr6208016pgo.185.1633027698467; Thu, 30 Sep 2021 11:48:18 -0700 (PDT) Received: from nuc10 (d50-92-229-34.bchsia.telus.net. [50.92.229.34]) by smtp.gmail.com with ESMTPSA id d24sm3652910pfn.62.2021.09.30.11.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 11:48:18 -0700 (PDT) Date: Thu, 30 Sep 2021 11:48:16 -0700 From: Rustam Kovhaev To: Vlastimil Babka Cc: Dave Chinner , djwong@kernel.org, linux-xfs@vger.kernel.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, gregkh@linuxfoundation.org, Al Viro Subject: Re: [PATCH] xfs: use kmem_cache_free() for kmem_cache objects Message-ID: References: <20210929212347.1139666-1-rkovhaev@gmail.com> <20210930044202.GP2361455@dread.disaster.area> <17f537b3-e2eb-5d0a-1465-20f3d3c960e2@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17f537b3-e2eb-5d0a-1465-20f3d3c960e2@suse.cz> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: DEF53801AB2B X-Stat-Signature: 8ijxgawtczayt3k9g4y1yhra8rt71nge Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QyFfNne9; spf=pass (imf06.hostedemail.com: domain of rkovhaev@gmail.com designates 209.85.215.177 as permitted sender) smtp.mailfrom=rkovhaev@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1633027699-463565 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, Sep 30, 2021 at 10:13:40AM +0200, Vlastimil Babka wrote: > On 9/30/21 06:42, Dave Chinner wrote: > > On Wed, Sep 29, 2021 at 02:23:47PM -0700, Rustam Kovhaev wrote: > >> For kmalloc() allocations SLOB prepends the blocks with a 4-byte header, > >> and it puts the size of the allocated blocks in that header. > >> Blocks allocated with kmem_cache_alloc() allocations do not have that > >> header. > >> > >> SLOB explodes when you allocate memory with kmem_cache_alloc() and then > >> try to free it with kfree() instead of kmem_cache_free(). > >> SLOB will assume that there is a header when there is none, read some > >> garbage to size variable and corrupt the adjacent objects, which > >> eventually leads to hang or panic. > >> > >> Let's make XFS work with SLOB by using proper free function. > >> > >> Fixes: 9749fee83f38 ("xfs: enable the xfs_defer mechanism to process extents to free") > >> Signed-off-by: Rustam Kovhaev > > > > IOWs, XFS has been broken on SLOB for over 5 years and nobody > > anywhere has noticed. > > > > And we've just had a discussion where the very best solution was to > > use kfree() on kmem_cache_alloc() objects so we didn't ahve to spend > > CPU doing global type table lookups or use an extra 8 bytes of > > memory per object to track the slab cache just so we could call > > kmem_cache_free() with the correct slab cache. > > > > But, of course, SLOB doesn't allow this and I was really tempted to > > solve that by adding a Kconfig "depends on SLAB|SLUB" option so that > > we don't have to care about SLOB not working. > > > > However, as it turns out that XFS on SLOB has already been broken > > for so long, maybe we should just not care about SLOB code and > > seriously consider just adding a specific dependency on SLAB|SLUB... > > I think it's fair if something like XFS (not meant for tiny systems AFAIK?) > excludes SLOB (meant for tiny systems). Clearly nobody tried to use these > two together last 5 years anyway. +1 for adding Kconfig option, it seems like some things are not meant to be together. > Maybe we could also just add the 4 bytes to all SLOB objects, declare > kfree() is always fine and be done with it. Yes, it will make SLOB footprint > somewhat less tiny, but even whan we added kmalloc power of two alignment > guarantees, the impact on SLOB was negligible. I'll send a patch to add a 4-byte header for kmem_cache_alloc() allocations. > > Thoughts? > > > > Cheers, > > > > Dave. > > >