From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753338AbcERTyi (ORCPT ); Wed, 18 May 2016 15:54:38 -0400 Received: from smtprelay0141.hostedemail.com ([216.40.44.141]:50824 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752299AbcERTyh (ORCPT ); Wed, 18 May 2016 15:54:37 -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:2194:2196:2199:2200:2393:2553:2559:2562:2693:2900:2904:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:4321:4385:5007:6261:7875:8660:9010:10004:10400:10471:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12555:12740:13148:13230:13255:13439:14181:14659:14721:21080:21433,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:2,LUA_SUMMARY:none X-HE-Tag: turn16_2808fa628c655 X-Filterd-Recvd-Size: 3419 Date: Wed, 18 May 2016 15:54:33 -0400 From: Steven Rostedt To: Soumya PN Cc: mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ftrace: As disabling interrupts is costly and write_lock variant of tasklist_lock is not held from interrupt context it is not necessary to disable interrupts. Message-ID: <20160518155433.1631bb23@gandalf.local.home> In-Reply-To: <1463500874-77480-1-git-send-email-soumya.p.n@hpe.com> References: <1463500874-77480-1-git-send-email-soumya.p.n@hpe.com> 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 -ERUNONSUBJECT -- Steve On Tue, 17 May 2016 21:31:14 +0530 Soumya PN wrote: > In ftrace.c inside the function alloc_retstack_tasklist()(which will be > invoked when function_graph tracing is on) the tasklist_lock is being > held as reader while iterating through list of threads. Here the lock > is being held as reader with irqs disabled. The tasklist_lock is never > write_locked in interrupt context so it is safe to not disable interrupts > for the duration of read_lock in this block which, can be significant, > given the block of code iterates through all threads. Hence changing the > code to call read_lock() and read_unlock() instead of read_lock_irqsave() > and read_unlock_irqrestore(). Seen the same change is made in > "kernel/tracepoint.c" and "kernel/sched/core.c"files with commit ids > 'commit 8063e41d2ffc ("tracing: Change syscall_*regfunc() to check > PF_KTHREAD and use for_each_process_thread()")' > 'commit 3472eaa1f12e ("sched: normalize_rt_tasks(): Don't use _irqsave > for tasklist_lock, use task_rq_lock()")' > > Stopped the irqbalance service and bound the interrupts and processes > being traced to the same cpu core with function_graph tracing on. I/Os > completed successfully. Verified the trace output and seen the expected > results. > > Signed-off-by: Soumya PN > --- > kernel/trace/ftrace.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index b1870fb..a680482 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -5713,7 +5713,6 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) > { > int i; > int ret = 0; > - unsigned long flags; > int start = 0, end = FTRACE_RETSTACK_ALLOC_SIZE; > struct task_struct *g, *t; > > @@ -5729,7 +5728,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) > } > } > > - read_lock_irqsave(&tasklist_lock, flags); > + read_lock(&tasklist_lock); > do_each_thread(g, t) { > if (start == end) { > ret = -EAGAIN; > @@ -5747,7 +5746,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) > } while_each_thread(g, t); > > unlock: > - read_unlock_irqrestore(&tasklist_lock, flags); > + read_unlock(&tasklist_lock); > free: > for (i = start; i < end; i++) > kfree(ret_stack_list[i]);