Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756836AbbFPPmC (ORCPT ); Tue, 16 Jun 2015 11:42:02 -0400 Received: from smtprelay0220.hostedemail.com ([216.40.44.220]:40235 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752314AbbFPPl4 (ORCPT ); Tue, 16 Jun 2015 11:41:56 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::,RULES_HIT:41:355:379:541:599:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:3138:3139:3140:3141:3142:3354:3622:3865:3867:3868:3871:3872:3873:3874:4250:4321:4385:5007:6119:6261:7875:7903:9010:9040:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12294:12296:12438:12517:12519:12555:12740:13972:14096:14097:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: start30_2d6f15140df17 X-Filterd-Recvd-Size: 3864 Date: Tue, 16 Jun 2015 11:41:51 -0400 From: Steven Rostedt To: Daniel Wagner Cc: paulmck@linux.vnet.ibm.com, Alexei Starovoitov , Daniel Wagner , LKML Subject: Re: call_rcu from trace_preempt Message-ID: <20150616114151.3681a9e8@gandalf.local.home> In-Reply-To: <558018DD.1080701@monom.org> References: <557F509D.2000509@plumgrid.com> <20150615230702.GB3913@linux.vnet.ibm.com> <557F7764.5060707@plumgrid.com> <20150616021458.GE3913@linux.vnet.ibm.com> <557FB7E1.6080004@plumgrid.com> <20150616122733.GG3913@linux.vnet.ibm.com> <558018DD.1080701@monom.org> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2921 Lines: 110 On Tue, 16 Jun 2015 14:38:53 +0200 Daniel Wagner wrote: > diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c > index 83c209d..8d73be3 100644 > --- a/kernel/bpf/hashtab.c > +++ b/kernel/bpf/hashtab.c > @@ -13,6 +13,8 @@ > #include > #include > #include > +#include > +#include > > struct bpf_htab { > struct bpf_map map; > @@ -27,10 +29,14 @@ struct bpf_htab { > struct htab_elem { > struct hlist_node hash_node; > struct rcu_head rcu; > + struct list_head list; > u32 hash; > char key[0] __aligned(8); > }; > > +static LIST_HEAD(elem_freelist); > +static DEFINE_SPINLOCK(elem_freelist_lock); > + > /* Called from syscall */ > static struct bpf_map *htab_map_alloc(union bpf_attr *attr) > { > @@ -228,6 +234,7 @@ static int htab_map_update_elem(struct bpf_map *map, > void *key, void *value, > memcpy(l_new->key + round_up(key_size, 8), value, map->value_size); > > l_new->hash = htab_map_hash(l_new->key, key_size); > + INIT_LIST_HEAD(&l_new->list); > > /* bpf_map_update_elem() can be called in_irq() */ > spin_lock_irqsave(&htab->lock, flags); > @@ -300,11 +307,17 @@ static int htab_map_delete_elem(struct bpf_map > *map, void *key) > if (l) { > hlist_del_rcu(&l->hash_node); > htab->count--; > - kfree_rcu(l, rcu); > + /* kfree_rcu(l, rcu); */ So this kfree_rcu() is only being used to defer a free, and has nothing to do with having to free 'l' from rcu? > ret = 0; > } > > spin_unlock_irqrestore(&htab->lock, flags); > + > + if (l) { > + spin_lock_irqsave(&elem_freelist_lock, flags); > + list_add(&l->list, &elem_freelist); > + spin_unlock_irqrestore(&elem_freelist_lock, flags); > + } > return ret; > } > > @@ -359,9 +372,31 @@ static struct bpf_map_type_list htab_type > __read_mostly = { > .type = BPF_MAP_TYPE_HASH, > }; > > +static int free_thread(void *arg) > +{ > + unsigned long flags; > + struct htab_elem *l; > + > + while (!kthread_should_stop()) { > + spin_lock_irqsave(&elem_freelist_lock, flags); > + while (!list_empty(&elem_freelist)) { > + l = list_entry(elem_freelist.next, > + struct htab_elem, list); > + list_del(&l->list); > + kfree(l); > + } > + spin_unlock_irqrestore(&elem_freelist_lock, flags); Wow! This is burning up CPU isn't it? If you just need to delay the kfree, why not use irq_work for that job? -- Steve > + } > + > + return 0; > +} > + > static int __init register_htab_map(void) > { > bpf_register_map_type(&htab_type); > + > + kthread_run(free_thread, NULL, "free_thread"); > + > return 0; > } > late_initcall(register_htab_map); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/