Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp583043pxb; Mon, 25 Apr 2022 17:15:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0F6J1q6rG1Nm43ATGIVRvYY5JIbAPdO+5Qd33C05gJB9l0pfdW/2TAs1wwInT3wr0ziNt X-Received: by 2002:a05:6a00:16c7:b0:4f7:e497:69b8 with SMTP id l7-20020a056a0016c700b004f7e49769b8mr21477007pfc.6.1650932151071; Mon, 25 Apr 2022 17:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650932151; cv=none; d=google.com; s=arc-20160816; b=RQfYwDQXpuYrG7auMAxhw+ZChDLwtXpHt6Ap0NPPnQevfuxKmgZZ1HLNwkpMK08R6D BTMK08XfTu8ctdCbvRw4/hZdFkd9YH5hz65hNpVO6eG2a8UBGZdm6x+ofctBr7lHVdQ+ 6Y/WGN0PdBIOjXcHmQ7kwAaIl/stbHV6NveqiVlbZX6rR490k50sn+YMyGEsbRmA+Wfk pI/Z7fvvZBhkZx8Y2q46OlDEEiEjD6sf12+iJMc73AzoiF+ZpHF5k7OR1IuFDqLDXf0x WUJMQFNq2spblJ2AOKAdjWcg0nPFDO6k5R2VN02uKFvW4DHdwYpZsQ5ngNOTD4jPZTib LPSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Ju3MNG0l6PZT3NlPuxMjxhTveM28nyA7MnYp02HrA3g=; b=LJvYkHoIzIiIszspElZcYAAiapWcTvmC8k4i2m2UqP81cnWzvms9ONmRSolbTSyXEY 3oq6uVrh4gR2h2HmZzQgPguAcmn6oaxxWrA9Vgztga0JQeHnGtk4yNeYFbpQrkqnaKls pkOrC2Idv0rgrVvUBczsLohoeKD+G4pAeKGvJVJ7kivobKcFRPSc3sgBgUvmVuNRP9A1 MRhcCnOlIZEkjN/+cXu4+mXZ6SpXtCrBaqFgZBMpnagBh8ntr8xV8lLNbN0Bb1cu8OrV qjnxnm8Ua34k1DfmRzyCHIOu0JrKQt26ymR843WBaf6cudY+lUpLp5aoPR3JP/5EhIUP xiNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c2XdBLBO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a170902d4c300b0015874d582f1si2243741plg.326.2022.04.25.17.15.34; Mon, 25 Apr 2022 17:15:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c2XdBLBO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242266AbiDYN5R (ORCPT + 99 others); Mon, 25 Apr 2022 09:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237810AbiDYN5P (ORCPT ); Mon, 25 Apr 2022 09:57:15 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 242B96C956 for ; Mon, 25 Apr 2022 06:54:11 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id v12so14167722wrv.10 for ; Mon, 25 Apr 2022 06:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ju3MNG0l6PZT3NlPuxMjxhTveM28nyA7MnYp02HrA3g=; b=c2XdBLBOlfmLEWkJaYwfFywTyfskFCw6bpnjcfeqXhyBmEqmUQjwPOV4AyIggXagiD wzbWZxTpH9r3DOzhbxg/99dGPHgdmS7G6aaQOo6gNeyvelEh9kNT4uPxd9Z3fIJVbjDv 1fgHdpRRPrpYkpZZ/ehfVQYYOrTkk727CPzkR2PczdmVc0zgqan189Bu3CV6+ledwkUm 8gnLVa+acEhbE8q59GCjNiopmnkAZhjUwfsAw7wH8xszCr1FVSxY8y+/STArB0DN2OLL mD4bmmHVRXPEkOUcwIR5fe4iZhXszr8h0kAleiNz0H98aT9Qq55L3b+WKDDrRLitbGXy G1pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ju3MNG0l6PZT3NlPuxMjxhTveM28nyA7MnYp02HrA3g=; b=0/yMGqSJlEx83lfjsGdd2zqhAFE3BScfWvRUSHRYf5wQFW/Jf5AqjhkHd4IFVim0b3 Z6B04KC51LAjM7yXnzj8BtO7Ey48PSBuXTluWDZwyJTDJaYbBzSPn9flvSNKotMDxnYi 1Gxf4447ApWNYdMEUkXdaSGugyhLJt6GNTEVSBEaNDkgy6RwDo9U2nGRI/lR2s97Gfcg ijIJh3Ndp6WCbOM9AyJ2CuAsxhydZ8oBAt1R1BwhSKETHIKU1SMAgnBqnt3UUEk3aUS8 mWkbwRly+WPnRZDQqbHMhyowMLndXy79S4RNHGogUMXdPcer8BL4hHW+h2pbOf5GALkX S3sg== X-Gm-Message-State: AOAM531kKmChyKmFIzFyaSrvnh5OzsyHnL0UQp3zm8kOGNtpSxMA2rgb QimjptvEkoFT80rfjW6uzgCB7w== X-Received: by 2002:a05:6000:49:b0:20a:da03:951f with SMTP id k9-20020a056000004900b0020ada03951fmr4757075wrx.519.1650894849681; Mon, 25 Apr 2022 06:54:09 -0700 (PDT) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id q15-20020adfaa4f000000b0020ac7bd4affsm11029272wrd.0.2022.04.25.06.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 06:54:08 -0700 (PDT) Date: Mon, 25 Apr 2022 14:53:42 +0100 From: Jean-Philippe Brucker To: "zhangfei.gao@foxmail.com" Cc: Fenghua Yu , Dave Hansen , Joerg Roedel , Ravi V Shankar , Tony Luck , Ashok Raj , Peter Zijlstra , Dave Hansen , x86 , linux-kernel , iommu , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Josh Poimboeuf , Thomas Gleixner , will@kernel.org, robin.murphy@arm.com, zhangfei.gao@linaro.org Subject: Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 23, 2022 at 07:13:39PM +0800, zhangfei.gao@foxmail.com wrote: > > > On 5.17 > > > fops_release is called automatically, as well as iommu_sva_unbind_device. > > > On 5.18-rc1. > > > fops_release is not called, have to manually call close(fd) > > Right that's weird > Looks it is caused by the fix patch, via mmget, which may add refcount of > fd. Yes indirectly I think: when the process mmaps the queue, mmap_region() takes a reference to the uacce fd. That reference is released either by explicit close() or munmap(), or by exit_mmap() (which is triggered by mmput()). Since there is an mm->fd dependency, we cannot add a fd->mm dependency, so no mmget()/mmput() in bind()/unbind(). I guess we should go back to refcounted PASIDs instead, to avoid freeing them until unbind(). Thanks, Jean