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 B58E0E7717D for ; Mon, 9 Dec 2024 20:17:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75F5010E246; Mon, 9 Dec 2024 20:17:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Mwwf0VWe"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC5E610E246 for ; Mon, 9 Dec 2024 20:17:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733775433; x=1765311433; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=1s+kRMM4zPaQx0/zohqcqZbVO1z5K8Mtpsvc8L1CQNI=; b=Mwwf0VWej+o3lbDBwEX2tbpGU2j9wMfZnzYaPwQywsnLoesdqLLIpzJl EDECjj6QNxeJEuTSk9Vu2WL43CXNuMBY1iLWOqzuKoklCpPGvhGidO0An gr4cXLgXeJfy0W9mnQ9dP3qzL1BEUfw0hoyyTxbSO7TLD67Scdlsfyubi PklWDM541rdAlUsdhHuutkY+dN9XYjB6LJGcTqVK2NZcsLcwN2pwFa8vl z3Q8C11BniycghKHy0vtjOOmXaHz3RhxvduiwPiH8VhKFzdfvob+L2BOp 5cMtw2rw6m1Gwmh/zJEl/vy+kN0kL+YtFllPATjpggQ0By+jYwEzw9JBG Q==; X-CSE-ConnectionGUID: uuBjRANcSmWHLHQ0roPeSw== X-CSE-MsgGUID: 5JSnAHq9TBOhXMFEwhRsvg== X-IronPort-AV: E=McAfee;i="6700,10204,11281"; a="34227473" X-IronPort-AV: E=Sophos;i="6.12,220,1728975600"; d="scan'208";a="34227473" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2024 12:17:12 -0800 X-CSE-ConnectionGUID: qtuLsDTQQDGH9ls6LmYokg== X-CSE-MsgGUID: k0xKcMbvSAexfnXeCBVkLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,220,1728975600"; d="scan'208";a="99995666" Received: from orsosgc001.jf.intel.com (HELO orsosgc001.intel.com) ([10.165.21.142]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2024 12:17:12 -0800 Date: Mon, 09 Dec 2024 12:17:12 -0800 Message-ID: <85h67c392v.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Sai Teja Pottumuttu Cc: Subject: Re: [PATCH i-g-t 1/1] tests/intel/xe_oa: Add test for different OA buffer sizes In-Reply-To: <20241204161606.363295-2-sai.teja.pottumuttu@intel.com> References: <20241204161606.363295-1-sai.teja.pottumuttu@intel.com> <20241204161606.363295-2-sai.teja.pottumuttu@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-redhat-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" On Wed, 04 Dec 2024 08:16:06 -0800, Sai Teja Pottumuttu wrote: > Hi Sai Teja, > Add a new test oa-buffer-size to test different OA buffer sizes, its > allocation and overflow scenarios. The test uses the new property > DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE to be able to vary the OA buffer > sizes. > > Signed-off-by: Sai Teja Pottumuttu > --- > include/drm-uapi/xe_drm.h | 8 +++++ > tests/intel/xe_oa.c | 71 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 79 insertions(+) > > diff --git a/include/drm-uapi/xe_drm.h b/include/drm-uapi/xe_drm.h > index 56163eb91..6d3ea045f 100644 > --- a/include/drm-uapi/xe_drm.h > +++ b/include/drm-uapi/xe_drm.h > @@ -1486,6 +1486,7 @@ struct drm_xe_oa_unit { > __u64 capabilities; > #define DRM_XE_OA_CAPS_BASE (1 << 0) > #define DRM_XE_OA_CAPS_SYNCS (1 << 1) > +#define DRM_XE_OA_CAPS_OA_BUFFER_SIZE (1 << 2) > > /** @oa_timestamp_freq: OA timestamp freq */ > __u64 oa_timestamp_freq; > @@ -1651,6 +1652,13 @@ enum drm_xe_oa_property_id { > * to the VM bind case. > */ > DRM_XE_OA_PROPERTY_SYNCS, > + > + /** > + * @DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE: Specifies the size of OA buffer > + * allocated by the driver in bytes. The default size would be 16MB and the > + * supported sizes are powers of 2 from 128KB to 128MB. > + */ > + DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE, OK for now but finally, when we merge this, this uapi change will need to come in via a separate commit which syncs IGT uapi headers with kernel headers. You can see previous IGT commits for this file. We can easily take care of this after the kernel patch is merged. And then we can merge the remainder of this patch. > }; > > /** > diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c > index 40f5d3607..abe0d2cc3 100644 > --- a/tests/intel/xe_oa.c > +++ b/tests/intel/xe_oa.c > @@ -2504,6 +2504,60 @@ again_1: > __perf_close(stream_fd); > } > > +/** > + * SUBTEST: oa-buffer-size > + * Description: Test OA buffer allocation and overflow with different OA buffer sizes. > + */ > +static void test_oa_buffer_size(size_t oa_buffer_size) > +{ > + int oa_exponent = max_oa_exponent_for_period_lte(20000); > + uint64_t properties[] = { > + DRM_XE_OA_PROPERTY_OA_UNIT_ID, 0, > + > + /* Include OA reports in samples */ > + DRM_XE_OA_PROPERTY_SAMPLE_OA, true, > + > + /* OA unit configuration */ > + DRM_XE_OA_PROPERTY_OA_METRIC_SET, default_test_set->perf_oa_metrics_set, > + DRM_XE_OA_PROPERTY_OA_FORMAT, __ff(default_test_set->perf_oa_format), > + DRM_XE_OA_PROPERTY_OA_PERIOD_EXPONENT, oa_exponent, > + > + DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE, oa_buffer_size > + }; > + struct intel_xe_oa_open_prop param = { > + .num_properties = ARRAY_SIZE(properties) / 2, > + .properties_ptr = to_user_pointer(properties), > + }; > + uint32_t buf_size = 2 * oa_buffer_size; > + uint8_t *buf = malloc(buf_size); > + struct drm_xe_oa_stream_info info; > + uint32_t total_len = 0; > + int len; > + u32 oa_status; > + > + igt_assert(buf); > + > + stream_fd = __perf_open(drm_fd, ¶m, true); > + > + do_ioctl(stream_fd, DRM_XE_OBSERVATION_IOCTL_INFO, &info); > + igt_assert_eq(oa_buffer_size, info.oa_buf_size); > + > + while (total_len < buf_size && > + ((len = read(stream_fd, &buf[total_len], buf_size - total_len)) > 0 || > + (len == -1 && (errno == EINTR || errno == EIO)))) { > + if (errno == EIO) { > + oa_status = get_stream_status(stream_fd); > + igt_debug("oa_status %#x\n", oa_status); > + igt_assert(!(oa_status & DRM_XE_OASTATUS_BUFFER_OVERFLOW)); > + } > + if (len > 0) > + total_len += len; > + } > + > + __perf_close(stream_fd); > + free(buf); The problem I am seeing here is we are not really checking for anything. How about adding buffer size to the non-zero-reason subtest and try to reuse that? Also, $ sudo ./build/tests/xe_oa --r oa-buffer-size IGT-Version: 1.29-g724fd0b79 (x86_64) (Linux: 6.12.0-rc4+ x86_64) Using IGT_SRANDOM=1733459091 for randomisation Opened device: /dev/dri/card0 Starting subtest: oa-buffer-size Starting dynamic subtest: 8MB Dynamic subtest 8MB: SUCCESS (0.403s) Starting dynamic subtest: 32MB Dynamic subtest 32MB: SUCCESS (1.595s) Starting dynamic subtest: 128MB Dynamic subtest 128MB: SUCCESS (6.326s) Subtest oa-buffer-size: SUCCESS (8.324s) So maybe 128 MB takes too long to run, maybe we could do 8, 16 and 32 MB? Or even just two. So if we are able to reuse non-zero-reason subtest without issues it would become two or three subtests: non-zero-reason-8MB non-zero-reason-16MB non-zero-reason-32MB Or similar, say using dynamic subtests. We'll also need to time these and see how long they take to run. We can even look at 64 and 128 MB times and then decide. Thanks. -- Ashutosh