From 3f214277bf0fc706f883719b5f56a25955487e9c Mon Sep 17 00:00:00 2001
From: Stephan Mueller <smueller@chronox.de>
Date: Sun, 15 May 2022 16:39:02 +0200
Subject: [PATCH 12/25] scheduler - add entropy sampling hook

The scheduler can be used as a source of entropy. This requires the
presence of a hook that invokes the entropy source implementation.

When the scheduler-based entropy source is not compiled, the hook is
folded into a noop which does not affect the scheduler in any way.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 kernel/sched/core.c | 3 +++
 1 file changed, 3 insertions(+)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7,6 +7,7 @@
  *  Copyright (C) 1991-2002  Linus Torvalds
  *  Copyright (C) 1998-2024  Ingo Molnar, Red Hat
  */
+#include <linux/lrng.h>
 #include <linux/highmem.h>
 #include <linux/hrtimer_api.h>
 #include <linux/ktime_api.h>
@@ -3620,6 +3621,8 @@ ttwu_stat(struct task_struct *p, int cpu
 {
 	struct rq *rq;
 
+	add_sched_randomness(p, cpu);
+
 	if (!schedstat_enabled())
 		return;
 
