Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp859126rwr; Wed, 26 Apr 2023 07:15:42 -0700 (PDT) X-Google-Smtp-Source: AKy350Zey2GhJikgYFECLz1UsrtJF2rBlxyEXXlybqs5dHi/x+PJEWrSCyDPUtx2JL2yV+KgJuk5 X-Received: by 2002:a05:6a20:42a2:b0:eb:c48b:d11d with SMTP id o34-20020a056a2042a200b000ebc48bd11dmr27025422pzj.30.1682518542026; Wed, 26 Apr 2023 07:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682518542; cv=none; d=google.com; s=arc-20160816; b=jxTyUDklblI2cSFAZWzBB35VHqBmCLQEkgVjQuvoJCn/MkgA2oY9LEvYGaP7R0/uuu u3wvaXG/8ZHdUvAycMbRKjVZkDeOjJY3FuzNJFjOMb0l6PTgq8rz+k50utCv4tQyfwlo wdQEA7y4oi2dqcLIEKqTIDWCogh8twBs4RYcs2JXV4Q6Rlo5cM7RsF9JS0qWTDOsS9ea 9DysOXzlV8b/e30HL+9HwF8fDdrbDzwEksxH4Nk75Nlm3qwxgjk+2F4jzkoseZIDPzZh +Eb1Xt/+0x/uUWdlr/TWGxtyV6Sed/oj7X2dJs2Uk+l8a2yCUImyzq/jj9fXhQmBRgnB I+iw== 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=FrAb4eQWH3TbtEFEDBwTA8GTUoY1eVzC37hGOtqravc=; b=O1+S9omwPDcJN2Cptwv2RSM4akpL1JnVhKkB09ebQArO1o94F5TNcPQFY8tziJeYPN q8RLtbwFTtzdHJ4PhQUT4stm/5CmBaXA61dqpyrnsJk3sVb3MF+ov9RzP0vqGSNdgTgO Qg1fLxjkCJjuYxCQyx/k3I4a4LQxim0PbGDbeJiWr28EYnlZx7IDTIGTzKtCYov7Lyrm jSzE7RQWXvdnn9KfMRZoGnOb7Xa7BgTVCyp4rvs9cZdVG7gGoWIkN4MkLuanjxrmqqGg djln/fOzmWtGeAxDwgVSQ/2bfc/OdzCfPNquqyrPrmSxy0SrEK57qhC1JnD3ebF//HN3 /MLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=PtgcFBMK; 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 l123-20020a622581000000b0063d232464absi16338473pfl.214.2023.04.26.07.15.30; Wed, 26 Apr 2023 07:15:41 -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=PtgcFBMK; 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 S241248AbjDZOEu (ORCPT + 99 others); Wed, 26 Apr 2023 10:04:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241267AbjDZOEs (ORCPT ); Wed, 26 Apr 2023 10:04:48 -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 3BF8E6591 for ; Wed, 26 Apr 2023 07:04:45 -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=FrAb4eQWH3TbtEFEDBwTA8GTUoY1eVzC37hGOtqravc=; b=PtgcFBMK52iZ++p3KhpKXU/FA8 ejRyQREXgNQzo74llkHHMmoHe18BbtYhCAYOshnbP4aldHXH4FkxfV58nJKMfPgA4cE6qdfZvEv3n qQ3GZ3WewH/TCC1BBvn82iQAheMq6nVpNEHLybJf3P8aJcEc5gRgDfupwoWGCDF4fpfFZ4Wv0yacf 3xmZD7T3LYNcwHIjBzs9efhxUQ8V6odC9zlhkdWeafWTlNNwKfyYmXXD+VsA2YJdqP41Aok5mqq7L pR3dYbvYTgZNlhg06iGuPMk5RwTirn5d/pt18/QOdySYu+U4V3ftjcuFFNix5SGyzlqJoII295IiZ Y8otxAkQ==; 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.96 #2 (Red Hat Linux)) id 1prfk5-00B1EF-0m; Wed, 26 Apr 2023 14:03:33 +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 75069300244; Wed, 26 Apr 2023 16:03:24 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3DC272419A6E4; Wed, 26 Apr 2023 16:03:24 +0200 (CEST) Date: Wed, 26 Apr 2023 16:03:24 +0200 From: Peter Zijlstra To: Chen Yu Cc: Vincent Guittot , Ingo Molnar , Juri Lelli , Mel Gorman , Tim Chen , Dietmar Eggemann , Steven Rostedt , Ben Segall , K Prateek Nayak , Abel Wu , Yicong Yang , "Gautham R . Shenoy" , Honglei Wang , Len Brown , Chen Yu , Tianchen Ding , Joel Fernandes , Josh Don , Hillf Danton , kernel test robot , Arjan Van De Ven , Aaron Lu , linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 2/2] sched/fair: Introduce SIS_CURRENT to wake up short task on current CPU Message-ID: <20230426140324.GB1377058@hirez.programming.kicks-ass.net> References: <98257d0184b227cad8b4e947eedd9246d60191d3.1682060436.git.yu.c.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <98257d0184b227cad8b4e947eedd9246d60191d3.1682060436.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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Sat, Apr 22, 2023 at 12:08:18AM +0800, Chen Yu wrote: > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 4af5799b90fc..46c1321c0407 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6501,6 +6501,46 @@ static int wake_wide(struct task_struct *p) > return 1; > } > > +/* > + * Wake up the task on current CPU, if the following conditions are met: > + * > + * 1. waker A is the only running task on this_cpu > + * 3. A is a short duration task (waker will fall asleep soon) > + * 4. wakee B is a short duration task (impact of B on A is minor) > + * 5. A and B wake up each other alternately > + */ > +static bool > +wake_on_current(int this_cpu, struct task_struct *p) > +{ > + if (!sched_feat(SIS_CURRENT)) > + return false; > + > + if (cpu_rq(this_cpu)->nr_running > 1) > + return false; > + > + /* > + * If a task switches in and then voluntarily relinquishes the > + * CPU quickly, it is regarded as a short duration task. In that > + * way, the short waker is likely to relinquish the CPU soon, which > + * provides room for the wakee. Meanwhile, a short wakee would bring > + * minor impact to the target rq. Put the short waker and wakee together > + * bring benefit to cache-share task pairs and avoid migration overhead. > + */ > + if (!current->se.dur_avg || ((current->se.dur_avg * 8) >= sysctl_sched_min_granularity)) > + return false; > + > + if (!p->se.dur_avg || ((p->se.dur_avg * 8) >= sysctl_sched_min_granularity)) > + return false; > + > + if (current->wakee_flips || p->wakee_flips) > + return false; > + > + if (current->last_wakee != p || p->last_wakee != current) > + return false; > + > + return true; > +} So I was going to play with this and found I needed to change things up since these sysctl's no longer exist in my EEVDF branch. And while I can easily do 's/sysctl_sched_min_granularity/sysctl_sched_base_slice/', it did make me wonder if that's the right value to use. min_gran/base_slice is related to how long we want a task to run before switching, but that is not related to how long it needs to run to establish a cache footprint. Would not sched_migration_cost be a better measure to compare against? That is also used in task_hot() to prevent migrations.