Received: by 10.192.165.156 with SMTP id m28csp997038imm; Wed, 18 Apr 2018 02:04:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SnEeOn1KOx8wfWmMXzOSQF5zIIMAkE2VIFJzkL9wCwmzH7P8IKEi9ruXuQZQrPaJrgsNT X-Received: by 10.98.60.154 with SMTP id b26mr1242561pfk.3.1524042259994; Wed, 18 Apr 2018 02:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524042259; cv=none; d=google.com; s=arc-20160816; b=dOCyyluLwGI5Uht808ywychAXVetFwpbHPQOc3uJ5ZxhipVaLuhs6OgKqemdARSEvw 2bgKEUWiAM1FdXZQO2jxHtw7ypI3SJmMGHJmNu5Mr4IKSoRAY9gxWABDmBIcSGTQl1dn uya4c0Dw8/Z1CkmhXOfnSBgXAZyTFkUqiEoSO6raxFg4+oa4sgXMb4p4UCo9aZYtaKdy koiVaNWODNrjCGkF/szaTtgR0dbLeGBc8mYL5rMsh/H9niTNgEFXsmpbjxX+nwE+sjlE BoHHHmLAQ2PmKrLMqZb2S1VIrGhkpwNqa5nZOoWRxjtfG+1PbwIMrraEe4zsrgtPoZQr 5Z6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=y7UQ4KQnnDOT1zLjSUryqNSSIH2EYcAozO9n2eY+KL4=; b=lyS9LUSNQAjj/JVcuxHBV27MN+7emMgze+N1UYH0xl8zLxgeWL7V+uI4FaSngaDo+Z l16uAsSTvNDQJoVdj39myZF4SOrar7dgAzzw3YO/0fcCIlBVXIkdGHVJ5/YfZJ/Hgwdf tUuxxRaXnAA90mKv3o2umsL9d1uGsJ4OXJpANZG1hh3J9+iRDeJeM1eUIZ9iRLM0P3cE hFtjSL9a7FEf/sARTA5AsNdrxh9f4mmcVKa20Y+tmEP6hnhltcShOScWzF/QJUz0Ly0C F4USOFvtqqrHPbvUWPmalVgm7FkgybxBIQrt+aGsssBiXKNQoCXCvLkoVF8zEwl3Jn9K En6w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si842491plk.308.2018.04.18.02.04.06; Wed, 18 Apr 2018 02:04:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753170AbeDRJC5 (ORCPT + 99 others); Wed, 18 Apr 2018 05:02:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:35032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751940AbeDRJCz (ORCPT ); Wed, 18 Apr 2018 05:02:55 -0400 Received: from devbox (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 763FE2175C; Wed, 18 Apr 2018 09:02:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 763FE2175C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org Date: Wed, 18 Apr 2018 18:02:50 +0900 From: Masami Hiramatsu To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, 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: Re: [RFC v4 3/4] irqflags: Avoid unnecessary calls to trace_ if you can Message-Id: <20180418180250.7b6038dddba46b37c94b796c@kernel.org> In-Reply-To: <20180417040748.212236-4-joelaf@google.com> References: <20180417040748.212236-1-joelaf@google.com> <20180417040748.212236-4-joelaf@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Apr 2018 21:07:47 -0700 Joel Fernandes wrote: > 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. Can we assume that the "flags" has only 1 bit irq-disable flag? Since it skips calling raw_local_irq_restore(flags); too, if there is any state in the flags on any arch, it may change the result. In that case, we can do it as below (just skipping trace_hardirqs_*) int disabled = irqs_disabled(); if (!raw_irqs_disabled_flags(flags) && disabled) trace_hardirqs_on(); raw_local_irq_restore(flags); if (raw_irqs_disabled_flags(flags) && !disabled) trace_hardirqs_off(); Thank you, > > 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 > -- Masami Hiramatsu