f24c1d7523
Implemented functions are based on Zstd streaming compression API. The functions are used in runtime to compress data that come from mmaped kernel buffer. zstd_init(), zstd_fini() are used for initialization and finalization to allocate and deallocate internal zstd objects. zstd_compress_stream_to_records() is used to convert parts of mmaped kernel buffer into an array of PERF_RECORD_COMPRESSED records. Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/18bf36f3-b85a-1fe2-dd83-10e0c6069568@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
58 lines
1.5 KiB
C
58 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef PERF_COMPRESS_H
|
|
#define PERF_COMPRESS_H
|
|
|
|
#include <stdbool.h>
|
|
#ifdef HAVE_ZSTD_SUPPORT
|
|
#include <zstd.h>
|
|
#endif
|
|
|
|
#ifdef HAVE_ZLIB_SUPPORT
|
|
int gzip_decompress_to_file(const char *input, int output_fd);
|
|
bool gzip_is_compressed(const char *input);
|
|
#endif
|
|
|
|
#ifdef HAVE_LZMA_SUPPORT
|
|
int lzma_decompress_to_file(const char *input, int output_fd);
|
|
bool lzma_is_compressed(const char *input);
|
|
#endif
|
|
|
|
struct zstd_data {
|
|
#ifdef HAVE_ZSTD_SUPPORT
|
|
ZSTD_CStream *cstream;
|
|
#endif
|
|
};
|
|
|
|
#ifdef HAVE_ZSTD_SUPPORT
|
|
|
|
int zstd_init(struct zstd_data *data, int level);
|
|
int zstd_fini(struct zstd_data *data);
|
|
|
|
size_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_t dst_size,
|
|
void *src, size_t src_size, size_t max_record_size,
|
|
size_t process_header(void *record, size_t increment));
|
|
#else /* !HAVE_ZSTD_SUPPORT */
|
|
|
|
static inline int zstd_init(struct zstd_data *data __maybe_unused, int level __maybe_unused)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int zstd_fini(struct zstd_data *data __maybe_unused)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline
|
|
size_t zstd_compress_stream_to_records(struct zstd_data *data __maybe_unused,
|
|
void *dst __maybe_unused, size_t dst_size __maybe_unused,
|
|
void *src __maybe_unused, size_t src_size __maybe_unused,
|
|
size_t max_record_size __maybe_unused,
|
|
size_t process_header(void *record, size_t increment) __maybe_unused)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif /* PERF_COMPRESS_H */
|