flt.lttng-utils.debug-info: Implement file descriptor cache
A `flt.lttng-utils.debug-info` component has to open files in order to
do the address resolving when processing a trace. Those file descriptors
are currently associated with a bin_info structure which are stored in a
hash table for each vpid. If, in the same trace, a binary file is loaded
by more than one process, that binary file will be opened twice. This
can create a file descriptor exhaustion problem on long running traces
if the same UST apps are run repeatedly.
This commit implements a file descriptor caching feature to reuse file
descriptors pointing to the same files.
After creating the file descriptor cache (fdcache), users must use the
following two functions to get and put handles to file descriptors:
struct fd_handle *fd_cache_get_handle(struct fd_cache *fdc, char *path);
void fd_cache_put_handle(struct fd_cache *fdc, struct fd_handle *handle);
The fd_handles are reference counted internally and their corresponding
file descriptors are closed when the refcount reaches zero.
Files are compared based on the hashed values of inode and device number
rather than solely on the path. This is needed to make sure that a file
opened previously has not changed. This is more likely to happen when
processing a lttng-live trace where the following scenario can happen
and must be supported:
1. Binary v1 is executed,
2. Trace data received by debug-info component,
3. Handle 1 is taken on the bin_a v1 file,
4. Addresses resolved using handle 1,
5. Binary is modified,
6. Binary v2 is compiled,
7. Binary v2 is executed,
8. Trace data received by debug-info component,
9. Handle 2 is taken on the bin_a v2 file,
10. Addresses resolved using handle 2.
Limitation
----------
It's still be possible to exhaust file descriptors in traces with a
large number of UST apps with no binary file overlap. If this becomes a
problem, we may consider devising an utility to close least recently
used files and reopening file descriptors for later used.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
14 files changed:
This page took 0.025771 seconds and 4 git commands to generate.