Skip to content

Commit

Permalink
8281274: deal with ActiveProcessorCount in os::Linux::print_container…
Browse files Browse the repository at this point in the history
…_info

Reviewed-by: stuefe, sgehwolf, dholmes, iklam
  • Loading branch information
MBaesken committed Feb 9, 2022
1 parent 69e390a commit bb2e10c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,11 @@ bool os::Linux::print_container_info(outputStream* st) {
int i = OSContainer::active_processor_count();
st->print("active_processor_count: ");
if (i > 0) {
st->print_cr("%d", i);
if (ActiveProcessorCount > 0) {
st->print_cr("%d, but overridden by -XX:ActiveProcessorCount %d", i, ActiveProcessorCount);
} else {
st->print_cr("%d", i);
}
} else {
st->print_cr("not supported");
}
Expand Down
12 changes: 11 additions & 1 deletion test/hotspot/jtreg/containers/docker/TestMisc.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -56,6 +56,7 @@ public static void main(String[] args) throws Exception {
testMinusContainerSupport();
testIsContainerized();
testPrintContainerInfo();
testPrintContainerInfoActiveProcessorCount();
} finally {
DockerTestUtils.removeDockerImage(imageName);
}
Expand Down Expand Up @@ -92,6 +93,15 @@ private static void testPrintContainerInfo() throws Exception {
checkContainerInfo(Common.run(opts));
}

private static void testPrintContainerInfoActiveProcessorCount() throws Exception {
Common.logNewTestCase("Test print_container_info()");

DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo").addJavaOpts("-XX:ActiveProcessorCount=2");
Common.addWhiteBoxOpts(opts);

OutputAnalyzer out = Common.run(opts);
out.shouldContain("but overridden by -XX:ActiveProcessorCount 2");
}

private static void checkContainerInfo(OutputAnalyzer out) throws Exception {
String[] expectedToContain = new String[] {
Expand Down

7 comments on commit bb2e10c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on bb2e10c Mar 22, 2022

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch MBaesken-backport-bb2e10cc in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit bb2e10cc from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 9 Feb 2022 and was reviewed by Thomas Stuefe, Severin Gehwolf, David Holmes and Ioi Lam.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev MBaesken-backport-bb2e10cc:MBaesken-backport-bb2e10cc
$ git checkout MBaesken-backport-bb2e10cc
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev MBaesken-backport-bb2e10cc

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on bb2e10c Apr 11, 2022

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport bb2e10cc to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/hotspot/os/linux/os_linux.cpp
  • test/hotspot/jtreg/containers/docker/TestMisc.java

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk11u-dev:

$ git checkout -b MBaesken-backport-bb2e10cc
$ git fetch --no-tags https://git.openjdk.java.net/jdk bb2e10ccea0c0b89b06ace034c99253e9999ec47
$ git cherry-pick --no-commit bb2e10ccea0c0b89b06ace034c99253e9999ec47
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport bb2e10ccea0c0b89b06ace034c99253e9999ec47'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport bb2e10ccea0c0b89b06ace034c99253e9999ec47.

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on bb2e10c Apr 12, 2022

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport bb2e10cc to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/hotspot/os/linux/os_linux.cpp
  • test/hotspot/jtreg/containers/docker/TestMisc.java

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk11u-dev:

$ git checkout -b MBaesken-backport-bb2e10cc
$ git fetch --no-tags https://git.openjdk.java.net/jdk bb2e10ccea0c0b89b06ace034c99253e9999ec47
$ git cherry-pick --no-commit bb2e10ccea0c0b89b06ace034c99253e9999ec47
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport bb2e10ccea0c0b89b06ace034c99253e9999ec47'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport bb2e10ccea0c0b89b06ace034c99253e9999ec47.

Please sign in to comment.