* [PATCH] libipw: split ieee->networks into small pieces
@ 2010-03-08 5:18 Zhu Yi
2010-03-08 8:01 ` Johannes Berg
0 siblings, 1 reply; 3+ messages in thread
From: Zhu Yi @ 2010-03-08 5:18 UTC (permalink / raw)
To: linville; +Cc: linux-wireless, Zhu Yi
The ieee->networks consists of 128 struct libipw_network entries. If
we allocate this chunk of memory altogether, it ends up with an
order 4 page allocation. High order page allocation is likely to fail
on system high load. This patch splits the big chunk memory allocation
into small pieces, each is 344 bytes, allocates them with 128 times.
The patch fixed bug http://bugzilla.kernel.org/show_bug.cgi?id=14989
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
---
drivers/net/wireless/ipw2x00/libipw.h | 2 +-
drivers/net/wireless/ipw2x00/libipw_module.c | 37 ++++++++++++--------------
2 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/drivers/net/wireless/ipw2x00/libipw.h b/drivers/net/wireless/ipw2x00/libipw.h
index bf45391..a6d5e42 100644
--- a/drivers/net/wireless/ipw2x00/libipw.h
+++ b/drivers/net/wireless/ipw2x00/libipw.h
@@ -797,7 +797,7 @@ struct libipw_device {
/* Probe / Beacon management */
struct list_head network_free_list;
struct list_head network_list;
- struct libipw_network *networks;
+ struct libipw_network *networks[MAX_NETWORK_COUNT];
int scans;
int scan_age;
diff --git a/drivers/net/wireless/ipw2x00/libipw_module.c b/drivers/net/wireless/ipw2x00/libipw_module.c
index 1ae0b2b..2fa5586 100644
--- a/drivers/net/wireless/ipw2x00/libipw_module.c
+++ b/drivers/net/wireless/ipw2x00/libipw_module.c
@@ -67,16 +67,17 @@ void *libipw_wiphy_privid = &libipw_wiphy_privid;
static int libipw_networks_allocate(struct libipw_device *ieee)
{
- if (ieee->networks)
- return 0;
-
- ieee->networks =
- kzalloc(MAX_NETWORK_COUNT * sizeof(struct libipw_network),
- GFP_KERNEL);
- if (!ieee->networks) {
- printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
- ieee->dev->name);
- return -ENOMEM;
+ int i, j;
+
+ for (i = 0; i < MAX_NETWORK_COUNT; i++) {
+ ieee->networks[i] = kzalloc(sizeof(struct libipw_network),
+ GFP_KERNEL);
+ if (!ieee->networks[i]) {
+ LIBIPW_ERROR("Out of memory allocating beacons\n");
+ for (j = 0; j < i; j++)
+ kfree(ieee->networks[j]);
+ return -ENOMEM;
+ }
}
return 0;
@@ -97,15 +98,11 @@ static inline void libipw_networks_free(struct libipw_device *ieee)
{
int i;
- if (!ieee->networks)
- return;
-
- for (i = 0; i < MAX_NETWORK_COUNT; i++)
- if (ieee->networks[i].ibss_dfs)
- kfree(ieee->networks[i].ibss_dfs);
-
- kfree(ieee->networks);
- ieee->networks = NULL;
+ for (i = 0; i < MAX_NETWORK_COUNT; i++) {
+ if (ieee->networks[i]->ibss_dfs)
+ kfree(ieee->networks[i]->ibss_dfs);
+ kfree(ieee->networks[i]);
+ }
}
void libipw_networks_age(struct libipw_device *ieee,
@@ -130,7 +127,7 @@ static void libipw_networks_initialize(struct libipw_device *ieee)
INIT_LIST_HEAD(&ieee->network_free_list);
INIT_LIST_HEAD(&ieee->network_list);
for (i = 0; i < MAX_NETWORK_COUNT; i++)
- list_add_tail(&ieee->networks[i].list,
+ list_add_tail(&ieee->networks[i]->list,
&ieee->network_free_list);
}
--
1.6.3.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] libipw: split ieee->networks into small pieces
2010-03-08 5:18 [PATCH] libipw: split ieee->networks into small pieces Zhu Yi
@ 2010-03-08 8:01 ` Johannes Berg
2010-03-08 9:07 ` Zhu Yi
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2010-03-08 8:01 UTC (permalink / raw)
To: Zhu Yi; +Cc: linville, linux-wireless
On Mon, 2010-03-08 at 13:18 +0800, Zhu Yi wrote:
> The ieee->networks consists of 128 struct libipw_network entries. If
> we allocate this chunk of memory altogether, it ends up with an
> order 4 page allocation. High order page allocation is likely to fail
> on system high load. This patch splits the big chunk memory allocation
> into small pieces, each is 344 bytes, allocates them with 128 times.
>
> The patch fixed bug http://bugzilla.kernel.org/show_bug.cgi?id=14989
Could it use cfg80211's scan list stuff and the wext handlers for
scanning there?
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libipw: split ieee->networks into small pieces
2010-03-08 8:01 ` Johannes Berg
@ 2010-03-08 9:07 ` Zhu Yi
0 siblings, 0 replies; 3+ messages in thread
From: Zhu Yi @ 2010-03-08 9:07 UTC (permalink / raw)
To: Johannes Berg; +Cc: linville@tuxdriver.com, linux-wireless@vger.kernel.org
On Mon, 2010-03-08 at 16:01 +0800, Johannes Berg wrote:
> On Mon, 2010-03-08 at 13:18 +0800, Zhu Yi wrote:
> > The ieee->networks consists of 128 struct libipw_network entries. If
> > we allocate this chunk of memory altogether, it ends up with an
> > order 4 page allocation. High order page allocation is likely to
> fail
> > on system high load. This patch splits the big chunk memory
> allocation
> > into small pieces, each is 344 bytes, allocates them with 128 times.
> >
> > The patch fixed bug http://bugzilla.kernel.org/show_bug.cgi?id=14989
>
> Could it use cfg80211's scan list stuff and the wext handlers for
> scanning there?
Probably yes. It all depends on how we organize the network list
internally. The ipw firmware sends raw management frames (assoc, beacon,
etc) to driver directly. So We can use cfg80211_bss to track beacons.
But it can require some effort since libipw_network is used throughout
libipw.
Thanks,
-yi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-08 9:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-08 5:18 [PATCH] libipw: split ieee->networks into small pieces Zhu Yi
2010-03-08 8:01 ` Johannes Berg
2010-03-08 9:07 ` Zhu Yi
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).