Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3720461rwb; Tue, 8 Nov 2022 07:41:59 -0800 (PST) X-Google-Smtp-Source: AMsMyM7rUCCv9fYurOTW1uC1rrxomLmMCmdh58A6kzWTMbNqO6fVwx++xZxs8Q+yChmfW4afdNZ7 X-Received: by 2002:a17:906:7949:b0:7ac:9917:c973 with SMTP id l9-20020a170906794900b007ac9917c973mr54287220ejo.620.1667922119208; Tue, 08 Nov 2022 07:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667922119; cv=none; d=google.com; s=arc-20160816; b=pBrQ/76VVwwxQvl4qQZIJDw+tcBEq0D8YDAxC2mZ+9zdArK4Y+0VXXIr06EvXX58qn Zw6oC2ZOu8l4V+otcn5DU3HniwEINbHIMtBUnUdYc9+NGYmuPQLxRFUsVMSnCMhne+Cv lhES0OXeGPFscmJj0O3YV0KoKyk/TGl38EK5JkivMhbgT6NJ81vRVFLlYiXi1NESA1Zq ntU6JgtsRQI6/JSqbV+wnWYx5hHlLd74kX2wDOusn9qQIDWBINLNEgd/hfWx/4UO5GZk Lzaj04DERqZqRoE/oNuR+4bwHYu9JgLheMebhmEe2SaTKhGMYn1PA95VzmWsaylXdTeu O49g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:dkim-signature:dkim-signature:date; bh=VfPSUnpW7rzzp1CUkOeNkqJuJm75Rk0F+y/XDUXdnVo=; b=Rr9S2YZAU0BF+5MJx719ug8RBhyG35xQC0HDl3NDbRG40Ljlj/7lI+gUB34WN12wIL oU0eOqKp7aq3hNrYQnNhENxU1rN6NGrMTebpUVAIC2Ue60vkedUfnHVjU48Wmpfjycaf rHmHRoUCMYHo/OAoZ5lj+Ie+Mf+s/k9Wrfei+PjR7gzYCZ9lbyiHyPRGPNwZvlwUpvyI Nrzu1yUst9/9ILlHYChGwdcVf+oMwdNEXcjZ3CryShKGKZoWUBkfQQ6U2MO1LWtOEoi+ TrSksNNoZFn9lahzBBZUaePQIYG10xDmqhnWrH+pBu8sjTSPuTk/TmEd2iLquah0PtFj 6Y7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2Pyd82zW; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a1709066d5500b007807e1f3d9dsi9148274ejt.842.2022.11.08.07.41.36; Tue, 08 Nov 2022 07:41:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2Pyd82zW; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234306AbiKHPGY (ORCPT + 91 others); Tue, 8 Nov 2022 10:06:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233326AbiKHPGX (ORCPT ); Tue, 8 Nov 2022 10:06:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9063914037 for ; Tue, 8 Nov 2022 07:06:22 -0800 (PST) Date: Tue, 8 Nov 2022 16:06:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667919980; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VfPSUnpW7rzzp1CUkOeNkqJuJm75Rk0F+y/XDUXdnVo=; b=2Pyd82zWpylLBxLRAxXeJmedNKZW4wuVXbvGWrwmOLEP3zWnEST2xrB8BlbAlkZDBAgLBO Lkw5aJ+AUBE9vZ9TZUdfbv9/3eHscaHai0HTPpSuGe0/mdj+nhSFl/pliZTfGPCJHM5Exp FhgqTC21WcOR0UB08kIB4hh3xrbURYP0JagOb4CRr/TUf2Mf19BBIyBfCMlOfh+mji7E/k PGni23dv6Iyrabk+/9+pcM4+W6tWaznblb2ONq7u3Bi76QaNaDUfeHAb1GwsPjVQI5fpHl mhGR0ltybUSnFg3fxiLwMVTnDCgb7zFBit9Aw+jeqQmRiphtuY2qdoiWV9oAqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667919980; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VfPSUnpW7rzzp1CUkOeNkqJuJm75Rk0F+y/XDUXdnVo=; b=FZyRqcXoaFj7sdCrb166GHWCSYax2w9oI7AIU59fnJWoGGfovdgWBXMrX+VKKSKslXf2bH s4B3RTGiEpVOKyAw== From: Anna-Maria Behnsen To: Pavan Kondeti cc: linux-kernel@vger.kernel.org, Peter Zijlstra , John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Frederic Weisbecker , Rik van Riel Subject: Re: [PATCH v4 00/16] timer: Move from a push remote at enqueue to a pull at expiry model In-Reply-To: <20221108043708.GA9994@hu-pkondeti-hyd.qualcomm.com> Message-ID: <776be028-9161-9ba1-3bf9-417b17f46a1b@linutronix.de> References: <20221104145737.71236-1-anna-maria@linutronix.de> <20221108043708.GA9994@hu-pkondeti-hyd.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 8 Nov 2022, Pavan Kondeti wrote: > Hi Anna-Maria, > > On Fri, Nov 04, 2022 at 03:57:21PM +0100, Anna-Maria Behnsen wrote: > > Next Steps > > ~~~~~~~~~~ > > > > Simple deferrable timers are no longer required as they can be converted to > > global timers. If a CPU goes idle, a formerly deferrable timer will not > > prevent the CPU to sleep as long as possible. Only the last migrator CPU > > has to take care of them. Deferrable timers with timer pinned flags needs > > to be expired on the specified CPU but must not prevent CPU from going > > idle. They require their own timer base which is never taken into account > > when calculating the next expiry time. This conversation and required > > cleanup will be done in a follow up series. > > > > Taking non-pinned deferrable timers case, they are queued on their own base > and its expiry is not taken into account while programming the next timer > event during idle. If CPU is not the last CPU going idle, then yes. > Can you elaborate on "Simple deferrable timers are no longer required as they > can be converted to global timers" statement? Global timers do not prevent CPU from going idle. Same thing that deferrable timers does right now. Global timers are queued into the hierarchy and migrator takes care of expiry when CPU goes idle. The main change of behavoir with global timers compared to deferrable timers is, that they will expire in time and not necessarily on the CPU they were enqueued. Deferrable timers were expired, only when the CPU was awake and always on the CPU they have been enqueued. > Though they can be on global base, we still need to find a way to distinguish > them aginst the normal global timers so that the last migrator can program > the next timer event without taking these deferrable timer expiry into > account? IOW, a deferrable timer should not bring a completely idle system out > of idle to serve the deferrable timer. This behavior will change a little. If the system is completely idle, the last migrator CPU has to handle the first global timer even if it is a formerly deferrable and non pinned timer. > When the deferrable timers will be queued on global base, once a CPU comes out > of idle and serve the timers on global base, the deferrable timers also would > be served. This is a welcoming change. We would see a truly deferrable global > timer something we would be interested in. [1] has some background on this. Serving the deferrable timers once a CPU comes out of idle is already the case even without the timer migration hierarchy. See upstream version of run_local_timers(). > [1] > https://lore.kernel.org/lkml/1430188744-24737-1-git-send-email-joonwoop@codeaurora.org/ As far as I understand the problem you are linking to correctly, you want to have a real "unbound" solution for deferrable or delayed work. This is what you get with the timer migration hierarchy and when enqueuing deferrable timers into global timer base. Timers are executed on the migrator CPU because this CPU is not idle - doesn't matter where they have been queued before. It might be possible, that a fomerly deferrable timer enforces the last CPU going idle to come back out of idle. But the question is, how often does this occur in contrast to a wakeup cause by a non deferrable timer? If you have a look at the timers in kernel you have 64 deferrable timers (this number also contain the deferrable and pinned timers). There are 7 timers with only TIMER_PINNED flag and some additional using the add_timer_on() to be enqueued on a dedicated CPU. But in total we have more than 1000 timers. Sure - in the end, numbers hardly depends on the selected kernel config... Side note: One big problem of deferrable timers disappear with this approach. All deferrable timers _WILL_ expire. Even if CPU where they have been enqueued does not come back out of idle. Only deferrable and pinned timers will still have this problem. Thanks, Anna-Maria