lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 27 Oct 2022 09:54:08 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Yajun Deng <yajun.deng@...ux.dev>
Cc:     mingo@...hat.com, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com, vschneid@...hat.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched/fair: Remove max_vruntime() and min_vruntime()

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ