Skip to content

!include/arch: use _PAGE_SIZE definition from p-r-kernel#486

Merged
oI0ck merged 3 commits into
masterfrom
michal.lach/page_shift
Jun 30, 2026
Merged

!include/arch: use _PAGE_SIZE definition from p-r-kernel#486
oI0ck merged 3 commits into
masterfrom
michal.lach/page_shift

Conversation

@oI0ck

@oI0ck oI0ck commented Jun 22, 2026

Copy link
Copy Markdown
Member

JIRA: RTOS-1358

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: aarch64a53-zynqmp-qemu.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

@oI0ck oI0ck requested a review from a team June 22, 2026 11:13
Comment thread include/arch/ia32/arch.h Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces _PAGE_SHIFT and defines _PAGE_SIZE using bitwise shifts across various architectures, as well as exposing PAGE_SHIFT in limits.h. However, critical compilation errors were introduced in include/arch/ia32/arch.h and include/arch/riscv64/arch.h due to duplicated and nested macro definitions for SIZE_PAGE during the edits.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread include/arch/ia32/arch.h Outdated
Comment thread include/arch/riscv64/arch.h Outdated
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

Unit Test Results

10 860 tests  ±0   10 190 ✅ ±0   52m 27s ⏱️ - 1m 1s
   670 suites ±0      670 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 32927ca. ± Comparison against base commit 7432e41.

♻️ This comment has been updated with latest results.

@ziemleszcz

Copy link
Copy Markdown
Contributor

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the _PAGE_SHIFT and PAGE_SHIFT macros across various architecture-dependent headers (including aarch64, armv7, armv8, ia32, riscv64, and sparcv8leon) and redefines _PAGE_SIZE using bitwise shifts. Additionally, it updates copyright years and author attributions in the modified files. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@julianuziemblo julianuziemblo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_PAGE_SIZE, PAGE_SIZE, PAGESIZE and SIZE_PAGE are always defined the same way: _PAGE_SIZE = (1 << _PAGE_SHIFT), PAGE_SIZE = _PAGE_SIZE, PAGESIZE = _PAGE_SIZE and SIZE_PAGE = _Pragma(...) _PAGE_SIZE. Maybe we could transfer them to the common limits.h file that includes all those for different architectures? Or is there a reason this is kept separate?

@anglov

anglov commented Jun 22, 2026

Copy link
Copy Markdown
Member

As an author of deprecation message on macro SIZE_PAGE and C/POSIX orthodox I would suggest you to remove SIZE_PAGE macro with deprecation warning altogether - it's deprecated for literally 7 years, and system users had a time to switch to PAGE_SIZE or _PAGE_SIZE.

Exporting PAGE_SHIFT from limits.h is fishy – it's C/POSIX header so you shouldn't export additional macros from there. Maybe just leave _PAGE_SHIFT?

@oI0ck

oI0ck commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

Exporting PAGE_SHIFT from limits.h is fishy – it's C/POSIX header so you shouldn't export additional macros from there. Maybe just leave _PAGE_SHIFT?

Sure, seems sane. <arch.h> is a thing, so there is no need really to export it in <limits.h>

@oI0ck

oI0ck commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

Maybe we could transfer them to the common limits.h file that includes all those for different architectures? Or is there a reason this is kept separate?

I also thought about it, but OTOH, arch/* is very architecture specific. Making it adhere to an external header (by requiring arch/$ARCH/limits.h to define some macros), kind of rubs me the wrong way, even though it would work in most cases.

@oI0ck oI0ck force-pushed the michal.lach/page_shift branch 2 times, most recently from 759b82d to 3af1b44 Compare June 23, 2026 08:29
@oI0ck oI0ck changed the title include/arch: define _PAGE_SHIFT constant macro !include/arch: define _PAGE_SHIFT constant macro Jun 23, 2026
@oI0ck oI0ck requested a review from a team June 23, 2026 09:49
@ziemleszcz

Copy link
Copy Markdown
Contributor

Consider adding PAGE_SHIFT define next to PAGE_SIZE define in arch limits.h headers for compatibility with Linux ports.

Comment thread include/arch/armv7a/arch.h Outdated

#define _PAGE_SIZE 0x1000
#define SIZE_PAGE _Pragma("GCC warning \"'SIZE_PAGE' is deprecated. Use _PAGE_SIZE from arch.h or PAGE_SIZE from limits.h (POSIX only)\"") _PAGE_SIZE
#define _PAGE_SHIFT 12

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider using unsigned values everywhere, as done in the kernel:
#define _PAGE_SHIFT 12U
#define _PAGE_SIZE (1U << _PAGE_SHIFT)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

@oI0ck

oI0ck commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

Exporting PAGE_SHIFT from limits.h is fishy – it's C/POSIX header so you shouldn't export additional macros from there. Maybe just leave _PAGE_SHIFT?

Consider adding PAGE_SHIFT define next to PAGE_SIZE define in arch limits.h headers for compatibility with Linux ports.

Rabini sa niezdecydowani.

@ziemleszcz

Copy link
Copy Markdown
Contributor

I understood that the idea is to use the PAGE_SIZE defined here for ports like JFFS2. JFFS2 also requires PAGE_SHIFT, though. I can agree that both should probably come from the kernel headers instead.

@oI0ck oI0ck force-pushed the michal.lach/page_shift branch 2 times, most recently from dc5cc96 to 0993310 Compare June 29, 2026 09:08
@oI0ck oI0ck force-pushed the michal.lach/page_shift branch 2 times, most recently from f707a88 to eb33f75 Compare June 29, 2026 13:22
oI0ck added 2 commits June 29, 2026 15:38
It has been deprecated some years already and it seems that there are not
many places it is still used in.

Deleted per deprecation message author suggestion.

JIRA: RTOS-1356
This is already defined in <posix/limits.h>

JIRA: RTOS-1358
@oI0ck oI0ck force-pushed the michal.lach/page_shift branch from eb33f75 to d29f889 Compare June 29, 2026 13:38
@oI0ck oI0ck changed the title !include/arch: define _PAGE_SHIFT constant macro !include/arch: use _PAGE_SIZE definition from p-r-kernel Jun 29, 2026
@oI0ck oI0ck requested a review from anglov June 29, 2026 14:10
@oI0ck

oI0ck commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

I moved _PAGE_SIZE and _PAGE_SHIFT to the kernel in p-r-kernel#800. Changed the title and description accordingly.

Also, implemented changes suggested by @julianuziemblo regarding definition dedup.

Comment thread include/arch.h Outdated
@oI0ck oI0ck force-pushed the michal.lach/page_shift branch from d29f889 to 32927ca Compare June 30, 2026 10:20
@oI0ck oI0ck requested a review from julianuziemblo June 30, 2026 10:31

@julianuziemblo julianuziemblo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@oI0ck oI0ck merged commit ca117cf into master Jun 30, 2026
47 checks passed
@oI0ck oI0ck deleted the michal.lach/page_shift branch June 30, 2026 10:53
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.

4 participants