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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 AA38DF43841 for ; Thu, 16 Apr 2026 07:50:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7011C10E840; Thu, 16 Apr 2026 07:50:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Njs3r6EL"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9F65610E840 for ; Thu, 16 Apr 2026 07:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1776325851; x=1807861851; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PNrurzVC6IAIr+GrFI0K2DR7iqWbSkFORn+VdDWm2Vs=; b=Njs3r6ELtnt3mAy3GQQKeoz9mq4HaNsnBTsBuEFWCDLIUfGiJmXjxdky oO5Ic0tso4N+y/o/1yeosWFs8O+/K13xC8Dtnvw/Shl9DFcS2Hlu3co0E v1wVAGMiwHSrN87kCOB1yFASxZyiAkufYjd+/caZ6ouY7TXPMsVV0vUS2 Y5E9K+Gbkl9V5vWZxvA6Y1Fl9KlquwfypbOYpzXDYTduo4RQQI/t0FixX YnY1v47dz380IsoYaEXG+cy/qBXufZSP7bzoOANgdEXn6HSLrhgaYAhcr urzIZHjqOYsKp2ruN9ep9L3qCkYHdyIMdsM2v7RMKtM7vuqWjwOtL6w3T w==; X-CSE-ConnectionGUID: A9hh2/IJR6aSLRrU2AihCg== X-CSE-MsgGUID: NUm/rQ7oTN+qgOUw/v6XTg== X-IronPort-AV: E=McAfee;i="6800,10657,11760"; a="81188812" X-IronPort-AV: E=Sophos;i="6.23,181,1770624000"; d="scan'208";a="81188812" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2026 00:50:51 -0700 X-CSE-ConnectionGUID: iRaB6fOFQ2mmlZ3kEDB83Q== X-CSE-MsgGUID: 5OGp56gFTgG7bG1h7QaznA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,181,1770624000"; d="scan'208";a="235036607" Received: from tejasupa-desk.iind.intel.com (HELO tejasupa-desk) ([10.190.239.37]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2026 00:50:49 -0700 From: Tejas Upadhyay To: intel-xe@lists.freedesktop.org Cc: matthew.auld@intel.com, matthew.brost@intel.com, thomas.hellstrom@linux.intel.com, himal.prasad.ghimiray@intel.com, Tejas Upadhyay Subject: [RFC PATCH V7 08/10] gpu/buddy: Add routine to dump allocated buddy blocks Date: Thu, 16 Apr 2026 13:19:57 +0530 Message-ID: <20260416074958.3722666-20-tejas.upadhyay@intel.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260416074958.3722666-12-tejas.upadhyay@intel.com> References: <20260416074958.3722666-12-tejas.upadhyay@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" To implement the ability to see allocated blocks under a specific VRAM instance in the drm driver, new api is introduced. While existing structs often show the free block list, this addition provides a comprehensive view of all currently resident VRAM allocations. Dump will look like, [ +0.000003] xe 0000:03:00.0: [drm] 0x00000002f8000000-0x00000002f8800000: 8388608 [ +0.000005] xe 0000:03:00.0: [drm] 0x00000002f8800000-0x00000002f8840000: 262144 [ +0.000004] xe 0000:03:00.0: [drm] 0x00000002f8840000-0x00000002f8860000: 131072 [ +0.000004] xe 0000:03:00.0: [drm] 0x00000002f8860000-0x00000002f8870000: 65536 [ +0.000005] xe 0000:03:00.0: [drm] 0x00000002f9000000-0x00000002f9800000: 8388608 [ +0.000004] xe 0000:03:00.0: [drm] 0x00000002f9800000-0x00000002f9880000: 524288 [ +0.000005] xe 0000:03:00.0: [drm] 0x00000002f9880000-0x00000002f9884000: 16384 [ +0.000004] xe 0000:03:00.0: [drm] 0x00000002f9900000-0x00000002f9980000: 524288 [ +0.000005] xe 0000:03:00.0: [drm] 0x00000002f9980000-0x00000002f9988000: 32768 [ +0.000004] xe 0000:03:00.0: [drm] 0x00000002f9988000-0x00000002f998c000: 16384 v2(MattB): - Add lockdep assert Signed-off-by: Tejas Upadhyay --- drivers/gpu/buddy.c | 43 +++++++++++++++++++++++++++++++++++++++ include/linux/gpu_buddy.h | 1 + 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/buddy.c b/drivers/gpu/buddy.c index 44bf926aca56..09aa4a33f928 100644 --- a/drivers/gpu/buddy.c +++ b/drivers/gpu/buddy.c @@ -10,6 +10,7 @@ #include #include +#include /** * gpu_buddy_assert - assert a condition in the buddy allocator @@ -1295,6 +1296,48 @@ int gpu_buddy_block_trim(struct gpu_buddy *mm, } EXPORT_SYMBOL(gpu_buddy_block_trim); +/** + * gpu_buddy_dump_allocated_blocks - print all allocated blocks in drm buddy + * + * @mm: DRM buddy manager to look into + * + * Looks into buddy manager for each block and their status and if allocated + * print allocated block range and size + * + * Returns: + * void + */ +void gpu_buddy_dump_allocated_blocks(struct gpu_buddy *mm) +{ + struct gpu_buddy_block *block; + LIST_HEAD(dfs); + int i; + + gpu_buddy_driver_lock_held(mm); + + for (i = 0; i < mm->n_roots; ++i) + list_add_tail(&mm->roots[i]->tmp_link, &dfs); + + do { + block = list_first_entry_or_null(&dfs, + struct gpu_buddy_block, + tmp_link); + if (!block) + break; + + list_del(&block->tmp_link); + + if (gpu_buddy_block_is_allocated(block)) + gpu_buddy_block_print(mm, block); + + if (gpu_buddy_block_is_split(block)) { + list_add(&block->right->tmp_link, &dfs); + list_add(&block->left->tmp_link, &dfs); + } + } while (1); +} +EXPORT_SYMBOL(gpu_buddy_dump_allocated_blocks); + static struct gpu_buddy_block * __gpu_buddy_alloc_blocks(struct gpu_buddy *mm, u64 start, u64 end, diff --git a/include/linux/gpu_buddy.h b/include/linux/gpu_buddy.h index e42c38a2a9f5..2834ea06da56 100644 --- a/include/linux/gpu_buddy.h +++ b/include/linux/gpu_buddy.h @@ -267,6 +267,7 @@ int gpu_buddy_block_trim(struct gpu_buddy *mm, u64 *start, u64 new_size, struct list_head *blocks); +void gpu_buddy_dump_allocated_blocks(struct gpu_buddy *mm); void gpu_buddy_reset_clear(struct gpu_buddy *mm, bool is_clear); -- 2.52.0