From: "George Spelvin" <linux@horizon.com>
To: rostedt@goodmis.org
Cc: linux@horizon.com, linux-kernel@vger.kernel.org
Subject: Re: [patch 2/3] scheduler: add full memory barriers upon task
Date: 2 Feb 2010 17:42:41 -0500 [thread overview]
Message-ID: <20100202224241.10918.qmail@science.horizon.com> (raw)
> again:
> tmp_mask = mm_cpumask(current->mm);
> smp_mb();
> rcu_read_lock(); /* ensures validity of cpu_curr(cpu) tasks */
> for_each_cpu(cpu, tmp_mask) {
> spin_lock_irq(&cpu_rq(cpu)->lock);
> ret = current->mm == cpu_curr(cpu)->mm;
> spin_unlock_irq(&cpu_rq(cpu)->lock);
> if (ret)
> smp_call_function_single(cpu, membarrier_ipi, NULL, 1);
> }
> rcu_read_unlock();
> smp_mb();
> if (tmp_mask != mm_cpumask(current->mm)) {
> /* do check for signals here */
> goto again;
> }
How about the harder-to-livelock version that avoids sending
a second IPI to all the processors if the retry condition
hits?
(It also caches current->mm across the various barriers, as I think the
compiler will have difficulty inferring that otherwise).
cpumask_t unsent_mask;
cpumask_setall(&unsent_mask);
cpumask_clear_cpu(smp_processor_id(), &unsent_mask);
struct mm_struct const *current_mm = current->mm;
for (;;) {
cpumask_t const *tmp_mask = mm_cpumask(current_mm);
int cpu = cpumask_next_and(-1, tmp_mask, &unsent_mask);
if (cpu > nr_cpu_ids)
break;
smp_mb();
rcu_read_lock(); /* ensures validity of cpu_curr(cpu) tasks */
do {
struct mm_struct const *other_mm;
spin_lock_irq(&cpu_rq(cpu)->lock);
other_mm = cpu_curr(cpu)->mm;
spin_unlock_irq(&cpu_rq(cpu)->lock);
if (other_mm == current_mm) {
smp_call_function_single(cpu, membarrier_ipi, NULL, 1);
cpumask_clear_cpu(cpu, &unsent_mask);
}
cpu = cpumask_next_and(cpu, tmp_mask, &unsent_mask);
} while (cpu < nr_cpu_ids);
rcu_read_unlock();
smp_mb();
/* And now check again if any more CPUs have joined the mm */
}
reply other threads:[~2010-02-02 22:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100202224241.10918.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).