Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3419440rdb; Wed, 13 Sep 2023 11:23:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxqHrbDaNHeuzaP+J+Acl56cmCeN5TnJBiZ4Ta/G/95DvCyTUHxKZDGwonO+8WBTrj4SoK X-Received: by 2002:a05:6358:290b:b0:140:e7b2:e482 with SMTP id y11-20020a056358290b00b00140e7b2e482mr4324325rwb.5.1694629397107; Wed, 13 Sep 2023 11:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694629397; cv=none; d=google.com; s=arc-20160816; b=AFpIIdsI7Df4E26+Nv2LZNmj4D2D5qHXapcl7fmJsdJV/TnIjLahRH2W/802O/I17A 6NkzSEpHJCOYMKfnI+mDF3rqAtQzI6F77fsRI10rbCmFTMA5a89adu1hZUneeiGcb8nk 3RYnTWpgQEmlyT+N+J06JxVsWVx0XODdHjYEpksPLLs7ZmUbHNS7Wst4caTkj/S+INxh 2yFlH/C6MafPBbrShdefrjnqWuz6waAXGwWNtvbmheSIlHSEhjRgjINZyiWGmFMRIKZ3 YJ8oJJju/SJgUPAA0hcQZ9g9ebH5cxBp9E6/mYGOHSDeri31/6MRfg61uWHFaIsNTw3K g14g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=3/IKF7OGCCwZZLbt2JLWGhBF2t0mxlApg1LHXU6v0Ng=; fh=vEj+EhfNhLiN+4R/wdWJyprps+0EOCSjkHzh4D8g/tc=; b=RHXM6gJZXFIFCdC9rIOTo2i0/8i52Ld9xhCv4bKmaT4Q4+ufb05dvVwHNFo6JIXKb+ Rm5KrzZKqgQSwiljQIIFgA48ZEw81/A9/ItGUcxwNky4elD5ZMq6ijaKgdwCSP6r+f90 L56N1yY/Y9BHRCHzdxd36nQkqoBUf4r4tLC/BJ8Kp4fNqAkA/WhoVOzVNsrY92QFgis2 oOTd37LKM3Biwtt9wTzDzDPbVU2k1OZuPNYOZYZjjS8jrv+JLh2kvKjh7dT0VkyKEpHo NcxasTL4Q7YMjFdI+xKJRXzj+oXk41ArVzPLjNh851VJMec0JgKL8AEHpc0Bv5YJEfJV Q7Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=FwXXv4HZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id k191-20020a6384c8000000b005775e17f560si7329362pgd.82.2023.09.13.11.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 11:23:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=FwXXv4HZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 10A4480310EA; Wed, 13 Sep 2023 08:45:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbjIMPpd (ORCPT + 99 others); Wed, 13 Sep 2023 11:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbjIMPpb (ORCPT ); Wed, 13 Sep 2023 11:45:31 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CDCAC1 for ; Wed, 13 Sep 2023 08:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1694619925; bh=571rZ6ouw0sSuats3nqKyMCENWzG24PPE1Ypk7gXuOQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=FwXXv4HZqtgCAZaOZR240YfKk1HAcyVZ+uQxOOBf5zOMgFyQMzJ3I7fYQkWaomcn5 3aEEC+1ng/GpdaVPnySXDB6USJQa3oUoxrFi2REMhTanZMoEtH9anctLUi4vsH3v62 MGCg4OZRZGYNcPJBI717HR0UVshxWgKhE2n97wxtUAkK+L0uyE8Ae1n5rH+7Miikkj Da9sTEy3w/xjH5V6FsgWFP/VAY0I89vHOQgYxgZOaow+sr9wW5nuUuKug8TT2WgScq 6dSUSLwZTGz+0Twm2DLKI1ocWcKydUwJBAh+eAfiJsQBXJTJ1VnKodxv6PZDeBPIXc zfiJuRxW2LJWA== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4Rm4Xj2qgcz1NyZ; Wed, 13 Sep 2023 11:45:25 -0400 (EDT) Message-ID: <0dcef55c-7baf-eadc-0253-d283385cbeb3@efficios.com> Date: Wed, 13 Sep 2023 11:46:47 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [RFC PATCH 1/2] sched: Rate limit migrations to 1 per 2ms per task Content-Language: en-US To: Chen Yu Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Ingo Molnar , Valentin Schneider , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Vincent Guittot , Juri Lelli , Swapnil Sapkal , Aaron Lu , Julien Desfossez , x86@kernel.org References: <20230905171105.1005672-1-mathieu.desnoyers@efficios.com> <20230905171105.1005672-2-mathieu.desnoyers@efficios.com> <20230906084145.GC38741@noisy.programming.kicks-ass.net> From: Mathieu Desnoyers In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 08:45:52 -0700 (PDT) X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 lipwig.vger.email On 9/10/23 03:03, Chen Yu wrote: > On 2023-09-06 at 09:57:04 -0400, Mathieu Desnoyers wrote: [...] >> >> I suspect we could try something like this then: >> >> When a cpu enters idle state, it could grab a sched_clock() timestamp >> and store it into this_rq()->enter_idle_time. Then, when it exits >> idle and reenters idle again, it could save rq->enter_idle_time to >> rq->prev_enter_idle_time, and sample enter_idle_time again. >> >> When considering the CPU as a target for task migration, if it is >> idle but the delta between sched_clock_cpu(cpu_of(rq)) and that >> prev_enter_idle_time is below a threshold (e.g. a few ms), this means >> the CPU got out of idle and went back to idle pretty quickly, which >> means it's not a good target for pulling tasks for a short while. >> > > Do you mean inhit the newidle balance? Currently the newidle balance > checks if the average idle duration of that rq is below the total cost > to do a load balance: > this_rq->avg_idle < sd->max_newidle_lb_cost Not quite but.. > >> I'll try something along these lines and see how it goes. anyway this approach did not work based on my testing. >> > > Consider the sleep time looks like a good idea! What you suggests that > inspires me that, maybe we could consider the task's sleep duration, > and decide whether to migrate it or not in the next wakeup. > > Say, if a task p sleeps and woken up quickly, can we reserve its previous > CPU as idle for a short while? So other tasks can not choose p's previous > CPU during their wakeup. A short while later, when p is woken up, it finds > that its previous CPU is still idle and chooses that. > > I created a draft patch based on that, and it shows some improvements on > a 224 CPUs system. I'll post the draft patch and Cc you. I think your approach is very promising, let's keep digging into that direction. Thanks, Mathieu > > thanks, > Chenyu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com