Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5954088rdb; Thu, 14 Dec 2023 04:42:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvKTEihDVECgC8U8fWsiS50+nJhhCshWbDK1fBoQY/PZMdlbiwNXngeFvNa7lqj5EH4Skb X-Received: by 2002:a05:6a20:f397:b0:18f:c875:6b3b with SMTP id qr23-20020a056a20f39700b0018fc8756b3bmr5076629pzb.100.1702557759906; Thu, 14 Dec 2023 04:42:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702557759; cv=none; d=google.com; s=arc-20160816; b=ijvtn8W23V+pyJGFwLvR6zRkj5qDqEGa0eq5JidNJvbdQ6Xj2Cb5mgBd7eeQ8TZDxx CMyrctg5Ev7QP4PPqTBeLbq9Xo8ZZYuF51D74PRZelvDEVCqI/CwUF9cmZTPQ7RgRP/+ AfV5cE1zhemg+Lut/u+kFzwPT3DzA9wu9bdSxbYkJ1RlSOmVYJZMBmVjj+BGRcdl8HXF k15YJa/P8g1wV0ck2jzKhuQb/yUK4tMzwxHsljh/imZ1wU56p5ld1YS7oNObgJ42eTpm xVv0pRuOh8YbZx4uH0FIxCvgE+KivlefQlXe8fvqL+F8a3NWikPJSAYv0qgnCyVmAv3U 4Grg== 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; bh=HhbrusEE3Wn1P/imDf+xNru41nylE7JX46UTHgMij+4=; fh=fUcUq98yuS5sACNZwlm5QMJHeDu/cuJ/pgQNidBINLg=; b=nQ9L3rksp4oV/C91YuAe5Bm0p22TeZ335/5FHbAWpXiOMG1Jd/WuZ2DW/nRJhOCRL2 Odt5Gu6mYpj8rtzDlEYhJZFi7VKlyxcHh5CVNCmmMNmRExWUhhXTW9meqIf49V6FpZKZ IkFHOrOjG5LizEctjlAHMXU8b0K9Xq8JCMqKE5PTiTyqiPkIZiS9XX/2Zbres+xo5c16 DFs+R5DYKFF0aZpw7nyY9XlUjpd98c715jFPUGVxPf290rKTiOy/FTPJDGIXuZxLa/lj qGJYz0kEGMNt43tWQlIRo2XlS9SZVtdptFHqi/e3C8zq7H7Sm3YNcn0gZ10dASjx5kDf 9uoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id t6-20020a170902e84600b001d0a0a9a997si11676644plg.25.2023.12.14.04.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 04:42:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 7CC86801CFDC; Thu, 14 Dec 2023 04:42:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573080AbjLNMmY (ORCPT + 99 others); Thu, 14 Dec 2023 07:42:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573090AbjLNMmY (ORCPT ); Thu, 14 Dec 2023 07:42:24 -0500 Received: from wxsgout04.xfusion.com (wxsgout03.xfusion.com [36.139.52.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C7F012C for ; Thu, 14 Dec 2023 04:42:28 -0800 (PST) Received: from wuxshcsitd00600.xfusion.com (unknown [10.32.133.213]) by wxsgout04.xfusion.com (SkyGuard) with ESMTPS id 4SrX3B0SSpzB0xZZ; Thu, 14 Dec 2023 20:39:02 +0800 (CST) Received: from localhost (10.82.147.3) by wuxshcsitd00600.xfusion.com (10.32.133.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 14 Dec 2023 20:42:23 +0800 Date: Thu, 14 Dec 2023 20:42:23 +0800 From: Wang Jinchao To: Abel Wu CC: Vincent Guittot , Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , , Subject: Re: Re: [PATCH] sched/fair: merge same code in enqueue_task_fair Message-ID: References: <202312101719+0800-wangjinchao@xfusion.com> <6c89812d-a7ef-42df-9ca7-22092937f13c@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <6c89812d-a7ef-42df-9ca7-22092937f13c@bytedance.com> X-Originating-IP: [10.82.147.3] X-ClientProxiedBy: wuxshcsitd00600.xfusion.com (10.32.133.213) To wuxshcsitd00600.xfusion.com (10.32.133.213) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 14 Dec 2023 04:42:37 -0800 (PST) On Thu, Dec 14, 2023 at 08:10:57PM +0800, Abel Wu wrote: > On 12/14/23 5:47 PM, Wang Jinchao Wrote: > > On Wed, Dec 13, 2023 at 09:23:46AM +0100, Vincent Guittot wrote: > > > On Wed, 13 Dec 2023 at 08:04, Wang Jinchao wrote: > > > > > > > > On Mon, Dec 11, 2023 at 04:23:52PM +0100, Vincent Guittot wrote: > > > > > On Sun, 10 Dec 2023 at 10:22, WangJinchao wrote: > > > > > > > > > > > > 1. The code below is duplicated in two for loops and need to be > > > > > > consolidated > > > > > > 2. Fix the bug where a se's on_rq is true but its parent is not > > > > > > > > > > Could you clarify which bug you want to fix ? > > > > Taking into account the additional information provided by Tim, > > > > this is not a bug. Therefore, this patch is merely a logical > > > > simplification. > > > > > > If there is no bug why changing it ? > > For two reasons: > > 1. (from Abel Wu) > > It doesn't need to, but it can actually bring some benefit from > > the point of view of text size, especially in warehouse-scale > > computers where icache is extremely contended. > > > > add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-56 (-56) > > Function old new delta > > enqueue_task_fair 936 880 -56 > > Total: Before=64899, After=64843, chg -0.09% > > But TBH this benefit is kind of weak to argue about, given that you > don't have any data supporting it. Agree. My initinal target is clear comprehension. And thanks for your numbers. > > > > > 2. For better code comprehension > > I became curious when I reached this part, wondering why there is a lot of > > repetition inside these two for-loops. Then I thought about 'do not repeat yourself,' > > and I feel that merging them would lead to a clearer understanding. Of course, > > it might be because I am just starting to read scheduler-related code and am not > > yet familiar with the entire logic. > > > > > > The duplication is done in order to have the same pattern in : > > > enqueue_task_fair > > > dequeue_task_fair > > > throttle_cfs_rq > > > unthrottle_cfs_rq > > Due to the two points mentioned above, do we need to adjust all four functions? > > > > > > so there is no need to change it > > I plan to get familiar with the scheduler-related code first and then consider this. > > > > Thanks > > >