Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp457005pxb; Wed, 27 Jan 2021 11:55:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXbAyB5HCq3yaqgLMyDqpnnJ/DDZ/SWLl3JG+2h7+0nVecIOpm25yrl20Mr1EsftH4u6er X-Received: by 2002:a05:6402:1682:: with SMTP id a2mr10855548edv.30.1611777318933; Wed, 27 Jan 2021 11:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611777318; cv=none; d=google.com; s=arc-20160816; b=VOQ4pHtheMnbLX3RxmiJO+nJd2ArMe4giIdVjndwdiyRCywl5Q7Dst5njSxjDzIkiH CQyYBs3YkTqZMauT1bOMRoObdaEu4UhAk8ybA8hUyDMP6NA7y3bTqg0dhpoAqbvznGYn BCOKB4v4BLvuwZOVXZZn4bpsKtXgVUPK+HLrwl9sytjrID8JX2wixnGa4KsBEx3sX1S7 0hCLTXrtoKFhm2kCp5RwJO3KSMFoHjJToQYHekEBvLFbdfEAKnH4nJdE6fslmFunXjI3 ULOrf7XNk6ntU9sigFFMWGSCJWgJcEqbzJ5hpl9KDLOiHIvoTT0GZjhcTFyghKOfifkW IQsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=iwcyLRKvRYCggpKhobLC2ptBLH4n0BU4QQA2pSmy6gc=; b=bHYYU2rHvnDMP2F/hn2kAoWTQcQ3p9lqOAyOIRbG287T3QfV1eV/YBIpfnIDNkd00D mMGPkV4IfC2uBfRlP9NPhuajNZyIBMxBCGHU1CxddAQERCPgVsARk7YU6QWLDnICEXR+ O1bf0a45ZJa1XuKYRKS8+vZtJzbkermfqCubBFZ6eaXl2jr5vERESkZqKWNDlM5X+1tQ uNuDuA72j0KPkRocFRjFb4uyDif9F/Arvz2Rdedev89P63FDvakEveQI510uVzAQJ4Ko eOU6IVN60QsNNe4jI0sROJe6X68ygUXSiM1bGVc2Sw7fKoHeIW2vrDsyUarH568GeEiK 3JgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="ZDmxBTp/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=O4mx4UC8; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a25si1240549ejd.541.2021.01.27.11.54.53; Wed, 27 Jan 2021 11:55:18 -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=@linutronix.de header.s=2020 header.b="ZDmxBTp/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=O4mx4UC8; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236214AbhA0DdN (ORCPT + 99 others); Tue, 26 Jan 2021 22:33:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729521AbhAZVTT (ORCPT ); Tue, 26 Jan 2021 16:19:19 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 135F3C06178A for ; Tue, 26 Jan 2021 13:15:58 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1611695756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iwcyLRKvRYCggpKhobLC2ptBLH4n0BU4QQA2pSmy6gc=; b=ZDmxBTp/e21MbdofjzyTZ41PDXwtt17H0NYYfF5AKLQf7Ledyd4KkAsyL+KLxyeR++e83c onDqaLI3DKzTJvmgdsEceRX2yLfKukqPjbayILLZPi+ErkpSUfgRfQYtTZpq3OpUe8LsAy qzFWjrVLOCG9cnjN4qydposjHkeUyDVaRari9Wkh9dmCVzQhabgXw8FiCTeTNYTB405WmV Qmesxzu1sZhPfokjCFkigv+eU5qvU2bYtcxzgtAf49LPUXP5YPaC3CGeQ2qBQa2ufgWhvg kByjJaKDFbkrlgno3ZV52Elkgo9y92ZHwCfzaJyrIlFEiRlvc/zp8/j2MEwkZw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1611695756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iwcyLRKvRYCggpKhobLC2ptBLH4n0BU4QQA2pSmy6gc=; b=O4mx4UC8ttIswaw3XxFwpD3FCh/yRWHNG2fOJv2rkgnTaMtYCBJgHu5QDr9YyoBuM/God4 qr55WlvmphLh4FCA== To: Petr Mladek Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk-rework 10/12] hv: synchronize kmsg_dumper Date: Tue, 26 Jan 2021 22:21:49 +0106 Message-Id: <20210126211551.26536-11-john.ogness@linutronix.de> In-Reply-To: <20210126211551.26536-1-john.ogness@linutronix.de> References: <20210126211551.26536-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for removing printk's @logbuf_lock, dumpers that have assumed to be protected against parallel calls must provide their own synchronization. Add a locally static spinlock to synchronize the kmsg_dump call. Signed-off-by: John Ogness --- drivers/hv/vmbus_drv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index fbeddef90941..08db95e1a139 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1362,23 +1362,27 @@ static void hv_kmsg_dump(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason, struct kmsg_dumper_iter *iter) { + static DEFINE_SPINLOCK(lock); size_t bytes_written; phys_addr_t panic_pa; + unsigned long flags; /* We are only interested in panics. */ if ((reason != KMSG_DUMP_PANIC) || (!sysctl_record_panic_msg)) return; + if (!spin_trylock_irqsave(&lock, flags)) + return; + panic_pa = virt_to_phys(hv_panic_page); - /* - * Write dump contents to the page. No need to synchronize; panic should - * be single-threaded. - */ + /* Write dump contents to the page. */ kmsg_dump_get_buffer(iter, false, hv_panic_page, HV_HYP_PAGE_SIZE, &bytes_written); if (bytes_written) hyperv_report_panic_msg(panic_pa, bytes_written); + + spin_unlock_irqrestore(&lock, flags); } static struct kmsg_dumper hv_kmsg_dumper = { -- 2.20.1