Skip to contentSkip to conversation

ratelimit: convert flags to int to save 8 bytes in size

PATCH Applied Mateusz Guzik 1 participant 2 messages Aug 17, 2024 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ratelimit: convert flags to int to save 8 bytes in size

Only bit 1 is used, making an unsigned long a total overkill.

This brings it from 64 to 32 bytes, which in turn shrinks user_struct from 136 to 128 bytes. Since the latter is allocated with hwalign, this means the total usage goes down from 192 to 128 bytes per object.

No functional changes.

---

./scripts/get_maintainer.pl --git was most unhelpful showing nothing

I have no idea who to prod about it, I think it is pretty trivial not needing any discussion.

Andrew Morton pulled in some of the changes to the file, so that's my primary recipient.

 include/linux/ratelimit_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ratelimit_types.h +1 -1
index 002266693e50..765232ce0b5e 100644
@@ -19,8 +19,8 @@ struct ratelimit_state {
 	int		burst;
 	int		printed;
 	int		missed;
+	unsigned int	flags;
 	unsigned long	begin;
-	unsigned long	flags;
 };
 
 #define RATELIMIT_STATE_INIT_FLAGS(name, interval_init, burst_init, flags_init) { \
Signature · 1 line
2.43.0
#1 lore raw
Quoted 3 lines · Mateusz Guzik

Only bit 1 is used, making an unsigned long a total overkill.

This brings it from 64 to 32 bytes, which in turn shrinks user_struct

sigh, 40 to 32 bytes of course

this is embedded into user_struct, avoidably pushing it past 128 bytes of size

Quoted 37 lines

from 136 to 128 bytes. Since the latter is allocated with hwalign, this means the total usage goes down from 192 to 128 bytes per object.

No functional changes.

---

./scripts/get_maintainer.pl --git was most unhelpful showing nothing

I have no idea who to prod about it, I think it is pretty trivial not needing any discussion.

Andrew Morton pulled in some of the changes to the file, so that's my primary recipient.

 include/linux/ratelimit_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ratelimit_types.h +1 -1
index 002266693e50..765232ce0b5e 100644
@@ -19,8 +19,8 @@ struct ratelimit_state {
 	int		burst;
 	int		printed;
 	int		missed;
+	unsigned int	flags;
 	unsigned long	begin;
-	unsigned long	flags;
 };
 
 #define RATELIMIT_STATE_INIT_FLAGS(name, interval_init, burst_init, flags_init) { \
Signature · 1 line
2.43.0