Received: by 10.213.65.68 with SMTP id h4csp1799606imn; Sun, 8 Apr 2018 11:43:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+LIr9DuCncEjJ0DLxiwDmQQzkOND+whmqWn9vcotNihrNFgqm7uM9O/if1GtebKZgM/hMK X-Received: by 10.99.42.65 with SMTP id q62mr18625301pgq.110.1523213003620; Sun, 08 Apr 2018 11:43:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523213003; cv=none; d=google.com; s=arc-20160816; b=MqeZxyf/lOJRi+0h2TJrBWjgaCcwzzQfMqw690fXfikt7Ti8ISzLbFSoBIY36Zm0n6 x4X9DQlKE3EkU5/abQSXjupRVNrYE5tqM/LsAinH7/c0Ejs25mnHNPftAWB6TP2o5AGr sMZluP1Ns2secKdrSCNqcTTotKMTQOx9iyxLTYqk4IB74O9yiFGkpWUibVBntiGqFuri eWrXHQ6rYgihl85qfpw8THnNAoz0ukNjLtL0LNN6bJ/xbmErQd4VXZq+8qXFWP5BTDpT b0KRCfqsDC5JCJ9dTtn9UyT1nJfQrRYn57/uSkl4E2SSQorKm+cfjIxfSgiguXm+YIbZ v16g== 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:dmarc-filter:arc-authentication-results; bh=7mmX1EZnY0YYNxNssgbW6v8echVN1VDvBstuapRJDys=; b=WSiBvxigrHw3zD66GXzCHp7jV61YtujENmu4o8ZtgNf11eTjZBcUNWMDauNkesJe/T QSekVuT5UN8rETqk6JcUOlSYtftRHyiYHOiDk7UeIyDpmpM7dC0BlvRcaESeOPqQM+QW h/Bspbd1pGGAdldwDmRp/eVYKqs0kR9jpuR2Bij/AXIaahPczeMtrJar839lOysMmyGR Fo8M2Gk/yyUtBUeY3m1LySxXKv3msGmK9M1aCWDh2YL2TToAV7kkjwlZJXYrnEj1vFHx tmDx5ml6XcUUsZUeUCatUzqrI78YNQmRoBo6mfJDfwyUAWyR+T2u7WbucghVW4q7c7A6 RaXg== 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 60-v6si14694619plb.679.2018.04.08.11.42.46; Sun, 08 Apr 2018 11:43:23 -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 S1752068AbeDHR6y (ORCPT + 99 others); Sun, 8 Apr 2018 13:58:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:43824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751552AbeDHR6x (ORCPT ); Sun, 8 Apr 2018 13:58:53 -0400 Received: from localhost (LFbn-NCY-1-193-82.w83-194.abo.wanadoo.fr [83.194.41.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA0D62177A; Sun, 8 Apr 2018 17:58:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA0D62177A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=frederic@kernel.org Date: Sun, 8 Apr 2018 19:58:48 +0200 From: Frederic Weisbecker To: "Rafael J. Wysocki" 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() Message-ID: <20180408175847.GA21904@lerouge> References: <1736751.LdhZHb50jq@aspire.rjw.lan> <101528364.6nGUqP0EsC@aspire.rjw.lan> <20180407144637.GC16600@lerouge> <3441609.rVjWXosy3s@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3441609.rVjWXosy3s@aspire.rjw.lan> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 08, 2018 at 10:20:30AM +0200, Rafael J. Wysocki wrote: > 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 Thanks!