From patchwork Fri Apr 4 08:35:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 27793 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CBA9920490 for ; Fri, 4 Apr 2014 08:39:31 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wp18sf9847880obc.8 for ; Fri, 04 Apr 2014 01:39:31 -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=41IZugTexfjmaDWzAIxXqOszjrR5YHqIHhFcnOlWOV8=; b=Q523iFy2oHPalzD0tLvn0kjTNJ9J07Pdph5GSpaREXWlHuRvPES2baNDk5Znbs6m4Q 18L2Xz8HNcv5cuznhyhded/muHEKtpkzs8rfCA2YVAslDPMV2KGdiSgVah2vBL9b0NjG fnTbtktvGgBsA9QxgxYNOKkmpfYcbxcJb7EmO6yjzuFBuW3iqk5SiLdPWGRY9Xydf7Wt 8xyz4denB3mdmGOZjQA3Xerc0YmyYUTF62y4G3DtmrxNNvShuLIOMsI32aTjoErjHzaw GDSLSy9JF2IU3l0Fcn2sexjR9w/xJkDRWvSJDQOf2E52+0kUuHMIw+sDzuPnufgfkdty S16w== X-Gm-Message-State: ALoCoQkdesXXOXgTKFsKSWMEHrvro11zZ7UDhyviwbSXR/wPzlOYmoZMBfGhsBEcpmYo6nMppxAx X-Received: by 10.50.136.198 with SMTP id qc6mr1229886igb.4.1396600771288; Fri, 04 Apr 2014 01:39:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.68 with SMTP id f62ls880461qge.8.gmail; Fri, 04 Apr 2014 01:39:31 -0700 (PDT) X-Received: by 10.52.51.197 with SMTP id m5mr10264103vdo.9.1396600771114; Fri, 04 Apr 2014 01:39:31 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id gx4si1696845vcb.1.2014.04.04.01.39.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Apr 2014 01:39:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.172 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.172; Received: by mail-ve0-f172.google.com with SMTP id jx11so1201802veb.3 for ; Fri, 04 Apr 2014 01:39:31 -0700 (PDT) X-Received: by 10.58.107.65 with SMTP id ha1mr4093211veb.1.1396600771031; Fri, 04 Apr 2014 01:39:31 -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 v8csp95724vcv; Fri, 4 Apr 2014 01:39:29 -0700 (PDT) X-Received: by 10.66.144.227 with SMTP id sp3mr13575319pab.100.1396600768769; Fri, 04 Apr 2014 01:39:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jh5si4306992pbb.254.2014.04.04.01.39.28; Fri, 04 Apr 2014 01:39:28 -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 S1752330AbaDDIjT (ORCPT + 27 others); Fri, 4 Apr 2014 04:39:19 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:42803 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752410AbaDDIgZ (ORCPT ); Fri, 4 Apr 2014 04:36:25 -0400 Received: by mail-wi0-f181.google.com with SMTP id hm4so759403wib.8 for ; Fri, 04 Apr 2014 01:36:22 -0700 (PDT) X-Received: by 10.180.189.139 with SMTP id gi11mr2446472wic.53.1396600582160; Fri, 04 Apr 2014 01:36:22 -0700 (PDT) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id di9sm3258478wid.6.2014.04.04.01.36.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 04 Apr 2014 01:36:21 -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 4/8] hrtimer: update timer->state with 'pinned' information Date: Fri, 4 Apr 2014 14:05:31 +0530 Message-Id: <489558160713494c5e8840aa5d6c22a8064aa603.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.172 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: , 'Pinned' information would be required in migrate_hrtimers() now, as we can migrate non-pinned timers away without a hotplug (i.e. with cpuset.quiesce). And so we may need to identify pinned timers now, as we can't migrate them. This patch reuses the timer->state variable for setting this flag as there were enough number of free bits available in this variable. And there is no point increasing size of this struct by adding another field. Signed-off-by: Viresh Kumar --- include/linux/hrtimer.h | 3 +++ kernel/hrtimer.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 435ac4c..9fdb67b 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -55,6 +55,7 @@ enum hrtimer_restart { * 0x01 enqueued into rbtree * 0x02 callback function running * 0x04 timer is migrated to another cpu + * 0x08 timer is pinned to a cpu * * Special cases: * 0x03 callback function running and enqueued @@ -81,6 +82,8 @@ enum hrtimer_restart { #define HRTIMER_STATE_ENQUEUED 0x01 #define HRTIMER_STATE_CALLBACK 0x02 #define HRTIMER_STATE_MIGRATE 0x04 +#define HRTIMER_PINNED_SHIFT 3 +#define HRTIMER_STATE_PINNED (1 << HRTIMER_PINNED_SHIFT) /** * struct hrtimer - the basic hrtimer structure diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index d62fe32..c5a4bf4 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -905,7 +905,11 @@ static void __remove_hrtimer(struct hrtimer *timer, unsigned long newstate, hrtimer_force_reprogram(base->cpu_base, 1); } #endif - timer->state = newstate; + /* + * We need to preserve PINNED state here, otherwise we may end up + * migrating pinned hrtimers as well. + */ + timer->state = newstate | (timer->state & HRTIMER_STATE_PINNED); } /* remove hrtimer, called with base lock held */ @@ -970,6 +974,10 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, timer_stats_hrtimer_set_start_info(timer); + /* Update pinned state */ + timer->state &= ~HRTIMER_STATE_PINNED; + timer->state |= !!(mode & HRTIMER_MODE_PINNED) << HRTIMER_PINNED_SHIFT; + enqueue_hrtimer(timer); /* @@ -1227,7 +1235,7 @@ static void __run_hrtimer(struct hrtimer *timer, ktime_t *now) * hrtimer_start_range_ns() or in hrtimer_interrupt() */ if (restart != HRTIMER_NORESTART) { - BUG_ON(timer->state != HRTIMER_STATE_CALLBACK); + BUG_ON(!(timer->state & HRTIMER_STATE_CALLBACK)); enqueue_hrtimer(timer); }