Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5869810rdb; Thu, 14 Dec 2023 01:48:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3sMxhNtA1R34y5Ir+hgbQOC2iVhefcCEhquG5X+VhLJ4F9Sc3V83oB6w4fw+mPhs8Er77 X-Received: by 2002:a17:90a:bf02:b0:28b:16b0:5599 with SMTP id c2-20020a17090abf0200b0028b16b05599mr88899pjs.49.1702547306857; Thu, 14 Dec 2023 01:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702547306; cv=none; d=google.com; s=arc-20160816; b=P8SvnH0y45hXOtyLC+TiXNMJd8fb3Gp1l82sove0O51iWDQd/c3UtbcPjSf/ZsF3jV 5IErGHu5wnAimp6pQlWfZcMCtge+lrFi+3mRz5xytf1Bw/4PZfsBCLExGgdEyRWUNJW+ XOUaBeCsxOvjvjVm78hwe3S3SxBMc6Zd6+1l29or4yt1csQx73DJT4qaoLxlT7CK551M /qXKxj/AtrF5VjETYDQh/RFWsGwGHmjlKkbJxeIT7h9H550g/8IPuCKQcI9M6fQhHLGG omCms3mrL2Hz5MAqvVnuDVQvPIJYwAfX+brOKjpr3vS60jsHfpK0+vf9BbffMZHu9eft 6jsw== 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=TJ+XgSEIlf4Y1OwyCFMD7/GsIzPCr4tjgUa8DZN3A5E=; fh=744hpuN/kP+p5N/PEaZuI2Iq+LhXvpWLCV9dQXiARRs=; b=UrT7H0eS3HhyAFN5lSKQukvVeVHK0/wCkZEYkzQERoa3mncP2XiGpC2AH4N/g7Xpxg KfSe+ViXGQ96qF9T08ImSV6qGJ9R+FDld33S9Q6Q8V7Jn5a78ncd63DciEFMBmv22Rv5 3YXv+dywbc6F/+FFY6kVvqALFEhUTFfeJrm/yLvK8h9V4Am8qiYGUrfSjCaiaF4lPhhB XF8qV0gkAvVi3tiOyyynP6JI+Y37S1n8yBF8W9pw0628YhgSvC+hnwnNiiktMTrnzOhe p9UH6YpPPC3VzhoEi4KPTlWaH9jfIVgd60VZ7QLRID9PMvcVvlZGXWLlCui1EPf9J1nJ ueKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id d3-20020a17090ab30300b00286785e0bfesi12626290pjr.147.2023.12.14.01.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 01:48:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 6B32480F61BC; Thu, 14 Dec 2023 01:48:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235545AbjLNJsA (ORCPT + 99 others); Thu, 14 Dec 2023 04:48:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjLNJr7 (ORCPT ); Thu, 14 Dec 2023 04:47:59 -0500 Received: from wxsgout04.xfusion.com (wxsgout04.xfusion.com [36.139.87.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B9D511D for ; Thu, 14 Dec 2023 01:48:03 -0800 (PST) Received: from wuxshcsitd00600.xfusion.com (unknown [10.32.133.213]) by wxsgout04.xfusion.com (SkyGuard) with ESMTPS id 4SrS9m5cSMzB1CfR; Thu, 14 Dec 2023 17:44:28 +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 17:47:57 +0800 Date: Thu, 14 Dec 2023 17:47:57 +0800 From: Wang Jinchao To: Vincent Guittot CC: Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , , Subject: Re: [PATCH] sched/fair: merge same code in enqueue_task_fair Message-ID: References: <202312101719+0800-wangjinchao@xfusion.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Dec 2023 01:48:23 -0800 (PST) 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% 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 >