Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp12496imm; Tue, 19 Jun 2018 14:56:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIgwFH+zR1ZX8lznBouek6PeRoKx/pREqjOsAt0QkCPdR9sfbXrjkHDDtVRWkYk3VioEH9L X-Received: by 2002:a63:a84f:: with SMTP id i15-v6mr16843218pgp.422.1529445416181; Tue, 19 Jun 2018 14:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529445416; cv=none; d=google.com; s=arc-20160816; b=rLuf67e0LiOLS2zUmCqx+2eFHpum+OBYpRsSkO4qDaMPMjV5pJCRc1Yj6DgLMGVYmc fKkMcqf0QIqnOxNIAVk2EsNdL9N0AL8F5WnisF+8gAfp9vEP1itblrqSzeu0ITEobMNf X4MmbjNY5nw0bMC9V75PmqOEhUJ4HDF5aQ793WbQvvoD92AtNQOBtREjhiLnryf+xOql 7Ytsum/NfYrkqXW19t5u+oF+8glHrL9syB0vywbPi58rxiqVpp7RtEEvlP64CT4kxL2K /LSHE4elHpfylsfYrlke4K4x+MWYlSsq+Ti7R1ohA6Vm0KCjf9ev3FKoPZATwSidjSfC 4DAg== 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=73idqDN0er2+cvDE02i/r1NByk3NqGEEPA3BjMv04sE=; b=cR+OwacxJ+J/vCyBm1KzHtRcG3r5o7G1YgGpdTGIi51F00qiLti5nQpqug56xBUMBh HEvB4Wd39NhGId5HA7sGLw0g4ZxKUo4EsYY1czdL1UXo6/a8qmee0u6xOEK4J6JwrDe+ GGylFtHD9mV9SqyBEj1MTXGBix/yLH38je8tkQTslGCvCcfg2jB4L0PoSoCRV5P/zN89 qtEVz0AJYpvzkL/OwrIAGZaJmcPwTc9FVWmmgyUVXlI+WcTwCDWr9Hui3l13xM+aSQVY dI5mYjOM3h5tSb4gUkc7yLWh0rTHFk5POS9E5mr9kkQL2qucLDcTYRGe7gus1iOPm/IR sCNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=vfG6zq4M; 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=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y20-v6si639010plp.267.2018.06.19.14.56.41; Tue, 19 Jun 2018 14:56:56 -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=@zx2c4.com header.s=mail header.b=vfG6zq4M; 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=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967261AbeFSVyN (ORCPT + 99 others); Tue, 19 Jun 2018 17:54:13 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:34287 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935912AbeFSVyK (ORCPT ); Tue, 19 Jun 2018 17:54:10 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 645aac03; Tue, 19 Jun 2018 21:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=eBHSgleS+pHQhgu3S2eYih1yzfo=; b=vfG6zq 4Mmyi0Sco7Lbn09eE8ksF2IplierVCReEF3VRad53LkRTxRgg5tdWzhLE94ncF7t PjiCWTp81ej70LKadRuH8Jdt/I2//7wQSDM/fULFWgp4IRArAmaj10cG0Dfe0vai ZoTlObLVwBE6XnrY9wUW86y1AKtPGWAi3aExQrXFq3nY3KQ4JyKBxsUeLPLM7/LH M4Q5ZV4TIfkWYIZwsmKDwGAn9Rn1sVILH/1EuXe9DeV8UQF0wXzElO2kDsb+nCGz t2h/As23P9sk/prm9sVxjOex+K1eKY8+ai6eS96W75sMuHJiZUNauNhpNz1q6dtX MUKu20W4omllxihQ== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 75854957 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO); Tue, 19 Jun 2018 21:48:14 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id e8-v6so1185210oii.2; Tue, 19 Jun 2018 14:54:09 -0700 (PDT) X-Gm-Message-State: APt69E1Z27uv3u328XrBCmUMT/N++qIelXMakEw0MOo15PBPua19+eXc 8GD6+iv1Fx5EZxghMstkGy1ab6clMVcQMlvGnP8= X-Received: by 2002:aca:3048:: with SMTP id w69-v6mr9634688oiw.29.1529445248526; Tue, 19 Jun 2018 14:54:08 -0700 (PDT) MIME-Version: 1.0 References: <20180619213352.71740-1-shakeelb@google.com> In-Reply-To: <20180619213352.71740-1-shakeelb@google.com> From: "Jason A. Donenfeld" Date: Tue, 19 Jun 2018 23:53:57 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] slub: fix __kmem_cache_empty for !CONFIG_SLUB_DEBUG To: Shakeel Butt Cc: Linux-MM , LKML , cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, 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 11:34 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: > --- > 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 > I can confirm that this fixes the test case on build.wireguard.com.