Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp577121pxb; Thu, 23 Sep 2021 06:32:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsotd7B2NDSWjZdmmOg2GlcHdiJH4oXF9WAvMplHpYgQqYvatsHwtHG6lZ/tnMzMzivjkx X-Received: by 2002:a50:e0cf:: with SMTP id j15mr5688702edl.23.1632403966488; Thu, 23 Sep 2021 06:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632403966; cv=none; d=google.com; s=arc-20160816; b=Tsw1YDEVAlfZylvDOhYSeHv72uX2RO16EaBhndoyxV4moiKIq6PQ/91CKcgJHdM4Ln zxACw3jiN3hXxuEJpWwnAxJe5c/8bPeJx9+A0PW9bAgJ5fTGOFhUXdv2udQL7BWLtGVA a3Lfxtkm9GM0jutYyCtavJOklxUJ4Bo0xeQ+p62ZKwweIdzaSUVAP486unEA8ds+Juja xENMHjQ2ocU6kSAyUF0fBV99habyqcvK/7DEk5ylVFkAyvk6Ue7De350Q0yHbzuBx1G2 whJNCkOueC/YUn0mMqQgOToH4TRO8xSkWkBh3S4fSPmmSwPmyBFiDtBihh2K7B9LBJEr yejQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=t8z/LmxoGBBSlUGmuhXoY/PzrkP46mbtkqPWUVKC82g=; b=dmXBaoTEg6BwiW7fw/jWS0DP5or8I+7tdsE0NuI0TR0UjtCKhZLr6jg+DtQSvAQEEn 2mL2n47oZEhUjAJUL/mVUiZyyPQXuqiWbT1Hnf9Fgejxt69PS2oxPyMKYra65iEYF/Kq lLo79rcy3tS05ztZUwYt5JGwB8yw5KBD/KfSCf05bdab+mD7Mr6H/rgNShMTDA8JJWh7 54T595gzvg7o90hLOMdzvbnTyLWCYScTt5Q1vY1HwtqYIsLVYN7HCOr19HfyAEgqvSiI ANvgyT9laMdmn6NuAxSVqY/jJ4WJwxQs3ZgI3WJ/9RvYC1uslBHfON4slgyAJWiVTeaM l9aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="J9Ezn/lB"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x20si6055921ejy.481.2021.09.23.06.32.22; Thu, 23 Sep 2021 06:32:46 -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=@kernel.org header.s=k20201202 header.b="J9Ezn/lB"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241265AbhIWNaS (ORCPT + 99 others); Thu, 23 Sep 2021 09:30:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:43106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232316AbhIWNaR (ORCPT ); Thu, 23 Sep 2021 09:30:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 09C1861107; Thu, 23 Sep 2021 13:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632403725; bh=w0JufNshx/PXI2oi9FITKwYGXFUmV7b/kmCZtFIv61E=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=J9Ezn/lBNXW73vjn6aYXvT1FJ+1Zc5vGGQPPaJx/RGjvMhhqlu0VXNVtw6Ia4nm17 T/xbP3fcz59nbaknDSFRHCcorU0UQ00eBy1nDt3cgQarFyJDgW9n+4jlS0qKiGj++f SJdqhjw4NuvAT2VO0a1m9z8KL6UZ/j+UV7mw2CDi0UlX6KuXbgT25eF/3/5R3eWnyV gxjLBkJJoTBPMaWUiJDv1U5Uf2q3uKP6sosQWSxtZktMnS9R9prDGqJOuV46skqOvG +FK4DJCwUVqmpDO/YLNzDVb2JR/vJ5kiBp94pKZXu4cHj7pcB59gZ0yxK122ZaMa+E 9Bjn+XKtVxuGw== Date: Thu, 23 Sep 2021 06:28:44 -0700 From: Jakub Kicinski To: Jens Axboe Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , linux-kernel@vger.kernel.org, Matthew Wilcox , John Garry , linux-block@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [RFC v2 PATCH] mm, sl[au]b: Introduce lockless cache Message-ID: <20210923062844.148e08fd@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <688e6750-87e9-fb44-ce40-943bad072e48@kernel.dk> References: <20210920154816.31832-1-42.hyeyoo@gmail.com> <20210922081906.GA78305@kvm.asia-northeast3-a.c.our-ratio-313919.internal> <688e6750-87e9-fb44-ce40-943bad072e48@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 Sep 2021 06:58:00 -0600 Jens Axboe wrote: > > I considered only case 2) when writing code. Well, To support 1), > > I think there are two ways: > > > > a) internally call kmem_cache_free when in_interrupt() is true > > b) caller must disable interrupt when freeing > > > > I think a) is okay, how do you think? > > If the API doesn't support freeing from interrupts, then I'd make that > the rule. Caller should know better if that can happen, and then just > use kmem_cache_free() if in a problematic context. That avoids polluting > the fast path with that check. I'd still make it a WARN_ON_ONCE() as > described and it can get removed later, hopefully. Shooting from the hip a little but if I'm getting the context right this is all very similar to the skb cache so lockdep_assert_in_softirq() may be useful: /* * Acceptable for protecting per-CPU resources accessed from BH. * Much like in_softirq() - semantics are ambiguous, use carefully. */ #define lockdep_assert_in_softirq() \ do { \ WARN_ON_ONCE(__lockdep_enabled && \ (!in_softirq() || in_irq() || in_nmi())); \ } while (0)