Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3720444pxb; Mon, 1 Feb 2021 02:59:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyay92K3msQZpyQLjbFEXrTCncC9FNV+a7nDmRi7a1KwPZN88S7mgq8HU8eMsvruts4fqLi X-Received: by 2002:a17:906:f85b:: with SMTP id ks27mr16691979ejb.20.1612177195298; Mon, 01 Feb 2021 02:59:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612177195; cv=none; d=google.com; s=arc-20160816; b=Mz9Q9SFBA+z+lBjTdN/HZTuPxvO7O/U/9SZBWjtC6I0MSm9nqejP1NS4ldY4epel+F 2fxcuQDpxABc5d3BTVWeJeRujhXYUmoTKiMASQdkGHHtkacjxrCNRIz3y5lfPRnxCLzd O6QCx7kJgN4SxxEfvPvVtyJzz4PQtWCz83O0o8xv2hNxf/uSIz+8fiEx6ae6/8VVRYSj TPaha+C1/ceWoJQuSOYi2Gke6YnLiC3Oz0jJQnDoJWfKfoG40/e5HGFnaEOXomakfcv7 MRHAN0oadcU4P0LaUflFN87RML3jaFf3zVKV3pZAQTuvboSyxf34hZQHKmEA4VlJjp4U 9Z3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=3b3ONkRx+Y110fQzzC6LdVzaXGV6aFBO4TMx+cCFyJQ=; b=KWW4T3iEdIiA8P8UE++UmsdTjTNeKK7fg4oFJUw/TFad/CKwwsPp79KteFDmszK5mL Cr3syiNQl8WePl94VGZNhvYDSUK56GJkGYsMXJ1kgOXAhll39uI2viEFQ8MHULkYbKdI VHzGdOVQHbdA80KkzDi+rUXqf7JBfOaOdX4tQvtr0ZlL8paoYP0BLHzJwv6Ix4fPxRDA CR34VpZX0bjVczbR/g8akvG+RQvWjtMNkbFKtTIAbQKxLiNvmVwPiE9k4CQ/ZwBNSkv3 LfOO6qHG2SDf+FGFtXNQSfdgk3xuy1R9AjpzBH+Vz8bq7HU8xluUZPr3MSPpssgGJqBk z0cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MRg8GBEN; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=v0PReqaT; 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 zl6si9921029ejb.747.2021.02.01.02.59.30; Mon, 01 Feb 2021 02:59:55 -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=MRg8GBEN; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=v0PReqaT; 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 S233385AbhBAK5A (ORCPT + 99 others); Mon, 1 Feb 2021 05:57:00 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:56736 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233422AbhBAK4t (ORCPT ); Mon, 1 Feb 2021 05:56:49 -0500 From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1612176967; h=from:from:reply-to:subject:subject: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=3b3ONkRx+Y110fQzzC6LdVzaXGV6aFBO4TMx+cCFyJQ=; b=MRg8GBEN5++zaK/UD+HezSsIxfIN/dVAKGywbh7sVoJlxvhG5+Vd/IDy+oJMs/5PMMSFEB /1pcn7M2n7kBpXYDiAGGbe6wa1t1vob9k3OLBJXwM4IdlTruWw5+qPIVt0H3qD84cbyhAq QcrY3R0qR37Qw9xLIL8HYAcA/PKT7VTtFQh40QdKCejSB7/mS2gpmhS7wSGdwNnwUsON0g aAF9nZvyZPBuQLqzJZJcn/NIc4A7Yr0I6KeyPT1w2ZEy5e4EKcFSpcIcOd7pXVMESxVlJC FL1Qqf8ZuTW/Sftq1VQHW9H4AcrPm9QsRrLvWk/+LUnn5U1MSnmUdq1hu9lw7g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1612176967; h=from:from:reply-to:subject:subject: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=3b3ONkRx+Y110fQzzC6LdVzaXGV6aFBO4TMx+cCFyJQ=; b=v0PReqaTNqGifN5D0arrp1P5QqfhUkaSu6oV8lLt1ctS0qJIzlArkWTfPm521qt3ZsBLM0 EVHozfUcqeR4s+Cw== To: Michael Kelley , Petr Mladek Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , "linux-kernel\@vger.kernel.org" Subject: RE: [PATCH printk-rework 10/12] hv: synchronize kmsg_dumper In-Reply-To: References: <20210126211551.26536-1-john.ogness@linutronix.de> <20210126211551.26536-11-john.ogness@linutronix.de> Date: Mon, 01 Feb 2021 12:02:06 +0106 Message-ID: <87mtwojbuh.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-01-27, Michael Kelley wrote: >> 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 > > I don't think this patch is needed. Per some of the unmodified code > above, and the comment, we proceed to the call to kmsg_dump_get_buffer() > only in the panic path. Code in the panic path prior to invoking kmsg_dump() > ensures that we are single-threaded on a single CPU. So I think everything > is good here without the new spin lock. The subsequent call to > hyperv_report_panic_msg() also assumes that we are single-threaded. You are correct. I will withdraw this patch from the series. Thanks for the feedback. John Ogness