From patchwork Thu Jun 1 17:33:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9760705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 97BB860363 for ; Thu, 1 Jun 2017 17:36:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82EDC28518 for ; Thu, 1 Jun 2017 17:36:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 758AB2851F; Thu, 1 Jun 2017 17:36:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F8B628518 for ; Thu, 1 Jun 2017 17:36:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGTyr-0008MW-Dz; Thu, 01 Jun 2017 17:33:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGTyq-0008MG-5l for xen-devel@lists.xenproject.org; Thu, 01 Jun 2017 17:33:52 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 9E/3E-02956-FFF40395; Thu, 01 Jun 2017 17:33:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIIsWRWlGSWpSXmKPExsXiVRvkrPvP3yD SYNsDA4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPWzgVMBV28FbOOvWJtYJzN1cXIxSEkMINR 4ufhF0wgDovAGlaJ5X9XMII4EgKXWCVOLu8AynAAOXESH47JdjFyApmVEmv/nmADsYUEVCRub l/FBDHpG6PEyUnLmEESwgJ6EkeO/mCHsAMlrs99ANbAJmAg8WbHXlYQW0RASeLeqslg85kF9C VWf+UBCbMIqEps+T8DrJxXwFvi+pOLYOWcAr4Sk06dYYTY6yPx7dcEJhBbVEBOYuXlFlaIekG JkzOfsECM1JRYv0sfJMwsIC+x/e0c5gmMIrOQVM1CqJqFpGoBI/MqRo3i1KKy1CJdI0O9pKLM 9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYzA4GcAgh2Mf5YFHGKU5GBSEuVdIG8QKcSXl J9SmZFYnBFfVJqTWnyIUYaDQ0mCN9sPKCdYlJqeWpGWmQOMQ5i0BAePkghvCkiat7ggMbc4Mx 0idYpRl2PSge1fmIRY8vLzUqXEeZeCFAmAFGWU5sGNgKWES4yyUsK8jEBHCfEUpBblZpagyr9 iFOdgVBLmXQkyhSczrwRu0yugI5iAjnixTR/kiJJEhJRUA2OIwzLGaSHhR3Lqbx/S29fXGVmk 0DRjTlknw5IbHYvYXctWnL0h+Nv8R3ZBouiLrJkP+3hMpivffXzo+H+nl5N2ur9/91rg30vuz p4Yu/XbTjsvWXNiRuclk2ze/04X+p6/aZS6L/1oz1+Tf8avz6bWW5UYf8pcO9fENe/0IgGGqb +kK1VF/BYpsRRnJBpqMRcVJwIAYxHH6QQDAAA= X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1496338430!52790170!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63267 invoked from network); 1 Jun 2017 17:33:50 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-15.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Jun 2017 17:33:50 -0000 Received: by mail-wm0-f67.google.com with SMTP id k15so13059479wmh.3 for ; Thu, 01 Jun 2017 10:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=7Pid1sHSWZTh811cn7/pK4KEEUFkwWkrQNVohvsQN9c=; b=maV2/lvwB754aFEBzXoeZu3W9zzzOXjvLFo2x+b+AVXw1WIkm99D+QdGvSbDnnabNm ymPm/E3x1rsGhmuZkxNUvc2m749BQLvgDXwlXTze2YUCWMcVm5tGrj3QKuAHQaATz3ac 5032J/owQnpsQVg70Vxf5W6BCR+FjPVwPExttX1tLZAUKUpYfeconNkj3Fzz4gve6Goe OY0T+UlRHbaBuVxjsH5hhp1AyNy0ah4DW7e49vdJJn+gVfln3JNcJdtjZgLRSQyPaXyx Tuey7E/uGdnTNuZtPx2bZmKXt4Lj8VLfzAfoZEFXc1YIvzV03MrUCcf4Uf9dU/Rh8T2x lxZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=7Pid1sHSWZTh811cn7/pK4KEEUFkwWkrQNVohvsQN9c=; b=tdxWbKRGzcaeu/c4UJCEorae8MfDW+NECyRimhN7dsSuWDk4bw0NJfS8I7np8Ospad nUw6s3RT4aHrWeQAfrRVUIIb/6zbBz7vQUA8HhjiZsE1YforLR9waLxRgzY/EJUlLJc1 B7JURvewaBe0G1ux2bQZsgOtIPrCHeiwGwIh6tU2O6q8vEaNiTdhwhnOAvotPiqJAmnL 3W8tY73kcSyA9clf/gkeYNNa/9k3o0EJw1svmjawt3GkfnejeQuclYNVZ3Q6TE15894j JCnxGKL3lFVKiMo9Q49X7vF/qUwLzT78kUwbLoTNgCpsKWDO+fYx0J/o3TtA4XbOiRIE Hj8A== X-Gm-Message-State: AODbwcDWmVgTDGP8nXQ3qNH3bnpbUTN7Hyqd+08kycOVrghSym2OvW/P d2PP1acRvARogFqx X-Received: by 10.223.176.25 with SMTP id f25mr2115104wra.74.1496338430455; Thu, 01 Jun 2017 10:33:50 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.25]) by smtp.gmail.com with ESMTPSA id p78sm15851wmg.5.2017.06.01.10.33.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 10:33:49 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 01 Jun 2017 19:33:48 +0200 Message-ID: <149633842869.12814.8051616219182929257.stgit@Solace.fritz.box> In-Reply-To: <149633614204.12814.14390287626133023934.stgit@Solace.fritz.box> References: <149633614204.12814.14390287626133023934.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap Subject: [Xen-devel] [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In fact, when calling __trace_var() directly, we can assume that tb_init_done has been checked to be true, and the if is hence redundant. While there, also: - still in __trace_var(), move the check that the event is actually being traced up a little bit (to bail as soon as possible, if it is not); - make it explicit that tb_init_done is likely 0 in trace_will_trace_event(), as it is almost everywhere in the code. Signed-off-by: Dario Faggioli --- Cc: George Dunlap --- xen/common/trace.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/xen/common/trace.c b/xen/common/trace.c index 4fedc26..f29cd4c 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -311,7 +311,7 @@ static int tb_set_size(unsigned int pages) int trace_will_trace_event(u32 event) { - if ( !tb_init_done ) + if ( likely(!tb_init_done) ) return 0; /* @@ -691,7 +691,8 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, unsigned int extra_word; bool_t started_below_highwater; - if( !tb_init_done ) + /* If the event is not interesting, bail, as early as possible */ + if ( (tb_event_mask & event) == 0 ) return; /* Convert byte count into word count, rounding up */ @@ -705,9 +706,6 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, /* Round size up to nearest word */ extra = extra_word * sizeof(u32); - if ( (tb_event_mask & event) == 0 ) - return; - /* match class */ if ( ((tb_event_mask >> TRC_CLS_SHIFT) & (event >> TRC_CLS_SHIFT)) == 0 ) return;