netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump
@ 2014-02-25 15:04 Michal Schmidt
  2014-02-25 15:04 ` [PATCH net-next 1/3] bnx2x: clamp num_queues to prevent passing a negative value Michal Schmidt
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Michal Schmidt @ 2014-02-25 15:04 UTC (permalink / raw)
  To: davem; +Cc: netdev, ariele, dmitry, yuvalmin

kdump kernels usually have only a small amount of memory reserved.
bnx2x can be memory-hungry. Let's minimize its memory usage when
running in kdump.

I detect kdump by looking at the "reset_devices" flag. A couple of
storage drivers (cciss, hpsa) use it for the same purpose. I am not sure
this is the best way to solve the problem, but it works.

Should it be made more generic by, say, looking at the total amount
of lowmem instead? Not using TPA by default when lowmem is small and/or
defaulting to fewer queues would help 32bit systems where a driver for
a multi-function multi-queue NIC can consume a significant amount
of available memory. Or do we want no such heuristics?

Is this something to consider doing for other network drivers too?

Michal Schmidt (3):
  bnx2x: clamp num_queues to prevent passing a negative value
  bnx2x: save RAM in kdump kernel by using a single queue
  bnx2x: save RAM in kdump kernel by disabling TPA

 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c  | 12 ++++++++----
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |  2 ++
 2 files changed, 10 insertions(+), 4 deletions(-)

-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/3] bnx2x: clamp num_queues to prevent passing a negative value
  2014-02-25 15:04 [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump Michal Schmidt
@ 2014-02-25 15:04 ` Michal Schmidt
  2014-02-25 15:04 ` [PATCH net-next 2/3] bnx2x: save RAM in kdump kernel by using a single queue Michal Schmidt
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Michal Schmidt @ 2014-02-25 15:04 UTC (permalink / raw)
  To: davem; +Cc: netdev, ariele, dmitry, yuvalmin

Use the clamp() macro to make the calculation of the number of queues
slightly easier to understand. It also avoids a crash when someone
accidentally passes a negative value in num_queues= module parameter.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 5ee13af..64c17b6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -61,10 +61,9 @@ static void bnx2x_add_all_napi(struct bnx2x *bp)
 
 static int bnx2x_calc_num_queues(struct bnx2x *bp)
 {
-	return  bnx2x_num_queues ?
-		 min_t(int, bnx2x_num_queues, BNX2X_MAX_QUEUES(bp)) :
-		 min_t(int, netif_get_num_default_rss_queues(),
-		       BNX2X_MAX_QUEUES(bp));
+	int nq = bnx2x_num_queues ? : netif_get_num_default_rss_queues();
+	nq = clamp(nq, 1, BNX2X_MAX_QUEUES(bp));
+	return nq;
 }
 
 /**
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/3] bnx2x: save RAM in kdump kernel by using a single queue
  2014-02-25 15:04 [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump Michal Schmidt
  2014-02-25 15:04 ` [PATCH net-next 1/3] bnx2x: clamp num_queues to prevent passing a negative value Michal Schmidt
@ 2014-02-25 15:04 ` Michal Schmidt
  2014-02-25 15:04 ` [PATCH net-next 3/3] bnx2x: save RAM in kdump kernel by disabling TPA Michal Schmidt
  2014-02-25 16:41 ` [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump Ariel Elior
  3 siblings, 0 replies; 6+ messages in thread
From: Michal Schmidt @ 2014-02-25 15:04 UTC (permalink / raw)
  To: davem; +Cc: netdev, ariele, dmitry, yuvalmin

When running in a kdump kernel, make sure to use only a single ethernet
queue even if a num_queues option in /etc/modprobe.d/*.conf would specify
otherwise. This saves memory, which tends to be scarce in kdump.

This saves about 40 MB in the kdump environment on a setup with
num_queues=8 in the config file.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 64c17b6..500d38a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -62,6 +62,11 @@ static void bnx2x_add_all_napi(struct bnx2x *bp)
 static int bnx2x_calc_num_queues(struct bnx2x *bp)
 {
 	int nq = bnx2x_num_queues ? : netif_get_num_default_rss_queues();
+
+	/* Reduce memory usage in kdump environment by using only one queue */
+	if (reset_devices)
+		nq = 1;
+
 	nq = clamp(nq, 1, BNX2X_MAX_QUEUES(bp));
 	return nq;
 }
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/3] bnx2x: save RAM in kdump kernel by disabling TPA
  2014-02-25 15:04 [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump Michal Schmidt
  2014-02-25 15:04 ` [PATCH net-next 1/3] bnx2x: clamp num_queues to prevent passing a negative value Michal Schmidt
  2014-02-25 15:04 ` [PATCH net-next 2/3] bnx2x: save RAM in kdump kernel by using a single queue Michal Schmidt
@ 2014-02-25 15:04 ` Michal Schmidt
  2014-02-25 16:41 ` [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump Ariel Elior
  3 siblings, 0 replies; 6+ messages in thread
From: Michal Schmidt @ 2014-02-25 15:04 UTC (permalink / raw)
  To: davem; +Cc: netdev, ariele, dmitry, yuvalmin

When running in a kdump kernel, disable TPA. This saves memory, which
tends to be scarce in kdump.

TPA, being a receive acceleration, is unlikely to be useful for kdump,
whose purpose is to send the memory image out.

This saves additional 5 MB in the kdump environment.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 8443915..13de536 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -11783,6 +11783,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
 
 	bp->disable_tpa = disable_tpa;
 	bp->disable_tpa |= IS_MF_STORAGE_SD(bp) || IS_MF_FCOE_AFEX(bp);
+	/* Reduce memory usage in kdump environment by disabling TPA */
+	bp->disable_tpa |= reset_devices;
 
 	/* Set TPA flags */
 	if (bp->disable_tpa) {
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump
  2014-02-25 15:04 [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump Michal Schmidt
                   ` (2 preceding siblings ...)
  2014-02-25 15:04 ` [PATCH net-next 3/3] bnx2x: save RAM in kdump kernel by disabling TPA Michal Schmidt
@ 2014-02-25 16:41 ` Ariel Elior
  2014-02-26 20:28   ` David Miller
  3 siblings, 1 reply; 6+ messages in thread
From: Ariel Elior @ 2014-02-25 16:41 UTC (permalink / raw)
  To: Michal Schmidt, davem@davemloft.net
  Cc: netdev@vger.kernel.org, Dmitry Kravkov, Yuval Mintz

> -----Original Message-----
> From: Michal Schmidt [mailto:mschmidt@redhat.com]
> Sent: Tuesday, February 25, 2014 5:04 PM
> To: davem@davemloft.net
> Cc: netdev@vger.kernel.org; Ariel Elior; Dmitry Kravkov; Yuval Mintz
> Subject: [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump
> 
> kdump kernels usually have only a small amount of memory reserved.
> bnx2x can be memory-hungry. Let's minimize its memory usage when
> running in kdump.
> 
> I detect kdump by looking at the "reset_devices" flag. A couple of
> storage drivers (cciss, hpsa) use it for the same purpose. I am not sure
> this is the best way to solve the problem, but it works.
> 
> Should it be made more generic by, say, looking at the total amount
> of lowmem instead? Not using TPA by default when lowmem is small and/or
> defaulting to fewer queues would help 32bit systems where a driver for
> a multi-function multi-queue NIC can consume a significant amount
> of available memory. Or do we want no such heuristics?
> 
> Is this something to consider doing for other network drivers too?
> 
> Michal Schmidt (3):
>   bnx2x: clamp num_queues to prevent passing a negative value
>   bnx2x: save RAM in kdump kernel by using a single queue
>   bnx2x: save RAM in kdump kernel by disabling TPA
> 
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c  | 12 ++++++++----
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |  2 ++
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> --
> 1.8.5.3

This series looks good, in the sense that it modifies the driver in a correct way to achieve the intended result (less memory on kdump).
The basic question of testing lowmem vs. reset_devices or perhaps some other parameter still needs to be answered though.
Acked-by: Ariel Elior <ariele@broadcom.com>

Thanks,
Ariel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump
  2014-02-25 16:41 ` [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump Ariel Elior
@ 2014-02-26 20:28   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2014-02-26 20:28 UTC (permalink / raw)
  To: ariele; +Cc: mschmidt, netdev, dmitry, yuvalmin

From: Ariel Elior <ariele@broadcom.com>
Date: Tue, 25 Feb 2014 16:41:07 +0000

>> -----Original Message-----
>> From: Michal Schmidt [mailto:mschmidt@redhat.com]
>> Sent: Tuesday, February 25, 2014 5:04 PM
>> To: davem@davemloft.net
>> Cc: netdev@vger.kernel.org; Ariel Elior; Dmitry Kravkov; Yuval Mintz
>> Subject: [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump
>> 
>> kdump kernels usually have only a small amount of memory reserved.
>> bnx2x can be memory-hungry. Let's minimize its memory usage when
>> running in kdump.
>> 
>> I detect kdump by looking at the "reset_devices" flag. A couple of
>> storage drivers (cciss, hpsa) use it for the same purpose. I am not sure
>> this is the best way to solve the problem, but it works.
>> 
>> Should it be made more generic by, say, looking at the total amount
>> of lowmem instead? Not using TPA by default when lowmem is small and/or
>> defaulting to fewer queues would help 32bit systems where a driver for
>> a multi-function multi-queue NIC can consume a significant amount
>> of available memory. Or do we want no such heuristics?
>> 
>> Is this something to consider doing for other network drivers too?
>> 
>> Michal Schmidt (3):
>>   bnx2x: clamp num_queues to prevent passing a negative value
>>   bnx2x: save RAM in kdump kernel by using a single queue
>>   bnx2x: save RAM in kdump kernel by disabling TPA
>> 
>>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c  | 12 ++++++++----
>>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |  2 ++
>>  2 files changed, 10 insertions(+), 4 deletions(-)
>> 
>> --
>> 1.8.5.3
> 
> This series looks good, in the sense that it modifies the driver in a correct way to achieve the intended result (less memory on kdump).
> The basic question of testing lowmem vs. reset_devices or perhaps some other parameter still needs to be answered though.
> Acked-by: Ariel Elior <ariele@broadcom.com>

Series applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-02-26 20:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-25 15:04 [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump Michal Schmidt
2014-02-25 15:04 ` [PATCH net-next 1/3] bnx2x: clamp num_queues to prevent passing a negative value Michal Schmidt
2014-02-25 15:04 ` [PATCH net-next 2/3] bnx2x: save RAM in kdump kernel by using a single queue Michal Schmidt
2014-02-25 15:04 ` [PATCH net-next 3/3] bnx2x: save RAM in kdump kernel by disabling TPA Michal Schmidt
2014-02-25 16:41 ` [PATCH net-next 0/3] bnx2x: minimize RAM usage in kdump Ariel Elior
2014-02-26 20:28   ` David Miller

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).