Received: by 10.192.165.156 with SMTP id m28csp1395780imm; Mon, 16 Apr 2018 21:10:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx484+ZHEzBzq+N93pGRgU18EqwT8KL6EolxlzCzsDcGRNiQRgSnENC1U0EE8Y1Fi9YZrU8wz X-Received: by 10.98.100.198 with SMTP id y189mr500298pfb.245.1523938239843; Mon, 16 Apr 2018 21:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523938239; cv=none; d=google.com; s=arc-20160816; b=TTlyFWJOlQT9etOq+/tf4SAaWlTrvlCuO81UgWDxyIKOFAR7UnyifDl/wMfpW6DnfG D9NtJPE0hYJ/b+8QrXDvYpItPw83M0X2s0/L5DNhjCgcIgDeRG4vyLcja/SqX39FIRhH 8HjoPRIoKarNEXl/ePNq783LkxeLgdB7Pka3T6SSpURIv+RJ8IisM7KccjK7Ql6qqrVt Qdq5anD8vD4R5/XP6xSHYahC9fGDdQKegaaTdv9u5qx0GXz7FXjCU/FuV0+Rk5/CarCv hnEsVAYGXY1R/6tBdZJ7lKhY0FZP+MJMTHi53OLuxxlMoJvbJFu5I2dyW2tQKByXsIQa l1xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=rV/yG8a/gdA+nrURRDQxghTRP29btj4cVJNhovNjzMA=; b=lZna+bNrFSBX4nyFe+BqsoQEgs7Y7AN3lRYUX8c2eMxUuWfrxmz9WgBoJl0a152GXT rbKWxUV9xkuS2gFJpgl3GVqWwx96qVR1EYwXr6uoE5Mj3a6T6uTjA0CxkWb5EeSzy6Is b7+rWojRJVG/wm2OZHhZ4yTCsKIPiYCJ1kUjjGwqtHTwZwezs0p++4mgr3HQkFn0x771 bg00hU3AdTwT1YKNbZarVt7jwm/gzMYZZZi6mQPRlCmCDrOT3fsJZ9fEgnLOOhkdYkEs JkukNvRpqooD4CACPHl6PsBxvngk6pOCMvtqnzZ7PQwPZRTr8Y1McXCYowC4d1iukI/7 74LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=K3UDdcxJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14si10914510pgf.183.2018.04.16.21.10.25; Mon, 16 Apr 2018 21:10:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=K3UDdcxJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752206AbeDQEIz (ORCPT + 99 others); Tue, 17 Apr 2018 00:08:55 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:36471 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751206AbeDQEIO (ORCPT ); Tue, 17 Apr 2018 00:08:14 -0400 Received: by mail-pl0-f66.google.com with SMTP id 91-v6so11256832pld.3 for ; Mon, 16 Apr 2018 21:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rV/yG8a/gdA+nrURRDQxghTRP29btj4cVJNhovNjzMA=; b=K3UDdcxJ85gChhEgz0dLmNzz/IcY4MUln0gk5H6yJxU6XNt7tUIcKksJ/3zzURjNw1 sZQp9T2HgwomeiQoKPi3pZ6UW/tYBKTSx3nRGRAl1Tkau42i/bCvxGMMDMJmNWn58cPn wT8LnCm7xr8x65S5HIYFZqamjTAMA92WjksH1KFmpC3wmY2/mxse3EnmgTQlAZI9tRfN z48jZmE9rjgbip0HC1F9uq5WC0UDlS4/hthDl+sYhEZiZuAWcNC8acTMVos0CsPfIiOL vh2P/5fRtNvBOZvVJzOp5i/fFglKDsXQnN7tsKXIyAnfrC35nRA8J0moILWpEc1MvdZD Pseg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rV/yG8a/gdA+nrURRDQxghTRP29btj4cVJNhovNjzMA=; b=V3kOun9WqPRWLmhvJYBXDRmS1lN7mXSOx4IXFIInJavA1sSxtnaGQjOItI6AsTuvur gJS65i5AuBhuH5lsEtrxGNG/ykfdfPOFbuT1QdB4jyQh3U8cKgaRAS9L+qqSrhLAEdRt nvVruOU7BlLUMS1DWP0Rvj4E1OZzZIj0tAH7NqjCb8q+8h7rTvpavx62wfEMykjYGUUw MaXWWwOuttWhOmv2VMMI3BVVZH8CUjYR7f4eZIJIiq+Zvq3G1jV7isSJ6lfbxX79HMRJ /bqQ3lR83/+c/f7pejhUpNcdS4UIdw9G+9Yxo28/LFNSHuMCjIizc4OSFv5Skhz5G6TO Hhcg== X-Gm-Message-State: ALQs6tCDUM7xIDvHCmnHOjCV2ZZek172cmd0egq/lXzBmz6iAedX9PDd O6C0yrSpHkR10kj7jQe8JDSNQSQjtoM= X-Received: by 2002:a17:902:43:: with SMTP id 61-v6mr553855pla.112.1523938093393; Mon, 16 Apr 2018 21:08:13 -0700 (PDT) Received: from joelaf.mtv.corp.google.com ([2620:0:1000:1611:2dd1:700f:d2f3:1711]) by smtp.gmail.com with ESMTPSA id j11sm23504686pgc.91.2018.04.16.21.08.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Apr 2018 21:08:12 -0700 (PDT) From: Joel Fernandes To: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Cc: Joel Fernandes , Steven Rostedt , Peter Zilstra , Ingo Molnar , Mathieu Desnoyers , Tom Zanussi , Namhyung Kim , Thomas Glexiner , Boqun Feng , Paul McKenney , Frederic Weisbecker , Randy Dunlap , Masami Hiramatsu , Fenguang Wu , Baohong Liu , Vedang Patel Subject: [RFC v4 3/4] irqflags: Avoid unnecessary calls to trace_ if you can Date: Mon, 16 Apr 2018 21:07:47 -0700 Message-Id: <20180417040748.212236-4-joelaf@google.com> X-Mailer: git-send-email 2.17.0.484.g0c8726318c-goog In-Reply-To: <20180417040748.212236-1-joelaf@google.com> References: <20180417040748.212236-1-joelaf@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With TRACE_IRQFLAGS, we call trace_ API too many times. We don't need to if local_irq_restore or local_irq_save didn't actually do anything. This gives around a 4% improvement in performance when doing the following command: "time find / > /dev/null" Also its best to avoid these calls where possible, since in this series, the RCU code in tracepoint.h seems to be call these quite a bit and I'd like to keep this overhead low. Cc: Steven Rostedt Cc: Peter Zilstra Cc: Ingo Molnar Cc: Mathieu Desnoyers Cc: Tom Zanussi Cc: Namhyung Kim Cc: Thomas Glexiner Cc: Boqun Feng Cc: Paul McKenney Cc: Frederic Weisbecker Cc: Randy Dunlap Cc: Masami Hiramatsu Cc: Fenguang Wu Cc: Baohong Liu Cc: Vedang Patel Signed-off-by: Joel Fernandes --- include/linux/irqflags.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h index 9700f00bbc04..ea8df0ac57d3 100644 --- a/include/linux/irqflags.h +++ b/include/linux/irqflags.h @@ -104,19 +104,20 @@ do { \ #define local_irq_save(flags) \ do { \ raw_local_irq_save(flags); \ - trace_hardirqs_off(); \ + if (!raw_irqs_disabled_flags(flags)) \ + trace_hardirqs_off(); \ } while (0) -#define local_irq_restore(flags) \ - do { \ - if (raw_irqs_disabled_flags(flags)) { \ - raw_local_irq_restore(flags); \ - trace_hardirqs_off(); \ - } else { \ - trace_hardirqs_on(); \ - raw_local_irq_restore(flags); \ - } \ +#define local_irq_restore(flags) \ + do { \ + if (raw_irqs_disabled_flags(flags) && !irqs_disabled()) { \ + raw_local_irq_restore(flags); \ + trace_hardirqs_off(); \ + } else if (!raw_irqs_disabled_flags(flags) && irqs_disabled()) {\ + trace_hardirqs_on(); \ + raw_local_irq_restore(flags); \ + } \ } while (0) #define safe_halt() \ -- 2.17.0.484.g0c8726318c-goog