Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1717901pxb; Wed, 9 Feb 2022 03:02:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZ+FAIP2/sG1CND8paYfHfFEjmJ3tH5YhIImZmp7P02670VE0viyaoZjlQScvTDICmxO+g X-Received: by 2002:a17:90a:d203:: with SMTP id o3mr2774247pju.122.1644404535145; Wed, 09 Feb 2022 03:02:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644404535; cv=none; d=google.com; s=arc-20160816; b=DvCwJY2b4K4BaCelocNJNPRae7jbL+2+Lt3uiKXU6MQKKk8OWGcvlBpT1j5VbegIQ1 hDsKnCM+iXAhgs7MgkLopyPjwIcGkLaGHW/Jz1l2m9gAxBw2h1WDLjw599m/DFsFtYwk jKcLSws6aK3+RuJt/MEaebkZ5UFrG5XCZSkiokOrkZE1IVPO33qM7goKqKEkSOVd4DL2 9MHDv2+0BnI7PzV8ZG0DonGIAmnv9WUs5fu3LxnUqR/e5S+sL7blIv05YAraLSwSzr98 dS0HB2UPaAGHSvSJzlZ8omW2ljv6Xj2QFZxKrbavnXy32JEX+hdCaXUppA2dYIOzbSMN vNRw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aHdm3+5pE3/cs331fyA3/X0W3c2j4ed34sm5EWt22qo=; b=TYyHumHAk+O2FQ20vaJSAvPBtb+C6hOqZfi0zXAasK8FsN7hGkSCDEe+BGw1gZdkUT 7ko2yDb7hN4XOboSxbp1sYf90RnBFXbmJiRV6QrfH33rGDOLboyC7sxXKCMjc0TF6ezt osB8bXX8Yam4ilo8CQ+hekdL1NEfI2shbQTS4nZlPk8Ylf3rfMjXtB5+neTfyVa6YqYb Sl7/mKBy40fntu6KjyuXe6526g6E+cU3tVCNiQhporIZP5/i4LtAL0pOFxyerMgFRB+/ zuwwjTww+sURuowIFnRDOnlHgicmoWebYj8GTh6BKrdZV6kZKBjoIPrqk8M/Ulpf1NPu WssA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jstWx8Jd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e3si15291448pgb.68.2022.02.09.03.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 03:02:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jstWx8Jd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 856E6E050446; Wed, 9 Feb 2022 01:30:52 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243242AbiBGHRu (ORCPT + 99 others); Mon, 7 Feb 2022 02:17:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239806AbiBGHOm (ORCPT ); Mon, 7 Feb 2022 02:14:42 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 188ADC043181; Sun, 6 Feb 2022 23:14:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A8AD560F1C; Mon, 7 Feb 2022 07:14:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 461A0C004E1; Mon, 7 Feb 2022 07:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644218080; bh=nniw70zMD1lKzi3bsESypvce1FBgSmU6hzhxOyTg6f4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jstWx8JddCSgvPIAV9wlSPQdIkMYIpz4LNBcEqkUl9QmFIRyUZ5PDBxeW1clz27ek ZEG/1tHsXP6nGyN+a87Xes3hqV/h12a/XBnyEYIjLvly0Jq7C+wvp9pAFve1MQxcyl EGG09eqc25QSDMecwnWoYiTIiKP2yg1HuKeQBeIU= Date: Mon, 7 Feb 2022 08:14:34 +0100 From: Greg KH To: Yu Xu Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, arnd@arndb.de, viro@zeniv.linux.org.uk, dhowells@redhat.com Subject: Re: [PATCH] chardev: call tty_init() in real chrdev_init() Message-ID: References: <4e753e51d0516413fbf557cf861d654ca73486cc.1644164597.git.xuyu@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 07, 2022 at 02:37:46PM +0800, Yu Xu wrote: > On 2/7/22 1:03 AM, Greg KH wrote: > > On Mon, Feb 07, 2022 at 12:27:31AM +0800, Xu Yu wrote: > > > It is confusing that tty_init() in called in the initialization of > > > memdev, i.e., static chr_dev_init(). > > > > > > Through blame, it is introduced by commit 31d1d48e199e ("Fix init > > > ordering of /dev/console vs callers of modprobe"), which fixes the > > > initialization order of /dev/console driver. However, there seems > > > to be a typo in the patch, i.e., chrdev_init, instead of chr_dev_init. > > > > > > This fixes the typo, IIUC. > > > > > > Note that the return value of tty_init() is always 0, and thus no error > > > handling is provided in chrdev_init(). > > > > > > Fixes: 31d1d48e199e ("Fix init ordering of /dev/console vs callers of modprobe") > > > Signed-off-by: Xu Yu > > > --- > > > drivers/char/mem.c | 2 +- > > > fs/char_dev.c | 1 + > > > 2 files changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/char/mem.c b/drivers/char/mem.c > > > index cc296f0823bd..8c90881f8115 100644 > > > --- a/drivers/char/mem.c > > > +++ b/drivers/char/mem.c > > > @@ -775,7 +775,7 @@ static int __init chr_dev_init(void) > > > NULL, devlist[minor].name); > > > } > > > - return tty_init(); > > > + return 0; > > > } > > > fs_initcall(chr_dev_init); > > > diff --git a/fs/char_dev.c b/fs/char_dev.c > > > index ba0ded7842a7..fc042a0a098f 100644 > > > --- a/fs/char_dev.c > > > +++ b/fs/char_dev.c > > > @@ -667,6 +667,7 @@ static struct kobject *base_probe(dev_t dev, int *part, void *data) > > > void __init chrdev_init(void) > > > { > > > cdev_map = kobj_map_init(base_probe, &chrdevs_lock); > > > + tty_init(); > > > } > > > > You just changed the ordering sequence here, are you SURE this is > > correct? > > To be honest, not 100% sure. > > > > > How was this tested? Did you verify that the problem that the original > > commit here was fixing is now not happening again? > > I tried to reproduce the issue described in the original commit, and > failed. The issue does not appear, or my reproduction is wrong. > 1. revert 31d1d48e199e manually; > 2. request_module("xxx") anywhere before do_initcalls(), since > tty_init() now is initialized by module_init(); > 3. no warning on request_module is shown. > > > > > And what real problem is this solving? How did you hit the issue that > > this solves? > > No real problem actually. As described in the log, it is confusing that > tty_init() in called in the initialization of memdev. They don't have > strong dependencies. I found the issue when I read through codes of > drivers/char/mem.c. It was added here as the linker order is what describes the init calls, and this call is probably needed before other code in the init call order, when things are built into the kernel. That might help in your debugging. good luck! greg k-h