[PATCH V4 3/3] nvme-pci: get rid of the division in the fast path

Keith Busch kbusch at kernel.org
Thu Jul 16 22:32:42 EDT 2020


On Thu, Jul 16, 2020 at 05:51:39PM -0700, Chaitanya Kulkarni wrote:
> Since we have a macro for calculating the size of the ctrl page we can
> remove the division in the fast path for nvme-pci in nvme_unmap_data().
> 
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
> ---
>  drivers/nvme/host/pci.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 3c852a8f18ed..616db1ae137c 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -513,7 +513,8 @@ static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req)
>  static void nvme_unmap_data(struct nvme_dev *dev, struct request *req)
>  {
>  	struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
> -	const int last_prp = NVME_CTRL_PAGE_SIZE / sizeof(__le64) - 1;
> +	const int last_prp = (NVME_CTRL_PAGE_SIZE >> ilog2(sizeof(__le64))) - 1;

This is an integer constant expression, so the result is already
evaluated at compile time.



More information about the Linux-nvme mailing list