From patchwork Fri Aug 17 15:15:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10569023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A0431575 for ; Fri, 17 Aug 2018 15:16:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B0DF2B1A7 for ; Fri, 17 Aug 2018 15:16:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E6952B1DD; Fri, 17 Aug 2018 15:16:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 50EED2B1B1 for ; Fri, 17 Aug 2018 15:16:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1FE16E665; Fri, 17 Aug 2018 15:15:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0058.outbound.protection.outlook.com [104.47.40.58]) by gabe.freedesktop.org (Postfix) with ESMTPS id 573586E661; Fri, 17 Aug 2018 15:15:58 +0000 (UTC) Received: from BN6PR12CA0035.namprd12.prod.outlook.com (2603:10b6:405:70::21) by DM2PR12MB0249.namprd12.prod.outlook.com (2a01:111:e400:50d1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.19; Fri, 17 Aug 2018 15:15:52 +0000 Received: from DM3NAM03FT054.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::206) by BN6PR12CA0035.outlook.office365.com (2603:10b6:405:70::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1059.19 via Frontend Transport; Fri, 17 Aug 2018 15:15:51 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by DM3NAM03FT054.mail.protection.outlook.com (10.152.83.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.1059.14 via Frontend Transport; Fri, 17 Aug 2018 15:15:51 +0000 Received: from agrodzovsky-All-Series.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Fri, 17 Aug 2018 10:15:50 -0500 From: Andrey Grodzovsky To: Subject: [PATCH] drm/scheduler: Add stopped flag to drm_sched_entity Date: Fri, 17 Aug 2018 11:15:42 -0400 Message-ID: <1534518942-13167-1-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(39860400002)(376002)(396003)(136003)(2980300002)(428003)(199004)(189003)(105586002)(356003)(16586007)(104016004)(8676002)(81166006)(81156014)(478600001)(72206003)(68736007)(6666003)(86362001)(54906003)(316002)(1857600001)(305945005)(5660300001)(50466002)(50226002)(53936002)(7696005)(186003)(2351001)(77096007)(48376002)(26005)(336012)(426003)(53416004)(126002)(476003)(2616005)(2906002)(6916009)(486006)(4326008)(8936002)(51416003)(450100002)(106466001)(36756003)(44832011)(97736004)(14444005)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0249; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT054; 1:ypjmfqc4WLz1cKIsrc/bpq/t7PXovyJFOxrMxQ8zBIUp2JSGio3IJkoM00cS/RYIb5ZuLWWKaIpnV/vppItVXZmFG1kHCDDlqTVZXIUu/H5N3UWCuJpMhJSEa4oKYpvW X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac2c89d6-a3d6-48ff-fc96-08d6045451c2 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060); SRVR:DM2PR12MB0249; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0249; 3:hJi9DBi21ONynXJN9Yvftl4HthgwZxVjVD4w3USGoaCWfR0MiPgJk5L0Pz439VrjhBduJu951f9WZdf+499mD0Qlt79VAjhbHqn1TSDj2+rpFvcoTXTbGPznLf0Y1c/xNRGtSRicdlidhkkUlnRaJwg2k0GSYiJJoK053NFvPdAMgYDOMP39+GySPqSMkssiKMiQ32ZXKxPhp9l6eohptb+MK14qXY/ss7kB8L0Au2ccFk1kH1mAuQ9dVBbZrijWhFTTvkgAxfHnUIcugPkQ6w8Af0LMOiXiTFA5ih8D2QtcYKksheDrD2rboyPo2XNVzVusCXTIaxb6u9eFcb/FCmjQempfGvaOePHcSZFJ3e4=; 25:HFIDIAIuviUhb+mdfM5I3kvrC2IEGcwMSG2JYi0iIdrdyvrwQWW73GES9LJHxH4U+Lkaq5/3xvH7RJ6BR6Yq99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-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231311)(944501410)(52105095)(93006095)(93003095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:DM2PR12MB0249; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0249; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0249; 4:vwa+74/YUs5hgEcyDFB4H42isi4NYFFxlJfFDkwt0JegqO6KFY6Wjr7X96D3mQl4zlUHPNXKRu5qe/RCkND6KG26EWDYzYCfMku6OpSIJ3xVAZjyexI32J3v8L4tYdq3isB02ZZLbKmuoCVD4+Db7UyXwy9ZLohu1w/ap3Ha/RkwBBvp4tE5D5dkDYx1MWuNRsldCokFbNN6X0EphQURJQlaNe0sd3Y+BgZOZRdxejq+GqaPvu53gKiuAZK/varlmGU22DOkEzt7Z5Tns2ZVttcUot9EasFgwNwrhwOAeMTQ/f8mCqHSh9k8WpBrJWKL X-Forefront-PRVS: 076777155F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0249; 23:R4hcIsJE7Z7NCylgwgjNnqcRaL24+PSBM6ZQeaKC2?= yLAk0iZJceiWyz/lOBg59BMLX4NdJqlBA7e+BXA+gdY4s7Zdl0TssvUZMbR7Yl6MCCBUVP6+1exbs7qhTXnnvKEJv7oxPRjJogwwDjaOMJ34+ZkYUqx3F0iYhkJftMVQD50CcpY+C6gNhvYGHMIy2I7Vcfz6Nz+xAJ5KeCPm4VMfTtiCIc8FfH8i+0tMa0YZAwTr1a/Wz0oNEx/nymGtt16x2zvltqUHi7U2BRFv2ibeSvBJ9QcX9x3yEyTRdwdtsGV0cODj/WMvSVBee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9ZhHnqSnf1g6By+2PRPtwXr3G1KpIJbK85kG88mLN44SVfP/DaI0Kr/J8JTFXp3lRjLq4qzj+iCWlfE47fwLlrmuOE SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0249; 20:op5SSM8fBJQrbi5xXiKjdkvWeGnGLHCykvqp2BZmLP3YoW1TBPQb/ejNNDe4hy3xgK8Sq1MW3d57wj3dJZB53I3DjEB4OEMlu89j8wYjZZFrhWqT7GBL9OctYiUz8gmjX1M5+foHN9M1f8/L/6/TIkUergg/r1N9RqqQHEYUDFtHOVcj6WCis5RdH/liGO+4vWCjEBibWM58ATOvtnwlECUuOxeF0xmMNtMJtXTW0+BvbmxH/DXlTbOAlBTcSnBd X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2018 15:15:51.3282 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac2c89d6-a3d6-48ff-fc96-08d6045451c2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0249 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, amd-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The flag will prevent another thread from same process to reinsert the entity queue into scheduler's rq after it was already removed from there by another thread during drm_sched_entity_flush. Signed-off-by: Andrey Grodzovsky Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/scheduler/sched_entity.c | 10 +++++++++- include/drm/gpu_scheduler.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 1416edb..07cfe63 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -177,8 +177,12 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) /* For killed process disable any more IBs enqueue right now */ last_user = cmpxchg(&entity->last_user, current->group_leader, NULL); if ((!last_user || last_user == current->group_leader) && - (current->flags & PF_EXITING) && (current->exit_code == SIGKILL)) + (current->flags & PF_EXITING) && (current->exit_code == SIGKILL)) { + spin_lock(&entity->rq_lock); + entity->stopped = true; drm_sched_rq_remove_entity(entity->rq, entity); + spin_unlock(&entity->rq_lock); + } return ret; } @@ -504,6 +508,10 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, if (first) { /* Add the entity to the run queue */ spin_lock(&entity->rq_lock); + if (entity->stopped) { + spin_unlock(&entity->rq_lock); + return; + } drm_sched_rq_add_entity(entity->rq, entity); spin_unlock(&entity->rq_lock); drm_sched_wakeup(entity->rq->sched); diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 919ae57..daec50f 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -70,6 +70,7 @@ enum drm_sched_priority { * @fini_status: contains the exit status in case the process was signalled. * @last_scheduled: points to the finished fence of the last scheduled job. * @last_user: last group leader pushing a job into the entity. + * @stopped: Marks the enity as removed from rq and destined for termination. * * Entities will emit jobs in order to their corresponding hardware * ring, and the scheduler will alternate between entities based on @@ -92,6 +93,7 @@ struct drm_sched_entity { atomic_t *guilty; struct dma_fence *last_scheduled; struct task_struct *last_user; + bool stopped; }; /**