From patchwork Fri Nov 24 14:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 13467721 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CED9CC61D97 for ; Fri, 24 Nov 2023 14:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jU8DlgPheLAnOLta/FOPkQ1OyeVbB4Je+Fs/s8Bcpb4=; b=EFjngpuhPRBMg0 ZcmkP4K0/JEBc0xFd7R8IggmjzbvEkMIG42dHkwFBDeZEbci2oH/MKfalsE/TV5UMzUGVJ7DKI1fx Jt+iXMD2xh4hhwQRQR65N2PxGScxgxAcdBrcDfwFCquvHHv0SfVtWLevZt8iBIDMUrLeC0cr4edAy cVWIJXD/N3navh9ZYTGtvn8LaZNGvyFjBlBZzyYfWdFcT/l+WFZAA5QbMSOpiJtx+xznPzhuvinyT YECvJ/YvhVapL9f/zj4MIHxK5K9Jf4U5ZLVACN8KqV0F3Orks6scU9sSUXGZ/XzP4znOptuC+WGZe f+Rk+edzR1gJCas8Gr2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r6X6v-007Off-0m; Fri, 24 Nov 2023 14:24:49 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r6X6r-007Oc7-2a for linux-arm-kernel@lists.infradead.org; Fri, 24 Nov 2023 14:24:47 +0000 Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by madras.collabora.co.uk (Postfix) with ESMTPSA id 6A3FF66073A5; Fri, 24 Nov 2023 14:24:38 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1700835879; bh=iIcP5WIQDPTMQgE5CZyRYxBziIRXARrefGPO4u4vmlU=; h=From:To:Cc:Subject:Date:From; b=AUwvAkV/wwlMGQ5z3glRc9Z45EUS8ANCaKGdVqI4SETixm6CVHFyjnaWVcM3AAVxD RxMEbQ1FeBK3wjgd1LiH8+A0c8RcJQnWzccT+zmFqonkPI0adZ08671yjkuPsIWbX7 oCMw0V/pRQylxsp0uvNumC9HQjafPcz0+vshN5dEyWhqxlac6s9hMHz/jzBI6GqgRe /n/ZQCqkpxqo9ArpGKlCSLmJgQR5uyg//+Wlaf2NCqeDe6/885fO0XvjJW7Y+LW/Z+ jdZ0BJp6btMZf8ywgBWepw6RKgxMgNv7zDptiGEvpitIjaJ5qgJ5eJlTKix6PLQHTe GGWD2J829m/Cw== From: Boris Brezillon To: Joerg Roedel , iommu@lists.linux.dev, Will Deacon , Robin Murphy , linux-arm-kernel@lists.infradead.org Cc: Rob Clark , Gaurav Kohli , Steven Price , Jason Gunthorpe , kernel@collabora.com, Boris Brezillon Subject: [PATCH v3 0/2] iommu: Allow passing custom allocators to pgtable drivers Date: Fri, 24 Nov 2023 15:24:32 +0100 Message-ID: <20231124142434.1577550-1-boris.brezillon@collabora.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231124_062446_033673_5A8808E6 X-CRM114-Status: GOOD ( 11.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello, This patchset is an attempt at making page table allocation customizable. This is useful to some GPU drivers for various reasons: - speed-up upcoming page table allocations by managing a pool of free pages - batch page table allocation instead of allocating one page at a time - pre-reserve pages for page tables needed for map/unmap operations and return the unused page tables to some pool The first and last reasons are particularly important for GPU drivers wanting to implement asynchronous VM_BIND. Asynchronous VM_BIND requires that any page table needed for a map/unmap operation to succeed be allocated at VM_BIND job creation time. At the time of the job creation, we don't know what the VM will look like when we get to execute the map/unmap, and can't guess how many page tables we will need. Because of that, we have to over-provision page tables for the worst case scenario (page table tree is empty), which means we will allocate/free a lot. Having pool a pool of free pages is crucial if we want to speed-up VM_BIND requests. There might also be other good reasons to want custom allocators, like fine-grained memory accounting and resource limiting. Regards, Boris Changes in v3: - Add Robin's R-b - Cosmetic changes - Improve the allocator doc - Stop passing GFP_ZERO to custom allocators Changes in v2: - Add Steven's R-b - Expand on possible use-cases for custom allocators - Add a caps field to io_pgtable_init_fns Boris Brezillon (2): iommu: Allow passing custom allocators to pgtable drivers iommu: Extend LPAE page table format to support custom allocators drivers/iommu/io-pgtable-arm.c | 55 ++++++++++++++++++++++++---------- drivers/iommu/io-pgtable.c | 23 ++++++++++++++ include/linux/io-pgtable.h | 34 +++++++++++++++++++++ 3 files changed, 96 insertions(+), 16 deletions(-) Reviewed-by: Gaurav Kohli Tested-by: Gaurav Kohli