From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C120B41D86; Mon, 27 Feb 2023 03:05:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E83440A84; Mon, 27 Feb 2023 03:05:48 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 00A5440A7D for ; Mon, 27 Feb 2023 03:05:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677463546; x=1708999546; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=GSVKhbzx9u6GO+a/OqOWBaovyfVla6hQLs4r6oucx0Y=; b=D2a8KFRITV80ejVd7Q8nqKS1Ot9XI+0GJ+IZIsrDJhOG6Xa/g33QVDb/ mDe2Nq+e9f7ptZsisgmEohzhZITgtm+0ASPkDWcFDld6AMJHHKPCDHsGh 1naLmHhP4DK8wuRuXWowPHbFuwkHpAui8HaAVd9tRn4lq0tsoAnBrSuIz Gd2vsCVXkrkcLkpLbWWgOb4o80xU7hj/N/rDv77bXRAQJ8Nx80hLfNUIX xlcWqU7qBLZGJhb6tCcygZevokz7pcFy7aKVqC7qyMRXfjAEnxAnoBUMy Pnva8QfCHKu/xK9PeRGjPQdQuFFFpL+E0KHHwKlT+P1JeIXrbTuzv0BWo Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10633"; a="313434289" X-IronPort-AV: E=Sophos;i="5.97,330,1669104000"; d="scan'208";a="313434289" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2023 18:05:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10633"; a="623397833" X-IronPort-AV: E=Sophos;i="5.97,330,1669104000"; d="scan'208";a="623397833" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga003.jf.intel.com with ESMTP; 26 Feb 2023 18:05:43 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Sun, 26 Feb 2023 18:05:43 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Sun, 26 Feb 2023 18:05:43 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.42) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Sun, 26 Feb 2023 18:05:42 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a3N0v9Zo030Vjro9GnklUk+q5xouyDDVDrLAcZ2dYREYKvMIQcJF0fSeu/khshLDpTnsRJCP8DcND5mid2x4upkJ0o5jhoqSTFlFVQ8WP57CpmOvvgcl8Mgj/Apwi9+vnEk8Sbpoei/1rvKs+LZ0ZYiQJSln3Q5UqqgdB8K0kYOnI3cY5yqhQyqPY85O+MotI5ri8OcydefDJ2S5Be5qRH+As6b8Vj068DXcJ/fK9/7hFYeKm5lMK68Isnb2tgMjll9TQQlooijoecB4bLkUKhe9ZuBRjv94RvEDVsZKWbuGJoxTLsIqkxOUuBgxBzP8fes5EShuLFcFmwoY3ssvLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kszwTIP2YMK9RLvDCK3Iiu4dAQHgIeR+8w/4E8qSsZM=; b=YxFzDqeT/ilksi/T6p6DjsyEhEJC/W6oaUIFnlP0s5SlLdC01ZmVJcizfF2dtTNmTcQZLReW27bhgWbtoUbSTWOHLHgm3eagk2AbiD2y3zG/2HtUv1Qt4gZ+pwmwb93qk/cQZ62df/HrNB9wiF0vYiAaagpSvqxYU2RKm4xOMS96W6BdXPhkY1VWRYsbw8GWcLOhy/WxHhBh8XZkPzPrfp6KuDi2EsDVldzk7ouCAAECPUE6SElW3W3uYKMjqESqnhddJiJmeyC468P5KVGrQPVVTVkIowH5isPw6MxmcqwvGM3MnN3y79OientRJR0UaOUTqSLqgQYPUo3kI3DwOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by CH0PR11MB8166.namprd11.prod.outlook.com (2603:10b6:610:182::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.27; Mon, 27 Feb 2023 02:05:40 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::930b:6671:e4f0:4ebc]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::930b:6671:e4f0:4ebc%3]) with mapi id 15.20.6134.026; Mon, 27 Feb 2023 02:05:40 +0000 From: "Xia, Chenbo" To: David Marchand , "dev@dpdk.org" CC: "thomas@monjalon.net" , Maxime Coquelin Subject: RE: [PATCH v2 11/20] net/virtio: annotate lock for guest announce Thread-Topic: [PATCH v2 11/20] net/virtio: annotate lock for guest announce Thread-Index: AQHZSGJ1KLFMesi3Y0auUyUIzePIjK7iDugQ Date: Mon, 27 Feb 2023 02:05:40 +0000 Message-ID: References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> <20230224151143.3274897-12-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-12-david.marchand@redhat.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB3504:EE_|CH0PR11MB8166:EE_ x-ms-office365-filtering-correlation-id: 93e74de0-08fc-4b35-bc3a-08db1867201d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 12rl3r9WKc7GRk08S8DqPnc518Xy0CdZd0/24ujC8J/wCligcOXcrb6Hz3BeUcnl/XmLA183f/K5MYDuvy+VzFRmRsvALEYKA2yI23b7TQlg+uEf7JxGdOMqiQgRVNr6GMujZNrzdpz4QEUglg+E8UMVU7ojj2J3Md9Ws/s8JcbtsViKOny+UysYtHJnRQqScQkzHcT7vOuoltD0bU1zXM9JgFoJ1V+OYoeIf057dH/x/k72q0fHxYSqJZY7tCaFBkQ3hPASHRN7vby8CNGA1bT5TFmpxu60/fRbceaSkfNdNObhF8qLaM7eiBa6Y52lDyqK7xWALedE7jCwjzo4t6zIflbVGSIFO0T+VOtFD21IVK6JZafqldKDQqho1ko03nJBLzQdB/RDMjDFLz4ZSGWBMMiEFmy5aRcj1qZPOhg9BEjBT68zgIXfbLcB9Lm5svl8t+9dFtbWnmWedBtOmV1euk05iLG505sHKielSxfFaWC80GaAbt4WUv+0DVW+CswzdyhyEPyi7Skaz2hm1VqWM46ZA78abG/TtLVnWvArEBxJdJSnQP8pBLCKrPN25ZkqSJAYeRAt3/d1iKWlD+yXnB/xPACB1uPqEg36fdganqdnV6GmrMSuDF7gFij5TaSs12R6WXrdl85peASmwXHnkmD0q/S1bCFJvxAGw7Mmm9iEcFGqcnmeP5MGf7Wf8PTlyaBFBt74mRCdMPfFjQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(396003)(39860400002)(136003)(346002)(366004)(376002)(451199018)(186003)(9686003)(2906002)(38100700002)(82960400001)(83380400001)(122000001)(38070700005)(316002)(52536014)(8936002)(8676002)(66446008)(4326008)(66556008)(66476007)(76116006)(41300700001)(66946007)(5660300002)(71200400001)(7696005)(55016003)(6506007)(478600001)(64756008)(26005)(53546011)(33656002)(110136005)(54906003)(86362001)(66899018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?p3j1y85YQWzQtImOH4+7OjYlhUocJkirXub4HYSDFrzl4BNPvU2xde51Y7mX?= =?us-ascii?Q?6Z2jyDNTk4Nb31C2Ow/99he5Y+Sco0qhC72yDHQP/IXvWaly45d40QWoKibt?= =?us-ascii?Q?m3/IaUwVf6Hwkwm6C5+juwoVA12powkppJsF0FAs/vE77F+GHwaZWdLaUFDk?= =?us-ascii?Q?xi4VV2oKTkjsFXsPoiCdG4ZmVjRzYWP7O0S1D+HcT4E8Zv8eBesDuE2DPsEE?= =?us-ascii?Q?C51H37vQVZwA/oE/96+83ivFR3VVpzIhDJClyNP49gCsTeKkoJta6mgJsfLm?= =?us-ascii?Q?ro/AIEH8pvILh196BO0fNV5La6eVTTYR6nnZUjeKZqwBPW1IHAb+ArF3FR2T?= =?us-ascii?Q?krazLAe3m928P81Au4bstkMiFqbiuKUqzfvZSQKMjydBY9iORxQ1N1NSDI86?= =?us-ascii?Q?DWIpbj+XM0D9oP1v7gzFB/NQIL+TuHtdp+Ts2bQXOENEnuH/uVUedymA1QGd?= =?us-ascii?Q?XF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Bsj0hNNX?= =?us-ascii?Q?BYb/wQi1ZpYCSE6xc8kWcN15V5G/WO2BkbgsGanyP5rwbJiYy0qrag+OqojA?= =?us-ascii?Q?eVpOkMld8YySJyXLmo8wGfyIvCWkTbdiK9DH0DfJBwKoC44mpARuM2rHzsYg?= =?us-ascii?Q?iPv03dy9LDWESYnUGpNse3QzHzFALzcT6sFbVcFbOcSL7N2VO2+2LPqyAspa?= =?us-ascii?Q?LmzJe6wM0O8MyQJA5IxFeNMVVbJKobOyN4oTozRr?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93e74de0-08fc-4b35-bc3a-08db1867201d X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2023 02:05:40.2262 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OFqhST5LpCio/j7UdPwdNlvIC51dT2qlh1ioVhYTS6h8mljDP8b8qU6lzMSBQevWRTWNqmd7ETlc+ncpRFTlUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR11MB8166 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi David, > -----Original Message----- > From: David Marchand > Sent: Friday, February 24, 2023 11:12 PM > To: dev@dpdk.org > Cc: thomas@monjalon.net; Maxime Coquelin ; Xi= a, > Chenbo > Subject: [PATCH v2 11/20] net/virtio: annotate lock for guest announce >=20 > Expose requirements for helpers dealing with the > VIRTIO_DEV_TO_HW(dev)->state_lock lock. >=20 > Signed-off-by: David Marchand > --- > drivers/net/virtio/virtio_ethdev.c | 8 ++++---- > drivers/net/virtio/virtio_ethdev.h | 7 +++++-- > 2 files changed, 9 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/net/virtio/virtio_ethdev.c > b/drivers/net/virtio/virtio_ethdev.c > index 0103d95920..a3de44958c 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -1149,11 +1149,11 @@ virtio_dev_pause(struct rte_eth_dev *dev) > { > struct virtio_hw *hw =3D dev->data->dev_private; >=20 > - rte_spinlock_lock(&hw->state_lock); > + rte_spinlock_lock(&VIRTIO_DEV_TO_HW(dev)->state_lock); >=20 > if (hw->started =3D=3D 0) { > /* Device is just stopped. */ > - rte_spinlock_unlock(&hw->state_lock); > + rte_spinlock_unlock(&VIRTIO_DEV_TO_HW(dev)->state_lock); > return -1; > } > hw->started =3D 0; > @@ -1174,7 +1174,7 @@ virtio_dev_resume(struct rte_eth_dev *dev) > struct virtio_hw *hw =3D dev->data->dev_private; >=20 > hw->started =3D 1; > - rte_spinlock_unlock(&hw->state_lock); > + rte_spinlock_unlock(&VIRTIO_DEV_TO_HW(dev)->state_lock); > } >=20 > /* > @@ -1217,7 +1217,7 @@ virtio_notify_peers(struct rte_eth_dev *dev) > } >=20 > /* If virtio port just stopped, no need to send RARP */ > - if (virtio_dev_pause(dev) < 0) { > + if (virtio_dev_pause(dev) !=3D 0) { > rte_pktmbuf_free(rarp_mbuf); > return; > } > diff --git a/drivers/net/virtio/virtio_ethdev.h > b/drivers/net/virtio/virtio_ethdev.h > index c08f382791..ece0130603 100644 > --- a/drivers/net/virtio/virtio_ethdev.h > +++ b/drivers/net/virtio/virtio_ethdev.h > @@ -112,8 +112,11 @@ int eth_virtio_dev_init(struct rte_eth_dev *eth_dev)= ; >=20 > void virtio_interrupt_handler(void *param); >=20 > -int virtio_dev_pause(struct rte_eth_dev *dev); > -void virtio_dev_resume(struct rte_eth_dev *dev); > +#define VIRTIO_DEV_TO_HW(dev) ((struct virtio_hw *)(dev)->data- > >dev_private) > +int virtio_dev_pause(struct rte_eth_dev *dev) > + __rte_exclusive_trylock_function(0, &VIRTIO_DEV_TO_HW(dev)- > >state_lock); Just curious, why this is trylock instead of lock? Thanks, Chenbo > +void virtio_dev_resume(struct rte_eth_dev *dev) > + __rte_unlock_function(&VIRTIO_DEV_TO_HW(dev)->state_lock); > int virtio_dev_stop(struct rte_eth_dev *dev); > int virtio_dev_close(struct rte_eth_dev *dev); > int virtio_inject_pkts(struct rte_eth_dev *dev, struct rte_mbuf **tx_pkt= s, > -- > 2.39.2