Commit 68ca27e
drm/ttm: Split cgroup charge and resource allocation
Coupling resource allocation and cgroup charging is racy when charging
succeeds, but subsequent resource allocation fails. Certain eviction
decisions are made on the basis of whether the allocating cgroup is
protected, i.e. within its min/low limits, but with the charge being
tied to resource allocation (and uncharged when the resource allocation
fails), this check is done at a point where the allocation is not actually
charged to the cgroup.
This is subtly wrong if the allocation were to cause the cgroup to exceed
the min/low protection, but it's even more wrong if the same cgroup tries
allocating multiple buffers concurrently: In this case, the min/low
protection may pass for all allocation attempts when the real min/low
protection covers only some, or potentially none of the allocated
buffers.
Instead, charge the allocation to the cgroup once and keep the charge
for as long as we try to allocate a ttm_resource, and only undo the charge
if allocating the resource is ultimately unsuccessful and we move on to
a different ttm_place.
Signed-off-by: Natalie Vock <natalie.vock@gmx.de>1 parent 7806d94 commit 68ca27e
3 files changed
Lines changed: 85 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
| 493 | + | |
| 494 | + | |
493 | 495 | | |
494 | 496 | | |
| 497 | + | |
| 498 | + | |
495 | 499 | | |
496 | 500 | | |
497 | 501 | | |
| |||
520 | 524 | | |
521 | 525 | | |
522 | 526 | | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
527 | 547 | | |
| 548 | + | |
528 | 549 | | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | 550 | | |
540 | | - | |
541 | | - | |
| 551 | + | |
542 | 552 | | |
543 | 553 | | |
544 | 554 | | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
545 | 560 | | |
546 | 561 | | |
547 | 562 | | |
| |||
596 | 611 | | |
597 | 612 | | |
598 | 613 | | |
599 | | - | |
600 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
601 | 617 | | |
602 | 618 | | |
603 | 619 | | |
| |||
636 | 652 | | |
637 | 653 | | |
638 | 654 | | |
| 655 | + | |
| 656 | + | |
639 | 657 | | |
640 | 658 | | |
641 | 659 | | |
| |||
666 | 684 | | |
667 | 685 | | |
668 | 686 | | |
| 687 | + | |
669 | 688 | | |
670 | 689 | | |
671 | 690 | | |
| |||
798 | 817 | | |
799 | 818 | | |
800 | 819 | | |
| 820 | + | |
801 | 821 | | |
802 | 822 | | |
803 | 823 | | |
| |||
806 | 826 | | |
807 | 827 | | |
808 | 828 | | |
809 | | - | |
810 | | - | |
811 | | - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
812 | 834 | | |
| 835 | + | |
813 | 836 | | |
| 837 | + | |
814 | 838 | | |
815 | 839 | | |
816 | 840 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
376 | 408 | | |
377 | 409 | | |
378 | 410 | | |
379 | | - | |
| 411 | + | |
380 | 412 | | |
381 | 413 | | |
382 | 414 | | |
383 | | - | |
384 | 415 | | |
385 | 416 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | 417 | | |
393 | | - | |
394 | | - | |
395 | | - | |
| 418 | + | |
396 | 419 | | |
397 | | - | |
398 | 420 | | |
399 | | - | |
| 421 | + | |
400 | 422 | | |
401 | 423 | | |
402 | 424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
459 | 463 | | |
460 | 464 | | |
461 | 465 | | |
462 | | - | |
| 466 | + | |
463 | 467 | | |
464 | 468 | | |
465 | 469 | | |
| |||
0 commit comments