From patchwork Fri Jun 26 12:27:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 1317613 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=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UxKF5asj; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49tbkg1Fg8z9sPF for ; Fri, 26 Jun 2020 22:27:55 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 9AD1120113; Fri, 26 Jun 2020 12:27:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FXAPZJGHelNB; Fri, 26 Jun 2020 12:27:50 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id BDC2320117; Fri, 26 Jun 2020 12:27:50 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A24D9C0891; Fri, 26 Jun 2020 12:27:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6830FC0863 for ; Fri, 26 Jun 2020 12:27:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 657D685BD0 for ; Fri, 26 Jun 2020 12:27:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3FlPXn6YeT-9 for ; Fri, 26 Jun 2020 12:27:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 2065F85E08 for ; Fri, 26 Jun 2020 12:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593174467; 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; bh=wdsriR/roi9hsULHPn+1h5G8O478aIv/E8PzGSqkmbU=; b=UxKF5asjoQ3E4L2OW+pvzK6zBrY17ZbZcyEex8rCdABvi/JIgfEPl3672VhMGdnVHhUEKW MLtlsZWJImHpUEMj8WgYXcstXueYFK47OHUf2CtlLxgB6n0CtZweucgMrAS6lLyxzFoAdt BOPWQYYaLoSFgT5l/l4spjQUfNTrJD4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292--vkh-Bv4NVmPNOwUrYLaOg-1; Fri, 26 Jun 2020 08:27:45 -0400 X-MC-Unique: -vkh-Bv4NVmPNOwUrYLaOg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7956D107ACF3; Fri, 26 Jun 2020 12:27:44 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5E091010428; Fri, 26 Jun 2020 12:27:42 +0000 (UTC) From: David Marchand To: dev@openvswitch.org Date: Fri, 26 Jun 2020 14:27:38 +0200 Message-Id: <20200626122738.28163-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH] dpdk: Refuse running on cpu >= RTE_MAX_LCORE. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" DPDK lcores range is [0, RTE_MAX_LCORE[. Trying to use a lcore out of this range expose OVS to crashes in DPDK mempool local cache array. Prefer a "clean" abort so that users know that something is wrong with their configuration. Signed-off-by: David Marchand --- lib/dpdk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/dpdk.c b/lib/dpdk.c index 98d0e2643e..55ce9a9221 100644 --- a/lib/dpdk.c +++ b/lib/dpdk.c @@ -617,7 +617,14 @@ dpdk_set_lcore_id(unsigned cpu) { /* NON_PMD_CORE_ID is reserved for use by non pmd threads. */ ovs_assert(cpu != NON_PMD_CORE_ID); + if (cpu >= RTE_MAX_LCORE) { + cpu = LCORE_ID_ANY; + } RTE_PER_LCORE(_lcore_id) = cpu; + if (rte_lcore_id() == LCORE_ID_ANY) { + ovs_abort(0, "PMD thread init failed, trying to use more cores than " + "DPDK supports (RTE_MAX_LCORE %u).", RTE_MAX_LCORE); + } } void