From patchwork Fri Jul 27 05:33:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu YiPing X-Patchwork-Id: 143009 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp397650ljj; Thu, 26 Jul 2018 22:33:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeGpPSU6BEJMbM+ZlxHXXuG64LKTHeAOZrD4VtjlnklliiAV6lc+9Tcj2+vdDuJGtWCVtG7 X-Received: by 2002:a62:57dc:: with SMTP id i89-v6mr5152538pfj.65.1532669628867; Thu, 26 Jul 2018 22:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532669628; cv=none; d=google.com; s=arc-20160816; b=PcjNzPvU/CgtUuYgyQqEnTyTa65d2T/G6z0p4iuWQUfZ7S/dHLJ0GMK4QVPnYWaYWT GcsRzYeD2sPI2EYv/2TWWJDdCsjq1qdXNOyRDU6WTMcmTnBsOa1Ab2ecgSek/TPvrzVv 2ekQz+8uWCAvwcN+lEQfJeIVjEPlACOm/sPQQFrXTrz7aN0oPnGFb2nS91up1h/msLBE rouX8jciLtMjGfNIFcIEa+2DlDtDQdPtRAEk7XFf5Rszz0GzLOmoO1fJeokFc3YIdbP5 qoa+nbvtoGNi5fyWk01/j3I3XW9G3a50+4HCwHEF3P1RSmHQQPOrdcAm8XvmoxOho749 3I3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=XuVgm0KU1PTnOicb8BvKdUK2Ums/zb7u+9xJJHyRwRQ=; b=ciYiJwlQazYGFJgVe54xj8pxWhDu7cV7b4ItJOTDB7tb8XUfYf9kI+Gai5jXRyhHAz J4cv04vhR7969W3O6Vd2cSYWLZy1VzqgAbqBKoqbdJzAnNHdaTaxqLE6rvrcFRq+4nPG XGg5JG3uuGSbhZ/gI7ee7Te1rywJ0csp2hoYTHA6hKIHu1QaCmZE70NwTcca7jkfvmGY ZGcwhjKOMVGH8PUBooXaOVr6muxVZMF7Q1R9MEclBiLUpRzUEN7LMWyqhqrSL6FXS6QN 6URx07yKBqV5RcnUeS9yPv1TPpC+QWNrpUroJELdwuez3iDteEp/M7LSkJ7ySC330vQX gXkA== 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 c9-v6si2797175plr.482.2018.07.26.22.33.48; Thu, 26 Jul 2018 22:33:48 -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 S1729383AbeG0Gxy (ORCPT + 31 others); Fri, 27 Jul 2018 02:53:54 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:35979 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725861AbeG0Gxy (ORCPT ); Fri, 27 Jul 2018 02:53:54 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id BA006B5DEDC88; Fri, 27 Jul 2018 13:33:39 +0800 (CST) Received: from vm167-7.huawei.com (10.177.167.7) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.382.0; Fri, 27 Jul 2018 13:33:30 +0800 From: Xu YiPing To: , , , CC: Subject: [PATCH] timers: fix offset calculation when the expires align with LVL_GRAN Date: Fri, 27 Jul 2018 13:33:30 +0800 Message-ID: <1532669610-103892-1-git-send-email-xuyiping@hisilicon.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.177.167.7] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org when the expires of timer is align with LVL_GRAN(n), it will be trigged in 'expires + LVL_GRAN(n)'. Some drivers like power runtime use the timer to start a power down of device, it could saves power if the timer is triggerd in time, especially when LEVEL=0 with low expires. Signed-off-by: Xu YiPing --- kernel/time/timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/time/timer.c b/kernel/time/timer.c index cc2d23e..76655e2 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -487,7 +487,8 @@ static inline void timer_set_idx(struct timer_list *timer, unsigned int idx) */ static inline unsigned calc_index(unsigned expires, unsigned lvl) { - expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl); + expires = (expires + LVL_GRAN(lvl) - 1) >> LVL_SHIFT(lvl); + return LVL_OFFS(lvl) + (expires & LVL_MASK); }