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 lists.zx2c4.com (lists.zx2c4.com [165.227.139.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C211C27C79 for ; Mon, 17 Jun 2024 16:51:28 +0000 (UTC) Received: by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 8daca988; Mon, 17 Jun 2024 16:33:45 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTPS id fc7e1e76 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Mon, 17 Jun 2024 16:33:43 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A5C1A61389 for ; Mon, 17 Jun 2024 16:33:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37D09C4AF4D for ; Mon, 17 Jun 2024 16:33:41 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="lqmD0K57" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1718642017; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dUjKSm9UM4O1aKGbEZjvZRgCeGJk15TE1+l7iyYY+0E=; b=lqmD0K57cnaPOftHh2pOum828X1k5uUv0Vyx2HD1+u8cZfhtcNcmaJO3Jde0keMY78Ap/O TP1hCGHPmLCeXxG7ZdUXs/CPJ7wNLwf1Rwwgjd5I+wJyed+uUTgzNPiCteakfasG+gGmeX AZiaHQP3EqVbkxlqL/iUR3o0NHjrlw4= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id c2ce827a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Mon, 17 Jun 2024 16:33:36 +0000 (UTC) Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-24c9f73ccaaso2639013fac.1 for ; Mon, 17 Jun 2024 09:33:36 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVGX4FgZJCqd17APv4/jW2Nbut4fm4pTKyR7Z9Q5eGkKLJozCRxgU8wKI5nk7Ft8zDsTkFEEvSVut3WzyknZxtWYU/tgXp+wwHa X-Gm-Message-State: AOJu0YwVmUiz6D37PSNZDNwHo5SHZ8+QED8BsCMv0/zgTpV1eI+FCdNC ceS7kFeG0UsPExnHbnfg6Kn05CFQS+YwN+s8uritB//qDf87ooHeEM4iEtGv3+XOz85TIou+0Wv Ix+rCUYODQ+ImTw3pspSs4tWTHhE= X-Google-Smtp-Source: AGHT+IH73cxa8bEaSx0br+R63lisN9Zy21+jpj61L5jMj9rENcrv4EuyB2mn51tWhnn9axbMUQaQmVNUc4nOeGH0JmU= X-Received: by 2002:a05:6870:9725:b0:254:9ba7:488b with SMTP id 586e51a60fabf-25842ba524dmr11130088fac.40.1718642015158; Mon, 17 Jun 2024 09:33:35 -0700 (PDT) MIME-Version: 1.0 References: <7efde25f-6af5-4a67-abea-b26732a8aca1@paulmck-laptop> In-Reply-To: From: "Jason A. Donenfeld" Date: Mon, 17 Jun 2024 18:33:23 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 00/14] replace call_rcu by kfree_rcu for simple kmem_cache_free callback To: Uladzislau Rezki Cc: "Paul E. McKenney" , Vlastimil Babka , Jakub Kicinski , Julia Lawall , linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org, bridge@lists.linux.dev, linux-trace-kernel@vger.kernel.org, Mathieu Desnoyers , kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Naveen N. Rao" , Christophe Leroy , Nicholas Piggin , netdev@vger.kernel.org, wireguard@lists.zx2c4.com, linux-kernel@vger.kernel.org, ecryptfs@vger.kernel.org, Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , linux-nfs@vger.kernel.org, linux-can@vger.kernel.org, Lai Jiangshan , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: wireguard@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: wireguard-bounces@lists.zx2c4.com Sender: "WireGuard" On Mon, Jun 17, 2024 at 6:30=E2=80=AFPM Uladzislau Rezki = wrote: > Here if an "err" is less then "0" means there are still objects > whereas "is_destroyed" is set to "true" which is not correlated > with a comment: > > "Destruction happens when no objects" The comment is just poorly written. But the logic of the code is right. > > > out_unlock: > > mutex_unlock(&slab_mutex); > > cpus_read_unlock(); > > diff --git a/mm/slub.c b/mm/slub.c > > index 1373ac365a46..7db8fe90a323 100644 > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -4510,6 +4510,8 @@ void kmem_cache_free(struct kmem_cache *s, void *= x) > > return; > > trace_kmem_cache_free(_RET_IP_, x, s); > > slab_free(s, virt_to_slab(x), x, _RET_IP_); > > + if (s->is_destroyed) > > + kmem_cache_destroy(s); > > } > > EXPORT_SYMBOL(kmem_cache_free); > > > > @@ -5342,9 +5344,6 @@ static void free_partial(struct kmem_cache *s, st= ruct kmem_cache_node *n) > > if (!slab->inuse) { > > remove_partial(n, slab); > > list_add(&slab->slab_list, &discard); > > - } else { > > - list_slab_objects(s, slab, > > - "Objects remaining in %s on __kmem_cache_shutdo= wn()"); > > } > > } > > spin_unlock_irq(&n->list_lock); > > > Anyway it looks like it was not welcome to do it in the kmem_cache_free() > function due to performance reason. "was not welcome" - Vlastimil mentioned *potential* performance concerns before I posted this. I suspect he might have a different view now, maybe? Vlastimil, this is just checking a boolean (which could be unlikely()'d), which should have pretty minimal overhead. Is that alright with you? Jason