Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8212707

GlobalCounter padding is too optimistic

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 12
    • Fix Version/s: 12
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b17

      Description

      Defined as follows:

      class GlobalCounter : public AllStatic {
       private:
        // Since do not know what we will end up next to in BSS, we make sure the
        // counter is on a seperate cacheline.
        struct PaddedCounter {
          DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE/2, 0);
          volatile uintx _counter;
          DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE/2, sizeof(volatile uintx));
        };

      Why "/2"? Every other use of DEFINE_PAD_MINUS_SIZE macro uses the full cache line size, and it is sensible: you can have two values *at the same cache line* separated by half of its width, unless the whole thing is cache-line-aligned.

      This also sets up for awkward accidents when others copy-paste this padding block as example for padding elsewhere.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rehn Robbin Ehn
              Reporter:
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: