Merge pull request #1343 from siliceum/fix/better-tracefs-detection

Better tracefs detection
This commit is contained in:
Bartosz Taudul
2026-04-21 11:55:10 +02:00
committed by GitHub

View File

@@ -558,14 +558,27 @@ static char* GetTraceFsPath()
char* ret = nullptr;
while( auto ent = getmntent( f ) )
{
if( strcmp( ent->mnt_fsname, "tracefs" ) == 0 )
if( strcmp( ent->mnt_type, "tracefs" ) == 0 )
{
auto len = strlen( ent->mnt_dir );
ret = (char*)tracy_malloc( len + 1 );
// ret may be != nullptr if we already saw a debugfs entry
ret = (char*)tracy_realloc( ret, len + 1 );
memcpy( ret, ent->mnt_dir, len );
ret[len] = '\0';
break;
}
else if( !ret && strcmp( ent->mnt_type, "debugfs" ) == 0 )
{
const char* tracingDirName = "tracing";
const size_t tracingDirNameLen = strlen( tracingDirName );
auto debugFsPathLen = strlen( ent->mnt_dir );
ret = (char*)tracy_malloc( debugFsPathLen + 1 + tracingDirNameLen + 1 );
memcpy( ret, ent->mnt_dir, debugFsPathLen );
ret[debugFsPathLen] = '/';
memcpy( ret + debugFsPathLen + 1, tracingDirName, tracingDirNameLen );
ret[debugFsPathLen + 1 + tracingDirNameLen] = '\0';
// Don't break to allow for tracefs to be found later as it is the preferred path
}
}
endmntent( f );
return ret;
@@ -578,15 +591,21 @@ bool SysTraceStart( int64_t& samplingPeriod )
#endif
const auto paranoidLevelStr = ReadFile( "/proc/sys/kernel/perf_event_paranoid" );
if( !paranoidLevelStr ) return false;
#ifdef TRACY_VERBOSE
int paranoidLevel = 2;
paranoidLevel = atoi( paranoidLevelStr );
if( !paranoidLevelStr )
{
TracyDebug( "Failed to read perf_event_paranoid, cannot setup system tracing." );
return false;
}
const int paranoidLevel = atoi( paranoidLevelStr );
TracyDebug( "perf_event_paranoid: %i", paranoidLevel );
#endif
auto traceFsPath = GetTraceFsPath();
if( !traceFsPath ) return false;
if( !traceFsPath )
{
TracyDebug( "Failed to get tracefs path, cannot setup system tracing." );
return false;
}
TracyDebug( "tracefs path: %s", traceFsPath );
int switchId = -1, wakingId = -1, vsyncId = -1;