-
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?
Conversation
[Experimental Bot, please feedback here] This PR does not fully meet the NuttX requirements yet. While it provides a basic description of the change, it lacks crucial details in the Impact and Testing sections. Here's a breakdown of what's missing:
In short, the PR needs to be significantly more detailed before it can be properly reviewed. Filling in the missing information in the Impact and Testing sections is crucial. The Summary section could also benefit from more context. |
what are you trying to fix with this? |
The new feature arm64 MTE is added, "#15461" requires that the allocated block address must be 16-byte aligned and the size must also be 16-byte aligned. Our current memory management does not meet the requirements.Adding this alignment can solve this problem |
#ifdef CONFIG_MM_NODE_PENDING | ||
union | ||
{ | ||
mmsize_t preceding; /* Physical preceding chunk size */ |
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.
why not simplify to:
mmsize_t preceding aligned_data(MM_ALIGN);
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.
It is invalid to do aligned_data(MM_ALIGN) on precding alone.
#include <stdio.h>
struct st0
{
char a;
char b;
}__attribute__((aligned(16)));
struct st1
{
char a __attribute__((aligned(16)));
char b;
};
struct st2
{
char a;
char b __attribute__((aligned(16)));
};
struct st3
{
char a __attribute__((aligned(16)));
char b __attribute__((aligned(16)));
char d[15];
}__attribute__((aligned(16)));
struct st4
{
union
{
char a;
char a_align[16];
};
union
{
char b;
char b_align[16];
};
};
#define OFFSET(struct, member) (&(((struct *)0)->member))
#define PRINTF_STRUCT(struct) \
printf("%s: ", #struct); \
printf("size: %d\n", sizeof(struct)); \
printf("member a: %d\n", OFFSET(struct, a)); \
printf("member b: %d\n", OFFSET(struct, b));
int main()
{
PRINTF_STRUCT(struct st0);
PRINTF_STRUCT(struct st1);
PRINTF_STRUCT(struct st2);
PRINTF_STRUCT(struct st3);
PRINTF_STRUCT(struct st4);
}
struct st0: size: 16
member a: 0
member b: 1
struct st1: size: 16
member a: 0
member b: 1
struct st2: size: 32
member a: 0
member b: 16
struct st3: size: 32
member a: 0
member b: 16
struct st4: size: 32
member a: 0
member b: 16
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
mm/mm_heap/mm.h
Outdated
@@ -182,13 +201,22 @@ struct mm_allocnode_s | |||
FAR void *backtrace[CONFIG_MM_BACKTRACE]; /* The backtrace buffer for caller */ | |||
# endif | |||
#endif | |||
}; | |||
}MM_NODE_STRUCT_PENDING; |
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.
why need
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.
df13122
to
b45cc31
Compare
pending memory block node precding and the entire struct, after turning on this bit, the size of each memory block wil be aligned to MM_ALIGN Signed-off-by: wangmingrong1 <[email protected]>
pending memory block node precding and the entire struct, after turning on this bit, the size of each memory block wil be aligned to MM_ALIGN
Note: Please adhere to Contributing Guidelines.
Summary
pending memory block node precding and the entire struct, after turning on this bit, the size of each memory block wil be aligned to MM_ALIGN.Adding this alignment can solve this problem
Impact
The new feature arm64 MTE is added, "#15461" requires that the allocated block address must be 16-byte aligned and the size must also be 16-byte aligned. Our current memory management does not meet the requirements.
Testing
Update this section with details on how did you verify the change,
what Host was used for build (OS, CPU, compiler, ..), what Target was
used for verification (arch, board:config, ..), etc. Providing build
and runtime logs from before and after change is highly appreciated.