I found that it is advised to check first @count(Statist) ans if it positve applut to @max operator
 
There is also interesting @entry operator.
 
My script still produces warning but produces result
 
Herfe is the script:
 
# script arguments :
# $1 - total test duration in sec
# ex: stap -v  <script>  100 5000
global Sum=0;
global Requests=0;
 
global Statist; // collects Sum on the end of sampling interval to calculate avg and max
 
global allocs;
 
probe kernel.function("__kmalloc").return { 
    if (isinstr(sprint_backtrace(),"argus"))  {
        //printf("[%ld] Ret  Alloc =%ld Ret Addr=%p\n",gettimeofday_us(), alloc_size, $return);
        Sum+=@entry($size);
        Statist <<< Sum
        allocs[$return]=@entry($size);  /* Store requested size by address */
    }
}
 
probe kernel.function("kfree") { 
    if ($x in allocs ) {
        try {
        freed_size = allocs[$x];
        }
        catch {
            printf("Non existing allocs[ Addr]=%p\n", $x);
        }
        delete allocs[$x];
 
        if (freed_size == 0 ) {
            next;
        }
 
probe timer.s($1) {
        exit();  /* Exit on timer , go to probe end */
}
 
probe end { 
    if (@count(Statist) > 0) {  /* if statistics is not empty */
        printf(" <EXIT> Alloc Requests=%ld Max=%ld Total Size=%ld\n", Requests, @max(Statist),Sum);
    }
    else {
        printf(" <EXIT> Alloc Requests=0 Max=0 Total Size=0\n");
    }
}
 
 
06.01.2019, 15:40, "Lev Olshvang" <levon...@yandex.com>:
> Hi,
>
> I debugged systemtap scripts which monitor __kmalloc() which are coming from my my 2 module MOD1.KO, MOD2.ko
>
> and they are working perfectly on my Ubuntu 16.10 kernel 4.8.17 VM with gcc 6.2.0 and systemtap package v3.0-7 amd64 . This is a custom kernel and I compiled it with debuginfo myself
>
> Then I moved this scripts to Amazon ?Ubuntu VM 16 I again compiled kernel with debuginfo myself.
>
> My modules are compiled with EXTRA_CFLAGS += -g -DDEBUG
>
> gcc on this host is v5.5.0
> I tried systemtap 3.1, 3,3 4.0 , same error
>
> sudo /usr/local/stap_v4.0/bin/stap -v -d MOD1.ko -d MOD2 ./kmalloc_argus.stp 1 1
> Pass 1: parsed user script and 472 library scripts using 91988virt/65864res/5032shr/61236data kb, in 260usr/50sys/320real ms.
> Pass 2: analyzed script: 5 probes, 7 functions, 1 embed, 6 globals using 131248virt/106220res/5972shr/100496data kb, in 640usr/70sys/711real ms.
> WARNING: missing unwind/symbol data for module 'MOD1.ko'
> WARNING: missing unwind/symbol data for module 'MOD2.ko'
> Pass 3: translated to C into "/tmp/stap7YDmYH/stap_9b711e9d9caac3ad6af772118b2bf956_4495_src.c" using 131248virt/106476res/6228shr/100496data kb, in 350usr/500sys/850real ms.
> Pass 4: compiled C into "stap_9b711e9d9caac3ad6af772118b2bf956_4495.ko" in 38820usr/166550sys/191672real ms.
> Pass 5: starting run.
> ERROR: empty aggregate near operator '@max' at ./kmalloc_argus.stp:58:3
> WARNING: Number of errors: 1, skipped probes: 0
> WARNING: /usr/local/stap_v4.0/bin/staprun exited with status: 1
> Pass 5: run completed in 130usr/1160sys/1748real ms.
> Pass 5: run failed. [man error::pass5]
_______________________________________________
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il

Reply via email to