@@ -412,28 +412,30 @@ class ZPageAllocation : public StackObj {
412412 const Ticks _start_timestamp;
413413 const uint32_t _young_seqnum;
414414 const uint32_t _old_seqnum;
415- const uint32_t _initiating_numa_id ;
415+ const uint32_t _preferred_partition ;
416416 bool _is_multi_partition;
417417 ZSinglePartitionAllocation _single_partition_allocation;
418418 ZMultiPartitionAllocation _multi_partition_allocation;
419419 ZListNode<ZPageAllocation> _node;
420420 ZFuture<bool > _stall_result;
421421
422422public:
423- ZPageAllocation (ZPageType type, size_t size, ZAllocationFlags flags, ZPageAge age)
423+ ZPageAllocation (ZPageType type, size_t size, ZAllocationFlags flags, ZPageAge age, uint32_t preferred_partition )
424424 : _type(type),
425425 _requested_size (size),
426426 _flags(flags),
427427 _age(age),
428428 _start_timestamp(Ticks::now()),
429429 _young_seqnum(ZGeneration::young()->seqnum()),
430430 _old_seqnum(ZGeneration::old()->seqnum()),
431- _initiating_numa_id(ZNUMA::id() ),
431+ _preferred_partition(preferred_partition ),
432432 _is_multi_partition(false ),
433433 _single_partition_allocation(size),
434434 _multi_partition_allocation(size),
435435 _node(),
436- _stall_result() {}
436+ _stall_result() {
437+ assert (_preferred_partition < ZNUMA::count (), " Preferred partition out-of-bounds (0 <= %d < %d)" , _preferred_partition, ZNUMA::count ());
438+ }
437439
438440 void reset_for_retry () {
439441 _is_multi_partition = false ;
@@ -474,8 +476,8 @@ class ZPageAllocation : public StackObj {
474476 return _old_seqnum;
475477 }
476478
477- uint32_t initiating_numa_id () const {
478- return _initiating_numa_id ;
479+ uint32_t preferred_partition () const {
480+ return _preferred_partition ;
479481 }
480482
481483 bool is_multi_partition () const {
@@ -1397,10 +1399,10 @@ static void check_out_of_memory_during_initialization() {
13971399 }
13981400}
13991401
1400- ZPage* ZPageAllocator::alloc_page (ZPageType type, size_t size, ZAllocationFlags flags, ZPageAge age) {
1402+ ZPage* ZPageAllocator::alloc_page (ZPageType type, size_t size, ZAllocationFlags flags, ZPageAge age, uint32_t preferred_partition ) {
14011403 EventZPageAllocation event;
14021404
1403- ZPageAllocation allocation (type, size, flags, age);
1405+ ZPageAllocation allocation (type, size, flags, age, preferred_partition );
14041406
14051407 // Allocate the page
14061408 ZPage* const page = alloc_page_inner (&allocation);
@@ -1548,7 +1550,7 @@ bool ZPageAllocator::claim_capacity(ZPageAllocation* allocation) {
15481550 }
15491551
15501552 // Round robin single-partition claiming
1551- const uint32_t start_numa_id = allocation->initiating_numa_id ();
1553+ const uint32_t start_numa_id = allocation->preferred_partition ();
15521554 const uint32_t start_partition = start_numa_id;
15531555 const uint32_t num_partitions = _partitions.count ();
15541556
@@ -1560,7 +1562,7 @@ bool ZPageAllocator::claim_capacity(ZPageAllocation* allocation) {
15601562 }
15611563 }
15621564
1563- if (!is_multi_partition_enabled () || sum_available () < allocation-> size ( )) {
1565+ if (!is_multi_partition_allowed ( allocation)) {
15641566 // Multi-partition claiming is not possible
15651567 return false ;
15661568 }
@@ -1578,7 +1580,7 @@ bool ZPageAllocator::claim_capacity(ZPageAllocation* allocation) {
15781580}
15791581
15801582bool ZPageAllocator::claim_capacity_fast_medium (ZPageAllocation* allocation) {
1581- const uint32_t start_node = allocation->initiating_numa_id ();
1583+ const uint32_t start_node = allocation->preferred_partition ();
15821584 const uint32_t numa_nodes = ZNUMA::count ();
15831585
15841586 for (uint32_t i = 0 ; i < numa_nodes; ++i) {
@@ -2191,6 +2193,12 @@ bool ZPageAllocator::is_multi_partition_enabled() const {
21912193 return _virtual.is_multi_partition_enabled ();
21922194}
21932195
2196+ bool ZPageAllocator::is_multi_partition_allowed (const ZPageAllocation* allocation) const {
2197+ return is_multi_partition_enabled () &&
2198+ allocation->type () == ZPageType::large &&
2199+ allocation->size () <= sum_available ();
2200+ }
2201+
21942202const ZPartition& ZPageAllocator::partition_from_partition_id (uint32_t numa_id) const {
21952203 return _partitions.get (numa_id);
21962204}
0 commit comments