From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9953BC7EE23 for ; Mon, 27 Feb 2023 00:54:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E86B36B0072; Sun, 26 Feb 2023 19:54:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E10E96B0073; Sun, 26 Feb 2023 19:54:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB0986B0074; Sun, 26 Feb 2023 19:54:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B5F486B0072 for ; Sun, 26 Feb 2023 19:54:51 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 756801A04F6 for ; Mon, 27 Feb 2023 00:54:51 +0000 (UTC) X-FDA: 80511251982.06.E96AAEF Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) by imf18.hostedemail.com (Postfix) with ESMTP id 8E2931C0009 for ; Mon, 27 Feb 2023 00:54:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="jaLlde/U"; spf=pass (imf18.hostedemail.com: domain of groeck7@gmail.com designates 209.85.166.41 as permitted sender) smtp.mailfrom=groeck7@gmail.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677459288; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4vfA8cCXK2hULckPJbRVreXLCcxArmL/xefqXVeDWtM=; b=4rKrvrwhl6Od/M9vEl/xkoyx7WX01In1krL9ly6mN9a8Hgi2HKcsCKmdrm1QZ11FFv3Zik sR9Kw097ae2xD1e1Jiz51R1oqtEQ/6g/biENa5GnTjLrzXDpAGil4GlYbhOOnh1BUMxGgj 7+EKRf88phZVHYpiSSsrcIpBSxuASAM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="jaLlde/U"; spf=pass (imf18.hostedemail.com: domain of groeck7@gmail.com designates 209.85.166.41 as permitted sender) smtp.mailfrom=groeck7@gmail.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677459288; a=rsa-sha256; cv=none; b=GY0o3PbndHMiFDNv4OXCcJuXYIxE8QKtDwyzxvajcYS58hEi/cFJ6g3xmXW4sqvtAyM6AR oPVXSlPLG7153ie0RIwRIoM/YyCbaNe6WedlEY0NAM9hNj5cddNkr0D2wrs7CClhU2aPvU 3882vaXndQd8ZSzVnB0e1KccvikwYv8= Received: by mail-io1-f41.google.com with SMTP id 76so1955625iou.9 for ; Sun, 26 Feb 2023 16:54:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=4vfA8cCXK2hULckPJbRVreXLCcxArmL/xefqXVeDWtM=; b=jaLlde/UNUUfyYs2nHDL2E5+B+xRISCOE7MdSmEJPADNpHUvy89CdECwS+lY/U2Y9y +hrAsXE2XA1ts0VuJPopKxaNllBtUdmNAOyF2zoEv8xWY+ct7TPNDMVD6G0GveQA3WOE K913/Rr/mM0WjwDKrovI2NDkL787OL/oVe1wTfpBSdmflnSP6ycQvZd36BK+KcMhTiB6 bF53H1Jz7imQJtmIy1Ll3yL5QKSz5rK+yeOgfEcra/4L9lBEGI1bJ7uYKMOR3BJiVaxZ SoL9XmzvrflLw/tqOBBiDM4WDl+PZF52E1rRQDhH4wgDEeDG9Jd+R1Y2aRItA4uf1ns8 XoyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4vfA8cCXK2hULckPJbRVreXLCcxArmL/xefqXVeDWtM=; b=1zHVZ+TgYF1M2pEwIjOWHpc6foOsK02utcpkT8LhMY7gH3Iv9K4gxuWmYoPNKn/REg Bizjyy+WUK1ivUaZ7FpTUCFvREecXOtn2EWh7JeKPDS20/g4wf6Ch2aPZS2xUqD0QQ08 rr9qfNpQg3JZtfg64ugrfjFWCnlnNLGGXm11czSGMDICV/tNDjVZktpxp/QJwQbxX4yc ItNr+WLeErPYzIqwKXYGgubkvlKje36A0XU/cacZGbAUKhjvWF50c9JHXcMdtr7WxH/p 6JkZO2NOLfjZywUszUf+as6N5qthbYxBV6b9Itk9nJnhoZGD5Ty5STNB9NacqJkq2WD+ /4Qw== X-Gm-Message-State: AO0yUKUqZc6iYFgnXTFH3H7y8+dnt49Ml3KKmdfh7oy3TuI1+dfwMPJr UwZCtYdiJ4Oq12kIPrFWFrw= X-Google-Smtp-Source: AK7set+fGuTpSVD5zx+mrnnIeh0GdB2sdvBzSLkVZy6qiW3WWCTa+6jycaMwne78HKDh0KCgwqyOoQ== X-Received: by 2002:a6b:fe03:0:b0:719:62d5:ed6c with SMTP id x3-20020a6bfe03000000b0071962d5ed6cmr15893137ioh.18.1677459287657; Sun, 26 Feb 2023 16:54:47 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r5-20020a92ce85000000b00316e3a38becsm1614090ilo.18.2023.02.26.16.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 16:54:47 -0800 (PST) Date: Sun, 26 Feb 2023 16:54:45 -0800 From: Guenter Roeck To: Keith Busch Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, willy@infradead.org, hch@lst.de, tonyb@cybernetics.com, akpm@linux-foundation.org, kernel-team@meta.com, Keith Busch Subject: Re: [PATCHv4 11/12] dmapool: link blocks across pages Message-ID: <20230227005445.GA3425881@roeck-us.net> References: <20230126215125.4069751-1-kbusch@meta.com> <20230126215125.4069751-12-kbusch@meta.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230126215125.4069751-12-kbusch@meta.com> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8E2931C0009 X-Rspam-User: X-Stat-Signature: wkjn9pp14e8sy1zadkt1dckk4bt1rkke X-HE-Tag: 1677459288-516850 X-HE-Meta: U2FsdGVkX1/7/yJjLZBbMiGHkcmk8/LToW9OSMB4kus3O1Kw0+llCdZwwDL+tse7szfcmsPz5VsIJtDsqtqD1MOmRx0UGsHFwbZzo7AB5EXG3cj7Fj9gVIEz7HHz5p/E8JvIliSB8/6uWiqpCE59XfgfkE2/I0KE2d7yNgAkChOGkcVh/g5n3jVdcvxr5BSE0N1vEb8kk7gtbpV0Obgxpu0A89vjL8Z2HbEKLEYiNmyv8VhJGYouy8QDyVersxZD8By/JgA6DhF9vTUyej6iORQuxby6S0DmGH+lZMPEX1A4wnBzNdaFcK8c9IKurbU4btqDZ7pD8vR4cc3h2GhcrT6PU7E+Q560ZOHKOFdI0biZBv8wNO5rPB6+TWFGDgx6JwA63uWuQi0r/4eFtkQL2Th42dMdKKj7fr4hQpTvV42A8DGc6RA5AJd3T4GN4q7eqmCngfD8hHpUcWcGeOmaQUtyVTmM640CFPd7YGXXdvcvIhPhwbs1CLiIr7iFHuGRotpa+n9Q9tY+0nSsP0nnIkiIJ7wLlWBkcTNcQdQblZr6v/ddPHFY5PxQZMOcZswLV6LUfjhxR9UQ55UhHuXGJMxz1eCJphEEzv8w5SWLGCJtjFLd5DHUBwSzPixEnnOag6zEogdB9Vder3qqmbdUpNAS2uHM1xZTAZWv1rCTesk/l19drDwdS970wI/8T06+NG0j7JKi3nclFSyojVw+Ur44iiDWNJCfSaFAv47N0qxLp0Y5nBkv9Tg/F/X9u6nfkI3QNFPSxWEoyAbqCfGzNGD0XomKxFMaM3UHWeDhCD6SDoQIgIJuDwNJ2QyLGuHqaDAcOZDWrnelso7ZDan3RRILBV0GJcUTRmSnz7psRkSVxh9i5A/UfR0L1Chi+S4rytvzC6oogJo94zMAPd+7ym2llC94V8uwwMSV0tYYRnhBEqwLmZrrsH/SLp4FWhLfX82fVRhGtw3guVUsThO 2fuD1E4X C2q5EAQYyRWUz2hWY6LAKude9n/t+TgiYT+tVXx54+J02GioHmcpndX+TIzrRue2x31eONEcgEbckvHMA66TQaNRjFCj4Ojq7u+Vm4eIm9odNyIy80k73DGEb3YQgBMqgSoYJq1tq6017wtKtCp2uWciELY4DxfnAo/+iWibszMDIim+XPWeQaUCryR7ew1HrBYqB3ZX4IjrVEGR1ChbxgMFMdL+20qaU+dn5fXkRzZO+DLLoTttLGU/iNYH1W2132HB+XeWpFARuon5wGTAE+mGiOWMIxL9S0PY1yLUPuSo2YRL0NREWtYOiUk5ohOGWskv6OXXUNob08N9ZugMIVghx2UnXUj06wGkdHbYO3G2YOrVggL7AUrqQ3sSiHYFn1jpQLQFYx+t6tXgONvf/Ejd7wYhYgfKbneFL47OxXK1WUsBTf5gRd0UH/5dKiGKFiwHsezwe3ebj4tOylZvsRw4/0PbkzcJxtGOjY7SR+79U6zsPH/UgIppApq7Sqv9zxRJ7DnqDmTubvWnZTBRbT58woFHEcURRRT4t7KSOQjKsPYwM+XqqAW6HdnKjdBmW1HiDnxQ/xTZX324= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi, On Thu, Jan 26, 2023 at 01:51:24PM -0800, Keith Busch wrote: > From: Keith Busch > > The allocated dmapool pages are never freed for the lifetime of the > pool. There is no need for the two level list+stack lookup for finding a > free block since nothing is ever removed from the list. Just use a > simple stack, reducing time complexity to constant. > > The implementation inserts the stack linking elements and the dma handle > of the block within itself when freed. This means the smallest possible > dmapool block is increased to at most 16 bytes to accomodate these > fields, but there are no exisiting users requesting a dma pool smaller > than that anyway. > > Removing the list has a significant change in performance. Using the > kernel's micro-benchmarking self test: > > Before: > > # modprobe dmapool_test > dmapool test: size:16 blocks:8192 time:57282 > dmapool test: size:64 blocks:8192 time:172562 > dmapool test: size:256 blocks:8192 time:789247 > dmapool test: size:1024 blocks:2048 time:371823 > dmapool test: size:4096 blocks:1024 time:362237 > > After: > > # modprobe dmapool_test > dmapool test: size:16 blocks:8192 time:24997 > dmapool test: size:64 blocks:8192 time:26584 > dmapool test: size:256 blocks:8192 time:33542 > dmapool test: size:1024 blocks:2048 time:9022 > dmapool test: size:4096 blocks:1024 time:6045 > > The module test allocates quite a few blocks that may not accurately > represent how these pools are used in real life. For a more marco level > benchmark, running fio high-depth + high-batched on nvme, this patch > shows submission and completion latency reduced by ~100usec each, 1% > IOPs improvement, and perf record's time spent in dma_pool_alloc/free > were reduced by half. > With this patch in linux-next, I see a boot failure when trying to boot a powernv qemu emulation from the SCSI MEGASAS controller. Qemu command line is qemu-system-ppc64 -M powernv -cpu POWER9 -m 2G \ -kernel arch/powerpc/boot/zImage.epapr \ -snapshot \ -device megasas,id=scsi,bus=pcie.0 -device scsi-hd,bus=scsi.0,drive=d0 \ -drive file=rootfs-el.ext2,format=raw,if=none,id=d0 \ -device i82557a,netdev=net0,bus=pcie.1 -netdev user,id=net0 \ -nographic -vga none -monitor null -no-reboot \ --append "root=/dev/sda console=tty console=hvc0" Reverting this patch together with "dmapool: create/destroy cleanup" fixes the problem. Bisect log is attached for reference. Guenter --- # bad: [8232539f864ca60474e38eb42d451f5c26415856] Add linux-next specific files for 20230225 # good: [c9c3395d5e3dcc6daee66c6908354d47bf98cb0c] Linux 6.2 git bisect start 'HEAD' 'v6.2' # good: [fe3130bc4df0b1303de4321af2bc4dcee5d7db2f] cifs: reuse cifs_match_ipaddr for comparison of dstaddr too git bisect good fe3130bc4df0b1303de4321af2bc4dcee5d7db2f # good: [8138ddac3c324feb92cc30f6d0d3a1bba51345a9] Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git git bisect good 8138ddac3c324feb92cc30f6d0d3a1bba51345a9 # bad: [2a15ddbcd09ca3a7843a48832884e37e703eaf83] Merge branch 'master' of git://linuxtv.org/media_tree.git git bisect bad 2a15ddbcd09ca3a7843a48832884e37e703eaf83 # bad: [a7d241d71cf464413307df69177ae2dec8481d37] Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git git bisect bad a7d241d71cf464413307df69177ae2dec8481d37 # bad: [446eb7f1f4aec9232d4b10222123a4566a8b1a95] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git git bisect bad 446eb7f1f4aec9232d4b10222123a4566a8b1a95 # good: [14c61d2100377dde2f6338395325b4090279d6a7] soc: document merges git bisect good 14c61d2100377dde2f6338395325b4090279d6a7 # bad: [cb26c07e8a8acaecb43228181e1eae68ece8db0e] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git git bisect bad cb26c07e8a8acaecb43228181e1eae68ece8db0e # bad: [d37d53a39d853fcc2121770fd3b61f274985d594] Merge branch 'mm-everything' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm git bisect bad d37d53a39d853fcc2121770fd3b61f274985d594 # bad: [708a06c601945c3415240ed0950e37fe27dd8e60] mm/userfaultfd: support WP on multiple VMAs git bisect bad 708a06c601945c3415240ed0950e37fe27dd8e60 # good: [beb78ba6c0dbed73b38d5ed74bf47aa2c65fafa7] dmapool: move debug code to own functions git bisect good beb78ba6c0dbed73b38d5ed74bf47aa2c65fafa7 # bad: [a2cb3f101b06f78258cf0c6813b3a17bd1ec846a] zsmalloc: remove insert_zspage() ->inuse optimization git bisect bad a2cb3f101b06f78258cf0c6813b3a17bd1ec846a # good: [e637ac603aec2b0a73e50fd8031481c6e55bf139] dmapool: don't memset on free twice git bisect good e637ac603aec2b0a73e50fd8031481c6e55bf139 # bad: [8f5073712e32685dfeb4925f13a95c6eb9f10cd8] dmapool: create/destroy cleanup git bisect bad 8f5073712e32685dfeb4925f13a95c6eb9f10cd8 # bad: [28b0a0c64bc658e176368f9270dc8085aa469c63] dmapool: link blocks across pages git bisect bad 28b0a0c64bc658e176368f9270dc8085aa469c63 # first bad commit: [28b0a0c64bc658e176368f9270dc8085aa469c63] dmapool: link blocks across pages