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

Backport-of: bb2e10ccea0c0b89b06ace034c99253e9999ec47
  • Loading branch information
MBaesken committed Mar 23, 2022
1 parent d6eb281 commit d442446
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 @@ -2253,7 +2253,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

1 comment on commit d442446

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.