extern struct prog_test_ref_kfunc *
 bpf_kfunc_call_test_kptr_get(struct prog_test_ref_kfunc **p, int a, int b) __ksym;
 extern void bpf_kfunc_call_test_release(struct prog_test_ref_kfunc *p) __ksym;
+void bpf_kfunc_call_test_ref(struct prog_test_ref_kfunc *p) __ksym;
 
 #define WRITE_ONCE(x, val) ((*(volatile typeof(x) *) &(x)) = (val))
 
        WRITE_ONCE(v->unref_ptr, p);
        if (!p)
                return;
+       /*
+        * p is rcu_ptr_prog_test_ref_kfunc,
+        * because bpf prog is non-sleepable and runs in RCU CS.
+        * p can be passed to kfunc that requires KF_RCU.
+        */
+       bpf_kfunc_call_test_ref(p);
        if (p->a + p->b > 100)
                return;
        /* store NULL */
        p = bpf_kptr_xchg(&v->ref_ptr, NULL);
        if (!p)
                return;
+       /*
+        * p is trusted_ptr_prog_test_ref_kfunc.
+        * p can be passed to kfunc that requires KF_RCU.
+        */
+       bpf_kfunc_call_test_ref(p);
        if (p->a + p->b > 100) {
                bpf_kfunc_call_test_release(p);
                return;