Re: [PATCH] sched/fair: Remove max_vruntime() and min_vruntime()
From: Peter Zijlstra
Date: Thu Oct 27 2022 - 03:54:50 EST
On Thu, Oct 27, 2022 at 09:53:51AM +0800, Yajun Deng wrote:
> There is no need to write max_vruntime() and min_vruntime() functions,
> we can use max_t() and min_t() instead.
Here; I did your homework for you:
/* max.c */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
typedef unsigned long long u64;
typedef unsigned long long s64;
static u64 max_vruntime(u64 max_vruntime, u64 vruntime)
{
s64 delta = (s64)(vruntime - max_vruntime);
if (delta > 0)
max_vruntime = vruntime;
return max_vruntime;
}
static u64 max(u64 a, u64 b)
{
return a > b ? a : b;
}
int main(int argc, char **argv)
{
u64 a, b;
if (argc < 3)
return 0;
a = strtoll(argv[1], NULL, 10);
b = strtoll(argv[2], NULL, 10);
printf(" max(%lu, %lu) = %lu\n", a, b, max(a,b));
printf("max_vruntime(%lu, %lu) = %lu\n", a, b, max_vruntime(a,b));
return 0;
}
$ ./max -1 0
max(18446744073709551615, 0) = 18446744073709551615
max_vruntime(18446744073709551615, 0) = 0