mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
selftests: intel_pstate: ftime() is deprecated
commit fc4a3a1bf9
upstream.
Use clock_gettime() instead of deprecated ftime().
aperf.c: In function ‘main’:
aperf.c:58:2: warning: ‘ftime’ is deprecated [-Wdeprecated-declarations]
58 | ftime(&before);
| ^~~~~
In file included from aperf.c:9:
/usr/include/sys/timeb.h:39:12: note: declared here
39 | extern int ftime (struct timeb *__timebuf)
| ^~~~~
Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Ricardo Cañuelo <ricardo.canuelo@collabora.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202304060514.ELO1BqLI-lkp@intel.com/
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ea8c42b3b6
commit
a2773afc81
1 changed files with 16 additions and 6 deletions
|
@ -10,8 +10,12 @@
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
#include "../kselftest.h"
|
#include "../kselftest.h"
|
||||||
|
|
||||||
|
#define MSEC_PER_SEC 1000L
|
||||||
|
#define NSEC_PER_MSEC 1000000L
|
||||||
|
|
||||||
void usage(char *name) {
|
void usage(char *name) {
|
||||||
printf ("Usage: %s cpunum\n", name);
|
printf ("Usage: %s cpunum\n", name);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +26,7 @@ int main(int argc, char **argv) {
|
||||||
long long tsc, old_tsc, new_tsc;
|
long long tsc, old_tsc, new_tsc;
|
||||||
long long aperf, old_aperf, new_aperf;
|
long long aperf, old_aperf, new_aperf;
|
||||||
long long mperf, old_mperf, new_mperf;
|
long long mperf, old_mperf, new_mperf;
|
||||||
struct timeb before, after;
|
struct timespec before, after;
|
||||||
long long int start, finish, total;
|
long long int start, finish, total;
|
||||||
cpu_set_t cpuset;
|
cpu_set_t cpuset;
|
||||||
|
|
||||||
|
@ -55,7 +59,10 @@ int main(int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ftime(&before);
|
if (clock_gettime(CLOCK_MONOTONIC, &before) < 0) {
|
||||||
|
perror("clock_gettime");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
pread(fd, &old_tsc, sizeof(old_tsc), 0x10);
|
pread(fd, &old_tsc, sizeof(old_tsc), 0x10);
|
||||||
pread(fd, &old_aperf, sizeof(old_mperf), 0xe7);
|
pread(fd, &old_aperf, sizeof(old_mperf), 0xe7);
|
||||||
pread(fd, &old_mperf, sizeof(old_aperf), 0xe8);
|
pread(fd, &old_mperf, sizeof(old_aperf), 0xe8);
|
||||||
|
@ -64,7 +71,10 @@ int main(int argc, char **argv) {
|
||||||
sqrt(i);
|
sqrt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
ftime(&after);
|
if (clock_gettime(CLOCK_MONOTONIC, &after) < 0) {
|
||||||
|
perror("clock_gettime");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
pread(fd, &new_tsc, sizeof(new_tsc), 0x10);
|
pread(fd, &new_tsc, sizeof(new_tsc), 0x10);
|
||||||
pread(fd, &new_aperf, sizeof(new_mperf), 0xe7);
|
pread(fd, &new_aperf, sizeof(new_mperf), 0xe7);
|
||||||
pread(fd, &new_mperf, sizeof(new_aperf), 0xe8);
|
pread(fd, &new_mperf, sizeof(new_aperf), 0xe8);
|
||||||
|
@ -73,11 +83,11 @@ int main(int argc, char **argv) {
|
||||||
aperf = new_aperf-old_aperf;
|
aperf = new_aperf-old_aperf;
|
||||||
mperf = new_mperf-old_mperf;
|
mperf = new_mperf-old_mperf;
|
||||||
|
|
||||||
start = before.time*1000 + before.millitm;
|
start = before.tv_sec*MSEC_PER_SEC + before.tv_nsec/NSEC_PER_MSEC;
|
||||||
finish = after.time*1000 + after.millitm;
|
finish = after.tv_sec*MSEC_PER_SEC + after.tv_nsec/NSEC_PER_MSEC;
|
||||||
total = finish - start;
|
total = finish - start;
|
||||||
|
|
||||||
printf("runTime: %4.2f\n", 1.0*total/1000);
|
printf("runTime: %4.2f\n", 1.0*total/MSEC_PER_SEC);
|
||||||
printf("freq: %7.0f\n", tsc / (1.0*aperf / (1.0 * mperf)) / total);
|
printf("freq: %7.0f\n", tsc / (1.0*aperf / (1.0 * mperf)) / total);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue