From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54CB617CA1C for ; Thu, 30 May 2024 13:09:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717074576; cv=none; b=GiwKauCDe3w2YFCId17kBRINmOMDkW8r/J9hhnSdoFCv33Z70HP5b8SgwNUlTSiWrEjnjuo/UxziKs9JWo1wIeUtV/qJGk35kfCA06xTucYr+pbEoV75wNvXkp8eCaXKOph0jFLB8pc8IRH/b9ZHDTUpy9SHVzZLXuI56qVqVqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717074576; c=relaxed/simple; bh=lYNJdQ0V3/Gcp7v8u0m6JSo1A8R6lWx78f/B4BWszTM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: In-Reply-To:Content-Type:Content-Disposition; b=kWHF9vMChTmZriHIGhHCDEgiKDT+j956mm1i6t35Xj2mHl3exNgQ3O112Te2phEymUuthhQW/72MdwiWOA7shbLqo4lqcz9S4HohXClOENRC5QieFOIjieYDfMdizCe8v4SqGEqDoGch106d5CDq1uhAMn/lFDAFMDRbyLOo0VQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OCXn6azv; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OCXn6azv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717074574; h=from:from:reply-to:subject:subject: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=I9nGi8qNIfkniqpWSI+fxCxi2UDSD2WgUFS9bKLvDdI=; b=OCXn6azv0Jqgli6Peh/2+uxhH0tAsorgJfI321vy5xpKOfd0qqB/El2TB9Fe9Wh7Lxbkem 0OBfscN7ntpk1DxPCLfo9QWpbVXeGZLLnGcBgG3MlQRzqLnPcTP02Chc7qjupPoc8GpfTT VNo73bfqgjLKtmfG9ulI23j89nW4y24= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-6nhq48qwMP-KjjJBiWYdYw-1; Thu, 30 May 2024 09:09:32 -0400 X-MC-Unique: 6nhq48qwMP-KjjJBiWYdYw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4212983c8c7so2598515e9.1 for ; Thu, 30 May 2024 06:09:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717074571; x=1717679371; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=I9nGi8qNIfkniqpWSI+fxCxi2UDSD2WgUFS9bKLvDdI=; b=TFrJuEwZnU8mmHJDly84PPJZBNE2jq1Cv6//I3MqulCX7Sqf4CWFRtmZDEgwP7AdE8 coili0jmhAQ7ryZLtN78VggRREbL2P6ZZA42RUfQ/fAYZkTrhzdXoso5lfB+XSnO/vqa GuGF6MzPKZ9M09OPokGqmIlb15UVBYC96gv2qJf8ZqTZVnY7/YV4As2FYfC7zf0n1RoV jtBm78Nc9M6C/e9riW2qUk8e4PB3iEXTeMbLAijJHcrR6amQOMGynjGP2pRjdhVq9IwG alvEIbIOHwulNApiibaRzpUPf0SlwAtuUHTRIvvA+Tzh1NouVSoBi+dHeMElUGUhghWj 8T4A== X-Forwarded-Encrypted: i=1; AJvYcCWGSzswVFpXOU11iBRn1znzD6kWKsTMaDKA46nrzvK27IAVQVC5Q9+zfrdAllHEdr6pYQrWcol8nQp9iwqSgNInm2E1wLseax4XxUdCaCk= X-Gm-Message-State: AOJu0YwCKMXJlAE9dJB5BG3z6gzMqEKUtJWSk8o/zjMd4diFOUTlTCxR sx+X+OermSr5O2RfpfWG3IyoYklRXpRG0sskMJHNrlLX/LUc5+cRXchqh4H1Az2Ouoe25l9kjzg dxRqK3ElcwqRcgk3n4TDX9Xqd5IN1w7gd2626rdNP2kIOlZTPQCcoskLuu3Wxlsxj X-Received: by 2002:a5d:550e:0:b0:354:df32:69da with SMTP id ffacd0b85a97d-35dc7e3e081mr1620569f8f.14.1717074570843; Thu, 30 May 2024 06:09:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBO25tbyDOl41OKFzuynZI6kqQwz9TH+1XUOCoEVIPxL3Ze93yMi/uikbyOHQnO8vRDvDBBw== X-Received: by 2002:a5d:550e:0:b0:354:df32:69da with SMTP id ffacd0b85a97d-35dc7e3e081mr1620530f8f.14.1717074570198; Thu, 30 May 2024 06:09:30 -0700 (PDT) Received: from redhat.com ([2.52.145.167]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42127065907sm25070785e9.16.2024.05.30.06.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 06:09:29 -0700 (PDT) Date: Thu, 30 May 2024 09:09:25 -0400 From: "Michael S. Tsirkin" To: Jason Wang Cc: xuanzhuo@linux.alibaba.com, eperezma@redhat.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Venkat Venkatsubra , Gia-Khanh Nguyen Subject: Re: [PATCH net-next V2] virtio-net: synchronize operstate with admin state on up/down Message-ID: <20240530090742-mutt-send-email-mst@kernel.org> References: <20240530032055.8036-1-jasowang@redhat.com> <20240530020531-mutt-send-email-mst@kernel.org> Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Thu, May 30, 2024 at 06:29:51PM +0800, Jason Wang wrote: > On Thu, May 30, 2024 at 2:10 PM Michael S. Tsirkin wrote: > > > > On Thu, May 30, 2024 at 11:20:55AM +0800, Jason Wang wrote: > > > This patch synchronize operstate with admin state per RFC2863. > > > > > > This is done by trying to toggle the carrier upon open/close and > > > synchronize with the config change work. This allows propagate status > > > correctly to stacked devices like: > > > > > > ip link add link enp0s3 macvlan0 type macvlan > > > ip link set link enp0s3 down > > > ip link show > > > > > > Before this patch: > > > > > > 3: enp0s3: mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 > > > link/ether 00:00:05:00:00:09 brd ff:ff:ff:ff:ff:ff > > > ...... > > > 5: macvlan0@enp0s3: mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000 > > > link/ether b2:a9:c5:04:da:53 brd ff:ff:ff:ff:ff:ff > > > > > > After this patch: > > > > > > 3: enp0s3: mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 > > > link/ether 00:00:05:00:00:09 brd ff:ff:ff:ff:ff:ff > > > ... > > > 5: macvlan0@enp0s3: mtu 1500 qdisc noqueue state LOWERLAYERDOWN mode DEFAULT group default qlen 1000 > > > link/ether b2:a9:c5:04:da:53 brd ff:ff:ff:ff:ff:ff > > > > > > Cc: Venkat Venkatsubra > > > Cc: Gia-Khanh Nguyen > > > Reviewed-by: Xuan Zhuo > > > Acked-by: Michael S. Tsirkin > > > Signed-off-by: Jason Wang > > > --- > > > Changes since V1: > > > - rebase > > > - add ack/review tags > > > > > > > > > > > > > --- > > > drivers/net/virtio_net.c | 94 +++++++++++++++++++++++++++------------- > > > 1 file changed, 63 insertions(+), 31 deletions(-) > > > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > > index 4a802c0ea2cb..69e4ae353c51 100644 > > > --- a/drivers/net/virtio_net.c > > > +++ b/drivers/net/virtio_net.c > > > @@ -433,6 +433,12 @@ struct virtnet_info { > > > /* The lock to synchronize the access to refill_enabled */ > > > spinlock_t refill_lock; > > > > > > + /* Is config change enabled? */ > > > + bool config_change_enabled; > > > + > > > + /* The lock to synchronize the access to config_change_enabled */ > > > + spinlock_t config_change_lock; > > > + > > > /* Work struct for config space updates */ > > > struct work_struct config_work; > > > > > > > > > But we already have dev->config_lock and dev->config_enabled. > > > > And it actually works better - instead of discarding config > > change events it defers them until enabled. > > > > Yes but then both virtio-net driver and virtio core can ask to enable > and disable and then we need some kind of synchronization which is > non-trivial. Well for core it happens on bring up path before driver works and later on tear down after it is gone. So I do not think they ever do it at the same time. > And device enabling on the core is different from bringing the device > up in the networking subsystem. Here we just delay to deal with the > config change interrupt on ndo_open(). (E.g try to ack announce is > meaningless when the device is down). > > Thanks another thing is that it is better not to re-read all config on link up if there was no config interrupt - less vm exits. -- MST