Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp59838lqt; Wed, 5 Jun 2024 17:22:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAI9Or0yyfsrcCjn/BKHSJFA4RyM2AM9p13+5IFZ8mwQ7vUY03t8A0AtGovq6o0AdsNc3v8wrnZMVVbszgme0ezplNBhfmmCv1DdBwJA== X-Google-Smtp-Source: AGHT+IEt/CyQWytWQCzOaiRjZ/PnD8/5hZ8hZoTYp9KUs1pj2T5q1BZk2A5Ci0K4U+4qUjE4ndR9 X-Received: by 2002:a25:4cc7:0:b0:df7:8b7d:1b7 with SMTP id 3f1490d57ef6-dfaca98d692mr4047972276.4.1717633360021; Wed, 05 Jun 2024 17:22:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717633360; cv=pass; d=google.com; s=arc-20160816; b=Isu9fp4JriWMCIHsvLcNL063AJwkzKeV813W0JYUxcxHw+FUIJOZgU+pS1Lw/gqDYs XMF8L5LbeOCCJJKkpvp5UNl40iZVz9Jtn2wtjP3FWOaMV6dhrSPSLzg6omzMHVx2XBgL EpFYXITtIdpDVeqRIdWwTr0c62MxOxhWPDEfmxNXThsROUNPuMvpKOCXuRNM64EuilHL b1NJ5pmK1tX8ndLIrbbUmBSEIQhScG7VV10BlkwgPDbZeXnyTLUgMSQCa7sm7dsES3W3 VjsB0veUK41CJDBshfGl5PO1zvhuE7RiqYZjZ274gFn1mznqn0/EyuFAx7yMaJOHrPW6 Pajw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=A3WnCdr7NGFNEC2Eyj9xh68M3W1rWWXkjJt9FXdJgiw=; fh=YixKFdXTsSkSa3ythIRVry+NOw22lJ4tdPMcaAzcnh4=; b=ZAM2wY0IhPZLaYgosi4nwpiCM4yloUetEIGnoWjuCYmRbCODXuv4emAuFLKG+RnPJ1 6vOkf7hGKfallUNPXW7Y2vHcfnCXkLOBNOfs/kaOHR9VvhQjmjopWOqlR7aGNSOesxvE qKcX/SfYkDlbwBMJlFa4PHrLoX08vCBqdxUMg2xOnEVv3qYByq+uHc8wkIorn6s0k6Vp TyhuZGbcioLBcgPRapioOZixIFG9rcrQGbLPeR4b1arHU563AgAQQe/YdTeNsHVcV+5I gE1lfi1xJ67zC7ZOEuQrMBsRaXC+Ug86LMlaksfgRmuHo0FFQCKfT22yDTAK8GBh5N5d bXRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HmeEcK6o; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-203447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b04f963dd9si2741726d6.221.2024.06.05.17.22.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 17:22:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HmeEcK6o; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-203447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AC7651C22809 for ; Thu, 6 Jun 2024 00:22:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DDB379F0; Thu, 6 Jun 2024 00:22:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HmeEcK6o" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 C7339139D for ; Thu, 6 Jun 2024 00:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717633351; cv=none; b=aRdIggckmRuElIyv8NuOs0TPWgoMGkE3Vin6BMXgCED2S/bsLmFpzCLwNRA2Ja7q5kUvMO+dval9buqEckd7BlablC3KRag469UvRO5I4xfAMB2YPdlKN2bQ1RDbfu2F/kAEtG7nmO37R0N7U3PYfyCw3+2FSZ/MTy5utTH4RFY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717633351; c=relaxed/simple; bh=3vc8T1yJa+tEmXjxhkr/Caecgw0eEIRO+K3Y9cuhyJk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZNa81tCCKWzAXgcTEP/pMKLixcD2wOqfjuwBysdQDTwqZpXgKnlsQ6VKxHxCFbmVQAguc43q7UZmRc+5XixUuTTFDu3DZmYoGaZ3bdpcqHK4q5Z+6ZryWJ6qEOCTYRqb8Bf9/WHcS0rS8lItZmhlvhYZUdAqmB00IuoD1P/52vU= 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=HmeEcK6o; arc=none smtp.client-ip=170.10.133.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717633348; 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=A3WnCdr7NGFNEC2Eyj9xh68M3W1rWWXkjJt9FXdJgiw=; b=HmeEcK6oB7O8DJ0LEv6svpcgLWWhpAwRv4J5qe8lsA3/jKw30TqxwNlZ09JfdtlrZpHviZ 7n7EkGsbgClj7T1FgAoZAoEl678e6nsOkZYgt/la3DEN1t6UDqCXldI7/0s0Hr//MsSeFM R7km6W8P70DCYHt+hYAFQEJbAz+9XFk= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-422-IGuwtwOwOmCuwr4emLH1gQ-1; Wed, 05 Jun 2024 20:22:26 -0400 X-MC-Unique: IGuwtwOwOmCuwr4emLH1gQ-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-70265fd9230so278199b3a.2 for ; Wed, 05 Jun 2024 17:22:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717633345; x=1718238145; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A3WnCdr7NGFNEC2Eyj9xh68M3W1rWWXkjJt9FXdJgiw=; b=i3LVm+NILA7FwPc6+C6n+2fUYes6kABDErG6F75B9UW7HRn8JLv4nnN+2E3Q3+js+w 8snQufvwgQUFhvYUh2Wh4jO02MZ/WUQDlybzGvyWxssOFuVIigcRJMfCKaVM5nDzxkNB +KCJNtnfo1FslDoI0WtuuJxiIE7ZBHxNgzWwuS3FzW2kCIjVJa5czhzKjRdZ9WhC6IRB tqnzQnfvz8qv3upRB6MbEh/4kmbUNZ45nU4nu8NTHceojN7K0AV2Hpu98EKeQbrCZUqb kpBTFjApkE30XhzUgvGUflL6YAGbmPrdNai8MJbAoKcli9GTes08WzDtH6L1zOJ4hfnB XCQw== X-Forwarded-Encrypted: i=1; AJvYcCWY/Eiy5sB6ECwEJW6RdyRVqjDCHc9Gkt3WWlZ7kiHy8pAs7K/UlJjNzMh8NC0WyFbBraNaBf+YPbWSjb9BVGwGlAAc359Jx1XTpQKI X-Gm-Message-State: AOJu0YwpwuvQW0/o1X3m3tt5ft35rCqowu2I0WY+XRj24n6rDkpniskD rIk01SHcN0bRY0nP9sNWkFOFa63HRYtjzQIbtPWTlFycA/y3pzdCwyyPupjijOigWjIhHJx1a2V gpgrGEUEhDjHjhQg4kyhFM1LLtv+TAXs1KXx+H580fEYoqRgIAjsqPf6BTgwuuvBr0bMLObqV2z CRhTbYs453Lk8/xdGVjlXpvZ9G/QwzU3P2v36D X-Received: by 2002:a05:6a20:7350:b0:1b2:b027:a305 with SMTP id adf61e73a8af0-1b2b6ff5aacmr4915754637.33.1717633345260; Wed, 05 Jun 2024 17:22:25 -0700 (PDT) X-Received: by 2002:a05:6a20:7350:b0:1b2:b027:a305 with SMTP id adf61e73a8af0-1b2b6ff5aacmr4915727637.33.1717633344499; Wed, 05 Jun 2024 17:22:24 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240530032055.8036-1-jasowang@redhat.com> <20240530020531-mutt-send-email-mst@kernel.org> <20240530090742-mutt-send-email-mst@kernel.org> In-Reply-To: From: Jason Wang Date: Thu, 6 Jun 2024 08:22:13 +0800 Message-ID: Subject: Re: [PATCH net-next V2] virtio-net: synchronize operstate with admin state on up/down To: "Michael S. Tsirkin" 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 31, 2024 at 8:18=E2=80=AFAM Jason Wang wr= ote: > > On Thu, May 30, 2024 at 9:09=E2=80=AFPM Michael S. Tsirkin wrote: > > > > On Thu, May 30, 2024 at 06:29:51PM +0800, Jason Wang wrote: > > > On Thu, May 30, 2024 at 2:10=E2=80=AFPM 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 st= atus > > > > > 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: mt= u 1500 qdisc noqueue state LOWERLAYERDOWN mode DEFAULT group default qlen 1= 000 > > > > > 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_enab= led */ > > > > > + 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. > > For example, there could be a suspend/resume when the admin state is down= . > > > > > > > > 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. > > Yes, but it should not matter much as it's done in the ndo_open(). Michael, any more comments on this? Please confirm if this patch is ok or not. If you prefer to reuse the config_disable() I can change it from a boolean to a counter that allows to be nested. Thanks > > Thanks > > > > > -- > > MST > >