Hi Hegde,

Le 25/02/2026 à 11:34, Shrikanth Hegde a écrit :
Hi Christophe.

On 2/25/26 3:15 PM, Christophe Leroy (CS GROUP) wrote:

Hope it is more explicit now.


Got it. The main concern was around with additional computation that sched_clock,
not any additional paths per se.

yes, that would be possible,


How about we do below? This adds only one subtraction.
This achieves the same outcome.

It adds a bit more than just a substration. It adds a call to an extern fonction.

00000164 <my_account_cpu_user_entry>:
 164:   94 21 ff f0     stwu    r1,-16(r1)
 168:   7c 08 02 a6     mflr    r0
 16c:   90 01 00 14     stw     r0,20(r1)
 170:   93 e1 00 0c     stw     r31,12(r1)
 174:   7f ec 42 e6     mftb    r31
 178:   48 00 00 01     bl      178 <my_account_cpu_user_entry+0x14>
                        178: R_PPC_REL24        get_boot_tb
 17c:   81 02 00 08     lwz     r8,8(r2)
 180:   81 22 00 28     lwz     r9,40(r2)
 184:   7c 84 f8 50     subf    r4,r4,r31
 188:   7d 29 40 50     subf    r9,r9,r8
 18c:   7d 29 22 14     add     r9,r9,r4
 190:   90 82 00 24     stw     r4,36(r2)
 194:   91 22 00 08     stw     r9,8(r2)
 198:   80 01 00 14     lwz     r0,20(r1)
 19c:   83 e1 00 0c     lwz     r31,12(r1)
 1a0:   7c 08 03 a6     mtlr    r0
 1a4:   38 21 00 10     addi    r1,r1,16
 1a8:   4e 80 00 20     blr

000001ac <my_account_cpu_user_exit>:
 1ac:   94 21 ff f0     stwu    r1,-16(r1)
 1b0:   7c 08 02 a6     mflr    r0
 1b4:   90 01 00 14     stw     r0,20(r1)
 1b8:   93 e1 00 0c     stw     r31,12(r1)
 1bc:   7f ec 42 e6     mftb    r31
 1c0:   48 00 00 01     bl      1c0 <my_account_cpu_user_exit+0x14>
                        1c0: R_PPC_REL24        get_boot_tb
 1c4:   81 02 00 0c     lwz     r8,12(r2)
 1c8:   81 22 00 24     lwz     r9,36(r2)
 1cc:   7c 84 f8 50     subf    r4,r4,r31
 1d0:   7d 29 40 50     subf    r9,r9,r8
 1d4:   7d 29 22 14     add     r9,r9,r4
 1d8:   90 82 00 28     stw     r4,40(r2)
 1dc:   91 22 00 0c     stw     r9,12(r2)
 1e0:   80 01 00 14     lwz     r0,20(r1)
 1e4:   83 e1 00 0c     lwz     r31,12(r1)
 1e8:   7c 08 03 a6     mtlr    r0
 1ec:   38 21 00 10     addi    r1,r1,16
 1f0:   4e 80 00 20     blr


I really still can't see the point of this substraction.

At one place we do

        tb1 = mftb1;

        acct->utime += (tb1 - acct->starttime_user);
        acct->starttime = tb1;

At the other place we do

        tb2 = mftb2;

        acct->stime += (tb2 - acct->starttime);
        acct->starttime_user = tb2;

So at the end we have

        acct->utime += mftb1 - mftb2;
        acct->stime += mftb2 - mftb1;

You want to change to
        tb1 = mftb1 - boot_tb;
        tb2 = mftb2 - boot_tb;

At the end we would get

        acct->utime += mftb1 - boot_tb - mftb2 + boot_tb = mftb1 - mftb2;
        acct->stime += mftb2 - boot_tb - mftb1 + boot_tb = mftb2 - mftb1;

So what's the point in doing such a useless substract that disappears at the end ? What am I missing ?

Christophe

Reply via email to