From patchwork Wed Jul 7 07:14:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio D'Angelo X-Patchwork-Id: 1501591 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.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=aC5xLrl+; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GKW0G5tf1z9t0k for ; Wed, 7 Jul 2021 17:15:10 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 632AE404B3; Wed, 7 Jul 2021 07:15:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SwrgjFvyE8iP; Wed, 7 Jul 2021 07:15:05 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3507B400D9; Wed, 7 Jul 2021 07:15:04 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 07335C001A; Wed, 7 Jul 2021 07:15:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id D20F3C000E for ; Wed, 7 Jul 2021 07:15:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id B3ADE83336 for ; Wed, 7 Jul 2021 07:15:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d-M_NfosWPcz for ; Wed, 7 Jul 2021 07:15:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id C2E9582F57 for ; Wed, 7 Jul 2021 07:15:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625642099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/IBEq64EBNLcBrEMuwW27mZXRbzIVXk04aImwAguoFo=; b=aC5xLrl+auEqOEkl8N4R7iOPzzrl/H0QosgHt0jp2kgKAUrqQwhE8AnFzOzZ/Cn/685r3c 069mW7rVLcxlEmiCskEfcswd7yqKadlV61tFNsJNIyMC+7VKCOGrVT6c+pPMLLL2gjJjGt JxJ02+cKa8eY8fT43FJLf9GqKY2fwbI= 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-153-E440NCPXN6eE2YZKr36cFQ-1; Wed, 07 Jul 2021 03:14:58 -0400 X-MC-Unique: E440NCPXN6eE2YZKr36cFQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 589F018BFE69 for ; Wed, 7 Jul 2021 07:14:57 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-113-141.rdu2.redhat.com [10.10.113.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1806860854 for ; Wed, 7 Jul 2021 07:14:57 +0000 (UTC) From: Fabrizio D'Angelo To: dev@openvswitch.org Date: Wed, 7 Jul 2021 03:14:55 -0400 Message-Id: <20210707071455.2067178-1-fdangelo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=fdangelo@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] northd: Add config option to specify # of threads 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" Uses northd database to specify number of threads that should be used when lflow parallel computation is enabled. Example: ovn-nbctl set NB_Global . options:num_parallel_threads=16 Reported at: https://bugzilla.redhat.com/show_bug.cgi?id=1975345 Signed-off-by: Fabrizio D'Angelo --- lib/ovn-parallel-hmap.c | 12 ++++++------ lib/ovn-parallel-hmap.h | 5 +++-- northd/ovn-northd.c | 7 ++++++- ovn-nb.xml | 10 ++++++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/ovn-parallel-hmap.c b/lib/ovn-parallel-hmap.c index b8c7ac786..cae0b3110 100644 --- a/lib/ovn-parallel-hmap.c +++ b/lib/ovn-parallel-hmap.c @@ -62,7 +62,7 @@ static int pool_size; static int sembase; static void worker_pool_hook(void *aux OVS_UNUSED); -static void setup_worker_pools(bool force); +static void setup_worker_pools(bool force, unsigned int thread_num); static void merge_list_results(struct worker_pool *pool OVS_UNUSED, void *fin_result, void *result_frags, int index); @@ -86,14 +86,14 @@ ovn_can_parallelize_hashes(bool force_parallel) &test, true)) { ovs_mutex_lock(&init_mutex); - setup_worker_pools(force_parallel); + setup_worker_pools(force_parallel, 0); ovs_mutex_unlock(&init_mutex); } return can_parallelize; } struct worker_pool * -ovn_add_worker_pool(void *(*start)(void *)) +ovn_add_worker_pool(void *(*start)(void *), unsigned int thread_num) { struct worker_pool *new_pool = NULL; struct worker_control *new_control; @@ -109,7 +109,7 @@ ovn_add_worker_pool(void *(*start)(void *)) &test, true)) { ovs_mutex_lock(&init_mutex); - setup_worker_pools(false); + setup_worker_pools(false, thread_num); ovs_mutex_unlock(&init_mutex); } @@ -401,14 +401,14 @@ worker_pool_hook(void *aux OVS_UNUSED) { } static void -setup_worker_pools(bool force) { +setup_worker_pools(bool force, unsigned int thread_num) { int cores, nodes; nodes = ovs_numa_get_n_numas(); if (nodes == OVS_NUMA_UNSPEC || nodes <= 0) { nodes = 1; } - cores = ovs_numa_get_n_cores(); + cores = thread_num ? thread_num : ovs_numa_get_n_cores(); /* If there is no NUMA config, use 4 cores. * If there is NUMA config use half the cores on diff --git a/lib/ovn-parallel-hmap.h b/lib/ovn-parallel-hmap.h index 0af8914c4..9637a273d 100644 --- a/lib/ovn-parallel-hmap.h +++ b/lib/ovn-parallel-hmap.h @@ -95,7 +95,8 @@ struct worker_pool { /* Add a worker pool for thread function start() which expects a pointer to * a worker_control structure as an argument. */ -struct worker_pool *ovn_add_worker_pool(void *(*start)(void *)); +struct worker_pool *ovn_add_worker_pool(void *(*start)(void *), + unsigned int thread_num); /* Setting this to true will make all processing threads exit */ @@ -265,7 +266,7 @@ bool ovn_can_parallelize_hashes(bool force_parallel); #define stop_parallel_processing() ovn_stop_parallel_processing() -#define add_worker_pool(start) ovn_add_worker_pool(start) +#define add_worker_pool(start, thread_num) ovn_add_worker_pool(start, thread_num) #define fast_hmap_size_for(hmap, size) ovn_fast_hmap_size_for(hmap, size) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 570c6a3ef..ffefac361 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -4153,6 +4153,7 @@ ovn_lflow_init(struct ovn_lflow *lflow, struct ovn_datapath *od, * logical datapath only by creating a datapath group. */ static bool use_logical_dp_groups = false; static bool use_parallel_build = true; +static unsigned int num_parallel_threads; static struct hashrow_locks lflow_locks; @@ -12219,7 +12220,8 @@ init_lflows_thread_pool(void) int index; if (!pool_init_done) { - struct worker_pool *pool = add_worker_pool(build_lflows_thread); + struct worker_pool *pool = add_worker_pool(build_lflows_thread, + num_parallel_threads); pool_init_done = true; if (pool) { build_lflows_pool = xmalloc(sizeof(*build_lflows_pool)); @@ -13456,6 +13458,9 @@ ovnnb_db_run(struct northd_context *ctx, (smap_get_bool(&nb->options, "use_parallel_build", false) && ovn_can_parallelize_hashes(false)); + num_parallel_threads = + smap_get_uint(&nb->options, "num_parallel_threads", 0); + use_logical_dp_groups = smap_get_bool(&nb->options, "use_logical_dp_groups", false); use_ct_inv_match = smap_get_bool(&nb->options, diff --git a/ovn-nb.xml b/ovn-nb.xml index 36a77097c..d5bfb7ece 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -226,6 +226,16 @@ The default value is false.

+ +

+ Manually specify the number of threads to be used for parallel + logical flow computation. +

+

+ The number of threads utilized will be determined by the number + of vCPUs on the system if this value is not specified. +

+