Coder Social home page Coder Social logo

division-by-zero about mhz HOT 5 OPEN

wtarreau avatar wtarreau commented on September 28, 2024
division-by-zero

from mhz.

Comments (5)

wtarreau avatar wtarreau commented on September 28, 2024

Hi Geert!
When you're saying "large clock granularity", what's the approx granularity you've been facing ? For example I remember a long time ago using HZ=100 and jiffies as the only clock source, and seeing tcpdump traces with a 10ms resolution which was not fun. But by then I hadn't developed the mhz tool and I haven't thought about this.

from mhz.

geertu avatar geertu commented on September 28, 2024

When you're saying "large clock granularity", what's the approx granularity you've been facing ? For example I remember a long time ago using HZ=100 and jiffies as the only clock source, and seeing tcpdump traces with a 10ms resolution which was not fun. But by then I hadn't developed the mhz tool and I haven't thought about this.

Using jiffies as the only clocksource, and CONFIG_HZ=100.

from mhz.

wtarreau avatar wtarreau commented on September 28, 2024

@geertu I can't reproduce it. In the worst case all I'm getting are lines like this:
count=10000 us50=0 us250=0 diff=0 cpu_MHz=inf
And indeed the divide is performed on a double here. I'm seeing only two integer divides:

  • the first one in run_once(), divides by count, which is not supposed to be zero there (and if I forcefully pass zero the test never finishes)
  • the second one in calibrate(), divides by duration, but it's done after a loop that loops for as long as duration is < 100000
    Hence I don't see how we can divide by zero there. And it doesn't seem either we could be in a case of -MAXINT/-1

Thus I'm a bit confused regarding this one for now. Any hint would be much appreciated.

from mhz.

geertu avatar geertu commented on September 28, 2024

Sorry, in userspace you indeed don't get an exception, but just an "inf" results. Which is still not what you want.

With my in-kernel version (which does an integer division), it does crash.

from mhz.

wtarreau avatar wtarreau commented on September 28, 2024

Ah OK it makes sense then.

Then I think it should be sufficient to loop around the test, multiplying "count" by 10 until duration is not zero. I'll give that a try.

from mhz.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.