From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932108AbcDVPa1 (ORCPT ); Fri, 22 Apr 2016 11:30:27 -0400 Received: from smtprelay0067.hostedemail.com ([216.40.44.67]:45553 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752369AbcDVPa0 (ORCPT ); Fri, 22 Apr 2016 11:30:26 -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:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:2693:2736:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:4362:4385:5007:6119:6261:7875:7903:9040:10004:10400:10848:10967:11026:11232:11658:11914:12043:12296:12517:12519:12740:13069:13255:13311:13357:13439:14096:14097:14181:14659:14721:21080:21324:30012:30054:30079:30090:30091,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,LFtime:3,LUA_SUMMARY:none X-HE-Tag: cause28_325d98ccc605 X-Filterd-Recvd-Size: 2678 Date: Fri, 22 Apr 2016 11:30:19 -0400 From: Steven Rostedt To: Namhyung Kim Cc: , Ingo Molnar , Andrew Morton , "H. Peter Anvin" , Thomas Gleixner , Jiri Olsa , Masami Hiramatsu , Subject: Re: [RFC][PATCH 2/4] tracing: Use pid bitmap instead of a pid array for set_event_pid Message-ID: <20160422113019.5b2d5cc8@gandalf.local.home> In-Reply-To: <20160422024530.GA1790@sejong> References: <20160419143421.829909157@goodmis.org> <20160419143725.295928551@goodmis.org> <20160422024530.GA1790@sejong> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; 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 On Fri, 22 Apr 2016 11:45:30 +0900 Namhyung Kim wrote: > > + pid_list->pid_max = READ_ONCE(pid_max); > > + /* Only truncating will shrink pid_max */ > > + if (filtered_pids && filtered_pids->pid_max > pid_list->pid_max) > > + pid_list->pid_max = filtered_pids->pid_max; > > + pid_list->pids = vzalloc((pid_list->pid_max + 7) >> 3); > > + if (!pid_list->pids) { > > + kfree(pid_list); > > + read = -ENOMEM; > > + goto out; > > + } > > + if (filtered_pids) { > > + /* copy the current bits to the new max */ > > + pid = find_first_bit(filtered_pids->pids, > > + filtered_pids->pid_max); > > + while (pid < filtered_pids->pid_max) { > > + set_bit(pid, pid_list->pids); > > + pid = find_next_bit(filtered_pids->pids, > > + filtered_pids->pid_max, > > + pid + 1); > > + nr_pids++; > > + } > > Why not just use memcpy and keep nr_pids in the pid_list? This is the slow path (very slow ;-), and this was the first method that came to my mind (while I programmed this during a conference). I could use memcpy, or simply one of the bitmask copies, and then get the nr_pids from bitmask_weight(). I would not keep nr_pids in pid_list because that would mean that I would have to manage it in the fast path. Maybe later I'll convert it to bitmap_copy(), but for now I'll just keep it as is. I move this code in my queue for 4.8, and don't want to deal with conflicts unless there's a real bug discovered. Thanks for looking at this code! -- Steve