Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp200705imm; Thu, 26 Jul 2018 01:50:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfznevfH7uA7yANG0sE6C9e4n0JGdEBfYc3EpBLVyYYEsmRe38Te9+vyt14UeTvOcR1pWys X-Received: by 2002:a17:902:8506:: with SMTP id bj6-v6mr1113565plb.210.1532595026036; Thu, 26 Jul 2018 01:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532595026; cv=none; d=google.com; s=arc-20160816; b=drDSYyuTWfo80oWn/5AxgWYl5M6r0JzELHxKyRps8S3jDhRfhazgPpi89fmfR/2KZ8 1HeMuGXpEXcaZ5jrDi62gvMkep64+B5OuSaWw5IQ+suHwptlwVxH/YViekkliR778dKb wQ7VqLY9sHrHTg9TX7d+FqAk+dH4pj99P4kUkHP8rK2YkOfVZ5rCtvJd28ppSDzvpnSG rQOia7p7K9KpUfhjfH5oGDt+JOZexFRLsOyAySe5XRsj7rU105fOHIZmI25I90s311sy B6+uACiXKCeD294lqrIHOWjq9qDuZvydwkgi7Wwm1KR1SS8oSmIlNimMA3k7qP/VqzQo bP9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=HP7XLcSw3NzLCk97uwXVfDZ00zo4Nc3jfsB0QS4QtTQ=; b=Gix8MSpJiJkST7NFPrYrN2gKLVLrl6I0jW8MktD07iNPyWAnkonURtK4kjYQLM1o/J qSuempi6zkqFqxjA5rZ5+g+fUvWK1bDlK5MtpbD97VsEyisoKpaIsnBv78+8teTz+TZ9 E1ojtmGsVU5FLEsFAEd6VJLUDOSiKbGYtb1IXduZHg+eFKhMausYGd3JTZSYIQ14UDYu 2ZCdM9POl9ABLA8ism7wIqpw/CshMRCkBjHQf0/AZGbrHDoGjuDmDo5972QDkowJBJVC 6jGEd8vaLBjVzOlTSb7RTkzjSExqniRLjjyjMw62kvNFvLMJHmFDXE0e459ZgMEB81zl CWlg== 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 n2-v6si876568pge.74.2018.07.26.01.50.11; Thu, 26 Jul 2018 01:50:26 -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; 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 S1729123AbeGZKEO (ORCPT + 99 others); Thu, 26 Jul 2018 06:04:14 -0400 Received: from alexa-out-blr-02.qualcomm.com ([103.229.18.198]:50994 "EHLO alexa-out-blr.qualcomm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728827AbeGZKEO (ORCPT ); Thu, 26 Jul 2018 06:04:14 -0400 X-Greylist: delayed 378 seconds by postgrey-1.27 at vger.kernel.org; Thu, 26 Jul 2018 06:04:12 EDT X-IronPort-AV: E=Sophos;i="5.51,404,1526322600"; d="scan'208";a="113498" Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by alexa-out-blr.qualcomm.com with ESMTP/TLS/AES256-SHA; 26 Jul 2018 14:12:05 +0530 X-IronPort-AV: E=McAfee;i="5900,7806,8965"; a="661274" Received: from gkohli-linux.qualcomm.com ([10.204.78.26]) by ironmsg02-blr.qualcomm.com with ESMTP; 26 Jul 2018 14:12:05 +0530 Received: by gkohli-linux.qualcomm.com (Postfix, from userid 427023) id 8754A3092; Thu, 26 Jul 2018 14:12:04 +0530 (IST) From: Gaurav Kohli To: john.stultz@linaro.org, tglx@linutronix.de, sboyd@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Gaurav Kohli Subject: [PATCH] timers: Clear must_forward_clk inside base lock Date: Thu, 26 Jul 2018 14:12:02 +0530 Message-Id: <1532594522-28045-1-git-send-email-gkohli@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While migrating timer to new base, there is a need to update base clk by calling forward_timer_base to avoid stale clock , but at the same time if run_timer is exectuing in new core it may set must_forward_clk to false and due to this forward base logic may fail as per below check: if (likely(!base->must_forward_clk)) return; So preventing the same by putting must_forward_clk inside base lock. Signed-off-by: Gaurav Kohli diff --git a/kernel/time/timer.c b/kernel/time/timer.c index cc2d23e..675241d 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1657,6 +1657,19 @@ static inline void __run_timers(struct timer_base *base) raw_spin_lock_irq(&base->lock); + /* + * must_forward_clk must be cleared before running timers so that any + * timer functions that call mod_timer will not try to forward the + * base. idle trcking / clock forwarding logic is only used with + * BASE_STD timers. + * + * The deferrable base does not do idle tracking at all, so we do + * not forward it. This can result in very large variations in + * granularity for deferrable timers, but they can be deferred for + * long periods due to idle. + */ + base->must_forward_clk = false; + while (time_after_eq(jiffies, base->clk)) { levels = collect_expired_timers(base, heads); @@ -1676,19 +1689,6 @@ static __latent_entropy void run_timer_softirq(struct softirq_action *h) { struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]); - /* - * must_forward_clk must be cleared before running timers so that any - * timer functions that call mod_timer will not try to forward the - * base. idle trcking / clock forwarding logic is only used with - * BASE_STD timers. - * - * The deferrable base does not do idle tracking at all, so we do - * not forward it. This can result in very large variations in - * granularity for deferrable timers, but they can be deferred for - * long periods due to idle. - */ - base->must_forward_clk = false; - __run_timers(base); if (IS_ENABLED(CONFIG_NO_HZ_COMMON)) __run_timers(this_cpu_ptr(&timer_bases[BASE_DEF])); -- 1.9.1