From patchwork Wed May 22 08:34:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 17084 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A7B1B238FE for ; Wed, 22 May 2013 08:35:10 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hr11sf2185798vcb.7 for ; Wed, 22 May 2013 01:34:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to :mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=ygZgScFkBG0CLafnbgf1XsEZ9oy+qtgWlqzMrHxVnCw=; b=eejzihL216SFbPyXXblGVdPCRzaQVk3/p1uJK/gOJHxF+Qpx2AoZIG8qxg0fueT+5M ByCWEfyEgH0o6krBq9AxaOHseeHWjiZRZIt+ptNTBbHHH82OyXiSk2itoOc+JeJYQM7G OgQui8YRUIdkKhLREyG+hyLW/sxszSJCCBjMbVJCOuIROqp+fHiBxDFyRCM+I343XT0t jHpkEjxdJMhLB+/LLnSq/fluyaELHDk9Xw/zVun54CokYawnwxzAKSXYEl4YTi9iso6k UVR+Rb31RpOyuhKwHVvN9vWFYIFf9nW29cUxuT0+uRz36rctELRGMpNIcBlaTc5jc90i C8rA== X-Received: by 10.224.59.205 with SMTP id m13mr3374131qah.7.1369211658241; Wed, 22 May 2013 01:34:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.86.202 with SMTP id r10ls722458qez.86.gmail; Wed, 22 May 2013 01:34:18 -0700 (PDT) X-Received: by 10.52.163.69 with SMTP id yg5mr2091815vdb.38.1369211658110; Wed, 22 May 2013 01:34:18 -0700 (PDT) Received: from mail-ve0-x22e.google.com (mail-ve0-x22e.google.com [2607:f8b0:400c:c01::22e]) by mx.google.com with ESMTPS id ad7si3210432vdc.55.2013.05.22.01.34.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 May 2013 01:34:18 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22e; Received: by mail-ve0-f174.google.com with SMTP id oy12so1215184veb.5 for ; Wed, 22 May 2013 01:34:18 -0700 (PDT) X-Received: by 10.58.172.67 with SMTP id ba3mr2367748vec.58.1369211657927; Wed, 22 May 2013 01:34:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.126.138 with SMTP id c10csp170951vcs; Wed, 22 May 2013 01:34:17 -0700 (PDT) X-Received: by 10.182.148.39 with SMTP id tp7mr4046728obb.15.1369211656937; Wed, 22 May 2013 01:34:16 -0700 (PDT) Received: from mail-ob0-x236.google.com (mail-ob0-x236.google.com [2607:f8b0:4003:c01::236]) by mx.google.com with ESMTPS id r7si3846002oej.44.2013.05.22.01.34.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 May 2013 01:34:16 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:4003:c01::236 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=2607:f8b0:4003:c01::236; Received: by mail-ob0-f182.google.com with SMTP id va2so1925607obc.13 for ; Wed, 22 May 2013 01:34:16 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.98.135 with SMTP id ei7mr3867239obb.102.1369211656422; Wed, 22 May 2013 01:34:16 -0700 (PDT) Received: by 10.182.180.16 with HTTP; Wed, 22 May 2013 01:34:16 -0700 (PDT) In-Reply-To: References: <1354024039.6276.72.camel@gandalf.local.home> Date: Wed, 22 May 2013 14:04:16 +0530 Message-ID: Subject: Re: [PATCH V2 Resend 4/4] timer: Migrate running timer From: Viresh Kumar To: Thomas Gleixner Cc: Steven Rostedt , pjt@google.com, paul.mckenney@linaro.org, tj@kernel.org, mingo@redhat.com, peterz@infradead.org, Arvind.Chauhan@arm.com, linaro-dev@lists.linaro.org, patches@linaro.org, pdsw-power-team@arm.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, john stultz X-Gm-Message-State: ALoCoQkDXcPVNvbHzvgG1yP6RhRPJkJQgqHYOQGE7hkqaMWXm+/HDpTB51987TiTuqNwoXz12qmr X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22e 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Sorry for being late in replying to your queries. On 13 May 2013 16:05, Thomas Gleixner wrote: > Which mechanism is migrating the timer away? It will be the same: get_nohz_timer_target() which will decide target cpu for migration. > I have no objections to the functionality per se, but the proposed > solution is not going to fly. > > Aside of bloating the data structure you're changing the semantics of > __mod_timer(). No __mod_timer() caller can deal with -EBUSY. So you'd > break the world and some more. Ahh.. That idea was dropped already. > Here is a list of questions: > > - Which mechanism migrates timers? > > - How is that mechanism triggered? The mechanism remains the same as is for non-rearmed timers. i.e. get_nohz_timer_target().. We are just trying to give a approach with which we can migrate running timers. i.e. those which re-arm themselves from their handlers. > - How does that deal with CPU bound timers? We will still check 'Pinned' for this timer as is done for any other normal timer. So, we don't migrate them. So, this is the clean draft for the idea I had.. (Naming is poor for now): timer->expires = expires; @@ -990,7 +984,8 @@ int try_to_del_timer_sync(struct timer_list *timer) base = lock_timer_base(timer, &flags); - if (base->running_timer != timer) { + if ((base->running_timer != timer) && + !timer->wait_for_migration_to_complete) { timer_stats_timer_clear_start_info(timer); ret = detach_if_pending(timer, base, true); } @@ -1183,6 +1178,8 @@ static inline void __run_timers(struct tvec_base *base) call_timer_fn(timer, fn, data); spin_lock_irq(&base->lock); } + if (timer->wait_for_migration_to_complete) + timer->wait_for_migration_to_complete = 0; } } base->running_timer = NULL; Please see if it a junk idea or has some light of hope :) diff --git a/include/linux/timer.h b/include/linux/timer.h index 8c5a197..ad00ebe 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -20,6 +20,7 @@ struct timer_list { void (*function)(unsigned long); unsigned long data; + int wait_for_migration_to_complete; int slack; diff --git a/kernel/timer.c b/kernel/timer.c index a860bba..7791f28 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -746,21 +746,15 @@ __mod_timer(struct timer_list *timer, unsigned long expires, new_base = per_cpu(tvec_bases, cpu); if (base != new_base) { - /* - * We are trying to schedule the timer on the local CPU. - * However we can't change timer's base while it is running, - * otherwise del_timer_sync() can't detect that the timer's - * handler yet has not finished. This also guarantees that - * the timer is serialized wrt itself. - */ - if (likely(base->running_timer != timer)) { - /* See the comment in lock_timer_base() */ - timer_set_base(timer, NULL); - spin_unlock(&base->lock); - base = new_base; - spin_lock(&base->lock); - timer_set_base(timer, base); - } + if (base->running_timer == timer) + timer->wait_for_migration_to_complete = 1; + + /* See the comment in lock_timer_base() */ + timer_set_base(timer, NULL); + spin_unlock(&base->lock); + base = new_base; + spin_lock(&base->lock); + timer_set_base(timer, base); }