Skip to content

8291945: Add OSInfo API for static OS information#9758

Closed
iklam wants to merge 5 commits intoopenjdk:masterfrom
iklam:8291945-add-OSInfo-api
Closed

8291945: Add OSInfo API for static OS information#9758
iklam wants to merge 5 commits intoopenjdk:masterfrom
iklam:8291945-add-OSInfo-api

Conversation

@iklam
Copy link
Member

@iklam iklam commented Aug 4, 2022

As suggested by @tstuefe in the review of #9600, many of the os APIs simply return a value that was initialized during VM start up. E.g., os::vm_page_size(). I have added a new class OSInfo for managing such info

  • Simplifies the per-OS implementation
  • Make the "init-only-once" check consistent
  • In some cases, the simpler OSInfo class can be used in lieu of the more complex os class. This improves HotSpot build time (e.g., relocInfo.hpp).

Note: I moved only 2 fields in this PR as a first step. If this works well I plan to move more fields in the future.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8291945: Add OSInfo API for static OS information

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9758/head:pull/9758
$ git checkout pull/9758

Update a local copy of the PR:
$ git checkout pull/9758
$ git pull https://git.openjdk.org/jdk pull/9758/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9758

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9758.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 4, 2022

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

@openjdk
Copy link

openjdk bot commented Aug 4, 2022

@iklam The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Aug 4, 2022
@iklam iklam marked this pull request as ready for review August 5, 2022 03:38
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 5, 2022
@mlbridge
Copy link

mlbridge bot commented Aug 5, 2022

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Seems reasonable, but I initially expected to see the os:: API removed and replaced by the OSInfo:: API, rather than OSInfo just being an internal implementation detail.

#include "memory/allStatic.hpp"
#include "utilities/debug.hpp"

// Static information about the operation system. Initialized exactly once
Copy link
Member

Choose a reason for hiding this comment

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

s/operation/operating

#include "runtime/handles.hpp"

class BasicLock;
class frame;
Copy link
Member

Choose a reason for hiding this comment

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

Seems unrelated to this change. ?/

Copy link
Member Author

Choose a reason for hiding this comment

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

This file was indirectly including frame.hpp via os.hpp. Since I removed os.hpp from this file, I needed to add a declaration for the frame class.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any such removal in this file. ??

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I was mistaken. What I did was removing os.hpp from relocInfo.hpp and safepointMechanismhpp. This exposed the fact that stackValue.hpp was using the frame class without a proper declaration.

@iklam
Copy link
Member Author

iklam commented Aug 5, 2022

Seems reasonable, but I initially expected to see the os:: API removed and replaced by the OSInfo:: API, rather than OSInfo just being an internal implementation detail.

I left os::vm_page_size() because:

  • It's used by a lot of places. I don't want this PR to be overwhelmed by such changes.
  • os::vm_page_size() is often used together with other os::xxx functions related to memory allocation.

So at this point, OSInfo is a just lower-level API if you just want to find out the value of some OS parameters. So far I've used it in two popular headers to avoid including os.hpp

@dholmes-ora
Copy link
Member

Okay I think it would be good to switch to the OSInfo API in the future, so that we reduce the scope of os even further and more clearly delineate an API to request services from the OS, and a simple query API for the OS.

@openjdk
Copy link

openjdk bot commented Aug 5, 2022

@iklam This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8291945: Add OSInfo API for static OS information

Reviewed-by: dholmes, stuefe

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 5, 2022
Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

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

Looks good!

Cheers, Thomas

// Returns the byte size of a virtual memory page
static int vm_page_size() { return _vm_page_size; }

// Returns the size in bytes of memory blocks which can be allocated.
Copy link
Member

Choose a reason for hiding this comment

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

Too vague and a bit misleading. Proposal:

Returns size, in bytes, of the granularity with which memory can be reserved using os::reserve_memory().

@iklam
Copy link
Member Author

iklam commented Aug 11, 2022

Thanks @dholmes-ora and @tstuefe for the review.
/integrate

@openjdk
Copy link

openjdk bot commented Aug 11, 2022

Going to push as commit 9bfffa0.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 11, 2022
@openjdk openjdk bot closed this Aug 11, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 11, 2022
@openjdk
Copy link

openjdk bot commented Aug 11, 2022

@iklam Pushed as commit 9bfffa0.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Labels

hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants