Skip to content

Commit bfba739

Browse files
committed
[cru] Handle folly's size discrepancy
1 parent 91a5fd2 commit bfba739

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Cru/CruDmaChannel.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ CruDmaChannel::CruDmaChannel(const Parameters& parameters)
8282
}
8383
stream << id << " ";
8484
//Implicit constructors are deleted for the folly Queue. Workaround to keep the Link struct with a queue * field.
85-
std::shared_ptr<SuperpageQueue> linkQueue = std::make_shared<SuperpageQueue>(LINK_QUEUE_CAPACITY);
85+
std::shared_ptr<SuperpageQueue> linkQueue = std::make_shared<SuperpageQueue>(LINK_QUEUE_CAPACITY_ALLOCATIONS);
8686
Link newLink = { static_cast<LinkId>(id), 0, linkQueue };
8787
mLinks.push_back(newLink);
8888
}

src/Cru/CruDmaChannel.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ class CruDmaChannel final : public DmaChannelPdaBase
6969
/// Max amount of superpages per link.
7070
/// This may not exceed the limit determined by the firmware capabilities.
7171
static constexpr size_t LINK_QUEUE_CAPACITY = Cru::MAX_SUPERPAGE_DESCRIPTORS;
72+
static constexpr size_t LINK_QUEUE_CAPACITY_ALLOCATIONS = LINK_QUEUE_CAPACITY + 1; // folly Queue needs + 1
7273

7374
/// Max amount of superpages in the ready queue.
7475
/// This is an arbitrary size, can easily be increased if more headroom is needed.
7576
static constexpr size_t READY_QUEUE_CAPACITY = Cru::MAX_SUPERPAGE_DESCRIPTORS * Cru::MAX_LINKS;
77+
static constexpr size_t READY_QUEUE_CAPACITY_ALLOCATIONS = READY_QUEUE_CAPACITY + 1; // folly Queue needs + 1
7678

7779
/// Queue for one link
7880
using SuperpageQueue = folly::ProducerConsumerQueue<Superpage>;
@@ -143,7 +145,7 @@ class CruDmaChannel final : public DmaChannelPdaBase
143145
size_t mLinkQueuesTotalAvailable;
144146

145147
/// Queue for superpages that have been transferred and are waiting for popping by the user
146-
SuperpageQueue mReadyQueue{ READY_QUEUE_CAPACITY };
148+
SuperpageQueue mReadyQueue{ READY_QUEUE_CAPACITY_ALLOCATIONS };
147149

148150
// These variables are configuration parameters
149151

0 commit comments

Comments
 (0)