From patchwork Thu Sep 3 19:24:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Lameter X-Patchwork-Id: 32902 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 00508B70B3 for ; Fri, 4 Sep 2009 03:08:29 +1000 (EST) Received: by ozlabs.org (Postfix) id E318FDDD04; Fri, 4 Sep 2009 03:08:29 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 74CF9DDD01 for ; Fri, 4 Sep 2009 03:08:29 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756039AbZICRHh (ORCPT ); Thu, 3 Sep 2009 13:07:37 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756021AbZICRHg (ORCPT ); Thu, 3 Sep 2009 13:07:36 -0400 Received: from smtp2.ultrahosting.com ([74.213.174.253]:55009 "EHLO smtp.ultrahosting.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752640AbZICRHf (ORCPT ); Thu, 3 Sep 2009 13:07:35 -0400 Received: from localhost (smtp.ultrahosting.com [127.0.0.1]) by smtp.ultrahosting.com (Postfix) with ESMTP id CB6EE700CEC; Thu, 3 Sep 2009 13:09:19 -0400 (EDT) X-Virus-Scanned: amavisd-new at ultrahosting.com Received: from smtp.ultrahosting.com ([74.213.174.253]) by localhost (smtp.ultrahosting.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A0mByz66ZF6P; Thu, 3 Sep 2009 13:09:19 -0400 (EDT) Received: from V090114053VZO-1 (unknown [74.213.171.31]) by smtp.ultrahosting.com (Postfix) with ESMTP id 2CB6F82D209; Thu, 3 Sep 2009 11:27:32 -0400 (EDT) Received: from cl (helo=localhost) by V090114053VZO-1 with local-esmtp (Exim 4.69) (envelope-from ) id 1MjHur-00039n-PM; Thu, 03 Sep 2009 14:24:17 -0500 Date: Thu, 3 Sep 2009 14:24:17 -0500 (CDT) From: Christoph Lameter X-X-Sender: cl@V090114053VZO-1 To: Eric Dumazet cc: Pekka Enberg , Zdenek Kabelac , Patrick McHardy , Robin Holt , Linux Kernel Mailing List , Jesper Dangaard Brouer , Linux Netdev List , Netfilter Developers , paulmck@linux.vnet.ibm.com Subject: Re: [PATCH] slub: fix slab_pad_check() In-Reply-To: <4A9FDA72.8060001@gmail.com> Message-ID: References: <4A87CE60.4020506@gmail.com> <4A896324.3040104@trash.net> <4A9EEF07.5070800@gmail.com> <4A9F1620.2080105@gmail.com> <84144f020909022331x2b275aa5n428f88670e0ae8bc@mail.gmail.com> <4A9F7283.1090306@gmail.com> <4A9FCDC6.3060003@gmail.com> <4A9FDA72.8060001@gmail.com> User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, 3 Sep 2009, Eric Dumazet wrote: > Point is we cannot deal with RCU quietness before disposing the slab cache, > (if SLAB_DESTROY_BY_RCU was set on the cache) since this disposing *will* > make call_rcu() calls when a full slab is freed/purged. There is no need to do call_rcu calls for frees at that point since objects are no longer in use. We could simply disable SLAB_DESTROY_BY_RCU for the final clearing of caches. > And when RCU grace period is elapsed, the callback *will* need access to > the cache we want to dismantle. Better to not have kfreed()/poisoned it... But going through the RCU period is pointless since no user of the cache remains. > I believe you mix two RCU uses here. > > 1) The one we all know, is use normal caches (!SLAB_DESTROY_BY_RCU) > (or kmalloc()), and use call_rcu(... kfree_something) > > In this case, you are 100% right that the subsystem itself has > to call rcu_barrier() (or respect whatever self-synchro) itself, > before calling kmem_cache_destroy() > > 2) The SLAB_DESTROY_BY_RCU one. > > Part of cache dismantle needs to call rcu_barrier() itself. > Caller doesnt have to use rcu_barrier(). It would be a waste of time, > as kmem_cache_destroy() will refill rcu wait queues with its own stuff. The dismantling does not need RCU since there are no operations on the objects in progress. So simply switch DESTROY_BY_RCU off for close. --- mm/slub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2009-09-03 10:14:51.000000000 -0500 +++ linux-2.6/mm/slub.c 2009-09-03 10:18:32.000000000 -0500 @@ -2594,9 +2594,9 @@ static inline int kmem_cache_close(struc */ void kmem_cache_destroy(struct kmem_cache *s) { - if (s->flags & SLAB_DESTROY_BY_RCU) - rcu_barrier(); down_write(&slub_lock); + /* Stop deferring frees so that we can immediately free structures */ + s->flags &= ~SLAB_DESTROY_BY_RCU; s->refcount--; if (!s->refcount) { list_del(&s->list);