Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp137028lqh; Thu, 30 May 2024 17:18:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsD1vrX3YRkl+7jQFbTlzTXMHelww9+f4DyzbGQoV5udaiqyTv4XjAVFQ4yy8h6GdjwI4lIOe5DPP2kbIP7FKPwf369D1FlBIlYFxbXQ== X-Google-Smtp-Source: AGHT+IHU8IE+VtYXE84N0JdBpxJC1SGm22N1PPas71wuu4IkijW32eEcikGw3LWnSrrTWLahpZw4 X-Received: by 2002:a05:6214:2a8c:b0:6ad:7a01:1980 with SMTP id 6a1803df08f44-6ae0e768a4bmr51071136d6.2.1717114706497; Thu, 30 May 2024 17:18:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717114706; cv=pass; d=google.com; s=arc-20160816; b=E7ZN2xYMqQK/EriEhbm25I49G+ZbAuWqerHg4ch86rUGUj6IG6oKSOAajd6fWzypWE WyEJ2S8b6lG2gWLI2SIl+GeNvA8u0afx6BSjfioOnwoedFqR4kql+Hkz3TYACHJ/sY/h o5Dbdtqgwhgamhn99Su6Eh5zE+yxxWlgaI26r1mRt0x71iYZtjEU73tuqkpcxgyY0wLm Y+HfxpPM1gJdpCXKLjvYVNhE2e5Q2huzsfPqO/Q/gxjfJdY5iQIiexPXtdiXnaPI2Ykq qcn2g2BIqV+93RSxPflVEwZ0nq1/JGwyfX26B5yCKcB2hsuZqNzgg1qwhMdqPwjaOGZ4 W4qA== 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=5jGk8SEMK5Bvtc/9k59FnMjRJyI8k1VJ2cg/HKGkhc4=; fh=jPyAQm4vz3w9EzJijafFuI3WCxE8eYyJhp9abVmDelo=; b=LmWVkpVFTqAHPv3PRatLy4LZe3qA7OrjpR32z2eHJcQixD4j5Cxrf1AV4TYqYHWtZF v7hTL/AC5o0dcJo9DOQRqZdNDcVox7VhaFRyQigNA7DATQgokMuFdKp8loi6HOKLzey9 7b1ie9K+E8lkgDVujJMFye7XGopa/I2HcyVpV/ZhHvDs/jnpSBiltFxppchXoh+trJyB jZqVPduJLmtaXK+mhI0Or3Tz5ucjdzG3PotCQ11oVDh3EzEWzx5ffkF//vSQDMsAoHca eUm/1aK6cwlavtACTGmR3IckwsGgx8i/54eZMJpjLRs08RKanm7KePX/duovwkcpON/X torg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EJrJEChX; 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-196069-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196069-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 af79cd13be357-794f32b8127si76996785a.727.2024.05.30.17.18.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 17:18:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196069-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=EJrJEChX; 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-196069-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196069-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 22A731C2239F for ; Fri, 31 May 2024 00:18:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06D581848; Fri, 31 May 2024 00:18:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EJrJEChX" 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 83AAC6AC0 for ; Fri, 31 May 2024 00:18:15 +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=1717114697; cv=none; b=JNlremapsenFafUm6qHKvtv8dGeUqlojsgco1QFkOY2m8s/W+fkIlqTTpJCPqf3PVFULhfJmgrYhflBKNsI0UEy/BNvv56htOqxP1W7UkKxu6gRdl1aLY+veUbI5VSM7aKI41DsaETcbl5I9jxRrUS8Kh0inSfexAtmNkHZ5EQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717114697; c=relaxed/simple; bh=KNXVkfWiz4Q50vCls1kWwILJ5qinN5zXnC4J+4f1Haw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MFAJx6jVCtt4PZcL+4/MhfCLTGEJtb8+Op5+eBvEqDek06j/OBDZWW/8p8WVj9k8zL18iT8e2/Q4WM5InvDOy8h0UcQrxWfWX8Qp+eJlnPB1StWaGJsgPiGjjUJ2Ykf8bj2xA8DiOtUSW/C2aFtzge1ljWFZOSjm5q8PtDMOXeU= 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=EJrJEChX; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717114694; 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=5jGk8SEMK5Bvtc/9k59FnMjRJyI8k1VJ2cg/HKGkhc4=; b=EJrJEChXPnVsS+OcqArUM4mqrFgU4x0z+c8JDI4QIQEjB3J0eLXicJeGHij14WxnPClZpN eJCuiJKMGVBnkgX7bfKIVQdstrINo7TWYhkNidWjRLxK50ZksI5qWYEVHLAErfteEmAVs3 3mFK94jM5NTKPMooN5J9kmYdgwG5Wno= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-53-96Sw8t6kOeeAE3rqcw2G6Q-1; Thu, 30 May 2024 20:18:13 -0400 X-MC-Unique: 96Sw8t6kOeeAE3rqcw2G6Q-1 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-2bf5e099692so1368563a91.0 for ; Thu, 30 May 2024 17:18:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717114692; x=1717719492; 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=5jGk8SEMK5Bvtc/9k59FnMjRJyI8k1VJ2cg/HKGkhc4=; b=P9BiBNSkll5F5DO3CYRuLUsPIx5H9HQIcWpU8SxK29StN2h7W7ebbDLm0YnlTuAoQo NRZgzUTSaWYt5Esv6/1EtqoGZdvaHA8pSE8CAui+Qq+YoilhdlOA9riKp+5PxFW5qeXH mYee84/esuZvHm5UWKrIirwvo9d/3SX+3RkZ1SaKaHnyNQs8tzHalPMU5398z8Vn6REY WvIizrj9ju2L/B+cQNpqmj1rX/fFLEnmBDvvDjaosAPAZ/FQOk4bf563MOerv9r8ipep 0gkifE93Yn2fKz+/88P5B0KkO4B/C3KKpbGQTj/U/0cTZg6vjwUZ8XLZyWyrGbSSIQYn vJzA== X-Forwarded-Encrypted: i=1; AJvYcCUrX8yXAdPUADUd5vp59fGFRarpKbOArAswkvc/rXbf2H797FqojkjSalESNssbdYErMa1WTWYYOMfLonBsAtzrrPfTeQ/10HZBp2P0 X-Gm-Message-State: AOJu0YxlBuIIIg002+C20NpFEmGwhfYLq+tdCG6GodxJFirHmRA5jEJd gSV49LdY29CZqUKMw2rok4MNwo0VoFf665jgaPYQneRB3Id7XvDQ2XkadUn6CQs6RdO5+01aZ5h n60GaxmNyz5F8CKRWtBBymZcdUTI9skSg4WLYepTM3SldlgxakBFCtLjstdffT3m/rxWowpPVuI ey6sao8O/v5YjP2VRZLTIBVZSRpMBo30SA8yr9 X-Received: by 2002:a17:90a:e28d:b0:2b9:e009:e47a with SMTP id 98e67ed59e1d1-2c1acc3d22cmr4688030a91.10.1717114691888; Thu, 30 May 2024 17:18:11 -0700 (PDT) X-Received: by 2002:a17:90a:e28d:b0:2b9:e009:e47a with SMTP id 98e67ed59e1d1-2c1acc3d22cmr4687990a91.10.1717114691232; Thu, 30 May 2024 17:18:11 -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: <20240530090742-mutt-send-email-mst@kernel.org> From: Jason Wang Date: Fri, 31 May 2024 08:18:00 +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 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 stat= us > > > > 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 DO= WN 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 15= 00 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 DO= WN 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 100= 0 > > > > 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_enable= d */ > > > > + 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(). Thanks > > -- > MST >