Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4440521rwl; Tue, 28 Mar 2023 07:05:57 -0700 (PDT) X-Google-Smtp-Source: AKy350bWjVxHK2qK4XjYoQN3XJv1YesCy9BLhw9s35s6Zv95NKOsKBqPtLjRPOke3QHLy9SVpuy2 X-Received: by 2002:a17:907:2175:b0:920:7a99:dcd4 with SMTP id rl21-20020a170907217500b009207a99dcd4mr16254537ejb.62.1680012357488; Tue, 28 Mar 2023 07:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680012357; cv=none; d=google.com; s=arc-20160816; b=Y/mviX8eTqNP5FQg5aqg9Tb2BlRDd6gqPFuyzY7XZ4y86aKyMzjAkzfQOVASdL3PV/ nUGgQdgxKS2Ej6ih13cAt1+/qeDVF+2D9T7DVLNc9rOKTEK1jetVBk29lH56xt6ISYy6 L6zktptBUwdM6aeB0DYrHABQEobh+qekPa00+LftE/yHIoeevSvSJpF8gwUux1V/Whcp KZ6FBrbEXcbU1mIEZHIYYSnbFNb6ug+shaynifcqLp3BJ/4spygjg7L13Rv6u56tCjDd l8kCKvxvgbjt/3nFMxm6rEHYj1gDwj5XrWRmUooz1hiVMIk9W1JP2IPr9hawSQSikthk JxXA== 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=AVBcqEYEGKTnf7WGbkGOAukA8G1Pz6BlAEfJJGZegkE=; b=HUnsehaLTdWz5v/4bhxzyGHyy9Ma9B8tSL7Pwk1f4M+zMA9hG6lCwGsyPMNCLBvRzC 0gm6KDFv1so/bMT6JawKzKCEuYPJBzeUrnS/3BD+j4nzoGrOc5INHiJXHLLzqx8FnrRd SgytVIvzPKq5qJcfiqctM4qehLbq7bhibw751Y1mzHYDpFSY/952HzsAVfkaX3CCkPwZ AWjsLCdccQA2LJlI1ZuBFgShSEh8PGu6Rj92yVpDUtm5+IYl+HsdxvvbjQno+mu09zxU SH2DVjbKf3lG3C+rZ5H5uXJ7lKIPajYdlDsNqA4JCTTMlIGcLQNwUEOiEz2NYvjgLYaD cDfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Qr5nmE8H; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XlMGHhzS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gr8-20020a170906e2c800b008e6266cd19csi31961478ejb.935.2023.03.28.07.05.32; Tue, 28 Mar 2023 07:05:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Qr5nmE8H; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XlMGHhzS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233086AbjC1N7l (ORCPT + 99 others); Tue, 28 Mar 2023 09:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232957AbjC1N7b (ORCPT ); Tue, 28 Mar 2023 09:59:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D29E7C651; Tue, 28 Mar 2023 06:59:18 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1680011957; 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=AVBcqEYEGKTnf7WGbkGOAukA8G1Pz6BlAEfJJGZegkE=; b=Qr5nmE8Hzfwst5KZgNjYoFM8HsLQhJkEdDi1f8YG7E2l6RW3I42AYUnd3Hj1dvU5eX6ucE GVg+jehpW7GdmqKghuc5lozEBjGFsuvQffCAWB3VU0HXTrToz1MAwJdoVuMf2ANcPXbKco lhCcdky/Da1Db5huCooHTwdeTfILjgiUjH/GDxsXgH1xX15uImZ9mM3zJv67wmrm+jjGUG Q5lPW37rXRdSYabbj2GV/aaDAsbu2UylovBlnI13TApvcR01HhbVh7P9BjmMcZGUuzmuND cShYSAlNbZ04zECY/+957ip3qCIjIt1ZT6CJ0lscZ3Se7Zdb0ZYpmMJkoFl8Jg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1680011957; 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=AVBcqEYEGKTnf7WGbkGOAukA8G1Pz6BlAEfJJGZegkE=; b=XlMGHhzSeLwTANt8K1piDZMwaiCTaHp3KPSQN9MATRV1Z9q5RIO3cVA0Gj8zfnAzt+Fsrk FK/+1PyuIPZ0BcBw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Aaron Tomlin , Luis Chamberlain , kgdb-bugreport@lists.sourceforge.net, Greg Kroah-Hartman , linux-fsdevel@vger.kernel.org, Andrew Morton , "Guilherme G. Piccoli" , David Gow , Tiezhu Yang , Daniel Vetter , tangmeng , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , rcu@vger.kernel.org Subject: Re: locking API: was: [PATCH printk v1 00/18] serial: 8250: implement non-BKL console In-Reply-To: References: <20230302195618.156940-1-john.ogness@linutronix.de> <87wn3zsz5x.fsf@jogness.linutronix.de> Date: Tue, 28 Mar 2023 16:03:36 +0206 Message-ID: <87a5zxger3.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-03-28, Petr Mladek wrote: >> + if (!__serial8250_clear_IER(up, wctxt, &ier)) >> + return false; >> + >> + if (console_exit_unsafe(wctxt)) { >> + can_print = atomic_print_line(up, wctxt); >> + if (!can_print) >> + atomic_console_reacquire(wctxt, &wctxt_init); > > I am trying to review the 9th patch adding console_can_proceed(), > console_enter_unsafe(), console_exit_unsafe() API. And I wanted > to see how the struct cons_write_context was actually used. First off, I need to post the latest version of the 8250-POC patch. It is not officially part of this series and is still going through changes for the PREEMPT_RT tree. I will post the latest version directly after answering this email. > I am confused now. I do not understand the motivation for the extra > @wctxt_init copy and atomic_console_reacquire(). If an atomic context loses ownership while doing certain activities, it may need to re-acquire ownership in order to finish or cleanup what it started. > Why do we need a copy? When ownership is lost, the context is cleared. In order to re-acquire, an original copy of the context is needed. There is no technical reason to clear the context, so maybe the context should not be cleared after a takeover. Otherwise, many drivers will need to implement the "backup copy" solution. > And why we need to reacquire it? In this particular case the context has disabled interrupts. No other context will re-enable interrupts because the driver is implemented such that the one who disables is the one who enables. So this context must re-acquire ownership in order to re-enable interrupts. > My feeling is that it is needed only to call > console_exit_unsafe(wctxt) later. Or do I miss anything? No. It is only about re-enabling interrupts. The concept of unsafe is not really relevant if a hostile takeover during unsafe occurs. In that case it becomes a "hope and pray" effort at the end of panic(). John