Add debug flag to print called ioctls

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2021-04-22 13:37:02 +00:00
committed by Compute-Runtime-Automation
parent 8deb4bcdba
commit 3521d89106
4 changed files with 29 additions and 0 deletions

View File

@ -157,6 +157,23 @@ TEST(DrmTest, GivenSelectedExistingDeviceWhenOpenDirFailsThenRetryOpeningRenderD
EXPECT_STREQ("00:03.0", hwDeviceIds[1]->getPciPath());
}
TEST(DrmTest, givenPrintIoctlEntriesWhenCallIoctlThenIoctlIsPrinted) {
::testing::internal::CaptureStdout();
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = DrmWrap::createDrm(*executionEnvironment->rootDeviceEnvironments[0]);
DebugManagerStateRestore restorer;
DebugManager.flags.PrintIoctlEntries.set(true);
uint32_t contextId = 1u;
drm->destroyDrmContext(contextId);
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.c_str(), "IOCTL 1074291822 called\nIOCTL 1074291822 returns 0, errno 9\n");
}
TEST(DrmTest, givenPrintIoctlTimesWhenCallIoctlThenStatisticsAreGathered) {
struct DrmMock : public Drm {
using Drm::ioctlStatistics;

View File

@ -220,6 +220,7 @@ EnableHostUsmSupport = -1
ForceBtpPrefetchMode = -1
OverrideProfilingTimerResolution = -1
PrintIoctlTimes = 0
PrintIoctlEntries = 0
UpdateTaskCountFromWait = -1
PreferCopyEngineForCopyBufferToBuffer = -1
EnableStaticPartitioning = -1

View File

@ -129,6 +129,7 @@ DECLARE_DEBUG_VARIABLE(bool, PrintTagAllocationAddress, false, "Print tag alloca
DECLARE_DEBUG_VARIABLE(bool, ProvideVerboseImplicitFlush, false, "provides verbose messages about implicit flush mechanism")
DECLARE_DEBUG_VARIABLE(bool, PrintBlitDispatchDetails, false, "Print blit dispatch details")
DECLARE_DEBUG_VARIABLE(bool, PrintIoctlTimes, false, "Print ioctl times")
DECLARE_DEBUG_VARIABLE(bool, PrintIoctlEntries, false, "Print ioctl being called")
/*PERFORMANCE FLAGS*/
DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForBuffers, false, "When active all buffer allocations will not share memory with CPU.")

View File

@ -77,8 +77,18 @@ int Drm::ioctl(unsigned long request, void *arg) {
start = std::chrono::steady_clock::now();
}
auto printIoctl = DebugManager.flags.PrintIoctlEntries.get();
if (printIoctl) {
printf("IOCTL %lu called\n", request);
}
ret = SysCalls::ioctl(getFileDescriptor(), request, arg);
if (printIoctl) {
printf("IOCTL %lu returns %d, errno %d\n", request, ret, errno);
}
if (measureTime) {
end = std::chrono::steady_clock::now();
auto elapsedTime = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();