From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E74F1755A; Wed, 8 May 2024 07:59:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.79 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715155179; cv=fail; b=FysHw4cdKHgFBVNzDSyp5aqFMxTeyC3mLLB398Gt8QKNnHFuJ0sbIjt1xv+fTpxTLDLA+pAXSOJ4zjc7ctSTXqxsMlR4JNEGcGNiSnDUJk0pc9Aht6m3FEprer/zuKCYMyePpstQplia53UFNIaoUxocHi4ErmiIgjnkmSNlHOE= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715155179; c=relaxed/simple; bh=AXdgSRF2K+o2216NHlc7e8dUMrJEgQlsycS+xV6w/64=; h=Message-ID:Date:Subject:To:References:From:In-Reply-To: Content-Type:MIME-Version; b=ErU7lwUKQPxGFAtViKoZw7sH4qGs3wCOvqT5bJzBvIfkIIXkOuQH6saqSSmwQV8M3shH8UaGz+8QllrcWQEI5Ng8X3jixO0zWaeTCNhVzg8jKKTCf0dvG9SBI8mYV8DxO1eWH+R1pxcks0iCqUXvEuip+SQJaVqnLYJxBZ5B/yc= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=LZgDq/y/; arc=fail smtp.client-ip=40.107.244.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="LZgDq/y/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YZfJFgcZJ2h6chrV4TdVOUs3VkAN4jGCmN3J9eI6bdE+pb3E+v5AsS5sNzLcJkomiPVwPypnbt7LYEn3Ix9qrYoMjdvjPUH6VS8R9aoGN9GuKTohq112YIxysaQdbPK3HCzWgh7ahsMnqzmIIxiZI4v7yKz3hSzcFze+Qlu1kq30Sv1X+33rHuyDiqvP6moir+pMUa0KcotHKksoomqeHTXKXkajHvBcdoqy2eYrrTZ9bY52KFpGvXJpVIYTeuen+k8DNQT8OaqAUbxJXxOsvY9zAN1EHSODcH9BqyrQgKbnLzlKRyF10XXTh2jojguCLxeoeJBuoKqk+2fi8vl7hw== 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=COg2CIfxRuDWjHNCwTSk7LYGNIvP+L37qxDtElZrmwQ=; b=Cbw+d4uRGtocfaqfUUJppwqiLSwbDwvnK+P7L5lA6NuVLvP0O40HOa9cX8O8VtoHZLP8JltR/3nRLgf4h29FRIDddsNh8rF5gxvFqtQDiv9864i9fpt4GVc9qjzeyUmP2TBnJcWMAKHIBVoMNBBqPha1lM96UwAb+dfACFc0JH1HgTX2ir4C6PagGK0B+DlCJ2TeE9gwmjXZryP5lCrV/hsT3s1PBOW8RTUVArLcB87ULuF6YpZ+eUMoSWatl0ft/oFHAgFwluVLQc8UpkiZ5ZofaNtzZxHWEhLUfjspmJ6fpxxvxO4eQ7kvkdxnLz/eo4GkzMWT3ukjGI7/OQ4D0A== 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=COg2CIfxRuDWjHNCwTSk7LYGNIvP+L37qxDtElZrmwQ=; b=LZgDq/y/cXOyY+RBTD8Bl+xOZhKJlQE5s8yQjSF/TZ3bqdAHqlZ6c0LBfeXF+6R2rRfae+l+dhBHwkXN/6amG2Y2WCz0osl3VTzpwSgYR0sEA/yuJK2s3+qtrcvt1oQcFt5xYe2DN1UOKfP8bCOo33cnVCq90sjZotlVdIfA/ho= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) by SA1PR12MB7246.namprd12.prod.outlook.com (2603:10b6:806:2bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.43; Wed, 8 May 2024 07:59:35 +0000 Received: from PH7PR12MB5685.namprd12.prod.outlook.com ([fe80::46fb:96f2:7667:7ca5]) by PH7PR12MB5685.namprd12.prod.outlook.com ([fe80::46fb:96f2:7667:7ca5%2]) with mapi id 15.20.7544.041; Wed, 8 May 2024 07:59:35 +0000 Message-ID: Date: Wed, 8 May 2024 09:59:26 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes To: =?UTF-8?Q?Michel_D=C3=A4nzer?= , =?UTF-8?Q?Christian_K=C3=B6nig?= , Linus Torvalds , Christian Brauner , Al Viro , keescook@chromium.org, axboe@kernel.dk, dri-devel@lists.freedesktop.org, io-uring@vger.kernel.org, jack@suse.cz, laura@labbott.name, linaro-mm-sig@lists.linaro.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, minhquangbui99@gmail.com, sumit.semwal@linaro.org, syzbot+045b454ab35fd82a35fb@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com References: <202405031110.6F47982593@keescook> <20240503211129.679762-2-torvalds@linux-foundation.org> <20240503212428.GY2118490@ZenIV> <20240504-wohngebiet-restwert-6c3c94fddbdd@brauner> <36169520-56e4-4a01-a467-051a94c7f810@mailbox.org> Content-Language: en-US From: =?UTF-8?Q?Christian_K=C3=B6nig?= In-Reply-To: <36169520-56e4-4a01-a467-051a94c7f810@mailbox.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR3P281CA0013.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1d::18) To PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR12MB5685:EE_|SA1PR12MB7246:EE_ X-MS-Office365-Filtering-Correlation-Id: b9a89be3-7906-4ab7-e658-08dc6f34cd03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|376005|1800799015|366007|921011; X-Microsoft-Antispam-Message-Info: =?utf-8?B?ZDlGQTlra0tGRFFGcStQOUk1SS9odDFuOTR5aU1GWkdUNjhkajRLa2o3V0V1?= =?utf-8?B?VWxaK2JXckdiaGQzaXNtTEUxKzh3YXVRc2c0THNOcDVnY0pIdHZVNklXa3FN?= =?utf-8?B?SU9ocWFBaWo5eDBEK2VQU0t3RGc3YmY0ZmowTnFBZmhLZC9ydmFvQWZZanVH?= =?utf-8?B?bkRZb2dYcVhTdUFvMzBGV0t3K1I0VHpYL1lUUGFQVU9tSTJJbUJFYnd1d2x6?= =?utf-8?B?Z1hqQmlzR3gyckZmVnEvU1k1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-8?B?eDZneTg0MlNvTEJxbWsrazIwKzJyck9wVlp4czBtSFJldytydVdsTytTenJ2?= =?utf-8?B?enNZSE5ieUUrMzhXeWpFSitiSTduK29JM0lVV3VZMjdGTW9HWXVZWWRlYWl3?= =?utf-8?B?VVFhK0JSSkxJUWVqc3YyRzFJUnpnaHM4c1hsdUxTQUNzcUtYMHVZZzI2M3dC?= =?utf-8?B?SlA5YThkWG5GTm9LVndEVElkZEw3M2hYdTFJWkVuWW1sNFk4UWV1QnorMUtU?= =?utf-8?B?ajRuRHlQWW11VkExd3k4cWVGTmh1SHZPMS96Wmw1YWJ5ekpEVUx4bjNYUy94?= =?utf-8?B?VDRXbGl0NWEzbDd0eXhDZ0hudDRFL2FzZmQ2MEdqZXR4aGIrM1M2c05OQ1BH?= =?utf-8?B?cHk4TUcyeE42WUNyRys4RERoWC9oaEMrdkt0QmdqRkgyUERRV1RPUEJ0a0ps?= =?utf-8?B?SHBFc1NicWNsK1ZhQXpYcU8yb2JoVHJLZVVtK2puT2hXWFgvRUM0blduVnl6?= =?utf-8?B?eWJTc3RwSEtLcE00VjZ0V3NvMmxNWFVQRGtIUFVzRDQ1TFE0VC9nb1hmbDBx?= =?utf-8?B?bkJWcDZCb2JwK0tqN1hWcGo1eUJaS2tOdzBONURPcGdrWjkwRUlQLzZvY1Qv?= =?utf-8?Q?dcBb6MJCI78iFv8D0lF/Ma1+G9Qrf+SZP8PAWj9?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB5685.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(376005)(1800799015)(366007)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VWpKS21QOUExMXZ4RmtDcW9QZkx4MHRMRmlKTmNGRU5hRWdRSkJjVEpoRVBF?= =?utf-8?B?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S0VXK24zcmV4VWFoNjhxSUtLcTQ5?= =?utf-8?B?cjhiV2ZYYzhDcjJ2QVBYY1BLRDY4RUpxN1dQOFpLZW0xTklhaTlNRFRXMnkz?= =?utf-8?B?YlFEMFAvVS9WNzZnVVFHTUsyQXVENlVpbkhKMzFoT3haVk1jOSsvbnBaUlhE?= =?utf-8?B?RUN2NitjMCtZVkFKTjJORndFakNkZDRyTEc1UXhnVkYyMUpHcDNNUnoyMkxs?= =?utf-8?B?cWpJQlY4VE53cW4vZUR3WUVPd2VYQVlxYTlkZGdwbmZaY3lQYWxOTkFjNllZ?= =?utf-8?Q?tTIfINL8Vh0FFiHTeED4YpY/9?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9a89be3-7906-4ab7-e658-08dc6f34cd03 X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB5685.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2024 07:59:34.9351 (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: a2gA26jfFrKEbRnELoY7OU3eW49vSLlb3fas4WRrOLNK8kdDeTbXPAzZyuaDLH8t X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7246 Am 08.05.24 um 09:51 schrieb Michel Dänzer: > On 2024-05-07 19:45, Christian König wrote: >> Am 07.05.24 um 18:46 schrieb Linus Torvalds: >>> Just what are the requirements for the GPU stack? Is one of the file >>> descriptors "trusted", IOW, you know what kind it is? >>> >>> Because dammit, it's *so* easy to do. You could just add a core DRM >>> ioctl for it. Literally just >>> >>>          struct fd f1 = fdget(fd1); >>>          struct fd f2 = fdget(fd2); >>>          int same; >>> >>>          same = f1.file && f1.file == f2.file; >>>          fdput(fd1); >>>          fdput(fd2); >>>          return same; >>> >>> where the only question is if you also woudl want to deal with O_PATH >>> fd's, in which case the "fdget()" would be "fdget_raw()". >>> >>> Honestly, adding some DRM ioctl for this sounds hacky, but it sounds >>> less hacky than relying on EPOLL or KCMP. >>> >>> I'd be perfectly ok with adding a generic "FISAME" VFS level ioctl >>> too, if this is possibly a more common thing. and not just DRM wants >>> it. >>> >>> Would something like that work for you? >> Well the generic approach yes, the DRM specific one maybe. IIRC we need to be able to compare both DRM as well as DMA-buf file descriptors. >> >> The basic problem userspace tries to solve is that drivers might get the same fd through two different code paths. >> >> For example application using OpenGL/Vulkan for rendering and VA-API for video decoding/encoding at the same time. >> >> Both APIs get a fd which identifies the device to use. It can be the same, but it doesn't have to. >> >> If it's the same device driver connection (or in kernel speak underlying struct file) then you can optimize away importing and exporting of buffers for example. > It's not just about optimization. Mesa needs to know this for correct tracking of GEM handles. If it guesses incorrectly, there can be misbehaviour. Oh, yeah good point as well. I think we can say in general that if two userspace driver libraries would mess with the state of an fd at the same time without knowing of each other bad things would happen. Regards, Christian.