Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp167479imm; Tue, 19 Jun 2018 18:27:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIQa+C8XfnYCUnilL/Cx4k3MGv/XO7Vt5XzS8/HNHAFM/erqEAXyrYslqv4jWUP0jpn+yKw X-Received: by 2002:a17:902:7009:: with SMTP id y9-v6mr21205432plk.217.1529458023680; Tue, 19 Jun 2018 18:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529458023; cv=none; d=google.com; s=arc-20160816; b=t3u3Z3HVtNpnxtO/BkCFs5ppaw9NU/tWxHoFjzi2KwvmuqpE7ul3iVAjAhWP2qFgLk sUyDbGnFI+V9TX/qgj0t7/+juF8O/BcSYgfi7vZFdcydp7dQmXJCeR1OTh0zyMMoPNz0 sDnN0B15plZdYme/7aIn/87nElFNhM0iThItqiZcnyMLESnE9r3MwmOVTltfoiYDFfhn YTqsE3s6c3szEU2P1muZ505Uy5O1jEyoP08SqKXm0EubMFWqfnOVE/1LEFMNzxKWs8h6 sRZcSkBqEBPB+Uk0OI+JUo+/Zg/XOroNiJELKRWdDXVJeeBv/MMd+GkLs9wJLTCtk3c4 YQwA== 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=SBNOy/WkQTQB5iEfr6BkcMUw1BWpxRZj8da7nWaCGyU=; b=nhVyxVi5raCzmdhITiU8S97PzHMjnZwqhgQvyLa1RSVxYLxCs+jC1ipGYy6hvK1g7+ DYDTCAoW+fYu5EuaDaJo17/UpP1H/35XWC1/Hyn3nwStYtj3cGmGOyIfpIoKSWb9qAGj U6QVFtbvy2Frspa5+2hLZYTJ3FNLf6dz3JRDkap3V4GQtQY6kvzPj31s5934+pKFR9+U EVnvUey34pE5HFr6hr20M/IbEQvqJeun7cpdfAxTs3fa0tRJazjQk2vaBBVejf8vOpnW VldE/Di3AahQUBLWiGpa09vbkmSplo5ZsmK0U3NovlqRlZUaoKwDS8msaB+X7SjQtNE7 LUSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bScAigkG; 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 i88-v6si1075980pfa.219.2018.06.19.18.26.49; Tue, 19 Jun 2018 18:27:03 -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=bScAigkG; 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 S1754093AbeFTBYs (ORCPT + 99 others); Tue, 19 Jun 2018 21:24:48 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40059 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753995AbeFTBYq (ORCPT ); Tue, 19 Jun 2018 21:24:46 -0400 Received: by mail-wm0-f68.google.com with SMTP id n5-v6so3657548wmc.5 for ; Tue, 19 Jun 2018 18:24:45 -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=SBNOy/WkQTQB5iEfr6BkcMUw1BWpxRZj8da7nWaCGyU=; b=bScAigkGH2QLWE0CcTsg6Ht8QhLXJ8OdlmQg1kTNZurqk6rkLWTn8tnuoTjT+TAwJZ IGKb6yVUt5h/QhWko8GBzibdIlyamWJOFamSjFoZajxANfc7C9d/ErrIDJTUCMFbdioz dobCFWx9DpXok36S8GO6rs14bgsOnRHonSHBpsnIM6pKAh+WqcD82MK98pkGDsnaa/wm W3IMxRRDfHPSjEb1EvV/2eloqbInrmeZNJJBH7syQGIMG/QC2ZzjQ4mp4HZOwzkC/mRC Dj5gd8ZybKtqo3fLK83mMrkF/KsZvEYOSyon70hSaLYiG5L0w0jVvsnAtapMNZUzWUvs AMsA== 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=SBNOy/WkQTQB5iEfr6BkcMUw1BWpxRZj8da7nWaCGyU=; b=pSwLeoopwdClPlOS9x9wKPS4QuEzdNMDwCVtssbc6TiUXy9DicMaXy33e1TzAHzoNk EI83QVBr12E9JwqZZ+d1heIceAsTGIG0oPxeEarQ+95wsNSY9E/2Gm9kco09TWgEXYW6 ATAs9u8YPOuZi6Bi3fSl3WtXPep2KmGaRNASoqPPdBWI6uJhjq76qaI/ThlfO4OQHGkC jm7yMZXXprfN8ZpwIsMUvKEUgKoeW6+NbsQtqXMIzeaRG5SFERpocGi6L7pnK62U8Kgx ETdSmpAUkKPJolSVzTqK3RsLG4QmCeS4yIRwniKbYzMTp5qvYnKCB2QTd0daWtrq+kqA 8Fhg== X-Gm-Message-State: APt69E3BPO081I48BOf7MLkwhM5Q9vrNdCL5avp1QTf7RrlmBgsjhk+r UdsXtcnarxer3Ci0XWE9bp5XB2uJU6GJB9XV/mFYQA== X-Received: by 2002:a1c:1c8f:: with SMTP id c137-v6mr20765wmc.142.1529457884924; Tue, 19 Jun 2018 18:24:44 -0700 (PDT) MIME-Version: 1.0 References: <20180619213352.71740-1-shakeelb@google.com> In-Reply-To: From: Shakeel Butt Date: Tue, 19 Jun 2018 18:24:32 -0700 Message-ID: Subject: Re: [PATCH] slub: fix __kmem_cache_empty for !CONFIG_SLUB_DEBUG To: David Rientjes Cc: Jason@zx2c4.com, Linux MM , LKML , Christoph Lameter , Pekka Enberg , 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 5:49 PM David Rientjes wrote: > > On Tue, 19 Jun 2018, Shakeel Butt wrote: > > > 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; > > Nit: wouldn't cpu be unused if CONFIG_SLUB_DEBUG is disabled? > I think I didn't get the warning as I didn't use #ifdef. > > 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; > > Wouldn't it just be better to allow {inc,dec}_slabs_node() to adjust the > nr_slabs counter instead of doing the per-cpu iteration on every shutdown? Yes that is doable as the functions {inc,dec}_slabs_node() are called in slow path. I can move them out of CONFIG_SLUB_DEBUG. I think the reason 0f389ec63077 ("slub: No need for per node slab counters if !SLUB_DEBUG") put them under CONFIG_SLUB_DEBUG is because these counters were only read through sysfs API which were disabled on !CONFIG_SLUB_DEBUG. However we have a usecase other than sysfs API. Please let me know if there is any objection to this conversion. For large machines I think this is preferable approach. thanks, Shakeel