Skip to content

Commit 3abe798

Browse files
committedSep 14, 2023
8316115: Parallel: Fix -Wconversion warnings around NUMA node ID
Reviewed-by: shade, tschatzl
1 parent 83dca62 commit 3abe798

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed
 

‎src/hotspot/share/gc/parallel/mutableNUMASpace.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ MutableNUMASpace::MutableNUMASpace(size_t alignment) : MutableSpace(alignment),
5454
#endif // LINUX
5555

5656
size_t lgrp_limit = os::numa_get_groups_num();
57-
int *lgrp_ids = NEW_C_HEAP_ARRAY(int, lgrp_limit, mtGC);
58-
int lgrp_num = (int)os::numa_get_leaf_groups(lgrp_ids, lgrp_limit);
57+
uint *lgrp_ids = NEW_C_HEAP_ARRAY(uint, lgrp_limit, mtGC);
58+
size_t lgrp_num = os::numa_get_leaf_groups(reinterpret_cast<int*>(lgrp_ids), lgrp_limit);
5959
assert(lgrp_num > 0, "There should be at least one locality group");
6060

61-
lgrp_spaces()->reserve(lgrp_num);
61+
lgrp_spaces()->reserve(checked_cast<int>(lgrp_num));
6262
// Add new spaces for the new nodes
63-
for (int i = 0; i < lgrp_num; i++) {
63+
for (size_t i = 0; i < lgrp_num; i++) {
6464
lgrp_spaces()->append(new LGRPSpace(lgrp_ids[i], alignment));
6565
}
6666

67-
FREE_C_HEAP_ARRAY(int, lgrp_ids);
67+
FREE_C_HEAP_ARRAY(uint, lgrp_ids);
6868
}
6969

7070
MutableNUMASpace::~MutableNUMASpace() {
@@ -207,7 +207,7 @@ size_t MutableNUMASpace::unsafe_max_tlab_alloc(Thread *thr) const {
207207
}
208208

209209
// Bias region towards the first-touching lgrp. Set the right page sizes.
210-
void MutableNUMASpace::bias_region(MemRegion mr, int lgrp_id) {
210+
void MutableNUMASpace::bias_region(MemRegion mr, uint lgrp_id) {
211211
HeapWord *start = align_up(mr.start(), page_size());
212212
HeapWord *end = align_down(mr.end(), page_size());
213213
if (end > start) {
@@ -224,7 +224,7 @@ void MutableNUMASpace::bias_region(MemRegion mr, int lgrp_id) {
224224
// size if not using large pages or else this function does nothing.
225225
os::free_memory((char*)aligned_region.start(), aligned_region.byte_size(), os_align);
226226
// And make them local/first-touch biased.
227-
os::numa_make_local((char*)aligned_region.start(), aligned_region.byte_size(), lgrp_id);
227+
os::numa_make_local((char*)aligned_region.start(), aligned_region.byte_size(), checked_cast<int>(lgrp_id));
228228
}
229229
}
230230

@@ -623,7 +623,7 @@ void MutableNUMASpace::print_short_on(outputStream* st) const {
623623
MutableSpace::print_short_on(st);
624624
st->print(" (");
625625
for (int i = 0; i < lgrp_spaces()->length(); i++) {
626-
st->print("lgrp %d: ", lgrp_spaces()->at(i)->lgrp_id());
626+
st->print("lgrp %u: ", lgrp_spaces()->at(i)->lgrp_id());
627627
lgrp_spaces()->at(i)->space()->print_short_on(st);
628628
if (i < lgrp_spaces()->length() - 1) {
629629
st->print(", ");
@@ -636,7 +636,7 @@ void MutableNUMASpace::print_on(outputStream* st) const {
636636
MutableSpace::print_on(st);
637637
for (int i = 0; i < lgrp_spaces()->length(); i++) {
638638
LGRPSpace *ls = lgrp_spaces()->at(i);
639-
st->print(" lgrp %d", ls->lgrp_id());
639+
st->print(" lgrp %u", ls->lgrp_id());
640640
ls->space()->print_on(st);
641641
if (NUMAStats) {
642642
for (int i = 0; i < lgrp_spaces()->length(); i++) {
@@ -679,7 +679,7 @@ void MutableNUMASpace::LGRPSpace::accumulate_statistics(size_t page_size) {
679679
for (size_t i = 0; i < npages; i++) {
680680
if (lgrp_ids[i] < 0) {
681681
space_stats()->_uncommited_space += os::vm_page_size();
682-
} else if (lgrp_ids[i] == lgrp_id()) {
682+
} else if (checked_cast<uint>(lgrp_ids[i]) == lgrp_id()) {
683683
space_stats()->_local_space += os::vm_page_size();
684684
} else {
685685
space_stats()->_remote_space += os::vm_page_size();
@@ -709,7 +709,7 @@ void MutableNUMASpace::LGRPSpace::scan_pages(size_t page_size, size_t page_count
709709

710710
os::page_info page_expected, page_found;
711711
page_expected.size = page_size;
712-
page_expected.lgrp_id = lgrp_id();
712+
page_expected.lgrp_id = checked_cast<uint>(lgrp_id());
713713

714714
char *s = scan_start;
715715
while (s < scan_end) {
@@ -720,7 +720,7 @@ void MutableNUMASpace::LGRPSpace::scan_pages(size_t page_size, size_t page_count
720720
if (e != scan_end) {
721721
assert(e < scan_end, "e: " PTR_FORMAT " scan_end: " PTR_FORMAT, p2i(e), p2i(scan_end));
722722

723-
if ((page_expected.size != page_size || page_expected.lgrp_id != lgrp_id())
723+
if ((page_expected.size != page_size || checked_cast<uint>(page_expected.lgrp_id) != lgrp_id())
724724
&& page_expected.size != 0) {
725725
os::free_memory(s, pointer_delta(e, s, sizeof(char)), page_size);
726726
}

‎src/hotspot/share/gc/parallel/mutableNUMASpace.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class MutableNUMASpace : public MutableSpace {
6565
friend class VMStructs;
6666

6767
class LGRPSpace : public CHeapObj<mtGC> {
68-
int _lgrp_id;
68+
uint _lgrp_id;
6969
MutableSpace* _space;
7070
AdaptiveWeightedAverage *_alloc_rate;
7171
bool _allocation_failed;
@@ -87,7 +87,7 @@ class MutableNUMASpace : public MutableSpace {
8787
char* last_page_scanned() { return _last_page_scanned; }
8888
void set_last_page_scanned(char* p) { _last_page_scanned = p; }
8989
public:
90-
LGRPSpace(int l, size_t alignment) : _lgrp_id(l), _allocation_failed(false), _last_page_scanned(nullptr) {
90+
LGRPSpace(uint l, size_t alignment) : _lgrp_id(l), _allocation_failed(false), _last_page_scanned(nullptr) {
9191
_space = new MutableSpace(alignment);
9292
_alloc_rate = new AdaptiveWeightedAverage(NUMAChunkResizeWeight);
9393
}
@@ -97,7 +97,7 @@ class MutableNUMASpace : public MutableSpace {
9797
}
9898

9999
static bool equals(void* lgrp_id_value, LGRPSpace* p) {
100-
return *(int*)lgrp_id_value == p->lgrp_id();
100+
return *(uint*)lgrp_id_value == p->lgrp_id();
101101
}
102102

103103
// Report a failed allocation.
@@ -117,7 +117,7 @@ class MutableNUMASpace : public MutableSpace {
117117
alloc_rate()->sample(alloc_rate_sample);
118118
}
119119

120-
int lgrp_id() const { return _lgrp_id; }
120+
uint lgrp_id() const { return _lgrp_id; }
121121
MutableSpace* space() const { return _space; }
122122
AdaptiveWeightedAverage* alloc_rate() const { return _alloc_rate; }
123123
void clear_alloc_rate() { _alloc_rate->clear(); }
@@ -148,7 +148,7 @@ class MutableNUMASpace : public MutableSpace {
148148
size_t base_space_size() const { return _base_space_size; }
149149

150150
// Bias region towards the lgrp.
151-
void bias_region(MemRegion mr, int lgrp_id);
151+
void bias_region(MemRegion mr, uint lgrp_id);
152152

153153
// Get current chunk size.
154154
size_t current_chunk_size(int i);

0 commit comments

Comments
 (0)
Please sign in to comment.