From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14B62C433E0 for ; Thu, 11 Mar 2021 10:10:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB72C64DDA for ; Thu, 11 Mar 2021 10:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232108AbhCKKKE convert rfc822-to-8bit (ORCPT ); Thu, 11 Mar 2021 05:10:04 -0500 Received: from mslow2.mail.gandi.net ([217.70.178.242]:44591 "EHLO mslow2.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbhCKKJ5 (ORCPT ); Thu, 11 Mar 2021 05:09:57 -0500 Received: from relay13.mail.gandi.net (unknown [217.70.178.233]) by mslow2.mail.gandi.net (Postfix) with ESMTP id A6C273A39D0 for ; Thu, 11 Mar 2021 09:51:22 +0000 (UTC) Received: from xps13 (lfbn-tou-1-1325-59.w90-89.abo.wanadoo.fr [90.89.138.59]) (Authenticated sender: miquel.raynal@bootlin.com) by relay13.mail.gandi.net (Postfix) with ESMTPSA id 6CEA98000D; Thu, 11 Mar 2021 09:50:56 +0000 (UTC) Date: Thu, 11 Mar 2021 10:50:55 +0100 From: Miquel Raynal To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org Subject: Re: [PATCH next v4 02/15] mtd: mtdoops: synchronize kmsg_dumper Message-ID: <20210311105055.4a0e864d@xps13> In-Reply-To: <20210303101528.29901-3-john.ogness@linutronix.de> References: <20210303101528.29901-1-john.ogness@linutronix.de> <20210303101528.29901-3-john.ogness@linutronix.de> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, John Ogness wrote on Wed, 3 Mar 2021 11:15:15 +0100: > The kmsg_dumper can be called from any context and CPU, possibly > from multiple CPUs simultaneously. Since the writing of the buffer > can occur from a later scheduled work queue, the oops buffer must > be protected against simultaneous dumping. > > Use an atomic bit to mark when the buffer is protected. Release the > protection in between setting the buffer and the actual writing in > order for a possible panic (immediate write) to be written during > the scheduling of a previous oops (delayed write). > > An atomic bit (rather than a spinlock) was chosen so that no > scheduling or preemption side-effects would be introduced. The MTD > kmsg_dumper may dump directly or it may be delayed (via scheduled > work). Depending on the context, different MTD callbacks are used. > For example, mtd_write() expects to be called in a non-atomic > context and may take a mutex. > > Signed-off-by: John Ogness > Reviewed-by: Petr Mladek Reviewed-by: Miquel Raynal Thanks, Miquèl