Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1198825

Re: [PATCH 05/10] nohz: New tick dependency mask

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH 05/10] nohz: New tick dependency mask
Date 2015-08-03 14:50 +0200
Message-ID <pTnlM-3kJ-31@gated-at.bofh.it> (permalink)
References <pPrQZ-3Wb-3@gated-at.bofh.it> <pPrR0-3Wb-7@gated-at.bofh.it> <pPOue-3ci-15@gated-at.bofh.it> <pPONA-3O6-13@gated-at.bofh.it> <pPPgB-4me-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jul 24, 2015 at 01:43:38PM -0400, Chris Metcalf wrote:
> On 07/24/2015 01:16 PM, Frederic Weisbecker wrote:
> >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.
> 
> Ah, of course.  Peter, maybe we need atomic_or_return() as part
> of your new atomic_or/_and/_xor series?  Certainly on tilegx, and
> likely other architectures, we can do better than Frederic's
> cmpxchg() loop.

No, atomic_or_return() would return the new value and is entirely
pointless for the logic ops since they're not reversible (with the
exception of xor).

What you'd need is atomic_fetch_or(), but we don't have any fetch_$op
primitives at all. Introducing them might make sense, but it'll have to
be a separate series.

Note that I have a fetch_or() macro in kernel/sched/core.c.
--
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 | Find similar | Unroll thread


Thread

Re: [PATCH 05/10] nohz: New tick dependency mask Peter Zijlstra <peterz@infradead.org> - 2015-08-03 14:50 +0200

csiph-web