Page MenuHomeFreeBSD

acpi: Tasks: Precisely report the maximum number of slots used
Needs ReviewPublic

Authored by olce on Mon, Oct 5, 5:04 PM.
Tags
None
Referenced Files
F175118288: D60375.id.diff
Thu, Oct 8, 9:38 AM
Unknown Object (File)
Wed, Oct 7, 10:53 AM
Unknown Object (File)
Wed, Oct 7, 12:14 AM
Unknown Object (File)
Tue, Oct 6, 2:36 AM
Unknown Object (File)
Tue, Oct 6, 2:36 AM
Unknown Object (File)
Tue, Oct 6, 2:35 AM
Unknown Object (File)
Tue, Oct 6, 2:35 AM
Unknown Object (File)
Tue, Oct 6, 2:35 AM
Subscribers

Details

Reviewers
obiwac
jkim
emaste
Summary

To this end, fix races when updating 'acpi_tasks_hiwater'.

In particular, one thread could enqueue first at a lower but
still-greater-than-the-current-maximum index, another thread then
enqueuing at some higher index, and then the first thread would update
'acpi_tasks_hiwater' while the second was exactly after the 'if (i >
acpi_tasks_hiwater)' but just before attempting the atomic_cmpset_int()
that updates 'acpi_task_hiwater', which then would fail (and the return
value was ignored), leading to the transient maximum not being recorded.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77729
Build 74612: arc lint + arc unit

Event Timeline

olce requested review of this revision.Mon, Oct 5, 5:04 PM
sys/dev/acpica/Osd/OsdSchedule.c
169

can we avoid the atomic in the common case?

olce marked an inline comment as done.Thu, Oct 8, 9:34 AM
olce added inline comments.
sys/dev/acpica/Osd/OsdSchedule.c
169

I don't think so, but don't think that makes a real difference either.

The access in the while() guard is just an explicitly "atomic" load of an int, but in the end is just compiled to an actual load (AFAIK; we actually implicitly depend on the loads of ints being atomic in a lot of places).

The atomic_cmpset_int() below is only executed while the high water value needs updating, so at most the number that it finally reports. Once it's stabilized, the i > hiwater test is always false and the atomic_cmpset_int() never executed again.

olce marked an inline comment as done.Thu, Oct 8, 9:34 AM