From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.neti, kuba@kernel.org
Cc: Bruce Allan <bruce.w.allan@intel.com>,
netdev@vger.kernel.org, sassmann@redhat.com,
anthony.l.nguyen@intel.com,
Harikumar Bokkena <harikumarx.bokkena@intel.com>
Subject: [net-next v2 01/15] ice: cleanup stack hog
Date: Fri, 13 Nov 2020 13:33:53 -0800 [thread overview]
Message-ID: <20201113213407.2131340-2-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20201113213407.2131340-1-anthony.l.nguyen@intel.com>
From: Bruce Allan <bruce.w.allan@intel.com>
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 <bruce.w.allan@intel.com>
Tested-by: Harikumar Bokkena <harikumarx.bokkena@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/ice/ice_flow.c | 44 +++++++++++++----------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c
index eadc85aee389..2a92071bd7d1 100644
--- a/drivers/net/ethernet/intel/ice/ice_flow.c
+++ b/drivers/net/ethernet/intel/ice/ice_flow.c
@@ -708,37 +708,42 @@ ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk,
struct ice_flow_seg_info *segs, u8 segs_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)
return ICE_ERR_BAD_PTR;
- memset(¶ms, 0, sizeof(params));
- params.prof = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*params.prof),
- GFP_KERNEL);
- if (!params.prof)
+ params = kzalloc(sizeof(*params), GFP_KERNEL);
+ if (!params)
return ICE_ERR_NO_MEMORY;
+ params->prof = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*params->prof),
+ GFP_KERNEL);
+ 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++)
- memcpy(¶ms.prof->segs[i], &segs[i], sizeof(*segs));
+ memcpy(¶ms->prof->segs[i], &segs[i], sizeof(*segs));
- 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");
@@ -746,19 +751,22 @@ 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.es);
+ status = ice_add_prof(hw, blk, prof_id, (u8 *)params->ptypes,
+ params->es);
if (status) {
ice_debug(hw, ICE_DBG_FLOW, "Error adding a HW flow profile\n");
goto out;
}
- INIT_LIST_HEAD(¶ms.prof->entries);
- mutex_init(¶ms.prof->entries_lock);
- *prof = params.prof;
+ INIT_LIST_HEAD(¶ms->prof->entries);
+ mutex_init(¶ms->prof->entries_lock);
+ *prof = params->prof;
out:
if (status)
- devm_kfree(ice_hw_to_dev(hw), params.prof);
+ devm_kfree(ice_hw_to_dev(hw), params->prof);
+free_params:
+ kfree(params);
return status;
}
--
2.26.2
next prev parent reply other threads:[~2020-11-13 21:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-13 21:33 [net-next v2 00/15][pull request] 100GbE Intel Wired LAN Driver Updates 2020-11-13 Tony Nguyen
2020-11-13 21:33 ` Tony Nguyen [this message]
2020-11-13 21:33 ` [net-next v2 02/15] ice: rename shared Flow Director functions Tony Nguyen
2020-11-13 21:33 ` [net-next v2 03/15] ice: initialize ACL table Tony Nguyen
2020-11-13 22:59 ` Alexander Duyck
2020-11-14 0:15 ` Nguyen, Anthony L
2020-11-14 1:50 ` Alexander Duyck
2020-11-21 0:39 ` Nguyen, Anthony L
2020-11-13 21:33 ` [net-next v2 04/15] ice: initialize ACL scenario Tony Nguyen
2020-11-13 21:33 ` [net-next v2 05/15] ice: create flow profile Tony Nguyen
2020-11-13 21:33 ` [net-next v2 06/15] ice: create ACL entry Tony Nguyen
2020-11-13 21:33 ` [net-next v2 07/15] ice: program " Tony Nguyen
2020-11-13 21:34 ` [net-next v2 08/15] ice: don't always return an error for Get PHY Abilities AQ command Tony Nguyen
2020-11-13 21:34 ` [net-next v2 09/15] ice: Enable Support for FW Override (E82X) Tony Nguyen
2020-11-13 21:34 ` [net-next v2 10/15] ice: Remove gate to OROM init Tony Nguyen
2020-11-13 21:34 ` [net-next v2 11/15] ice: Remove vlan_ena from vsi structure Tony Nguyen
2020-11-13 21:34 ` [net-next v2 12/15] ice: cleanup misleading comment Tony Nguyen
2020-11-13 21:34 ` [net-next v2 13/15] ice: silence static analysis warning Tony Nguyen
2020-11-13 21:34 ` [net-next v2 14/15] ice: join format strings to same line as ice_debug Tony Nguyen
2020-11-13 21:34 ` [net-next v2 15/15] ice: Add space to unknown speed Tony Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201113213407.2131340-2-anthony.l.nguyen@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=bruce.w.allan@intel.com \
--cc=davem@davemloft.neti \
--cc=harikumarx.bokkena@intel.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sassmann@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).