Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4011672pxb; Tue, 25 Jan 2022 01:19:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkiF5fATRyGKudusTkQdlcvb4MQ/mEVbR1avi2O86oDuu0BkFX3IkEU6p5l9V3sUjMYDOY X-Received: by 2002:a17:902:d10a:b0:14b:4a73:8778 with SMTP id w10-20020a170902d10a00b0014b4a738778mr9238659plw.53.1643102393625; Tue, 25 Jan 2022 01:19:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643102393; cv=pass; d=google.com; s=arc-20160816; b=W8VMA63aupzOXmAuz4P1lA0LinWMJuGxfgWgJTA5uBzansI3de0zdCB61RDWfUPM9s IUj47AD4Ffdo2cqljovNweCd/+EaESWSCksZ3vA+wWyRidGD1bG3kYB2nIM0nJgvUMr/ srh0bypr8hEi4oBJ871JWkw4WT3/GY3AevPC+ODIRRaUeFs+lKXVrfip0OwaRhdupNt2 qVTCcg6U5DRxyZot27z8OH9fZqR0sH+X1ms+in1s3upWxI4rPI9CUFse6/06Z0KQdu/S o2R5R81cUM663H1KuH2FjkjCWPCflXjOQ4RXbrruSacWB5UB/Aok0WrR/5LFN/s0pfxK i4Kw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-language :content-transfer-encoding:in-reply-to:user-agent:date:message-id :from:references:cc:to:subject:dkim-signature; bh=iDYVNkPrlzT9H9e1/OuiVoKw3/d9p2F+WSl5pz1Vg+c=; b=t26njsPqKPGmJkHSzwgKHAp13UAuWMY7RnHJavoIC9f7I3RTEfSbBDnIo1uys72oA7 YgebOHS2scB+ukC3opyzxHDlUReJRQkhrAcOXJN63+RJmZLAJ4mmEGDRNzQs5CSUBywt dKYTHm/Muu7fCZA22hkGVHJ7iHuDLG/0j8wuUlasqq7hqLc7PwTIaZT2akkB5ZHY+bSP pDkSitEITlsVkIB+XdhoHwQoSbYYpRuEtoP2VHtaAIvPsE+QUD48z6O7mrlhkRjv+hQ9 dBNwdrToaZXDpomIbKEGELy25dS2X0xThJANA2dFvMfzHwaz1ZjFSvwPuqsbjp7p+vgS vUPw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BkF9QY+9; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si14365827pgo.616.2022.01.25.01.19.41; Tue, 25 Jan 2022 01:19:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BkF9QY+9; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1445471AbiAYH2y (ORCPT + 99 others); Tue, 25 Jan 2022 02:28:54 -0500 Received: from mail-dm6nam12on2082.outbound.protection.outlook.com ([40.107.243.82]:45665 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1445104AbiAYH0i (ORCPT ); Tue, 25 Jan 2022 02:26:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B1t5KXqJYappknWmKmWVsrUPVHUvnpITXcrbJWehZSdueeKu0DtqM+l7Vy7dCAnlGcv+XTV+Wmat66YpyqEQ91/ciYKxAma/XZUd9pdU/QxXAWOxUNDo+EbbZFhlDUoLfjxXigC0mLEg5LAi+8XmkPRQKxYmWSyRY4mrTUJP+xFrp+Dt5GclhYvsrNUFBDNTa7gQFdWzN500thGQQ2xL+cpcHVe+WKm1D96hr8VJOAmf5jErr7kAswjTxXgTnewRNPi7yxoVTaSbOnubjWXhvzL2tgvEs0uEtUNW/wo2uH80WjO6gMHvZBejQh0iho+KJI6CwxxF0Qd1snF89E92cA== 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=iDYVNkPrlzT9H9e1/OuiVoKw3/d9p2F+WSl5pz1Vg+c=; b=frkPBkdtHvI77tQDzVGt/Unri8wMoKJogqbNDW0k6O80w3M0IJeDtQTsTIfIvQp9YAYCuHlEtNR1izUSlp9g0z21ufrclpGRnrg3EKWYzPmQTXNuzGAXChj8PfR7sHp3Wxy7qjBObhmIg0kcxkXjc3Dxa1mnRTPSH9AgtotyRXEcUFfl3nj6mISGlTEDesue9py2vd54z4NnYyakFrapmrJV9yIBGvhwYCtD3s2KDN00Z09YkvQ1+YpgWK742l6hEEwkByvSzjKWsrZz7e+6apFZjcQ5M9Mq0y6RvOevug1J3R6s5GcxNm/gFNn0hpwjgMY1Q9wxjowdTcOn7lhYGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=iDYVNkPrlzT9H9e1/OuiVoKw3/d9p2F+WSl5pz1Vg+c=; b=BkF9QY+947zASJ49OuolZ9dUDV52YgoNaZ9wLPSvm/q4doa4BtINlJ4IH9ANqjZWdesZL7k1tb4EXiwz+HPwi2W3AKoBesWvXsx1NmtrElnjObFxz2oDvwuCWHAk6hJIL0rm4BrQSJsI60UHJ3RNpiWY6ltgVgAyLKl3l7GLD1s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by BN8PR12MB2897.namprd12.prod.outlook.com (2603:10b6:408:99::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Tue, 25 Jan 2022 07:26:26 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::d8e7:e6b0:d63c:4a21]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::d8e7:e6b0:d63c:4a21%5]) with mapi id 15.20.4909.017; Tue, 25 Jan 2022 07:26:26 +0000 Subject: Re: [PATCH 5.16 0702/1039] drm/amdgpu: Dont inherit GEM object VMAs in child process To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, Felix Kuehling , David Yat Sin , Rajneesh Bhardwaj , Alex Deucher , Sasha Levin References: <20220124184125.121143506@linuxfoundation.org> <20220124184148.931014095@linuxfoundation.org> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Tue, 25 Jan 2022 08:26:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <20220124184148.931014095@linuxfoundation.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-ClientProxiedBy: AM6P195CA0065.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::42) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 49fce4f3-e7d1-4480-58cc-08d9dfd3fede X-MS-TrafficTypeDiagnostic: BN8PR12MB2897:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rpMe6izbguWC2OnLFhAzI5HHNSc6lPdkaJ2wDxThH5mveOjWXSUdBcpKUMnFJs0tKTCz4bbtl9y69STQFNiqIaNwGCtjfveGrh7UPMK7pKad473aDX0jK5V42EyLmW85Uyfcqq2j/BrhI2RZSwjZW5hz1hdaok9AL0CAkFxjbKKwf1W4/PX4MO3ac3dfUtQIYZAy10WDSeRP3b2iJtbCaLbWZ3y+6ViscjBh/qiKrgOtc+qCtqM4I7WxUC+8PkDj1ObKpBDZBsr/HredJbVAY/568kgChSsfNUMm9WcZVF6q5YlXtrHMtnuef/R3H3y/PBKRftpICzjm0wt9oNy9ImoneRAH5Eb4m1ICqsZ9VWNSXypGNim8KSxpQ76HRn9dG5TrZVvxfLh1tpEUplGMmGDUSiXxXY7PQ+HUzxMe9bueB31Bofhgmj3ce4S3M0APoKNFjRJeVMfOGbjU7bJ9w/CM9mfaA143xAXmmOjuybltl7/KSUoJi5c6DKOtuGPzAKPWn3n+D7nQvlTOegrDk/RXCaxi04Y/hGZNVuNGYTkV9/ea28GL7oKjjg6r8UXD5aO0xFKpkqZ3Zv27PpqEekxYKbGN5uajuZ8QJWK0jffupH4S561OT682L6AG39EufQAUyi7E+ayQtT8jR1mWODrEWdQPpslQiZE58ScrC7OS/0w3T4fo8ypV56sekifMyYD9HAQDeQ03XLZmxX338xX238ZAx7QIyNb4w3tcqYslHR9KKbvP/Xa7G+jHBerz15RVOqYa5G4Be+Nk1IUMPQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(31696002)(8936002)(38100700002)(66946007)(66476007)(66556008)(6666004)(186003)(5660300002)(8676002)(6506007)(86362001)(54906003)(4326008)(2906002)(316002)(508600001)(6512007)(6486002)(66574015)(36756003)(83380400001)(31686004)(2616005)(192303002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U1dXaStZenZNbTIvYWVOLy95KzRQbVdOTlEzWURMRXNES1g5Rkp5TDhlamZR?= =?utf-8?B?MlZjSTMrSnN2MkdMWk9ORkZTdVZnWU5QZG4yYUFkeU1MSHRaUHNxSzVmUDA1?= =?utf-8?B?WGY2Z0w0bXQrNEZTNmU1ZEx5ZGpxdTJaZlRDMktRQ1BFVU85bjZPOUgwVVIv?= =?utf-8?B?QVNsZVVLL3h3RS9JMCtsUFZWeElkdVhYeFdkYmIvMmMzTlJPNmVlRkZxdGxy?= =?utf-8?B?SGhoeGFUQVQzU1RsSXFXRWZYSlc1RTdWUW55cVVBa3VZTWozeDZ4QXFUVUxN?= =?utf-8?B?MFlKRXp6UWQ1VGU1Z0xVOVVsY0RRQUFsYWpwV2NVKys4a1VmSDFqVlg5YzdV?= =?utf-8?B?NE1YZ3U0dVhPbnJPRml1SU5qaUdWOW9kWGsvYUIralFyV2pxL2hLK2FzckVp?= =?utf-8?B?Y3F6c29pYSs0VjlQVzhsVnkwTXBGdEVyNHZEZmkvcGZKK2haUEFuRm9nM2Vh?= =?utf-8?B?TTdrZmVLY3p5ZUxRSEIxMWZqalVNcmIzZ2c0em5hVmxyNCtxZ3NJVWREa3or?= =?utf-8?B?RVlacTBCdkYwWTZuZU1BaUl4OXhMZ3BCcDJuelkzbjZnUmVpdFpPNGxqVklQ?= =?utf-8?B?VDNPMHI2ekJidWFRWDFQME9ITFRTOFdJbGE3SEVhSDZGa3Q2VG1SN1hXU0ds?= =?utf-8?B?MlpCOFVnMFJoTnRRMG9nTUxZQzU2REI1M2J0ZkNSczJ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kQkhCYU0wVitLekExQUI5dVp2ZnJlYVM4?= =?utf-8?B?SHB5NmR1YW5uS1MzR3phWVo3b2NUUWNVQmUvZ3NRUVZCR2d4enA4OE5zUm1u?= =?utf-8?B?a2l0cEI2QkoxOFYwbys3V1BkL1pRdGN6NFdDd0ZtU0l4V2xhSE9CajgwOUVL?= =?utf-8?B?dVZNcnpHYjU1NlFUaHlNWFNwY09rWXh4UG9KUUw3Tmk3RGo2eEJVNkgyZlRW?= =?utf-8?B?NUIzY0hENlM5NjdWalVjS2hXd1JNVDRuOVY2Q3pmYWRYVXUydS8yajRBenNm?= =?utf-8?B?VDMxNVUxM2UwdGluS293bjg4cmFBaE15ejhpYjJUYWRaajZVNkcxMGFjd3Vu?= =?utf-8?B?bEJwNmFOWFRCTGt6MTc4b1QrTnkxeTkvWlBjMTFGS3dQbm1pbThhMEg1Q2wz?= =?utf-8?B?dHBLdUp5dG5ybmFwTG9WNmxTWDIxSXBlUm41eE0vaXFKbTVVNXFHWDUzRnM3?= =?utf-8?B?WlNTUXdRcTRjWmdwN1FjWjg4RmhJMi9JUDhXd2R3eDkzVEhobnhCN1NzQ3Bk?= =?utf-8?B?TUlTbEpDK0grTUdvcDFURmZDbVl3YkxVTWxaWU44dGtYU3BORGgwK0lCekFN?= =?utf-8?Q?8ij7aGtHKHPHCUsBCMhz1vk=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49fce4f3-e7d1-4480-58cc-08d9dfd3fede X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 07:26:25.8745 (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: whTcLrfbBHAxWcSvtOGdo5l9hWYXe8Rf0P5F2mhiUf40qY3m/5WDXfRiHEM5j+mM X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB2897 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, Am 24.01.22 um 19:41 schrieb Greg Kroah-Hartman: > From: Rajneesh Bhardwaj > > [ Upstream commit fbcdbfde87509d523132b59f661a355c731139d0 ] > > When an application having open file access to a node forks, its shared > mappings also get reflected in the address space of child process even > though it cannot access them with the object permissions applied. With the > existing permission checks on the gem objects, it might be reasonable to > also create the VMAs with VM_DONTCOPY flag so a user space application > doesn't need to explicitly call the madvise(addr, len, MADV_DONTFORK) > system call to prevent the pages in the mapped range to appear in the > address space of the child process. It also prevents the memory leaks > due to additional reference counts on the mapped BOs in the child > process that prevented freeing the memory in the parent for which we had > worked around earlier in the user space inside the thunk library. > > Additionally, we faced this issue when using CRIU to checkpoint restore > an application that had such inherited mappings in the child which > confuse CRIU when it mmaps on restore. Having this flag set for the > render node VMAs helps. VMAs mapped via KFD already take care of this so > this is needed only for the render nodes. > > To limit the impact of the change to user space consumers such as OpenGL > etc, limit it to KFD BOs only. > > Acked-by: Felix Kuehling > Reviewed-by: Christian König > Signed-off-by: David Yat Sin > Signed-off-by: Rajneesh Bhardwaj > Signed-off-by: Alex Deucher > Signed-off-by: Sasha Levin Please drop this patch from all stable versions since it was reverted from upstream later on. Regards, Christian. > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > index a1e63ba4c54a5..630dc99e49086 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > @@ -264,6 +264,9 @@ static int amdgpu_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_str > !(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC))) > vma->vm_flags &= ~VM_MAYWRITE; > > + if (bo->kfd_bo) > + vma->vm_flags |= VM_DONTCOPY; > + > return drm_gem_ttm_mmap(obj, vma); > } >