From patchwork Tue Oct 17 15:44:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13425537 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 298C3CDB483 for ; Tue, 17 Oct 2023 15:45:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D9636B0246; Tue, 17 Oct 2023 11:45:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 988C36B0248; Tue, 17 Oct 2023 11:45:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82AA66B0249; Tue, 17 Oct 2023 11:45:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 72D5E6B0246 for ; Tue, 17 Oct 2023 11:45:26 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 52ACEA0D63 for ; Tue, 17 Oct 2023 15:45:26 +0000 (UTC) X-FDA: 81355377852.21.0401BCA Received: from out-198.mta1.migadu.com (out-198.mta1.migadu.com [95.215.58.198]) by imf29.hostedemail.com (Postfix) with ESMTP id A5E4312002E for ; Tue, 17 Oct 2023 15:45:23 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=DaAtiZgQ; spf=pass (imf29.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.198 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697557523; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uepMlN8KtJ2YuJ4CH70+gbxhj8qnD/tT1k7NrYZtVVI=; b=qIAuJD4MiIx9MwdOevnuW4I++DeK8KWHifJ1+pEW1IOsi4pEp/Pxs3tOI1ND3fyX9lwcCQ 28FEaJgjVsRKyF2ikbTej7oBy+a7VhpNZTR7oADhm2G0GX7IB5egn1Zc8KZ9REcgNVyksp HikK8ecMzVqaZwlaQUMxYX4G0h0hEDk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697557523; a=rsa-sha256; cv=none; b=aAe3Ng/JAFIH4VARTHUJGfMF17z1r24ullqtkiWmpVDGwHAMBzLyr/fpeOZ6CG2ybsLzrO Sd9DcGLn7koQeP0Jq0LCqngd1juZibyh+itD0tjx/W1X7uLpxTcHi8EoCtINPlTWCmm+wx Aagk8g6XeKgGNTXg2ROqP0z2vRYitiQ= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=DaAtiZgQ; spf=pass (imf29.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.198 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1697557522; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uepMlN8KtJ2YuJ4CH70+gbxhj8qnD/tT1k7NrYZtVVI=; b=DaAtiZgQCtDa1rxPzHIgjJc4DIjqm3myRMfLOwX9HUwVK+3r/TPToUXQkLJLfTM7KtEz6X P6rFQUmudCXJ4U+y638uzl0+mFMh4ihgvECPrJJA2ZQUJxMrCtLFiczP96D5Kt+GJmG0g9 TeH5WidQi5s+QCvlDqd5nD8QeqE0pNc= From: chengming.zhou@linux.dev To: cl@linux.com, penberg@kernel.org Cc: rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengming.zhou@linux.dev, Chengming Zhou Subject: [RFC PATCH 2/5] slub: Don't manipulate slab list when used by cpu Date: Tue, 17 Oct 2023 15:44:36 +0000 Message-Id: <20231017154439.3036608-3-chengming.zhou@linux.dev> In-Reply-To: <20231017154439.3036608-1-chengming.zhou@linux.dev> References: <20231017154439.3036608-1-chengming.zhou@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: d9kyayha7ff5gm6bibon4x5m1i8xpej1 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A5E4312002E X-Rspam-User: X-HE-Tag: 1697557523-177182 X-HE-Meta: U2FsdGVkX18QXKt5pIsw1A5Hkeqji71joy01Qa+HU50w4noGI/rZQ2zL2SkZ8Kk2RRzDRvckrDa0oCYpo1/w4CR1UFVWdWOQ75zk3YVdGvmlhdXjkN2PJ2/7DuSFaDctO/4+XB6O0ApvDbz1DPhpzr2PTUatZi+kgZloi1IyvjA8lg+/SIXYBjU2gAE92pOyZ1s/rI/u8pA6k1NbHc1cyY0t4y8FwkFGYh08/JX+4iQeL9hzIY421pRmiHe6oxM5aYF4LBMJVik8/mW96UINXrcZfZo4gcG9ZIahQfamS9G3MBMASZ96Ir9cYFXyRph2aMtmScZPURbsvPwI3kv5SfECwxvoSRXBoaVnKNPkeJIkt4KPKWEYIHKeCrwOKok+6NRWBZoY3tbmuTNYUfGtF3CP32C2R8QTnumi+OLTapdeyA7Yjdz0vrMAyN5LfbQ6LUauKXSEvVeea56yNkMfMZeXlhS6GFmt5bZQzozEz6qboWSdyU5OUA91CWgo0sRz7MRMUax9bcoZD9Xx6WotchTM2Gx0qK4Ebpw40i1C9HXBTYaa1/zxVBu/a9ejt3DTkP1ePVaMcGsMH1HupG+rUbJhN30Tsjiva1TPNJTUNhqOXj0kwEkhdxlfbOwBSGkneNAqIpnjVtt+wOqza8GQEJEHYohpHgQhBaNSjNWswFoWyihvPeugYuKfVEtTM7iwhrCnD+LOEi2wx2dX3WWckqcdCSWLIc+GyV46gQrst0JwIH/D5Ooxts5+B6x4CjRTDsiI4vrkfS9N8nIxjSoOwMHczY+4K99V2C2+w4smHG8J+QsK3RY+69re2/OEMD6TN0WQYq1Tt1IJWFZa/+bVfNN314bfDX0rjmElyFno2QG0uIMdqkvFt27eFf3a97uGDeJxDV37JrdlMivQC5VHke+HEyljv7dHQMVJNUM9+DeVUH0Smh0zod5HmRz+BzzdeC4HsEZ4VVDG53nxrqi +G7CgFvH SNXNclNoJVU+PD19MIVBtJqk4DDduXA09MoPp/KKrAQO0Bqy5vUMig4tgfYZ+b6XDK1gUtyiJPft+nzusVPXyJx3OIEQHqyhbHoiNS27VMw1LO83voELuvDJAceqh+qE0aMFdJKhBIUa3yedQHW7VuIpx4sk3cLScwKNZ39TbEaZCo35ZmMeeSdTwk619yWuTRz6geDSiTRaGKkE= 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: From: Chengming Zhou We will change to don't freeze slab when moving it out of node partial list in the following patch, so we can't rely on the frozen bit to indicate if we should manipulate the slab list or not. This patch use the introduced on_partial() helper, which check the slab->flags that protected by node list_lock, so we can know if the slab is on the node partial list. Signed-off-by: Chengming Zhou --- mm/slub.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index e5356ad14951..27eac93baa13 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3636,6 +3636,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab, unsigned long counters; struct kmem_cache_node *n = NULL; unsigned long flags; + bool on_node_partial; stat(s, FREE_SLOWPATH); @@ -3683,6 +3684,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab, */ spin_lock_irqsave(&n->list_lock, flags); + on_node_partial = on_partial(n, slab); } } @@ -3711,6 +3713,15 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab, return; } + /* + * This slab was not on node partial list and not full either, + * in which case we shouldn't manipulate its list, early return. + */ + if (!on_node_partial && prior) { + spin_unlock_irqrestore(&n->list_lock, flags); + return; + } + if (unlikely(!new.inuse && n->nr_partial >= s->min_partial)) goto slab_empty;