From patchwork Tue Dec 17 16:20:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Mikityanskiy X-Patchwork-Id: 1211626 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="CqesdECi"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47cmfk01wxz9sRQ for ; Wed, 18 Dec 2019 05:21:01 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 8FA6687E76; Tue, 17 Dec 2019 18:21:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ots0GtB5EiYZ; Tue, 17 Dec 2019 18:20:55 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id EB10587EA2; Tue, 17 Dec 2019 18:20:54 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 027801BF2B3 for ; Tue, 17 Dec 2019 16:35:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D41D685205 for ; Tue, 17 Dec 2019 16:35:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bE-FLtyeEfW1 for ; Tue, 17 Dec 2019 16:35:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70048.outbound.protection.outlook.com [40.107.7.48]) by whitealder.osuosl.org (Postfix) with ESMTPS id 04D9D82492 for ; Tue, 17 Dec 2019 16:35:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DnmwTkkPdMXq4qmuns+z0QRn0EimT/siyQIzO0EgMwWCTo/0sFySx/H/kYDTOY+ynqVNCzwVY76/jKwqv2z17VCR3Iz9HAFKg2pG+NO+j2b9FA6n6C2vwzrKeoGDrM+U6lIzKZ/a++qn/N/wqDgGdSqtDNM60mniJtC+YSMWy0zALHfbtr/fJEEZWFjmjhsQ/J1JDVMX2DLQVIt7rC/c6AR0R+vVKrF6eeyWredhAdvkNkBEL5Pd6OD0o5ZBhixaWY0gu0wbMBtiUs29lMpDIbWWNWIyhEcE5Gf/WEBljm2SvNOXmT1QVbFtKuhyJyKlA3mWG9aCAosB8U5k/kA+bg== 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-SenderADCheck; bh=oxCkWBSS9ERmXz2+SQhzVIbnCx811MoNC5e/TdqjHYU=; b=HoQGZnlwGBrD3B6tgYShTCj7Nqzm7KHdlAEiqSxe35hc6UfQLAWRgWAMAI0sNIe9Z1b0uL4XL+2+zNOMhHZ4/DVFXDD1dorvdetC3vu9x6lNvlLL0C/STx/con31UqT7bHQIB8D4aQG/tFeKuCmpKyz5NtV+0qlnseZ+ODv1bwmmce2KdwUIPRhqbDYnEVzmmxOseBMna7yl5z/m0jIdx+IVyIxX3whe/i7JVw8bVcoBE2u9gyUeWzJaDDLQm8dysIXKEa15Fj1UPHbFibRF75OmH+2ND8R/HHueSVhR/cEuv8kMAn+hgZfOtvU7ftCyrqfIs0F8+4YznevJrygFWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oxCkWBSS9ERmXz2+SQhzVIbnCx811MoNC5e/TdqjHYU=; b=CqesdECiQq1iFwCUiV4L3r5rFNlmFh4FR+77UzUoiQNPUZ8wbnZQb0YlTJX5eqb9cIzcvBObfc8kwkVNYrontTZMPLlkJIvhkC5GzRevtwmWsgOvLWaRUKrwJkTaKCvpKmA+5jp0cCt7mPjDF+p0CtlaaZwTbbLpXSU/CoOB9yE= Received: from AM0PR05MB5875.eurprd05.prod.outlook.com (20.178.119.159) by AM0PR05MB4259.eurprd05.prod.outlook.com (52.134.126.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.18; Tue, 17 Dec 2019 16:20:47 +0000 Received: from AM0PR05MB5875.eurprd05.prod.outlook.com ([fe80::259f:70b4:dab1:8f2]) by AM0PR05MB5875.eurprd05.prod.outlook.com ([fe80::259f:70b4:dab1:8f2%5]) with mapi id 15.20.2538.019; Tue, 17 Dec 2019 16:20:47 +0000 From: Maxim Mikityanskiy To: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Jeff Kirsher Thread-Topic: [PATCH bpf v2 4/4] net/ixgbe: Fix concurrency issues between config flow and XSK Thread-Index: AQHVtPXw51X2BxHsYEiQil4hifDEQw== Date: Tue, 17 Dec 2019 16:20:47 +0000 Message-ID: <20191217162023.16011-5-maximmi@mellanox.com> References: <20191217162023.16011-1-maximmi@mellanox.com> In-Reply-To: <20191217162023.16011-1-maximmi@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR02CA0106.eurprd02.prod.outlook.com (2603:10a6:208:154::47) To AM0PR05MB5875.eurprd05.prod.outlook.com (2603:10a6:208:12d::31) authentication-results: spf=none (sender IP is ) smtp.mailfrom=maximmi@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [94.188.199.18] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: a25a66de-3e86-41fd-5169-08d7830d12c6 x-ms-traffictypediagnostic: AM0PR05MB4259:|AM0PR05MB4259: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2331; x-forefront-prvs: 02543CD7CD x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(136003)(366004)(346002)(396003)(39860400002)(199004)(189003)(54906003)(26005)(66556008)(6506007)(110136005)(66476007)(2906002)(7416002)(64756008)(186003)(5660300002)(66446008)(36756003)(52116002)(1076003)(8676002)(81166006)(71200400001)(86362001)(81156014)(6486002)(107886003)(2616005)(478600001)(316002)(66946007)(6512007)(66574012)(8936002)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB4259; H:AM0PR05MB5875.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: keh7RuEFwRVuXpmogXbkiob6E7axQFPPr0YQ1tpkTmKChD3Cr5+2VLAK8JH4XzyTXQGDlAKPV9InPQ33wddy/0Xo9e64feQ/WWg8pGYVzW+84YWQkUCd2wuDP537YWvLfD0rYWJklTgM5WtZisOdBcmXgrpSUKH/mjvEFOp+LQSlUt9/CzGEqlCjqPUcA1yjGXUAhL21Hrmk+SYQS9qsg0h6ao2FkveTbvqvIWL4FHjalP00TsfdxnIZJv6krUCtNTo6jYHo20acbHIYuzQRkFWDHPBto60OIc4k8Gft83OkV+UK9k8QLKbhUm2NoDZVym4m2Q9AGFZ6MxqR80RS443ZfjJfkckbVyz+pJ6S4v2CnF6A6c9P59sAHBR8ltJVyiaVW9d5n9Q2/jOIL1DdrdJZ0Ig84oGW1CqNgwmJF6EFBrzRZG3CloO1Aa45R9+4 Content-ID: MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: a25a66de-3e86-41fd-5169-08d7830d12c6 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2019 16:20:47.1063 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Glq5VOsYcXNC7vu4/jv6NXo/zvWRNIbXDUOtlElY50oC2Nlb+1sD0BXVv5BlqInBp7txhitP7kdEzkbxM9/ftg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4259 X-Mailman-Approved-At: Tue, 17 Dec 2019 18:20:49 +0000 Subject: [Intel-wired-lan] [PATCH bpf v2 4/4] net/ixgbe: Fix concurrency issues between config flow and XSK X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxim Mikityanskiy , Jakub Kicinski , Jesper Dangaard Brouer , Daniel Borkmann , "netdev@vger.kernel.org" , Alexei Starovoitov , Saeed Mahameed , "intel-wired-lan@lists.osuosl.org" , Jonathan Lemon , "bpf@vger.kernel.org" , "David S. Miller" Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Use synchronize_rcu to wait until the XSK wakeup function finishes before destroying the resources it uses: 1. ixgbe_down already calls synchronize_rcu after setting __IXGBE_DOWN. 2. After switching the XDP program, call synchronize_rcu to let ixgbe_xsk_wakeup exit before the XDP program is freed. 3. Changing the number of channels brings the interface down. 4. Disabling UMEM sets __IXGBE_TX_DISABLED before closing hardware resources and resetting xsk_umem. Check that bit in ixgbe_xsk_wakeup to avoid using the XDP ring when it's already destroyed. synchronize_rcu is called from ixgbe_txrx_ring_disable. Signed-off-by: Maxim Mikityanskiy Signed-off-by: Björn Töpel --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 ++++++- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 25c097cd8100..82a30b597cf9 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -10261,7 +10261,12 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) /* If transitioning XDP modes reconfigure rings */ if (need_reset) { - int err = ixgbe_setup_tc(dev, adapter->hw_tcs); + int err; + + if (!prog) + /* Wait until ndo_xsk_wakeup completes. */ + synchronize_rcu(); + err = ixgbe_setup_tc(dev, adapter->hw_tcs); if (err) { rcu_assign_pointer(adapter->xdp_prog, old_prog); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c index d6feaacfbf89..b43be9f14105 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c @@ -709,10 +709,14 @@ int ixgbe_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags) if (qid >= adapter->num_xdp_queues) return -ENXIO; - if (!adapter->xdp_ring[qid]->xsk_umem) + ring = adapter->xdp_ring[qid]; + + if (test_bit(__IXGBE_TX_DISABLED, &ring->state)) + return -ENETDOWN; + + if (!ring->xsk_umem) return -ENXIO; - ring = adapter->xdp_ring[qid]; if (!napi_if_scheduled_mark_missed(&ring->q_vector->napi)) { u64 eics = BIT_ULL(ring->q_vector->v_idx);