Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3020325yba; Mon, 8 Apr 2019 09:24:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0hiSxWDRc4wssalWxPkRnvqPhVsHehxBO9ZBaLR3r/Pt2OT4bID9L+rSWKozHRYpV/Qsh X-Received: by 2002:a63:ed4e:: with SMTP id m14mr29727249pgk.182.1554740645489; Mon, 08 Apr 2019 09:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554740645; cv=none; d=google.com; s=arc-20160816; b=TzUq47tSxkwZ4apnELMH5oB3Cve06sV51HbdhQhL3uT07WVnJzMVqNuRwMmFz7Rk5a NBO/Ddaxv2tfrS9Gn1jGN8z5e4FmFSC8uVMhqBQp3cA6sHzr+VrQ+FLBFHa154J95Uk1 gl63AF6Co9w48AhbV3FRlipLEtb51bLaftqHPYzWO8Ob8HbpFNpZKXMEa+OGS+PXRJMs avHG4UZ3bINvfWyVGU79hT68eMcNsgoNAYhF7fZWiUqyyEEUx7tFDzxfNUOR5ps2IDFU xOWh4VPUWcPaGjqyaIBYPKs+yYZU6dDCyxVSvj3QABvIdW4Dg/TIx9w4L4OWB7EU53mL 4vFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=TtLcZ1DgNdY6h+VKceMVrD9yzhmJPRAtCbOygPX7JTc=; b=gtpcEnk8XixxV+xQdBSPg1Fngg9pfC6rb6eKHHOf18jnrh9KsEQ3nELKRzyXif5pcG 56vY3Lfc28dBEOMwXSuRCwEtEi6B85ZURZ7kuwqK5WPbsXQTLbdoCZgSmY2f4hZseFEV fz7fhbazS9MMG76QTEVpMj+rYLvyZRETpTT5IzCRh7cMGcJwf8tQGyIT3ptEwGyeSin9 kNC9c8rZixMwSpjSSOs5u+axcQ+dH702/DtsoWswVTk/cfZn6fmfLVtAp4VzvZKQA1k7 1gANYQWoM6dwh4tbiyVoFRzq2BH5DWe9uVGjZJXOQCWl0tNmsnFyP02aur2hzHghIyP6 DmaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wiEWXzV7; 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 be7si20012244plb.266.2019.04.08.09.23.49; Mon, 08 Apr 2019 09:24:05 -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=@kernel.org header.s=default header.b=wiEWXzV7; 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 S1728771AbfDHQIS (ORCPT + 99 others); Mon, 8 Apr 2019 12:08:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:48184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbfDHQIR (ORCPT ); Mon, 8 Apr 2019 12:08:17 -0400 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2353D2190B for ; Mon, 8 Apr 2019 16:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554739696; bh=RreRBcz4kMbrSb4+TrHcvb5hfroMvi0yEWBvzQZRoQk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=wiEWXzV71pxafzOXr8qKnb2Leb6LfK4aC7yUkT80I2nEfhsQT/oexJmAdNXmr6X7r kg2vSl+YLvGu+nTPs1tPyOONBNgrberaRCKMXclYEKmuS66wmjCfJVH9be9zU5Tm5o y/gPXokVE8D1Yf8y17volrr3VhYUc4G+5cN/XIdc= Received: by mail-wr1-f46.google.com with SMTP id j9so17102288wrn.6 for ; Mon, 08 Apr 2019 09:08:16 -0700 (PDT) X-Gm-Message-State: APjAAAUMBSm58+0ifZroYGrGibwauOBLFlFj2a0a+B9B7BaCDdseZIYo pSQOquE3WnSWdOF7Pl303oBPEbiid+NkqLUScmrTFg== X-Received: by 2002:adf:c788:: with SMTP id l8mr19019626wrg.143.1554739694561; Mon, 08 Apr 2019 09:08:14 -0700 (PDT) MIME-Version: 1.0 References: <9ba6e0eb-cc4c-49db-40dc-1df4b93b81ef@redhat.com> In-Reply-To: <9ba6e0eb-cc4c-49db-40dc-1df4b93b81ef@redhat.com> From: Andy Lutomirski Date: Mon, 8 Apr 2019 09:08:03 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 0/7] Early task context tracking To: Daniel Bristot de Oliveira Cc: Andy Lutomirski , LKML , Steven Rostedt , Arnaldo Carvalho de Melo , Ingo Molnar , Thomas Gleixner , Borislav Petkov , Peter Zijlstra , "H. Peter Anvin" , "Joel Fernandes (Google)" , Jiri Olsa , Namhyung Kim , Alexander Shishkin , Tommaso Cucinotta , Romulo Silva de Oliveira , Clark Williams , X86 ML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 8, 2019 at 5:47 AM Daniel Bristot de Oliveira wrote: > > On 4/4/19 2:01 AM, Andy Lutomirski wrote: > >> To resolve this problem, the set/unset of the IRQ/NMI context needs to > >> be done before the execution of the first C execution, and after its > >> return. By doing so, and using this method to identify the context in the > >> trace recursion protection, no more events are lost. > > I would much rather do the opposite: completely remove context > > tracking from the asm and, instead, stick it into the C code. We'd > > need to make sure that the C code is totally immune from tracing, > > kprobes, etc, but it would be a nice cleanup. And then you could fix > > this bug in C! > > > > > > Humm... what we could do to have things in C is to set the variable right at the > begin of the C handler, e.g., do_IRQ(), and right before the return. > > But by doing this we would have a problem with two things: > > 1) irq handler itself (e.g., do_IRQ()) > 2) functions/tracepoints that might run before and after the handler execution > (e.g., preemptirq tracer), but still in the IRQ context. > > We can work around the first case by checking if (the function is in the > __irq_entry .text section) in the recursion control. > > The second case would still be a problem. For instance, the preemptirq: > tracepoints in the preemptirq tracer would be "dropped" in the case of a > miss-identification of a recursion. > > Thinking aloud: should we try to move the preemptirq tracers to the C part? I think we should try to move as much as possible to the C part.