Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1764169AbZD3ONj (ORCPT ); Thu, 30 Apr 2009 10:13:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1764134AbZD3OMt (ORCPT ); Thu, 30 Apr 2009 10:12:49 -0400 Received: from mx2.mail.elte.hu ([157.181.151.9]:41636 "EHLO mx2.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763377AbZD3OMr (ORCPT ); Thu, 30 Apr 2009 10:12:47 -0400 Date: Thu, 30 Apr 2009 16:10:50 +0200 From: Ingo Molnar To: Christoph Lameter Cc: Mathieu Desnoyers , Tejun Heo , Nick Piggin , Peter Zijlstra , Yuriy Lalym , Linux Kernel Mailing List , ltt-dev@lists.casi.polymtl.ca, Andrew Morton , thomas.pi@arcor.dea, Linus Torvalds Subject: Re: [ltt-dev] [PATCH] Fix dirty page accounting in redirty_page_for_writepage() Message-ID: <20090430141050.GC14696@elte.hu> References: <20090429232546.GB15782@Krystal> <20090430024303.GB19875@Krystal> <20090430062140.GA9559@elte.hu> <20090430063306.GA27431@Krystal> <20090430065055.GA16277@elte.hu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-ELTE-VirusStatus: clean X-ELTE-SpamScore: -1.5 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-1.5 required=5.9 tests=BAYES_00 autolearn=no SpamAssassin version=3.2.3 -1.5 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1788 Lines: 58 * Christoph Lameter wrote: > On Thu, 30 Apr 2009, Ingo Molnar wrote: > > > > I see however that it's only guaranteed to be atomic wrt preemption. > > > > That's really only true for the non-x86 fallback defines. If we so > > decide, we could make the fallbacks in asm-generic/percpu.h irq-safe > > The fallbacks have different semantics and therefore we cannot > rely on irq safeness in the core code when using the x86 cpu ops. Well it's irq and preempt safe on x86. It's preempt-safe on other architectures - but the fallback is not irq-safe on other architectures. That is remedied easily via the patch below. (Note: totally untested) Ingo diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 1581ff2..6b3984a 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h @@ -139,17 +139,23 @@ static inline void free_percpu(void *p) #ifndef percpu_read # define percpu_read(var) \ ({ \ + unsigned long flags; \ typeof(per_cpu_var(var)) __tmp_var__; \ - __tmp_var__ = get_cpu_var(var); \ - put_cpu_var(var); \ + \ + local_irq_save(flags); \ + __tmp_var__ = __get_cpu_var(var); \ + local_irq_restore(flags); \ __tmp_var__; \ }) #endif #define __percpu_generic_to_op(var, val, op) \ do { \ - get_cpu_var(var) op val; \ - put_cpu_var(var); \ + unsigned long flags; \ + \ + local_irq_save(flags); \ + op val; \ + local_irq_restore(flags); \ } while (0) #ifndef percpu_write -- 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/