Received: by 10.213.65.68 with SMTP id h4csp1369285imn; Sun, 8 Apr 2018 01:47:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+tF1wHK2cJm4aspZF0H41obAofC56MNaJS8gnL+4WqFky3Rsi8jRfAtda6mWDT9ZTxYnKj X-Received: by 2002:a17:902:7894:: with SMTP id q20-v6mr34693560pll.86.1523177277493; Sun, 08 Apr 2018 01:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523177277; cv=none; d=google.com; s=arc-20160816; b=g/Y/qiUrcZve+47ehMlS1PN6K1qObDKUSsX9A6lFwsu/ryJyUW35qX2Ih6F+IBrS9o /aq7pxG2aBd0sKuuuO2QGgP/6k3xPDulzq4VFJGq4CxDXCICMh6rjyYyYHiwcRrN0zwB wio/TLVHAgGt16mIQIkuOxHtdhUnathNec3Gp66oxqo5/plk7e6v/qLgXbzUbVfmSFdU Cnkwr73QyLNLfS/9JfrcOMYt9pLL//uOL/VjG6L0fv/H/aMw3F3bqWqqSgFDmoOaHiaN WO09Yc3n947JMABIQYyiMid8IZT0AndkzS6kNLn1aTMMuzfTC1h71RRdoanX7fjxqpZ2 0wOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=j/BWxht+z3/huXEPEud3+zQRnfdUCslTWUyulY6xGws=; b=ices1cqU1AmNEibtORjPI7IfmNYM9QtvPFYCKxshHICKXk/KH5EyTEDpJv1QlKtf+E +GMZA8KeUDGx4TJVsN5TKlcd8KctFxp4cip1t5Tpo1oEp09SjrKaPyV8QruKQHdL6mic vHsHFddwcA0eUrkOk17PiPANqs51YT9lhP2NMDVxPH0406Q2uCCi0UNoR31bYnwOPz03 GQBsy3r067JtdsETaUND0cwzUFRoKPAthLH6m3+5vj1Hzu0jZiWEuThgofrY0ReX42Ml tl3GBGyzbicoVQHL0nb9dAVheC4IY54YEuN+meRQqXYoZhUXmb/jrkJpi1/OLWXFdU69 R8Eg== 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 71-v6si16260579plf.244.2018.04.08.01.46.55; Sun, 08 Apr 2018 01:47:57 -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 S1751786AbeDHIUZ (ORCPT + 99 others); Sun, 8 Apr 2018 04:20:25 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:43428 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751309AbeDHIUY (ORCPT ); Sun, 8 Apr 2018 04:20:24 -0400 Received: from 85.219.170.202 (85.219.170.202) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83) id 9d1ccbdfc10baa64; Sun, 8 Apr 2018 10:20:21 +0200 From: "Rafael J. Wysocki" To: Frederic Weisbecker Cc: Linux PM , Peter Zijlstra , Frederic Weisbecker , Thomas Gleixner , Paul McKenney , Thomas Ilsche , Doug Smythies , Rik van Riel , Aubrey Li , Mike Galbraith , LKML , Len Brown Subject: Re: [PATCH v9 07/10] time: hrtimer: Introduce hrtimer_next_event_without() Date: Sun, 08 Apr 2018 10:20:30 +0200 Message-ID: <3441609.rVjWXosy3s@aspire.rjw.lan> In-Reply-To: <20180407144637.GC16600@lerouge> References: <1736751.LdhZHb50jq@aspire.rjw.lan> <101528364.6nGUqP0EsC@aspire.rjw.lan> <20180407144637.GC16600@lerouge> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday, April 7, 2018 4:46:38 PM CEST Frederic Weisbecker wrote: > On Wed, Apr 04, 2018 at 10:45:39AM +0200, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > The next set of changes will need to compute the time to the next > > hrtimer event over all hrtimers except for the scheduler tick one. > > > > To that end introduce a new helper function, > > hrtimer_next_event_without(), for computing the time until the next > > hrtimer event over all timers except for one and modify the underlying > > code in __hrtimer_next_event_base() to prepare it for being called by > > that new function. > > > > No intentional changes in functionality. > > > > Signed-off-by: Rafael J. Wysocki > > --- > > > > v8 -> v9: > > * Make fewer changes to the existing code. > > * Add a new helper function for the handling of the use case at hand. > > > > --- > > include/linux/hrtimer.h | 1 > > kernel/time/hrtimer.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++-- > > 2 files changed, 54 insertions(+), 2 deletions(-) > > > > Index: linux-pm/include/linux/hrtimer.h > > =================================================================== > > --- linux-pm.orig/include/linux/hrtimer.h > > +++ linux-pm/include/linux/hrtimer.h > > @@ -426,6 +426,7 @@ static inline ktime_t hrtimer_get_remain > > } > > > > extern u64 hrtimer_get_next_event(void); > > +extern u64 hrtimer_next_event_without(const struct hrtimer *exclude); > > > > extern bool hrtimer_active(const struct hrtimer *timer); > > > > Index: linux-pm/kernel/time/hrtimer.c > > =================================================================== > > --- linux-pm.orig/kernel/time/hrtimer.c > > +++ linux-pm/kernel/time/hrtimer.c > > @@ -490,6 +490,7 @@ __next_base(struct hrtimer_cpu_base *cpu > > while ((base = __next_base((cpu_base), &(active)))) > > > > static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base, > > + const struct hrtimer *exclude, > > unsigned int active, > > ktime_t expires_next) > > { > > @@ -502,9 +503,24 @@ static ktime_t __hrtimer_next_event_base > > > > next = timerqueue_getnext(&base->active); > > timer = container_of(next, struct hrtimer, node); > > + if (timer == exclude) { > > + /* Get to the next timer in the queue. */ > > + struct rb_node *rbn = rb_next(&next->node); > > + > > + next = rb_entry_safe(rbn, struct timerqueue_node, node); > > + if (!next) > > + continue; > > Minor cosmectic detail again, timerqueue_iterate_next() would do the job and > avoid browsing timerqueue details. And below is a patch to make this change on top of the original. --- From: Rafael J. Wysocki Subject: [PATCH] time: hrtimer: Use timerqueue_iterate_next() to get to the next timer Use timerqueue_iterate_next() to get to the next timer in __hrtimer_next_event_base() without browsing the timerqueue details diredctly. No intentional changes in functionality. Suggested-by: Frederic Weisbecker Signed-off-by: Rafael J. Wysocki --- kernel/time/hrtimer.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) Index: linux-pm/kernel/time/hrtimer.c =================================================================== --- linux-pm.orig/kernel/time/hrtimer.c +++ linux-pm/kernel/time/hrtimer.c @@ -505,9 +505,7 @@ static ktime_t __hrtimer_next_event_base timer = container_of(next, struct hrtimer, node); if (timer == exclude) { /* Get to the next timer in the queue. */ - struct rb_node *rbn = rb_next(&next->node); - - next = rb_entry_safe(rbn, struct timerqueue_node, node); + next = timerqueue_iterate_next(next); if (!next) continue;