Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp312539rwi; Thu, 27 Oct 2022 01:19:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jT5gnHEwxLqlbJ5NHR6rH3UBzZ0An4YXOIC3LB/mBnsDH7w9321qtrhmbNFTsi6bQhH1d X-Received: by 2002:a63:41c5:0:b0:46e:f23a:9fa2 with SMTP id o188-20020a6341c5000000b0046ef23a9fa2mr21773193pga.77.1666858787631; Thu, 27 Oct 2022 01:19:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666858787; cv=pass; d=google.com; s=arc-20160816; b=THt3SRTX80PnF1ef2YtH9syjoF8BrNBZJ7ktuXiL8LaO/Gar66+eJiB+2tr14W7dXm MzObRLiWBb1qZlU9lgm4o5jRE+d2PekToAY+3NeEFeSlmL/Mo+TOEwqaHIPM8XTyhVCT 3QQUox/1KC81RxcOFV0Uc10p/2bjfwn+j5kgwTSD+AElpNEZrOrZT1boJ9hZCSwnEq2+ hc18oMD3nGsZaPxnNjq2zz6UdYZ9Ltt36HdvlZPK9NNXcKy62lZt/AHezIHNjOFdWkcR 1037Za+mhm50Fk7/2LVDw5Gb731Uzz5Vj8impokxGMyUq26j8K3zj/IUJvE+/FoUCYXU zkqg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:references:cc:to:from:content-language:subject :user-agent:date:message-id:dkim-signature; bh=hZHHMnPAYBkevkZCgikK8Yo+BiQpdWWOw3tBC/TqvvA=; b=w+GJC8G77Gw7sYRcrLk4B7/GfPlEKZlztyZw8wNvv0CSNEtttCf0bMOpmFZPXlrSbf N37yMMrKU4+Nh7y6TxQuCBIyScjHDfna1MTSa60X5o6TYbhf1uPPQ8Rl9mLEtM9xx+O3 /YEAihdBJURzJnL+Q4hmv99dnixqnT53GegBKD+2rgqK6/1OCPWWjo6PgDFYEiuZmE2R O3kImDAHvsT56pVvJyjqXF8u6lRe1ruXzqBfGjPIeoll2qJRLS9ik8SF2z8UGhwaavaq QxmBFA3UN99n1N5i3gvldLWtzK3v+LfLLFtyixFAwCO/EXmhZFayURC2RpYL+Cb6jRKZ NjBg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Q4B22c50; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c140-20020a621c92000000b005612b15a927si997066pfc.181.2022.10.27.01.19.36; Thu, 27 Oct 2022 01:19:47 -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=@amd.com header.s=selector1 header.b=Q4B22c50; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234771AbiJ0IHd (ORCPT + 99 others); Thu, 27 Oct 2022 04:07:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234493AbiJ0IHc (ORCPT ); Thu, 27 Oct 2022 04:07:32 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2041.outbound.protection.outlook.com [40.107.96.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11A7362932 for ; Thu, 27 Oct 2022 01:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FPBTMgu4FxmCbMjWlyudawP0jHpGGN8OcIcLWGcXSXGGgLvvOU4sNEecC+6/06tqpvKJ8pSCQvknDzz78r0gUvjTHPr6cGKdn1MK4KDFkd5FYKhTClNtnXCBZcRJabIiMguIjtWt0kATF/KD+oeIDfnTmTZzXnLzuWY8wshKDZk/bp8CVjN84L/sHCqFihFsXdCcnb5WJeFauuG9ZyoyNujIOasjLpiXRjkiBUJfLh5DUSgOZMJ96AGY6PZwqAPPMggXhzu69QnZ04D3RPZwPhoKHP5+mtfAbB6b90Lr9ouxvlsa98b4n7B6f8yfpHovWvrwTHlz/RWxS7N1FK90FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hZHHMnPAYBkevkZCgikK8Yo+BiQpdWWOw3tBC/TqvvA=; b=Cpm+iq0eI5zkQhzoDhwwpgojDtVPCnQq9q5IwGlHybexqS+4TEo7Kd2rf/MuOJ1S0CNQU7SXj8K5cOT/jUpbNmfQk7r635IW2pTXL066ocRIo9jEO+BHMM3kQtZ+lJPdMdXhsH0AIGbhrC8kL1BxFslNOMe6dEeT4uOGv4KZ8JgoCk6vrEnoihrLReU0oSmI6+KwvwGYgnlBhBbt6jnWoPDO1fXSvEwl5LO9XTHVHPQFp7DZXkgxGAQb1G8P84IKZnEtT1F0CYDu9ZBT48CUhUmc0IXIcod3JzAUAaDdK5ifWn3TYMMtXWma7tZdeGpt7TpH9Ok1xyyG6lIb+76B/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hZHHMnPAYBkevkZCgikK8Yo+BiQpdWWOw3tBC/TqvvA=; b=Q4B22c50kXTpt//mxAiI5qemnEsDRMDEjY5ehcmJbM2Bm1C5gdHOmM3CoKxWzuMR5qk6rXK8DPtPN61D/7G2y5HgZTb6AWYFcrqrSE9FL+YkPCow4PHgUGxyA5JdX3NKTnh/wfHPa5u9fiRupEMF6sKu14O3qLwUCCaj+9V0tY8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB3370.namprd12.prod.outlook.com (2603:10b6:5:38::25) by MN0PR12MB6102.namprd12.prod.outlook.com (2603:10b6:208:3ca::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Thu, 27 Oct 2022 08:07:28 +0000 Received: from DM6PR12MB3370.namprd12.prod.outlook.com ([fe80::d309:77d2:93d8:2425]) by DM6PR12MB3370.namprd12.prod.outlook.com ([fe80::d309:77d2:93d8:2425%7]) with mapi id 15.20.5746.028; Thu, 27 Oct 2022 08:07:28 +0000 Message-ID: <9774ddd6-60d9-245c-77ac-59951c13b263@amd.com> Date: Thu, 27 Oct 2022 04:07:26 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH] drm/scheduler: set current_entity to next when remove from rq Content-Language: en-CA From: Luben Tuikov To: brolerliew , "Koenig, Christian" Cc: Alex Deucher , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20221025061846.447975-1-brolerliew@gmail.com> <69e672a5-a68e-7bad-fc49-4281c1c6039d@amd.com> In-Reply-To: <69e672a5-a68e-7bad-fc49-4281c1c6039d@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: YT1PR01CA0086.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2d::25) To DM6PR12MB3370.namprd12.prod.outlook.com (2603:10b6:5:38::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3370:EE_|MN0PR12MB6102:EE_ X-MS-Office365-Filtering-Correlation-Id: 03d9511c-8cf2-4a1e-21a7-08dab7f24a81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PYXTCGQB50B9EwP/hAQYbbZtnMfN6a5owxXsScZEJER/sVaRu1nMvXhGAzGYjt0k9E0AB3sy6Cm4n2Q/Xvrkw4h4fFvuqIb/L3B7Q7rrQGD5mjI79gl24HZVT1OvHc1HZQTMMwr3qKhORLE/EN0ZvhkO1qZTqeWeQqrmL1Mn2buOxhXflubrzOX0yGW9npqTQyuhyXbgUq7qvvHbm4cSyA01VzYIdmw/AZ9K0qDGOPU4t2a3dSXnm9H7kOTwCATj4yF6iDqYUL1tgq2ZOrpGy02K4KQqDXWoiy4Rpilm+plzk7P9f2RUZuXdV8ocy3kZyUMONSfAHZa4goNAKIZnQCV7j4kHQZIalNIya4mMMBuwrO6Qzg4QSqmEgpn4lfPQ7ZcBv46HeSsHNs3W7u+bivt1Aw51+ldolN7Lug9UVcZe791iD2KpcDM3a2dpMSDeuiSzWTfh+AysbjowHrk9OITxQHwop5/34TrrsaiVnMvJDSeZJzYxE6cPZSk6kRo0zyQjoDEXIxHDQFisf3nzbCx71B7VjDfZANwiSVthIQqzEkHzo1qVY9h1QZZlFbY8gthkF4zQ14TuZJ0KTUbYlYz1YcO3Hx2XM8Ts2cQ1NfsJPHjpgKUJLyoiPDb9F6aGp72tOL/73hv66knHHX+p6yAHnsa4V2Dtv2+FB81n2U1gWynqdy89/LfySOwQHsLD5gtkyeNJQqtfL+KM8YufB66scYYbwahT3vHtrHZcx2uq4KByHeaMimIxzAtTfvoRnbYKszEni/eaAbh1JZYCqMwktIdpVLc19qfyCFBpAhk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3370.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(39860400002)(376002)(396003)(136003)(346002)(451199015)(86362001)(31696002)(186003)(38100700002)(44832011)(5660300002)(8936002)(2906002)(4001150100001)(66556008)(8676002)(83380400001)(6506007)(53546011)(6512007)(2616005)(26005)(316002)(6486002)(110136005)(6636002)(41300700001)(66476007)(4326008)(66946007)(478600001)(31686004)(36756003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OTYrKy9RR2ZxOXM2WTJGUE9QVlFjb0x1TUREQlNGVWQ4bkc5bDRWVlNPNFlE?= =?utf-8?B?c2VDTjNESDVlVUMvQU5PSkZmR1F2RHVCdEhSeTBERUl4cUttUW1tYVJ3b1l5?= =?utf-8?B?VGV2WURhWHp6dUZMQWxqRjY4aTZ0emRkN01hemNVd25LYUJtUVdZYVR1bUVx?= =?utf-8?B?SlN2Y2lmYVk2Qy96bk1BVlBkdk5pYkYwS1hwdDg2UzdtbnlPM1JDUGZIdVpP?= =?utf-8?B?YWFQeG1LTExZWG44bDc1VVV3ZDNVVWlxUHJ5VVBQQnlVWmRwNFZBVmk4aHIv?= =?utf-8?B?UDdIREZEcXBTdElHVEpxWml1cTQ3ZWR0dkFOVUNoOWYyQmhGYkVGTXRCbk1r?= =?utf-8?B?Mm1UbUtnWjd6aUtYRmR4NHJLUXQ4d1IrK011MTB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ab7f24a81 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3370.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2022 08:07:28.7541 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VafEGYWrbeI4AsZ7/FxVxkaaUra6yb8IfzGw68ZKUF9pgAryeGg/bJl1JITW+e68 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6102 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 2022-10-27 03:01, Luben Tuikov wrote: > On 2022-10-25 13:50, Luben Tuikov wrote: >> Looking... >> >> Regards, >> Luben >> >> On 2022-10-25 09:35, Alex Deucher wrote: >>> + Luben >>> >>> On Tue, Oct 25, 2022 at 2:55 AM brolerliew wrote: >>>> >>>> When entity move from one rq to another, current_entity will be set to NULL >>>> if it is the moving entity. This make entities close to rq head got >>>> selected more frequently, especially when doing load balance between >>>> multiple drm_gpu_scheduler. >>>> >>>> Make current_entity to next when removing from rq. >>>> >>>> Signed-off-by: brolerliew >>>> --- >>>> drivers/gpu/drm/scheduler/sched_main.c | 5 +++-- >>>> 1 file changed, 3 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c >>>> index 2fab218d7082..00b22cc50f08 100644 >>>> --- a/drivers/gpu/drm/scheduler/sched_main.c >>>> +++ b/drivers/gpu/drm/scheduler/sched_main.c >>>> @@ -168,10 +168,11 @@ void drm_sched_rq_remove_entity(struct drm_sched_rq *rq, >>>> spin_lock(&rq->lock); >>>> >>>> atomic_dec(rq->sched->score); >>>> - list_del_init(&entity->list); >>>> >>>> if (rq->current_entity == entity) >>>> - rq->current_entity = NULL; >>>> + rq->current_entity = list_next_entry(entity, list); >>>> + >>>> + list_del_init(&entity->list); >>>> >>>> if (drm_sched_policy == DRM_SCHED_POLICY_FIFO) >>>> drm_sched_rq_remove_fifo_locked(entity); >>>> -- >>>> 2.34.1 >>>> >> > > Looks good. I'll pick it up into some other changes I've in tow, and repost > along with my changes, as they're somewhat related. Actually, the more I look at it, the more I think that we do want to set rq->current_entity to NULL in that function, in order to pick the next best entity (or scheduler for that matter), the next time around. See sched_entity.c, and drm_sched_rq_select_entity() where we start evaluating from the _next_ entity. So, it is best to leave it to set it to NULL, for now. Regards, Luben