Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp883143rdb; Fri, 20 Oct 2023 02:07:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAllWHrYEpflp0FO29QmKvVaKDu9koBgNgA+IfdlL4Qy3nck6cjigeCsJZSTG+PylZ9XSn X-Received: by 2002:a17:902:eccb:b0:1c9:ba18:785c with SMTP id a11-20020a170902eccb00b001c9ba18785cmr1698520plh.25.1697792820265; Fri, 20 Oct 2023 02:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697792820; cv=none; d=google.com; s=arc-20160816; b=SvsC7/Y1Wanas+z65T3JTvtu+5zVlp909qIjZXVMHnf8CNlITifj7Iv04Jqv6DABoQ RGcWt2xmaG+TBiwvsFC2x/d6RHyhQOJfezhpewULPdx8++Pl9zR8ajwdB6g9epmDTpAW v58aPoKvZLRVld/pBJLmCscIoILe/LJn5IlYeto86WYB4cnWDKVysqc7quxKcB8MzOic jaaWSMmxabf4CTrxo3lt5x/1z9fNHR0Jr0UfCfTeEKG8VZpjmSxFlYJ3GSMWS83wDy46 3Zu4+tIyU/aMSF5K42U11flUbokNbUMVZTdjwUU2ijz1IjnvJIuOhPIigb7lULqjeDAq nJtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ioyyHtqaMc24vP/Ebg3Nlc6OBQPrCHn0ttSIqLYUh38=; fh=i298iYrcKvmiuDmAQjdEaBJmC636Y4MOmvy8pJCA+x0=; b=n3+7YUry3/Jxj+/h365rKRh/ro3lZO7uNKu2Q777VYvWseoq/LCqU8ER7MC6SSXmQ5 aLqssRUu9hH5zEqN5hb+54knRsN2H+6ZqAXWfB5KhKPyW9tfUdEOU+izUGxQ1w3hab9e 97KViKoW70HvUU8t/niaLReXThelndQfC8r7akK403JOnM0nBWiUsdyAtMayvOYk4lwt O0q9tNnCd2dU9a7ZMw34vkp2VyGPetaGDBfJAZuqWT/jqGKezNBXm6hXrPLIztCoaemI /YW1TQatgPhKJxqZdxyyb8MVsjZ/097YcB2DoiJWw7X2U7JiNC2Nc/ilWorEZoPbCrwi Tg+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=LhoV6eRD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id e8-20020a170902744800b001b973681493si1333956plt.16.2023.10.20.02.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:07:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=LhoV6eRD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id DBC6883C224A; Fri, 20 Oct 2023 02:06:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376558AbjJTJGq (ORCPT + 99 others); Fri, 20 Oct 2023 05:06:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376552AbjJTJGp (ORCPT ); Fri, 20 Oct 2023 05:06:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1BF1BF for ; Fri, 20 Oct 2023 02:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ioyyHtqaMc24vP/Ebg3Nlc6OBQPrCHn0ttSIqLYUh38=; b=LhoV6eRDt5P/a4jZnj4pPsx8YS 2Joae+tkXUQF791Z9aF7qXgyBRbyYP5J5xNN9pGtBBPFbvoYeIpVFTGd39IqjZdqJXsYYEZRT66fT ctDGY/5jBIpWh6p9CXbBAnhp4FaG2ZEGRc7muMO1M1SJXy5TK95OMMTZUYh0FyBIkNxGjp6UZmvZf 3KrK7cf60OB9a45gX786F/gVQPeCtK2RA0/ViyVuSSwXjSDZDqxF+Xv17xJ3NJpxrRDUiY2fFoAQz PX2brrQJBv8u83c8+wfhZ1kuPA6jJvMwfFadPyNTHnFUGoRevBjJHzziok1XA2fXA/LlvPEUFv3td BGzXh9SQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qtlSI-00CEaw-PJ; Fri, 20 Oct 2023 09:06:06 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 685D0300392; Fri, 20 Oct 2023 11:06:06 +0200 (CEST) Date: Fri, 20 Oct 2023 11:06:06 +0200 From: Peter Zijlstra To: K Prateek Nayak Cc: Anna-Maria Behnsen , linux-kernel@vger.kernel.org, John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Frederic Weisbecker , Rik van Riel , Steven Rostedt , Sebastian Siewior , Giovanni Gherdovich , Lukasz Luba , "Gautham R . Shenoy" , Srinivas Pandruvada Subject: Re: [PATCH v8 00/25] timer: Move from a push remote at enqueue to a pull at expiry model Message-ID: <20231020090606.GA31411@noisy.programming.kicks-ass.net> References: <20231004123454.15691-1-anna-maria@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 20 Oct 2023 02:06:53 -0700 (PDT) On Fri, Oct 06, 2023 at 10:35:43AM +0530, K Prateek Nayak wrote: > Hello Anna-Maria, > > On 10/4/2023 6:04 PM, Anna-Maria Behnsen wrote: > > [..snip..] > > > > Ping Pong Oberservation > > ^^^^^^^^^^^^^^^^^^^^^^^ > > > > During testing on a mostly idle machine a ping pong game could be observed: > > a process_timeout timer is expired remotely on a non idle CPU. Then the CPU > > where the schedule_timeout() was executed to enqueue the timer comes out of > > idle and restarts the timer using schedule_timeout() and goes back to idle > > again. This is due to the fair scheduler which tries to keep the task on > > the CPU which it previously executed on. > > Regarding above, are you referring to "wake_up_process(timeout->task)" in > "process_timeout()" ends up waking the task on an idle CPU instead of the > CPU where process_timeout() ran? > > In which case, have you tried using the "WF_CURRENT_CPU" flag for the > wakeup? (landed upstream in v6.6-rc1) It is only used by wait queues in > kernel/sched/wait.c currently but perhaps we can have a > "wake_up_process_on_current_cpu()" that process_timeout() can call. > > Something along the lines of: > > int wake_up_process_on_current_cpu(struct task_struct *p) > { > return try_to_wake_up(p, TASK_NORMAL, WF_CURRENT_CPU); > } > EXPORT_SYMBOL(wake_up_process_on_current_cpu); > > Thoughts? Yeah, we should definitely not export such a function. Also, WF_CURRENT_CPU should be used sparingly. So restarting the task on the previous CPU is done because of cache affinity and is typically the right thing to do if you care about performance. The first question to ask is where this schedule_timeout() is coming from. Is this some daft userspace that is polling on something that eventually ends up in schedule_timeout() ? Can we fix the userspace to not do silly things like that? The alternative is adding heuristics and we all know where that ends :/