Mike Kravetz wrote:
>
> Is there anything simple I can do to check the latencies of the
> pthread_cond_*() functions? I'd like to do some analysis of
> scheduler behavior, but am unfamiliar with the user level code.
I just wrote small test program (attached) for testing this. It is similar
to my app, but for this test the soundcard is just used more as a timing
source.
Adjust the buffer size so that it's on the edge of missing blocks then
generate some system load to run it over the edge to see how sensitive it is
and how many blocks are lost. I can see clear difference using kernel with
original scheduler and with kernel having the O(1) scheduler.
It's quite sensitive when you run it without setuid privileges, but normal
situation is to run it at SCHED_FIFO.
Because of famous ReiserFS tailmerging feature lost-and-rewrote part of it
after crashing system with it. Found the the binary overwriting top of it
after reboot... I was happy to have copied it to another machine over NFS
just a few minutes before crash, so not much was lost.
- Jussi Laako
-- PGP key fingerprint: 161D 6FED 6A92 39E2 EB5B 39DD A4DE 63EB C216 1E4B Available at PGP keyservers --------------4C7DB0877E0D7DFF1039EF4F Content-Type: application/x-unknown-content-type-cfile; name="schedtest.c" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="schedtest.c"LyoKCiAgICBTbWFsbCBwcm9ncmFtIGZvciB0ZXN0aW5nIHNjaGVkdWxpbmcgbGF0ZW5jaWVz LgoKICAgIENvcHlyaWdodCAoQykgMjAwMiBKdXNzaSBMYWFrbwoKKi8KCgojaW5jbHVkZSA8 c3RkaW8uaD4KI2luY2x1ZGUgPHN0cmluZy5oPgojaW5jbHVkZSA8c2lnbmFsLmg+CiNpbmNs dWRlIDx1bmlzdGQuaD4KI2luY2x1ZGUgPGZjbnRsLmg+CiNpbmNsdWRlIDxlcnJuby5oPgoj aW5jbHVkZSA8c3lzL3R5cGVzLmg+CiNpbmNsdWRlIDxzeXMvc3RhdC5oPgojaW5jbHVkZSA8 c3lzL2lvY3RsLmg+CiNpbmNsdWRlIDxzeXMvc291bmRjYXJkLmg+CgojaW5jbHVkZSA8c2No ZWQuaD4KI2luY2x1ZGUgPHB0aHJlYWQuaD4KCgovKiB0aGlzIGlzIGNvbnNpZGVyZWQgc2Fm ZSwgbG9zc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AgICAmc2NoZWR1bGVyX3BhcmFtcykgIT0gMCkKICAgICAgICBwZXJyb3IoInB0 aHJlYWRfc2V0c2NoZWRwYXJhbSgpIik7CiAgICBzZXR1aWQoY3VycmVudF91aWQpOwp9CgoK dm9pZCAqcHJvZHVjZXJfdGhyZWFkICh2b2lkICpwYXJhbSkKewogICAgaW50IGggPSAoaW50 KSBwYXJhbTsKICAgIHNpZ25lZCBzaG9ydCBidWZbQlVGX1NJWkVdOwoKICAgIHNldF9zY2hl ZHVsaW5nKCk7CgogICAgd2hpbGUgKHJ1bikKICAgIHsKICAgICAgICBpZiAocmVhZChoLCBi dWYsIHNpemVvZihidWYpKSAhPSAoaW50KSBzaXplb2YoYnVmKSkKICAgICAgICAgICAgcGVy cm9yKCJyZWFkKCkiKTsKICAgICAgICBwdGhyZWFkX211dGV4X2xvY2soJm10eCk7CiAgICAg ICAgbWVtY3B5KHNoYXJlZF9idWYsIGJ1ZiwgQlVGX1NJWkUgKiBzaXplb2Yoc2lnbmVkIHNo b3J0KSk7CiAgICAgICAgZXZlbnRjbnRyKys7CiAgICAgICAgcHRocmVhZF9jb25kX2Jyb2Fk Y2FzdCgmY29uZCk7CiAgICAgICAgcHRocmVhZF9tdXRleF91bmxvY2soJm10eCk7CiAgICB9 CgogICAgcmV0dXJuIE5VTEw7Cn0KCgp2b2lkICpjb25zdW1lcl90aHJlYWQgKHZvaWQgKnBh cmFtKQp7CiAgICBpbnQgaCA9IChpbnQpIHBhcmFtOwogICAgaW50IGxvY2FsX2V2ZW50Y250 cjsKICAgIHNpZ25lZCBzaG9ydCBidWZbQlVGX1NJWkVdOwoKICAgIHNldF9zY2hlZHVsaW5n KCk7CgogICAgcHRocmVhZF9tdXRleF9sb2NrKCZtdHgpOwogICAgbG9jYWxfZXZlbnRjbnRy ID0gZXZlbnRjbnRyOwogICAgcHRocmVhZF9tdXRleF91bmxvY2soJm10eCk7CiAgICB3aGls ZSAocnVuKQogICAgewogICAgICAgIHB0aHJlYWRfbXV0ZXhfbG9jaygmbXR4KTsKICAgICAg ICBwdGhyZWFkX2NvbmRfd2FpdCgmY29uZCwgJm10eCk7CiAgICAgICAgbWVtY3B5KGJ1Ziwg c2hhcmVkX2J1ZiwgQlVGX1NJWkUgKiBzaXplb2Yoc2lnbmVkIHNob3J0KSk7CiAgICAgICAg bG9jYWxfZXZlbnRjbnRyKys7CiAgICAgICAgaWYgKGxvY2FsX2V2ZW50Y250ciAhPSBldmVu dGNudHIpCiAgICAgICAgewogICAgICAgICAgICBwcmludGYoInRocmVhZCAldSBsb3N0ICVp IGJsb2Nrc1xuIiwgCiAgICAgICAgICAgICAgICBwdGhyZWFkX3NlbGYoKSwKICAgICAgICAg ICAgICAgIGV2ZW50Y250ciAtIGxvY2FsX2V2ZW50Y250cik7CiAgICAgICAgICAgIGxvY2Fs X2V2ZW50Y250ciA9IGV2ZW50Y250cjsKICAgICAgICB9CiAgICAgICAgcHRocmVhZF9tdXRl eF91bmxvY2soJm10eCk7CiAgICAgICAgaWYgKHdyaXRlKGgsIGJ1Ziwgc2l6ZW9mKGJ1Zikp ICE9IChpbnQpIHNpemVvZihidWYpKQogICAgICAgICAgICBwZXJyb3IoIndyaXRlKCkiKTsK ICAgIH0KICAgIHJldHVybiBOVUxMOwp9CgoKdm9pZCBzaWdfaGFuZGxlciAoaW50IHNpZ25v KQp7CiAgICBzd2l0Y2ggKHNpZ25vKQogICAgewogICAgICAgIGNhc2UgU0lHSU5UOgogICAg ICAgICAgICBydW4gPSAwOwogICAgICAgICAgICBicmVhazsKICAgIH0KfQoKCmludCBvcGVu X2F1ZGlvICgpCnsKICAgIGludCBkZXZoOwogICAgaW50IGZtdCA9IEFGTVRfUzE2X05FOwog ICAgaW50IGNocyA9IDI7CiAgICBpbnQgc3BkID0gNDQxMDA7CiAgICBpbnQgZnJhZ3NpemU7 CiAgICBpbnQgZnJhZ3NldHRpbmc7CgogICAgZGV2aCA9IG9wZW4oQVVESU9fREVWLCBPX1JE T05MWSk7CiAgICBpZi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o dm9pZCAqKSBhdWRpb19oKTsKICAgIHB0aHJlYWRfY3JlYXRlKCZ0aWRfY29uc3VtZXIxLCBO VUxMLCBjb25zdW1lcl90aHJlYWQsICh2b2lkICopIG51bGxfaDEpOwogICAgcHRocmVhZF9j cmVhdGUoJnRpZF9jb25zdW1lcjIsIE5VTEwsIGNvbnN1bWVyX3RocmVhZCwgKHZvaWQgKikg bnVsbF9oMik7CgogICAgc2lnd2FpdCgmc2lnc2V0X3dhaXQsICZyZWN2X3NpZyk7CiAgICBy dW4gPSAwOwoKICAgIHB0aHJlYWRfam9pbih0aWRfY29uc3VtZXIxLCBOVUxMKTsKICAgIHB0 aHJlYWRfam9pbih0aWRfY29uc3VtZXIyLCBOVUxMKTsKICAgIHB0aHJlYWRfam9pbih0aWRf cHJvZHVjZXIsIE5VTEwpOwoKICAgIHB0aHJlYWRfY29uZF9kZXN0cm95KCZjb25kKTsKICAg IHB0aHJlYWRfbXV0ZXhfZGVzdHJveSgmbXR4KTsKCiAgICBjbG9zZShhdWRpb19oKTsKICAg IGNsb3NlKG51bGxfaDEpOwogICAgY2xvc2UobnVsbF9oMik7CgogICAgcmV0dXJuIDA7Cn0K
--------------4C7DB0877E0D7DFF1039EF4F--
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/