Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp661888pxa; Sat, 1 Aug 2020 02:01:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV2ioBxFX3Q70gOQcwrk6acqvVGXLDWCZJmSbPbeypZIaID+sJCMMZTn7IorGnIADzBdqp X-Received: by 2002:a17:906:d159:: with SMTP id br25mr7714841ejb.16.1596272499537; Sat, 01 Aug 2020 02:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596272499; cv=none; d=google.com; s=arc-20160816; b=Mm+ECqUu5Zn8MIoNnGWzxVYHUZnWk/VdQpRnFA0QUpJ/uKGNKTBymPYir+tsReKj4e 1A5bGmR8fHAVG+EurmJIkCVbzMH66eNiUhwaoSxYBMaf93VftKWIJO4iIR1V0eNlYavJ wasC1c8rgrTxcNlHOcj+eNbdT5f2ifVEzSSRkS8TjLYx6jTbKemJWBb22iuzgXNDqDqO 85Gk5gshPh0kBixv8Kv7sxGyFDeVtACjLrag0Bb9kathwxrQa59kAPe4Qnk+K8kzW322 tdiYJnK7PBPmRbs0CYTqmsLlvj2c4T3b/pC7lbz09OxBcnWSrqgYitNLurUmT3eK/uoF PCag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=zeOyWqH0WZZbk4dw2NqwvW6mE9/SRkgfKUn4tSPaMEk=; b=ASI2bxHmv99tlMf632wOvFBsptVOBO0riD8ethilo2cv3gqfSl6sibhVtTq53VLuT+ V7x7brPSTjorBdIpdPiyEPghRCq6Unb35W3YUrDc5YamjGS7Jxlev8FzqH3Hn2QF0DXA zFImO8pnP8/ahyZyS2Mak1rOIljr/ZuvS0b3Vt85+ALA6QBhD5xTf1iVRa03O+OdoOsy ff5s11bzrDSHn9FPHbXRzIVwDLYJLIAuw4fXScEe/5ISahEIw1agtOim2eGfo+Tmfg2N BO73N+MXBN2jQUcqIaml+YN8WYylvqWFGC5866DFHqD/ffshTIecLcZlCE2BxUfF19d3 6xmw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si6259465ejk.175.2020.08.01.02.01.16; Sat, 01 Aug 2020 02:01:39 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728645AbgHAI7T (ORCPT + 99 others); Sat, 1 Aug 2020 04:59:19 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:47861 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbgHAI7T (ORCPT ); Sat, 1 Aug 2020 04:59:19 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01355;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0U4O6FF._1596272349; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0U4O6FF._1596272349) by smtp.aliyun-inc.com(127.0.0.1); Sat, 01 Aug 2020 16:59:15 +0800 From: Wen Yang To: davem@davemloft.net, Jakub Kicinski Cc: Xunlei Pang , Caspar Zhang , Wen Yang , Andrew Lunn , Eric Dumazet , Jiri Pirko , Leon Romanovsky , Julian Wiedmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: core: explicitly call linkwatch_fire_event to speed up the startup of network services Date: Sat, 1 Aug 2020 16:58:45 +0800 Message-Id: <20200801085845.20153-1-wenyang@linux.alibaba.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The linkwatch_event work queue runs up to one second later. When the MicroVM starts, it takes 300+ms for the ethX flag to change from '+UP +LOWER_UP' to '+RUNNING', as follows: Jul 20 22:00:47.432552 systemd-networkd[210]: eth0: bringing link up ... Jul 20 22:00:47.446108 systemd-networkd[210]: eth0: flags change: +UP +LOWER_UP ... Jul 20 22:00:47.781463 systemd-networkd[210]: eth0: flags change: +RUNNING Let's manually trigger it here to make the network service start faster. After applying this patch, the time consumption of systemd-networkd.service was reduced from 366ms to 50ms. Signed-off-by: Wen Yang Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Andrew Lunn Cc: Eric Dumazet Cc: Jiri Pirko Cc: Leon Romanovsky Cc: Julian Wiedmann Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- net/core/link_watch.c | 3 +++ net/core/rtnetlink.c | 1 + 2 files changed, 4 insertions(+) diff --git a/net/core/link_watch.c b/net/core/link_watch.c index 75431ca..6b9d44b 100644 --- a/net/core/link_watch.c +++ b/net/core/link_watch.c @@ -98,6 +98,9 @@ static bool linkwatch_urgent_event(struct net_device *dev) if (netif_is_lag_port(dev) || netif_is_lag_master(dev)) return true; + if ((dev->flags & IFF_UP) && dev->operstate == IF_OPER_DOWN) + return true; + return netif_carrier_ok(dev) && qdisc_tx_changing(dev); } diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 58c484a..fd0b3b6 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2604,6 +2604,7 @@ static int do_setlink(const struct sk_buff *skb, extack); if (err < 0) goto errout; + linkwatch_fire_event(dev); } if (tb[IFLA_MASTER]) { -- 1.8.3.1