From patchwork Mon Sep 7 11:27:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 76691 X-Patchwork-Delegate: qi.z.zhang@intel.com 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 06CF4A04B5; Mon, 7 Sep 2020 13:25:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7B07D1C124; Mon, 7 Sep 2020 13:24:43 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 77C371C10A for ; Mon, 7 Sep 2020 13:24:39 +0200 (CEST) IronPort-SDR: H90Ez1JAuchNjnXsBKSqHwLnT12+bY8S297iqaVJeQl/N4qcF2iPEpyyrV3eySCo4AyJEE3yUN PAdm514a1SnQ== X-IronPort-AV: E=McAfee;i="6000,8403,9736"; a="157252586" X-IronPort-AV: E=Sophos;i="5.76,401,1592895600"; d="scan'208";a="157252586" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 04:24:39 -0700 IronPort-SDR: hsKZtl8zYZYetKLokyjS0Bdt7hd+dHasaEDX9OOCku19cwn4b/XPtdeQ8k625kKYPpZjor+XuH qss8bMFn3ZUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,401,1592895600"; d="scan'208";a="328058744" Received: from dpdk51.sh.intel.com ([10.67.111.82]) by fmsmga004.fm.intel.com with ESMTP; 07 Sep 2020 04:24:37 -0700 From: Qi Zhang To: qiming.yang@intel.com Cc: dev@dpdk.org, Qi Zhang , Bruce Allan Date: Mon, 7 Sep 2020 19:27:51 +0800 Message-Id: <20200907112826.48493-6-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20200907112826.48493-1-qi.z.zhang@intel.com> References: <20200907112826.48493-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH 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 --- 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 6035bdfcf..d68a9ca5d 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; }