Hi,
Alessandro Ghedini wrote:
> See attached diff against upstream procps version 3.2.8, which is the version
> that, AFAICT, ulatencyd embeds.
Hm. Does upstream have any hints about this? My first guess would
be that the imported copy of procps was distro-patched.
[...]
> +++ /home/ale/devel/debian/pkg-collab/packages/ulatencyd/src/proc/alloc.c
> 2012-07-04 16:37:32.104710221 +0200
[...]
> @@ -26,6 +27,7 @@
> if (size == 0)
> ++size;
> p = malloc(size);
> + memset(p, 0, size);
> if (!p) {
> fprintf(stderr, "xmalloc: malloc(%d) failed", size);
> perror(NULL);
>From ulatencyd commit 518a9672 "finish lua filter code", 2010-12-20.
Making xmalloc() act like calloc doesn't make much sense except as a
temporary workaround to a buggy caller.
[...]
> +++ /home/ale/devel/debian/pkg-collab/packages/ulatencyd/src/proc/readproc.c
> 2012-07-04 16:37:32.104710221 +0200
[...]
> static const unsigned char asso[] =
> {
> - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
> - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
> + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
> + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
[...]
procps commit 5f570a84 "per-process swap info available on Linux
2.6.34", 2010-05-18.
> };
>
> static const status_table_struct table[] = {
> - F(VmStk)
> + F(Pid)
[...]
> @@ -157,6 +163,9 @@
> P->vm_exe = 0;
> P->vm_lib = 0;
> P->nlwp = 0;
> + P->nsupgid = 0;
> + P->supgid = NULL;
> + P->supgrp = NULL;
Seems to have been implemented differently by procps commit 3ef4823f
"supgid/supgrp support, improved library interface", 2011-08-01.
> P->signal[0] = '\0'; // so we can detect it as missing for very old
> kernels
>
> goto base;
> @@ -173,7 +182,9 @@
> // examine a field name (hash and compare)
> base:
> if(unlikely(!*S)) break;
> - entry = table[63 & (asso[S[3]] + asso[S[2]] + asso[S[0]])];
> + hash = asso[S[3]] + asso[S[2]] + asso[S[0]];
> + if (hash > 65) continue;
> + entry = table[hash];
Specific to ulatencyd, and already present in its 2010-12-19 initial
import.
[...]
> @@ -271,6 +282,21 @@
> P->sgid = strtol(S,&S,10);
> P->fgid = strtol(S,&S,10);
> continue;
> + case_Groups:
> + isupgid = 0;
> + if (*S != '\n'){ // Is there any supplementary group ?
> + P->supgid = (int *) xmalloc(0x0004 * sizeof(int));
> + int vctsize = 0x0004;
> + while (S[1] != '\n' && isupgid<INT_MAX){ // There is one blank
> before '\n'
> + if (isupgid == vctsize){
> + vctsize *= 2;
> + P->supgid = (int *)xrealloc(P->supgid,vctsize * sizeof(int));
> + }
> + P->supgid[isupgid++] = strtol(S,&S,10);
> + P->nsupgid++;
> + }
> + }
> + continue;
Implemented differently in procps commit 3ef4823f.
> @@ -407,7 +433,7 @@
> /* fprintf(stderr, "statm2proc converted %d fields.\n",num); */
> }
>
> -static int file2str(const char *directory, const char *what, char *ret, int
> cap) {
> +int file2str(const char *directory, const char *what, char *ret, int cap) {
Exposing a private function, present since the beginning of the
history described in the ulatencyd repo.
> @@ -421,7 +447,7 @@
> return num_read;
> }
>
> -static char** file2strvec(const char* directory, const char* what) {
> +char** file2strvec_ext(const char* directory, const char* what, char
> terminator) {
ulatencyd commit 1191b159 "add cgroups_origin and exit filter call",
2011-02-08.
[...]
> @@ -589,6 +622,13 @@
> }
> }
>
> + if (flags & PROC_FILLSUPGRP && p->nsupgid > 0){
> + allocsupgrp(p);
> + int i;
> + for (i=0; i < p->nsupgid; i++)
> + memcpy(p->supgrp[i], group_from_gid(p->supgid[i]), P_G_SZ);
> + }
> +
Different from the procps version.
[...]
> @@ -599,6 +639,17 @@
> else
> p->environ = NULL;
>
> + if(linux_version_code>=LINUX_VERSION(2,6,24) && (flags &
> PROC_FILLCGROUP)) {
> + p->cgroup = file2strvec_ext(path, "cgroup", '\n'); /* read
> /proc/#/cgroup */
> + if(p->cgroup && *p->cgroup) {
> + int i = strlen(*p->cgroup);
> + if( (*p->cgroup)[i-1]=='\n' )
> + (*p->cgroup)[i-1] = ' '; //little hack to remove
> trailing \n
> + }
Done differently in procps upstream.
[... etc ...]
Hope that helps,
Jonathan
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]