For CONFIG_BUILD_KERNEL using the sched/task/task_exithook implementation will just not work. It calls user code with kernel privileges which is a bit of a security issue.