From patchwork Tue Mar 31 15:19:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 46596 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 66AE5216E5 for ; Tue, 31 Mar 2015 15:20:03 +0000 (UTC) Received: by lbbug6 with SMTP id ug6sf4504178lbb.3 for ; Tue, 31 Mar 2015 08:20:02 -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=M3tKlCdg8E2lx9d6lCUBYL3JP2ejvfyPWJAv1nqIqHo=; b=VLBkvAzbfOWQfVkeBfxdhGhqaDFv4Ze8OSXabmplwN+FTPa8iyP/s7oIiAZCu1uIvo 0nQJkKffHMzlLrunX71i79VyiIPuuyIuYD2ji4D1fOALb47HDTA69hXvzeZMkGtgzKf5 SOYy6KC+ZN4/WqVplcfywZ5mujILGSXVh/AwX/vSY6JXIy85crfzvMQF4wfLJGPEQZsQ dtat5JP2yI7o5GcxfcnlSlVrfURcb89wCPyc7+TRqJ1CGuxcJEmEV7rKz/21oO1HCkYG wtCpAFiBZBhwL+aSztqPajZ050EzL5ua4XjbOvGdj3bk4fDYrQt6LMz/JizYIuZw9UhP Z2Bw== X-Gm-Message-State: ALoCoQmRHVhwLqF/LnmK40VTKRzhdQkQ4TtGBXPek5C1NQp3dTEemqZI5RqQOHyLWVfjfaD2q+JU X-Received: by 10.180.90.175 with SMTP id bx15mr811714wib.3.1427815202354; Tue, 31 Mar 2015 08:20:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.129 with SMTP id ay1ls523210lab.61.gmail; Tue, 31 Mar 2015 08:20:02 -0700 (PDT) X-Received: by 10.112.131.66 with SMTP id ok2mr31018942lbb.51.1427815202158; Tue, 31 Mar 2015 08:20:02 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id iq2si2715721lac.127.2015.03.31.08.20.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Mar 2015 08:20:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by lajy8 with SMTP id y8so15324318laj.0 for ; Tue, 31 Mar 2015 08:20:02 -0700 (PDT) X-Received: by 10.152.4.104 with SMTP id j8mr11611141laj.72.1427815202052; Tue, 31 Mar 2015 08:20:02 -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.112.57.201 with SMTP id k9csp51933lbq; Tue, 31 Mar 2015 08:20:01 -0700 (PDT) X-Received: by 10.70.36.198 with SMTP id s6mr13561887pdj.143.1427815200134; Tue, 31 Mar 2015 08:20:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si19870056pdd.111.2015.03.31.08.19.58; Tue, 31 Mar 2015 08:20:00 -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 S932330AbbCaPTu (ORCPT + 27 others); Tue, 31 Mar 2015 11:19:50 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:35603 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932298AbbCaPTp (ORCPT ); Tue, 31 Mar 2015 11:19:45 -0400 Received: by pddn5 with SMTP id n5so23821942pdd.2 for ; Tue, 31 Mar 2015 08:19:45 -0700 (PDT) X-Received: by 10.66.156.7 with SMTP id wa7mr15651199pab.99.1427815185067; Tue, 31 Mar 2015 08:19:45 -0700 (PDT) Received: from localhost ([122.167.118.120]) by mx.google.com with ESMTPSA id dr5sm14277152pdb.48.2015.03.31.08.19.43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 31 Mar 2015 08:19:44 -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 V2 2/3] timer: Don't initialize tvec_base on hotplug Date: Tue, 31 Mar 2015 20:49:01 +0530 Message-Id: <54a1c30ea7b805af55beb220cadf5a07a21b0a4d.1427814611.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.215.52 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(). Cc: Ingo Molnar Cc: Thomas Gleixner Cc: linaro-kernel@lists.linaro.org Signed-off-by: Viresh Kumar Signed-off-by: Peter Zijlstra (Intel) --- kernel/time/timer.c | 98 +++++++++++++++++++++++------------------------------ 1 file changed, 43 insertions(+), 55 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index f3cc653f876c..1feb9c7035c0 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1543,43 +1543,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]; - int j; - - if (!tvec_base_done[cpu]) { - static char boot_cpu_skipped; - - if (!boot_cpu_skipped) { - boot_cpu_skipped = 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) { @@ -1621,6 +1584,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); @@ -1630,25 +1596,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; } @@ -1656,18 +1613,49 @@ 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; + struct tvec_base *base; + int local_cpu = smp_processor_id(); + int cpu; + + for_each_possible_cpu(cpu) { + if (cpu == local_cpu) + base = &boot_tvec_bases; + else + base = per_cpu_ptr(&__tvec_bases, cpu); + + 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);