From patchwork Fri Sep 11 13:19:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 77392 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B6AF1A04B7; Fri, 11 Sep 2020 15:16:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 40D3E1C11C; Fri, 11 Sep 2020 15:16:12 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 0B4341C0DA for ; Fri, 11 Sep 2020 15:16:06 +0200 (CEST) IronPort-SDR: p5IQphfpXfGzOLbQf3NQmWYLppkCK9oBTL/G7xJgjix0nYYa4MoRtRFVz1Y9MYJBYxzaTe7hh9 jERYn8F5gdEQ== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146482121" X-IronPort-AV: E=Sophos;i="5.76,415,1592895600"; d="scan'208";a="146482121" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 06:16:06 -0700 IronPort-SDR: FB/oZK9duB2fFkPwxJ/2DarmsH/v+PyLDRMOZxdzY2EBg8wNeaE6sT+Xp7kTTLgiwvPHJps/Dd /kCMzb5ghgYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,415,1592895600"; d="scan'208";a="342296457" Received: from dpdk51.sh.intel.com ([10.67.111.82]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2020 06:16:04 -0700 From: Qi Zhang To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Qi Zhang , Bruce Allan Date: Fri, 11 Sep 2020 21:19:19 +0800 Message-Id: <20200911131954.15999-6-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20200911131954.15999-1-qi.z.zhang@intel.com> References: <20200907112826.48493-1-qi.z.zhang@intel.com> <20200911131954.15999-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2 05/40] net/ice/base: cleanup stack hog X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In ice_flow_add_prof_sync(), struct ice_flow_prof_params has recently grown in size hogging stack space when allocated there. Hogging stack space should be avoided. Change allocation to be on the heap when needed. Signed-off-by: Bruce Allan Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/base/ice_flow.c | 55 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c index 552e58f9b..0169da995 100644 --- a/drivers/net/ice/base/ice_flow.c +++ b/drivers/net/ice/base/ice_flow.c @@ -1815,52 +1815,57 @@ ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk, struct ice_flow_action *acts, u8 acts_cnt, struct ice_flow_prof **prof) { - struct ice_flow_prof_params params; + struct ice_flow_prof_params *params; enum ice_status status; u8 i; if (!prof || (acts_cnt && !acts)) return ICE_ERR_BAD_PTR; - ice_memset(¶ms, 0, sizeof(params), ICE_NONDMA_MEM); - params.prof = (struct ice_flow_prof *) - ice_malloc(hw, sizeof(*params.prof)); - if (!params.prof) + params = (struct ice_flow_prof_params *)ice_malloc(hw, sizeof(*params)); + if (!params) return ICE_ERR_NO_MEMORY; + params->prof = (struct ice_flow_prof *) + ice_malloc(hw, sizeof(*params->prof)); + if (!params->prof) { + status = ICE_ERR_NO_MEMORY; + goto free_params; + } + /* initialize extraction sequence to all invalid (0xff) */ for (i = 0; i < ICE_MAX_FV_WORDS; i++) { - params.es[i].prot_id = ICE_PROT_INVALID; - params.es[i].off = ICE_FV_OFFSET_INVAL; + params->es[i].prot_id = ICE_PROT_INVALID; + params->es[i].off = ICE_FV_OFFSET_INVAL; } - params.blk = blk; - params.prof->id = prof_id; - params.prof->dir = dir; - params.prof->segs_cnt = segs_cnt; + params->blk = blk; + params->prof->id = prof_id; + params->prof->dir = dir; + params->prof->segs_cnt = segs_cnt; /* Make a copy of the segments that need to be persistent in the flow * profile instance */ for (i = 0; i < segs_cnt; i++) - ice_memcpy(¶ms.prof->segs[i], &segs[i], sizeof(*segs), + ice_memcpy(¶ms->prof->segs[i], &segs[i], sizeof(*segs), ICE_NONDMA_TO_NONDMA); /* Make a copy of the actions that need to be persistent in the flow * profile instance. */ if (acts_cnt) { - params.prof->acts = (struct ice_flow_action *) + params->prof->acts = (struct ice_flow_action *) ice_memdup(hw, acts, acts_cnt * sizeof(*acts), ICE_NONDMA_TO_NONDMA); - if (!params.prof->acts) { + if (!params->prof->acts) { status = ICE_ERR_NO_MEMORY; goto out; } } - status = ice_flow_proc_segs(hw, ¶ms); + status = ice_flow_proc_segs(hw, params); if (status) { ice_debug(hw, ICE_DBG_FLOW, "Error processing a flow's packet segments\n"); @@ -1868,24 +1873,26 @@ ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk, } /* Add a HW profile for this flow profile */ - status = ice_add_prof(hw, blk, prof_id, (u8 *)params.ptypes, - params.attr, params.attr_cnt, params.es, - params.mask); + status = ice_add_prof(hw, blk, prof_id, (u8 *)params->ptypes, + params->attr, params->attr_cnt, params->es, + params->mask); if (status) { ice_debug(hw, ICE_DBG_FLOW, "Error adding a HW flow profile\n"); goto out; } - INIT_LIST_HEAD(¶ms.prof->entries); - ice_init_lock(¶ms.prof->entries_lock); - *prof = params.prof; + INIT_LIST_HEAD(¶ms->prof->entries); + ice_init_lock(¶ms->prof->entries_lock); + *prof = params->prof; out: if (status) { - if (params.prof->acts) - ice_free(hw, params.prof->acts); - ice_free(hw, params.prof); + if (params->prof->acts) + ice_free(hw, params->prof->acts); + ice_free(hw, params->prof); } +free_params: + ice_free(hw, params); return status; }