Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1061241iob; Thu, 28 Apr 2022 18:04:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDYtIMCMPo2XDn757KYyrv3NC1JnSuWOMpgKUKyNq5iRzigXrTloUEGtSzouXW7mhJYsOe X-Received: by 2002:a05:6512:33c2:b0:472:33dd:9f46 with SMTP id d2-20020a05651233c200b0047233dd9f46mr5691074lfg.98.1651194253229; Thu, 28 Apr 2022 18:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651194253; cv=none; d=google.com; s=arc-20160816; b=QvT4OfLmbijQ9SGS6C5g9aPu5DhovwDfGtd35aKcBLw25qs/+9lPSS/MHJJO6FGxHF oHNUZG94jFxiXGBLcISTKTS7/l9AebODZc8/XZpVEKqkCcJIcFaclPRoPQ1sCdDMo553 wvpUYLWETnjFxDssfp1CgEHWIzABlCgWsAzfcBigr9aCMdV+UlLuOsMwyTeWLCz88N4j VkdGFSHlvzdAdTv8/WsTvdU84h+vCfTI5BfN0YnhNHVu7Nz2FHyUt47reXU3kSXvvmP6 O+qmdEMbvnWtKxhPhNTX8FygPyhJkx+zrW+86dGlZGFIJhvWTD90Sb2b0CLy4x86sM0N XQqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:jabber-id:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:date; bh=VDyv3NeEuJBmPLvrgoETkJvUUk++NsedIod9LKManGw=; b=du+QiWH1qNTyd8kGNOdElRcdnmVG6PACyYSC7hmXX6znKT4K5ZDaooh8309nNoqL3l 6nuPm6Slyup2Kf3YC4zLmN9Y9lJPoRFEOhdmhWhlhaBDvGlw+TNB8H8sMqhMcKe7jiTA tsJOR7/P+XW/zJDgm9Tajr9bxuXMqxvunN6QzvKHu9v7xAL2QiCd3VlHGq3k7Fgl2B5I 7/1aX9dcXZAKNEOdSlxefIzQHm50GNPgf91m0chcyKWC9NBkvJcqaOqtLtEpU6lH6Wr+ M9X0cwRuKziQ2Ilc6WwytXe8UxwbsIennydr1usrTykn1iEJDbh+IGm4//sbKAQmTT/m thJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=hmP6z0Tn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a2e904d000000b0024f06a6a250si5355709ljg.307.2022.04.28.18.03.46; Thu, 28 Apr 2022 18:04:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=hmP6z0Tn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348527AbiD1OsG (ORCPT + 99 others); Thu, 28 Apr 2022 10:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348517AbiD1OsF (ORCPT ); Thu, 28 Apr 2022 10:48:05 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5E606D3BF for ; Thu, 28 Apr 2022 07:44:49 -0700 (PDT) Date: Thu, 28 Apr 2022 16:44:47 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1651157087; bh=1g8VE7azqFzzy065FworAEOOCfsdqNZvcvV19NCfaYA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hmP6z0TnAhqP4V6qWw0EaMSba/ZbdeMGOnIcJerhHOgpwd+2rlft+wbi0T2B+zQ3f n0zyrr3suOZpW+PvJICdGGK0apKO0bpWTmNiXQdtJ9KCO7lWqnkKqOruGx0iQ2ymbe ortsdVhugui2YrCf1EN1N0sDQ+HQ7dQ/SAUO4oi4= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Christoph Hellwig Cc: Keith Busch , Jens Axboe , Sagi Grimberg , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Subject: Re: [PATCH] nvme-pci: fix host memory buffer allocation size Message-ID: <5060d75e-46c0-4d29-a334-62c7e9714fa7@t-8ch.de> References: <20220428101922.14216-1-linux@weissschuh.net> <20220428143603.GA20460@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220428143603.GA20460@lst.de> Jabber-ID: thomas@t-8ch.de X-Accept: text/plain, text/html;q=0.2, text/*;q=0.1 X-Accept-Language: en-us, en;q=0.8, de-de;q=0.7, de;q=0.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-04-28 16:36+0200, Christoph Hellwig wrote: > On Thu, Apr 28, 2022 at 12:19:22PM +0200, Thomas Weißschuh wrote: > > We want to allocate the smallest possible amount of buffers with the > > largest possible size (1 buffer of size "hmpre"). > > > > Previously we were allocating as many buffers as possible of the smallest > > possible size. > > This also lead to "hmpre" to not be satisifed as not enough buffer slots > > where available. > > > > Signed-off-by: Thomas Weißschuh > > --- > > > > Also discussed at https://lore.kernel.org/linux-nvme/f94565db-f217-4a56-83c3-c6429807185c@t-8ch.de/ > > > > drivers/nvme/host/pci.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > > index 3aacf1c0d5a5..0546523cc20b 100644 > > --- a/drivers/nvme/host/pci.c > > +++ b/drivers/nvme/host/pci.c > > @@ -2090,7 +2090,7 @@ static int __nvme_alloc_host_mem(struct nvme_dev *dev, u64 preferred, > > > > 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); > > preferred is based on the HMPRE field in the spec, which documents the > preffered size. So the max here would not make ny sense at all. Is the current code supposed to reach HMPRE? It does not for me. The code tries to allocate memory for HMPRE in chunks. The best allocation would be to allocate one chunk for all of HMPRE. If this fails we half the chunk size on each iteration and try again. On my hardware we start with a chunk_size of 4MiB and just allocate 8 (hmmaxd) * 4 = 32 MiB which is worse than 1 * 200MiB. What am I missing?