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

PREEMPT_RT support for EVE #3254

Merged
merged 8 commits into from
Jun 6, 2023
Merged

PREEMPT_RT support for EVE #3254

merged 8 commits into from
Jun 6, 2023

Conversation

rouming
Copy link
Contributor

@rouming rouming commented May 31, 2023

This PR introduces the PREEMPT_RT support for the main EVE kernel (pkg/kernel) for the x86_64 architecture by

  1. Bumping up the minor version of the main kernel to the 5.1.131 to be aligned with PREEMPT_RT patches.

  2. Adding the official patch-5.10.131-rt72.patch.gz set of patches.

  3. Adding the patch which does not export the migrate_enable() and migrate_disable() kernel calls as GPL. OpenZFS is not GPL but uses those calls. Before the PREEMPT_RT patches those two calls were declared as "static inline" in the header, thus no export was needed.

  4. Once the 'make pkg/kernel PREEMPT_RT=1' is specified the PREEMPT_RT kernel flavour is built in the 'eve-rt-kernel' docker image.

  5. To build a live image with the PREEMPT_RT kernel call as the following: 'make live PREEMPT_RT=1'. The same applies for the installer images, e.g.: 'make installer-iso PREEMPT_RT=1'.

The PR is quite conservative and introduces a new kernel flavor which can be enabled on demand, so that by default other functionality is not touched.

This PR targets only amd64, since PREEMPT_RT scheduler can't be enabled on arm64 along with the KVM support (what a bummer).

There are a few changes in Dockerfile (recent security improvements) and kernel-build-yml.sh script, so @shjala please take a look.

@rouming rouming requested review from eriknordmark and rvs as code owners May 31, 2023 16:14
@rouming rouming force-pushed the preempt-rt-eve branch 3 times, most recently from 4bc287f to c87aa23 Compare June 1, 2023 07:20
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_SLUB_MEMCG_SYSFS_ON is not set
# CONFIG_COMPAT_BRK is not set
-CONFIG_SLAB=y
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't notice we were using SLAB before.... but I guess you are changing to SLUB only for improvements, right?

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 the default, comes with the preemt_rt. I left untouched.

# end of Scheduler Debugging

# CONFIG_DEBUG_TIMEKEEPING is not set
+CONFIG_DEBUG_PREEMPT=y
Copy link
Contributor

Choose a reason for hiding this comment

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

Enable DEBUG here will increase overhead and affect the performance, I don't think we should enabled by default...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left as is intentionally. Want to catch any complains from kernel if preempted in unsafe way. Want to see the whole virtualization stack in action. Will disable later.

preempt_lazy_disable();
preempt_enable();
}
-EXPORT_SYMBOL_GPL(migrate_disable);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change was not needed before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before those methods were declared as static inline in the header, so no export beeded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

*needed

@rouming rouming force-pushed the preempt-rt-eve branch 2 times, most recently from 0ae507e to e2ae120 Compare June 1, 2023 09:37
Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

LGTM.
Should we do a separate PR which applies this to new-kernel as well?

Makefile Outdated Show resolved Hide resolved
@rouming
Copy link
Contributor Author

rouming commented Jun 1, 2023

Should we do a separate PR which applies this to new-kernel as well?

@eriknordmark Frankly I don't want to bother with a new kernel now, because it is used for risc only and the future of the whole new-kernel is not clear: do we drop it and switch the main kernel to a 5.15?

Update: or better to invest time and unify both Dockerfile and do the same trick with building a 5.15 on demand by 'KERNEL=5.15' make argument?

@eriknordmark
Copy link
Contributor

Should we do a separate PR which applies this to new-kernel as well?

@eriknordmark Frankly I don't want to bother with a new kernel now, because it is used for risc only and the future of the whole new-kernel is not clear: do we drop it and switch the main kernel to a 5.15?

Over the next few months we should update the kernel. But if we keep them in synch that can be done by "rm -rf kernel; mv new-kernel kernel; mkdir new-kernel; // fill new-kernel with next kernel LTS"

Don't know if it is worth the effort to keep them in synch for that reason.
@rene any thoughts on this?

Update: or better to invest time and unify both Dockerfile and do the same trick with building a 5.15 on demand by 'KERNEL=5.15' make argument?

Probably not worth while if we are going to externalize the kernel build from the repo.

@rouming
Copy link
Contributor Author

rouming commented Jun 1, 2023

Probably not worth while if we are going to externalize the kernel build from the repo.

This does not eliminate the dockerfile and all the efforts to keep both in sync, we just skip the step of downloading the kernel sources and applying patches. Other than that stays the same.

rouming added 3 commits June 2, 2023 12:52
…0.131

In the next patches I introduce the preempt-rt patches, which
can be applied without conflicts on the nearest stable 131 version.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
Parlez-vous francais? Ich auch.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
kernel-yml:
$(QUIET)if [ ! -f "pkg/kernel/build.yml" ] || [ ! -f "pkg/new-kernel/build.yml" ]; then tools/kernel-build-yml.sh; fi

$(QUIET)$(KERNEL_BUILD_YML_TOOL)
Copy link
Member

Choose a reason for hiding this comment

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

Do I get it right, that now kernel-yml will always be quiet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems nothing has been changed, QUIET was always there.

Copy link
Member

Choose a reason for hiding this comment

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

I guess I like python more than bash :D But nevertheless, you are removing check if pkg/kernel/build.yml and pkg/new-kernel/build.yml files exist and instead we always put tools/kernel-build-yml.sh with PREEMT_RT variable. Why do we skip it now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The commit message should tell the whole story: e66a85a
What's probably is missing in the description is the following line: "We need to generate the build.yml each time to reflect the changes in the PREEMPT_RT_SUPPORT build argument"

@uncleDecart
Copy link
Member

@rouming you say this PR targets only amd64, do we need to include some checks that PREEMT_RT will not build for arm or did I miss them?

@rouming
Copy link
Contributor Author

rouming commented Jun 2, 2023

@rouming you say this PR targets only amd64, do we need to include some checks that PREEMT_RT will not build for arm or did I miss them?

The config for other arches is missing, so no worries, you get an error :)

@rouming
Copy link
Contributor Author

rouming commented Jun 2, 2023

Difference to the previous version:

  • s/PREEMPT_RT_SUPPORT/PREEMPT_RT_SUPPORT_ARG/ in the Makefile

rouming added 4 commits June 2, 2023 13:29
Tidy up how we call the kernel-build-yml.sh.

Also don't check the existence of generated files and
re-generate them unconditionally to reflect possible
changes of the PREEMPT_RT_SUPPORT build argument.

Re-generated build.yml files should not differ in other
build arguments, which are passed for making reproducible
kernel builds.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
…RT kernel

Generate build.yml with the "eve-rt-kernel" image and PREEMPT_RT_SUPPORT build
args set to true. In the future patches the Dockerfile will be modified to
support the PREEMPT_RT flavour of the kernel.

To build the "eve-rt-kernel" the following has to be called:

   make pkg/kernel PREEMPT_RT=1

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
No functional change, just tidy the dockerfile up and make
the procedure of keys copy before actual patches applying
and building.

This is needed for the next patches, which introduce the
PREEMPT_RT patching.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
This patch introduces the PREEMPT_RT support for the main EVE kernel for the
x86_64 architecture by:

1. Adding the official `patch-5.10.131-rt72.patch.gz` set of patches

2. Adding the patch which does not export the migrate_enable() and
   migrate_disable() kernel calls as GPL. OpenZFS is not GPL but uses
   those calls.

3. Once the 'make pkg/kernel PREEMPT_RT=1' is specified the PREEMPT_RT
   kernel flavour is built in the 'eve-rt-kernel' docker image.

4. To build a live image with the PREEMPT_RT kernel call as the following:
   'make live PREEMPT_RT=1'. The same applies for the installer images, e.g.:
   'make installer-iso PREEMPT_RT=1'

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
@rouming
Copy link
Contributor Author

rouming commented Jun 2, 2023

Difference to the previous version:

  • Just commit message tweaks

@rouming
Copy link
Contributor Author

rouming commented Jun 2, 2023

I pay 5 euro for approval. Offer is valid today only.

@rene
Copy link
Contributor

rene commented Jun 2, 2023

Should we do a separate PR which applies this to new-kernel as well?

@eriknordmark Frankly I don't want to bother with a new kernel now, because it is used for risc only and the future of the whole new-kernel is not clear: do we drop it and switch the main kernel to a 5.15?

Over the next few months we should update the kernel. But if we keep them in synch that can be done by "rm -rf kernel; mv new-kernel kernel; mkdir new-kernel; // fill new-kernel with next kernel LTS"

Don't know if it is worth the effort to keep them in synch for that reason. @rene any thoughts on this?

Update: or better to invest time and unify both Dockerfile and do the same trick with building a 5.15 on demand by 'KERNEL=5.15' make argument?

Probably not worth while if we are going to externalize the kernel build from the repo.

They are not in that sync anyways, I don't think is worth to introduce all these change in new-kernel right now....

preempt_enable();
}
-EXPORT_SYMBOL_GPL(migrate_disable);
+EXPORT_SYMBOL(migrate_disable);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that from a law/license point of view this is allowed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Until we don't ship the product - why not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or even we ship the product

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth to ask a lawyer ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this raises questions I can drop the compilation of the openzfs for preempt_rt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eriknordmark interesting question from Christoph

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to understand why in the RT case you need to export migrate_{enabled,disabled} to ZFS, but that is not needed in the non-RT case. Are there some RT patches to the zfs module?

Copy link
Contributor Author

@rouming rouming Jun 6, 2023

Choose a reason for hiding this comment

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

Before the PREEMPT_RT patches the "migrate_{enabled,disbled}" calls were defined as "static inline" in the header file (defined and declared!), so basically ANY driver with ANY license can use these API calls.

With the PREEMPT_RT patches those two calls were moved and defined in a sched/core.c. Since this is a public API, the exporting should be done. Authors of the PREEMPT_RT exported those two calls as GPL (basically limiting to only GPL users), so any driver which announce itself as non-GPL is not able to be linked with those two calls (since they are GPL).

I removed GPL export suffix to let the openzfs use those calls. If we think, this is dangerous etc, then I will remove a patch and exclude openzfs from compilation for the PREEMPT_RT case.

But frankly, this is pure debug feature. Who cares?

Copy link
Contributor

@mikem-zed mikem-zed left a comment

Choose a reason for hiding this comment

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

LGTM after the issue with docker tag is resolved

Just a line, which exposes the possibility to build PREEMPT_RT EVE
for x86_64 only.

   make pkg/kernel PREEMPT_RT=1
   make live PREEMPT_RT=1

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
@rouming
Copy link
Contributor Author

rouming commented Jun 2, 2023

Difference to the previous version:

  • Docs tweaks

@shjala
Copy link
Member

shjala commented Jun 5, 2023

LGTM

Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

LGTM

@rouming rouming merged commit a9777ef into lf-edge:master Jun 6, 2023
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.

7 participants