Skip to contentSkip to conversation

ath9k: decrease size of ath9k.ko

PATCH New tom.leiming at gmail.com 6 participants 11 messages Feb 27, 2010 – Mar 11, 2010 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

From: Ming Lei <[email protected]>

The patch defines the fields of 'valid_single_stream' and 'valid' in struct ath_rate_table as char type, so decrease the size of ath9k.ko about 2KB.

old ath9k.ko
[tom at tom-lei ath9k]$ size ath9k.ko

   text    data     bss     dec     hex filename
  69344    3080     168   72592   11b90 ath9k.ko

new ath9k.ko
[tom at tom-lei ath9k]$ size ath9k.ko

   text    data     bss     dec     hex filename
  67304    3080     168   70552   11398 ath9k.ko
---
 drivers/net/wireless/ath/ath9k/rc.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/rc.h +2 -2
index 4f6d6fd..389168a 100644
@@ -110,8 +110,8 @@ struct ath_rate_table {
 	int rate_cnt;
 	int mcs_start;
 	struct {
-		int valid;
-		int valid_single_stream;
+		char valid;
+		char valid_single_stream;
 		u8 phy;
 		u32 ratekbps;
 		u32 user_ratekbps;
Signature · 1 line
1.6.2.5
#1 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

Quoted 26 lines · tom.leiming at gmail.com

From: Ming Lei <[email protected]>

The patch defines the fields of 'valid_single_stream' and 'valid' in struct ath_rate_table as char type, so decrease the size of ath9k.ko about 2KB.

old ath9k.ko
[tom at tom-lei ath9k]$ size ath9k.ko

   text    data     bss     dec     hex filename
  69344    3080     168   72592   11b90 ath9k.ko

new ath9k.ko
[tom at tom-lei ath9k]$ size ath9k.ko

   text    data     bss     dec     hex filename
  67304    3080     168   70552   11398 ath9k.ko
---
 drivers/net/wireless/ath/ath9k/rc.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/rc.h +0 -0
index 4f6d6fd..389168a 100644

drivers/net/wireless/ath/ath9k/rc.h struct ath_rate_table { · line 117

Quoted 10 lines
drivers/net/wireless/ath/ath9k/rc.h +2 -2
@@ -110,8 +110,8 @@ struct ath_rate_table {
 	int rate_cnt;
 	int mcs_start;
 	struct {
-		int valid;
-		int valid_single_stream;
+		char valid;
+		char valid_single_stream;
 		u8 phy;
 		u32 ratekbps;
 		u32 user_ratekbps;

Why 'char' rather than 'u8'? To me, the latter implies a small integer, not character data.

Larry

author
#2 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

2010/2/28 Larry Finger <[email protected]>:

Quoted 32 lines · tom.leiming at gmail.com
Quoted 31 lines

From: Ming Lei <[email protected]>

The patch defines the fields of 'valid_single_stream' and 'valid' in struct ath_rate_table as char type, so decrease the size of ath9k.ko about 2KB.

old ath9k.ko
[tom at tom-lei ath9k]$ size ath9k.ko
? ?text ? ?data ? ? bss ? ? dec ? ? hex filename
? 69344 ? ?3080 ? ? 168 ? 72592 ? 11b90 ath9k.ko

new ath9k.ko
[tom at tom-lei ath9k]$ size ath9k.ko
? ?text ? ?data ? ? bss ? ? dec ? ? hex filename
? 67304 ? ?3080 ? ? 168 ? 70552 ? 11398 ath9k.ko

---
?drivers/net/wireless/ath/ath9k/rc.h | ? ?4 ++--
?1 files changed, 2 insertions(+), 2 deletions(-)

drivers/net/wireless/ath/ath9k/rc.h +0 -2
index 4f6d6fd..389168a 100644
@@ -110,8 +110,8 @@ struct ath_rate_table {
 ? ? ? int rate_cnt;
 ? ? ? int mcs_start;
 ? ? ? struct {
- ? ? ? ? ? ? int valid;
- ? ? ? ? ? ? int valid_single_stream;
Quoted 8 lines

drivers/net/wireless/ath/ath9k/rc.h struct ath_rate_table { · line 117

Quoted 5 lines
drivers/net/wireless/ath/ath9k/rc.h +2 -0
+ ? ? ? ? ? ? char valid;
+ ? ? ? ? ? ? char valid_single_stream;
 ? ? ? ? ? ? ? u8 phy;
 ? ? ? ? ? ? ? u32 ratekbps;
 ? ? ? ? ? ? ? u32 user_ratekbps;

Why 'char' rather than 'u8'? To me, the latter implies a small integer, not character data.

Either 'char' or 'u8' is OK, since both has one-byte size, isn't it?

Thanks,

Signature · 1 line
Lei Ming
#3 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

Quoted 42 lines · Ming Lei

2010/2/28 Larry Finger <[email protected]>:

Quoted 32 lines · tom.leiming at gmail.com
Quoted 31 lines

From: Ming Lei <[email protected]>

The patch defines the fields of 'valid_single_stream' and 'valid' in struct ath_rate_table as char type, so decrease the size of ath9k.ko about 2KB.

old ath9k.ko
[tom at tom-lei ath9k]$ size ath9k.ko

   text    data     bss     dec     hex filename
  69344    3080     168   72592   11b90 ath9k.ko

new ath9k.ko
[tom at tom-lei ath9k]$ size ath9k.ko

   text    data     bss     dec     hex filename
  67304    3080     168   70552   11398 ath9k.ko
---
 drivers/net/wireless/ath/ath9k/rc.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/rc.h +0 -2
index 4f6d6fd..389168a 100644
@@ -110,8 +110,8 @@ struct ath_rate_table {
      int rate_cnt;
      int mcs_start;
      struct {
-             int valid;
-             int valid_single_stream;
Quoted 8 lines

drivers/net/wireless/ath/ath9k/rc.h struct ath_rate_table { · line 117

Quoted 5 lines
drivers/net/wireless/ath/ath9k/rc.h +2 -0
+             char valid;
+             char valid_single_stream;
              u8 phy;
              u32 ratekbps;
              u32 user_ratekbps;

Why 'char' rather than 'u8'? To me, the latter implies a small integer, not character data.

Quoted 1 line

Either 'char' or 'u8' is OK, since both has one-byte size, isn't it?

It wasn't the size, but the content implied by the type.

author
#4 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

Quoted 2 lines

From e74b075cdb143d45be9b371ee8a8e2dcfc15ab34 Mon Sep 17 00:00:00 2001

From: Ming Lei <[email protected]>
Date: Sat, 27 Feb 2010 23:50:54 +0800
Subject: [PATCH] ath9k: decrease size of ath9k.ko

The patch defines the fields of 'valid_single_stream' and 'valid' in struct ath_rate_table as char type, so decrease the size of ath9k.ko about 2KB.

old ath9k.ko
[tom@tom-lei ath9k]$ size ath9k.ko

   text    data     bss     dec     hex filename
  69344    3080     168   72592   11b90 ath9k.ko

new ath9k.ko
[tom@tom-lei ath9k]$ size ath9k.ko

   text    data     bss     dec     hex filename
  67304    3080     168   70552   11398 ath9k.ko

---

This version takes Larry's suggestion to define 'valid_single_stream' and 'valid' as u8 instead of char.

---
 drivers/net/wireless/ath/ath9k/rc.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/rc.h +2 -2
index 4f6d6fd..aeaaa88 100644
@@ -110,8 +110,8 @@ struct ath_rate_table {
 	int rate_cnt;
 	int mcs_start;
 	struct {
-		int valid;
-		int valid_single_stream;
+		u8 valid;
+		u8 valid_single_stream;
 		u8 phy;
 		u32 ratekbps;
 		u32 user_ratekbps;
Signature · 5 lines
1.6.2.5



On Sat, 27 Feb 2010 21:19:51 -0600
Quoted 8 lines · Larry Finger
Quoted 5 lines · Ming Lei

2010/2/28 Larry Finger <[email protected]>:

Quoted 2 lines · On 02/27/2010 10:56 AM, [email protected] wrote:
Quoted 1 line

From: Ming Lei <[email protected]>

Either 'char' or 'u8' is OK, since both has one-byte size, isn't it?

It wasn't the size, but the content implied by the type.

#5 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

drivers/net/wireless/ath/ath9k/rc.h struct ath_rate_table {

Quoted 4 lines · Ming Lei
drivers/net/wireless/ath/ath9k/rc.h +2 -2
-		int valid;
-		int valid_single_stream;
+		u8 valid;
+		u8 valid_single_stream;

You can use bool instead, and that would give the same size saving while being even more descriptive. I think using bool could be safer, as the compiler would be able to detect some misuses and the values.

But I could get even more saving by using bool with the field width:

bool valid:1;
bool valid_single_stream:1;

That would place both variables into one byte. It may be ineffective for speed, but it's more effective for storage.

In my configuration, I get following sizes:

original (int):    2792138
your patch (u8):   2790186
bool:              2790186
bool (1 bit):      2789218
Signature · 2 lines
Regards,
Pavel Roskin
#6 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

Quoted 18 lines · Pavel Roskin

drivers/net/wireless/ath/ath9k/rc.h struct ath_rate_table {

Quoted 4 lines · Ming Lei
drivers/net/wireless/ath/ath9k/rc.h +2 -2
-		int valid;
-		int valid_single_stream;
+		u8 valid;
+		u8 valid_single_stream;

You can use bool instead, and that would give the same size saving while being even more descriptive. I think using bool could be safer, as the compiler would be able to detect some misuses and the values.

But I could get even more saving by using bool with the field width:

bool valid:1;
bool valid_single_stream:1;

That would place both variables into one byte. It may be ineffective for speed, but it's more effective for storage.

Quoted 6 lines

In my configuration, I get following sizes:

original (int):    2792138
your patch (u8):   2790186
bool:              2790186
bool (1 bit):      2789218

Or use flags, and use BIT(1), BIT(2), etc for #defines for each stream mode. Would save even more.

Luis

author
#7 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

In reply to Pavel Roskin

2010/3/3 Pavel Roskin <[email protected]>:

Quoted 18 lines · Ming Lei
Quoted 4 lines

- ? ? ? ? ? ? int valid;
- ? ? ? ? ? ? int valid_single_stream;
+ ? ? ? ? ? ? u8 valid;
+ ? ? ? ? ? ? u8 valid_single_stream;

You can use bool instead, and that would give the same size saving while being even more descriptive. ?I think using bool could be safer, as the compiler would be able to detect some misuses and the values.

But I could get even more saving by using bool with the field width:

bool valid:1;
bool valid_single_stream:1;

That would place both variables into one byte. ?It may be ineffective for speed, but it's more effective for storage.

Quoted 6 lines

In my configuration, I get following sizes:

original (int): ? ?2792138
your patch (u8): ? 2790186
bool: ? ? ? ? ? ? ?2790186
bool (1 bit): ? ? ?2789218

1bit is not enough, at least 3bit is required for each one.

We does not save more using bit field since size of the least type is 1 byte.

Signature · 1 line
Lei Ming
#8 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

In reply to Ming Lei
Quoted 1 line

Either 'char' or 'u8' is OK, since both has one-byte size, isn't it?

Besides Johannes' comment: char is signed, u8 is unsigned. This can sometimes byte you.

Signature · 1 line
http://www.holgerschurig.de
#9 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

In reply to tom.leiming at gmail.com
Quoted 5 lines · tom.leiming at gmail.com

From: Ming Lei <[email protected]>

The patch defines the fields of 'valid_single_stream' and 'valid' in struct ath_rate_table as char type, so decrease the size of ath9k.ko about 2KB.

Why would this be a -stable patch?

confused,

greg k-h

#10 lore raw

PATCH 1/1 ath9k: decrease size of ath9k.ko

Quoted 10 lines · Greg KH
Quoted 5 lines · tom.leiming at gmail.com

From: Ming Lei <[email protected]>

The patch defines the fields of 'valid_single_stream' and 'valid' in struct ath_rate_table as char type, so decrease the size of ath9k.ko about 2KB.

Why would this be a -stable patch?

confused,

Its not, oh he e-mailed stable, yeah ignore.

Luis