Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp425349pxa; Tue, 4 Aug 2020 08:45:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBSeGtxqat/5/FKuyKD6MVfLaW/RSB/XD/BUg8J3ZMiwf0tXLV1eep2QfuCERrOk0TrVHN X-Received: by 2002:aa7:cb45:: with SMTP id w5mr15437242edt.77.1596555951197; Tue, 04 Aug 2020 08:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596555951; cv=none; d=google.com; s=arc-20160816; b=K2Nz7KPuncu2Hw801OCq8O+Xgj075hUV0t+UDLvmRDds3heIKu6M5Adrjet0Umiszv IVdJXf8nvn7M1Xhhf/EJ4i3U+ArBMQmShQ/0SB1WBaTC0+kQl0MotB5AVjzY0/kDvl42 9WvcPid26qNpm1V+EX8evEMti9MV8KXYs7mmDQyHF+DD7k66vKGtnBooG6E+nM1RdiN5 BKkPA+nNVj+GeQfZBUNdxV1RceZZzAIrv5+CW5tIAd0siqxUeTqMKdES/0S824BjaKVW Us0mtAxpiLVusGmeQtB9P7munzgK3N+tENg/jDNAh3cncQBgsYUc5okCD9fdQrmfl2EQ 9LXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=H4JQaTkH18iHZhr5mRcUoCQ7w0Oz4NhHM6QKGzTo1bo=; b=DZz3HrbgoUxUvbafBDvTnCH1iR0MmViNq5mYKbpmScY/SGCvgRwPqVKo5QgxDZqpi1 Xh0UB+9IYjmfFLWY7o2ck1SaoUxoZjXFsQs0l+BiwJ3PEdDN3JYbh2aHBSQgmqGumhd9 f0sYN29Zr8cXpH5ielh482AO8kATUU5BuTMqUCuJxuLZh18q6R5aKmZle5DhlWZP0p0L Y2UgZbVRq6THQAD/0QrCws9EvPHMHrzJDeqWSFcgchXNR3l6Bxi7i8nklQQTMbDUaLpR g44IpSOkG/MoMHlO8/7+tC/4JNOJCae1LlFD04OMAc5KbmI4RumFmZFD1fdKdpGsuYDr +apA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ldFkcUFp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs25si12739371edb.174.2020.08.04.08.45.28; Tue, 04 Aug 2020 08:45:51 -0700 (PDT) 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=@google.com header.s=20161025 header.b=ldFkcUFp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725932AbgHDPo5 (ORCPT + 99 others); Tue, 4 Aug 2020 11:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbgHDPo4 (ORCPT ); Tue, 4 Aug 2020 11:44:56 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F273BC06174A for ; Tue, 4 Aug 2020 08:44:55 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id q13so14287343vsn.9 for ; Tue, 04 Aug 2020 08:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=H4JQaTkH18iHZhr5mRcUoCQ7w0Oz4NhHM6QKGzTo1bo=; b=ldFkcUFp7ri+IazwVWH1DnJFGu4x0mPAE5c8LizFVx2rdt1FE7sAuwon3cwzJKF5LL ZNJqk1Re7Ztm4LTRTSxLIblqxv1Tdv3kmXSjg7auDZuvC8yZ0w69Nn/DGRo8tp0Eil14 jFciSc7TK05orgQRJRd7XKd6eTpBBIMNXzVXQ2Jed9/2SZYXTu2h73RR/N6qsNl/Pca7 9+8tv7nrB+KevcGtu4bJtd0lxUtz9q8jECfBtEGtUXeOl6f4BACUpXlr/k4Faqg/qrCp Hx6izzJsxcomSTRM+gxPrYoa/pz+vZQZOFj3Rncam1GLYEBX+eB0thlPgKUiM/AR0tKS NIzQ== 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:references :mime-version:content-disposition:in-reply-to; bh=H4JQaTkH18iHZhr5mRcUoCQ7w0Oz4NhHM6QKGzTo1bo=; b=jIcg+M1O1xOXNPavtUNyhAeV4sqrsJTSTouxu/pf4+1JVMBi9/KjCwKFBRHAL0PMnD 52NmJ+PnXZl3Mt1c+/TR6tkuQCJ1TQ9+vgPfUOl5d7tYt91ICsjZhkli1+Ip8jwQS/3P mVghagyNtyztVEaPGYx1L8b80upochSFEOY0A6Im01sjxfEBI+u42RH74isBYHyOgu4S jR2ub917W0N4TEk8OocQ8MO9Ii8kECSSiPTy9nU6u5Th1yaQml9BBMnJbzUTrka+cQQ9 8HSwkcebvVxn0OPRFW0c+D4UL5OBHsZilo+rSmS/QdC4q85ZP1w5bFxPUWPdXIgwOhNu 913w== X-Gm-Message-State: AOAM532Y3poB3eUaWopSRSFmH3EQfkQu9gsOKJLG8ss0TyIraH6vUWqH FCCrmMmjFDac74fZ7i3zU1NxVA== X-Received: by 2002:a67:ef81:: with SMTP id r1mr8018212vsp.37.1596555894889; Tue, 04 Aug 2020 08:44:54 -0700 (PDT) Received: from google.com (182.71.196.35.bc.googleusercontent.com. [35.196.71.182]) by smtp.gmail.com with ESMTPSA id b138sm3212924vka.48.2020.08.04.08.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2020 08:44:54 -0700 (PDT) Date: Tue, 4 Aug 2020 15:44:51 +0000 From: Kalesh Singh To: Al Viro Cc: Suren Baghdasaryan , Matthew Wilcox , Jonathan Corbet , Sumit Semwal , Steven Rostedt , Ingo Molnar , linux-doc@vger.kernel.org, LKML , linux-media@vger.kernel.org, DRI mailing list , linaro-mm-sig@lists.linaro.org, linux-fsdevel@vger.kernel.org, Hridya Valsaraju , Ioannis Ilkos , John Stultz , kernel-team Subject: Re: [PATCH 2/2] dmabuf/tracing: Add dma-buf trace events Message-ID: <20200804154451.GA948167@google.com> References: <20200803144719.3184138-1-kaleshsingh@google.com> <20200803144719.3184138-3-kaleshsingh@google.com> <20200803154125.GA23808@casper.infradead.org> <20200803161230.GB23808@casper.infradead.org> <20200803222831.GI1236603@ZenIV.linux.org.uk> <20200804010913.GA2096725@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200804010913.GA2096725@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 04, 2020 at 02:09:13AM +0100, Al Viro wrote: > On Mon, Aug 03, 2020 at 11:28:31PM +0100, Al Viro wrote: > > > IOW, what the hell is that horror for? You do realize, for example, that there's > > such thing as dup(), right? And dup2() as well. And while we are at it, how > > do you keep track of removals, considering the fact that you can stick a file > > reference into SCM_RIGHTS datagram sent to yourself, close descriptors and an hour > > later pick that datagram, suddenly getting descriptor back? > > > > Besides, "I have no descriptors left" != "I can't be currently sitting in the middle > > of syscall on that sucker"; close() does *NOT* terminate ongoing operations. > > > > You are looking at the drastically wrong abstraction level. Please, describe what > > it is that you are trying to achieve. Hi Al. Thank you for the comments. Ultimately what we need is to identify processes that hold a file reference to the dma-buf. Unfortunately we can't use only explicit dma_buf_get/dma_buf_put to track them because when an FD is being shared between processes the file references are taken implicitly. For example, on the sender side: unix_dgram_sendmsg -> send_scm -> __send_scm -> scm_fp_copy -> fget_raw and on the receiver side: unix_dgram_recvmsg -> scm_recv -> scm_detach_fds -> __scm_install_fd -> get_file I understand now that fd_install is not an appropriate abstraction level to track these. Is there a more appropriate alternative where we could use to track these implicit file references? > _IF_ it's "who keeps a particularly long-lived sucker pinned", I would suggest > fuser(1) run when you detect that kind of long-lived dmabuf. With events generated > by their constructors and destructors, and detection of longevity done based on > that. > > But that's only a semi-blind guess at the things you are trying to achieve; please, > describe what it really is.