Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp355113pxb; Wed, 14 Apr 2021 17:39:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFq62Nn/bONzGAZV0VTGSRuCVyWGg0hcgBohHA2fm8EQPG1LwEb+AEZ2ws4MLSqtC9bdGT X-Received: by 2002:aa7:df95:: with SMTP id b21mr964955edy.338.1618447144365; Wed, 14 Apr 2021 17:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618447144; cv=none; d=google.com; s=arc-20160816; b=A6c63jA/KDyMhJCnfOuyTaDajjhUzIkHmnUGBETIiUTMUK3s/zJY8tCl4mcaY8j/9I g6iNYjBhiyz92WLnZ8E+BiGZiGmJ2+3WrDR1eOD1MK0XDLuvilTohafW2QyaUZxzzE6W 9FV/pbTQGkEEGTuOTUccYOhwtA+AuvoCQ5j7oobXq+0Un5fL6fGSjLEWJPM1hMwihCPJ Z6BoKNrAlfzWc0Rl9G0G24BIU9NgnQFh6MIxmxbQj3jA17axei8M43Cb6PFEhjhhVD4J /7CcQmyDawnRp9ozyPQNdWPsaJK9U3J3e13vMEYiSqr9NVxzDddddgcDMrQL39DZbECv LEsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zqnsSjijlDG5mETYLx6fpmqZMJsm0kdSrlijsYb2gIA=; b=aWI9o/wbV6qQPyEnM6bU+X4GSvFOyPD8mRlfcgQJL13iQOewX/LjDserKhDqz1E3QP w+jx9UNFLknLO5OB0NWVbWT/tM1uVWrc2KTEnqfzG3PRbUQsl8yWSsFhSAalx7p0sD5y yXR828PlYjFcp75bYWV/B6M/5BXZF99TtuM00W+QfKFRADjHueE1ufMFo4lF+JEd2kVb XU6dcLNMNIFMAw9beaPXETXCAa9Z/e+GlOSW0JDg42jq4vWb9ApZrxE+zqkrBKY/RAFs cTsdZmWSPz2xJQ/1an7ihQkajlxEPYPGd5X6kvwwpVrm5zI0haQH5LGdf5AQSa2je6gU dbtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=tOt8HYaz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si691600ejx.574.2021.04.14.17.38.40; Wed, 14 Apr 2021 17:39:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=tOt8HYaz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351022AbhDNRhS (ORCPT + 99 others); Wed, 14 Apr 2021 13:37:18 -0400 Received: from mx2.suse.de ([195.135.220.15]:53592 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350752AbhDNRhS (ORCPT ); Wed, 14 Apr 2021 13:37:18 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1618421815; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zqnsSjijlDG5mETYLx6fpmqZMJsm0kdSrlijsYb2gIA=; b=tOt8HYaznpNtfzYlBCt1743v9GFzCOSkq7kG21aRuvWJgkvndZaOARndMRilVmOz/ymyk9 6vM/7Y9RbDT4xPFZc0Pvr+FTkH1B9mXhXORD7fwi5KLHXl+YWOq4q4ab8KW6eDXcjUEklY n5BxV9dWbWOWwlXitn/HWEFxtzkAYK0= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 81369B007; Wed, 14 Apr 2021 17:36:55 +0000 (UTC) Date: Wed, 14 Apr 2021 19:36:54 +0200 From: Petr Mladek To: Samo =?utf-8?B?UG9nYcSNbmlr?= Cc: Tetsuo Handa , Jiri Slaby , Sergey Senozhatsky , Steven Rostedt , John Ogness , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: Re: How to handle concurrent access to /dev/ttyprintk ? Message-ID: References: <3c15d32f-c568-7f6f-fa7e-af4deb9b49f9@i-love.sakura.ne.jp> <051b550c-1cdd-6503-d2b7-0877bf0578fc@i-love.sakura.ne.jp> <157d81a5eb9e56e47e40c1cd652cdc7a915cb755.camel@t-2.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2021-04-13 17:22:46, Samo Pogačnik wrote: > Dne 13.04.2021 (tor) ob 16:32 +0200 je Petr Mladek napisal(a): > > On Tue 2021-04-13 13:10:50, Samo Pogačnik wrote: > > > Dne 13.04.2021 (tor) ob 11:41 +0200 je Petr Mladek napisal(a): > > > > On Mon 2021-04-12 14:41:27, Samo Pogačnik wrote: > > > > > Dne 12.04.2021 (pon) ob 19:39 +0900 je Tetsuo Handa napisal(a): > > > > > > What is the intended usage of /dev/ttyprintk ? > > > > > > > > > > > > > > > > The intended use of 'ttyprintk' is to redirect console to /dev/ttyprintk > > > > > via the TIOCCONS ioctl. After successfull redirection, all console > > > > > messages get "merged" with kernel messages and as such automatically > > > > > processed > > > > > (stored/transferred) by the syslog service for example. > > > > > > > > The same can be achieved by /dev/kmsg that was created by systemd > > > > developers. > > > > > > > > > > 'kmsg' and 'ttyprintk' are different types of drivers and as such rather > > > complementary than exclusive. The 'ttyprintk' being a tty driver allows > > > for a system wide automatic redirection of anything written to the > > > console. > > > > I might miss something. But how can one setup ttyprintk as the system > > wide console? I do not see any code that would use ttyprintk > > in struct console. > > > > You can compile this simple code below and call: > > # ./tioccons /dev/ttyprintk Thanks a lot for the example. My head is still spinning around it. I have troubles to update my mental model around /dev/console with this use case. My original model is that kernel or processes write into /dev/console so that a human could see and read it on the device attached to the console. kernel is calling console->write() callback when showing new messages on consoles. The write to the redirected /dev/console makes the messages appear in the kernel log. It feels like it should create an infinite loop. Except that it doesn't work this way. Sigh. Best Regards, Petr