Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1480481ybf; Sun, 1 Mar 2020 10:26:59 -0800 (PST) X-Google-Smtp-Source: APXvYqxiyrBTvPpi9swmbI50m9zquHWmO8Xrz1twlSJfnK71TT/LEEhdrOzxnVsN56W+vzK4jc8v X-Received: by 2002:a9d:7356:: with SMTP id l22mr10302012otk.335.1583087219277; Sun, 01 Mar 2020 10:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583087219; cv=none; d=google.com; s=arc-20160816; b=GgRwA3pKthwQF9wKNJJGcyKlpt+pqhkZcn0X3kHX6SV4yGeUdvr0qV3MWaiq4/GNLR h6DYlaDSq0bgZD6wUzf2tFnk5TPhh2wEzp5t/kbWdA2jlvhTscM7Z6RWXbv+JRIAFQO1 Zwxwfy64trMd12X02a5/mLOqzhUyJdGp0KJsGc9Eh/p4GP9PV7+rAJW9nmjIMMeDc3/i d077mFD9K95bUa3WYXZfXlILYGf1gJ7yZ/7jt2usAgECYAVBHQ63XFA440RgjjpmgRA/ YItiKaL467Yv4FT/4BSwIZ0RWersVOQc29wFXacZMPzr1HUixeqwiGOIIwjFeM/wWumt W7bQ== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=n3dt4dT7iuhFpka6RyaW6nDwyenymsOvLXq9GGp0Uio=; b=BAsOXXXdGWy/Um/g0pHRq9bN491Wx0DBz6NUB2z6MQKTo3yef6fOGsFQvPHs5M/unc WY7ptDjogx7G8VKlCPr1L2C3y/u3qSt44qS44uFJ7xi3iB/K17TXy5NFwQklyLDhrqZv GT1omSq8Kr4BQ8hfF2M0fIVWDzl9y4/rz6m5gMtoI1k/lcfl1CTkiF7bd1qsCLGf6iaK PLL6yM1m6mDHyMKuCK5+TRryQwXTSkMDpxCP4vBsHD7zHZBVpXrgauf+cMG+2R8oztp8 HFvC7qwVvhhVvn9lNyCYd2Wcw2NKPHWiMSH9qQN3DUb39EUM4YSChScId2WT0GK6ArYc IhrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AmJQkHih; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a23si4955134oie.81.2020.03.01.10.26.40; Sun, 01 Mar 2020 10:26:59 -0800 (PST) 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=@kernel.org header.s=default header.b=AmJQkHih; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbgCAS0G (ORCPT + 99 others); Sun, 1 Mar 2020 13:26:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:37508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbgCAS0G (ORCPT ); Sun, 1 Mar 2020 13:26:06 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (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 878C5246B9; Sun, 1 Mar 2020 18:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583087165; bh=iGyDbZTZc2mTFtN+89VlucoGW+2KGQYnR0ya2KuoYGw=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=AmJQkHihxDgTLHhdxB80KQTo8RnH4Ic2leol+BeqKLH+pYsV70r3olmQfqJ9JFMOa tHxBKteuu+YYvkWCmi6011ovQ+tEZvMbgmNtgbN+tDsdj+KQZR3rOJPLilO9HjMsqL CEtAkqJLoGaY+thdWNMy/Y8zlFL5sLEbSSXz66Tc= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 5D471352272F; Sun, 1 Mar 2020 10:26:05 -0800 (PST) Date: Sun, 1 Mar 2020 10:26:05 -0800 From: "Paul E. McKenney" To: Thomas Gleixner Cc: Andy Lutomirski , Steven Rostedt , Peter Zijlstra , LKML , X86 ML , Brian Gerst , Juergen Gross , Paolo Bonzini , Arnd Bergmann Subject: Re: [patch 4/8] x86/entry: Move irq tracing on syscall entry to C-code Message-ID: <20200301182605.GT2935@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <87imjofkhx.fsf@nanos.tec.linutronix.de> <87d09wf6dw.fsf@nanos.tec.linutronix.de> <878skkeygm.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878skkeygm.fsf@nanos.tec.linutronix.de> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 01, 2020 at 07:12:25PM +0100, Thomas Gleixner wrote: > Andy Lutomirski writes: > > On Sun, Mar 1, 2020 at 7:21 AM Thomas Gleixner wrote: > >> Andy Lutomirski writes: > >> >> On Mar 1, 2020, at 2:16 AM, Thomas Gleixner wrote: > >> >> Ok, but for the time being anything before/after CONTEXT_KERNEL is unsafe > >> >> except trace_hardirq_off/on() as those trace functions do not allow to > >> >> attach anything AFAICT. > >> > > >> > Can you point to whatever makes those particular functions special? I > >> > failed to follow the macro maze. > >> > >> Those are not tracepoints and not going through the macro maze. See > >> kernel/trace/trace_preemptirq.c > > > > That has: > > > > void trace_hardirqs_on(void) > > { > > if (this_cpu_read(tracing_irq_cpu)) { > > if (!in_nmi()) > > trace_irq_enable_rcuidle(CALLER_ADDR0, CALLER_ADDR1); > > tracer_hardirqs_on(CALLER_ADDR0, CALLER_ADDR1); > > this_cpu_write(tracing_irq_cpu, 0); > > } > > > > lockdep_hardirqs_on(CALLER_ADDR0); > > } > > EXPORT_SYMBOL(trace_hardirqs_on); > > NOKPROBE_SYMBOL(trace_hardirqs_on); > > > > But this calls trace_irq_enable_rcuidle(), and that's the part of the > > macro maze I got lost in. I found: > > > > #ifdef CONFIG_TRACE_IRQFLAGS > > DEFINE_EVENT(preemptirq_template, irq_disable, > > TP_PROTO(unsigned long ip, unsigned long parent_ip), > > TP_ARGS(ip, parent_ip)); > > > > DEFINE_EVENT(preemptirq_template, irq_enable, > > TP_PROTO(unsigned long ip, unsigned long parent_ip), > > TP_ARGS(ip, parent_ip)); > > #else > > #define trace_irq_enable(...) > > #define trace_irq_disable(...) > > #define trace_irq_enable_rcuidle(...) > > #define trace_irq_disable_rcuidle(...) > > #endif > > > > But the DEFINE_EVENT doesn't have the "_rcuidle" part. And that's > > where I got lost in the macro maze. I looked at the gcc asm output, > > and there is, indeed: > > DEFINE_EVENT > DECLARE_TRACE > __DECLARE_TRACE > __DECLARE_TRACE_RCU > static inline void trace_##name##_rcuidle(proto) > __DO_TRACE > if (rcuidle) > .... > > > But I also don't see why this is any different from any other tracepoint. > > Indeed. I took a wrong turn at some point in the macro jungle :) > > So tracing itself is fine, but then if you have probes or bpf programs > attached to a tracepoint these use rcu_read_lock()/unlock() which is > obviosly wrong in rcuidle context. Definitely, any such code needs to use tricks similar to that of the tracing code. Or instead use something like SRCU, which is OK with readers from idle. Or use something like Steve Rostedt's workqueue-based approach, though please be very careful with this latter, lest the battery-powered embedded guys come after you for waking up idle CPUs too often. ;-) Thanx, Paul