Skip to content

os::get_process_uid and os::rss for BSD - #11

Open
snake66 wants to merge 7 commits into
openjdk:bsd-portfrom
snake66:bsd-port--os-process-uid
Open

os::get_process_uid and os::rss for BSD#11
snake66 wants to merge 7 commits into
openjdk:bsd-portfrom
snake66:bsd-port--os-process-uid

Conversation

@snake66

@snake66 snake66 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Port of os::get_process_uid() and os::rss() to BSD.

Also makes sure relevant platform dependent includes are only included where supported.

This work is sponsored by The FreeBSD Foundation



Progress

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

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11

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

Using diff file

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

Using Webrev

Link to Webrev Comment

snake66 and others added 3 commits June 18, 2026 13:16
This work is sponsored by The FreeBSD Foundation

Co-authored-by: Kurt Miller <bsdkurt@gmail.com>
Co-authored-by: Greg Lewis <glewis@eyesbeyond.com>
* Add BSD support for RSS process size.  This probably needs a tweak
  for OpenBSD and NetBSD
* Sync with Linux
@bridgekeeper

bridgekeeper Bot commented Jun 18, 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 Jun 18, 2026

Copy link
Copy Markdown

@snake66 This change is no longer ready for integration - check the PR body for details.

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

mlbridge Bot commented Jun 18, 2026

Copy link
Copy Markdown

Webrevs

This work is sponsored by The FreeBSD Foundation

@bsdkurt bsdkurt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This approach seems like a reasonable way to support Apple/FreeBSD/OpenBSD/NetBSD in these functions. The alternative would be less readable.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Jun 30, 2026
@bsdkurt

bsdkurt commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

/reviewers 2

@openjdk

openjdk Bot commented Jun 30, 2026

Copy link
Copy Markdown

@bsdkurt Only the author of the pull request or Reviewers are allowed to change the number of required reviewers.

@bsdkurt

bsdkurt commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

@snake66 Harald, could you bump the reviewers to 2? We want an Oracle dev to review as well and I guess as a committer, I can't issue the command.

@snake66

snake66 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

/reviewers 2

@openjdk

openjdk Bot commented Jun 30, 2026

Copy link
Copy Markdown

@snake66
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Committer, 1 Author).

@openjdk openjdk Bot removed the ready Pull request is ready to be integrated label Jun 30, 2026
@dholmes-ora

Copy link
Copy Markdown
Member

I'm afraid you are very unlikely to get an Oracle reviewer for this at this time.

@snake66

snake66 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

@dholmes-ora Ok, what do you suggest? Just wait for less busy times, or is there a fundamental problem?

@tstuefe tstuefe 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.

Preface:

  • you really should consider splitting bsd from apple in hotspot
  • I'd consider adding utility features for BSD, eg BSD_ONLY/NOT_BSD (see examples in macros.hpp) and maybe also for the variants eg FREEBSD_ONLY/NOT_FREEBSD.

Comment thread src/hotspot/os/bsd/os_bsd.cpp Outdated
#else
u_int namelen = 4;
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
#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.

Make namelen const, move it out of the ifdefs, and calculated it based on the array like this

const int namelen = sizeof(mib)/sizeof(mib[0]);

also mib can probably be constexpr as well.

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.

Updated, but a few comments:

I could not use the NOT_FREEBSD() macro as it would require it to be a variadic macro. That works and is doable, but since the other similar macros are not variadic, I though it best to keep to the same pattern. Still reduced to a single conditional using plain #ifndef makes the code nicer I think.

mib can not be constexpr since it contains the pid which is by definition not const :)

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.

haha right, sorry, my bad

Comment thread src/hotspot/os/bsd/os_bsd.cpp Outdated
#else
pid_t pid = getpid();
struct KINFO_PROC_T kp;
size_t bufSize = sizeof kp;

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.

we use brackets with sizeof

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.

Fixed in latest commit.

#define KI_RSS p_vm_rssize
#define KI_UID p_uid
#define KI_PID p_pid
#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.

This is an eyesore. Can this be shortened, and/or moved into a helper include?

@dholmes-ora

Copy link
Copy Markdown
Member

@dholmes-ora Ok, what do you suggest? Just wait for less busy times, or is there a fundamental problem?

Less busy time may help (JEP-401 and JEP-539 are our priority on VM side right now) and we also have a lot of folk on summer vacations. Not many people with experience across different BSD flavors either (I don't have it).

@snake66

snake66 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@tstuefe Thanks a lot for the feedback!

Preface:

  • you really should consider splitting bsd from apple in hotspot

That would be our preference too. But I think we need to have someone from the apple side join us in that effort.

From our perspective, I think it would be fine if everything that is under "bsd" now is renamed/moved to "macos" or something, and then we'll deal with the fallout on our side.

  • I'd consider adding utility features for BSD, eg BSD_ONLY/NOT_BSD (see examples in macros.hpp) and maybe also for the variants eg FREEBSD_ONLY/NOT_FREEBSD.

Yeah that's a good point. I'll see what that will do for the code.

@snake66

snake66 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@dholmes-ora Yeah, I see those JEP's are quite involved, and touches a lot of code! And no worries, we'll wait for our time.

@tstuefe

tstuefe commented Jul 2, 2026

Copy link
Copy Markdown
Member

@tstuefe Thanks a lot for the feedback!

Preface:

  • you really should consider splitting bsd from apple in hotspot

That would be our preference too. But I think we need to have someone from the apple side join us in that effort.

Why? Just do it :-) The code for MacOS would not be affected, and we'd be less worried that a change in BSD accidentally breaks MacOS.

From our perspective, I think it would be fine if everything that is under "bsd" now is renamed/moved to "macos" or something, and then we'll deal with the fallout on our side.

Sure. os/macos would be the obvious choice.

@snake66

snake66 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Why? Just do it :-)

Ok! I'll go for it, and see how it's received :)

Redused the amount of conditional sections to only concern the part of
the mib that is different between the platforms.

This work is sponsored by The FreeBSD Foundation

@tstuefe tstuefe 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.

looks good to me

This work is sponsored by The FreeBSD Foundation
@snake66

snake66 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

Since I need one more review anyways, I thought I'd just as well submit another related refactoring to these functions.

@snake66

snake66 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

That didn't seem too successfull... I'll have a look at it tomorrow.

This work is sponsored by The FreeBSD Foundation
Comment thread src/hotspot/os/bsd/os_bsd.cpp
@bsdkurt
bsdkurt self-requested a review July 8, 2026 13:04

@bsdkurt bsdkurt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@snake66
snake66 requested a review from tstuefe July 10, 2026 06:11
@bridgekeeper

bridgekeeper Bot commented Aug 10, 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.

5 participants