lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKZGPAOYPp3ANWfBWxcsT3TJdPt8jH-f2ZJzpin=UZ=-b_-QFg@mail.gmail.com>
Date:   Wed, 19 Jul 2023 10:36:08 +0530
From:   Arun KS <arunks.linux@...il.com>
To:     linux-kernel@...r.kernel.org
Cc:     linux-arm-kernel@...ts.infradead.org, Arun KS <getarunks@...il.com>
Subject: Question on sched_clock

Hi,

Kernel’s printk uses local_clock() for timestamps and it is mapped to
sched_clock(). Two problems/requirements I see,

One, Kernel’s printk timestamps start from 0, I want to change this to
match with actual time since boot.
Two, sched_clock() doesn’t account for time spend in low power
state(suspend to ram)

Could workout patches to modify these behaviours and found working in
my system. But need to hear expert opinion on why this is not done in
the upstream.

diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index 68d6c1190ac7..b63b2ded5727 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -190,7 +190,10 @@ sched_clock_register(u64 (*read)(void), int bits,
unsigned long rate)
        /* Update epoch for new counter and update 'epoch_ns' from old counter*/
        new_epoch = read();
        cyc = cd.actual_read_sched_clock();
-       ns = rd.epoch_ns + cyc_to_ns((cyc - rd.epoch_cyc) &
rd.sched_clock_mask, rd.mult, rd.shift);
+       if (!cyc)
+               ns = cyc_to_ns(new_epoch, new_mult, new_shift)
+       else
+               ns = rd.epoch_ns + cyc_to_ns((cyc - rd.epoch_cyc) &
rd.sched_clock_mask, rd.mult, rd.shift);
        cd.actual_read_sched_clock = read;

        rd.read_sched_clock     = read;

@@ -287,7 +290,6 @@ void sched_clock_resume(void)
 {
        struct clock_read_data *rd = &cd.read_data[0];

-       rd->epoch_cyc = cd.actual_read_sched_clock();
        hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL_HARD);
        rd->read_sched_clock = cd.actual_read_sched_clock;
 }

Regards,
Arun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ