-
Notifications
You must be signed in to change notification settings - Fork 125
Replace kzalloc with mempool to reduce memory fragmentation #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -7,6 +7,8 @@ | |||
#include "http_parser.h" | |||
#include "http_server.h" | |||
|
|||
extern mempool_t *http_buf_pool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use extern
here. Honor the header instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue has been fixed. Thanks, professor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue has been fixed.
No, you didn't.
main.c
Outdated
static void *http_buf_alloc(gfp_t gfp_mask, void *pool_data) | ||
{ | ||
return kzalloc(RECV_BUFFER_SIZE, gfp_mask); | ||
} | ||
|
||
static void http_buf_free(void *element, void *pool_data) | ||
{ | ||
kfree(element); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the functions to the header as static inline
ones.
main.c
Outdated
return -ENOMEM; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the blank line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use git rebase -i
to squash commits.
Signed-off-by: Nick Huang <sef1548@gmail.com>
Replace kzalloc with mempool to reduce memory fragmentation
Using mempool improves memory allocation stability and reduces fragmentation
in high-frequency allocation scenarios, especially under memory pressure.