Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp865151pxb; Thu, 28 Jan 2021 02:06:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyub6vZlZnuOUg84PhUu8v2FYyylpLouR7msdDQtId4gjHgBCGI8hUuU4FlIQoxr53CldN4 X-Received: by 2002:a17:907:94c8:: with SMTP id dn8mr10559459ejc.512.1611828416376; Thu, 28 Jan 2021 02:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611828416; cv=none; d=google.com; s=arc-20160816; b=G5L3q0WIc5VyL0Sl0/9391nQx4TyAzM5nzlNvT3AS6EyTGJCDPxGp1o3P3ZF9+iUUc ahlhVPdqsz8bhlma2xgZLzLzMwuxIcStwhSmbQ4UhmwzvrSRW2Lm55AY8Jrv94GBB/wz tsWwykvzev70QHxIrrrBKBlbj2D5Ivwy4ILvVsvzK5onAMQRCItugxb5tZevf7Om1m11 yp/6LZV7oD1LnGn5qAoAk7n6xB/x2oxxEs4xFjtKzfOHwz5L/t0QE7lvrE5+8Td6iw8V sWPQ7DVl1F5Z4453Sr6jVvHovsu88IKiixPMWcR2diIXghkIyUBiwADsM0gwhwOe39kP MCSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=w7zs4vtlCOUzPk4JPVodMGjOwCX7vvMr8Eyh0CtBlKY=; b=lk3Ngnjc9JQJvv+gH5liagytBNaMnlCF/HVg3pe1mqB61Qj8ukWTSDzDpedhshpJcg E6gKWv161SbDRD60YeW5IhaeFNhpCQtQFn/DepsYnh4kvpL5gTBXmLyCQDCWaskSWEXX xyZ7EY2uL+MheIYFdNp0EU6T4qq43gRsC2JLnsZTGBTGExo73koASMkn0V0BlLGiq2R7 Nq3BvnhNYyqSs4dsCqRiRHog+6v0gyrLVPUv2bSNBOqw7WqgnBf5wVo5xigdKzcqy1Vh m7NUyB3SO++OYocy/7vBjgyfRdIKGmHS1IksmiWVNoQOcFnZhq/nvi+w9YlJwlMveV7m /sGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aBdiFZ6Y; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si2647191edr.115.2021.01.28.02.06.31; Thu, 28 Jan 2021 02:06:56 -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=@gmail.com header.s=20161025 header.b=aBdiFZ6Y; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232361AbhA1KCn (ORCPT + 99 others); Thu, 28 Jan 2021 05:02:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231267AbhA1KCS (ORCPT ); Thu, 28 Jan 2021 05:02:18 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E641AC061573; Thu, 28 Jan 2021 02:01:36 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id a8so6798090lfi.8; Thu, 28 Jan 2021 02:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version; bh=w7zs4vtlCOUzPk4JPVodMGjOwCX7vvMr8Eyh0CtBlKY=; b=aBdiFZ6Y4Kp+nOhlgpCK6Z6WTIvAH7uPf6Dw5GNH8lHwqAWrTPwgv7vL2KYjq02Vzf shdsv89u8LsaAAr4C9B70PX49KyEWjk11sBOUQy5cKQC7sAnotKMqxOnFd5pwGXnuYyy l4f3pSmC2a8RsLkHnRek405USQ2daHF00hHJonK1HWU4GiqNMZaAeTUGMoThii0wUOzP NDy6YjY8kZgEdVBQIdn4njsH+p0ACV44wG9Nd5DeSV8KqfTab60BZgHhtRoUq+xmcC5v I+zA3q+ohcTZQbquqDT8HBeN8YzAWKtplRBAFKkGxorn+I+YQQvbBqrzdDKBAsHw2dtU 037A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version; bh=w7zs4vtlCOUzPk4JPVodMGjOwCX7vvMr8Eyh0CtBlKY=; b=oQ8AleDfmz1mLGLP5QEKKcjP/PUKYwB+aS7fH3FwnANGjxJFk7GvskSnTPfULf4l6G ckKJ7Mnh0jaD/gwNb+CTdSUR5v/Cs3yfzNVTCfRdG8HbpyVAn13ImK/J2cmSCu8Tqdpm gD5PxQvVwLS5plNfehibC80jKLpAkPNsUGnjVKMnUJwolZVhlQxNtqjmv4csky1H+o5k qj9ZVP3niZKz/dvjz3+CK8AcdU/qPB4tHRz0M6vhNK+IiSXxg84PfQfIkv+1z08DqtQO GdlLd0NmJGDUDgl6mDfhOau77PJav3tMhP7bIOG6gzP8GuERcpIS5OdI+ZtlESzo0pZQ g+5A== X-Gm-Message-State: AOAM532suIXNBBI2/3FAc6Z+AeTGtDhMDdeT/CaiQSSmcLpYu6P25wRr oBSb/FOBW/dHJs1kJzJnpvA= X-Received: by 2002:a19:7507:: with SMTP id y7mr6874145lfe.334.1611828094763; Thu, 28 Jan 2021 02:01:34 -0800 (PST) Received: from eldfell ([194.136.85.206]) by smtp.gmail.com with ESMTPSA id y20sm1830647ljh.124.2021.01.28.02.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 02:01:34 -0800 (PST) Date: Thu, 28 Jan 2021 12:01:30 +0200 From: Pekka Paalanen To: Christian =?UTF-8?B?S8O2bmln?= Cc: Michal Hocko , Jann Horn , "open list:DOCUMENTATION" , Szabolcs Nagy , dri-devel@lists.freedesktop.org, Andrei Vagin , Kalesh Singh , Hui Su , Michel Lespinasse , Jonathan Corbet , Mauro Carvalho Chehab , Jeffrey Vander Stoep , Daniel Jordan , kernel-team , Alexey Dobriyan , Linux Media Mailing List , Kees Cook , linaro-mm-sig@lists.linaro.org, linux-fsdevel , Bernd Edlinger , Suren Baghdasaryan , Alexey Gladkov , kernel list , Minchan Kim , Yafang Shao , "Eric W. Biederman" , Greg Kroah-Hartman , Hridya Valsaraju , Andrew Morton , Linux API Subject: Re: [PATCH] procfs/dmabuf: Add /proc//task//dmabuf_fds Message-ID: <20210128120130.50aa9a74@eldfell> In-Reply-To: References: <20210126225138.1823266-1-kaleshsingh@google.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/EjrvI7yGo=jgR=BTk/_==YI"; protocol="application/pgp-signature" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Sig_/EjrvI7yGo=jgR=BTk/_==YI Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 27 Jan 2021 12:01:55 +0100 Christian K=C3=B6nig wrote: > Somewhat correct. This interface here really doesn't make sense since=20 > the file descriptor representation of DMA-buf is only meant to be used=20 > for short term usage. >=20 > E.g. the idea is that you can export a DMA-buf fd from your device=20 > driver, transfer that to another process and then import it again into a= =20 > device driver. >=20 > Keeping a long term reference to a DMA-buf fd sounds like a design bug=20 > in userspace to me. Except keeping the fd is exactly what userspace must do if it wishes to re-use the buffer without passing a new fd over IPC again. Particularly Wayland compositors need to keep the client buffer dmabuf fd open after receiving it, so that they can re-import it to EGL to ensure updated contents are correctly flushed as EGL has no other API for it. That is my vague understanding, and what Weston implements. You can say it's a bad userspace API design in EGL, but what else can we do? However, in the particular case of Wayland, the shared dmabufs should be accounted to the Wayland client process. OOM-killing the client process will eventually free the dmabuf, also the Wayland server references to it. Killing the Wayland server (compositor, display server) OTOH is something that should not be done as long as there are e.g. Wayland clients to be killed. Unfortunately(?), Wayland clients do not have a reason to keep the dmabuf fd open themselves, so they probably close it as soon as it has been sent to a display server. So the process that should be OOM-killed does not have an open fd for the dmabuf (but probably has something else, but not an mmap for CPU). Buffer re-use in Wayland does not require re-sending the dmabuf fd over IPC. (In general, dmabufs are never mmapped for CPU. They are accessed by devices.) Thanks, pq --Sig_/EjrvI7yGo=jgR=BTk/_==YI Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEJQjwWQChkWOYOIONI1/ltBGqqqcFAmASi3oACgkQI1/ltBGq qqdcrA//X9uN75QyHDm8jqei3p8rmD/duy0jDCn6W2DbNy+6VM79pp8ZjqqdpeEp ZLe9ivqRVUOCUclKfiG2d0/vdgYwU2xnkWYSz0KUNP5pVE+4nZY3O/SA+SQcefkg KwfFhyM0XXm8eTVLVl5h+1dMMQ8tWkXpEwXqed4l0/478wepY8srMWoH3YRBxpiE q/PSkaWrRegUA8nYHp65kLVAAgP2kOeylAO/DmmtGye12AGMlNESNJHYuHPyc/wT Aos56muFTYYGhkICx+eqTsJBCr8mk32rFyIj/dinUcXUyvbj+sUt9eTZVAazsjjx NLC3zr3OSnKjQz2+kkXeGIHqTBCEWXFw3VHsPQLv7pf6XPqxJVoWtgHvzvTVduzo 3Oxff1eYaBN54Evn1xLWLdEGhqc7wqH6RFYDnKhbOxWmBujXHpdF8Ge5xNfPauBP gFAtgtHJIyyu/j+CCCo1z25ToKsGTuiJnbXalIrlmWNeIq8m7XKZ3JjhR3WYZOJU MEOXDkeVcodCfo0ZueGvTj5meY6eJ1LIBdWBmT0h1/xA/fBocbRADBFgez42NN5s ro5soi7B49KRuSygUPsaSMnjpr32NwCIrQIzGtZQzgJVfRPSdke9ZD1wNle9jAXY B7ZbDZmlD1St8rxL+usyhRjZdUoKXjfG8d72ss37EHIhch+3CEQ= =oEE0 -----END PGP SIGNATURE----- --Sig_/EjrvI7yGo=jgR=BTk/_==YI--