Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2831929yba; Mon, 8 Apr 2019 05:50:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTbjqrw1AnY/O0fNZwLN89AlFlbT9Uy1ps8xFYZwgP0qgyOEa6Ao+OgB162/nr2VKRzaxr X-Received: by 2002:a17:902:a513:: with SMTP id s19mr29085076plq.97.1554727809723; Mon, 08 Apr 2019 05:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554727809; cv=none; d=google.com; s=arc-20160816; b=jGZuLE7vMj4n1SCzmvxTyobvHjXWSGgn1TjXfScVih1iM6FW8w2sIgp2VGh8zSz7v6 XW6WHsEU9Nuqda4QXmX5c1qIb7P1pKbC+CV1mSo6uw7yxxUxlbb4tGqgoI81SAkCZ260 6etLYZ4kbnGTvR4VfzWJH4FOO+bwaUl56/+MnUpn4WuI279/EsU1rUljZYRVFa9hkLN9 c11uOWq0NJAU/ghY2tbWLVaxbtN8Sz4s5fluD74XD40PPnAQToVYhsJj+FZR2UtCJcyD jJxjCfssBBvY29Rn6jpZnV8wyy/+p/JiGg2J8R+hUjsM53o/76QD7QHdCx65xCwc63vN VnEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=sWgZr2/ASFrFMuFomVVmihUekuNMjX5ykTCS8SSqMD8=; b=fa9MgAaFQXYqvM440jvOlGYGTkl+UCMOEZSMNX9Za9Oajv8/KDesWgrBNjvzBQrmfL DXQo8Nf7nOhXyaw0ke0S7VFVR+3XxtFuhQv15Ny5Es05GzLvb7ZtC2WCxSxp6FESQNLj ZXFapRPTppCSdpOPvh3kUrxpiI3jbB/JgsQkWuF5sXpN13GWW5otgLQ4eNjWyFlftzou bQIyVUrkChaQaDR4s2Mdq3SIJmnvzaZS0eeHbOY+NQ0qwPfMWOmTDoW/bnYQCzlpW5is 9QsSJ+HVgPsqtMl8m4s1EFLzimqx7ndSzFRIURE1n7BX2dIOQW01vSgePpj5NYFe3m0A muWQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4si25139795pgq.208.2019.04.08.05.49.53; Mon, 08 Apr 2019 05:50:09 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbfDHMrh (ORCPT + 99 others); Mon, 8 Apr 2019 08:47:37 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39447 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbfDHMrh (ORCPT ); Mon, 8 Apr 2019 08:47:37 -0400 Received: by mail-wr1-f65.google.com with SMTP id j9so16238653wrn.6 for ; Mon, 08 Apr 2019 05:47:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sWgZr2/ASFrFMuFomVVmihUekuNMjX5ykTCS8SSqMD8=; b=hR0eg4jmz03xmEQyMGf/xsf3/LTsHmXtibD89UADo0yOM8+Srww9fmIj/uUB45X3St VXis5XwuhAlztltrZHOWp6pkc2waDEJyUq0/RiqjJO4/bHOFPR90qHDqedwFJi8nsJIR +rg1W01CwXFfmuxVTRKdfxPX25nM6+LiEFJQxLGtJmmXulQ2M4pZItlUOc5riA1OFdMO Th6QITXEFYUrc0x0XF043I3LEvECgIg7mbCkwiZQgjzaMXpV6Li6zCcvPVue5ko2+DEG oVUIr1s1mocLFFuEzsfCAvIhHo2aVk8GpzPlgXqBxVI2oLmNgOziCFu2mSYcirCSKgxt JA7g== X-Gm-Message-State: APjAAAXJZtdl8v1wy61ytiFLu6NCndHsQNikahoVqe7L1ncl3uEZf5qb sAbUIecTtRDwf//9CbgiOMEyMg== X-Received: by 2002:adf:efc1:: with SMTP id i1mr18390089wrp.199.1554727655576; Mon, 08 Apr 2019 05:47:35 -0700 (PDT) Received: from t460s.bristot.redhat.com ([193.205.81.200]) by smtp.gmail.com with ESMTPSA id j22sm92297955wrd.91.2019.04.08.05.47.34 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 05:47:34 -0700 (PDT) Subject: Re: [RFC PATCH 0/7] Early task context tracking To: Andy Lutomirski Cc: 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 References: From: Daniel Bristot de Oliveira Message-ID: <9ba6e0eb-cc4c-49db-40dc-1df4b93b81ef@redhat.com> Date: Mon, 8 Apr 2019 14:47:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 will try to come up with a patch with this approach to see if it "works." Thoughts? -- Daniel