Commit aa695ae
btrfs: avoid space_info locking when checking if tickets are served
When checking if a ticket was served, we take the space_info's spinlock.
If the ticket was served (its ->bytes is 0) or had an error (its ->error
it not 0) then we just unlock the space_info and return.
This however causes contention on the space_info's spinlock, which is
heavily used (space reservation, space flushing, allocating and
deallocating an extent from a block group (btrfs_update_block_group()),
etc).
Instead of using the space_info's spinlock to check if a ticket was
served, use a per ticket spinlock which isn't used by anyone other than
the task that created the ticket (stack allocated) and the task that
serves the ticket (a reclaim task or any task deallocating space that
ends up at btrfs_try_granting_tickets()).
After applying this patch and all previous patches from the same patchset
(many attempt to reduce space_info critical sections), lockstat showed
some improvements for a fs_mark test regarding the space_info's spinlock
'lock'. The lockstat results:
Before patchset:
con-bounces: 13733858
contentions: 15902322
waittime-total: 264902529.72
acq-bounces: 28161791
acquisitions: 38679282
After patchset:
con-bounces: 12032220
contentions: 1359803
waittime-total: 221806127.28
acq-bounces: 24717947
acquisitions: 34103281
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>1 parent 902d696 commit aa695ae
2 files changed
+34
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
| 520 | + | |
| 521 | + | |
520 | 522 | | |
521 | 523 | | |
522 | 524 | | |
523 | 525 | | |
524 | 526 | | |
525 | 527 | | |
| 528 | + | |
526 | 529 | | |
527 | 530 | | |
528 | 531 | | |
529 | 532 | | |
530 | 533 | | |
531 | 534 | | |
| 535 | + | |
532 | 536 | | |
533 | 537 | | |
534 | 538 | | |
| |||
1495 | 1499 | | |
1496 | 1500 | | |
1497 | 1501 | | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
1498 | 1513 | | |
1499 | 1514 | | |
1500 | 1515 | | |
| |||
1504 | 1519 | | |
1505 | 1520 | | |
1506 | 1521 | | |
1507 | | - | |
1508 | 1522 | | |
1509 | 1523 | | |
1510 | 1524 | | |
1511 | 1525 | | |
1512 | 1526 | | |
1513 | 1527 | | |
1514 | | - | |
1515 | | - | |
| 1528 | + | |
1516 | 1529 | | |
1517 | | - | |
1518 | 1530 | | |
| 1531 | + | |
1519 | 1532 | | |
1520 | 1533 | | |
1521 | 1534 | | |
1522 | 1535 | | |
1523 | 1536 | | |
| 1537 | + | |
| 1538 | + | |
1524 | 1539 | | |
1525 | 1540 | | |
1526 | | - | |
1527 | | - | |
1528 | | - | |
1529 | | - | |
1530 | 1541 | | |
1531 | 1542 | | |
1532 | 1543 | | |
| |||
1554 | 1565 | | |
1555 | 1566 | | |
1556 | 1567 | | |
1557 | | - | |
1558 | | - | |
1559 | 1568 | | |
1560 | | - | |
1561 | | - | |
| 1569 | + | |
1562 | 1570 | | |
1563 | | - | |
1564 | 1571 | | |
| 1572 | + | |
1565 | 1573 | | |
1566 | 1574 | | |
1567 | 1575 | | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
| 1576 | + | |
1571 | 1577 | | |
1572 | | - | |
| 1578 | + | |
1573 | 1579 | | |
1574 | 1580 | | |
1575 | 1581 | | |
| |||
1582 | 1588 | | |
1583 | 1589 | | |
1584 | 1590 | | |
1585 | | - | |
1586 | 1591 | | |
1587 | | - | |
| 1592 | + | |
1588 | 1593 | | |
| 1594 | + | |
| 1595 | + | |
1589 | 1596 | | |
| 1597 | + | |
1590 | 1598 | | |
1591 | 1599 | | |
1592 | 1600 | | |
| |||
1596 | 1604 | | |
1597 | 1605 | | |
1598 | 1606 | | |
| 1607 | + | |
1599 | 1608 | | |
1600 | | - | |
| 1609 | + | |
| 1610 | + | |
1601 | 1611 | | |
1602 | | - | |
1603 | 1612 | | |
1604 | 1613 | | |
1605 | 1614 | | |
1606 | 1615 | | |
1607 | | - | |
| 1616 | + | |
1608 | 1617 | | |
1609 | | - | |
| 1618 | + | |
1610 | 1619 | | |
1611 | 1620 | | |
1612 | 1621 | | |
| |||
1804 | 1813 | | |
1805 | 1814 | | |
1806 | 1815 | | |
| 1816 | + | |
1807 | 1817 | | |
1808 | 1818 | | |
1809 | 1819 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
| |||
0 commit comments