Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp263331ybi; Fri, 31 May 2019 00:49:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqze9Rv466pIV6mG8DDAffhZtY8nDArhmLl2tasFcNgFCLdcyHLOIEC5IkOkggJBEGzMYnEL X-Received: by 2002:a63:f410:: with SMTP id g16mr7382179pgi.428.1559288940655; Fri, 31 May 2019 00:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559288940; cv=none; d=google.com; s=arc-20160816; b=cayP412wjdE9bViiRDq4JCkNYxI9Rcrzg2ifTPwRBtAGVHlqrMxLHLevRiDRq0GaRi OoYJwl3jlJHdkQYkjwWUhrnpcPrUaBNBto9Id33csZonjWgArOjOsWP3muy79nNhUpxJ BQJd/IXjvLBTz6mQAmyzoBDJgZsVhKkKFnvhX45bJQLtxy64Jp7nd8y4hGlaREVKLvDS Ta9JYyz885lEySLMCBWoBHjwrUvL0fmubqJyNBN1mCh7bM7PSB8JMvPnDCzeSZ7WEetB REssytZkl0hDLUaIvcYdmK7zkH7NVoAsEoFVnwep3Ho7BfNir8UQBZkwK0XygeyCMmWb jyFg== 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=yFiBFS3YJewgSrxZxwvXs8opxzJGD2ag0QKFTiVhgRg=; b=uOSkSiMAXB76e3Z/BNV4RHlBDb4Ej1wvfNjW4czqEs9bQAbRXrs+g4qCRdH8SG4iMi rxzgUxyaDT/hwCwMRgZ/c/1fxGYH1xIpgq9yFJY+Wn5f7KunTyPY6U7aUdoc6xnh6l4W jeVcUzu+xq8EheSHNcpjjiBE01a78P/zXlN6mEjmWZ4lCneL/SiVc0TQHACxfYyyPxoa bDdDlyVHQ4LeskytegIrMGx297P+XVWwrI/IX5NVqhfSoQRYkZmS5UngFv1kP70VhOuu XUawxJZEwChbSPpP0SV6pA91F/BBHw7GBg6hYOVTkIfFfPheHuaCpOqcDV+CpjzfcZjI rJTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Nta5JwyX; 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 t34si5190878pgm.396.2019.05.31.00.48.42; Fri, 31 May 2019 00:49:00 -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=@joelfernandes.org header.s=google header.b=Nta5JwyX; 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 S1726797AbfEaHrd (ORCPT + 99 others); Fri, 31 May 2019 03:47:33 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44426 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726158AbfEaHrd (ORCPT ); Fri, 31 May 2019 03:47:33 -0400 Received: by mail-pf1-f196.google.com with SMTP id x3so162146pff.11 for ; Fri, 31 May 2019 00:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=yFiBFS3YJewgSrxZxwvXs8opxzJGD2ag0QKFTiVhgRg=; b=Nta5JwyX0hwpprGGkS/wpy9JlQYD3T7/2zElvCrxLoDKX4Ynqqa406OUqBcDc4Spoh qeSodXsi2caRwDB1iOoIJh0uieV+6g9tcLgzBY0GkvXgVUyoJw5ehTdsQSzSjbMMqqit lQu4cE2zJzr3LyFEdPgKWDyPxrU789djjprFI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=yFiBFS3YJewgSrxZxwvXs8opxzJGD2ag0QKFTiVhgRg=; b=Gt/ZnHTiEHR3GQPPE5mIB6OQnOIV5hukO0QuSmCnixJnPibUN3mKaIEIm7OWWBN4O5 49TM24xUhOKh97cmJF31W1l4lMbS+fthDT/N9NIy5ngp+bGxkEB7Pb141LdN4NPt8a+T bQJfPOk75BE7S9/hhAyK5BYSG16xRI3OzHdl7vBwUih6uPNtW4mrE18Dul1JdD38rmjJ n3TPyfYCEO7dvzsUn3Jg/lyfLMVnvK+8JHupwFon/MkDEacQ+h9A34nwbnCYj8cxN62b /9oWTi6XchqgtLr9XGm18IeJ2Wz1o4gEHspi5aQ4JAz7VsdUKrMvXAheyYhNMudVCDXT GKQw== X-Gm-Message-State: APjAAAUii6AJeeqUfRPL6Yj7sEvicakQZWri40snWKD02iSTVvr/IcEQ AI67TUERkTrGCb6zqkSzj1GGZe35Tvg= X-Received: by 2002:a65:5304:: with SMTP id m4mr7449105pgq.126.1559288852273; Fri, 31 May 2019 00:47:32 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id h18sm4187968pgv.38.2019.05.31.00.47.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 May 2019 00:47:30 -0700 (PDT) Date: Fri, 31 May 2019 03:47:29 -0400 From: Joel Fernandes To: Daniel Bristot de Oliveira Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, williams@redhat.com, daniel@bristot.me, "Steven Rostedt (VMware)" , Ingo Molnar , Thomas Gleixner , "Paul E. McKenney" , Matthias Kaehlcke , 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: <20190531074729.GA153831@google.com> References: <20190529083357.GF2623@hirez.programming.kicks-ass.net> 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 Wed, May 29, 2019 at 11:40:34AM +0200, Daniel Bristot de Oliveira wrote: > On 29/05/2019 10:33, Peter Zijlstra wrote: > > 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? > > > right, they are. > > exposing my problem in a more specific way: > > To show in a model that an event always takes place with preemption disabled, > but not necessarily with IRQs disabled, it is worth having the preemption > disable events separated from IRQ disable ones. > > The main reason is that, although IRQs disabled postpone the execution of the > scheduler, it is more pessimistic, as it also delays IRQs. So the more precise > the model is, the less pessimistic the analysis will be. > > But there are other use-cases, for instance: > > (Steve, correct me if I am wrong) > > The preempt_tracer will not notice a "preempt disabled" section in an IRQ > handler if the problem above happens. > > (Yeah, I know these problems are very specific... but...) I agree with the problem. I think Daniel does not want to miss the preemption disabled event caused by the IRQ disabling. > >> 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 :/ > > Yeah... :-( Is there another way to provide such "atomicity"? > > Can I use the argument "if one has these tracepoints enabled, they are not > considering it as a hot-path?" The only addition here seems to the raw_local_irq_{save,restore} around the calls to increment the preempt counter and start the latency tracking. Is there any performance data with the tracepoint enabled and with/without this patch? Like with hackbench? Thanks.