[rocprofv3] signal handler fix (#332)

* rocprofv3: LD_PRELOAD for signal and sigaction

- wrappers around `signal` and `sigaction` to prevent applications which install signal handlers to replace the rocprofv3 signal handlers
- minor tweaks to buffer sizes (use page_size instead of
KiB)

* [DO NOT COMMIT] extra logging

* Switch git submodule url for perfetto

- use GitHub URL as this is more accessible

* Update ring_buffer<Tp>

- account for alignment padding

* Update buffered_output

- track number of bytes stored
- add nullptr checks

* Update tmp_file_buffer

- track number of bytes
- read_tmp_file does not create tmp file if it does not already exist

* Update tmp_file

- add exists member function for checking whether temporary file already exists
- tweak remove() implementation

* Update config.hpp

- add option to enable/disable signal handlers
- add option for minimum_output_bytes

* Make signal, sigaction functions visible

* rocprofv3 tool updates

- chained signals
- override the signal handler(s) installed by the application
- improve cleanup of temporary files
- support minimum output bytes

* Add commandline support

* fixing test

* minor fix

* minor fix

* fix clang issue

* fix

* Adding docs

* review comments

* review changes

* review

* YUV pulldown additions to rocdecode

* More rocdecode changes

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Co-authored-by: Jonathan R. Madsen <Jonathan.Madsen@amd.com>
Co-authored-by: Benjamin Welton <bewelton@amd.com>
This commit is contained in:
Nagaraj, Sriraksha
2025-04-17 23:10:52 -05:00
committed by GitHub
parent 46818b0167
commit 87badfbd15
22 changed files with 866 additions and 107 deletions
+28 -8
View File
@@ -300,7 +300,7 @@ struct ring_buffer : private base::ring_buffer
~ring_buffer() = default;
explicit ring_buffer(size_t _size)
: base_type{_size * sizeof(Tp)}
: base_type{_size * aligned_data_size()}
{}
ring_buffer(const ring_buffer&);
@@ -313,16 +313,19 @@ struct ring_buffer : private base::ring_buffer
bool is_initialized() const { return base_type::is_initialized(); }
/// Get the total number of Tp instances supported
size_t capacity() const { return (base_type::capacity()) / sizeof(Tp); }
size_t capacity() const { return (base_type::capacity()) / aligned_data_size(); }
/// Creates new ring buffer.
void init(size_t _size) { base_type::init(_size * sizeof(Tp)); }
void init(size_t _size) { base_type::init(_size * aligned_data_size()); }
/// Destroy ring buffer.
void destroy() { base_type::destroy(); }
/// Write data to buffer.
size_t data_size() const { return sizeof(Tp); }
/// Size of the data type
static constexpr size_t data_size() { return sizeof(Tp); }
/// Size of the data type + padding
static constexpr size_t aligned_data_size();
/// Write data to buffer. Return pointer to location of write
Tp* write(Tp* in) { return base_type::write<Tp>(in).second; }
@@ -337,16 +340,16 @@ struct ring_buffer : private base::ring_buffer
Tp* retrieve() { return base_type::retrieve<Tp>(); }
/// Returns number of Tp instances currently held by the buffer.
size_t count() const { return (base_type::count()) / sizeof(Tp); }
size_t count() const { return (base_type::count()) / aligned_data_size(); }
/// Returns how many Tp instances are availiable in the buffer.
size_t free() const { return (base_type::free()) / sizeof(Tp); }
size_t free() const { return (base_type::free()) / aligned_data_size(); }
/// Returns if the buffer is empty.
bool is_empty() const { return base_type::is_empty(); }
/// Returns if the buffer is full.
bool is_full() const { return (base_type::free() < sizeof(Tp)); }
bool is_full() const { return (base_type::free() < aligned_data_size()); }
bool clear() { return base_type::clear(); }
@@ -365,6 +368,7 @@ struct ring_buffer : private base::ring_buffer
std::ostringstream ss{};
size_t _w = std::log10(base_type::capacity()) + 1;
ss << std::boolalpha << std::right << "data size: " << std::setw(_w) << data_size()
<< "B, aligned data size: " << std::setw(_w) << aligned_data_size()
<< " B, is_initialized: " << std::setw(5) << is_initialized()
<< ", is_empty: " << std::setw(5) << is_empty() << ", is_full: " << std::setw(5)
<< is_full() << ", capacity: " << std::setw(_w) << capacity()
@@ -392,6 +396,22 @@ ring_buffer<Tp>::get_items_per_page()
}
//
template <typename Tp>
constexpr size_t
ring_buffer<Tp>::aligned_data_size()
{
constexpr auto _data_size = sizeof(Tp);
constexpr auto _data_align = alignof(Tp);
constexpr auto _align_modulo = _data_size % _data_align;
constexpr auto _result =
(_align_modulo == 0) ? _data_size : (_data_size + (_data_align - _align_modulo));
static_assert(_result >= _data_size && _result < (_data_size + _data_align),
"should neither be < sizeof(Tp) nor > sizeof(Tp) + alignof(Tp)");
return _result;
}
//
template <typename Tp>
ring_buffer<Tp>::ring_buffer(const ring_buffer<Tp>& rhs)
: base_type{rhs}
{