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 520C145B37; Mon, 14 Oct 2024 13:03:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7278B40697; Mon, 14 Oct 2024 13:03:10 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by mails.dpdk.org (Postfix) with ESMTP id 62E7740395 for ; Mon, 14 Oct 2024 13:03:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728903785; x=1760439785; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+6LTDAYcn2JvWTZZpOZE5S/0YoE2f9KX89deNBnRHFI=; b=f28YLxWG1ZVzwqOMJTbugj6G6qXnl5WBqE+huvHvSkG64u581CbYgEFf SIA7654wO/ZGLbhJ6Zavqep6x2yf+/Y3Xe8lphs/Y3qTgHHuYw6lPucqc 0QBPFRmYBNFqyuxBPO5wp0nKBP4avwIYZVixax8uY36QQ0od3BewNS1ze cwqo76UoS3v+UMAkS08D6B5dmEsjA1gsbJii00mTjTD6fJsuI7vrOOtCs RSdi/98gRnrZQz5SpXkdsbcFejIhGwF88NkWIEveGb5VLpJYYqnUNXDJ2 yiMb7ZuWkFfg7KuwxEiruBpU3/z98znbEHD1X6DIW0kcGYAnVKqEWrPMw g==; X-CSE-ConnectionGUID: 0QrGZa8mSWeMaJ2p9R58uw== X-CSE-MsgGUID: /dzO10IbQSmE5vsrLvKzHA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="28340348" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="28340348" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2024 04:03:04 -0700 X-CSE-ConnectionGUID: eIZFTWcoSvqxgbD9sZVzDA== X-CSE-MsgGUID: 5VNIq36pSl+HhDLmuOBtGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,202,1725346800"; d="scan'208";a="77167131" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.25]) by fmviesa006.fm.intel.com with ESMTP; 14 Oct 2024 04:03:02 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Subject: [PATCH v2 06/10] net/ice/base: optimize subtree searches Date: Mon, 14 Oct 2024 12:02:10 +0100 Message-ID: <20241014110250.2314727-7-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014110250.2314727-1-bruce.richardson@intel.com> References: <20241011164459.1987538-1-bruce.richardson@intel.com> <20241014110250.2314727-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 | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c index 45934f9152..4c5c19daf3 100644 --- a/drivers/net/ice/base/ice_sched.c +++ b/drivers/net/ice/base/ice_sched.c @@ -1464,25 +1464,16 @@ void ice_sched_get_psm_clk_freq(struct ice_hw *hw) * subtree or not */ bool -ice_sched_find_node_in_subtree(struct ice_hw *hw, struct ice_sched_node *base, +ice_sched_find_node_in_subtree(struct ice_hw __ALWAYS_UNUSED *hw, + struct ice_sched_node *base, struct ice_sched_node *node) { - u8 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