Page MenuHomeFreeBSD

linuxkpi: Add shrinker support
ClosedPublic

Authored by manu on Dec 22 2020, 6:19 PM.

Details

Summary

A driver can register a shrinker that will be called when the kernel
wants to free some memory.
Add support for that in linuxkpi and call the registered shrinkers
when the lowmem event is triggered.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

manu requested review of this revision.Dec 22 2020, 6:19 PM
bz added inline comments.
sys/compat/linuxkpi/common/src/linux_shrinker.c
47

I always wonder if we should document that fields are initialised by at least adding KASSERT()s?
I guess I've been calling too many NULL function pointers lately elsewhere which were never initialised or checked on registration.

70

batch is not needed until line 79; can it be initialised after the initial return?

77

No { } needed.

107

Long line.

sys/compat/linuxkpi/common/src/linux_shrinker.c
47

you mean adding something like KASSERT(s->count_objects == NULL, ...) ?
Anyway yeah I think that I should check that both function pointer are not NULL here.

70

Will change.

77

printf debugging leftover :)
I'll change that.

107

Will change.

manu marked 4 inline comments as done.

Looks good scrolling through now.

This revision is now accepted and ready to land.Jan 2 2021, 1:56 PM
This revision was automatically updated to reflect the committed changes.