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 5C2F945B14; Fri, 11 Oct 2024 18:45:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6482A4069F; Fri, 11 Oct 2024 18:45:31 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by mails.dpdk.org (Postfix) with ESMTP id DF67E40662 for ; Fri, 11 Oct 2024 18:45:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728665128; x=1760201128; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+6LTDAYcn2JvWTZZpOZE5S/0YoE2f9KX89deNBnRHFI=; b=bqKAkNSOCDEsP8ojjmK7b9GKQoZ5mdR/vt4qalUGz63rTPwd1EO6udKZ Kn1KdDxNu03MfwzO7Zh+h7pcs542FZ8lSSPxcHvfxerlncFej0pOpfWR1 0fYztsIAidcB9iKYjMWUR7urEkMR22FU7qp2Ir5SFGU8oINx0nVxSZYaN 2NNh4+lw4GDn667FFeMCd/vwbjEz0zqaq8OiItLEdPNgx3zS3P7tbahaU bMFNG+AUrGErVNQan0VJ23pWqSon50G0Hjq7ghe5/xJ/winFoACiaJkI2 VxYQoERPZwI7ZjG+xmyJOFnvm0ku6WjGe6IvwHe1NKuBIigPdHJFhGHTr w==; X-CSE-ConnectionGUID: eEuM+RS3QbWKK1I2D5QoKQ== X-CSE-MsgGUID: 2EgUXOoCTEqx+8sJOpR3OA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="53477064" X-IronPort-AV: E=Sophos;i="6.11,196,1725346800"; d="scan'208";a="53477064" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2024 09:45:27 -0700 X-CSE-ConnectionGUID: XrWOFSbnQsKfystxtOm/AA== X-CSE-MsgGUID: CRJ9I7/iSMWJCRqrxuw9OA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,196,1725346800"; d="scan'208";a="76609320" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.25]) by fmviesa007.fm.intel.com with ESMTP; 11 Oct 2024 09:45:27 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Subject: [PATCH 6/9] net/ice/base: optimize subtree searches Date: Fri, 11 Oct 2024 17:44:56 +0100 Message-ID: <20241011164459.1987538-7-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241011164459.1987538-1-bruce.richardson@intel.com> References: <20241011164459.1987538-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