Received: by 10.213.65.68 with SMTP id h4csp90384imn; Tue, 27 Mar 2018 17:18:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx48cqaGkQheAy/0DjSMSx9xUaSGvBPWx/hxnypTETcXVenZJwTskjDbuWlkyTt3SAs+mibR3 X-Received: by 10.99.97.16 with SMTP id v16mr970606pgb.104.1522196327688; Tue, 27 Mar 2018 17:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522196327; cv=none; d=google.com; s=arc-20160816; b=MJXsFL88ucfBYS1FuNigb8Eo8KNGw9DkKa/RYbYTr7V5pJDhocUTnhQnsDJiCKI/pM 7gEBsxYt8syZ3g8qOO3am69OtQMseZzuJFtjy96EzvoJqZ4upAAq39VhEPP6aZB131XW xostGDdhJ+OHg5yt0sbJasJCiFnH0PFsz8oqv6crccktLUFUhxTozqDS/RXl+vBrfphG u4fkEhwz6y4mabOr9cgDoEmQIfs5hHmy3ZKkKGCe2qLEMgxd3kuw4OKxc7+mzWwQRj5x 8F7w+lv/QruNj/po4AxDI4qu1Pg23NMuJHQzsCQ5KqSRkQErRn4KXlAakRc21V7L7jN6 kykw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=EwG0oKNMoR8lQqPN+gqJkQY7ind7M+x9GtGkq6qeYoE=; b=uNJShjFH9X6s8bOnKj63KSzzwP7ICa4eTsCO7dhakDgbemEfoUOrpvhJN1GJ9ZA7vE P57Eibh270bEm+dLhVaBDDVxhQZFNQ/lABarJjG1/IuSFswSVbi5KIqqrqmEI/AftkTO 0kIZoKjY8cS6qH64h091DxUEbkLRJMfIvsyzbwGiy0nNbcUUo9jbElm1/yhHBvLVtJhm APuwUSjFQcCzdgJHtEiiCWrKs96Upgfm4URa+Q+qorNj37eGsfI5sHHlJW7r7IdJ5MXz ah+O7nP6+/T+79pgDIFk1uRMoMtzqWNBK93UglszuYA2rNLkmaxz6vk5GjWyWIPNuufw O8mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aIQ2fCTf; 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 91-v6si2456990pld.396.2018.03.27.17.18.23; Tue, 27 Mar 2018 17:18:47 -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=aIQ2fCTf; 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 S1752453AbeC1ARD (ORCPT + 99 others); Tue, 27 Mar 2018 20:17:03 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34902 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752130AbeC1ARB (ORCPT ); Tue, 27 Mar 2018 20:17:01 -0400 Received: by mail-pf0-f195.google.com with SMTP id u86so291428pfd.2 for ; Tue, 27 Mar 2018 17:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=EwG0oKNMoR8lQqPN+gqJkQY7ind7M+x9GtGkq6qeYoE=; b=aIQ2fCTf64YWvWP3WgtBUFuq6NVUmmkF5LQwBhejOzX72ushBzeryboRhU+qJ4F+uN lQ90zbmL/VAId8+OKhMh1B4DrXbz2NIwOtilx89UUzs1cTwcI9a9q9GB+cvPu500Sqm7 bQKWiqwc4vfLYVdAbTwQCSju1mXrt9ZbUIV0LO9Brq8XDMaoskghhCNgeZsZIgmsWt2S eOdDEog6SH527VqFQDnW3BrNRlr6WNoMOQkCTkmM+kK2jPUGTKGrw04RWn69Kn+mCYZL zrw6aUfYZjy3hBmPmgvC4Mg+++Or6E5d05b9mmJ74RKJ1PIWUo8itLlNyEsubB8+iVmm YC/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=EwG0oKNMoR8lQqPN+gqJkQY7ind7M+x9GtGkq6qeYoE=; b=Pe1RmoBXsVqWOjL4GnhPA9Gx7rkffhW6U9I8+PoZhp33jNrWuGUPJfDWvu8PbuI1zX io0vKlbD8aqJJ0nSXOzTSSlywjj7rh9O2XKHOYmooawvCfYEGkPRAmcfToumntuEkcd7 7rZlCsIOTUoPPxrOfleY5Ttcra1H+iO5xEeMryCymvdT5ZFLNptlJMQ/NSMrRCEZZzN3 0Xx2B2FE9+/M8xM75kP0HL+iQIq/Whfs1LRKIsfNTNLzKb7rFI8xNBpsryncpCimdJoD 9Uy2pMzlSnH08h9b3vHK/c1Nvn1pDdc1RDnYv0SUb/OizM7jRpiUGYDjpAZIpqwjApao K+0Q== X-Gm-Message-State: AElRT7EFeUrW78BPot+Yj6JzQcDzH+iymrztEoCVGAVHbAmIsH8C/GdO xmYaUpHEg1fPuuXVqmwHFw4CwQ== X-Received: by 10.98.29.145 with SMTP id d139mr1063885pfd.165.1522196220693; Tue, 27 Mar 2018 17:17:00 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id a28sm4058009pgd.38.2018.03.27.17.16.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 17:16:59 -0700 (PDT) Date: Tue, 27 Mar 2018 17:16:59 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Shakeel Butt cc: Andrey Ryabinin , Vladimir Davydov , Alexander Potapenko , Greg Thelen , Dmitry Vyukov , Christoph Lameter , Pekka Enberg , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] slab, slub: skip unnecessary kasan_cache_shutdown() In-Reply-To: <20180327230603.54721-1-shakeelb@google.com> Message-ID: References: <20180327230603.54721-1-shakeelb@google.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Mar 2018, Shakeel Butt wrote: > diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c > index 49fffb0ca83b..135ce2838c89 100644 > --- a/mm/kasan/kasan.c > +++ b/mm/kasan/kasan.c > @@ -382,7 +382,8 @@ void kasan_cache_shrink(struct kmem_cache *cache) > > void kasan_cache_shutdown(struct kmem_cache *cache) > { > - quarantine_remove_cache(cache); > + if (!__kmem_cache_empty(cache)) > + quarantine_remove_cache(cache); > } > > size_t kasan_metadata_size(struct kmem_cache *cache) > diff --git a/mm/slab.c b/mm/slab.c > index 9212c64bb705..b59f2cdf28d1 100644 > --- a/mm/slab.c > +++ b/mm/slab.c > @@ -2291,6 +2291,18 @@ static int drain_freelist(struct kmem_cache *cache, > return nr_freed; > } > > +bool __kmem_cache_empty(struct kmem_cache *s) > +{ > + int node; > + struct kmem_cache_node *n; > + > + for_each_kmem_cache_node(s, node, n) > + if (!list_empty(&n->slabs_full) || > + !list_empty(&n->slabs_partial)) > + return false; > + return true; > +} > + > int __kmem_cache_shrink(struct kmem_cache *cachep) > { > int ret = 0; > diff --git a/mm/slab.h b/mm/slab.h > index e8981e811c45..68bdf498da3b 100644 > --- a/mm/slab.h > +++ b/mm/slab.h > @@ -166,6 +166,7 @@ static inline slab_flags_t kmem_cache_flags(unsigned int object_size, > SLAB_TEMPORARY | \ > SLAB_ACCOUNT) > > +bool __kmem_cache_empty(struct kmem_cache *); > int __kmem_cache_shutdown(struct kmem_cache *); > void __kmem_cache_release(struct kmem_cache *); > int __kmem_cache_shrink(struct kmem_cache *); > diff --git a/mm/slub.c b/mm/slub.c > index 1edc8d97c862..44aa7847324a 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -3707,6 +3707,17 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) > discard_slab(s, page); > } > > +bool __kmem_cache_empty(struct kmem_cache *s) > +{ > + int node; > + struct kmem_cache_node *n; > + > + for_each_kmem_cache_node(s, node, n) > + if (n->nr_partial || slabs_node(s, node)) > + return false; > + return true; > +} > + > /* > * Release all resources used by a slab cache. > */ Any reason not to just make quarantine_remove_cache() part of __kmem_cache_shutdown() instead of duplicating its logic?