Skip to content

Port hotspot/os/bsd/os_perf_bsd.cpp to BSD - #9

Open
snake66 wants to merge 3 commits into
openjdk:bsd-portfrom
snake66:bsd-port--os_perf_bsd
Open

Port hotspot/os/bsd/os_perf_bsd.cpp to BSD#9
snake66 wants to merge 3 commits into
openjdk:bsd-portfrom
snake66:bsd-port--os_perf_bsd

Conversation

@snake66

@snake66 snake66 commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Implements CPUPerformanceInterface::CPUPerformance for FreeBSD, OpenBSD and NetBSD. This is essentially a parallel implementation to the macOS implementation in this source file.

This work is sponsored by The FreeBSD Foundation



Progress

  • Change must not contain extraneous whitespace
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/bsd-port.git pull/9/head:pull/9
$ git checkout pull/9

Update a local copy of the PR:
$ git checkout pull/9
$ git pull https://git.openjdk.org/bsd-port.git pull/9/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9

View PR using the GUI difftool:
$ git pr show -t 9

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/bsd-port/pull/9.diff

Using Webrev

Link to Webrev Comment

Implements CPUPerformanceInterface::CPUPerformance for FreeBSD, OpenBSD
and NetBSD. This is essentially a parallel implementation to the macOS
implementation in this source file.

This work is sponsored by The FreeBSD Foundation

Co-authored-by: Kurt Miller <kurt@openjdk.org>
Co-authored-by: Greg Lewis <glewis@openjdk.org>
@bridgekeeper

bridgekeeper Bot commented May 5, 2026

Copy link
Copy Markdown

👋 Welcome back haraldei! A progress list of the required criteria for merging this PR into bsd-port will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented May 5, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added the rfr Pull request is ready for review label May 5, 2026
@mlbridge

mlbridge Bot commented May 5, 2026

Copy link
Copy Markdown

Webrevs

@dean-long

Copy link
Copy Markdown
Member

Is it really necessary to have a full parallel implementation? I would expect a large part to be sharable between bsd variants.

@snake66

snake66 commented May 8, 2026

Copy link
Copy Markdown
Collaborator Author

@dean-long I don't see much overlap between the macOS and *BSD implementations. The macOS code seems to be targeted for the Mach kernel, which is not used by any of the others. To be fair, there's enough differences even among the traditional *BSD's that this code will be quite hairy regardless of how we approach it.

@dholmes-ora dholmes-ora left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is certainly complex with all the conditionals. I can't help wonder if we wouldn't better off splitting some things out into separate per-BSD files.

#define NET_RT_IFLIST2 NET_RT_IFLIST
#define RTM_IFINFO2 RTM_IFINFO
#endif
#ifdef __NetBSD__

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why a simple ifdef here but a if !defined above? Can we use one style please.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Probably to align with the #ifdef __APPLE__ above, but I've cleaned up this section in the new version of the patch so it's hopefully better now.

Comment thread src/hotspot/os/bsd/os_perf_bsd.cpp Outdated
Comment on lines 853 to 855
#if !defined(KERN_PROC_PATHNAME)
#define KERN_PROC_PATHNAME 5
#endif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this be handled where we do the #include?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ack, moved it up in the new version of the patch.

Comment thread src/hotspot/os/bsd/os_perf_bsd.cpp Outdated
Comment on lines +44 to +55
static const double NANOS_PER_SEC = 1000000000.0;
static const time_t NANOS_PER_SEC = 1000000000LL;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand this change when most use-sites cast back to double anyway - and the one that doesn't should have been casting to an integral type in the first place.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's used once as each, but I agree, there's no reason to change this. I've reverted this and added the cast to uint64_t where it's being used as such.

- Clean up #include section
- Revert NANOS_PER_SEC back to a double
- Move NetBSD def of KERN_PROC_PATHNAME to #include section

This work is sponsored by The FreeBSD Foundation
@snake66

snake66 commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

This is certainly complex with all the conditionals. I can't help wonder if we wouldn't better off splitting some things out into separate per-BSD files.

I would actually really like it if we could split this up instead. We have just tried to adapt to the structure that was already there, but if it's ok with you I'll be happy to work out a suggestion for a patch where we split it up instead.

If it's ok, I would also like to split the different interface implementations (CPUPerformance, SystemProcess and NetworkPerformance) into separate source files as well. Will be many files then :)

@dholmes-ora

Copy link
Copy Markdown
Member

Will be many files then :)

Lets try to not to go overboard with too fine-grained an approach. We also need to allow sharing where possible.

Just in terms of the bigger picture, I am a bit concerned about all the different kinds of BSD being supported here. From a "supported port" perspective there needs to be a maintainer willing to take on all aspects of this.

@snake66

snake66 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Lets try to not to go overboard with too fine-grained an approach. We also need to allow sharing where possible.

That makes sense. I'll try to split the BSD and macOS implementations, and then we can see from there.

Just in terms of the bigger picture, I am a bit concerned about all the different kinds of BSD being supported here. From a "supported port" perspective there needs to be a maintainer willing to take on all aspects of this.

I'm aware. As my work is supported by the FreeBSD Foundation, I can only commit to support for FreeBSD. @bsdkurt and @battleblow may be able to say more about OpenBSD and NetBSD.

@bsdkurt

bsdkurt commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Just in terms of the bigger picture, I am a bit concerned about all the different kinds of BSD being supported here. From a "supported port" perspective there needs to be a maintainer willing to take on all aspects of this.

I'm aware. As my work is supported by the FreeBSD Foundation, I can only commit to support for FreeBSD. @bsdkurt and @battleblow may be able to say more about OpenBSD and NetBSD.

I'm happy to continue to maintain OpenBSD's portion of the bsd-port. I've been doing that for around 25 years now on a volunteer basis (except for some consulting work I did for the FreeBSD foundation's prior work at certification). NetBSD has not had a consistent developer engaged with the project over those years, but we've (Greg and myself) always tried to maintain support for it along the way.

@mlbridge

mlbridge Bot commented Jun 1, 2026

Copy link
Copy Markdown

Mailing list message from Christos Zoulas on bsd-port-dev:

On Jun 1, 2026, at 8:05 AM, Kurt Miller <kurt@openjdk.org> wrote:

On Mon, 1 Jun 2026 08:14:34 GMT, Harald Eilertsen <haraldei@openjdk.org> wrote:

Just in terms of the bigger picture, I am a bit concerned about all the different kinds of BSD being supported here. From a "supported port" perspective there needs to be a maintainer willing to take on all aspects of this.

I'm aware. As my work is supported by the FreeBSD Foundation, I can only commit to support for FreeBSD. @bsdkurt and @battleblow may be able to say more about OpenBSD and NetBSD.

I'm happy to continue to maintain OpenBSD's portion of the bsd-port. I've been doing that for around 25 years now on a volunteer basis (except for some consulting work I did for the FreeBSD foundation's prior work at certification). NetBSD has not had a consistent developer engaged with the project over those years, but we've (Greg and myself) always tried to maintain support for it along the way.

Thanks Kurt, I am around and I can try to help if needed for NetBSD.

christos

@mlbridge

mlbridge Bot commented Jun 1, 2026

Copy link
Copy Markdown

Mailing list message from Stephanie Bergmann on bsd-port-dev:

OptOut!

Stephanie Bergmann

Christos Zoulas <christos@zoulas.com> schrieb am Mo., 1. Juni 2026, 15:37:

On Jun 1, 2026, at 8:05 AM, Kurt Miller <kurt@openjdk.org> wrote:

On Mon, 1 Jun 2026 08:14:34 GMT, Harald Eilertsen <haraldei@openjdk.org>
wrote:

Just in terms of the bigger picture, I am a bit concerned about all
the different kinds of BSD being supported here. From a "supported port"
perspective there needs to be a maintainer willing to take on all aspects
of this.

I'm aware. As my work is supported by the FreeBSD Foundation, I can
only commit to support for FreeBSD. @bsdkurt and @battleblow may be able to
say more about OpenBSD and NetBSD.

I'm happy to continue to maintain OpenBSD's portion of the bsd-port.
I've been doing that for around 25 years now on a volunteer basis (except
for some consulting work I did for the FreeBSD foundation's prior work at
certification). NetBSD has not had a consistent developer engaged with the
project over those years, but we've (Greg and myself) always tried to
maintain support for it along the way.

Thanks Kurt, I am around and I can try to help if needed for NetBSD.

christos

@bridgekeeper

bridgekeeper Bot commented Jun 29, 2026

Copy link
Copy Markdown

@snake66 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

Split implementation into separate source files for macOS and BSD where
necessary, and consolidate the code that's common between them into a
common source.

- Split CPUPerformanceInterface impl for BSD and macOS, but keep the
  common PIMPL wrapper class.
- Move SystemProcessInterface::SystemProcess to common code, implement
  functions to imitate relevant macOS proc.h function for the BSD's.
- Drop retreiving process args for FreeBSD and NetBSD for now, this was
  not implemented for macOS or OpenBSD in any case. Can add it back
  later if it has value.
- Move NetworkPerformanceInterface::NetworkPerformance to common code.
  Only minor adjustments via conditional sections between macOS and BSD
  implementation.

This work is sponsored by The FreeBSD Foundation

Co-authored-by: Kurt Miller <bsdkurt@gmail.com>
Co-authored-by: Greg Lewis <glewis@eyesbeyond.com>
@bridgekeeper

bridgekeeper Bot commented Aug 7, 2026

Copy link
Copy Markdown

@snake66 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

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

Labels

rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

4 participants