Skip to content

Support sd_mod being compiled as module#4

Open
p12tic wants to merge 2 commits intogeppi:mainfrom
p12tic:support-sd-mod-as-module
Open

Support sd_mod being compiled as module#4
p12tic wants to merge 2 commits intogeppi:mainfrom
p12tic:support-sd-mod-as-module

Conversation

@p12tic
Copy link
Contributor

@p12tic p12tic commented Oct 7, 2025

Currently trying to use zolspinup on a system where sd_mod module is compiled as a module fails with the following error:

bpf: sd_resume_runtime is not found in vmlinux BTF
...
Exception: Failed to load BPF program b'kfunc__vmlinux__sd_resume_runtime': No such file or directory

This is because when the target function is in a module, the eBPF program must use MODULE_KFUNC_PROBE instead of KFUNC_PROBE.

This commit adds support for both cases by checking whether sd_mod is loaded as a module and if yes, using MODULE_KFUNC_PROBE-based eBPF program.

sd_mod is compiled as a module in popular Linux distributions by default, such as on Debian Bookworm and Trixie (BLK_DEV_SD=m).

@p12tic p12tic force-pushed the support-sd-mod-as-module branch from 1ca2cb7 to 35f56af Compare October 7, 2025 22:39
@geppi
Copy link
Owner

geppi commented Oct 16, 2025

Could you please elaborate a little on the issue that this PR is supposed to fix?

Currently trying to use zolspinup on a system where sd_mod module is
compiled as a module fails with the following error:

bpf: sd_resume_runtime is not found in vmlinux BTF
...
Exception: Failed to load BPF program
b'kfunc__vmlinux__sd_resume_runtime': No such file or directory

This is because when the target function is in a module, the eBPF
program must use MODULE_KFUNC_PROBE instead of KFUNC_PROBE.

This commit adds support for both cases by checking whether sd_mod is
loaded as a module and if yes, using MODULE_KFUNC_PROBE-based eBPF
program.

sd_mod is compiled as a module in popular Linux distributions by
default, such as on Debian Bookworm and Trixie (BLK_DEV_SD=m).
@p12tic p12tic force-pushed the support-sd-mod-as-module branch from 35f56af to a45fcbc Compare October 21, 2025 18:49
@p12tic
Copy link
Contributor Author

p12tic commented Oct 21, 2025

@geppi I am sorry for producing poor PR and commit description the first time. I've now updated both to include full information about what the problem was.

Please let me know if I could improve them more.

@p12tic
Copy link
Contributor Author

p12tic commented Nov 1, 2025

@geppi Just a friendly ping :-)

@geppi
Copy link
Owner

geppi commented Nov 5, 2025

Sorry, I'm currently a little bit swamped. It's not forgotten.

Copy link
Owner

@geppi geppi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a nice improvement.
However, in this form the PR does create a large diff for a small change in the BPF program strings.
I would prefer a diff that highlights what really had to be changed to implement the improvement.

)
else:
eBPF_program = ZpoolRpmManager.eBPF_resume_monitor
eBPF_program = self.__get_eBPF_resume_monitor()
Copy link
Owner

@geppi geppi Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional replace operation on the strings could be directly performed in the start_monitor method in the above if/else statement like

    )
else:
    if self.__is_sd_mod_module:
        eBPF_program = ZpoolRpmManager.eBPF_resume_monitor.replace('KFUNC_PROBE(', 'MODULE_KFUNC_PROBE(sd_mod, ')
    else:
        eBPF_program = ZpoolRpmManager.eBPF_resume_monitor

Also adding a log message in the init method that tells when the module was detected would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants