crypto/acompress.c
Source file repositories/reference/linux-study-clean/crypto/acompress.c
File Facts
- System
- Linux kernel
- Corpus path
crypto/acompress.c- Extension
.c- Size
- 13590 bytes
- Lines
- 579
- Domain
- Kernel Services
- Bucket
- crypto
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/internal/acompress.hcrypto/scatterwalk.hlinux/cryptouser.hlinux/cpumask.hlinux/err.hlinux/kernel.hlinux/module.hlinux/percpu.hlinux/scatterlist.hlinux/sched.hlinux/seq_file.hlinux/smp.hlinux/spinlock.hlinux/string.hlinux/workqueue.hnet/netlink.hcompress.h
Detected Declarations
struct crypto_scompfunction crypto_acomp_reportfunction crypto_acomp_showfunction crypto_acomp_exit_tfmfunction crypto_acomp_init_tfmfunction crypto_acomp_extsizefunction acomp_save_reqfunction acomp_restore_reqfunction acomp_reqchain_virtfunction acomp_virt_to_sgfunction acomp_do_nondmafunction acomp_do_one_reqfunction acomp_reqchain_finishfunction acomp_reqchain_donefunction acomp_do_req_chainfunction crypto_acomp_compressfunction crypto_acomp_decompressfunction comp_prepare_algfunction crypto_register_acompfunction crypto_unregister_acompfunction crypto_register_acompsfunction crypto_unregister_acompsfunction acomp_stream_workfnfunction for_each_cpufunction crypto_acomp_free_streamsfunction for_each_possible_cpufunction crypto_acomp_alloc_streamsfunction for_each_possible_cpufunction acomp_walk_done_srcfunction acomp_walk_done_dstfunction acomp_walk_next_srcfunction acomp_walk_next_dstfunction acomp_walk_virtexport crypto_alloc_acompexport crypto_alloc_acomp_nodeexport crypto_acomp_compressexport crypto_acomp_decompressexport crypto_register_acompexport crypto_unregister_acompexport crypto_register_acompsexport crypto_unregister_acompsexport crypto_acomp_free_streamsexport crypto_acomp_alloc_streamsexport _crypto_acomp_lock_stream_bhexport acomp_walk_done_srcexport acomp_walk_done_dstexport acomp_walk_next_srcexport acomp_walk_next_dst
Annotated Snippet
if (ret) {
crypto_unregister_acomps(algs, i);
return ret;
}
}
return 0;
}
EXPORT_SYMBOL_GPL(crypto_register_acomps);
void crypto_unregister_acomps(struct acomp_alg *algs, int count)
{
int i;
for (i = count - 1; i >= 0; --i)
crypto_unregister_acomp(&algs[i]);
}
EXPORT_SYMBOL_GPL(crypto_unregister_acomps);
static void acomp_stream_workfn(struct work_struct *work)
{
struct crypto_acomp_streams *s =
container_of(work, struct crypto_acomp_streams, stream_work);
struct crypto_acomp_stream __percpu *streams = s->streams;
int cpu;
for_each_cpu(cpu, &s->stream_want) {
struct crypto_acomp_stream *ps;
void *ctx;
ps = per_cpu_ptr(streams, cpu);
if (ps->ctx)
continue;
ctx = s->alloc_ctx();
if (IS_ERR(ctx))
break;
spin_lock_bh(&ps->lock);
ps->ctx = ctx;
spin_unlock_bh(&ps->lock);
cpumask_clear_cpu(cpu, &s->stream_want);
}
}
void crypto_acomp_free_streams(struct crypto_acomp_streams *s)
{
struct crypto_acomp_stream __percpu *streams = s->streams;
void (*free_ctx)(void *);
int i;
s->streams = NULL;
if (!streams)
return;
cancel_work_sync(&s->stream_work);
free_ctx = s->free_ctx;
for_each_possible_cpu(i) {
struct crypto_acomp_stream *ps = per_cpu_ptr(streams, i);
if (!ps->ctx)
continue;
free_ctx(ps->ctx);
}
free_percpu(streams);
}
EXPORT_SYMBOL_GPL(crypto_acomp_free_streams);
int crypto_acomp_alloc_streams(struct crypto_acomp_streams *s)
{
struct crypto_acomp_stream __percpu *streams;
struct crypto_acomp_stream *ps;
unsigned int i;
void *ctx;
if (s->streams)
return 0;
streams = alloc_percpu(struct crypto_acomp_stream);
if (!streams)
return -ENOMEM;
ctx = s->alloc_ctx();
if (IS_ERR(ctx)) {
free_percpu(streams);
return PTR_ERR(ctx);
Annotation
- Immediate include surface: `crypto/internal/acompress.h`, `crypto/scatterwalk.h`, `linux/cryptouser.h`, `linux/cpumask.h`, `linux/err.h`, `linux/kernel.h`, `linux/module.h`, `linux/percpu.h`.
- Detected declarations: `struct crypto_scomp`, `function crypto_acomp_report`, `function crypto_acomp_show`, `function crypto_acomp_exit_tfm`, `function crypto_acomp_init_tfm`, `function crypto_acomp_extsize`, `function acomp_save_req`, `function acomp_restore_req`, `function acomp_reqchain_virt`, `function acomp_virt_to_sg`.
- Atlas domain: Kernel Services / crypto.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.