From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423018AbcFMLkW (ORCPT ); Mon, 13 Jun 2016 07:40:22 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:44464 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422859AbcFMLkQ (ORCPT ); Mon, 13 Jun 2016 07:40:16 -0400 Date: Mon, 13 Jun 2016 13:40:05 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: LKML , Ingo Molnar , "Paul E. McKenney" , Eric Dumazet , Frederic Weisbecker , Chris Mason , Arjan van de Ven , rt@linutronix.de Subject: Re: [patch 13/20] timer: Switch to a non cascading wheel Message-ID: <20160613114005.GY30909@twins.programming.kicks-ass.net> References: <20160613070440.950649741@linutronix.de> <20160613075929.282143900@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160613075929.282143900@linutronix.de> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 13, 2016 at 08:41:00AM -0000, Thomas Gleixner wrote: > + * HZ 1000 > + * Level Offset Granularity Range > + * 0 0 1 ms 0 ms - 63 ms > + * 1 64 8 ms 64 ms - 511 ms > + * 2 128 64 ms 512 ms - 4095 ms (512ms - ~4s) > + * 3 192 512 ms 4096 ms - 32767 ms (~4s - ~32s) > + * 4 256 4096 ms (~4s) 32768 ms - 262143 ms (~32s - ~4m) > + * 5 320 32768 ms (~32s) 262144 ms - 2097151 ms (~4m - ~34m) > +static int collect_expired_timers(struct timer_base *base, > + struct hlist_head *heads) > +{ > + unsigned long clock = base->clk; > + struct hlist_head tmp, *vec; > + int i, levels = 0; > + unsigned int idx; > + > + /* Expire the regular buckets */ > + for (i = 0; i < LVL_DEPTH - 1; i++) { > + idx = (clock & LVL_MASK) + i * LVL_SIZE; > + > + if (__test_and_clear_bit(idx, base->pending_map)) { > + vec = base->vectors + idx; > + hlist_move_list(vec, heads++); > + levels++; > + } > + /* Is it time to look at the next level? */ > + if (clock & LVL_CLK_MASK) > + return levels; > + /* Shift clock for the next level granularity */ > + clock >>= LVL_CLK_SHIFT; > + } > + > + /* Cascading, sigh... */ So given that userspace has no influence on timer period; can't we simply fail to support timers longer than 30 minutes? In anything really arming timers _that_ long? > + idx = (clock & LVL_MASK) + i * LVL_SIZE; > + > + if (__test_and_clear_bit(idx, base->pending_map)) { > + vec = base->vectors + idx; > + hlist_move_list(vec, &tmp); > + /* Make sure we queue them in the future */ > + base->clk++; > + while (!hlist_empty(&tmp)) { > + struct timer_list *timer; > + > + timer = hlist_entry(tmp.first, struct timer_list, entry); > + trace_timer_cascade(timer); > + __hlist_del(&timer->entry); > + __internal_add_timer(base, timer); > + } > + base->clk--; > + } > + return levels; > +}