Skip to content

6.3.0 throws exception on AIX from AixCentralProcessor.java:113 #2228

Closed

Description

@mnellemann

Hi,

After upgrading oshi-core from 6.2.2 to 6.3.0 I started getting errors when running on AIX:

java.lang.ArithmeticException: divide by zero
        at oshi.hardware.platform.unix.aix.AixCentralProcessor.initProcessorCounts(AixCentralProcessor.java:113)
        at oshi.hardware.common.AbstractCentralProcessor.<init>(AbstractCentralProcessor.java:65)
        at oshi.hardware.platform.unix.aix.AixCentralProcessor.<init>(AixCentralProcessor.java:38)
        at oshi.hardware.platform.unix.aix.AixHardwareAbstractionLayer.createProcessor(AixHardwareAbstractionLayer.java:55)
        at oshi.util.Memoizer$1.get(Memoizer.java:61)
        at oshi.hardware.common.AbstractHardwareAbstractionLayer.getProcessor(AbstractHardwareAbstractionLayer.java:48)
        at sysmon.plugins.os_base.BaseProcessorExtension.getMetrics(BaseProcessorExtension.java:84)

Call in my code is from BaseProcessorExtension.java:84, which works as expected with 6.2.2.

Code is tested on a Power9 LPAR (VM/Guest) running AIX 7200-05-04-2220.
System configuration: type=Dedicated mode=Capped smt=8 lcpu=8 mem=4096MB

Works fine on Linux - have not tested on any other OS.

Have I missed something important in the release notes?

Activity

  1. mprins commented on Oct 29, 2022

    @mprins
    Member

    that seems to be a regression from #2198 see my comment: https://github.com/oshi/oshi/pull/2198/files#r1008699766

    I think lpPerPp should be a float or double

  2. added
    confirmed bug
    on Oct 29, 2022
  3. dbwiddis commented on Oct 29, 2022

    @dbwiddis
    Member

    I think lpPerPp should be a float or double

    Not really, as it should never be a fraction. The root cause appears to be that not all physical processors were in use, leading to a case where (current) logical processors was less than the (max) physical processors:

    int physProcs = (int) config.numProcessors.max;
    int lcpus = config.lcpus;
    int lpPerPp = lcpus / physProcs;

    where config.numProcessors has these options:

    class perfstat_value_t extends Structure {
        public long online;
        public long max;
        public long min;
        public long desired;
    }

    Quick fix (and should go in anyway) would be ensuring that the lpPerPp value is at least 1, but I'm not sure that's the complete solution. Other options in addition to this:

    • ensure physical processor count is never higher than logical processor count
    • use a different structure element than max to define physical proecessor count (probably online).

    @mnellemann thanks for this bug report, do you have any suggestions on proper counting of physical processors in your particular configuration?

  4. dbwiddis commented on Oct 29, 2022

    @dbwiddis
    Member

    Here's a thread with some potential output.

    I rather identify with this comment:

    Even here, the term 'physical CPU' is misleading.

    But here's a situation that would have resulted in the bug, stripped to what I think is relevant:

    $ lparstat -i
    Type : Shared-SMT
    Entitled Capacity : 27.00
    Online Virtual CPUs : 56
    Maximum Virtual CPUs : 64
    Minimum Virtual CPUs : 1
    Maximum Physical CPUs in system : 64
    Active Physical CPUs in system : 57
    Active CPUs in Pool : 57
    Physical CPU Percentage : 48.21%
    

    This would give OSHI an lp count of 56 on 64 (max) physical processors, so max is wrong, but active would also be wrong. But it's also in a pool that provides an "entitlement" to the user, e.g., they are allotted processing on 27 of the 56 vCPUs (48.21%) although it is labeled "physical CPU percentage" which would imply 27 of 57 (47.37%).

    It gets more complicated when you consider that the logical processor count (and list of LPs) is supposed to align with the per-processor metrics such as CPU ticks. Those are fetched by the perfstat_cpu() function, but the result there is variable:

    This number represents the number of logical processors for which statistics are available. In a dynamic logical partitioning (DLPAR) environment, this number is the highest logical index of an online processor since the last reboot.

    I'm thinking it may be best to just have OSHI report the max number of logical processors. Currently it reports from:

    class perfstat_cpu_total_t extends Structure {
        public int ncpus; // number of active logical processors

    Perhaps it should come from the same structure (and use .max) as the physical processors:

    class perfstat_partition_config_t extends Structure {
        public perfstat_value_t numProcessors; // Number of Configured Physical Processors in frame
        /* Virtual CPU related Configuration */
        public perfstat_value_t vcpus; // Min, Max and Online Virtual CPUs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions