| @@ -376,7 +376,7 @@ int x86_add_exclusive(unsigned int what) · 375 unmodified lines |
| 376 | * LBR and BTS are still mutually exclusive. | 376 | * LBR and BTS are still mutually exclusive. |
| 377 | */ | 377 | */ |
| 378 | if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt) | 378 | if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt) |
| 379 | return 0; | 379 | goto out; |
| 380 | | 380 | |
| 381 | if (!atomic_inc_not_zero(&x86_pmu.lbr_exclusive[what])) { | 381 | if (!atomic_inc_not_zero(&x86_pmu.lbr_exclusive[what])) { |
| 382 | mutex_lock(&pmc_reserve_mutex); | 382 | mutex_lock(&pmc_reserve_mutex); |
| @@ -388,6 +388,7 @@ int x86_add_exclusive(unsigned int what) · 5 unmodified lines |
| 388 | mutex_unlock(&pmc_reserve_mutex); | 388 | mutex_unlock(&pmc_reserve_mutex); |
| 389 | } | 389 | } |
| 390 | | 390 | |
| | 391 | out: |
| 391 | atomic_inc(&active_events); | 392 | atomic_inc(&active_events); |
| 392 | return 0; | 393 | return 0; |
| 393 | | 394 | |
| @@ -398,11 +399,15 @@ fail_unlock: · 4 unmodified lines |
| 398 | | 399 | |
| 399 | void x86_del_exclusive(unsigned int what) | 400 | void x86_del_exclusive(unsigned int what) |
| 400 | { | 401 | { |
| | 402 | atomic_dec(&active_events); |
| | 403 | |
| | 404 | /* |
| | 405 | * See the comment in x86_add_exclusive(). |
| | 406 | */ |
| 401 | if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt) | 407 | if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt) |
| 402 | return; | 408 | return; |
| 403 | | 409 | |
| 404 | atomic_dec(&x86_pmu.lbr_exclusive[what]); | 410 | atomic_dec(&x86_pmu.lbr_exclusive[what]); |
| 405 | atomic_dec(&active_events); | | |
| 406 | } | 411 | } |
| 407 | | 412 | |
| 408 | int x86_setup_perfctr(struct perf_event *event) | 413 | int x86_setup_perfctr(struct perf_event *event) |
| @@ -1642,9 +1647,12 @@ static struct attribute_group x86_pmu_format_group __ro_after_init = { · 1233 unmodified lines |
| 1642 | | 1647 | |
| 1643 | ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr, char *page) | 1648 | ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr, char *page) |
| 1644 | { | 1649 | { |
| 1645 | struct perf_pmu_events_attr *pmu_attr = \ | 1650 | struct perf_pmu_events_attr *pmu_attr = |
| 1646 | container_of(attr, struct perf_pmu_events_attr, attr); | 1651 | container_of(attr, struct perf_pmu_events_attr, attr); |
| 1647 | u64 config = x86_pmu.event_map(pmu_attr->id); | 1652 | u64 config = 0; |
| | 1653 | |
| | 1654 | if (pmu_attr->id < x86_pmu.max_events) |
| | 1655 | config = x86_pmu.event_map(pmu_attr->id); |
| 1648 | | 1656 | |
| 1649 | /* string trumps id */ | 1657 | /* string trumps id */ |
| 1650 | if (pmu_attr->event_str) | 1658 | if (pmu_attr->event_str) |
| @@ -1713,6 +1721,9 @@ is_visible(struct kobject *kobj, struct attribute *attr, int idx) · 62 unmodified lines |
| 1713 | { | 1721 | { |
| 1714 | struct perf_pmu_events_attr *pmu_attr; | 1722 | struct perf_pmu_events_attr *pmu_attr; |
| 1715 | | 1723 | |
| | 1724 | if (idx >= x86_pmu.max_events) |
| | 1725 | return 0; |
| | 1726 | |
| 1716 | pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr.attr); | 1727 | pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr.attr); |
| 1717 | /* str trumps id */ | 1728 | /* str trumps id */ |
| 1718 | return pmu_attr->event_str || x86_pmu.event_map(idx) ? attr->mode : 0; | 1729 | return pmu_attr->event_str || x86_pmu.event_map(idx) ? attr->mode : 0; |