Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3710686imj; Tue, 19 Feb 2019 08:09:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IYNIF1gzzsxLx8Bgqn/qr+QNUWuJ0MoLleBlbTmplq5Rn72qpALQ99+57FODByLUI8z12+i X-Received: by 2002:a63:ae0e:: with SMTP id q14mr28896674pgf.151.1550592561962; Tue, 19 Feb 2019 08:09:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550592561; cv=none; d=google.com; s=arc-20160816; b=SlIJLVrHdrsfUj8u/nnzmt8azDqz/qBYjbuVPhmwkD47DAN8AL4Bas9A0iz0RdXXh2 eq5WfAw3B+wHgM/zULmXGBzKRbtjyzY117KGcJGxwWHMAdSEQEZctVkqn5HE6PcV73+P FtBllcYN5RmsL+DCzglcjYHMfh5vY5LOIVmc/83WoODNP4YYP0QAm0Gk9L++ZzVsZpI+ RAd5NyqH+VYcgAhnoO7fLIqImV8Gu4ZgMaPdUJZftXOvDUrrIwpmTyQMTUOfiRM5ENtQ wf+HZNoZrSFNyjzin9SfE4cpFuV5JdTBd9lmbQG3HsM8qpJ0qBlE89Thn2b4Sv98nPMU K4Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=USRAKIclLRghi1jbFcmtS2CEL0MCzYIIu3uyjS+p8iw=; b=mPrcy9rkKRCawbVeLLhRJSinRWy2Q/tGSDGTcdpU6YgsIfa2TAJY0Cs1jt0bdoDrRc HErHGDEEleT8FLj1TaYOHpOoDJ4JHRoh8+KAFMV3cY41J2PABmpvVdRgayl0mLX+qrzd cH+pch8KmdRPbHd8xB2/AEU/kZa5JjxUGxNUcGySFcxtXk7DvNxQK0HmedcPiu1UKq3Z tgk4v7S2fKMCR06NJsqqqAy16nvaXmFDj5waHjRc6ENylbpiAHDmHwET7XgD2VDBV0v2 kR4ROkDTosgrNS8102FNLfQ3mY7mfzXJ/Pl4LQ78RqXjcbq1EnFtnSJnLAj/fvoe+mp6 OpQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 98si11886659pla.320.2019.02.19.08.09.06; Tue, 19 Feb 2019 08:09:21 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728978AbfBSQIq (ORCPT + 99 others); Tue, 19 Feb 2019 11:08:46 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:34062 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbfBSQIq (ORCPT ); Tue, 19 Feb 2019 11:08:46 -0500 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1gw7wp-0001FM-2l; Tue, 19 Feb 2019 17:08:43 +0100 Date: Tue, 19 Feb 2019 17:08:43 +0100 From: Sebastian Andrzej Siewior To: linux-rt-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Steven Rostedt Subject: [PATCH RT 4/2] hrtimer: Don't lose state in cpu_chill() Message-ID: <20190219160842.qxpwicoa5tzq4njo@linutronix.de> References: <20190218163107.iwdpngwmbs6xyk7x@linutronix.de> <20190218163137.cmor4ek3odus5m6j@linutronix.de> <20190219160755.fn4c65ph4lzqflw2@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190219160755.fn4c65ph4lzqflw2@linutronix.de> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In cpu_chill() the state is set to TASK_UNINTERRUPTIBLE and a timer is programmed. On return the state is always TASK_RUNNING which means we lose the state if it was something other than RUNNING. Also set_current_state() sets ->task_state_change to within cpu_chill() which is not expected. Save the task state on entry and restore it on return. Simply set the state in order to avoid updating ->task_state_change. Cc: stable-rt@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior --- kernel/time/hrtimer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 851b2134e77f4..6f2736ec4b8ef 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1902,15 +1902,18 @@ void cpu_chill(void) { ktime_t chill_time; unsigned int freeze_flag = current->flags & PF_NOFREEZE; + long saved_state; + saved_state = current->state; chill_time = ktime_set(0, NSEC_PER_MSEC); - set_current_state(TASK_UNINTERRUPTIBLE); + __set_current_state_no_track(TASK_UNINTERRUPTIBLE); current->flags |= PF_NOFREEZE; sleeping_lock_inc(); schedule_hrtimeout(&chill_time, HRTIMER_MODE_REL_HARD); sleeping_lock_dec(); if (!freeze_flag) current->flags &= ~PF_NOFREEZE; + __set_current_state_no_track(saved_state); } EXPORT_SYMBOL(cpu_chill); #endif -- 2.20.1