Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1631017pxy; Fri, 23 Apr 2021 12:49:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVCE0jPyhZrZM7GxCnCFubn2IezK+IJ1oXoSBYc0bkvNc1Ynn7pF3Ojv+3OsPis69X551a X-Received: by 2002:a17:902:d911:b029:ea:cc53:5501 with SMTP id c17-20020a170902d911b02900eacc535501mr5592030plz.21.1619207342964; Fri, 23 Apr 2021 12:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619207342; cv=none; d=google.com; s=arc-20160816; b=Mv1R/Vpt0n5/C4pU5XzDHu4II4vT4IYH5Bcuw8L86EBz5sn5wQwxfFGVhtfLE7kiwc pE1Zw0Ccn3ESobLqz29WnYhoSQ82c3lRHfL7A/SaxVNm5ck6CZ+RNk5LBjeg5kaZmKGL Sn28YQkMNeQ9ivYXbL6dZ3lJrC1k0M02+XJQMot/f7whpTICRUM+Uv8YZpHJ9SBEy4L3 OGCEWEeCRtIRRGiNbO87hFbMt+hnR2BDk4GAC6ACIQIAAZmlV1aznjlMGdD3c6DIGXdO TdIB/3YFwTwjDKFabMFI+YYrakf/7mYL7hPOAhinD4eBf53xKFJ1/hPg9raKXcNXbcMq VVIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=N3qKqrIfeI2HjmXxQvaS4CVJCUT4xjltxefRMLU7KyU=; b=SN12le3E0tSaOBX8yCRxGvd0SDCwsVLMyLUuBxbCTg1xGW0q4yn7IVhUx7WJ3seXCf FpHB5sUHLvEzSZKVhJJxxJUiGskUL4kqbaSZ7iG8chHLFWTkK7z/y+aNVzolsHuo2pWA klTmm9c66RTVEMBSyKQooU5L7rZTmK2aH5vqH+q9RS4euD+5UoItlZ3ULKB1mN/L3Jxp PtwIARTYwSLeHKF8QSjOt5Cxcz++tR3wNYUGsKPTnajWm55aSfFdCvkepx+4X3M38a4b 3O5wrJWRDlmdA5LYu0mot7Mk4SXkNjhnZ2LyODF1O/RCX4Ylmt6QOex4sESHBKwIb1lx IFCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-2.net header.s=smtp-out-2 header.b=KTstc+Nr; 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=REJECT dis=NONE) header.from=t-2.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u25si7686843pfh.192.2021.04.23.12.48.32; Fri, 23 Apr 2021 12:49:02 -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=@t-2.net header.s=smtp-out-2 header.b=KTstc+Nr; 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=REJECT dis=NONE) header.from=t-2.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231721AbhDWTsS (ORCPT + 99 others); Fri, 23 Apr 2021 15:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbhDWTsR (ORCPT ); Fri, 23 Apr 2021 15:48:17 -0400 Received: from smtp-good-out-4.t-2.net (smtp-good-out-4.t-2.net [IPv6:2a01:260:1:4::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5F5C061574 for ; Fri, 23 Apr 2021 12:47:40 -0700 (PDT) Received: from smtp-1.t-2.net (smtp-1.t-2.net [84.255.208.30]) by smtp-good-out-4.t-2.net (Postfix) with ESMTP id 4FRlF63sCbz1FxZ; Fri, 23 Apr 2021 21:47:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-2.net; s=smtp-out-2; t=1619207258; bh=3yGHUd8Z+HJ9p1kGXM3dg0c8vffZFIHtV0TYAfwi9e4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=KTstc+Nr4YLkP6QCNDayPMBFRcswz2s1+ovlVsqhsu47ApeEXO4so+61GUeksxUyH ahQCWGdy/uNxTAKyoUqBBUGw/UdKMS7NCvXhLlriMfev06V93eZxWD/v06BfioHD8b NvYOSWP5IizphvRjRjoMt1Oap8DL0PNO1CnHUJvk= Received: from localhost (localhost [127.0.0.1]) by smtp-1.t-2.net (Postfix) with ESMTP id 4FRlF63j3BzTpmmn; Fri, 23 Apr 2021 21:47:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at t-2.net Received: from smtp-1.t-2.net ([127.0.0.1]) by localhost (smtp-1.t-2.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id swBwA3IceKnf; Fri, 23 Apr 2021 21:47:38 +0200 (CEST) Received: from hp450g3 (89-212-91-172.static.t-2.net [89.212.91.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp-1.t-2.net (Postfix) with ESMTPS; Fri, 23 Apr 2021 21:47:02 +0200 (CEST) Message-ID: <07c3c9015491ca9b42362098d5e90ca7480cf5ed.camel@t-2.net> Subject: Re: [PATCH] ttyprintk: Add TTY hangup callback. From: Samo =?UTF-8?Q?Poga=C4=8Dnik?= To: Tetsuo Handa , Jiri Slaby , Greg Kroah-Hartman Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , John Ogness , linux-kernel@vger.kernel.org, syzkaller-bugs Date: Fri, 23 Apr 2021 21:47:01 +0200 In-Reply-To: <33461bad-ef57-9036-135d-95a60a8c88d5@i-love.sakura.ne.jp> References: <20210403041444.4081-1-penguin-kernel@I-love.SAKURA.ne.jp> <3c15d32f-c568-7f6f-fa7e-af4deb9b49f9@i-love.sakura.ne.jp> <051b550c-1cdd-6503-d2b7-0877bf0578fc@i-love.sakura.ne.jp> <32e75be6-6e9f-b33f-d585-13db220519da@i-love.sakura.ne.jp> <095d5393-b212-c4d8-5d6d-666bd505cc3d@i-love.sakura.ne.jp> <31a4dec3d36ed131402244693cae180816ebd4d7.camel@t-2.net> <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> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dne 23.04.2021 (pet) ob 19:12 +0900 je Tetsuo Handa napisal(a): > On 2021/04/23 18:55, Samo Pogačnik wrote: > > > > Using the supplied test code, i've tested the patch on my desktop > > > > running > > > > the > > > > 5.4 kernel. After applying the patch, the kernel warnings like > > > > "ttyprintk: > > > > tty_port_close_start: tty->count = 1 port count = 11" do not appear any > > > > more, > > > > when the test code is run. > > > > I think the patch is ok. > > > > > > I wonder if the buffer shouldn't be flushed in hangup too? Or better, > > > the flush moved from tty_ops->close to tty_port->ops->shutdown? > > > > > > thanks, > > > > Good point. I tried the following additional change, which seems to do the > > trick. What do you think? > > > > Shouldn't the tpk_printk buffer be per a "struct file" (i.e. allocated upon > open() and released upon close() in order to allow multiple users) ? Final destination of the ttyprintk is printk(), which is a single destination. The tpk_printk buffer is a common representation of what is yet to be printk-ed depending on the formatting conditions within the buffer. At any point the tpk_buffer is potentially multiplexed/interleaved by parts of required output of any concurrent user, as buffs are being delivered by the scheduled writes. As per user buffers look promising with output formatting, the FDs passing between tasks lead to the same single buffer (Greg already mentioned that). The other thing which is important to me is the console redirection to ttyprintk, which automatically brings all concurrent console users to the single open of ttyprintk. best regards, Samo