mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 17:41:22 +00:00
5940a20a18
Zstd streams create dictionaries that can require significant RAM, especially when there is one per-CPU. Tools like 'perf record' won't use the streams without the -z option, and so the creation of the streams is pure overhead. Switch to creating the streams on first use. Committer notes: ssize_t comes from sys/types.h, size_t from stddef.h. This worked on glibc as stdlib.h includes both, but not on musl libc. So do what 'man size_t' says and include sys/types.h and stddef.h instead of stdlib.h Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com> Cc: Changbin Du <changbin.du@huawei.com> Cc: Colin Ian King <colin.i.king@gmail.com> Cc: Dmitrii Dolgov <9erthalion6@gmail.com> Cc: German Gomez <german.gomez@arm.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: K Prateek Nayak <kprateek.nayak@amd.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Li Dong <lidong@vivo.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Ming Wang <wangming01@loongson.cn> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Nick Terrell <terrelln@fb.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Steinar H. Gunderson <sesse@google.com> Cc: Vincent Whitchurch <vincent.whitchurch@axis.com> Cc: Wenyu Liu <liuwenyu7@huawei.com> Cc: Yang Jihong <yangjihong1@huawei.com> Link: https://lore.kernel.org/r/20231102175735.2272696-5-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
72 lines
1.9 KiB
C
72 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef PERF_COMPRESS_H
|
|
#define PERF_COMPRESS_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <sys/types.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;
|
|
ZSTD_DStream *dstream;
|
|
int comp_level;
|
|
#endif
|
|
};
|
|
|
|
#ifdef HAVE_ZSTD_SUPPORT
|
|
|
|
int zstd_init(struct zstd_data *data, int level);
|
|
int zstd_fini(struct zstd_data *data);
|
|
|
|
ssize_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));
|
|
|
|
size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size,
|
|
void *dst, size_t dst_size);
|
|
#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
|
|
ssize_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;
|
|
}
|
|
|
|
static inline size_t zstd_decompress_stream(struct zstd_data *data __maybe_unused, void *src __maybe_unused,
|
|
size_t src_size __maybe_unused, void *dst __maybe_unused,
|
|
size_t dst_size __maybe_unused)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif /* PERF_COMPRESS_H */
|