Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1227208
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | single_task_running() vs. preemption warnings (was Re: [PATCH] kvm: fix preemption warnings in kvm_vcpu_block) |
| Date | 2015-09-17 18:50 +0200 |
| Message-ID | <q9KxI-W9-21@gated-at.bofh.it> (permalink) |
| References | <q9Ken-yZ-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 17/09/2015 18:27, Dominik Dingel wrote:
> + preempt_disable();
> + solo = single_task_running();
> + preempt_enable();
> +
> cur = ktime_get();
> - } while (single_task_running() && ktime_before(cur, stop));
That's the obvious way to fix it, but the TOCTTOU problem (which was in
the buggy code too) is obvious too. :) And the only other user of
single_task_running() in drivers/crypto/mcryptd.c has the same issue.
In fact, because of the way the function is used ("maybe I can do a
little bit of work before going to sleep") it will likely be called many
times in a loop. This in turn means that:
- any wrong result due to a concurrent process migration would be
rectified very soon
- preempt_disable()/preempt_enable() can actually be just as expensive
or more expensive than single_task_running() itself.
Therefore, I wonder if single_task_running() should just use
raw_smp_processor_id(). At least the TOCTTOU issue can be clearly
documented in the function comment, instead of being hidden behind each
of the callers.
Thanks,
Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] kvm: fix preemption warnings in kvm_vcpu_block Dominik Dingel <dingel@linux.vnet.ibm.com> - 2015-09-17 18:30 +0200
single_task_running() vs. preemption warnings (was Re: [PATCH] kvm: fix preemption warnings in kvm_vcpu_block) Paolo Bonzini <pbonzini@redhat.com> - 2015-09-17 18:50 +0200
Re: single_task_running() vs. preemption warnings (was Re: [PATCH] kvm: fix preemption warnings in kvm_vcpu_block) Dominik Dingel <dingel@linux.vnet.ibm.com> - 2015-09-17 19:10 +0200
Re: single_task_running() vs. preemption warnings (was Re: [PATCH] kvm: fix preemption warnings in kvm_vcpu_block) Tim Chen <tim.c.chen@linux.intel.com> - 2015-09-17 22:50 +0200
Re: single_task_running() vs. preemption warnings (was Re: [PATCH] kvm: fix preemption warnings in kvm_vcpu_block) Peter Zijlstra <peterz@infradead.org> - 2015-09-18 10:00 +0200
csiph-web