Skip to contentSkip to conversation

bpf: add schedule point in htab_init_buckets()

PATCH Applied Eric Dumazet 3 participants 3 messages Dec 21, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: add schedule point in htab_init_buckets()

From: Eric Dumazet <[email protected]>

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")
Cc Song Liu <[email protected]>
---
 kernel/bpf/hashtab.c | 1 +
 1 file changed, 1 insertion(+)
kernel/bpf/hashtab.c +1 -0
index 7e848200cd268a0f9ed063f0b641d3c355787013..c1ac7f964bc997925fd427f5192168829d812e5d 100644
@@ -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();
 	}
 }
 
Signature · 1 line
2.29.2.729.g45daf8777d-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

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

Quoted 7 lines

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")
Cc Song Liu <[email protected]>

Thanks for the fix!

Quoted 19 lines

---
kernel/bpf/hashtab.c | 1 +

1 file changed, 1 insertion(+)
kernel/bpf/hashtab.c +1 -0
index 7e848200cd268a0f9ed063f0b641d3c355787013..c1ac7f964bc997925fd427f5192168829d812e5d 100644
@@ -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();
 	}
 }
 
Signature · 1 line
2.29.2.729.g45daf8777d-goog
#2 lore raw
In reply to Eric Dumazet
This patch was applied to bpf/bpf.git (refs/heads/master):

Hello:

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

Quoted 10 lines · On Mon, 21 Dec 2020 11:25:06 -0800 you wrote:

From: Eric Dumazet <[email protected]>

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