Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6033444ybi; Wed, 29 May 2019 01:38:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbe6IRD1OITKV8+68Eq2Kv/OGvr9GpZXgCRvPQ0WaAUU+NEtcpp0gPV2eLJHOiZbzv5VUC X-Received: by 2002:a63:a41:: with SMTP id z1mr33245237pgk.389.1559119116954; Wed, 29 May 2019 01:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559119116; cv=none; d=google.com; s=arc-20160816; b=ISsfvpbre1VJ4e0qDgXXM5nsQvE4JmgxRYVrO36ugC45YG71DrjbVH98eDl/b4Kirz 41n6KlM2WhnXGO0dRRpYJlV6T5K3NShVdvGiXQsakln52u17Dk9VQ/PzerDO8GjDjVGa 5qmcWtkiZ/tC0b/+eceBKMj08NL2BijXjTG1dHB7ah0O1Beoh/SiGgnrWB1/VUuWc153 GY1x5sxc3clSuY0VZd7VZxj2JZE9PT6h83+wHpKdAUwa+VWJ57oFU6slzjfpAFlLnUHV 7O8Wd9bu4dqzj2u7HkuUqiTdle+BkJhYjpr9avYJ2BuvVONERRA9LynQnxcJoATGWuAd vp2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LfvUm4Cf2qfw8lv7xzhDhJX5sO8cqOBowUhl/iL3wzA=; b=kOSa0BO9DpuTz2KczlrY0VtOi9FgVjkJvzwHbCuRADqBxLQL4Y3K5S13VsxPPh3ckj T0eNuDJJHAWyyc/SV98taIWwjdMW587VwhlWKUf0+J2E9pfrvGvldHkXRmXeVF1c2iuq B9cbKRtIk/GiS9N1uyzs8/uiA1dYTHKc8EUGV1Ph6jk6Vd7Si59GAcIk6YripyXXbK3a V33b73t8i3gk2JqGyqFGs7wJ61OYWT6kYOkLQP/yhbJB9XrHPCzDVd8obeay8LcgtwWu PrBOIh2CbDUQ01RnABib0NeMAMTc6MSQNZpqjU7RV1Jcx1YSwCiYX6vJXh5cjUCqL5XU iMyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=dNeWGeHl; 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 k66si6202936pje.9.2019.05.29.01.38.20; Wed, 29 May 2019 01:38:36 -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=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=dNeWGeHl; 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 S1726106AbfE2IfL (ORCPT + 99 others); Wed, 29 May 2019 04:35:11 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49042 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726057AbfE2IfL (ORCPT ); Wed, 29 May 2019 04:35:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=n7yoVkhKpAqi+lqCMTPRH0YV1JfvuDb3vl6aJ/78F2g=; b=dNeWGeHlt/e1Aj/mSEc3wilX7 kMnI9uP0ujtPmAUt+RNwXBVjMxK1v01Teu17CJgIBx5o22KKzpUtMlTZ5ifv4FO90xSozEVyyZGpV Z0S89tDNA/INzYRs/YW1suB3njaOOwvbQXVXIlHW6h0Vz3B8ARo88NUoWolIe7HlA/GEWOw/HTZQe 4SJyHemdSSjunl50faFlyf0KKVYfOI4Y/TDFbDbgu6TMAFyTh65tRB+cfrv3Jtn/PgO2YWa/7a7P8 EA6yLGu9NYTDH+u1CzgPJKSx00X2Bq0IZdNqFGeJUclAmP+4yo341kw86K8CkVagwYQfdr0JW/C5W sHFdBAj9w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVu23-0006jN-SI; Wed, 29 May 2019 08:34:00 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C66AB201A7E41; Wed, 29 May 2019 10:33:57 +0200 (CEST) Date: Wed, 29 May 2019 10:33:57 +0200 From: Peter Zijlstra To: Daniel Bristot de Oliveira Cc: linux-kernel@vger.kernel.org, williams@redhat.com, daniel@bristot.me, "Steven Rostedt (VMware)" , Ingo Molnar , Thomas Gleixner , "Paul E. McKenney" , Matthias Kaehlcke , "Joel Fernandes (Google)" , Frederic Weisbecker , Yangtao Li , Tommaso Cucinotta Subject: Re: [RFC 2/3] preempt_tracer: Disable IRQ while starting/stopping due to a preempt_counter change Message-ID: <20190529083357.GF2623@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 28, 2019 at 05:16:23PM +0200, Daniel Bristot de Oliveira wrote: > The preempt_disable/enable tracepoint only traces in the disable <-> enable > case, which is correct. But think about this case: > > ---------------------------- %< ------------------------------ > THREAD IRQ > | | > preempt_disable() { > __preempt_count_add(1) > -------> smp_apic_timer_interrupt() { > preempt_disable() > do not trace (preempt count >= 1) > .... > preempt_enable() > do not trace (preempt count >= 1) > } > trace_preempt_disable(); > } > ---------------------------- >% ------------------------------ > > The tracepoint will be skipped. .... for the IRQ. But IRQs are not preemptible anyway, so what the problem? > To avoid skipping the trace, the change in the counter should be "atomic" > with the start/stop, w.r.t the interrupts. > > Disable interrupts while the adding/starting stopping/subtracting. > +static inline void preempt_add_start_latency(int val) > +{ > + unsigned long flags; > + > + raw_local_irq_save(flags); > + __preempt_count_add(val); > + preempt_latency_start(val); > + raw_local_irq_restore(flags); > +} > +static inline void preempt_sub_stop_latency(int val) > +{ > + unsigned long flags; > + > + raw_local_irq_save(flags); > + preempt_latency_stop(val); > + __preempt_count_sub(val); > + raw_local_irq_restore(flags); > +} That is hideously expensive :/