Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5429616rwn; Mon, 12 Sep 2022 08:56:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR4LQYU/TUbdnnlT3x0LToUtKhr9MifELsB6Y/r9x/7Xel+xbO6eXtZFwrvfLa54ycdstnmC X-Received: by 2002:a17:902:6b42:b0:172:ed37:bc55 with SMTP id g2-20020a1709026b4200b00172ed37bc55mr26749404plt.33.1662998180568; Mon, 12 Sep 2022 08:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662998180; cv=none; d=google.com; s=arc-20160816; b=yGmcAz7ah5bR6NHajmGNvWrg5pCUVakItosXIJ3S1EIxjX6Ec7s+YEKWQWoJQYj4Hj kjWPFURJ/P6LCwF0JBdwgT8pEHQvyTra6LkaNUVbgmP0KZG6NoUwkLHX/aATkhoQnbYK PteJP6VD/7tWVUBrcbdu0SyFXV5bsDG8tbWmUkWQ+nCLOcAn3FKgeVNBhYdsxbNKkb3D dnBlGEeYzqQI4ku3eCw6PQbY7U6rJnfVkYBm+hfy3YlTlpYEOqqxRRXaJSXCWutzo+s6 xkC1LwISo+jXfLYPekdPV6PCULugdxoU1J8RFsQ9Mbtyu0vzLCffp3yQcH2+LZ040WRQ SyXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=zI8dQLr+hgubSc2Md+BLeXBqKRPJrR0RfZFn/VtvoiY=; b=Eq5aKn0UCn/azCRpMz6nDXMOzCn1DWWqcQtmtKFVdYpAR1vxAhu20uKfNhDi67fZTd NwJ2BlJu9B3Olv5gnJjhalZm06ogrUmvQ2imqYLyKLX+ZnexZ9BYtr8j2KHIE4Txq0y2 +dPauqo6gS7QgyTmUq3C/di7WkyVWUcEGJkOkPXLMMga5ximQ3LnpOFBkpX4Uo9xRsBD NVuVzHdy056v/RR99Wg9HHIMIevrFaYWoxaMsbPK24dogTRTsvbng5U+Vvx39AgP0QJc JKilZOlr6ew8VRntJeSJ8NHvNuOJaRic9aKjNR1hdiNK6VNCnN7bHo7JBqjHBy3twKQ3 I3LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=pug4P711; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=hartkopp.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm18-20020a056a00339200b0054102a6773fsi8495449pfb.126.2022.09.12.08.56.07; Mon, 12 Sep 2022 08:56:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=pug4P711; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=hartkopp.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbiILOzG (ORCPT + 99 others); Mon, 12 Sep 2022 10:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbiILOzB (ORCPT ); Mon, 12 Sep 2022 10:55:01 -0400 Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [85.215.255.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 310946277; Mon, 12 Sep 2022 07:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1662994494; s=strato-dkim-0002; d=hartkopp.net; h=In-Reply-To:From:References:Cc:To:Subject:Date:Message-ID:Cc:Date: From:Subject:Sender; bh=zI8dQLr+hgubSc2Md+BLeXBqKRPJrR0RfZFn/VtvoiY=; b=pug4P711jbukSxRjD5Fs3Nqpp2V3i+itICXRJvCm73SfX5ct9w2UnzwLz5QdmE77WW b3k3oriaOxVhdNX5Wr44HBZLm8CdocOwAOJ+9Djle2Qqq45UgZlzUHC/9UamwNZhpR6A hSg7z5vFU5IqjtvKl770MFli+caHVE26JPHCYfsm7WvTop+RLQN/a/bIUsnQathlBDP7 5gUv2toCpAg5sj+7dEaKy+HVFYn8FICwKkYND/hxrcRSUoIGKynPNuWF+Tx1gCz47Jn0 V+RvoDGZjKrdNRZEKm/I1+SaqWo1pIvKYFF+EfG4loVaFa5KopyiOeYEjbe6yPM3ah+B 4Fug== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P2MHfkW8eP4Mre39l357AZT/I7AY/7nT2yrDxb8mjG14FZxedJy6qgO1qCHSa1GLptZHusx3hdIrpKytJSr6hfz3Vg==" X-RZG-CLASS-ID: mo00 Received: from [IPV6:2a00:6020:1cfd:d100::923] by smtp.strato.de (RZmta 48.1.0 AUTH) with ESMTPSA id d25a93y8CEsr18D (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 12 Sep 2022 16:54:53 +0200 (CEST) Message-ID: <4791cc31-db17-7720-4a86-f83e7bf0918d@hartkopp.net> Date: Mon, 12 Sep 2022 16:54:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH 1/2] can: bcm: registration process optimization in bcm_module_init() Content-Language: en-US To: Marc Kleine-Budde Cc: "Ziyang Xuan (William)" , edumazet@google.com, kuba@kernel.org, linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <823cff0ebec33fa9389eeaf8b8ded3217c32cb38.1662606045.git.william.xuanziyang@huawei.com> <381dd961-f786-2400-0977-9639c3f7006e@hartkopp.net> <7b063d38-311c-76d6-4e31-02f9cccc9bcb@huawei.com> <053c7de3-c76c-82fd-2d44-2e7c1673ae98@hartkopp.net> <9228b20a-3baa-32ad-6059-5cf0ffdb97a3@huawei.com> <20220912120020.dlxuryltw4sii635@pengutronix.de> From: Oliver Hartkopp In-Reply-To: <20220912120020.dlxuryltw4sii635@pengutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 12.09.22 14:00, Marc Kleine-Budde wrote: > On 09.09.2022 17:04:06, Oliver Hartkopp wrote: >> >> >> On 09.09.22 05:58, Ziyang Xuan (William) wrote: >>>> >>>> >>>> On 9/8/22 13:14, Ziyang Xuan (William) wrote: >>>>>> Just another reference which make it clear that the reordering of function calls in your patch is likely not correct: >>>>>> >>>>>> https://elixir.bootlin.com/linux/v5.19.7/source/net/packet/af_packet.c#L4734 >>>>>> >>>>>> static int __init packet_init(void) >>>>>> { >>>>>>          int rc; >>>>>> >>>>>>          rc = proto_register(&packet_proto, 0); >>>>>>          if (rc) >>>>>>                  goto out; >>>>>>          rc = sock_register(&packet_family_ops); >>>>>>          if (rc) >>>>>>                  goto out_proto; >>>>>>          rc = register_pernet_subsys(&packet_net_ops); >>>>>>          if (rc) >>>>>>                  goto out_sock; >>>>>>          rc = register_netdevice_notifier(&packet_netdev_notifier); >>>>>>          if (rc) >>>>>>                  goto out_pernet; >>>>>> >>>>>>          return 0; >>>>>> >>>>>> out_pernet: >>>>>>          unregister_pernet_subsys(&packet_net_ops); >>>>>> out_sock: >>>>>>          sock_unregister(PF_PACKET); >>>>>> out_proto: >>>>>>          proto_unregister(&packet_proto); >>>>>> out: >>>>>>          return rc; >>>>>> } >>>>>> >> >>> Yes,all these socket operations need time, most likely, register_netdevice_notifier() and register_pernet_subsys() had been done. >>> But it maybe not for some reasons, for example, cpu# that runs {raw,bcm}_module_init() is stuck temporary, >>> or pernet_ops_rwsem lock competition in register_netdevice_notifier() and register_pernet_subsys(). >>> >>> If the condition which I pointed happens, I think my solution can solve. >>> >> >> No, I don't think so. >> >> We need to maintain the exact order which is depicted in the af_packet.c >> code from above as the notifier call references the sock pointer. > > The notifier calls bcm_notifier() first, which will loop over the > bcm_notifier_list. The list is empty if there are no sockets open, yet. > So from my point of view this change looks fine. > > IMHO it's better to make a series where all these notifiers are moved in > front of the respective socket proto_register(). Notifiers and/or pernet_subsys ? But yes, that would be better to have a clean consistent sequence in all these cases. Would this affect af_packet.c then too? Regards, Oliver