Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1260113lqb; Thu, 18 Apr 2024 05:10:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUP0gaeej0u6Gk7Nz+ZeA/CI+/E6q5HqdrpuhLyoxgAs5t5MnenBQjwakHOK3ionP1ggrGKGFh3lOcZMpbFgCz9F8PHtS4sHgYOMrdawg== X-Google-Smtp-Source: AGHT+IHdAFmZnspdk/VfMgzKADn6TdCSjllfToYVBKxVbEcGRnTyVprpYmmC8v7kh9aXCpBF31D6 X-Received: by 2002:a05:6512:3ba2:b0:519:25cc:6440 with SMTP id g34-20020a0565123ba200b0051925cc6440mr1824029lfv.42.1713442234914; Thu, 18 Apr 2024 05:10:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713442234; cv=pass; d=google.com; s=arc-20160816; b=QOBGPtvp/6LZHPinzTJhPeoBtiQHs+kgpC1zNguZ1XbY/Qc3H/qNalWf1HEaG2CBHE EMuTojmxXdPdYfveCYHimETU081FpbJsUk7/kXwGpo9LjUZQV2pIt51MBa/uP+6ogfI/ XBmAFGz0mqkgUeICE+3kC19L0+XAD7YqDcHPniJwQuSyx4wkBBoh0oGy1YDv7HLcE1fh xi9hLE9fOQdnBqnAr7Sm/Ly/2hMATH/grzE3KI8zOxyJEYxjNvYKV6pHAEVWjT9XtjnL 0VNh2aU2bZlKHOlvBrEQ//SS2cLDK5mTmYmg8WBSS70VP8awo1KO/F2kqqYiLJEXz12p XZzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=zhpP4JnpNsRxYyCsXa/uiaJlYp5pfcUesjCAkban9ps=; fh=/NZX815RJy/ecOe1WbZ023sSZUJKZnpaeIZwQG5Ym7U=; b=v6A2LxQ1nZX6GhUO0SmbFZHV/zTi6CiF2r3/JBncTRxa7NSmpKrrOTu5Vj3hhfuOXL o4M0JsZ9UO8yDqFas6Gka7XHv1dKiAD+acpwJQ+xyRJpcQ3gz9ajc8u9mZ51RJpL43C0 DeWi4dgWC1pqIZf9nLzTQ8n/gWiL8DaOgURKEQrj8/1rl1tgBCBDm4dVpDzbWaQw3NQL h4COcfabE4sCq9BR6OUsx8golg5xQmioVzz52NNMwUI300c1GBH+7McOlDbx9F992iam JjGLl/nho0d3htGY9Xu5sqz6dY/YSn2vnraeeXNm4AMIOYkEFOEdOycM7d6ZL5Eh9UoH ZHTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="n/TOSPfP"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SEVcYqVS; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-150043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150043-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ku13-20020a170907788d00b00a524394aab8si844388ejc.599.2024.04.18.05.10.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 05:10:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="n/TOSPfP"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SEVcYqVS; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-150043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150043-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9957C1F217EA for ; Thu, 18 Apr 2024 12:10:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22FBD15F404; Thu, 18 Apr 2024 12:10:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="n/TOSPfP"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SEVcYqVS" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 822F815B578 for ; Thu, 18 Apr 2024 12:10:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713442227; cv=none; b=FzqJcKqtSvLYCfYD9HhZKbhkUSihbuhItfBUyETT30YBl6RUzBq+8aj5H1QXZfR2/JxFW2wY5rI2ipGL++Q8ge4bueTfDpXQTrJAlJ0vDj/cjkRvu4fSO6vyCXmKq6AYf5vx52nz6MozpH0J7kGeCiiYIvnqrr7q4iSGiZfCbMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713442227; c=relaxed/simple; bh=mmHxbgkvcdq7I9XxDoEzaG1qsDjLvp2IM6Ipv6u6XmQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=txdYxvtqL8xa+1n0nNi4dig+8uT1NwnUX6hfLERThgw/cVPSJFkRDzJ4zN7/79Cv7YcanTGGnGx1qHs9YCyMY4qxnA/PuFQpAG6ZooRtRI2oF+BYJlR25HCTJaiowZw14AHSG4JnAWa2igertkEyS/alIV5bUM0HYIGK/6zBkcU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=n/TOSPfP; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SEVcYqVS; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1713442217; 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=zhpP4JnpNsRxYyCsXa/uiaJlYp5pfcUesjCAkban9ps=; b=n/TOSPfPFWMaiK/uaHOYZHBbNHp0DmUpgkpuw2jj98/lvwnKjb6gd6njGvNPsInU8JwdQO 0IzMQgktOZ4HuAgQq0iGiyba8HYjNVrga7ixJ07C3salftCNWT0owgejewhRF8BBB5MCHv K9kmjdQxhVngj1JtpDQMcsBCPmmysIgnEC9YNxHoCrp6iQr+R+6GvEILYC4TBpNe5h3CQ5 TxMSxuTeGtNybdfUe4Jd1JZce+OSlQkz2c+PPSnJd5rxc3D4U9I8XFNfSUifFrDFLR96i8 YyLb1UpAqJKlyoRCYYrMGeasZMOPHdGWEaVs5KfbRcCAATJbbbinBhCz5XmlVw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1713442217; 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=zhpP4JnpNsRxYyCsXa/uiaJlYp5pfcUesjCAkban9ps=; b=SEVcYqVSFdKHuWo4xMfn1fFuZOCfsET5EguPBnsKQJkRBoaU8f0PJe/9nIqOtJSM2vvcft 9sxml5Ab6hwh/4Dw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: Re: [PATCH printk v4 06/27] printk: nbcon: Add callbacks to synchronize with driver In-Reply-To: References: <20240402221129.2613843-1-john.ogness@linutronix.de> <20240402221129.2613843-7-john.ogness@linutronix.de> <87y19djqr0.fsf@jogness.linutronix.de> <87bk68niod.fsf@jogness.linutronix.de> Date: Thu, 18 Apr 2024 14:16:16 +0206 Message-ID: <87h6fyswgn.fsf@jogness.linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On 2024-04-18, Petr Mladek wrote: > I am not sure how it is done in other parts of kernel code where > RT needed to introduce some tricks. But I think that we should > really start mentioning RT behavior in the commit messages and > and comments where the RT mode makes huge changes. Yes, our motivation is RT. But these semantics are not RT-specific. They apply to the general kernel locking model. For example, even for a !RT system, it is semantically incorrect to take a spin_lock while holding a raw_spin_lock. In the full PREEMPT_RT series I have tried to be careful about only mentioning PREEMPT_RT when it is really PREEMPT_RT-specific. For example [0][1][2]. [0] https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/commit/?h=linux-6.9.y-rt-rebase&id=1564af55a92c32fe215af35cf55cb9359c5fff30 [1] https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/commit/?h=linux-6.9.y-rt-rebase&id=033b416ad25b17dc60d5f71c1a0b33a5fbc17639 [2] https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/commit/?h=linux-6.9.y-rt-rebase&id=7929ba9e5c110148a1fcd8bd93d6a4eff37aa265 > The race could NOT happen in: > > + NBCON_PRIO_PANIC context because it does not schedule Yes. > + NBCON_PRIO_EMERGENCY context because we explicitly disable > preemption there Yes. > + NBCON_NORMAL_PRIO context when we ALWAYS do nbcon_try_acquire() > under con->device() lock. Here the con->device_lock() serializes > nbcon_try_acquire() calls even between running tasks. The nbcon_legacy_emit_next_record() printing as NBCON_NORMAL_PRIO is a special situation where write_atomic() is used. It is safe because it disables hard interrupts and is never called from NMI context. nbcon_atomic_flush_pending() as NBCON_NORMAL_PRIO is safe in !NMI because it also disables hard interrupts. However, nbcon_atomic_flush_pending() could be called in NMI with NBCON_NORMAL_PRIO. I need to think about this case. John