Manuel
Manuel

Reputation: 831

Linux kernel: fastest way to copy small amounts of data

I'm refactoring the kernel's LZO compression code. It happens often that small bits of data is copied from one buffer to another. The usual length of such a copy operation is either 4, 8, or 16 bytes long.

What's the best way to perform these operations? Is it memcpy or are there specific functions for these small buffer sizes that can make use of CPU opcodes in case they are supported?

Upvotes: 1

Views: 1414

Answers (1)

CL.
CL.

Reputation: 180040

The best way to perform these operation is with mempcy, because the compiler is able to implement them with direct assignments if the size is a constant.

Upvotes: 2

Related Questions