Commit a24fc53
committed
Speedup vDSO CNTVCT and amortized urandom
vDSO clock_gettime drops from 1256 ns SVC trap to 2.5ns via CNTVCT-based
fast path (493x speedup, 20x under the sub-50 ns design target). The
trampoline emits a 28-instruction A64 sequence that reads CNTVCT_EL0,
LDAR-acquires the vvar initialized flag, and interpolates wall clock
from the anchor as delta * 125 / 3 (Apple Silicon CNTFRQ = 24 MHz),
falling back to SVC on first call or CNTVCT regression. The first SVC
seeds the vvar via a three-state CAS (0 -> 2 -> 1) so concurrent first
calls cannot tear the anchor fields. The seed is gated on ELR_EL1
matching the trampoline's svc_fallback PC so an unrelated raw
clock_gettime syscall cannot poison the anchor from arbitrary X9.
/dev/urandom 1-byte reads drop from 5688 ns uncached to 2054 ns (2.77x)
via a new per-fd entropy cache: an arc4random_buf-refilled 4 KiB buffer
per FD_URANDOM slot. The cache is zeroed on close via a type-to-cleanup
registry that also closes pre-existing dup and fork-state race windows
for every synthetic fd type.
eventfd dup shares state across aliases per the Linux contract
(refcounted slot plus eventfd_owner[FD_TABLE_SIZE] table). The dup path
holds fd_lock and sfd_lock together for the bind commit so racing close
cannot leak the refcount; the source identity is pinned via snapshotted
host fd so a racing close-and-rebind of the source cannot bind to the
wrong slot. tests/test-eventfd-dup pins the shared-state contract.
fork_ipc_send_fd_table filters eventfd, signalfd, timerfd, inotify,
netlink, pidfd, and epoll out of the SCM_RIGHTS payload. macOS rejects
kqueue fds across SCM_RIGHTS and per-class side-table state is not
transferable, so a clean drop is the only honest contract.
tests/test-fork-synthetic-fd pins it.
Startup decomposition: ELFUSE_STARTUP_TRACE=1 emits per-step wall time
for VM bring-up (17 steps on test-hello, dominated by hv_vcpu_create and
guest_init at roughly 0.9 ms each). Zero overhead when unset.1 parent b065c43 commit a24fc53
34 files changed
Lines changed: 2056 additions & 167 deletions
File tree
- src
- core
- runtime
- syscall
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
| 338 | + | |
337 | 339 | | |
338 | 340 | | |
339 | 341 | | |
340 | 342 | | |
| 343 | + | |
341 | 344 | | |
342 | 345 | | |
343 | 346 | | |
344 | 347 | | |
| 348 | + | |
345 | 349 | | |
346 | 350 | | |
347 | 351 | | |
| |||
374 | 378 | | |
375 | 379 | | |
376 | 380 | | |
| 381 | + | |
377 | 382 | | |
378 | 383 | | |
379 | 384 | | |
380 | 385 | | |
| 386 | + | |
381 | 387 | | |
382 | 388 | | |
383 | 389 | | |
| |||
405 | 411 | | |
406 | 412 | | |
407 | 413 | | |
| 414 | + | |
408 | 415 | | |
409 | 416 | | |
410 | 417 | | |
411 | 418 | | |
412 | 419 | | |
| 420 | + | |
413 | 421 | | |
414 | 422 | | |
415 | 423 | | |
| |||
427 | 435 | | |
428 | 436 | | |
429 | 437 | | |
| 438 | + | |
430 | 439 | | |
431 | 440 | | |
| 441 | + | |
432 | 442 | | |
433 | 443 | | |
434 | 444 | | |
435 | 445 | | |
436 | 446 | | |
437 | 447 | | |
438 | 448 | | |
| 449 | + | |
439 | 450 | | |
440 | 451 | | |
441 | 452 | | |
| |||
448 | 459 | | |
449 | 460 | | |
450 | 461 | | |
| 462 | + | |
451 | 463 | | |
| 464 | + | |
452 | 465 | | |
453 | 466 | | |
454 | 467 | | |
455 | 468 | | |
456 | 469 | | |
| 470 | + | |
457 | 471 | | |
458 | 472 | | |
459 | 473 | | |
460 | 474 | | |
461 | 475 | | |
462 | 476 | | |
463 | 477 | | |
| 478 | + | |
464 | 479 | | |
465 | 480 | | |
466 | 481 | | |
467 | 482 | | |
468 | 483 | | |
| 484 | + | |
469 | 485 | | |
470 | 486 | | |
| 487 | + | |
471 | 488 | | |
472 | 489 | | |
473 | 490 | | |
474 | 491 | | |
475 | 492 | | |
| 493 | + | |
476 | 494 | | |
477 | 495 | | |
478 | 496 | | |
479 | 497 | | |
480 | 498 | | |
481 | 499 | | |
| 500 | + | |
482 | 501 | | |
483 | 502 | | |
484 | 503 | | |
| |||
505 | 524 | | |
506 | 525 | | |
507 | 526 | | |
| 527 | + | |
508 | 528 | | |
509 | 529 | | |
510 | 530 | | |
511 | 531 | | |
512 | 532 | | |
513 | 533 | | |
| 534 | + | |
514 | 535 | | |
515 | 536 | | |
516 | 537 | | |
| |||
526 | 547 | | |
527 | 548 | | |
528 | 549 | | |
| 550 | + | |
529 | 551 | | |
530 | 552 | | |
531 | 553 | | |
| |||
536 | 558 | | |
537 | 559 | | |
538 | 560 | | |
| 561 | + | |
539 | 562 | | |
540 | 563 | | |
541 | 564 | | |
542 | 565 | | |
543 | 566 | | |
544 | 567 | | |
| 568 | + | |
545 | 569 | | |
546 | 570 | | |
547 | 571 | | |
548 | 572 | | |
549 | 573 | | |
| 574 | + | |
550 | 575 | | |
| 576 | + | |
551 | 577 | | |
552 | 578 | | |
553 | 579 | | |
554 | 580 | | |
555 | 581 | | |
556 | 582 | | |
557 | 583 | | |
| 584 | + | |
558 | 585 | | |
559 | 586 | | |
560 | 587 | | |
| |||
564 | 591 | | |
565 | 592 | | |
566 | 593 | | |
| 594 | + | |
567 | 595 | | |
568 | 596 | | |
569 | 597 | | |
| |||
599 | 627 | | |
600 | 628 | | |
601 | 629 | | |
| 630 | + | |
602 | 631 | | |
603 | 632 | | |
604 | 633 | | |
| |||
613 | 642 | | |
614 | 643 | | |
615 | 644 | | |
| 645 | + | |
616 | 646 | | |
| 647 | + | |
617 | 648 | | |
618 | 649 | | |
619 | 650 | | |
620 | 651 | | |
621 | 652 | | |
622 | 653 | | |
623 | 654 | | |
| 655 | + | |
624 | 656 | | |
625 | 657 | | |
626 | 658 | | |
| |||
632 | 664 | | |
633 | 665 | | |
634 | 666 | | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
635 | 673 | | |
636 | 674 | | |
637 | 675 | | |
| |||
645 | 683 | | |
646 | 684 | | |
647 | 685 | | |
| 686 | + | |
648 | 687 | | |
649 | 688 | | |
650 | 689 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| 206 | + | |
| 207 | + | |
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
| |||
257 | 260 | | |
258 | 261 | | |
259 | 262 | | |
| 263 | + | |
260 | 264 | | |
261 | 265 | | |
262 | 266 | | |
| |||
266 | 270 | | |
267 | 271 | | |
268 | 272 | | |
| 273 | + | |
269 | 274 | | |
270 | 275 | | |
271 | 276 | | |
| |||
307 | 312 | | |
308 | 313 | | |
309 | 314 | | |
| 315 | + | |
310 | 316 | | |
311 | 317 | | |
| 318 | + | |
312 | 319 | | |
313 | 320 | | |
314 | 321 | | |
| |||
320 | 327 | | |
321 | 328 | | |
322 | 329 | | |
| 330 | + | |
323 | 331 | | |
324 | 332 | | |
325 | 333 | | |
| |||
335 | 343 | | |
336 | 344 | | |
337 | 345 | | |
| 346 | + | |
338 | 347 | | |
| 348 | + | |
339 | 349 | | |
340 | 350 | | |
| 351 | + | |
341 | 352 | | |
342 | 353 | | |
343 | 354 | | |
| |||
380 | 391 | | |
381 | 392 | | |
382 | 393 | | |
| 394 | + | |
| 395 | + | |
383 | 396 | | |
384 | 397 | | |
385 | 398 | | |
| |||
403 | 416 | | |
404 | 417 | | |
405 | 418 | | |
| 419 | + | |
406 | 420 | | |
407 | 421 | | |
| 422 | + | |
408 | 423 | | |
409 | 424 | | |
410 | 425 | | |
| |||
417 | 432 | | |
418 | 433 | | |
419 | 434 | | |
| 435 | + | |
420 | 436 | | |
421 | 437 | | |
422 | 438 | | |
| |||
426 | 442 | | |
427 | 443 | | |
428 | 444 | | |
| 445 | + | |
429 | 446 | | |
430 | 447 | | |
431 | 448 | | |
432 | 449 | | |
433 | 450 | | |
434 | 451 | | |
435 | 452 | | |
| 453 | + | |
436 | 454 | | |
437 | 455 | | |
| 456 | + | |
438 | 457 | | |
439 | 458 | | |
440 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
| |||
0 commit comments