Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sched/wqueue/notifier: protect the work notifier with critical section #2767

Merged
merged 2 commits into from Jan 30, 2021

Conversation

anchao
Copy link
Contributor

@anchao anchao commented Jan 28, 2021

Summary

sched/wqueue/notifier: protect the work notifier with critical section

replace the semaphore to avoid the notifier holding the lock in the interrupt context

ASSERT:

libs/libc/assert/lib_assert.c:36   :_assert
sched/semphore/sem_wait.c:113      :nxsem_wait
sched/semphore/sem_wait.c:222      :nxsem_wait_uniterruptible
sched/wqueue/kwork_notifier.c:371  :work_notifier_signal
mm/iob/iob_free.c:188              :iob_free
drivers/syslog/syslog_stream.c:272 :syslogstream_destroy
...
sched/irq/irq_dispatch.c:183       :irq_dispatch

Signed-off-by: chao.an anchao@xiaomi.com

Impact

call syslog() on interrupt context

Testing

replace the semaphore to avoid the notifier holding the lock in the interrupt context

ASSERT:

libs/libc/assert/lib_assert.c:36   :_assert
sched/semphore/sem_wait.c:113      :nxsem_wait
sched/semphore/sem_wait.c:222      :nxsem_wait_uniterruptible
sched/wqueue/kwork_notifier.c:371  :work_notifier_signal
mm/iob/iob_free.c:188              :iob_free
drivers/syslog/syslog_stream.c:272 :syslogstream_destroy
...
sched/irq/irq_dispatch.c:183       :irq_dispatch

Signed-off-by: chao.an <anchao@xiaomi.com>
@anchao anchao force-pushed the 21012801 branch 3 times, most recently from 2d711aa to 5e6f32e Compare January 29, 2021 11:49
Copy link
Contributor

@davids5 davids5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments/suggestions . If you feel it is OK as is. Just ignore the comments.

sched/wqueue/kwork_notifier.c Show resolved Hide resolved
sched/wqueue/kwork_notifier.c Show resolved Hide resolved
replace the unique key to freerun counter to avoid traverse
of the notifier list.

Signed-off-by: chao.an <anchao@xiaomi.com>
Copy link
Contributor

@davids5 davids5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that looks better.

Do we know what is the lifetime a notification can live in the list?

The older look up work_notifier_find(key) seams to imply that collision can happen and most be avoided. Even at 32 bits, the number will still wrap. Will this be an issue?

@xiaoxiang781216
Copy link
Contributor

Ok that looks better.

Do we know what is the lifetime a notification can live in the list?

The older look up work_notifier_find(key) seams to imply that collision can happen and most be avoided. Even at 32 bits, the number will still wrap. Will this be an issue?

The lifetime of notifier is short and the generation rate(from tcp, iob and usb) is also slow, so the possibility is very low. And to reduce the possibity even furture, the patch extend key from 16bit to 32bit too.

@davids5 davids5 merged commit 5cf794e into apache:master Jan 30, 2021
@btashton btashton added this to To-Add in Release Notes - 10.1.0 Apr 12, 2021
@jerpelea jerpelea moved this from To-Add to Minor in Release Notes - 10.1.0 Apr 12, 2021
@jerpelea jerpelea moved this from Minor to Added in Release Notes - 10.1.0 Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants