Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2407338ioo; Sat, 28 May 2022 12:38:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb6se4FXPSXB2zLwBusM4jip2aWxzkeGPwb5sW3BSyis7Zg47QtW2wuB103WpVqb9vpGKf X-Received: by 2002:a17:902:6b03:b0:161:51d6:61b with SMTP id o3-20020a1709026b0300b0016151d6061bmr24908140plk.23.1653766716928; Sat, 28 May 2022 12:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653766716; cv=none; d=google.com; s=arc-20160816; b=W/Q3MkaeZF0zQXwwaRc/EjE83eTNKkMKLUEH5n4gf7S+pHQ4WzIQgW5TBmSUsx4AV6 7/fqearGYWFpVKHyXoGkI8ho5vgxjuWSWOGVWgUo/TG4usKb0WADZ0zefwuPdyur1O+A iUblfuuuFID/Ch0cuZOTBc99DrkWaTQXBiFW62treYPrAvzBtllxz9+VLyL4i/7Zlofe ANHEGttfc19beqcieRaWagQG/VNkrGX1U/Q9vUlHi0s6HG/pe/v+7iIhSRqNjyZi+I+f w5kVQp+82tBsx/9NCfrjIuskTyg3cO1nnDspbpNFBa/58bfAtkEmWLDI7E9pe0ycKKxi gg4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uXndldvdsnff+SI5mnwhgjiYJhDOOy3ju96PXbn1+48=; b=J6a+LDd9EWC5+XVyxu1RK6/HhKbVaeJPhfFdFHmN+yrKhle0pypn/BnmRBtCW4bKtA JLBbC2lYH9A3AX5RKqBbBrjM1BMZYccikFC0DeKxMN5bdRKpO3c1teCHK9wQnvqJ+s4g bDQKF0O4XSqX0KE1v1R6v67EyiwANWMIBT+mxfxCMENXtTBbWrlo7mZOxA0KMMnpSUG3 sbvumn0kwNpRy5WWpYISp83+1tB7rkFjmWWWEv4OHx8G2A0t2GnvcQd34j8haDbjnudH j/uhv6Ln7aJWTe040LkcAWvUGvohGuZeR7Dg1jmdmqAiv/0NyJGU/g6hKqetuglfJsEb EEnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oExo7SPI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v4-20020a17090331c400b0015870834b16si8588596ple.549.2022.05.28.12.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:38:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oExo7SPI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 01B865DA39; Sat, 28 May 2022 12:03:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354678AbiE0VBf (ORCPT + 99 others); Fri, 27 May 2022 17:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbiE0VBb (ORCPT ); Fri, 27 May 2022 17:01:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 499201EAEB for ; Fri, 27 May 2022 14:01:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D38F76027A for ; Fri, 27 May 2022 21:01:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5164C385A9; Fri, 27 May 2022 21:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653685290; bh=b1REJzW0O2tqVTt711WSZgo7eiYCCpX58Hv7sbbE0tw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oExo7SPI3jcDj+dU4oC3F5/k6QyytX+pQIzjuetvwOUlqQ3ZABt6GEieb82uXewIY RSwGyx1DW+jLmQp2kN2npOCaCyMzuOhTvAguW9DOV5/X5s1cn+DE5jX1wlhCoZ6k9F LbuwtHdUSj0IIjGzk0u+2vw/ycIZjlj5nfo7seiUS7+fcklWBByWq5QmI5mCxSZOfa qek1J+nvnNCNFFdTNNavebjSw1fhqUeWZ9cGvLe4U3vSJXNiUnwL6nC2Mo8eItmXKy BvzsG4gzDHIF4QbQKanLB+lYuuJGPj2Pq3gmZvNRkOQ2o+r8+kgMGWh+cY9arr6+// 5DKv08hjwFyMw== Date: Fri, 27 May 2022 15:01:27 -0600 From: Keith Busch To: Tony Battersby Cc: kernel-team@fb.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org Subject: Re: [PATCH 0/2] dmapool performance enhancements Message-ID: References: <20220428202714.17630-1-kbusch@kernel.org> <156da4ae-20de-a40f-5173-3b02c779b43c@cybernetics.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <156da4ae-20de-a40f-5173-3b02c779b43c@cybernetics.com> X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Fri, May 27, 2022 at 03:35:47PM -0400, Tony Battersby wrote: > I posted a similar patch series back in 2018: > > https://lore.kernel.org/linux-mm/73ec1f52-d758-05df-fb6a-41d269e910d0@cybernetics.com/ > https://lore.kernel.org/linux-mm/15ff502d-d840-1003-6c45-bc17f0d81262@cybernetics.com/ > https://lore.kernel.org/linux-mm/1288e597-a67a-25b3-b7c6-db883ca67a25@cybernetics.com/ > > > I initially used a red-black tree keyed by the DMA address, but then for > v2 of the patchset I put the dma pool info directly into struct page and > used virt_to_page() to get at it.? But it turned out that was a bad idea > because not all architectures have struct page backing > dma_alloc_coherent(): > > https://lore.kernel.org/linux-kernel/20181206013054.GI6707@atomide.com/ > > I intended to go back and resubmit the red-black tree version, but I was > too busy at the time and forgot about it.? A few days ago I finally > decided to update the patches and submit them upstream.? I found your > recent dmapool xarray patches by searching the mailing list archive to > see if anyone else was working on something similar. > > Using the following as a benchmark: > > modprobe mpt3sas > drivers/scsi/mpt3sas/mpt3sas_base.c > _base_allocate_chain_dma_pool > loop dma_pool_alloc(ioc->chain_dma_pool) > > rmmod mpt3sas > drivers/scsi/mpt3sas/mpt3sas_base.c > _base_release_memory_pools() > loop dma_pool_free(ioc->chain_dma_pool) > > Here are the benchmark results showing the speedup from the patchsets: > > modprobe rmmod > orig 1x 1x > xarray 5.2x 186x > rbtree 9.3x 269x > > It looks like my red-black tree version is faster than the v1 of the > xarray patch on this benchmark at least, although the mpt3sas usage of > dmapool is hardly typical.? I will try to get some testing done on my > patchset and post it next week. Thanks for the info. Just comparing with xarray, I actually found that the list was still faster until you get >100 pages in the pool, after which xarray becomes the clear winner. But it turns out I don't often see that many pages allocated for a lot of real use cases, so I'm trying to take this in a different direction by replacing the lookup structures with an intrusive stack. That is safe to do since pages are never freed for the lifetime of the pool, and it's by far faster than anything else. The downside is that I'd need to increase the size of the smallest allowable pool block, but I think that's okay. Anyway I was planning to post this new idea soon. My reasons for wanting a faster dma pool are still in the works, though, so I'm just trying to sort out those patches before returning to this one.