Skip to content

Commit 326e82c

Browse files
committed
Prepare for atop 2.10
1 parent ba78f4c commit 326e82c

26 files changed

+741
-53
lines changed

AUTHORS

+4
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ codebling
2626
Justin Kromlinger
2727
Alastair Young
2828
roadrunner2
29+
liutingjieni
30+
Algebra970
31+
Donatas Abraitis
32+
Marc Haber

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ genericinstall: atop atopacctd atopconvert atopcat atophide
172172
chmod 0711 $(DESTDIR)$(BINPATH)/atopconvert
173173
cp atopcat $(DESTDIR)$(BINPATH)/atopcat
174174
chmod 0711 $(DESTDIR)$(BINPATH)/atopcat
175-
cp atopcat $(DESTDIR)$(BINPATH)/atophide
175+
cp atophide $(DESTDIR)$(BINPATH)/atophide
176176
chmod 0711 $(DESTDIR)$(BINPATH)/atophide
177177
cp man/atop.1 $(DESTDIR)$(MAN1PATH)
178178
cp man/atopsar.1 $(DESTDIR)$(MAN1PATH)

atopconvert.c

+135-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
** ATOP - System & Process Monitor
33
**
4-
** The program 'atop' offers the possibility to view the activity of
4+
** The program 'atop' offers the possibility to view the activity of
55
** the system on system-level as well as process-level.
66
**
77
** This program converts a raw logfile created by a particular version
@@ -11,7 +11,7 @@
1111
** E-mail: gerlof.langeveld@atoptool.nl
1212
** Initial: July/August 2018
1313
** --------------------------------------------------------------------------
14-
** Copyright (C) 2018-2022 Gerlof Langeveld
14+
** Copyright (C) 2018-2024 Gerlof Langeveld
1515
**
1616
** This program is free software; you can redistribute it and/or modify it
1717
** under the terms of the GNU General Public License as published by the
@@ -85,27 +85,41 @@
8585
#include "prev/photosyst_29.h"
8686
#include "prev/photoproc_29.h"
8787

88+
#include "prev/photosyst_210.h"
89+
#include "prev/photoproc_210.h"
90+
8891

8992
void justcopy(void *, void *, count_t, count_t);
9093

9194
void scpu_to_21(void *, void *, count_t, count_t);
9295
void sdsk_to_21(void *, void *, count_t, count_t);
96+
9397
void sint_to_22(void *, void *, count_t, count_t);
98+
9499
void scpu_to_27(void *, void *, count_t, count_t);
95100
void smem_to_27(void *, void *, count_t, count_t);
96101
void sdsk_to_27(void *, void *, count_t, count_t);
102+
97103
void smem_to_28(void *, void *, count_t, count_t);
98104
void sdsk_to_28(void *, void *, count_t, count_t);
99105
void smnu_to_28(void *, void *, count_t, count_t);
100106
void scnu_to_28(void *, void *, count_t, count_t);
107+
108+
void sllc_to_210(void *, void *, count_t, count_t);
109+
101110
void tgen_to_21(void *, void *, count_t, count_t);
102111
void tmem_to_21(void *, void *, count_t, count_t);
112+
103113
void tgen_to_22(void *, void *, count_t, count_t);
114+
104115
void tcpu_to_26(void *, void *, count_t, count_t);
105116
void tmem_to_26(void *, void *, count_t, count_t);
117+
106118
void tcpu_to_28(void *, void *, count_t, count_t);
107119
void tmem_to_28(void *, void *, count_t, count_t);
108120

121+
void tgen_to_210(void *, void *, count_t, count_t);
122+
109123
///////////////////////////////////////////////////////////////
110124
// Conversion functions
111125
// --------------------
@@ -190,7 +204,7 @@ sint_to_22(void *old, void *new, count_t oldsize, count_t newsize)
190204
sizeof(struct perintf_21));
191205

192206
// correct last members by refilling
193-
//
207+
//
194208
i22->intf[i].type = '?';
195209
i22->intf[i].speed = i21->intf[i].speed;
196210
i22->intf[i].speedp = i21->intf[i].speed;
@@ -330,7 +344,7 @@ smnu_to_28(void *old, void *new, count_t oldsize, count_t newsize)
330344
n28->numa[i].inactive = n27->numa[i].inactive;
331345
n28->numa[i].shmem = n27->numa[i].shmem;
332346
n28->numa[i].tothp = n27->numa[i].tothp;
333-
}
347+
}
334348
}
335349

336350
void
@@ -355,9 +369,26 @@ scnu_to_28(void *old, void *new, count_t oldsize, count_t newsize)
355369
n28->numa[i].Stime = n27->numa[i].Stime;
356370
n28->numa[i].steal = n27->numa[i].steal;
357371
n28->numa[i].guest = n27->numa[i].guest;
358-
}
372+
}
359373
}
360374

375+
void
376+
sllc_to_210(void *old, void *new, count_t oldsize, count_t newsize)
377+
{
378+
struct llcstat_29 *l29 = old;
379+
struct llcstat_210 *l210 = new;
380+
int i;
381+
382+
l210->nrllcs = l29->nrllcs;
383+
384+
for (i=0; i < l210->nrllcs; i++)
385+
{
386+
l210->perllc[i].id = l29->perllc[i].id;
387+
l210->perllc[i].occupancy = l29->perllc[i].occupancy;
388+
l210->perllc[i].mbm_local = l29->perllc[i].mbm_local;
389+
l210->perllc[i].mbm_total = l29->perllc[i].mbm_total;
390+
}
391+
}
361392

362393
// /////////////////////////////////////////////////////////////////
363394
// Specific functions that convert an old tstat sub-structure to
@@ -482,6 +513,25 @@ tmem_to_28(void *old, void *new, count_t oldsize, count_t newsize)
482513
memset(m28->cfuture, 0, sizeof m28->cfuture);
483514
}
484515

516+
void
517+
tgen_to_210(void *old, void *new, count_t oldsize, count_t newsize)
518+
{
519+
// member 'nthridle' inserted, everything from member 'ctid' must shift
520+
//
521+
struct gen_29 *g29 = old;
522+
struct gen_210 *g210 = new;
523+
524+
memcpy(g210, g29, (char *)&g29->ctid - (char *)g29); // copy base values
525+
526+
g210->nthridle = 0;
527+
g210->ctid = g29->ctid;
528+
g210->vpid = g29->vpid;
529+
g210->wasinactive = g29->wasinactive;
530+
531+
memcpy(g210->utsname, g29->container, sizeof(g210->utsname));
532+
memcpy(g210->cgpath, g29->cgpath, sizeof(g210->cgpath));
533+
}
534+
485535
///////////////////////////////////////////////////////////////
486536
// conversion definition for various structs in sstat and tstat
487537
//
@@ -510,6 +560,7 @@ struct sstat_26 sstat_26;
510560
struct sstat_27 sstat_27;
511561
struct sstat_28 sstat_28;
512562
struct sstat_29 sstat_29;
563+
struct sstat_210 sstat_210;
513564
struct sstat sstat;
514565

515566
struct tstat_20 tstat_20;
@@ -522,6 +573,7 @@ struct tstat_26 tstat_26;
522573
struct tstat_27 tstat_27;
523574
struct tstat_28 tstat_28;
524575
struct tstat_29 tstat_29;
576+
struct tstat_210 tstat_210;
525577
struct tstat tstat;
526578

527579
struct convertall {
@@ -556,7 +608,7 @@ struct convertall {
556608
struct tconvstruct tmem;
557609
struct tconvstruct tnet;
558610
struct tconvstruct tgpu;
559-
} convs[] =
611+
} convs[] =
560612
{
561613
{SETVERSION(2,0),
562614
sizeof(struct sstat_20), &sstat_20,
@@ -577,11 +629,11 @@ struct convertall {
577629
{0, NULL, NULL},
578630
{0, NULL, NULL},
579631

580-
{sizeof(struct gen_20),
632+
{sizeof(struct gen_20),
581633
STROFFSET(&tstat_20.gen, &tstat_20), NULL},
582634
{sizeof(struct cpu_20),
583635
STROFFSET(&tstat_20.cpu, &tstat_20), NULL},
584-
{sizeof(struct dsk_20),
636+
{sizeof(struct dsk_20),
585637
STROFFSET(&tstat_20.dsk, &tstat_20), NULL},
586638
{sizeof(struct mem_20),
587639
STROFFSET(&tstat_20.mem, &tstat_20), NULL},
@@ -613,7 +665,7 @@ struct convertall {
613665
STROFFSET(&tstat_21.gen, &tstat_21), tgen_to_21},
614666
{sizeof(struct cpu_21),
615667
STROFFSET(&tstat_21.cpu, &tstat_21), justcopy},
616-
{sizeof(struct dsk_21),
668+
{sizeof(struct dsk_21),
617669
STROFFSET(&tstat_21.dsk, &tstat_21), justcopy},
618670
{sizeof(struct mem_21),
619671
STROFFSET(&tstat_21.mem, &tstat_21), tmem_to_21},
@@ -641,7 +693,7 @@ struct convertall {
641693
{0, NULL, NULL},
642694
{0, NULL, NULL},
643695

644-
{sizeof(struct gen_22),
696+
{sizeof(struct gen_22),
645697
STROFFSET(&tstat_22.gen, &tstat_22), tgen_to_22},
646698
{sizeof(struct cpu_22),
647699
STROFFSET(&tstat_22.cpu, &tstat_22), justcopy},
@@ -679,7 +731,7 @@ struct convertall {
679731
STROFFSET(&tstat_23.cpu, &tstat_23), justcopy},
680732
{sizeof(struct dsk_23),
681733
STROFFSET(&tstat_23.dsk, &tstat_23), justcopy},
682-
{sizeof(struct mem_23),
734+
{sizeof(struct mem_23),
683735
STROFFSET(&tstat_23.mem, &tstat_23), justcopy},
684736
{sizeof(struct net_23),
685737
STROFFSET(&tstat_23.net, &tstat_23), justcopy},
@@ -883,6 +935,39 @@ struct convertall {
883935
{sizeof(struct gpu_29),
884936
STROFFSET(&tstat_29.gpu, &tstat_29), justcopy},
885937
},
938+
939+
{SETVERSION(2,10), // 2.9 --> 2.10
940+
sizeof(struct sstat_210), &sstat_210,
941+
sizeof(struct tstat_210), NULL,
942+
943+
{sizeof(struct cpustat_210), &sstat_210.cpu, justcopy},
944+
{sizeof(struct memstat_210), &sstat_210.mem, justcopy},
945+
{sizeof(struct netstat_210), &sstat_210.net, justcopy},
946+
{sizeof(struct intfstat_210), &sstat_210.intf, justcopy},
947+
{sizeof(struct dskstat_210), &sstat_210.dsk, justcopy},
948+
{sizeof(struct nfsstat_210), &sstat_210.nfs, justcopy},
949+
{sizeof(struct contstat_210), &sstat_210.cfs, justcopy},
950+
{sizeof(struct wwwstat_210), &sstat_210.www, justcopy},
951+
{sizeof(struct pressure_210), &sstat_210.psi, justcopy},
952+
{sizeof(struct gpustat_210), &sstat_210.gpu, justcopy},
953+
{sizeof(struct ifbstat_210), &sstat_210.ifb, justcopy},
954+
{sizeof(struct memnuma_210), &sstat_210.memnuma, justcopy},
955+
{sizeof(struct cpunuma_210), &sstat_210.cpunuma, justcopy},
956+
{sizeof(struct llcstat_210), &sstat_210.llc, sllc_to_210},
957+
958+
{sizeof(struct gen_210),
959+
STROFFSET(&tstat_210.gen, &tstat_210), tgen_to_210},
960+
{sizeof(struct cpu_210),
961+
STROFFSET(&tstat_210.cpu, &tstat_210), justcopy},
962+
{sizeof(struct dsk_210),
963+
STROFFSET(&tstat_210.dsk, &tstat_210), justcopy},
964+
{sizeof(struct mem_210),
965+
STROFFSET(&tstat_210.mem, &tstat_210), justcopy},
966+
{sizeof(struct net_210),
967+
STROFFSET(&tstat_210.net, &tstat_210), justcopy},
968+
{sizeof(struct gpu_210),
969+
STROFFSET(&tstat_210.gpu, &tstat_210), justcopy},
970+
},
886971
};
887972

888973
int numconvs = sizeof convs / sizeof(struct convertall);
@@ -1046,7 +1131,7 @@ main(int argc, char *argv[])
10461131
exit(11);
10471132
}
10481133

1049-
// handle the output file
1134+
// handle the output file
10501135
//
10511136
if (optind >= argc)
10521137
exit(0);
@@ -1060,7 +1145,7 @@ main(int argc, char *argv[])
10601145
exit(12);
10611146
}
10621147

1063-
// open the output file
1148+
// open the output file
10641149
//
10651150
if ( (ofd = openout(outfile)) == -1)
10661151
{
@@ -1076,6 +1161,9 @@ main(int argc, char *argv[])
10761161
orh.sstatlen = convs[targetix].sstatlen;
10771162
orh.tstatlen = convs[targetix].tstatlen;
10781163

1164+
if (orh.pidwidth == 0) // no pid width know in old raw log?
1165+
orh.pidwidth = getpidwidth();
1166+
10791167
writeout(ofd, &orh, sizeof orh);
10801168

10811169
printf("Version of %s: %d.%d\n", outfile,
@@ -1127,7 +1215,7 @@ convert_samples(int ifd, int ofd, struct rawheader *irh, int ivix, int ovix)
11271215
exit(7);
11281216

11291217
// STEP-BY-STEP CONVERSION FROM OLD VERSION TO NEW VERSION
1130-
//
1218+
//
11311219
for (i=ivix; i < ovix; i++)
11321220
{
11331221
// convert system-level statistics to newer version
@@ -1161,32 +1249,32 @@ convert_samples(int ifd, int ofd, struct rawheader *irh, int ivix, int ovix)
11611249
for (t=0; t < irr.ndeviat; t++) // for every task
11621250
{
11631251
do_tconvert(
1164-
convs[i].tstat +(t*convs[i].tstatlen),
1252+
convs[i].tstat +(t*convs[i].tstatlen),
11651253
convs[i+1].tstat+(t*convs[i+1].tstatlen),
11661254
&(convs[i].tgen), &(convs[i+1].tgen));
11671255

11681256
do_tconvert(
1169-
convs[i].tstat +(t*convs[i].tstatlen),
1257+
convs[i].tstat +(t*convs[i].tstatlen),
11701258
convs[i+1].tstat+(t*convs[i+1].tstatlen),
11711259
&(convs[i].tcpu), &(convs[i+1].tcpu));
11721260

11731261
do_tconvert(
1174-
convs[i].tstat +(t*convs[i].tstatlen),
1262+
convs[i].tstat +(t*convs[i].tstatlen),
11751263
convs[i+1].tstat+(t*convs[i+1].tstatlen),
11761264
&(convs[i].tdsk), &(convs[i+1].tdsk));
11771265

11781266
do_tconvert(
1179-
convs[i].tstat +(t*convs[i].tstatlen),
1267+
convs[i].tstat +(t*convs[i].tstatlen),
11801268
convs[i+1].tstat+(t*convs[i+1].tstatlen),
11811269
&(convs[i].tmem), &(convs[i+1].tmem));
11821270

11831271
do_tconvert(
1184-
convs[i].tstat +(t*convs[i].tstatlen),
1272+
convs[i].tstat +(t*convs[i].tstatlen),
11851273
convs[i+1].tstat+(t*convs[i+1].tstatlen),
11861274
&(convs[i].tnet), &(convs[i+1].tnet));
11871275

11881276
do_tconvert(
1189-
convs[i].tstat +(t*convs[i].tstatlen),
1277+
convs[i].tstat +(t*convs[i].tstatlen),
11901278
convs[i+1].tstat+(t*convs[i+1].tstatlen),
11911279
&(convs[i].tgpu), &(convs[i+1].tgpu));
11921280
}
@@ -1203,7 +1291,7 @@ convert_samples(int ifd, int ofd, struct rawheader *irh, int ivix, int ovix)
12031291
irr.ndeviat);
12041292

12051293
// cleanup
1206-
//
1294+
//
12071295
free(convs[ovix].tstat);
12081296
}
12091297

@@ -1524,7 +1612,7 @@ testcompval(int rv, char *func)
15241612
exit(7);
15251613

15261614
case Z_DATA_ERROR:
1527-
fprintf(stderr,
1615+
fprintf(stderr,
15281616
"%s: failed due to corrupted/incomplete data\n", func);
15291617
exit(7);
15301618

@@ -1551,3 +1639,28 @@ ptrverify(const void *ptr, const char *errormsg, ...)
15511639
exit(13);
15521640
}
15531641
}
1642+
1643+
1644+
/*
1645+
** return maximum number of digits for PID/TID
1646+
** from the current system
1647+
*/
1648+
int
1649+
getpidwidth(void)
1650+
{
1651+
FILE *fp;
1652+
char linebuf[64];
1653+
int numdigits = 5;
1654+
1655+
if ( (fp = fopen("/proc/sys/kernel/pid_max", "r")) != NULL)
1656+
{
1657+
if ( fgets(linebuf, sizeof(linebuf), fp) != NULL)
1658+
{
1659+
numdigits = strlen(linebuf) - 1;
1660+
}
1661+
1662+
fclose(fp);
1663+
}
1664+
1665+
return numdigits;
1666+
}

man/atop.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH ATOP 1 "April 2023" "Linux"
1+
.TH ATOP 1 "January 2024" "Linux"
22
.SH NAME
33
.B atop
44
- Advanced System & Process Monitor

man/atopacctd.8

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH ATOPACCTD 8 "December 2022" "Linux"
1+
.TH ATOPACCTD 8 "January 2024" "Linux"
22
.SH NAME
33
.B atopacctd
44
- process accounting daemon

man/atopcat.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH ATOPCAT 1 "December 2022" "Linux"
1+
.TH ATOPCAT 1 "January 2024" "Linux"
22
.SH NAME
33
.B atopcat
44
- concatenate raw log files to stdout

0 commit comments

Comments
 (0)