From patchwork Thu Mar 20 13:49:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 26708 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B405C202E0 for ; Thu, 20 Mar 2014 13:50:04 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id lx4sf3059794iec.11 for ; Thu, 20 Mar 2014 06:50:03 -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=mHHBp7FUF48w798SLEYkNMIqOSz2w3FHgC7Ripv/yJQ=; b=WTdJl87cUnGS8i55G+fKvcylJL+/HFVMsaLDZjMCaqNbh+Oln1eT9LYRms0zlJeDDb D2I4uaPeQQbMG+L7iT5GtYoQ+6HdkMne5V69zDbzcLaLbBfIpWqE1MEOSuW12TWG5sDo kVMgUCpLHJxvOQxaYLvTXgXDqtu5GKb333BLtolrhbU9XWYgvDbUYmFhqvlR/ipURUdV yJpqCk4Ftivs2+mF06M2Xn/SA9Wwmi6p4f61svRQj7BPWkWEHxmaR6i1k+t6Z1ZSjiQs ALUF/wFxZA5L/D69yQH7AIfaIgB7TY9FCqJ+Jt91I6Grw6TshZzb7z+qrTiidrkOGnB+ cuhQ== X-Gm-Message-State: ALoCoQno3W9OsaOqKlObVwgtICeemIlu0GgCWSSSMjLvdYrnuch59dveMzlYtK4a9tjAQ6RSINdu X-Received: by 10.43.92.73 with SMTP id bp9mr16163151icc.26.1395323403491; Thu, 20 Mar 2014 06:50:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.33 with SMTP id c30ls271647qge.9.gmail; Thu, 20 Mar 2014 06:50:03 -0700 (PDT) X-Received: by 10.220.92.135 with SMTP id r7mr34030348vcm.11.1395323403373; Thu, 20 Mar 2014 06:50:03 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id qr10si435582vcb.81.2014.03.20.06.50.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 06:50:03 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so931153veb.23 for ; Thu, 20 Mar 2014 06:50:03 -0700 (PDT) X-Received: by 10.58.34.101 with SMTP id y5mr34005294vei.8.1395323403281; Thu, 20 Mar 2014 06:50:03 -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.220.78.9 with SMTP id i9csp389609vck; Thu, 20 Mar 2014 06:50:02 -0700 (PDT) X-Received: by 10.66.119.172 with SMTP id kv12mr47288081pab.34.1395323402176; Thu, 20 Mar 2014 06:50:02 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tk5si1533171pbc.166.2014.03.20.06.50.01; Thu, 20 Mar 2014 06:50:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758992AbaCTNtj (ORCPT + 26 others); Thu, 20 Mar 2014 09:49:39 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:58538 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757914AbaCTNtg (ORCPT ); Thu, 20 Mar 2014 09:49:36 -0400 Received: by mail-pd0-f171.google.com with SMTP id r10so943531pdi.16 for ; Thu, 20 Mar 2014 06:49:35 -0700 (PDT) X-Received: by 10.66.164.36 with SMTP id yn4mr47021816pab.25.1395323375786; Thu, 20 Mar 2014 06:49:35 -0700 (PDT) Received: from localhost ([122.172.246.56]) by mx.google.com with ESMTPSA id pq3sm4042148pbb.57.2014.03.20.06.49.31 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 20 Mar 2014 06:49:35 -0700 (PDT) From: Viresh Kumar To: tglx@linutronix.de, fweisbec@gmail.com, peterz@infradead.org, mingo@kernel.org, tj@kernel.org, lizefan@huawei.com Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Viresh Kumar Subject: [RFC 3/4] timer: create timer_quiesce_cpu() for cpusets.quiesce option Date: Thu, 20 Mar 2014 19:19:00 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e 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=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , Cpusets would be using timer migration code to isolate/quiese a CPU. And hence that should be changed a bit as the CPU in question would be online now. Also we need to make sure that we don't remove pinned timers. Signed-off-by: Viresh Kumar --- kernel/timer.c | 54 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/kernel/timer.c b/kernel/timer.c index a7f8b99..81d64e0 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1602,18 +1602,27 @@ static int init_timers_cpu(int cpu) return 0; } -#ifdef CONFIG_HOTPLUG_CPU -static void migrate_timer_list(struct tvec_base *new_base, struct list_head *head) +#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_CPUSETS) +static void migrate_timer_list(struct tvec_base *new_base, + struct list_head *head, bool remove_pinned) { struct timer_list *timer; + struct list_head pinned_list; int is_pinned; + INIT_LIST_HEAD(&pinned_list); + while (!list_empty(head)) { timer = list_first_entry(head, struct timer_list, entry); - /* We ignore the accounting on the dying cpu */ - detach_timer(timer, false); is_pinned = tbase_get_pinned(timer->base); + if (!remove_pinned && is_pinned) { + list_move_tail(&timer->entry, &pinned_list); + continue; + } else { + /* We ignore the accounting on the dying cpu */ + detach_timer(timer, false); + } /* Check if CPU still has pinned timers */ if (is_pinned) { @@ -1625,15 +1634,18 @@ static void migrate_timer_list(struct tvec_base *new_base, struct list_head *hea timer_set_base(timer, new_base); internal_add_timer(new_base, timer); } + + if (!list_empty(&pinned_list)) + list_splice_tail(&pinned_list, head); } -static void migrate_timers(int cpu) +/* Migrate timers from 'cpu' to this_cpu */ +static void __migrate_timers(int cpu, bool remove_pinned) { struct tvec_base *old_base; struct tvec_base *new_base; int i; - BUG_ON(cpu_online(cpu)); old_base = per_cpu(tvec_bases, cpu); new_base = get_cpu_var(tvec_bases); /* @@ -1646,20 +1658,40 @@ static void migrate_timers(int cpu) BUG_ON(old_base->running_timer); for (i = 0; i < TVR_SIZE; i++) - migrate_timer_list(new_base, old_base->tv1.vec + i); + migrate_timer_list(new_base, old_base->tv1.vec + i, + remove_pinned); for (i = 0; i < TVN_SIZE; i++) { - migrate_timer_list(new_base, old_base->tv2.vec + i); - migrate_timer_list(new_base, old_base->tv3.vec + i); - migrate_timer_list(new_base, old_base->tv4.vec + i); - migrate_timer_list(new_base, old_base->tv5.vec + i); + migrate_timer_list(new_base, old_base->tv2.vec + i, + remove_pinned); + migrate_timer_list(new_base, old_base->tv3.vec + i, + remove_pinned); + migrate_timer_list(new_base, old_base->tv4.vec + i, + remove_pinned); + migrate_timer_list(new_base, old_base->tv5.vec + i, + remove_pinned); } spin_unlock(&old_base->lock); spin_unlock_irq(&new_base->lock); put_cpu_var(tvec_bases); } +#endif /* CONFIG_HOTPLUG_CPU || CONFIG_CPUSETS */ + +#ifdef CONFIG_HOTPLUG_CPU +static void migrate_timers(int cpu) +{ + BUG_ON(cpu_online(cpu)); + __migrate_timers(cpu, true); +} #endif /* CONFIG_HOTPLUG_CPU */ +#ifdef CONFIG_CPUSETS +void timer_quiesce_cpu(void *data) +{ + __migrate_timers((int)data, false); +} +#endif /* CONFIG_CPUSETS */ + static int timer_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) {