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=-5.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 2525AC4161F for ; Tue, 2 Mar 2021 11:02:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F336564EF4 for ; Tue, 2 Mar 2021 11:02:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1838486AbhCBKzA (ORCPT ); Tue, 2 Mar 2021 05:55:00 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:36324 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383052AbhCBKqK (ORCPT ); Tue, 2 Mar 2021 05:46:10 -0500 From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1614681928; 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=vSOy8dFeOWs2dUYht0tqtF69xzoKC+eQy2xuFHyua5I=; b=Y6pmBHMmwv8wUtkfhespjgY/x6QS9e35XcglBRIUOp2I+XS9TXMGCMMMB0p5GB+v7X3qCC mbAzXSdYQyT2ucsI03h/edoxdZppVl4N8+/hfbCUPuzqumqBq/F3Ek5exG/O5TIeaBtLcl cCfunqwhLVa4VYPyQJv/XqDOsSuC+jJ8236Ef5i1WX6D3PCa6MNmLYZkPzLQPkd3C96rxU e4wWxawSMHaj5IJv7iNZUwhN2sgYyCPhlJzTJuWAkhpDqsp7U1sCL1oeh30PMwCjEqvCXX 7zQtRQI1vwab/ahWbsm6EBF2tsBt1/crPwz4ynYy3efJZrODPTdX3cX+5M8IxQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1614681928; 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=vSOy8dFeOWs2dUYht0tqtF69xzoKC+eQy2xuFHyua5I=; b=GXOfiVqk2mYR6O83D5argptmP1sp4qvmGQZHwJ/9nP5x+tH7n5o31BZ9g2mQ0Kqfp//m3W zjM5bqhiwrRtomCQ== To: Petr Mladek Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org Subject: Re: [PATCH next v3 02/15] mtd: mtdoops: synchronize kmsg_dumper In-Reply-To: References: <20210225202438.28985-1-john.ogness@linutronix.de> <20210225202438.28985-3-john.ogness@linutronix.de> Date: Tue, 02 Mar 2021 11:45:27 +0100 Message-ID: <87tuptq1fc.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-03-01, Petr Mladek wrote: >> 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). > > Just to be sure. You did not use spin lock to prevent problems > with eventual double unlock in panic(). Do I get it correctly, > please? I do not understand what possible double unlock you are referring to. I chose not to use spinlocks because I wanted something that does not cause any scheduling or preemption side-effects for mtd. The mtd dumper sometimes dumps directly, sometimes delayed (via scheduled work), and they use different mtd callbacks in different contexts. mtd_write() expects to be called in a non-atomic context. The callbacks can take a mutex. John Ogness