Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp394644ybl; Wed, 11 Dec 2019 01:19:42 -0800 (PST) X-Google-Smtp-Source: APXvYqwEej/OeCT8+rGFKh9bvhTtuyz9c6C9716GUlI6ksCE06TdrEqi63VuPvgIvyqRG6SAC5Dx X-Received: by 2002:aca:c692:: with SMTP id w140mr2008090oif.139.1576055982734; Wed, 11 Dec 2019 01:19:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576055982; cv=none; d=google.com; s=arc-20160816; b=eBLE+RTDCpzLBjQMykW0iciFMb48/1bVklL3BQtO2WavtkL1GZZtbmpSpI0kZXwH2U W6vUMAjjbRhowzS8yR/Jk6BsIJLgUx302+W45M5DJm9w7C/4OtD7KqgVWbL2x0xxeRFs s96QdVeTzVv9YWUXvraiMl/xnqgfSmhF55AYk3Hk4IrwQhZhSu3LCSRzKJxSKx2LSeho DUNKxl/jmYrhrT7cA1orcWCuHUtCGlDH1g9wYztygsmsJ13SNGi/RRRWRiEI1zzOUVDP 6ESRL8A7nW+aRJtnYozs/YVj13rJXyLNk/MFqBEmEmht1OTAVamTAxj1lYmuQzkcaDHq f29w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=QjTFEKT5qis2lXQ8f2DMjCf5ajY3ZKcanOQDnzRCNA8=; b=SoncwhKj4MACD9etkx2SIYmhhiugKwtQ2iXik3BPQYh+TNvEb+sKrTxn5tEA4UoUJz tNT+KKk2Jx3OisjCMLWGhLjW7gyZwyd+HGLyxvLorY7igcJHV0X6wsdJgfdPE7nnhrfr ABnyvtjD+lmTKgFLptpJylBWfCA0tQKxjkOfkLXsUutRudhSatz48wAmDWxPYWPxRqN3 sUgDFwIo2bweknt/597o5fuIsxB06Qjxvsp24VhnYzuB7tq1Zv5oaxTMm7lruu3SEx5R MyKKkStrw6kUvbss7ZMeDfwTMBNzMogp5MFvcRxYltqYVG81hYdfTVN7WFZ5YOVUtixM vkcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r21si719067otd.276.2019.12.11.01.19.31; Wed, 11 Dec 2019 01:19:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728478AbfLKJRo (ORCPT + 99 others); Wed, 11 Dec 2019 04:17:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:56376 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726983AbfLKJRn (ORCPT ); Wed, 11 Dec 2019 04:17:43 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 57636AB89; Wed, 11 Dec 2019 09:17:41 +0000 (UTC) Date: Wed, 11 Dec 2019 10:17:40 +0100 From: Petr Mladek To: Benjamin Herrenschmidt Cc: linux-kernel@vger.kernel.org, Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , AlekseyMakarov Subject: Re: [RFC/PATCH] printk: Fix preferred console selection with multiple matches Message-ID: <20191211091740.p6bgjy7sy75maenw@pathway.suse.cz> References: <20191210091502.qoq55fdjad6aixab@pathway.suse.cz> <50d2c44a15960760c6a9d24442a93fa4b31b7594.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50d2c44a15960760c6a9d24442a93fa4b31b7594.camel@kernel.crashing.org> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2019-12-11 09:39:06, Benjamin Herrenschmidt wrote: > On Tue, 2019-12-10 at 10:15 +0100, Petr Mladek wrote: > > On Tue 2019-12-10 11:57:26, Benjamin Herrenschmidt wrote: > > > In the following circumstances, the rule of selecting the console > > > corresponding to the last "console=" entry on the command line as > > > the preferred console (CON_CONSDEV, ie, /dev/console) fails. This > > > is a specific example, but it could happen with different consoles > > > that have a similar name aliasing mechanism. > > > > > > This tentative fix changes the loop in register_console to continue > > > matching with the array until the match is actually the preferred > > > console. > > > > One problem with this is that con->match() callbacks might have > > side effects. If the console matches, the callback sometimes > > do some changes in the console driver because it expects > > that the console is going to be registered and used. > > It will still be enabled. I am not changing that. The main issue would > be if the match callback chokes on being called multiple times. And this would exactly happen as pointed out by Sergey. match() does also some setup operations. I would be scared to call them twice. > This looks indeed a lot more invasive. Is there any reason why what I > propose wouldn't work as a first patch that can easily be backported ? Your solution is not acceptable because it might cause calling match() more times. The reverse search of list of console does not work for ttySX consoles because the number is omitted when matching. And the messages will appear only on the first matched serial console. There is a paragraph about this in the commit message of my patch. > We can continue cleaning up from there of course, but I'd be keen on > having a minimal fix that can go back to stable first. I would be fine to take my patch as is and do the clean up later. It seems that more users are affected by the problem. The clean up might be complicated and prone to regressions. The question is how far back you would like to go. The changes in register_console() are rare. Everybody is scared to touch this mess ;-) And it is prone to regressions. > I'll give it a spin. However I don't fully grasp why it's necessarily > so complicated. Correct me if I'm wrong here but you are trying to > address two issues in that patch: > > - The one I'm trying to address which is that we might "miss" the > preferred console in the case of multiple matches. > > - The fact that when the preferred console isn't found, the one we > default to (which ends up first in the list) is missing CONSDEV. My patch is primary fixing this 2nd problem. It fixes showconsole tool to work correctly. But it covers also the 1st one. It might be possible to split it when needed. But I think that you could not easily fix the 1st problem without solving the 2nd one. The best solution would be to split the match() and setup functionality. It would be really appreciated. But it is a lot of work. And it might be hard to backport. Best Regards, Petr