Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp485imm; Tue, 19 Jun 2018 14:41:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL+FuVsT1iHnmFdjfEV++g5427PE2VIt4jUdeulNGV5/Awuub+4FcbRP/ZE7caJ96G5SY44 X-Received: by 2002:a17:902:205:: with SMTP id 5-v6mr20453495plc.301.1529444500749; Tue, 19 Jun 2018 14:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529444500; cv=none; d=google.com; s=arc-20160816; b=KeYxtQTcyoOywsH/K5SLIgj91H/ZvKXhoTMOOIh8wf5jE7jvQCD15zYD4lxBwCSSdu jZ5dHpKo3tOMxldsWBxVGaDYU3u8pIUqxfrGoQr2fjvXx2FBdYFzY7IWK9kZODvGG4vE 2QHRcX7Cj/+lZGW5QFq+mIm98oiEtH1Os/Px57jafCliXDQHusU94Pb09ronUWGjUX4X JReH7TbfJ9Zsk/ILYNEQpJpw0b3c4KRKpD34B677KIcVKohe5i1dc7yhz5Pq+kJuXdJ7 abCbzTBOXXDoH5OKhsRC366vL6Ej1Bn8gvV/QBE59+FkGI2rG/Wq97uShwPDg2F6jBz+ 6C9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=2F0jI+CA6cfoLi4EbDtVyIGjIAX/atVlgLdOJ64bNUI=; b=Kn1Bd9tpxv9v77BmJfCJ5687L1UJFhLDE/GR1uF64VEoBlBHd5nQ5WerNqNNgbz7FK G98pfNIWGgyy7wde9yDkI3YltnGemTA92Z37si8AQbnjzGDRrZlpivw8iPuAhkw5kncK Vcxuqo3q8yfkflOfFqzwfRv80iwJUARNHo/9cmQ8OLaMx+PMTJ6G4NjvDp9Kc08n0YCi eSUjfMNu6QPp+wEWIAeGTeqUrq7l1Lun58zGt4n3wLTT9WcynY1sjDIeJVOms3YtDAir Ghol4BZLAg1aOqRACnY7qFVyNav0xl2Bob8V1A7loi8dw/GJ3VYUYfJ/aAm6du2vtoJH /g6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ntoh8smW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g194-v6si644233pfb.280.2018.06.19.14.41.13; Tue, 19 Jun 2018 14:41:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ntoh8smW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937576AbeFSViZ (ORCPT + 99 others); Tue, 19 Jun 2018 17:38:25 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:34331 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937365AbeFSViW (ORCPT ); Tue, 19 Jun 2018 17:38:22 -0400 Received: by mail-wr0-f195.google.com with SMTP id a12-v6so1130982wro.1 for ; Tue, 19 Jun 2018 14:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2F0jI+CA6cfoLi4EbDtVyIGjIAX/atVlgLdOJ64bNUI=; b=ntoh8smWqSHmEJvId/rii4PgTkSd0p+m5yQlFVC1Yox3WSVt+lU9Kiv5M8Rd2KIomJ jynJrNfNaDJ/P3nROCxPSGJYXgdGaCsy9daCA6gOTxSYNVqkmDTuvk1I2xR0ScgGqPjD Sfy4Matw/vvcSOU3N1Aks2yjRniTuDIabU+GT2tphv7ZicupGzdXcQkJ2VbN9VQPF38t sKfo2XFaSuc+bgGqgHTGTLhkFSFbdfrs08I/YRvVOMKSuCgX/7U6T4x4mNgRMaQ9KAZ2 FahdOHR1k3Oeh/KSRtLlYQAVZDS3TMFxaNbgQOb9sMlB8bWtu6CGwAKOsj+ZARlNiX6B QJ9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2F0jI+CA6cfoLi4EbDtVyIGjIAX/atVlgLdOJ64bNUI=; b=sYYVjQRz8HF/JKjAaRI+WZWphkgKgKxRTNtN/UTdE4iJ19XLg34IGUv3bvOAi83bzH VRHrGereoFiMroNuWu1ECz/pyWkE57jPumu6wvoTZYkluJWQs1RXgiUVVpiPVrZB2EpA 8QMX9fEmzeH9CbXbxqk+gj+McUid14zhnmFcineA/XL9BAUP6vrV+yA2YSGeu97/BGaD oOQnE1EuBazznxpBMGxFdxk7akBkNX1t8usvhbCFrfwp5LghhEeLtZ0/x4jqDQ8jmxGY mKuCCqBR0dLL2+lv7prAqIT3dQy/tlfGwlpQgW5+j9Noq27z6DFzOkqG3GaAlqOlBeUb WnGw== X-Gm-Message-State: APt69E25vvlFvPEQnXqb6/KxeNWSY4P/N/cSNia15ubhwXecQdSwFz78 EC1gQ0le+2DXQe2r6iyGmBlREUdAlT7zpaoL42cBPw== X-Received: by 2002:adf:dd03:: with SMTP id a3-v6mr16378212wrm.2.1529444300536; Tue, 19 Jun 2018 14:38:20 -0700 (PDT) MIME-Version: 1.0 References: <20180619213352.71740-1-shakeelb@google.com> In-Reply-To: <20180619213352.71740-1-shakeelb@google.com> From: Shakeel Butt Date: Tue, 19 Jun 2018 14:38:08 -0700 Message-ID: Subject: Re: [PATCH] slub: fix __kmem_cache_empty for !CONFIG_SLUB_DEBUG To: Jason@zx2c4.com, Andrey Ryabinin Cc: Linux MM , LKML , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 19, 2018 at 2:33 PM Shakeel Butt wrote: > > For !CONFIG_SLUB_DEBUG, SLUB does not maintain the number of slabs > allocated per node for a kmem_cache. Thus, slabs_node() in > __kmem_cache_empty() will always return 0. So, in such situation, it is > required to check per-cpu slabs to make sure if a kmem_cache is empty or > not. > > Please note that __kmem_cache_shutdown() and __kmem_cache_shrink() are > not affected by !CONFIG_SLUB_DEBUG as they call flush_all() to clear > per-cpu slabs. > > Fixes: f9e13c0a5a33 ("slab, slub: skip unnecessary kasan_cache_shutdown()") > Signed-off-by: Shakeel Butt > Reported-by: Jason A . Donenfeld > Cc: Christoph Lameter > Cc: Pekka Enberg > Cc: David Rientjes > Cc: Joonsoo Kim > Cc: Andrew Morton > Cc: Forgot to Cc: Andrey Ryabinin > --- > mm/slub.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/mm/slub.c b/mm/slub.c > index a3b8467c14af..731c02b371ae 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -3673,9 +3673,23 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) > > bool __kmem_cache_empty(struct kmem_cache *s) > { > - int node; > + int cpu, node; > struct kmem_cache_node *n; > > + /* > + * slabs_node will always be 0 for !CONFIG_SLUB_DEBUG. So, manually > + * check slabs for all cpus. > + */ > + if (!IS_ENABLED(CONFIG_SLUB_DEBUG)) { > + for_each_online_cpu(cpu) { > + struct kmem_cache_cpu *c; > + > + c = per_cpu_ptr(s->cpu_slab, cpu); > + if (c->page || slub_percpu_partial(c)) > + return false; > + } > + } > + > for_each_kmem_cache_node(s, node, n) > if (n->nr_partial || slabs_node(s, node)) > return false; > -- > 2.18.0.rc1.244.gcf134e6275-goog >