From patchwork Mon Mar 30 05:17:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 46465 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f198.google.com (mail-yk0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 934332159F for ; Mon, 30 Mar 2015 05:17:57 +0000 (UTC) Received: by ykeg184 with SMTP id g184sf51101971yke.3 for ; Sun, 29 Mar 2015 22:17:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=N3l2UwWJjZ8j7bermxdDjtkSVBfIIW+ZgeZMgeyJLvQ=; b=LNk6xriNRpRQlKfTjMjy47hHIJHoDC/dR0HhHvPBxBhkR6+a9kqIk+Q8rhfKg5wMG1 3aTaj+Oy5ZTKUKjF3wR8oYSX17AxklZnK29G3LvhULkzemlk04qsjZpeO/Nv8vrqiVEB qAtFpvXoKypZ0i8QEGErQqBocmigT6Dq0Ft+C3zwRYQ/ElOBQve30oQYPoG0+T8Z3a7M rHxRIPOYxBAgGGmYyyFeCG+/9u3qqkgBAf7XnJCIm/98nTiK3Ycu9QEA40KXJ+kEbM0j EZxYqwMYFe3ZFy/nXHozqxssI9dc0KGMYTFuqBqbYrYcyo3nKUS8wFbCx9aMZYqjHNLp v0YA== X-Gm-Message-State: ALoCoQkmOwvGf8yYJ+ZKjwGLGo5/cyIPgOIGXYxmZgrKVArjvVE0uiOqS7VqIwk18Fobm2T/N2En X-Received: by 10.236.207.230 with SMTP id n66mr36250107yho.30.1427692677442; Sun, 29 Mar 2015 22:17:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.41.169 with SMTP id z38ls2178335qgz.72.gmail; Sun, 29 Mar 2015 22:17:57 -0700 (PDT) X-Received: by 10.55.42.160 with SMTP id q32mr64611717qkq.68.1427692677373; Sun, 29 Mar 2015 22:17:57 -0700 (PDT) Received: from mail-qc0-f180.google.com (mail-qc0-f180.google.com. [209.85.216.180]) by mx.google.com with ESMTPS id 21si9403641qht.87.2015.03.29.22.17.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Mar 2015 22:17:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.216.180 as permitted sender) client-ip=209.85.216.180; Received: by qcay5 with SMTP id y5so61833633qca.1 for ; Sun, 29 Mar 2015 22:17:57 -0700 (PDT) X-Received: by 10.140.94.242 with SMTP id g105mr37764870qge.2.1427692677266; Sun, 29 Mar 2015 22:17:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.96.155.231 with SMTP id vz7csp1204649qdb; Sun, 29 Mar 2015 22:17:56 -0700 (PDT) X-Received: by 10.66.100.138 with SMTP id ey10mr54912905pab.142.1427692674646; Sun, 29 Mar 2015 22:17:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oj13si13174346pdb.149.2015.03.29.22.17.53; Sun, 29 Mar 2015 22:17:54 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752797AbbC3FRr (ORCPT + 27 others); Mon, 30 Mar 2015 01:17:47 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:34880 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752729AbbC3FRk (ORCPT ); Mon, 30 Mar 2015 01:17:40 -0400 Received: by pddn5 with SMTP id n5so48060227pdd.2 for ; Sun, 29 Mar 2015 22:17:39 -0700 (PDT) X-Received: by 10.66.216.40 with SMTP id on8mr55348968pac.27.1427692659841; Sun, 29 Mar 2015 22:17:39 -0700 (PDT) Received: from localhost ([122.167.118.120]) by mx.google.com with ESMTPSA id h9sm9083479pdo.5.2015.03.29.22.17.38 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 29 Mar 2015 22:17:39 -0700 (PDT) From: Viresh Kumar To: Ingo Molnar , Peter Zijlstra , Thomas Gleixner Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 3/3] timer: Don't initialize tvec_base on hotplug Date: Mon, 30 Mar 2015 10:47:19 +0530 Message-Id: <9624d9e80b5d499937ecd6877c39bec27a5b28b9.1427691098.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.3.0.rc0.44.ga94655d In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.216.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , There is no need to call init_timers_cpu() on every cpu hotplug event, there is not much we need to reset. - Timer-lists are already empty at the end of migrate_timers(). - timer_jiffies will be refreshed while adding a new timer, after the CPU is online again. - active_timers and all_timers can be reset from migrate_timers(). Signed-off-by: Viresh Kumar --- kernel/time/timer.c | 101 +++++++++++++++++++++++----------------------------- 1 file changed, 45 insertions(+), 56 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 40918a5d3e1d..aa02d49b3748 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1532,44 +1532,6 @@ signed long __sched schedule_timeout_uninterruptible(signed long timeout) } EXPORT_SYMBOL(schedule_timeout_uninterruptible); -static int init_timers_cpu(int cpu) -{ - struct tvec_base *base = per_cpu(tvec_bases, cpu); - static char tvec_base_done[NR_CPUS]; - static DEFINE_PER_CPU(struct tvec_base, __tvec_bases); - int j; - - if (!tvec_base_done[cpu]) { - static char boot_done; - - if (!boot_done) { - boot_done = 1; /* skip the boot cpu */ - } else { - base = per_cpu_ptr(&__tvec_bases, cpu); - per_cpu(tvec_bases, cpu) = base; - } - - spin_lock_init(&base->lock); - tvec_base_done[cpu] = 1; - base->cpu = cpu; - } - - for (j = 0; j < TVN_SIZE; j++) { - INIT_LIST_HEAD(base->tv5.vec + j); - INIT_LIST_HEAD(base->tv4.vec + j); - INIT_LIST_HEAD(base->tv3.vec + j); - INIT_LIST_HEAD(base->tv2.vec + j); - } - for (j = 0; j < TVR_SIZE; j++) - INIT_LIST_HEAD(base->tv1.vec + j); - - base->timer_jiffies = jiffies; - base->next_timer = base->timer_jiffies; - base->active_timers = 0; - base->all_timers = 0; - return 0; -} - #ifdef CONFIG_HOTPLUG_CPU static void migrate_timer_list(struct tvec_base *new_base, struct list_head *head) { @@ -1611,6 +1573,9 @@ static void migrate_timers(int cpu) migrate_timer_list(new_base, old_base->tv5.vec + i); } + old_base->active_timers = 0; + old_base->all_timers = 0; + spin_unlock(&old_base->lock); spin_unlock_irq(&new_base->lock); put_cpu_var(tvec_bases); @@ -1620,25 +1585,16 @@ static void migrate_timers(int cpu) static int timer_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { - long cpu = (long)hcpu; - int err; - - switch(action) { - case CPU_UP_PREPARE: - case CPU_UP_PREPARE_FROZEN: - err = init_timers_cpu(cpu); - if (err < 0) - return notifier_from_errno(err); - break; #ifdef CONFIG_HOTPLUG_CPU + switch (action) { case CPU_DEAD: case CPU_DEAD_FROZEN: - migrate_timers(cpu); + migrate_timers((long)hcpu); break; -#endif default: break; } +#endif return NOTIFY_OK; } @@ -1646,18 +1602,51 @@ static struct notifier_block timers_nb = { .notifier_call = timer_cpu_notify, }; +static void __init init_timer_cpu(struct tvec_base *base, int cpu) +{ + int j; -void __init init_timers(void) + base->cpu = cpu; + per_cpu(tvec_bases, cpu) = base; + spin_lock_init(&base->lock); + + for (j = 0; j < TVN_SIZE; j++) { + INIT_LIST_HEAD(base->tv5.vec + j); + INIT_LIST_HEAD(base->tv4.vec + j); + INIT_LIST_HEAD(base->tv3.vec + j); + INIT_LIST_HEAD(base->tv2.vec + j); + } + for (j = 0; j < TVR_SIZE; j++) + INIT_LIST_HEAD(base->tv1.vec + j); + + base->timer_jiffies = jiffies; + base->next_timer = base->timer_jiffies; +} + +static void __init init_timer_cpus(void) { - int err; + /* Used for all CPUs, except boot CPU (which uses boot_tvec_bases) */ + static DEFINE_PER_CPU(struct tvec_base, __tvec_bases); + struct tvec_base *base; + int local_cpu = smp_processor_id(); + int cpu; + + for_each_possible_cpu(cpu) { + if (likely(cpu != local_cpu)) + base = per_cpu_ptr(&__tvec_bases, cpu); + else + base = &boot_tvec_bases; + + init_timer_cpu(base, cpu); + } +} +void __init init_timers(void) +{ /* ensure there are enough low bits for flags in timer->base pointer */ BUILD_BUG_ON(__alignof__(struct tvec_base) & TIMER_FLAG_MASK); - err = timer_cpu_notify(&timers_nb, (unsigned long)CPU_UP_PREPARE, - (void *)(long)smp_processor_id()); - BUG_ON(err != NOTIFY_OK); - + init_timer_cpus(); init_timer_stats(); register_cpu_notifier(&timers_nb); open_softirq(TIMER_SOFTIRQ, run_timer_softirq);