Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6357294ybi; Wed, 29 May 2019 06:44:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqysomKWN1afkX6vqZDqVieqld8la5v/1Yt+FbZIf0F5QA3Rt13R5s9712JefN96ijjKWZpa X-Received: by 2002:a65:64d5:: with SMTP id t21mr65701116pgv.310.1559137489335; Wed, 29 May 2019 06:44:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559137489; cv=none; d=google.com; s=arc-20160816; b=N8ok1ujJMiIyDgveAKtvqsmsWSq1pRtxa72u/JOTIZ1p3UNHAmb1ZBylFNJUG387+C IuQE05+DARYwT9/GA+4xT/+o/f3yfeG+6bFI+TpqM6jXEOC7ESmkU78ytZqtFXZbvgbq 9T3NSsZgkgBWDx/0VtPlXtOFlnHPt17+JkxNRbEdOqffJhb9f6Q9mOEjbfjPFkAootI5 XIsmj7gVXVN4s4YBGaFZci6rJORDOP+rphF6XoQTi7NYX2SC+9KiveHMway1Hexg4Ldg FTupU+cZu2PBXdK3eR4AAR3hJtadoNKD7MGEH1No+TBfoVn+mpHXtSBtxIfKq7Ft26RU q2Yg== 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; bh=EWsus0m3GogFylQTQRXhPWfn8nRz9uPGt6lGy8MV66I=; b=kQ0HhSAVJp3Rv/RwnlnUxB0bVGi1tbDK8QDaAYwr1lEFp0LfuEYn03xLqJX6YSFqP9 mdfX98+JI0GZJT3kMfkP/il8MfSy+AsYLsWnrf2zByCGB9g3HJLC1uvEahxrnuAvjTUw h7x1443c16HeXLetSZVn+R7GaIyjcEiuNC620Om/JOWf/AZFsbCYzK9BuSqFgVEH+U/x lM9tWTWJ+EIA1bmVirAg4Awcz8DRpZC/JbSch1zDBiPNvNOEKsd1yYolQIk9VUjlvl8u VQz6sJG9o1A+fnegXcHeO0iH1rBGAOzNWfJSOlwDjlafj57r7HBmL2fjGIpwaM6u84yq siXg== 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 k10si25324165plt.133.2019.05.29.06.44.33; Wed, 29 May 2019 06:44:49 -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 S1727380AbfE2NmT (ORCPT + 99 others); Wed, 29 May 2019 09:42:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:57210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbfE2NmR (ORCPT ); Wed, 29 May 2019 09:42:17 -0400 Received: from oasis.local.home (unknown [12.156.218.74]) (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 15313229F7; Wed, 29 May 2019 13:42:16 +0000 (UTC) Date: Wed, 29 May 2019 09:42:13 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: Daniel Bristot de Oliveira , linux-kernel@vger.kernel.org, williams@redhat.com, daniel@bristot.me, 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: <20190529094213.3e344965@oasis.local.home> In-Reply-To: <20190529131957.GV2623@hirez.programming.kicks-ass.net> References: <20190529083357.GF2623@hirez.programming.kicks-ass.net> <20190529102038.GO2623@hirez.programming.kicks-ass.net> <20190529083930.5541130e@oasis.local.home> <20190529131957.GV2623@hirez.programming.kicks-ass.net> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-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 Wed, 29 May 2019 15:19:57 +0200 Peter Zijlstra wrote: > On Wed, May 29, 2019 at 08:39:30AM -0400, Steven Rostedt wrote: > > I believe I see what Daniel is talking about, but I hate the proposed > > solution ;-) > > > > First, if you care about real times that the CPU can't preempt > > (preempt_count != 0 or interrupts disabled), then you want the > > preempt_irqsoff tracer. The preempt_tracer is more academic where it > > just shows you when we disable preemption via the counter. But even > > with the preempt_irqsoff tracer you may not get the full length of time > > due to the above explained race. > > IOW, that tracer gives a completely 'make believe' number? What's the > point? Just delete the pure preempt tracer. The preempt_tracer is there as part of the preempt_irqsoff tracer implementation. By removing it, the only code we would remove is displaying preemptoff as a tracer. I stated this when it was created, that it was more of an academic exercise if you use it, but that code was required to get preempt_irqsoff working. > > And the preempt_irqoff tracer had better also consume the IRQ events, > and if it does that it can DTRT without extra bits on, even with that > race. > > Consider: > > preempt_disable() > preempt_count += 1; > > trace_irq_enter(); > > trace_irq_exit(); > > trace_preempt_disable(); > > /* does stuff */ > > preempt_enable() > preempt_count -= 1; > trace_preempt_enable(); > > You're saying preempt_irqoff() fails to connect the two because of the > hole between trace_irq_exit() and trace_preempt_disable() ? > > But trace_irq_exit() can see the raised preempt_count and set state > for trace_preempt_disable() to connect. That's basically what I was suggesting as the solution to this ;-) > > > What I would recommend is adding a flag to the task_struct that gets > > set before the __preempt_count_add() and cleared by the tracing > > function. If an interrupt goes off during this time, it will start > > the total time to record, and not end it on the trace_hardirqs_on() > > part. Now since we set this flag before disabling preemption, what > > if we get preempted before calling __preempt_count_add()?. Simple, > > have a hook in the scheduler (just connect to the sched_switch > > tracepoint) that checks that flag, and if it is set, it ends the > > preempt disable recording time. Also on scheduling that task back > > in, if that flag is set, start the preempt disable timer. > > I don't think that works, you also have to consider softirq. And yes > you can make it more complicated, but I still don't see the point. Note, there's places that disable preemption without being traced. If we trigger only on preemption being disabled and start the "timer", there may not be any code to stop it. That was why I recommended the flag in the code that starts the timing. > > And none of this is relevant for Daniels model stuff. He just needs to > consider in-IRQ as !preempt. But he does bring up an issues that preempt_irqsoff fails. -- Steve