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 5F52AC7EE24 for ; Tue, 6 Jun 2023 15:25:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16D5F10E373; Tue, 6 Jun 2023 15:25:05 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id D0FD410E372 for ; Tue, 6 Jun 2023 15:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686065102; x=1717601102; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q+iz9DtovXMvGwExeqgdhrT9uhofCu2gqfFvRRLbF6o=; b=bdWYctc4tq8rdg2LXPJHKIqDxShK+GO04g84fSCNjXdG0rgrfDmbd3vg nm5ZwmLKuEVrzyuU3nWz4qStCj8+kpmW1G4LX634I5Can8WeOJvXvbk/P qXa00eOn6LqEaJNb09NCaX0E0HlGUFvc2MmdyIA7te//UYb9/2KBFWRhs 4icyiwvfyF/Cpf7/us1m+02UvDJ5S8j+FsorhbuJGKlEImZvM3ciS2RRj 4weOt0xovEo8zjisr0m7zvDjiSNkrl9bJBfhSc4ZUmaR3KckJNfAV8KLn Y4Gw+gJ+IGtCCZLVAol0iMffDXwHcLi8c9zXnjIWY677rPd1flqb9OUjc g==; X-IronPort-AV: E=McAfee;i="6600,9927,10733"; a="354205284" X-IronPort-AV: E=Sophos;i="6.00,221,1681196400"; d="scan'208";a="354205284" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2023 08:24:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10733"; a="686581970" X-IronPort-AV: E=Sophos;i="6.00,221,1681196400"; d="scan'208";a="686581970" Received: from akurkina-mobl1.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.252.4.184]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2023 08:24:56 -0700 From: Matthew Auld To: intel-xe@lists.freedesktop.org Date: Tue, 6 Jun 2023 16:24:16 +0100 Message-Id: <20230606152420.172591-2-matthew.auld@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606152420.172591-1-matthew.auld@intel.com> References: <20230606152420.172591-1-matthew.auld@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Intel-xe] [PATCH v5 1/5] drm/xe/uapi: restrict system wide accounting 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: , Cc: Filip Hazubski , Lucas De Marchi , Effie Yu , Carl Zhang Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Since this is considered an info leak (system wide accounting), rather hide behind perfmon_capable(). Signed-off-by: Matthew Auld Cc: Maarten Lankhorst Cc: Thomas Hellström Cc: Gwan-gyeong Mun Cc: Lucas De Marchi Cc: José Roberto de Souza Cc: Filip Hazubski Cc: Carl Zhang Cc: Effie Yu Cc: Gwan-gyeong Mun Reviewed-by: José Roberto de Souza Reviewed-by: Gwan-gyeong Mun --- drivers/gpu/drm/xe/xe_query.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c index c4165fa3428e..7bd073a2f348 100644 --- a/drivers/gpu/drm/xe/xe_query.c +++ b/drivers/gpu/drm/xe/xe_query.c @@ -128,7 +128,10 @@ static int query_memory_usage(struct xe_device *xe, usage->regions[0].min_page_size = PAGE_SIZE; usage->regions[0].max_page_size = PAGE_SIZE; usage->regions[0].total_size = man->size << PAGE_SHIFT; - usage->regions[0].used = ttm_resource_manager_usage(man); + if (perfmon_capable()) + usage->regions[0].used = ttm_resource_manager_usage(man); + else + usage->regions[0].used = usage->regions[0].total_size; usage->num_regions = 1; for (i = XE_PL_VRAM0; i <= XE_PL_VRAM1; ++i) { @@ -145,8 +148,16 @@ static int query_memory_usage(struct xe_device *xe, SZ_1G; usage->regions[usage->num_regions].total_size = man->size; - usage->regions[usage->num_regions++].used = - ttm_resource_manager_usage(man); + + if (perfmon_capable()) { + usage->regions[usage->num_regions].used = + ttm_resource_manager_usage(man); + } else { + usage->regions[usage->num_regions].used = + man->size; + } + + usage->num_regions++; } } -- 2.40.1