BpfMap: remove @CriticalNative from nativeSynchronizeKernelRCU()

There's been some reports that this can cause process termination due
to gc/sleep logic thinking the thread is stuck for >4s.

While this implies that RCU is stuck for >4s, maybe this is something
that can happen on lower power devices.

It seems prudent to (at least temporarily) revert back to the old
non-CriticalNative behaviour.

Test: TreeHugger
Flag: EXEMPT mainline, bugfix
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I56b2802132f252a02411a9a8f762d98ab2f336ad
This commit is contained in:
Maciej Żenczykowski 2025-09-11 12:37:26 -07:00
commit 1e1d336141
2 changed files with 2 additions and 4 deletions

View file

@ -28,7 +28,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import dalvik.annotation.optimization.CriticalNative;
import dalvik.annotation.optimization.FastNative;
import java.util.NoSuchElementException;
@ -304,6 +303,5 @@ public class BpfMap<K extends Struct, V extends Struct> implements IBpfMap<K, V>
private native boolean nativeFindMapEntry(int fd, byte[] key, byte[] value)
throws ErrnoException;
@CriticalNative
private static native int nativeSynchronizeKernelRCU();
}

View file

@ -136,7 +136,8 @@ static jboolean com_android_net_module_util_BpfMap_nativeFindMapEntry(JNIEnv *en
return throwIfNotEnoent(env, "nativeFindMapEntry", ret, errno);
}
static jint com_android_net_module_util_BpfMap_nativeSynchronizeKernelRCU() {
static jint com_android_net_module_util_BpfMap_nativeSynchronizeKernelRCU(JNIEnv *env,
jclass clazz) {
const int pfSocket = socket(AF_KEY, SOCK_RAW | SOCK_CLOEXEC, PF_KEY_V2);
if (pfSocket < 0) return -errno;
// On Linux close() will always close the fd, any error it returns is a previous pending error.
@ -196,7 +197,6 @@ static const JNINativeMethod gBpfMapMethods[] = {
(void*) com_android_net_module_util_BpfMap_nativeGetNextMapKey },
{ "nativeFindMapEntry", "(I[B[B)Z",
(void*) com_android_net_module_util_BpfMap_nativeFindMapEntry },
// CriticalNative
{ "nativeSynchronizeKernelRCU", "()I",
(void*) com_android_net_module_util_BpfMap_nativeSynchronizeKernelRCU },