Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6037277ybi; Wed, 29 May 2019 01:43:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2chYEr+XBJjgBUqaP97YdbidoOlDT+aW2KxkK2MEj9I64iY/SitH1VJM0wRf8EuC5WW7C X-Received: by 2002:aa7:8248:: with SMTP id e8mr38546916pfn.155.1559119409282; Wed, 29 May 2019 01:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559119409; cv=none; d=google.com; s=arc-20160816; b=wIIexi1QUDnfWPOsK8s82SbclxODCS8yq2mXp/Rr+CjuE8vuIBiBzOfhOjrJRf+uze c0zIMYhYp5e+kPfMjTT1iu7UjVhQg9Gatsvuj94PmdY7ch3V7BOw27qSjl24Zvwvnyu3 rciTTOagUj5MYDC7XVsloD4gHHqph2DX1y+XXSv7MG7dY+Op2SxLN9k8hjrfny8ZQgmo LeAGNHTPyaF1gGxwYVx2KK7SLWsO4TCtqICzWMGLPxpd1o7NiK9pzTFGs20KYRQPgHG/ svbbLH/AgqWRcvCTPyqGQl00toK/m4RPBtZdu7HORHFmIQ+fC7FJ5EuGikucrE7q/Xxw IFAw== 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=Ex7cwI1Y+T7IBQhxpqiVOAaTe/SzLACjja508VX2LQU=; b=W3/tfTI/fgC0X+u3Dlorn1S9xL3Xvl/cJMOTtSrOHmIjtImYT7MgmER5rIr0PluHX9 PETG0RlUdtoTeK5cLDPiNmSWl/pNeTJCC4q6He5N7hLgA+ASTKYUr35RgUI2mmrRoLCx aUfV8sqrfyB4NdvPA81+vXllAJtZcPm4BAimfbhLlpIwyKNnIUtBdUmzsdhkdnyb/0Qa 3+SkN/ud9WGmgUxgB9M8CMbBul7n4bDXkxNpKUsQd5sep/7TnL8nm0eGmX/05n9CNPU0 ogc2sH/uUXPF7OTAdeVQh6C+w4D9oInCMNLSum8hY7p0+18UXV0EV9814i3iQgVIA+Kf ruog== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=gpWtvEz6; 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 z17si24691932pgg.279.2019.05.29.01.43.13; Wed, 29 May 2019 01:43:29 -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=merlin.20170209 header.b=gpWtvEz6; 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 S1726205AbfE2Ilz (ORCPT + 99 others); Wed, 29 May 2019 04:41:55 -0400 Received: from merlin.infradead.org ([205.233.59.134]:60480 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbfE2Ily (ORCPT ); Wed, 29 May 2019 04:41:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=Ex7cwI1Y+T7IBQhxpqiVOAaTe/SzLACjja508VX2LQU=; b=gpWtvEz6EvTgc7TnciPDmZ0uZ nx6WzAdVB3SRP9VM+MVa2CYPHzeMWWzyMVIbRoNzwNqi9536+ODL7a5KcpE9D0mETIaVnuCP7Ghbj sxPjkMgUkCw/x78xOg15xQ+JR1isDEFx63hR5afjPWLdBhYEF4Qf9hZgiWpZ6HNKccLQh+ElgnplW RiBArqSiFDwFMdesPZSRP/yhzWz0GJaYA5tKORPTWGSxAcQ96dVO40xuK2ditoUdPISAOmRnJ/s3v LFtEQQlsXv394dFVSuvtKgMwEMhXQ8j9bHW+EhZmisHjMGbVaScf7bkXY8qP4EcasYZcMvig25eI6 chdgLXsMQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVu9B-0002aD-8s; Wed, 29 May 2019 08:41:21 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D228E201A7E41; Wed, 29 May 2019 10:41:18 +0200 (CEST) Date: Wed, 29 May 2019 10:41:18 +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 3/3] preempt_tracer: Use a percpu variable to control traceble calls Message-ID: <20190529084118.GG2623@hirez.programming.kicks-ass.net> References: <9b0698774be3bb406e2b8b2c12dc1fb91532bff0.1559051152.git.bristot@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9b0698774be3bb406e2b8b2c12dc1fb91532bff0.1559051152.git.bristot@redhat.com> 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:24PM +0200, Daniel Bristot de Oliveira wrote: > #if defined(CONFIG_PREEMPT) && (defined(CONFIG_DEBUG_PREEMPT) || \ > defined(CONFIG_TRACE_PREEMPT_TOGGLE)) > + > +DEFINE_PER_CPU(int, __traced_preempt_count) = 0; > /* > * If the value passed in is equal to the current preempt count > * then we just disabled preemption. Start timing the latency. > */ > void preempt_latency_start(int val) > { > - if (preempt_count() == val) { > + int curr = this_cpu_read(__traced_preempt_count); We actually have this_cpu_add_return(); > + > + if (!curr) { > unsigned long ip = get_lock_parent_ip(); > #ifdef CONFIG_DEBUG_PREEMPT > current->preempt_disable_ip = ip; > #endif > trace_preempt_off(CALLER_ADDR0, ip); > } > + > + this_cpu_write(__traced_preempt_count, curr + val); > } > > static inline void preempt_add_start_latency(int val) > @@ -3200,8 +3206,12 @@ NOKPROBE_SYMBOL(preempt_count_add); > */ > void preempt_latency_stop(int val) > { > - if (preempt_count() == val) > + int curr = this_cpu_read(__traced_preempt_count) - val; this_cpu_sub_return(); > + > + if (!curr) > trace_preempt_on(CALLER_ADDR0, get_lock_parent_ip()); > + > + this_cpu_write(__traced_preempt_count, curr); > } Can't say I love this, but it is miles better than the last patch.