Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6334948ybi; Wed, 29 May 2019 06:26:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjdRd7hStFF2F2G78tryIOToNmdXTbHwnnga3OUcw+ATOZKfRs209Y31HuqfkRRAXc5q5V X-Received: by 2002:a63:6bc3:: with SMTP id g186mr126784153pgc.21.1559136373487; Wed, 29 May 2019 06:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559136373; cv=none; d=google.com; s=arc-20160816; b=gf2NUWRDS03Q9lfdAgEmAOvcO6tB8X7l84v3+yGorCvjmkOsxZOc1xRBI0TIX7ItWG UFQGMbKMV5gc1sVU8IjndudaelveFGo9Nj+VWJ5PmPMX1m/BnLFrlxsrXWqcLE4kSpku YMv95u/QFzaDBg0jbf/lBNPwl9LmWXff4VX3dkOMwHC6D/9vqgorO05lRAGcS/4Z0gAb 38GYO+xb+Oamy5hBDqC6qtp5OBtKCe3XrUua/eGPOoet4cWFk57zdlSOkuvEEw9EpQBF NXIZPA2Lj2KESFGfjMp/YjLAGHpjxPVtcUQ6wnCmjXLvCsTxvV6CeyiFEIGQTYp+EmUL wMGg== 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=UAADxwxT6tx6lBr1tunJYn8T5v+uyVuwmaIKsyOB1k8=; b=TjaRzT8narbXH3bSAIwVFfaxbddxUno+1x9jAOzYlpi8Yu0eQXwsi0pbuAd097qdYo 3t5WM8O+8qINeitm5r9RrwKQu/2b1TVIwUVRG6IhC+GEdN/54ip0cUeJCzawwPqVCuL5 1ihB77+ZYPtfZVrjUApE+ZygKbd6cb45f1DYPjVdUk5xz6r2ArTTwzgLUOLRhd6VpYMa oxVhLcMJafJR0t0O0Rsk+YT+AU/dmUA/Ob/z+QK1vqKAEqY3ajvzv3AbkcIVmp3CqoDP kAHVTrfWAGYNGMKOh9SZAE99UzIkItIxo12Ec6Pe0R+g9PEao1InO9J7R9J6eYuUKfRG pFhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=AKgbZi0K; 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 v35si26383163plg.136.2019.05.29.06.25.56; Wed, 29 May 2019 06:26:13 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=AKgbZi0K; 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 S1727152AbfE2NYP (ORCPT + 99 others); Wed, 29 May 2019 09:24:15 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58596 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbfE2NYP (ORCPT ); Wed, 29 May 2019 09:24:15 -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=UAADxwxT6tx6lBr1tunJYn8T5v+uyVuwmaIKsyOB1k8=; b=AKgbZi0KQ1t2Byq/+qYeTQlx8 5Zk6Wh1iPXKpKZjKkRe0R461W9XyCy56UX3A2h6knc4wXd0aEWQBIcBQ5cV8dp2iMnSPn2F4sXjDs 7U7GyCSUxopx6delIu2Odqo9AGVC2/4Y1YErsibRbj2Y7Os4fez8ueckeVNOs02iFqUmwU3Ps5Kqr +cSOs01pQFgYSMx15l1nxBOU98MwJiQS/8Ohw6Hp8Uyv4SRiZMPwO3KZVF+ggau43CLLZeEUlLOUl YG1iskTIMI6GwzZ0W8pYfWoIVl/pf8+SUXoA1A0jEvnfGBCW+hAqIvfrwpfMrYOwFMvj/o6Fva/bC b4TlKMLfA==; 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 1hVyUq-00012k-4l; Wed, 29 May 2019 13:20:00 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 91307201DB7FA; Wed, 29 May 2019 15:19:57 +0200 (CEST) Date: Wed, 29 May 2019 15:19:57 +0200 From: Peter Zijlstra To: Steven Rostedt 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: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190529083930.5541130e@oasis.local.home> 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 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. 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. > 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. And none of this is relevant for Daniels model stuff. He just needs to consider in-IRQ as !preempt.