Skip to content
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

Support maximum of 64kB page on aarch64 #3146

Merged
merged 6 commits into from
Apr 18, 2022

Conversation

yuyichao
Copy link
Contributor

@yuyichao yuyichao commented Apr 11, 2022

Build the preload library to be aligned to 64kB following the default of binutils.

I've never used capnp before and I'm not sure yet how to add and use a new header field.....

If I'm doing things correctly, this should not affect x86...

Fix #3143

@yuyichao
Copy link
Contributor Author

  • I've cleaned up the commit a bit, now there are a few relatively standalone commits here that should hopefully help with reviewing. Most of the commits are refactoring that doesn't make a difference on x86.
  • Some of the commits can be its own PR, one of which is Consistently use 4k as the size unit for mmap2-like internal functions #3154. Since I think this is fully ready now I'm not going to split any out ATM into their own PR.
  • No separate linker script anymore. Use configure file instead.
  • It should be relatively easy to change the build time page size in the future, as shown in the last commit.
  • I've added two fields in the header for the runtime page size and the build time page size as suggested by @rocallahan

@yuyichao yuyichao force-pushed the aarch64-64kpage branch 2 times, most recently from 4f47bcd to d48aa8e Compare April 15, 2022 00:55
.set preload_thread_locals,0x70001000
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this use 0x70000000 + RR_PAGE_SIZE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was actually just because I was too lazy to check if the macro was defined by this point ;-p...

#define RR_THREAD_LOCALS_PAGE_ADDR 0x70001000
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise this could be RR_PAGE_ADDR + page_size()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the test so it's somewhat different. It would have to be rr_page_size() as well.

Copy link
Collaborator

@rocallahan rocallahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean librrpreload.so, not librrpage.so?

I think we should move rr_page_size() to to util.h/util.cc as a global function that's a peer of page_size(). I think we should also change its name ... how about rr_max_supported_page_size() since it's the the maximum page size supported by this build of rr (which is baked into librrpreload.so layout)?

@yuyichao
Copy link
Contributor Author

I'm fine with renaming. I pick the current name mainly to emphasize that it's the size of the block in the preload library, since that's actually what most of the code uses it for (they use that size with a multiplication factor to compute an offset/address). It's somewhat less obvious what address + n * maximum_support_page_size means but as I said, I don't feel too strong about it either...

@yuyichao
Copy link
Contributor Author

I also realized that I left one instance of RR_PAGE_SIZE unchanged so I'll need to fix that...

I also did only minimum amount of refactoring but I could refactor it more to make most things that need a page size to get them from fewer places. I wasn't sure how much to abstract out/assume but I guess I'll just assume that we'll have an architecture dependent maximum page size to support and refactor everything around that. If there's an architecture that doesn't have a upper limit for page size it might be a problem but I think the system linker would also have to make such a decision anyway.....

@rocallahan
Copy link
Collaborator

OK how about calling it preload_library_page_size() and document that it's the maximum supported page size for this architecture/rr build?

@yuyichao
Copy link
Contributor Author

Is there any specific reason to have both a function version rr_page_size() and a macro/constant version RR_PAGE_SIZE of seemingly the same thing? Should they be merged/both renamed?

@rocallahan
Copy link
Collaborator

You're right. We should just have a PRELOAD_LIBRARY_PAGE_SIZE constant and use that everywhere.

@yuyichao
Copy link
Contributor Author

OK, so there's no need to make it arch dependent at runtime? I guess we can worry about that if/when there's support for cross architecture record/replay?...

@rocallahan
Copy link
Collaborator

This has to be a build-time property because it determines the layout of the preload library.

@yuyichao
Copy link
Contributor Author

But in principle it only need to be a build time property librrpage.so (pretty sure this is the one I'm talking about, not librrpreload.so), the rr binary could accept multiple sizes and pick them at runtime.....

Anyway, constant it is for now...

@rocallahan
Copy link
Collaborator

Right. I want it in the trace header so that later we can change the value for a given architecture and extend rr to support replaying "old" traces with a different value, so it would have to be a function outside the preload library. But we don't need to do that now.

Just to be consistent on what we use
To better reflect what we use this for. This is the size of the blocks (pages) within librrpage.so and we use this size mostly for computing addresses within/around that file.
PRELOAD_LIBRARY_PAGE_SIZE is the size/alignment of librrpage.so which is determined at compile time.
It should not depend on the runtime system page size.
Use a cmake variable to control the page size/alignment used by
the linker script and the tweak script.
…ZE in the trace

In case we need to retrieve this information in a future version.
Build the preload library to be aligned to 64kB following the default of binutils.

Fix rr-debugger#3143
@yuyichao
Copy link
Contributor Author

I updated with the new name and replaced all use of rr_page_size with the constant. As shown in the last commit, there are still a few (5) places where this value is defined. This is because, AFAICT, these do not include a shared header.

The simplest method to avoid this is to just add a add_definitions(-DPRELOAD_LIBRARY_PAGE_SIZE=${PRELOAD_LIBRARY_PAGE_SIZE}). Maybe even an PRELOAD_LIBRARY_PAGE_SHIFT so that rr_page.S doesn't have to hard code another value that may get out of sync. However, this would mean that the header would be less standalone which is a minor concern since preload_interface.h is installed. If someone is relying on preload_interface.h being usable (granted the renaming would have broke the API) an alternative is to use configure_file to create a header with this value. If that's not a concern I can just go with add_definitions.

@yuyichao
Copy link
Contributor Author

(The new field in the trace file header is also updated)

@rocallahan
Copy link
Collaborator

I think this is good enough for now.

@rocallahan rocallahan merged commit 9300470 into rr-debugger:master Apr 18, 2022
@yuyichao yuyichao deleted the aarch64-64kpage branch April 18, 2022 11:52
@rocallahan
Copy link
Collaborator

Actually I added a followup patch 9d623e8 to set the default page size to its correct value, and made the page sizes UInt32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hard coded 4k page size
2 participants