[PATCH bpf] bpf: add schedule point in htab_init_buckets()

Subsystems: bpf [general] (safe dynamic programs and tools), the rest

STALE2091d LANDED

Landed in mainline as e7e518053c26 on 2020-12-21.

3 messages, 3 authors, 2020-12-21 · open the first message on its own page

[PATCH bpf] bpf: add schedule point in htab_init_buckets()

From: Eric Dumazet <hidden>
Date: 2020-12-21 19:26:02

From: Eric Dumazet <edumazet@google.com>

We noticed that with a LOCKDEP enabled kernel,
allocating a hash table with 65536 buckets would
use more than 60ms.

htab_init_buckets() runs from process context,
it is safe to schedule to avoid latency spikes.

Fixes: c50eb518e262 ("bpf: Use separate lockdep class for each hashtab")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-By: John Sperbeck <redacted>
Cc: Song Liu <redacted>
---
 kernel/bpf/hashtab.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index 7e848200cd268a0f9ed063f0b641d3c355787013..c1ac7f964bc997925fd427f5192168829d812e5d 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -152,6 +152,7 @@ static void htab_init_buckets(struct bpf_htab *htab)
 			lockdep_set_class(&htab->buckets[i].lock,
 					  &htab->lockdep_key);
 		}
+		cond_resched();
 	}
 }
 
-- 
2.29.2.729.g45daf8777d-goog

Re: [PATCH bpf] bpf: add schedule point in htab_init_buckets()

From: Song Liu <hidden>
Date: 2020-12-21 20:55:57

On Dec 21, 2020, at 11:25 AM, Eric Dumazet [off-list ref] wrote:

From: Eric Dumazet <edumazet@google.com>

We noticed that with a LOCKDEP enabled kernel,
allocating a hash table with 65536 buckets would
use more than 60ms.

htab_init_buckets() runs from process context,
it is safe to schedule to avoid latency spikes.

Fixes: c50eb518e262 ("bpf: Use separate lockdep class for each hashtab")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-By: John Sperbeck <redacted>
Cc: Song Liu <redacted>
Acked-by: Song Liu <redacted>

Thanks for the fix!
quoted hunk
---
kernel/bpf/hashtab.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index 7e848200cd268a0f9ed063f0b641d3c355787013..c1ac7f964bc997925fd427f5192168829d812e5d 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -152,6 +152,7 @@ static void htab_init_buckets(struct bpf_htab *htab)
			lockdep_set_class(&htab->buckets[i].lock,
					  &htab->lockdep_key);
		}
+		cond_resched();
	}
}

-- 
2.29.2.729.g45daf8777d-goog

Re: [PATCH bpf] bpf: add schedule point in htab_init_buckets()

From: patchwork-bot+netdevbpf@kernel.org
Date: 2020-12-21 23:20:48

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

On Mon, 21 Dec 2020 11:25:06 -0800 you wrote:
From: Eric Dumazet <edumazet@google.com>

We noticed that with a LOCKDEP enabled kernel,
allocating a hash table with 65536 buckets would
use more than 60ms.

htab_init_buckets() runs from process context,
it is safe to schedule to avoid latency spikes.

[...]
Here is the summary with links:
  - [bpf] bpf: add schedule point in htab_init_buckets()
    https://git.kernel.org/bpf/bpf/c/e7e518053c26

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help