All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas@weissschuh.net>
To: linux-nvme@lists.infradead.org
Subject: Calculation of Host Memory Buffer sizes
Date: Thu, 28 Apr 2022 00:40:37 +0200	[thread overview]
Message-ID: <f94565db-f217-4a56-83c3-c6429807185c@t-8ch.de> (raw)

Hi,

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.

Hardware information:

mn        : WD_BLACK SN770 1TB
fr        : 731030WD
hmpre     : 51200 (limited by max_host_mem_size_mb to 32768 -> 128MiB)
hmmin     : 823
hmminds   : 0
hmmaxd    : 8

To me this looks like the disk wants 200MiB allocated that can be described in
eight descriptors.
However the kernel log has the following entry:

[    8.981685] nvme nvme0: allocated 32 MiB host memory buffer.

Tracing through drivers/nvme/host/pci.c the following happens:

The loop in nvme_alloc_host_mem() is only entered once.
  min: 3371008
  preferred: 134217728
  min_chunk: 4194304
  chunk_size: 4194304

Now in __nvme_alloc_host_mem() the loop is called the eight times for hmmaxd,
each time allocating 4194304 bytes (4 MiB).
The end result is that a total of 32MiB of Host Memory Buffer are allocated
which is the bare minimum instead of the 200 MiB that are preferred and
available.

It seems that the logic to calculate min_chunk in nvme_alloc_host_mem() starts
with a too small value.

All of this is on a normal x86 laptop with plenty of system memory.
It's reproducible with current git (46cf2c613f4b10eb12f749207b0fd2c1bfae3088)
and 5.17.4.

Thanks,
Thomas


             reply	other threads:[~2022-04-27 22:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-27 22:40 Thomas Weißschuh [this message]
2022-04-27 23:09 ` Calculation of Host Memory Buffer sizes Thomas Weißschuh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f94565db-f217-4a56-83c3-c6429807185c@t-8ch.de \
    --to=thomas@weissschuh.net \
    --cc=linux-nvme@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.