Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4372592pxb; Tue, 25 Jan 2022 09:01:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZCWOJcz15IYKHOy/jMoRdeKRlJOKuV4vZXqxaa0lCb4n80hGoo+02ESbn6gp7vV8ozzQh X-Received: by 2002:a05:6a00:2151:b0:4a2:5c9a:f0a9 with SMTP id o17-20020a056a00215100b004a25c9af0a9mr18963710pfk.39.1643130098280; Tue, 25 Jan 2022 09:01:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643130098; cv=none; d=google.com; s=arc-20160816; b=YdjwtlCznr8KR8YqN6w3pAGVNlX+fxpWbX+LF+Y6Tg2H3/o+FYIgvlfxlodgL0SVDz 4YiXgCRqRvV/nCHGVdYC4oKHsvuuFdI3m9KHy4t4VzClRNRwHDEdouIfKCF7wH2hsmDy 6y2OTAJ1HB79FMzwRlNET+kZSxu8FlfSujBzzBYj+ruFeKztDz4f94ggsurH0beoJAOX GLfHrWi56lUZV3PsBv3HLAZ1mQ0Kx7hLZK6Hsw+n/NjHL/uR0GLh46gCGtllAD+Cn98i aHR5LQ7rdWVhocYFdlGaYDIydfHhEYroT6ubjANVjGyxpqrJeAx4hM2HIPeqIwoc0121 bNQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YLtlKuPoADWCEZcM/RaMVq/xOpaxcT6tevD1Rm+nUYA=; b=VYsdxy/XdZ0gvSbOC6a/MWFqeHP8NEyHoXvU3stl0oioRcebUwLLdZQyuBmY3b1qv0 C0enRZOkRUDZIdr3ilqh1az+aY83qG2VVByZiJWzBt9TknBinZURHsqWdLHKtf6/88X4 kCmMKr8JbylqAt+XlHoBeOi5EPzjLjYJ9g/JGcFkhxRfzqOAjuIONLblMYT8dherFXSL QT43JMKp93bQUk3Smo9TvscBKNbJSkJvVDGdWW/xZj3lxggOXAfZzQlLjjCrnpdmN/+F 81b9qDXUKpv5PjCf8IWmLtCazR2DwTcV1TdWnDuVjn5A1zf2ryrOC14RUtFCcAW2A81M 8uKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=RpTppQc4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si18366435pfj.19.2022.01.25.09.01.24; Tue, 25 Jan 2022 09:01:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=RpTppQc4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384145AbiAYMpO (ORCPT + 99 others); Tue, 25 Jan 2022 07:45:14 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:55266 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1452800AbiAYMmJ (ORCPT ); Tue, 25 Jan 2022 07:42:09 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E39101F380; Tue, 25 Jan 2022 12:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1643114524; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YLtlKuPoADWCEZcM/RaMVq/xOpaxcT6tevD1Rm+nUYA=; b=RpTppQc4leOl0T0HMyo5gixVuROCn5E/wZm/UJ3ydVYLXpETYI5XxkPWN8iGeYGvk6V54D NzTIVRjBTDVvht330nSPUP5ZudYliwjY9xILG9GIngoY3Lrhi/6ex4RUsLinCGc95O5u2d Sowt7oZFbRzjOLBJ158+QkuzD0chcjg= Received: from suse.cz (unknown [10.100.216.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 9DB02A3B81; Tue, 25 Jan 2022 12:42:04 +0000 (UTC) Date: Tue, 25 Jan 2022 13:42:03 +0100 From: Petr Mladek To: Stephen Brennan Cc: Sergey Senozhatsky , Steven Rostedt , John Ogness , Sergey Senozhatsky , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] printk: disable optimistic spin during panic Message-ID: References: <20220121190222.572694-1-stephen.s.brennan@oracle.com> <20220121190222.572694-3-stephen.s.brennan@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220121190222.572694-3-stephen.s.brennan@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 2022-01-21 11:02:20, Stephen Brennan wrote: > A CPU executing with console lock spinning enabled might be halted > during a panic. Before the panicking CPU calls console_flush_on_panic(), > it may call console_trylock(), which attempts to optimistically spin, > deadlocking the panic CPU: > > CPU 0 (panic CPU) CPU 1 > ----------------- ------ > printk() { > vprintk_func() { > vprintk_default() { > vprintk_emit() { > console_unlock() { > console_lock_spinning_enable(); > ... printing to console ... > panic() { > crash_smp_send_stop() { > NMI -------------------> HALT > } > atomic_notifier_call_chain() { > printk() { > ... > console_trylock_spinnning() { > // optimistic spin infinitely > > This hang during panic can be induced when a kdump kernel is loaded, and > crash_kexec_post_notifiers=1 is present on the kernel command line. The > following script which concurrently writes to /dev/kmsg, and triggers a > panic, can result in this hang: > > #!/bin/bash > date > # 991 chars (based on log buffer size): > chars="$(printf 'a%.0s' {1..991})" > while :; do > echo $chars > /dev/kmsg > done & > echo c > /proc/sysrq-trigger & > date > exit > > To avoid this deadlock, ensure that console_trylock_spinning() does not > allow spinning once a panic has begun. > > Fixes: dbdda842fe96 ("printk: Add console owner and waiter logic to load balance console writes") > > Suggested-by: Petr Mladek > Signed-off-by: Stephen Brennan Looks good to me: Reviewed-by: Petr Mladek Best Regards, Petr