Skip to content

Commit 9169675

Browse files
committed
Improve egg, again
1 parent 2279d9f commit 9169675

3 files changed

Lines changed: 113 additions & 117 deletions

File tree

include/linux/timekeeper_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ struct timekeeper {
138138
#endif
139139
};
140140

141+
extern struct timekeeper global_timekeeper;
142+
141143
#ifdef CONFIG_GENERIC_TIME_VSYSCALL
142144

143145
extern void update_vsyscall(struct timekeeper *tk);

kernel/sched/easy.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <linux/sched/clock.h>
22
#include <linux/sched/cputime.h>
3-
#include <asm/tsc.h>
3+
#include <linux/timekeeper_internal.h>
44
#include <linux/sched/isolation.h>
55
#include <linux/sched/nohz.h>
66
#include "sched.h"
@@ -39,19 +39,21 @@ static __inline void egg(void)
3939
pr_alert("easy_sched: 'Your math is too poor!'\n");
4040
pr_alert("easy_sched: But every time they said it, I had already deleted their math-heavy bullshit,\n");
4141
pr_alert("easy_sched: and the system still ran — faster, cleaner, simpler.\n");
42-
if (__ktime_get_real_seconds())
43-
pr_alert("!!! Happy %s !!!\n", unix_days[(__ktime_get_real_seconds()/86400)%7]);
42+
if (global_timekeeper.xtime_sec)
43+
pr_alert("!!! Happy %s !!!\n", unix_days[(global_timekeeper.xtime_sec/86400)%7]);
4444
else
4545
pr_alert("!!! Happy ???Day, time unknown 233 !!!\n");
4646
shown = 1;
4747
}
4848
static __inline void egg2(struct task_struct *p)
4949
{
5050
static uint64_t last_yield = 0;
51-
uint64_t now_sec = __ktime_get_real_seconds();
52-
if (now_sec-last_yield<30) return;
53-
pr_alert("\033[1;31mWarning from Professors with PID=%lld: %s\033[0m\n", p->pid, prof_words[get_cycles()%(sizeof(prof_words)/sizeof(char *))]);
54-
last_yield = now_sec;
51+
if (global_timekeeper.ktime_sec-last_yield<30) return;
52+
if (p->utime%255 > 233)
53+
{
54+
pr_alert("\033[1;31mWarning from Professors with PID=%lld: %s\033[0m\n", p->pid, prof_words[get_cycles()%(sizeof(prof_words)/sizeof(char *))]);
55+
last_yield = global_timekeeper.ktime_sec;
56+
}
5557
}
5658

5759
void easy_sched_init(easy_sched_struct_def *easy_context)

0 commit comments

Comments
 (0)