Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* LX164 and rpcc
@ 1998-12-17 10:45 Hannu Mallat
  1998-12-17 11:36 ` Thorsten Koch
  0 siblings, 1 reply; 8+ messages in thread
From: Hannu Mallat @ 1998-12-17 10:45 UTC (permalink / raw)
  To: axp-list


Hi all,

I'm working on a executable instrumentation toolkit for my thesis, and
ran on the following problem: I'm trying to measure execution times
using the procedure cycle counter, obtaining the 64-bit counter value
by rpcc and adding the high 32 bits to the low 32 bits, as mentioned
in David Mosberger's Linux Expo '97 paper. For the most part, I'm
getting reasonable values; however, sometimes the pcc is _smaller_
after the routine than before (and no, it did not have time to wrap
around). 

I'm doing my measurements on a 533 MHz LX164, with 2.0.35 kernel and
the latest MILO. Below is a small program that illustrates the problem.
I've run it on the equipment mentioned above and on another Alpha with
v4.0 of OSF/1 on it (I believe it's a DEC AlphaServer 2100 5/300), where
the problem does not reproduce. 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

static inline unsigned long cc64 (void) {
  unsigned long cc;
  asm volatile("rpcc %0" : "=r"(cc) : : "memory");
  return cc;
}

int main(int argc, char* argv[]) {
  char *buf = NULL;
  int i;
  unsigned long c1, c2;
  unsigned int i1, i2;
  unsigned int buf_len = 0;

  buf_len = atoi(argv[1]);
  buf = malloc(buf_len);
  if(!buf)
    abort();

  for(i = 0; i < buf_len; i++)
    buf[i] = i % 256;

  for(i = 0; i < 10; i++) {
    FILE* f = fopen("foo.bar", "w+");
    if(!f) {
      fprintf(stderr, "Argh! %s\n", strerror(errno));
      exit(1);
    }
    fwrite(buf, buf_len, 1, f);
    c1 = cc64();
    fclose(f);
    c2 = cc64();

    i1 = ((c1 >> 32ULL) & 0xffffffff) + (c1 & 0xffffffff); 
    i2 = ((c2 >> 32ULL) & 0xffffffff) + (c2 & 0xffffffff); 

    fprintf(stdout, 
            "%08x %08x ... %08x %08x : %08x ... %08x : %08x\n",
            (unsigned int)(c1 >> 32), 
            (unsigned int)(c1 & 0xffffffff), 
            (unsigned int)(c2 >> 32), 
            (unsigned int)(c2 & 0xffffffff), 
            i1, i2, i2 - i1);
  }

  exit(0);
}

Here's the interesting part: if I write < 1024 bytes, the results are OK,
if more, things fail. Sample logs:

[peak9:src] ./rpcc 1024
14606d55 11f0bc9f ... 145fe353 11f13abe : 265129f4 ... 26511e11 : fffff41d
144f0f79 12054dc5 ... 144ed043 1205788d : 26545d3e ... 265448d0 : ffffeb92
1442d48e 1213addc ... 1442980f 1213d920 : 2656826a ... 2656712f : ffffeec5
1436ac67 1221d69a ... 14366da5 122200c1 : 26588301 ... 26586e66 : ffffeb65
142a75c8 12301401 ... 142a36e8 12304089 : 265a89c9 ... 265a7771 : ffffeda8
141dc20c 123ec09d ... 141d8569 123eead3 : 265c82a9 ... 265c703c : ffffed93
14118ad9 124cf05f ... 14114f92 124d1ab8 : 265e7b38 ... 265e6a4a : ffffef12
140264a2 125e4fa1 ... 140225bf 125e79f0 : 2660b443 ... 26609faf : ffffeb6c
1374a167 12ee12f3 ... 1374625f 12ee3e1d : 2662b45a ... 2662a07c : ffffec22
136735d4 12fd79c2 ... 1366f850 12fda411 : 2664af96 ... 26649c61 : ffffeccb
[peak9:src] ./rpcc 1023
cd9c9425 58b55ec6 ... cd97179a 58bb9575 : 2651f2eb ... 2652ad0f : 0000ba24
cd8fc1c5 58c5ae29 ... cd8a9120 58cb4b35 : 26556fee ... 2655dc55 : 00006c67
cd836c28 58d43aee ... cd7e49b1 58d9c72f : 2657a716 ... 265810e0 : 000069ca
cd772481 58e2af2b ... cd720390 58e83b6e : 2659d3ac ... 265a3efe : 00006b52
cd6ac300 58f14ef5 ... cd659865 58f6e2f2 : 265c11f5 ... 265c7b57 : 00006962
cd5e7eb7 58ffbbf2 ... cd595c9a 59054386 : 265e3aa9 ... 265ea020 : 00006577
cd523212 590e33a4 ... cd4d0dd9 5913bf1a : 266065b6 ... 2660ccf3 : 0000673d
cd42f040 591fc57e ... cd3d7171 5925b348 : 2662b5be ... 266324b9 : 00006efb
ccb4c72b 59b01d70 ... ccaf770b 59b5da3d : 2664e49b ... 26655148 : 00006cad
cca74054 59bfea07 ... cca218bf 59c57d0d : 26672a5b ... 266795cc : 00006b71

Perhaps I'm just blind to some obviousity, but I really don't know what
at the moment. I haven't had the energy to look properly inside the lx164
palcode yet (afaik the palcode is responsible for the high 32 bits, right?)
but I'd be surprised if the bug was there and no one found it yet.

Hannu




^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: LX164 and rpcc
@ 1998-12-24 17:53 Hannu Mallat
  1998-12-26 18:50 ` Jay.Estabrook
  0 siblings, 1 reply; 8+ messages in thread
From: Hannu Mallat @ 1998-12-24 17:53 UTC (permalink / raw)
  To: axp-list


Richard Henderson wrote:

> If you're adventurous, you might try something like this:
> 
>         stq_p   t10, PCB_Q_USP(v0)      // Store user stack pointer
>         addl    p5, p7, p7              // Set new time

Unfortunately, I'm having loads of trouble getting a decent, working MILO
compiled, with or without the patched palcode. The furthest I got was to
produce an image that hung up on boot. Is there any special wizardry that
needs to be invoked? (requirements for a specific egcs version, etc? I'm
running RH 5.2, the 2.0.35-0.2 kernel from gatekeeper and trying to
compile the corresponding milo sources)

In any case, happy holidays!

Hannu



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1998-12-29 14:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-12-17 10:45 LX164 and rpcc Hannu Mallat
1998-12-17 11:36 ` Thorsten Koch
1998-12-17 14:58   ` Hannu Mallat
1998-12-18 13:02   ` Hannu Mallat
1998-12-18 16:53     ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
1998-12-24 17:53 Hannu Mallat
1998-12-26 18:50 ` Jay.Estabrook
1998-12-29 14:03   ` Hannu Mallat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox