Skip to content

Commit

Permalink
8235931: add OM_CACHE_LINE_SIZE and use smaller size on SPARCv9 and X64
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, redestad, mdoerr
  • Loading branch information
Daniel D. Daugherty committed Feb 5, 2020
1 parent e7e182a commit b9e3a4e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/hotspot/cpu/sparc/globalDefinitions_sparc.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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 @@ -42,12 +42,14 @@ const bool CCallingConventionRequiresIntsAsLongs = true;
#if defined(TIERED)
// tiered, 64-bit, large machine
#define DEFAULT_CACHE_LINE_SIZE 128
#define OM_CACHE_LINE_SIZE 64
#elif defined(COMPILER1)
// pure C1, 32-bit, small machine
#define DEFAULT_CACHE_LINE_SIZE 16
#elif defined(COMPILER2)
// pure C2, 64-bit, large machine
#define DEFAULT_CACHE_LINE_SIZE 128
#define OM_CACHE_LINE_SIZE 64
#endif

#if defined(SOLARIS)
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/x86/globalDefinitions_x86.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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 @@ -40,6 +40,7 @@ const bool CCallingConventionRequiresIntsAsLongs = false;
#ifdef _LP64
// tiered, 64-bit, large machine
#define DEFAULT_CACHE_LINE_SIZE 128
#define OM_CACHE_LINE_SIZE 64
#else
// tiered, 32-bit, medium machine
#define DEFAULT_CACHE_LINE_SIZE 64
Expand All @@ -52,6 +53,7 @@ const bool CCallingConventionRequiresIntsAsLongs = false;
#ifdef _LP64
// pure C2, 64-bit, large machine
#define DEFAULT_CACHE_LINE_SIZE 128
#define OM_CACHE_LINE_SIZE 64
#else
// pure C2, 32-bit, medium machine
#define DEFAULT_CACHE_LINE_SIZE 64
Expand Down
10 changes: 8 additions & 2 deletions src/hotspot/share/runtime/objectMonitor.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, 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 @@ -120,6 +120,12 @@ class ObjectWaiter : public StackObj {
// intptr_t. There's no reason to use a 64-bit type for this field
// in a 64-bit JVM.

#ifndef OM_CACHE_LINE_SIZE
// Use DEFAULT_CACHE_LINE_SIZE if not already specified for
// the current build platform.
#define OM_CACHE_LINE_SIZE DEFAULT_CACHE_LINE_SIZE
#endif

class ObjectMonitor {
friend class ObjectSynchronizer;
friend class ObjectWaiter;
Expand All @@ -139,7 +145,7 @@ class ObjectMonitor {
// _object is a good choice to share the cache line with _header.
// _next_om shares _header's cache line for pre-monitor list historical
// reasons. _next_om only changes if the next ObjectMonitor is deflated.
DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE,
DEFINE_PAD_MINUS_SIZE(0, OM_CACHE_LINE_SIZE,
sizeof(volatile markWord) + sizeof(void* volatile) +
sizeof(ObjectMonitor *));
void* volatile _owner; // pointer to owning thread OR BasicLock
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/runtime/synchronizer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, 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 @@ -517,15 +517,15 @@ void ObjectSynchronizer::notifyall(Handle obj, TRAPS) {
// performed by the CPU(s) or platform.

struct SharedGlobals {
char _pad_prefix[DEFAULT_CACHE_LINE_SIZE];
char _pad_prefix[OM_CACHE_LINE_SIZE];
// These are highly shared mostly-read variables.
// To avoid false-sharing they need to be the sole occupants of a cache line.
volatile int stw_random;
volatile int stw_cycle;
DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile int) * 2);
DEFINE_PAD_MINUS_SIZE(1, OM_CACHE_LINE_SIZE, sizeof(volatile int) * 2);
// Hot RW variable -- Sequester to avoid false-sharing
volatile int hc_sequence;
DEFINE_PAD_MINUS_SIZE(2, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile int));
DEFINE_PAD_MINUS_SIZE(2, OM_CACHE_LINE_SIZE, sizeof(volatile int));
};

static SharedGlobals GVars;
Expand Down Expand Up @@ -1082,9 +1082,9 @@ ObjectMonitor* ObjectSynchronizer::om_alloc(Thread* self) {
assert(_BLOCKSIZE > 1, "invariant");
size_t neededsize = sizeof(PaddedObjectMonitor) * _BLOCKSIZE;
PaddedObjectMonitor* temp;
size_t aligned_size = neededsize + (DEFAULT_CACHE_LINE_SIZE - 1);
size_t aligned_size = neededsize + (OM_CACHE_LINE_SIZE - 1);
void* real_malloc_addr = NEW_C_HEAP_ARRAY(char, aligned_size, mtInternal);
temp = (PaddedObjectMonitor*)align_up(real_malloc_addr, DEFAULT_CACHE_LINE_SIZE);
temp = (PaddedObjectMonitor*)align_up(real_malloc_addr, OM_CACHE_LINE_SIZE);
(void)memset((void *) temp, 0, neededsize);

// Format the block.
Expand Down
10 changes: 8 additions & 2 deletions src/hotspot/share/runtime/synchronizer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, 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 @@ -34,7 +34,13 @@
class ObjectMonitor;
class ThreadsList;

typedef PaddedEnd<ObjectMonitor, DEFAULT_CACHE_LINE_SIZE> PaddedObjectMonitor;
#ifndef OM_CACHE_LINE_SIZE
// Use DEFAULT_CACHE_LINE_SIZE if not already specified for
// the current build platform.
#define OM_CACHE_LINE_SIZE DEFAULT_CACHE_LINE_SIZE
#endif

typedef PaddedEnd<ObjectMonitor, OM_CACHE_LINE_SIZE> PaddedObjectMonitor;

struct DeflateMonitorCounters {
int n_in_use; // currently associated with objects
Expand Down

0 comments on commit b9e3a4e

Please sign in to comment.