Calculation of Host Memory Buffer sizes
Thomas Weißschuh
thomas at weissschuh.net
Wed Apr 27 16:09:58 PDT 2022
On 2022-04-28 00:40+0200, Thomas Weißschuh wrote:
> I am wondering about the calculation of the NVMe Host Memory Buffer sizes.
> It seems to me that the current algorithm to calculate this size does not lead
> to an optimal result.
>
> [..]
>
> It seems that the logic to calculate min_chunk in nvme_alloc_host_mem() starts
> with a too small value.
Of course shortly after sending the original mail I probably found the solution:
static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
{
- u64 min_chunk = min_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES);
+ u64 min_chunk = max_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES);
This would also much better fit the comment "start big and work our way down".
I'll send a proper patch tomorrow.
Thomas
More information about the Linux-nvme
mailing list