Re: [PATCH 2/3] relay: Fix race condition which occurs when reading across CPUs.

From: Pekka Enberg
Date: Sat Jun 14 2008 - 12:16:22 EST


On Fri, 13 Jun 2008 23:26:41 -0500
Tom Zanussi <tzanussi@xxxxxxxxx> wrote:
>> Alternatively, you could get rid of the problem by making sure CPU0
>> never reads CPU1's data, by having the userspace reader use per-cpu
>> threads and using sched_setaffinity() to pin each thread to a given
>> cpu. See for example, the blktrace code, which does this.

On Sat, Jun 14, 2008 at 6:11 PM, Eduard - Gabriel Munteanu
<eduard.munteanu@xxxxxxxxxxx> wrote:
> Yes, and performance-wise this is better. Though I'm not sure setting
> affinity is 100% safe. Will the thread be migrated soon enough, so we
> don't read cross-CPU? The point is I'm not sure how hard this is
> enforced.
>
> However, I suggest this patch should go in, for two reasons:
> 1. It provides expected behavior in any such situation.
> 2. It adds (almost) no overhead when used in conjuction with setting CPU
> affinity. When the writer acquires the spinlock, it does not busy-wait,
> so the spinlock just disables IRQs (relay_write()).

Agreed. Tom, any objections to merging this patch?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/