Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751220AbdCPDlP (ORCPT ); Wed, 15 Mar 2017 23:41:15 -0400 Received: from smtprelay0029.hostedemail.com ([216.40.44.29]:34727 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751137AbdCPDlO (ORCPT ); Wed, 15 Mar 2017 23:41:14 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::,RULES_HIT:41:355:379:541:599:800:960:973:981:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3353:3622:3743:3865:3866:3867:3870:3871:3872:3873:3874:4398:4605:5007:6119:6261:7809:7875:7903:8603:8660:9040:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12114:12295:12296:12438:12740:12760:12895:13069:13148:13161:13229:13230:13311:13357:13439:14096:14097:14181:14659:14721:21080:21324:21433:30006:30054: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:1,LUA_SUMMARY:none X-HE-Tag: stove28_61ac7665da559 X-Filterd-Recvd-Size: 2905 Date: Wed, 15 Mar 2017 23:41:09 -0400 From: Steven Rostedt To: Andi Kleen Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH 1/7] trace: Move trace_seq_overflowed out of line Message-ID: <20170315234109.6ddc7073@grimm.local.home> In-Reply-To: <20170315232030.19d9ffe2@gandalf.local.home> References: <20170315021431.13107-1-andi@firstfloor.org> <20170315021431.13107-2-andi@firstfloor.org> <20170315205420.53b5e105@grimm.local.home> <20170316022756.GF14380@two.firstfloor.org> <20170315232030.19d9ffe2@gandalf.local.home> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; 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: 1808 Lines: 65 On Wed, 15 Mar 2017 23:20:30 -0400 Steven Rostedt wrote: > > It is used in lots of places outside trace_handle_return, so that would > > give far less savings. Actually, I think you'll probably have *more* savings inlining trace_handle_return() than trace_seq_has_overflowed(). Why? Think about it now before looking at the answer below. > > include/linux/trace_events.h:143: return trace_seq_has_overflowed(s) ? > > Every thing below is negligible. The above which is called in > trace_handle_return() is your problem. > > Let me explain it to you. > > The above is part of the TRACE_EVENT() logic. It is duplicated for > *every* tracepoint in the system. > > Looking at a current kernel: > > # ls /debug/tracing/events/*/*/enable | wc -l > 1267 > > There's 1267 events. That means the function trace_handle_return() is > called 1267 times! THAT IS THE PROBLEM!!!! > > Look at include/trace/trace_events.h for > > trace_raw_output_##call() > > That's the macro that creates over a thousand functions calling > trace_handle_return(). > trace_handle_return() is called 1267 times. If you out of line that function, not only do you save the compares, you also save the condition too! That could be a jump as well. static inline enum print_line_t trace_handle_return(struct trace_seq *s) { return trace_seq_has_overflowed(s) ? TRACE_TYPE_PARTIAL_LINE : TRACE_TYPE_HANDLED; } The above is called 1267 times. If you move out of line trace_seq_has_overflowed() you only saved the s->full || s->seq->len > s->seq->size part from being duplicated. But if you out of line trace_handle_return, you move out s->full || s->seq->len > s->seq->size ? TRACE_TYPE_PARTIAL_LINE : TRACE_TYPE-HANDLED 1267 times as well. Try it. It may surprise you. -- Steve