-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
mm: Add pending configuration for mm node struct and precding #15484
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,15 @@ | |
* previous freenode | ||
*/ | ||
|
||
#define MM_ALLOCNODE_OVERHEAD (MM_SIZEOF_ALLOCNODE - sizeof(mmsize_t)) | ||
#ifdef CONFIG_MM_NODE_PENDING | ||
# define MM_NODE_PENDING aligned_data(MM_ALIGN) | ||
# define MMSIZE_T_LEN MM_ALIGN | ||
#else | ||
# define MM_NODE_PENDING | ||
# define MMSIZE_T_LEN sizeof(mmsize_t) | ||
#endif | ||
|
||
#define MM_ALLOCNODE_OVERHEAD (MM_SIZEOF_ALLOCNODE - MMSIZE_T_LEN) | ||
|
||
/* Get the node size */ | ||
|
||
|
@@ -173,23 +181,41 @@ typedef size_t mmsize_t; | |
|
||
struct mm_allocnode_s | ||
{ | ||
mmsize_t preceding; /* Physical preceding chunk size */ | ||
mmsize_t size; /* Size of this chunk */ | ||
union | ||
{ | ||
mmsize_t preceding; /* Physical preceding chunk size */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not simplify to:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is invalid to do aligned_data(MM_ALIGN) on precding alone.
My understanding is that the alignment of attribute((aligned(16))) is more about the alignment of the size of the entire structure, and the alignment of a single member is limited to the alignment of access, not size.Therefore, using union is the only effective way to align the size There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but anonymous union doesn't support by all c compiler. |
||
uint8_t preceding_align[MMSIZE_T_LEN]; | ||
}; | ||
union | ||
{ | ||
mmsize_t size; /* Physical preceding chunk size */ | ||
uint8_t size_align[MMSIZE_T_LEN]; | ||
}; | ||
|
||
#if CONFIG_MM_BACKTRACE >= 0 | ||
pid_t pid; /* The pid for caller */ | ||
unsigned long seqno; /* The sequence of memory malloc */ | ||
# if CONFIG_MM_BACKTRACE > 0 | ||
FAR void *backtrace[CONFIG_MM_BACKTRACE]; /* The backtrace buffer for caller */ | ||
# endif | ||
#endif | ||
}; | ||
}MM_NODE_PENDING; | ||
|
||
/* This describes a free chunk */ | ||
|
||
struct mm_freenode_s | ||
{ | ||
mmsize_t preceding; /* Physical preceding chunk size */ | ||
mmsize_t size; /* Size of this chunk */ | ||
union | ||
{ | ||
mmsize_t preceding; /* Physical preceding chunk size */ | ||
W-M-R marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uint8_t preceding_align[MMSIZE_T_LEN]; | ||
}; | ||
union | ||
{ | ||
mmsize_t size; /* Physical preceding chunk size */ | ||
uint8_t size_align[MMSIZE_T_LEN]; | ||
}; | ||
|
||
#if CONFIG_MM_BACKTRACE >= 0 | ||
pid_t pid; /* The pid for caller */ | ||
unsigned long seqno; /* The sequence of memory malloc */ | ||
|
@@ -199,7 +225,7 @@ struct mm_freenode_s | |
#endif | ||
FAR struct mm_freenode_s *flink; /* Supports a doubly linked list */ | ||
FAR struct mm_freenode_s *blink; | ||
}; | ||
}MM_NODE_PENDING; | ||
|
||
static_assert(MM_SIZEOF_ALLOCNODE <= MM_MIN_CHUNK, | ||
"Error size for struct mm_allocnode_s\n"); | ||
|
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.