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

prov/opx: define PAGE_SIZE if undefined #10308

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Xeonacid
Copy link

Some arch like riscv does not have a standard defined PAGE_SIZE in sys/user.h.

@j-xiong
Copy link
Contributor

j-xiong commented Aug 14, 2024

@charlesshereda Does this look ok to you?

Copy link
Contributor

@charlesshereda charlesshereda left a comment

Choose a reason for hiding this comment

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

Requesting merge be withheld pending feedback from @j-xiong and why @Xeonacid felt existing code wasn't working given fix is already present.

@charlesshereda
Copy link
Contributor

I think this should already be covered in c52e280, no? Plus that earlier commit protects it by specifically checking if it's a RISC-V arch.

@shefty
Copy link
Member

shefty commented Aug 16, 2024

I agree with @charlesshereda , c52e280 has a similar fix.

@Xeonacid
Copy link
Author

Xeonacid commented Aug 17, 2024

@charlesshereda @shefty c52e280 fixes the issue for i_opx_hfi1_packet.h, but it is not included by opa_user_gen1.h.
Placing the fix in a header included by both headers might be a good idea. Do you have any suggestions for which header to choose?
Additionally, the fix in c52e280 is not entirely correct; it should be 4096UL instead of 4096 (int).

@shefty
Copy link
Member

shefty commented Aug 17, 2024

Can you use page_sizes[OFI_PAGE_SIZE], which gets the actual page size, rather than hard-coding 4k?

Looking at the existing code (well at least since my last update), it looks like PAGE_SIZE is only used to set OPX_HFI1_TID_PAGESIZE. Honestly, it's bad form for a provider to define a preprocessor define that's not protected using some sort of prefix. 'PAGE_SIZE' should probably be replaced with OPX_HFI1_TID_PAGESIZE. If PAGE_SIZE isn't defined, rather than defining it, define OPX_HFI1_TID_PAGESIZE to 4k or page_sizes[OFI_PAGE_SIZE] instead.

@Xeonacid
Copy link
Author

Can you use page_sizes[OFI_PAGE_SIZE], which gets the actual page size, rather than hard-coding 4k?

Looking at the existing code (well at least since my last update), it looks like PAGE_SIZE is only used to set OPX_HFI1_TID_PAGESIZE. Honestly, it's bad form for a provider to define a preprocessor define that's not protected using some sort of prefix. 'PAGE_SIZE' should probably be replaced with OPX_HFI1_TID_PAGESIZE. If PAGE_SIZE isn't defined, rather than defining it, define OPX_HFI1_TID_PAGESIZE to 4k or page_sizes[OFI_PAGE_SIZE] instead.

I'm wondering how OFI_PAGE_SIZE should be used, which is an enum that should be 0:

enum {
	OFI_PAGE_SIZE,
	OFI_DEF_HUGEPAGE_SIZE,
};

Current code directly uses it as follows:

/* prov/psm3/shared/mem.c */
079 | page_sizes[OFI_PAGE_SIZE] = psize;

Replaces PAGE_SIZE with OFI_PAGE_SIZE should lead to a bad result.
Is there special handling for OFI_PAGE_SIZE in the code, or am I misunderstanding something?

@shefty
Copy link
Member

shefty commented Aug 18, 2024

OFI_PAGE_SIZE is an index, which is why you need to use page_sizes[OFI_PAGE_SIZE]. page_sizes contains an array of all page sizes supported by the system. The default page size entry is index 0, and the default huge page size is index 1.

OFI_PAGE_SIZE is not a portable name for PAGE_SIZE.

Some arch like riscv does not have a standard defined PAGE_SIZE in sys/user.h.

Signed-off-by: Zhuo Zhi <[email protected]>
@Xeonacid
Copy link
Author

OFI_PAGE_SIZE is an index, which is why you need to use page_sizes[OFI_PAGE_SIZE]. page_sizes contains an array of all page sizes supported by the system. The default page size entry is index 0, and the default huge page size is index 1.

OFI_PAGE_SIZE is not a portable name for PAGE_SIZE.

Thank you for the clarification, updated.

@charlesshereda
Copy link
Contributor

This looks fine to Ben and me now.

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

Successfully merging this pull request may close these issues.

5 participants