Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754506AbbGXRRK (ORCPT ); Fri, 24 Jul 2015 13:17:10 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:35672 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753184AbbGXRRI (ORCPT ); Fri, 24 Jul 2015 13:17:08 -0400 Date: Fri, 24 Jul 2015 19:16:58 +0200 From: Frederic Weisbecker To: Chris Metcalf Cc: LKML , Peter Zijlstra , Thomas Gleixner , Preeti U Murthy , Christoph Lameter , Ingo Molnar , Viresh Kumar , Rik van Riel Subject: Re: [PATCH 05/10] nohz: New tick dependency mask Message-ID: <20150724171655.GA20925@lerouge> References: <1437669735-8786-1-git-send-email-fweisbec@gmail.com> <1437669735-8786-6-git-send-email-fweisbec@gmail.com> <55B26E07.1020005@ezchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55B26E07.1020005@ezchip.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2031 Lines: 61 On Fri, Jul 24, 2015 at 12:55:35PM -0400, Chris Metcalf wrote: > On 07/23/2015 12:42 PM, Frederic Weisbecker wrote: > >+unsigned long __tick_nohz_set_tick_dependency(enum tick_dependency_bit bit, > >+ unsigned long *dep) > >+{ > >+ unsigned long prev; > >+ unsigned long old = *dep; > >+ unsigned long mask = BIT_MASK(bit); > >+ > >+ while ((prev = cmpxchg(dep, old, old | mask)) != old) { > >+ old = prev; > >+ cpu_relax(); > >+ } > >+ > >+ return prev; > >+} > > Why not use set_bit() here? It is suitably atomic. Because I don't want to send an IPI if the CPU already had bits set in the dependency. Ideally I need something like test_and_set_bit() but which returns the whole previous value and not just the previous value of the bit. > > >+ /* > >+ * We need the IPIs to be sent from sane process context. > >+ * The posix cpu timers are always set with irqs disabled. > >+ */ > > The block comment indentation is not quite right here. Right. > > >+void tick_nohz_set_tick_dependency_cpu(enum tick_dependency_bit bit, int cpu) > >+{ > >+ unsigned long prev; > >+ struct tick_sched *ts; > >+ > >+ ts = per_cpu_ptr(&tick_cpu_sched, cpu); > >+ > >+ prev = __tick_nohz_set_tick_dependency(bit, &ts->tick_dependency); > >+ if (!prev) > >+ tick_nohz_full_kick_cpu(cpu); > >+} > > I could imagine arguments for a WARN_ON() if cpu == smp_processor_id() here, > since then you should be using the _thiscpu() variant. > Or, you could transparently call the _thiscpu() variant in that case. > I think some comment explaining why the approach you chose is better > than those alternatives would be helpful here, perhaps. It's fine to use this variant for local dependency but if you want it to be NMI safe you need the _this_cpu() version. perf events require it. -- 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/