Design of linux server slab cache recycling solution

background

I wrote it myself to recycle slab memory ko, and insmod reported an error "shrink_slab:unknown symbol _x86_indirect_thunk_rax(err 0)";

analyze

1.Explanation of terms

In the x86 architecture, function calls usually use callinstructions to jump directly to the address of the target function. However, when you need to call a function through a function pointer or dynamic link, you need to use __x86_indirect_thunk_raxindirect jumps.

__x86_indirect_thunk_raxis an assembly code symbol used to provide an intermediate layer during indirect jumps. Its function is to load the function pointer into raxthe register and jmp raxindirectly jump to the address of the target function through the instruction.

This symbol is usually generated by the compiler and used during the linking process to resolve indirect jumps in function calls. If you encounter errors related to during compilation or linking __x86_indirect_thunk_rax, it may be caused by incorrect compiler or linker configuration.

2. Positioning reasons

shrink_slab.ko source code

static int __init shrink_slab_init(void)
{
    unsigned long (*shrink_slab)(struct shrink_control *shrink,
                          unsigned long nr_pages_scanned,
                          unsigned long lru_pages);
    struct shrink_control shrink = {
        .gfp_mask = G

Guess you like

Origin blog.csdn.net/qq_28693567/article/details/132874299