Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp914576ybh; Tue, 10 Mar 2020 10:40:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsP2kNlbj/TSjxqH7SSRZ3f3zcSlPYWiyms/Q0YaIAFS37drGzfrdFZpyKcUmUfhZdwSjfW X-Received: by 2002:aca:1c09:: with SMTP id c9mr2048376oic.85.1583862045901; Tue, 10 Mar 2020 10:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583862045; cv=none; d=google.com; s=arc-20160816; b=0kelvmIGZ8ilNNRC+Xl4Y9DLhK5UhjI1Jt3TRWr8GvCphUPH6tMgWYfyjjfqdO5Izi 1TyH+15SGQV24u1kfo2gsLf3aPZPAgE9Av4YSHG1zUIChzK6e34Q6KZZD1a2eDGupa33 R3fvP+3kD3mJIntglul4wZE2KYymNpgksXVcTpTIwTl2iVTLk4t97MyLcVdGh7RLW0bl 7Sd01ACfFc0nbk3HUepE5WvUM1Y8IoFVSJ//N5ds+MHWOI/2yfdIq5nZ1n9fVu/fD28b z7hZjIFyDYI2sA/bCgGelmY1fZKZjvOip9oprdyl/BTIUgm7qMs4qe7BjTqTC+ldlh1C Gmhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=iONBCAnNnPUIdJmi3a+nz18hpW44b+1vL2nzHQR+DuQ=; b=K7xttDsk4DdVL7MaVCf87fA9xQM1j24B2X7xocPnqrsNXJ6+6QvUL4Naka4tpcAL86 7PgHModdItF8IfaB+ti8o9hvcNzbLmiEATi6fzIiFwjSNsNRa5NPnicE2wqDrkSGjzgD O7nsz4J6HrsK45Wdnw13IfKfm8S3Z63kakiJ8HhP0UEmKWnaO+o5GGMUMu4rksbtJY7A 0I8wIFDiuPDn/BJYonO0cm7SdZTgIScc6RPEpZwOU4x3nAQVz+DeEKgILv4vPDnVWzhJ GazXk7u7HI63efQp0orWDLDR32E/oNYc69pWWtO2LfdPUBCaCg9eikhVUvsP4D1xBw62 OpIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=mfjjClrc; 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=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u12si5930067oiv.13.2020.03.10.10.40.33; Tue, 10 Mar 2020 10:40:45 -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=pass header.i=@efficios.com header.s=default header.b=mfjjClrc; 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=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbgCJRkG (ORCPT + 99 others); Tue, 10 Mar 2020 13:40:06 -0400 Received: from mail.efficios.com ([167.114.26.124]:47352 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726438AbgCJRkG (ORCPT ); Tue, 10 Mar 2020 13:40:06 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 901812718AE; Tue, 10 Mar 2020 13:40:04 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 7u8iEzcEV_87; Tue, 10 Mar 2020 13:40:04 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 2CBC52717D1; Tue, 10 Mar 2020 13:40:04 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 2CBC52717D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1583862004; bh=iONBCAnNnPUIdJmi3a+nz18hpW44b+1vL2nzHQR+DuQ=; h=Date:From:To:Message-ID:MIME-Version; b=mfjjClrcJZA6gu5jXccb1pKaRSypbi4RF+6lz5aZdSN5aW1mOa6UONJljm9SM/aiD tH/7QhsfrT4deUqGZlfdwwhUnDiADbP8jPPsoYLxgB6YZIAg47PZ+zxch0f12PjsKY vU/ZyN+v6hZT1vyHjjN9L43/TLJUmbuERf+vAXfwf7mLaNsK7GxsnysFXP5++H2Xs7 chh3RU9aGhmxvGDlnkR7gY0v1SVWlfRg/VGDoF7d689mNyKHxAGnlOlsqJ7CUrx7lq ks3OT8/hHAVMEgREzRb61mOLWpM6n+NlgD9F38wsVQvaopONiYPaPT6pjeRCa+259n cziePMG5SDqAw== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id OWi771wHAZwD; Tue, 10 Mar 2020 13:40:04 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 15C3E271929; Tue, 10 Mar 2020 13:40:04 -0400 (EDT) Date: Tue, 10 Mar 2020 13:40:03 -0400 (EDT) From: Mathieu Desnoyers To: Thomas Gleixner Cc: linux-kernel , Peter Zijlstra , rostedt , Masami Hiramatsu , Alexei Starovoitov , paulmck , "Joel Fernandes, Google" , Frederic Weisbecker Message-ID: <1666704263.23816.1583862003925.JavaMail.zimbra@efficios.com> In-Reply-To: <87imjc5f6a.fsf@nanos.tec.linutronix.de> References: <87mu8p797b.fsf@nanos.tec.linutronix.de> <1403546357.21810.1583779060302.JavaMail.zimbra@efficios.com> <871rq171ca.fsf@nanos.tec.linutronix.de> <1489283504.23399.1583852595008.JavaMail.zimbra@efficios.com> <87imjc5f6a.fsf@nanos.tec.linutronix.de> Subject: Re: Instrumentation and RCU MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_3901 (ZimbraWebClient - FF73 (Linux)/8.8.15_GA_3895) Thread-Topic: Instrumentation and RCU Thread-Index: 0nTX/RKhF+4jMm6zLS3dy/aLVWymRA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Mar 10, 2020, at 12:48 PM, Thomas Gleixner tglx@linutronix.de wrote: > Mathieu Desnoyers writes: [...] > See the entry series I'm working on. Aside of moving all this nonsense > into C-code it splits lockdep and tracing so it looks like this: > > lockdep_hardirqs_off(); > user_exit_irqsoff(); > __trace_hardirqs_off(); > > The latter uses regular RCU and not the scru/rcu_irq dance. > Awesome :) > >>>> If a tracer recurses, or if a tracer attempts to trace another tracer, the >>>> instrumentation would break the recursion chain by preventing instrumentation >>>> from firing. If we end up caring about tracers tracing other tracers, we could >>>> have one distinct flag per tracer and let each tracer break the recursion chain. >>>> >>>> Having this flag per kernel stack rather than per CPU or per thread would >>>> allow tracing of nested interrupt handlers (and NMIs), but would break >>>> call chains both within the same stack or going through a trap. I think >>>> it could be a nice complementary safety net to handle mishaps in a non-fatal >>>> way. >>> >>> That works as long as none of this uses breakpoint based patching to >>> dynamically disable/enable stuff. >> >> I'm clearly missing something here. I was expecting the "in_tracing" flag trick >> to be able to fix the breakpoint recursion issue. What is the problem I'm >> missing >> here ? > > How do you "fix" that when you can't reach the tracepoint because you > trip over a breakpoint and then while trying to fixup that stuff you hit > another one? I may still be missing something, but if the fixup code (AFAIU the code performing the out-of-line single-stepping of the original instruction) belongs to a section hidden from instrumentation, it should not be an issue. The basic idea would be, e.g. pseudo-code for int3: <---- in section which cannot be instrumented if (recursion_ctx->in_tracer) { single-step original instruction iret } [...] prepare stuff recursion_ctx->in_tracer = true; instr_allowed() call external kernel functions (which can be instrumented) instr_disallowed() recursion_ctx->in_tracer = false; single-step original instruction iret The purpose of the "in_tracer" flag is to protect whatever is done within external kernel functions (which can be instrumented) from triggering tracer recursion. It needs to be combined with hiding of early/late low-level entry/exit functions from instrumentation (as you propose) to work. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com