Skip to content

Bug in clock_gettime syscall #1333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mhomidi opened this issue Jul 25, 2024 · 1 comment
Open

Bug in clock_gettime syscall #1333

mhomidi opened this issue Jul 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mhomidi
Copy link
Collaborator

mhomidi commented Jul 25, 2024

Problem

Hi everyone,
When we call clock_gettime syscall, we get the userTime and systemTime for CPU state and make their scale to nano-second in qkernel/src/qlib/kernel/threadmgr/task_sched.rs:154. Then in the qkernel/src/qlib/kernel/threadmgr/task_sched.rs:454 and/or qkernel/src/qlib/kernel/threadmgr/task_sched.rs:457, we again scale and multiply them to 1000 to get nano-second again while their are in nano-second scale by themselves. This make some issue in wait syscall and probably other places.

If you want to see the issue, try to run Quark in two machines with different clock frequency. (Actually it just be accurate when clock freq is 1GHz)

Solution

We just need to change function Now in line qkernel/src/qlib/kernel/threadmgr/task_sched.rs:451 and remove the Scale and *1000:

pub fn Now(&self) -> Time {
    let stats = self.t.Upgrade().unwrap().CPUStats();
    if self.includeSys {
        return Time::FromNs(stats.UserTime + stats.SysTime);
    }

    return Time::FromNs(stats.UserTime);
}
@mhomidi mhomidi added the bug Something isn't working label Jul 25, 2024
@shrik3
Copy link
Collaborator

shrik3 commented Aug 12, 2024

Hi mhomidi:

since you already have a solution, perhaps it's better to just go ahead and open an PR, mark as draft or RFC if you are not sure.

It's an overhead to create a patch from your snippet; Also you should be properly credited for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants