Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6115016ybv; Wed, 12 Feb 2020 06:18:58 -0800 (PST) X-Google-Smtp-Source: APXvYqzfcFzUVbwToMMyQ+KLSrN+Wy8VsAFFKGyQBQqMedkKYWSU53/tRpXUoDoRMt4/LcDZKxtE X-Received: by 2002:a05:6830:10d7:: with SMTP id z23mr9477738oto.114.1581517137925; Wed, 12 Feb 2020 06:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581517137; cv=none; d=google.com; s=arc-20160816; b=cPf4vBU7ssPw48sqhBpu8C/aaAItO0dPNsgfQbsBtxbix68er2ZO8vk5/kdpDEH3Ev QaJoKYhanExRoVul5PI6l9xheYXpeAnKJqiTz/Cbz83ZuhaIpY23b9KmjjIqsfxyxOzD INsFm3ugvJwo0n8YOznURZ8Z5iZEK6psd5iZFwGHXYxQtdiqHOAQaf7CGsIsjhPUIl42 zu7iqzYDRabAh6Aia+vi7jRX6Dcd+XcfTp1XoKdl/L6fk7GHVM5Q1Wp4usG07hHrW3Xh kHghld+TggcQspO7XsacCK98KtQO8FRLwxrRruXGk/f5AFmBBIHYARSAsmfc/c++c5eP 1Pyw== 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:message-id:subject:cc :to:from:date; bh=j80qk5FtObBLzlv79ZuiyU1427vfyxSnunT7fd2eYZc=; b=JOO7/CeAfk00BbP6fQlPfHQTgCW4NqEbYzibrcwBMUERXKXuVMcuh56QIwE7bTX8No Rx2TxxDn/IgzHR0VhgSucry49+q/cCAIZGbCEnPsQjsomsQDZewINuuLPXzrxbC+ZVi2 u28183uT7ousYqITet2PDm0yZZppU6RocJnlpI3BUsM7TSgpD5K7qly1GIqlAFeAJM0f tJS5pNOS3F5Om2kOeT2gNUTY+m4+rJxwpb7zZsQ5sQY+GevR55W1VloX9cyb4/LIXeFL 8CqKzgfuJ/HBx51+FkrCqMfusEc8LaTOQpCs0zIHJuIqDuTMQ+XP4bhYlsoz/eAG0+3N FYfA== 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 o4si250992otp.200.2020.02.12.06.18.44; Wed, 12 Feb 2020 06:18:57 -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; 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 S1728098AbgBLOSe (ORCPT + 99 others); Wed, 12 Feb 2020 09:18:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:50402 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727732AbgBLOSe (ORCPT ); Wed, 12 Feb 2020 09:18:34 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D3759AF27; Wed, 12 Feb 2020 14:18:32 +0000 (UTC) Date: Wed, 12 Feb 2020 15:18:32 +0100 From: Petr Mladek To: Sergey Senozhatsky Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Steven Rostedt , Sergey Senozhatsky , Andrew Morton , Dmitry Monakhov , Konstantin Khlebnikov Subject: Re: [PATCH] kernel/watchdog: flush all printk nmi buffers when hardlockup detected Message-ID: <20200212141832.lqmzzdi77hb6yrhu@pathway.suse.cz> References: <158132813726.1980.17382047082627699898.stgit@buzz> <20200212011551.GA13208@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200212011551.GA13208@google.com> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2020-02-12 10:15:51, Sergey Senozhatsky wrote: > On (20/02/10 12:48), Konstantin Khlebnikov wrote: > > > > In NMI context printk() could save messages into per-cpu buffers and > > schedule flush by irq_work when IRQ are unblocked. This means message > > about hardlockup appears in kernel log only when/if lockup is gone. > > > > Comment in irq_work_queue_on() states that remote IPI aren't NMI safe > > thus printk() cannot schedule flush work to another cpu. > > > > This patch adds simple atomic counter of detected hardlockups and > > flushes all per-cpu printk buffers in context softlockup watchdog > > at any other cpu when it sees changes of this counter. > > Petr, could you remind me, why do we do PRINTK_NMI_DIRECT_CONTEXT_MASK > only from ftrace? There was a possible deadlock when printing backtraces from all CPUs. The CPUs were serialized via a lock in nmi_cpu_backtrace(). One of them might have been interrupted under logbuf_lock. ftrace was needed because it printed too many messages. And it was safe because the ftrace log was read from a single CPU without any lock. Best Regards, Petr