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.8 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 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 12E7FC433ED for ; Tue, 27 Apr 2021 10:08:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C219560FDA for ; Tue, 27 Apr 2021 10:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235275AbhD0KIz (ORCPT ); Tue, 27 Apr 2021 06:08:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:36312 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235303AbhD0KIx (ORCPT ); Tue, 27 Apr 2021 06:08:53 -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=1619518089; 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=UbRt3ADypZu1Qx6u0tSZO6+NBi1xHyRWflz8+gg2fs8=; b=c5LLRgkuGWYxr+jlRctOqwBDuk+/ePHjK7cQ3H0vqD2eEFCydTNx4efTmR9Y8XSjsCTnbL TLhTaJmOBOGSVbGa1qsr4HpHrAFpkihHsFc9OwFWbMSN6e6iFPNC6LFlqB+ukR06lZlKeU 23KbjI1FpB4lBsACeS9LhP63o8aTGKc= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 57679AFC6; Tue, 27 Apr 2021 10:08:09 +0000 (UTC) Date: Tue, 27 Apr 2021 12:08:08 +0200 From: Petr Mladek To: Samo =?utf-8?B?UG9nYcSNbmlr?= Cc: Tetsuo Handa , Jiri Slaby , Greg Kroah-Hartman , Sergey Senozhatsky , Steven Rostedt , John Ogness , linux-kernel@vger.kernel.org, syzkaller-bugs Subject: Re: [PATCH] ttyprintk: Add TTY hangup callback. Message-ID: References: <17e0652d-89b7-c8c0-fb53-e7566ac9add4@i-love.sakura.ne.jp> <8043d41d48a0f4f13bd891b4c3e9ad28c76b430e.camel@t-2.net> <699d0312-ee68-8f05-db2d-07511eaad576@kernel.org> <33461bad-ef57-9036-135d-95a60a8c88d5@i-love.sakura.ne.jp> <07c3c9015491ca9b42362098d5e90ca7480cf5ed.camel@t-2.net> <9e8805a98d6c0d0f20e563c8e4db98b595826c13.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 Mon 2021-04-26 18:42:05, Samo Pogačnik wrote: > Dne 26.04.2021 (pon) ob 12:00 +0200 je Petr Mladek napisal(a): > > It does not matter how much buffering games you play. As long as you > > use printk() to store single lines into the kernel logbuffer they > > alway could be interleaved with lines from other processes/CPUs. > > Exactly. The only purpose of ttyprintk buffering is to mark any begining of > lines occurring within the userspace-string written into ttyprintk TTY. The > marked lines do not originate in the kernel source code, which is not obvious > otherwise (imho this is importannt). Even the CONFIG_PRINTK_CALLER=y does not > give this information, if the task ID printed does not live anymore. I guess that you mean TPK_PREFIX + "[U] ". > > I am not sure if I understand the problem. But why does ttyprintk need > > any buffer at all. AFAIK, the use-case is to pass any written data into the > > kernel logbuffer via printk()? > (see above - it is not something the kernel is telling you) But you could do this already in tpk_write(). I mean that you could parse the given buffer, copy each line to a temporary buffer, and call printk(TPK_PREFIX "[U] %s\n", tmp_buf). Why is it postponed to tpk_close()? IMHO, the printk() in tpk_write() might simplify the logic a bit. > > Why tpk_write() does not call printk() directly? > (see above) > > > > If you call printk() directly, the caller_id would be from the process > > that really wrote the data/message. > It can be a kernel-code originating message printk-ed on behalf of a user task > or a kernel-code originating message on behalf of a kernel task. Or it may be a > user-code originating message on behalf of its task, when printk-ed via > ttyprintk. Exactly. Now, I am not sure if you think that this good or bad. IMHO, it is much better to use caller_id of the process/context that wrote the data/message instead of the process that caused the final tpk_close(). Anyway, it is not a big deal. We could leave the code as is if it works for you. My mine intention was to stop the ideas of per-task buffers and additional complexity. It was just an idea how to simplify the code instead. Best Regards, Petr