Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4355460pxy; Tue, 27 Apr 2021 03:09:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIjFPlPLHYQ4sLG8rPbuaMKbQqHbRlDuVRAXsa463RBN+KE6dt68JaJa+zWyxcnHbkySC9 X-Received: by 2002:a17:902:778f:b029:ec:d04d:4556 with SMTP id o15-20020a170902778fb02900ecd04d4556mr22782957pll.43.1619518158279; Tue, 27 Apr 2021 03:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619518158; cv=none; d=google.com; s=arc-20160816; b=aXZgWGEHH6tJH/t6vx6HbtZEd08ZrGDPPD/7JTKXjhpRZ8l9/NpxZfGk+MmYJ1fI0W Tz1sdJv97FkoET3kv7xFPdbcEBXiVGho+ZFJ9OOgGI8Gm1htGcRXPjr6802axxW1TncZ EIQenX66sXU91Zzr1Pv4XHJeBrTkDBv6NDtlrGqwRXSwi2uHn0e+LEBMS5bEfJdtmNdD LESpV3RkdgdfldG/48X7R3N5hmH7ODqiHZ+0KqUZOFMcKXyeSn8993BG8vNespZKTqGG Y1pbFag3CVXeRHoz09pcIHxOOsmGcwsiHTmwy2ldTI6Yy4KBgOjp0cJEd8SgnTm0Qytj M4GA== 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=UbRt3ADypZu1Qx6u0tSZO6+NBi1xHyRWflz8+gg2fs8=; b=xoFky1bwBSo8CD9HoiQzQNxLUkXDYVyT5AXEdID4hTDxwdqmqg5/DzT9BWR/E98kFv aLsB0EwvIpaGnxgvd4cYJMMljAquvCXXbDcGhQ2Tur+8XeJbVgYyG40XBM5Y/i8v1Qt/ 6gebgwZdohWG5aRxwqMAgZRrd7XnPYOlvgZIQIsTnyEtXpfIhk9wIPunFOE1j8usl9qB OQyxX0l6RkW/0D8HeenW98XUiz+o+2YwxFIagdmuaGbdNoCtPCedrkYYmAmYPkdo2ZmT FFW8u0iy2EcgE4f+YFw9EiQYWG6m+bNEs90hEjAnRaXepq5I05gfHXqltwnJvtCBHfYv jq6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=c5LLRgku; 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 b10si21805254pgw.174.2021.04.27.03.09.04; Tue, 27 Apr 2021 03:09:18 -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=c5LLRgku; 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 S235334AbhD0KIz (ORCPT + 99 others); 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