Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp519540qtx; Thu, 3 Nov 2022 06:05:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Ae+CnoBW+Gdfz7uBO9NaLbrBqu8PYHHAgOd9ER5sH8iwLtqhQ+g/uOeYDtHb4ZtQrCrX5 X-Received: by 2002:a17:907:8a09:b0:7ad:adff:ddf6 with SMTP id sc9-20020a1709078a0900b007adadffddf6mr29797217ejc.320.1667480737464; Thu, 03 Nov 2022 06:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667480737; cv=none; d=google.com; s=arc-20160816; b=fsLTqVstMvRHCMDPwr3fOGOe4j7CPE3+kkhS1BeHwn2JZZuSOBzp57FSWYqXB1bKhu txtL1UMn7keGEXzOpWatzW3rgLMS4srxAnMtKNx3KHWmMEEZNk6oG6uf0hAyDdr0oyGV MRK5N7U2YrCxv+UBqa/1/Y8h6YPcqYQMZOk05P4ocn63YzV2RipYki9FKoZkf7evwwfw IMst+Sm9bTBWWBjDahIO4fgwToQuG7rTTUSX5p102k0Gclp3I/dv3hIAakRxS2D3BIso 0O/voim5eBC3McKe9psFdaJqa9Y2I6IyxHR+Htz70BLxHKnS0aEapSTV9yeVIfM83aXq izgA== 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=HCFDfBsw1t4TwyE4aixcJbLjNpdOwDL65IBVpDbxU3g=; b=Qx/8qZ4fZPmbPvdMN3aXgUDBquPBqKvSkZ+DwHlsX7CdLEXN9aB58jYdV79LnXcCmO huKG9FLEs30M01qEXmYiawVZpuQ/54gd9lqnt9/KDCB9bshLSafYZyjTUdE9m0oVghMF jySfFi/xdNXPU5FyehEkwFgWb3s9qWfFWSDWw3MbUrGmhQJfvEp60W4wamfNiSlf7slQ d2SVcrqEqs02ydFa4HLu18M5X35g4m2zrZYgluc3mp6muF71+SbZLTnirtemmWFqELFv 24UsilgeE4/RXeK1V/AeKezZMx88BBTOYL34e145GcE1IHg0GIGTBITGjo+JOFf9QlMJ XMEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=AUs8DSN4; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r24-20020a1709064d1800b0073d74bcac8dsi1001198eju.513.2022.11.03.06.05.07; Thu, 03 Nov 2022 06:05:37 -0700 (PDT) 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=@infradead.org header.s=desiato.20200630 header.b=AUs8DSN4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231499AbiKCMpC (ORCPT + 97 others); Thu, 3 Nov 2022 08:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231381AbiKCMpA (ORCPT ); Thu, 3 Nov 2022 08:45:00 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3019910B64 for ; Thu, 3 Nov 2022 05:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=HCFDfBsw1t4TwyE4aixcJbLjNpdOwDL65IBVpDbxU3g=; b=AUs8DSN4y5XA/oMkE/BV/2vrrM 54P/VtUuGexfYjYpjj2YU0v5KV1pR/ppY/FEU4HaiQRmUEp4IkdSLwz1x1tgqz8UTI3SclDr2XPMy RzicET/ENwm4lqkhGVSY8TL3hsTgWM+70YjE8GwASfMVV7VgsrDGcSAJTOKz+Te0EosqK5xSuY/BC sek3bF1tMx3IWXR6btzZuoy5OIBkFS5Y9zsXe4W/2CVJp9LRltAzyZpqAkT66caG/SXtfM/FYk7La cK+LTQz30qsU2F4PfI/b2RIadRcsz3bnRyFdt2Caf+bYz0iRNK3pCr+O7LR7f8vppFRyj95fdIk/m GyQZ3dHw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqZZv-008gM6-Cc; Thu, 03 Nov 2022 12:44:16 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DC3F7300130; Thu, 3 Nov 2022 13:44:12 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C4C42201001C7; Thu, 3 Nov 2022 13:44:12 +0100 (CET) Date: Thu, 3 Nov 2022 13:44:12 +0100 From: Peter Zijlstra To: Chen Yu Cc: Vincent Guittot , Tim Chen , Mel Gorman , Juri Lelli , Rik van Riel , Aaron Lu , Abel Wu , K Prateek Nayak , Yicong Yang , "Gautham R . Shenoy" , Ingo Molnar , Dietmar Eggemann , Steven Rostedt , Ben Segall , Daniel Bristot de Oliveira , Valentin Schneider , Hillf Danton , Honglei Wang , Len Brown , Chen Yu , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2 1/2] sched/fair: Introduce short duration task check Message-ID: References: <6b81eea9a8cafb7634f36586f1744b8d4ac49da5.1666531576.git.yu.c.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6b81eea9a8cafb7634f36586f1744b8d4ac49da5.1666531576.git.yu.c.chen@intel.com> 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_NONE 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 Sun, Oct 23, 2022 at 11:32:31PM +0800, Chen Yu wrote: > + if (sched_feat(SIS_SHORT) && !prev->on_rq) { > + /* > + * sum_exec_runtime has been updated in update_curr() > + * because we reach here via dequeue. > + */ > + this_dur_avg = se->sum_exec_runtime - se->prev_sum_runtime_vol; > + /* > + * Record the accumulated runtime when task voluntarily > + * switches out. End of old duration period, a new period > + * starts. > + */ > + se->prev_sum_runtime_vol = se->sum_exec_runtime; > + > + last_dur_avg = se->dur_avg; > + delta = this_dur_avg - last_dur_avg; > + /* consider large change to avoid frequent update */ > + if (abs(delta) >= sysctl_sched_min_granularity) { > + /* > + * If it is the first time the task starts to > + * record dur_avg, discard the initial value 0. > + * Otherwise, calculate the EWMA. > + */ > + if (unlikely(!this_dur_avg)) > + se->dur_avg = this_dur_avg; > + else > + update_avg(&se->dur_avg, this_dur_avg); > + } > + } This seems excessively convoluted; what's wrong with something like: if (sched_feat(SIS_SHORT) && !prev->on_rq) { u64 this_dur = se->sum_exec_runtime - se->prev_sum_exec_runtime_vol; se->prev_sum_exec_runtime_vol = se->sum_exec_runtime; update_avg(&se->dur_avg, this_dur); } All that other stuff just makes it unreadable and probably slower.