Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6091339ybi; Wed, 29 May 2019 02:43:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdK8pwR9nRSPWvFwnwV9X3Old4qrDRUutY/D/VtRV26+iCGoCc8eo9bz8bPk5Fu52OTMJU X-Received: by 2002:a17:90a:9a87:: with SMTP id e7mr10946239pjp.90.1559123010399; Wed, 29 May 2019 02:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559123010; cv=none; d=google.com; s=arc-20160816; b=sU5PJqXDMklmhCAxr2pEKpHyZK8Z077W4KmHfvDv0a514JaKlUaqhmAY+Tipj+zfAL Zmbpq6OC5uSP/IffM3VeRlVENuvRx8tVg9kCa3Zl6WSz24lc8jT6sX+96B3B4lkhIU68 o7YI2zLAwueKDyoNAyvvHfmuPyTz7DTAaL6OrjfFsdhjzlbj3D8Jg5/aoYMPob8Z9xJA UaMu8VyZF8OtK/5u63k1kH8HAaC1L5bi/NQnHLo01lWfULSC/r+dDgpXuVGJGRmsxNG5 IJMmIRSE8BstqmKd3Z0Dcc8bWy76PO5qFNI4ljeL0oI4A76/8PqDu2eC8GznqnN2VfHI n5Sg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=j0hlqpO7DoKf0qS7cy3GbaeQGV5MXFN+9TtToWsTFR4=; b=nN8CleMVIYBEfcdU72tFh001sFzORFtXdOv/yBgekBNqkv8cx3bPjsv1RCYbsdj7i2 8Zj9xbR5XRfmFpzKWi+pgWaaCR9QO9VPNxGjOGVTXwhZyTzA5fIE/hT/QJ+BJOLp6NG+ Q+RkrvmaIogpurYWqiUeMt700u7qbFA65H7UBWzry2+PCSDHIKJux2sdYJjezy/3fuRk qU/9uowvUX5BT+HaZH2Y5tYaZ162uHL7hQzDu4TkoXbl0mn80Knpf0XdL32V+jICTLAF 2rjsLsuM3VPO/dnYSctbLMtscGsJEyk/6RaNnnfv4bpzRAlzL1ZSsltwu/S6VgMwRKno 4ytA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16si6846568pgl.570.2019.05.29.02.43.13; Wed, 29 May 2019 02:43:30 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726495AbfE2Jko (ORCPT + 99 others); Wed, 29 May 2019 05:40:44 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43681 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbfE2Jkm (ORCPT ); Wed, 29 May 2019 05:40:42 -0400 Received: by mail-wr1-f68.google.com with SMTP id l17so1209588wrm.10 for ; Wed, 29 May 2019 02:40:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=j0hlqpO7DoKf0qS7cy3GbaeQGV5MXFN+9TtToWsTFR4=; b=Uo1WZSoyhUVGRj2+3MOJxfJXM+P7v0LSEDHlcQSFGEhHHPCaoqk1454kY5k+dzExg9 us2AtiZjrMNOPDi64X95de+ylMMtOL6qNtz3pQUP52aPgOW94RuGLiVmLDp8+g0VPYAh 6Mi0M2qTjKFeF6Mfc8gdi0Cp75PrGNfrrNxS0MNa5laFBesch2XEdoI2trSj8VP9p+kU DU/WPlQ5+bPV907ofgyW8fIOLZXl5I8bF1IQGA8sxmXbXEH87c1yJVE+GFIF20Ga0kT5 RQn5VL2hIaKWCJhqeCJJYdMd9e1Ub8ulDQbynjSwcboBJ/xCCoA9If0IeDnHej8BR0R7 uqDQ== X-Gm-Message-State: APjAAAUUrheAjiwhxS16IxaXvZTLvFr6FO5P76B85ln41J/bWULnRTc/ Eawrys8po8JYBvfpIY+eaYEN8A== X-Received: by 2002:a5d:4089:: with SMTP id o9mr6276933wrp.6.1559122836612; Wed, 29 May 2019 02:40:36 -0700 (PDT) Received: from t460s.bristot.redhat.com ([193.205.81.200]) by smtp.gmail.com with ESMTPSA id f3sm2461336wre.93.2019.05.29.02.40.35 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 02:40:35 -0700 (PDT) Subject: Re: [RFC 2/3] preempt_tracer: Disable IRQ while starting/stopping due to a preempt_counter change To: Peter Zijlstra 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 References: <20190529083357.GF2623@hirez.programming.kicks-ass.net> From: Daniel Bristot de Oliveira Message-ID: Date: Wed, 29 May 2019 11:40:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190529083357.GF2623@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...) >> 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?" -- Daniel