Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp800527imm; Fri, 11 May 2018 06:38:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrV4UJWPfdAisg5egwiURZd/WZL+pEhIgvaiSFZjYJUq1AzkPsk3RBIJ1AbPoZglxNsvRMv X-Received: by 2002:a17:902:9a4b:: with SMTP id x11-v6mr5641214plv.176.1526045927030; Fri, 11 May 2018 06:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526045926; cv=none; d=google.com; s=arc-20160816; b=TzXGD3ESSvPvTsCUtMPrjzgrxBpH6xBpoQQaE+PewmJQWogiqzbDEeXtE24QqNdrjj RA+aWmFMYjmlJlwpXsDhpPykhk3JHDTsyPzfrGlHjh+PffjNVYVGdaNsiMwJc3AyKtSC V+faufb9LiOKRQr/btQ8S6Mk7is+q67YupHciPM2/VQXzZWsDap8cZ808Bk9rQdfiJwd ukyKKu77rpjr6xplGKCmjkMt0LF/D5vDRMxwJnyNDJlf0YS4j0p4cbEuHS/H5HyNZtP6 HCYWG+KwJlLoD7U8TkdqGa+B0bYEcDGCKPbA+7BbRWcJBn6DGuFtvDZJl0FUHavYxTs9 DrlA== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=EE7Xkl4kizoURm/UIEeDeqUApp/bX06E+HfWKnu9Psw=; b=y21Z9Yvso/3sDhS70RcWOoeAaLp4oXW6ZOghaZ6kjwZY1M+sHaUmJqzMfLdQO5eIJd BMqXdNTdjDuWUaN/60Wpl34iDFWY8O9hbqAfXPYxYShyPB3OXjdn7Wgk9UiNLACnBld9 OLOwRZgy5TqrRrwEWUIZFuy/5jwKyoP4/EbqFgZ8utUBuLL69o5hQsMHrMxcr5l+9NwM IKNith1W5YZ//UE7Nk+6Amw5xtZFbeAaLo78HX6nKgZFynNIT5OMr6JPda58OKfcNjvj hjSz7kBilTiZoSaDuwbZYOJveOFfiDRa9hEjte8sPbkTF4atyygtuzLXqBQUyNRNUwJG MuBw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 88-v6si3113471pla.315.2018.05.11.06.38.02; Fri, 11 May 2018 06:38:46 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753002AbeEKNhT (ORCPT + 99 others); Fri, 11 May 2018 09:37:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:36632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750758AbeEKNhS (ORCPT ); Fri, 11 May 2018 09:37:18 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.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 B467420779; Fri, 11 May 2018 13:37:17 +0000 (UTC) Date: Fri, 11 May 2018 09:37:16 -0400 From: Steven Rostedt To: Sergey Senozhatsky Cc: Dmitry Vyukov , Tetsuo Handa , Petr Mladek , Sergey Senozhatsky , syzkaller , Fengguang Wu , LKML Subject: Re: printk feature for syzbot? Message-ID: <20180511093716.18329322@gandalf.local.home> In-Reply-To: <20180511095004.GA6575@jagdpanzerIV> References: <201805102350.JJH73950.tVJHQLFSOMOOFF@I-love.SAKURA.ne.jp> <20180511014515.GA895@jagdpanzerIV> <201805110238.w4B2cIGH079602@www262.sakura.ne.jp> <20180511062151.GA18160@jagdpanzerIV> <20180511095004.GA6575@jagdpanzerIV> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 11 May 2018 18:50:04 +0900 Sergey Senozhatsky wrote: > On (05/11/18 11:17), Dmitry Vyukov wrote: > > > > From what I see, it seems that interrupts can be nested: > > Hm, I thought that in general IRQ handlers run with local IRQs > disabled on CPU. So, generally, IRQs don't nest. Was I wrong? > NMIs can nest, that's true; but I thought that at least IRQs > don't. We normally don't run nested interrupts, although as the comment in preempt.h says: * The hardirq count could in theory be the same as the number of * interrupts in the system, but we run all interrupt handlers with * interrupts disabled, so we cannot have nesting interrupts. Though * there are a few palaeontologic drivers which reenable interrupts in * the handler, so we need more than one bit here. And no, NMI handlers do not nest. Yes, we deal with nested NMIs, but in those cases, we just set a bit as a latch, and return, and when the first NMI is complete, it checks that bit and if it is set, it executes another NMI handler. > > > https://syzkaller.appspot.com/bug?id=72eddef9cedcf81486adb9dd3e789f0d77505ba5 > > https://syzkaller.appspot.com/bug?id=66fcf61c65f8aa50bbb862eb2fde27c08909a4ff > > > > Will this in_nmi()/in_irq()/in_serving_softirq()/else be enough to > > untangle output printed by such nested interrupts? > > Well, hm. __irq_enter() does preempt_count_add(HARDIRQ_OFFSET) and > __irq_exit() does preempt_count_sub(HARDIRQ_OFFSET). So, technically, > you can store > > preempt_count() & HARDIRQ_MASK > preempt_count() & SOFTIRQ_MASK > preempt_count() & NMI_MASK > > in that extended context tracking. The numbers will not tell you > the IRQ line number, for instance, but at least you'll be able to > distinguish different hard/soft IRQs, NMIs. Just an idea, I didn't > check it, may be it won't work at all. > > Ideally, the serial log should be like this > > i:1 ... foo() > i:1 ... bar() > i:2 ... foo() // __irq_enter() > i:2 ... bar() > i:2 ... buz() // __irq_exit() > i:1 ... buz() > > but I may be completely wrong. > > Petr and Steven probably will have better ideas. I handle nesting of different contexts in the ftrace ring buffer using the preempt count. See trace_recursive_lock/unlock() in kernel/trace/ring_buffer.c. -- Steve