mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 13:34:10 +08:00
19f545b6e0
The zcomp driver uses per-CPU compression. The per-CPU data pointer is acquired with get_cpu_ptr() which implicitly disables preemption. It allocates memory inside the preempt disabled region which conflicts with the PREEMPT_RT semantics. Replace the implicit preemption control with an explicit local lock. This allows RT kernels to substitute it with a real per CPU lock, which serializes the access but keeps the code section preemptible. On non RT kernels this maps to preempt_disable() as before, i.e. no functional change. [bigeasy: Use local_lock(), description, drop reordering] Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20200527201119.1692513-8-bigeasy@linutronix.de
44 lines
1.2 KiB
C
44 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2014 Sergey Senozhatsky.
|
|
*/
|
|
|
|
#ifndef _ZCOMP_H_
|
|
#define _ZCOMP_H_
|
|
#include <linux/local_lock.h>
|
|
|
|
struct zcomp_strm {
|
|
/* The members ->buffer and ->tfm are protected by ->lock. */
|
|
local_lock_t lock;
|
|
/* compression/decompression buffer */
|
|
void *buffer;
|
|
struct crypto_comp *tfm;
|
|
};
|
|
|
|
/* dynamic per-device compression frontend */
|
|
struct zcomp {
|
|
struct zcomp_strm __percpu *stream;
|
|
const char *name;
|
|
struct hlist_node node;
|
|
};
|
|
|
|
int zcomp_cpu_up_prepare(unsigned int cpu, struct hlist_node *node);
|
|
int zcomp_cpu_dead(unsigned int cpu, struct hlist_node *node);
|
|
ssize_t zcomp_available_show(const char *comp, char *buf);
|
|
bool zcomp_available_algorithm(const char *comp);
|
|
|
|
struct zcomp *zcomp_create(const char *comp);
|
|
void zcomp_destroy(struct zcomp *comp);
|
|
|
|
struct zcomp_strm *zcomp_stream_get(struct zcomp *comp);
|
|
void zcomp_stream_put(struct zcomp *comp);
|
|
|
|
int zcomp_compress(struct zcomp_strm *zstrm,
|
|
const void *src, unsigned int *dst_len);
|
|
|
|
int zcomp_decompress(struct zcomp_strm *zstrm,
|
|
const void *src, unsigned int src_len, void *dst);
|
|
|
|
bool zcomp_set_max_streams(struct zcomp *comp, int num_strm);
|
|
#endif /* _ZCOMP_H_ */
|