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 8E85F4575B; Wed, 7 Aug 2024 11:35:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DFCD440EE7; Wed, 7 Aug 2024 11:34:31 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by mails.dpdk.org (Postfix) with ESMTP id B0B8D40E36 for ; Wed, 7 Aug 2024 11:34:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723023264; x=1754559264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WNGvCEHT2eO8jmDMYmqgWt/AiLTTGF2USXUYqSHc79s=; b=gCBN/JhqD2zIYrSH3iVreQRXaLDZ8bGpWk60IeMEiutHvp+IdjtJ9T1U obAnq8qW1i7LbMsznm+dA1mJMrJ6rnmc7alHSkF5h9ZJpPTJBWRopvpS7 NvjmijYfR6uY0jwqQWSyUBdn9ABHevgWAME8/Ij1iTUGFydYC6vFNZWLJ Ys5CbgNEgawIQ3AvR56dlEYWCcrIhVsHnwdhHOx/FdCwJDaAKuO4Yv9lP 1ebJDeYWzhIo58se527JcJ94NAGPZOY67VrO65nnX2oY/5a2T4kqCoEIj 3QR/WrafZmFoD0u0lDDMghGzVjemlfMz2nrsgMPUmmb4VGHds2SYuHfyq g==; X-CSE-ConnectionGUID: vQsdgDNqRhCtSbHt8pVuSw== X-CSE-MsgGUID: poLcCO6RTRqE4+o27x/pZQ== X-IronPort-AV: E=McAfee;i="6700,10204,11156"; a="12897959" X-IronPort-AV: E=Sophos;i="6.09,269,1716274800"; d="scan'208";a="12897959" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2024 02:34:23 -0700 X-CSE-ConnectionGUID: 6lJEkhP9SFukhhIg1ySZxA== X-CSE-MsgGUID: LTaoLR+9SiO8iX9OyxA5LA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,269,1716274800"; d="scan'208";a="87731026" Received: from silpixa00400562.ir.intel.com (HELO silpixa00401385.ir.intel.com) ([10.237.214.39]) by fmviesa001.fm.intel.com with ESMTP; 07 Aug 2024 02:34:23 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Subject: [PATCH 10/15] net/ice/base: optimize subtree searches Date: Wed, 7 Aug 2024 10:34:02 +0100 Message-ID: <20240807093407.452784-11-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240807093407.452784-1-bruce.richardson@intel.com> References: <20240807093407.452784-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