From patchwork Fri Apr 4 08:35:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 27794 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 092C120490 for ; Fri, 4 Apr 2014 08:39:55 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id bj1sf11451292pad.11 for ; Fri, 04 Apr 2014 01:39:55 -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=ioclyXhFrpsxQOh5itexxgTiD0WDvTbmdsDLXM0/ZNo=; b=D09FQfzwiRbgpcPrFl7fjFYRYa9n5qq4R0rCW1NWWat5gluwTpN61AcGjf6TI3fQB5 7EUbju1+fAIFNWEkPD0YTpiMDCEzZJjkPK8wwCJLlXtfmVcHFHOUGaRzrST14eusJHxo SY8HP7ZVACE7yTe4cKlPML/dOpYiQjuGzkktVIcBeqdOvZTHidxWTmoIQCpeOI10JVKI kvG9YQeE4d1gCROWK+ue8YsHVaur76TKn7XNSRKgg9rMFX8Py2Uqj9B+p4hK2J5ORZa4 lZHriNuR2vBwl+1uv2oIZQodVHct2uHSe4/h3bQd3OBSsdkEOhw472sKIKiCX8RRcY10 eyhg== X-Gm-Message-State: ALoCoQmhqUBbbbqoiATepuk4o70tOPMZwJBCXRhhEM8e0zqUS2xOUOrLhc5m4WJEf5zaEh8m/bpY X-Received: by 10.66.66.163 with SMTP id g3mr4059117pat.3.1396600795261; Fri, 04 Apr 2014 01:39:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.105 with SMTP id y96ls927828qgd.82.gmail; Fri, 04 Apr 2014 01:39:55 -0700 (PDT) X-Received: by 10.58.23.6 with SMTP id i6mr3963374vef.12.1396600795167; Fri, 04 Apr 2014 01:39:55 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id bj3si1674674vcb.172.2014.04.04.01.39.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Apr 2014 01:39:55 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 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.176; Received: by mail-ve0-f176.google.com with SMTP id db11so1171057veb.7 for ; Fri, 04 Apr 2014 01:39:55 -0700 (PDT) X-Received: by 10.52.78.231 with SMTP id e7mr316784vdx.28.1396600795086; Fri, 04 Apr 2014 01:39:55 -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.12.8 with SMTP id v8csp95748vcv; Fri, 4 Apr 2014 01:39:53 -0700 (PDT) X-Received: by 10.68.170.131 with SMTP id am3mr4203100pbc.97.1396600793061; Fri, 04 Apr 2014 01:39:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dj5si4292984pad.451.2014.04.04.01.39.52; Fri, 04 Apr 2014 01:39:52 -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 S1752135AbaDDIjq (ORCPT + 27 others); Fri, 4 Apr 2014 04:39:46 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:54681 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752170AbaDDIgR (ORCPT ); Fri, 4 Apr 2014 04:36:17 -0400 Received: by mail-we0-f173.google.com with SMTP id w61so3012191wes.4 for ; Fri, 04 Apr 2014 01:36:15 -0700 (PDT) X-Received: by 10.180.92.196 with SMTP id co4mr2568529wib.50.1396600574921; Fri, 04 Apr 2014 01:36:14 -0700 (PDT) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id jd2sm3252870wic.9.2014.04.04.01.36.10 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 04 Apr 2014 01:36:14 -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, linaro-networking@linaro.org, Arvind.Chauhan@arm.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Viresh Kumar Subject: [PATCH V2 3/8] timer: create timer_quiesce_cpu() to isolate CPU from timers Date: Fri, 4 Apr 2014 14:05:30 +0530 Message-Id: <12833475ef32cb4ee832e40dbbc0445c4d8ab3e7.1396599474.git.viresh.kumar@linaro.org> 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.176 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: , To isolate CPUs (isolate from timers) from sysfs using cpusets, we need some support from the timer core. i.e. A routine timer_quiesce_cpu() which would migrate away all the unpinned timers, but shouldn't touch the pinned ones. This patch creates this routine. Signed-off-by: Viresh Kumar --- include/linux/timer.h | 3 +++ kernel/timer.c | 54 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/include/linux/timer.h b/include/linux/timer.h index 2962403..1588a4f 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -196,6 +196,9 @@ extern void set_timer_slack(struct timer_list *time, int slack_hz); */ extern unsigned long get_next_timer_interrupt(unsigned long now); +/* To be used from cpusets, only */ +extern void timer_quiesce_cpu(void *cpup); + /* * Timer-statistics info: */ diff --git a/kernel/timer.c b/kernel/timer.c index 6c3a371..4676a07 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 (unlikely(WARN(is_pinned, @@ -1624,15 +1633,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); /* @@ -1645,20 +1657,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 *cpup) +{ + __migrate_timers(*(int *)cpup, false); +} +#endif /* CONFIG_CPUSETS */ + static int timer_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) {