Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp323274rwi; Thu, 27 Oct 2022 01:31:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YyI7i4hyotJlBbzmVa1olPKJiyZVJ5focvR8NxpNpx1lb2X/S1KpeCCQRpBGzWzrW5+nA X-Received: by 2002:a17:907:3f23:b0:78e:260a:fc33 with SMTP id hq35-20020a1709073f2300b0078e260afc33mr41676833ejc.152.1666859495489; Thu, 27 Oct 2022 01:31:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666859495; cv=pass; d=google.com; s=arc-20160816; b=yJXQgTPdmm/uW69pVphanXLyiqlhFqs67IFoo1BeKU3QqP5h9Tk63BT/ue30LKSZWe Yl52j+BsHioYRHbL+IIJqOC0tVqePO1xHogdojZ4WeKfjIk8W9T3hyBVfXdm5bzEHmAG xaJJVrXYUP24SNl5m9k6FYyOHv7GLun00xULA5xpg2M6rJT/wiSc1qbhCYFBe6tbnFJd OOgOxSUTOBcmStAf8X8MemqATn19eDY7YQfVEOPtRqF7csw/4nRX9xIKM3T+raCauVwg bZclLJhE/Sfps7tmuR+VSfu/viNqvbpgAaYK/BtnJ0TblcNnIxZ9QgV/F4YvPLcg0leX My0g== 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:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=ssW8B9K6q7hhnxObzL5N+R5XSnPF1TYDgCy/b9JvuvQ=; b=S8/geS7hwRFqdyFq13um4y4inO//tvzyK4xLm9VvUNHUt0Vai9eCEsa+xixAemai50 V30RQCQDRNzjdYqs6XNNj6AhhtKJfMMqqHV6toLGNLM4633lYmLhIG7a5/vjAXT5D59d 8Pj3uBPqO0JuugboJD7pD2EQSH8n6Yr/rC8jar7bHjgmKSKifwmSfEEZRDNZ3j3+k07p l3afQxAVZtU7pVx0BolllzdwVBi3nzC9R4vASuDIdBOKitdXEvNIMjtD8VlzWAmqQNwI Rtp1D73cngXfmM6Wxod1wI2AO9d6sW1IbHKy8yOvj3Vr0tT6KXA0I8Flli8BfQkbuzS8 Wy3w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=DberEgoy; 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 g5-20020a1709065d0500b007acf3aed493si903080ejt.910.2022.10.27.01.31.08; Thu, 27 Oct 2022 01:31:35 -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=DberEgoy; 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 S233965AbiJ0IYo (ORCPT + 99 others); Thu, 27 Oct 2022 04:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234043AbiJ0IYj (ORCPT ); Thu, 27 Oct 2022 04:24:39 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20605.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::605]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84609167F3 for ; Thu, 27 Oct 2022 01:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g9NYA1/6LiT/FwGJ9iQKxDNzRJzabCa+Sk0RqpsANJy4fAoqolcQDKCLHF59k8ZgNpLlCAIMId6OupLTM8IuDko/qhr9/OH/S0kkxD7dAcLR9MNxgnZXt6562g1deCtBNnG4AzsLifcwo5gPD1KDG1T1vGwZaxPLbphO+J/bQje5UnjmCypBMHmSUu4s4JQ3qmWGpSRqFwHmXy6WMaYt4svn34kQYmdC1XyJCWKuvUixNm/cthhssytaAc6YCoLlIgb8J2ePop+/hoqZCgni4ZeyzWj3bq3X7bkNcLWvNycmjDvvqUvRUetfwcTVC8nnKrJ1gKUSCGLFonVnTuP+aA== 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=ssW8B9K6q7hhnxObzL5N+R5XSnPF1TYDgCy/b9JvuvQ=; b=L8JFYugAHMNTirSKETBodAMJXkOTFtMLWPsVfxQY4A2jNcxgYSQBIvlz+5zxdZtEiZQcrchG0FtB4rLEZJutW82WksBIOQgZa/zqAEPfslfHpHUuaViaEYQQONYvbRyIM0lmO7y01GCDFsDdFrMTPhyxT7xIWHIdAWnwJAGwpsP6pGFZVOkyKdDy6WaWeOpn8IlKuYbh7HhjTnAce7XLbp5AfEIDPEFJKJ8Uzs+a8MgMM4x+NcShhh0BE/YSQqfnLc97WqZlw4hInw2LChlv3UmNBfyXPz3E+XCv9+MBJWAMogyY7yCh6tKRFIT7v+qsVS+b9tB+fHFT38qZ/b9f+A== 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=ssW8B9K6q7hhnxObzL5N+R5XSnPF1TYDgCy/b9JvuvQ=; b=DberEgoy33jq7/FlpKCm9Kl5oRkIvEJpwCYabbVss4xJC+C/S2bexBAtZKGu6UlMA+vwxiPztjkx9R2yeeDq8xb90my1IWV2w7L4xwC2aFfsccaUp+D1jlBC8w9gBwXKzUE+9FQFO91t/fm0RbKtq/tM1LjZQ3+iFGj7VHuvu5o= 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 DS7PR12MB5790.namprd12.prod.outlook.com (2603:10b6:8:75::18) 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:24:36 +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:24:36 +0000 Message-ID: <5bc35aea-466b-bd09-563e-f3e32796b83b@amd.com> Date: Thu, 27 Oct 2022 04:24:27 -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 To: =?UTF-8?Q?Christian_K=c3=b6nig?= , brolerliew 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> <9774ddd6-60d9-245c-77ac-59951c13b263@amd.com> From: Luben Tuikov In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: YT4P288CA0071.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d2::23) To DM6PR12MB3370.namprd12.prod.outlook.com (2603:10b6:5:38::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3370:EE_|DS7PR12MB5790:EE_ X-MS-Office365-Filtering-Correlation-Id: fd5d5188-8570-4ed9-202f-08dab7f4aec9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K7vv5U56jBknHm59fuif6UIbYAXGgT4Sx59VKfwfa2FSp5rmrt1Luh7lURkODPe1zJHvkQ/OCFIQtnq6BkffbJtMcRoyd0R+wSNuLP7WsCjIjowJHbEOWPe+KcSojkBj/toVowkwWMZHpukcDlfnM1mBalEWz8eV1vuFrW+SN+V+3H/GnkIdxZJ1Xdlm4YtnJ+1qEYohVhp+0JegqQOBfwYKYMDjq8ttH4F9ccQLzZ3plJAcW52WcN/NXMu3qeJnmr9oqWoQ457tHnBOPZIFyZwhVPD+pdfamOpVJObg94AHz4p5/k3/tPuwsa1crPA6ji5mgPJ/3zY4EE/ThNoXKqSy6P+QWPm2+XksvkggN5DwB6OLkG3keFx7bsdtqGoifBBZI1bo+0IAISnuNt0GXdZtJuzebI6pcmeIC6jZGLnXCdTAX04QHlQN6nvTnTDo6z0584eW8A0NJV9p4NgrvJugV3vOTYw0WDa46FbJJzdPKnwoqwcGbLLNWcWP66UlRc7ITVuaYRMd/0utBm3tRhiJPLa7rjcVrZ4Kwt1phRkTG3429LcHnBPEYM1wfcE1AqRmM4eV/XsuvjcDKYHt+hnQ0TXyqC8yKIsBiKaz1n/EjojkQyp3BriWx2AIJ8W/xLk5V07UrL1mCp/u4ghpnyZGyJw1pepWArH8AQxp73vT8sf2LzUlELpt8wxN+YhxS9abz4xG/xajs4HrVzvw7zMoiml6QKyfKPmFDCYZqlSM2IdGNe29hU/ZXBsiE/wbGC/IvJjC0sdPGPUFkSELIm3vrXZ2Ucj5Tmgq0XKY3uU= 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)(136003)(366004)(376002)(396003)(39860400002)(346002)(451199015)(83380400001)(316002)(110136005)(8936002)(6512007)(31696002)(6506007)(478600001)(38100700002)(6486002)(86362001)(66574015)(36756003)(53546011)(26005)(41300700001)(6666004)(44832011)(5660300002)(31686004)(2906002)(4326008)(8676002)(66946007)(4001150100001)(66556008)(66476007)(186003)(2616005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aTAwRGxvSDRicnh4M3pDMUgxVC95Zm8raitSdGxhd3o3UXhYMldlOEpsd2Vm?= =?utf-8?B?UG9uT3EwQkViZmlWMVIwZHltZ0NESkdkWjRQei9NRnUrWXlaOFRKZzNUSHQ0?= =?utf-8?B?MVVXU1BiTHFSSGxSYWUzM29IL2ZqbVpDRzAyY0REcWEvL2c3dkdzd0JkMjNO?= =?utf-8?B?S090NmsrUzhBbWs4RUFRRDZjajJCb0FhVmk5cU92RUNhSEZyMmpISkpyQXNH?= =?utf-8?B?Zkc4TXN1MDNpWndrVG9MOFpJd0I3ZkowVEI5SkNDN1pVYUU4QlhDRXB6NmpT?= =?utf-8?B?SkloSzZpTFRJN0l6bktWLzQ4a25ib2h0TVFDWWU0NVE3YlBMRGsyMXZnbDJl?= =?utf-8?B?MzNqM0N2NWc1cmd3RlNFOHpUYmYrSDRJOWt6UStndFNHWTUvMU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570-4ed9-202f-08dab7f4aec9 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:24:36.0072 (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: HYSHjLW+/CI+R2OhyhJdSeOIWfpMKOgonwm6vihpIWGFOTBV7cnOUN5By8OY9IBu X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5790 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, 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 04:19, Christian König wrote: > Am 27.10.22 um 10:07 schrieb Luben Tuikov: >> 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. > > Apart from that this patch here could cause a crash when the entity is > the last one in the list. > > In this case current current_entity would be set to an incorrect upcast > of the head of the list. Absolutely. I saw that, but in rejecting the patch, I didn't feel the need to mention it. Thanks for looking into this. Regards, Luben