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 C992C4575B; Wed, 7 Aug 2024 11:48:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2D67427E0; Wed, 7 Aug 2024 11:47:28 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mails.dpdk.org (Postfix) with ESMTP id 4E0F7427A1 for ; Wed, 7 Aug 2024 11:47:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723024043; x=1754560043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WNGvCEHT2eO8jmDMYmqgWt/AiLTTGF2USXUYqSHc79s=; b=d5pz9wQpDjMbLmqVv3XtCnCaf/48hs8oo/JUNkHscV7TP4xqVopv2GdR AJLFkYJ3lrsInJVtpUYc3ABKTmZnPeriOvjfI4R7CMtZ76GYHKyaMAJNZ Rvt4IZRTikCIXHXkWTJA+73amCKUN5ftsh8yGfLCWO2VKoGj+Ve3UHHLN eQBogt3xSw+kbQGlrva+XzNgrpult6qyOqKUmPg3DAhUL2qU5rQe1oYuL rvCeWYd2iL6Eo4F++O239miJoc3mvc/11QPM+NaPhEC3xK6vCnWQn5NjI kqY7oyn3GLLWQ8l1ZTX7jUsXKTDsOtWRxFiTvxZMvxAhK0BdwQfqpd5uE A==; X-CSE-ConnectionGUID: iOclOfAVTDCGQXA7oIHkXQ== X-CSE-MsgGUID: 0Jsmpfo9Rq+iwRuqg9B5mw== X-IronPort-AV: E=McAfee;i="6700,10204,11156"; a="21257945" X-IronPort-AV: E=Sophos;i="6.09,269,1716274800"; d="scan'208";a="21257945" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2024 02:47:22 -0700 X-CSE-ConnectionGUID: /2RlYuGFR62HIDXEzgdXTw== X-CSE-MsgGUID: 8gJv5chYQa69S7qaJMuNEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,269,1716274800"; d="scan'208";a="87467392" Received: from silpixa00400562.ir.intel.com (HELO silpixa00401385.ir.intel.com) ([10.237.214.39]) by orviesa002.jf.intel.com with ESMTP; 07 Aug 2024 02:47:21 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Subject: [PATCH v2 10/15] net/ice/base: optimize subtree searches Date: Wed, 7 Aug 2024 10:47:01 +0100 Message-ID: <20240807094706.459822-11-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240807094706.459822-1-bruce.richardson@intel.com> References: <20240807093407.452784-1-bruce.richardson@intel.com> <20240807094706.459822-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 In a number of places throughout the driver code, we want to confirm that a scheduler node is indeed a child of another node. Currently, this is confirmed by searching down the tree from the base until the desired node is hit, a search which may hit many irrelevant tree nodes when recursing down wrong branches. By switching the direction of search, to check upwards from the node to the parent, we can avoid any incorrect paths, and so speed up processing. Signed-off-by: Bruce Richardson --- drivers/net/ice/base/ice_sched.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c index be13833e1e..f7d5f8f415 100644 --- a/drivers/net/ice/base/ice_sched.c +++ b/drivers/net/ice/base/ice_sched.c @@ -1475,20 +1475,12 @@ ice_sched_find_node_in_subtree(struct ice_hw *hw, struct ice_sched_node *base, { u16 i; - for (i = 0; i < base->num_children; i++) { - struct ice_sched_node *child = base->children[i]; - - if (node == child) - return true; - - if (child->tx_sched_layer > node->tx_sched_layer) - return false; - - /* this recursion is intentional, and wouldn't - * go more than 8 calls - */ - if (ice_sched_find_node_in_subtree(hw, child, node)) + if (base == node) + return true; + while (node->tx_sched_layer != 0 && node->parent != NULL) { + if (node->parent == base) return true; + node = node->parent; } return false; } -- 2.43.0