From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D916C5519F for ; Wed, 25 Nov 2020 09:28:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD4D8206F9 for ; Wed, 25 Nov 2020 09:28:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="J2TU+ZzT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD4D8206F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 37C496B0070; Wed, 25 Nov 2020 04:28:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 32AFA6B0071; Wed, 25 Nov 2020 04:28:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 241D56B0072; Wed, 25 Nov 2020 04:28:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id 0F5E66B0070 for ; Wed, 25 Nov 2020 04:28:11 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CE007180AD815 for ; Wed, 25 Nov 2020 09:28:10 +0000 (UTC) X-FDA: 77522414340.11.able45_520237327375 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id A4BA7180F8B81 for ; Wed, 25 Nov 2020 09:28:10 +0000 (UTC) X-HE-Tag: able45_520237327375 X-Filterd-Recvd-Size: 5591 Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Nov 2020 09:28:10 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id a15so1815123edy.1 for ; Wed, 25 Nov 2020 01:28:10 -0800 (PST) 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=V6jfPwZkNeh5oW/xhyxIAPCS+jYbX5BnmAGa7tqS/UM=; b=J2TU+ZzTtpXOeRpQEU95Ot5rlO5r6/XqvYl5hbbxifRwxuudgrBEX+kHKxWKrh0yR+ d57ZC0VghJ3JrkXqCZ5vuegixijbxUTkoHcoDeEg11SJPHlRp+2GvFW63hpArzENjq4U OlF4db7JcfP3J6yAqr1EhhDw3oaiUx2sAcSA0NzoqPQAALKchRAM7bJGV1FEyU/u8Zew 714LCXKYumJNKQVlpjCTYX+Z7UJsT797AMbwG/YZfFX4eQ60bh81Lj92i3gDvaNhbTY/ 5f3jFSNHbCDkr9eiCZyarUEoxZFkkIlKVBkr3onMOxe0WoWtw4M6SyzvBKX/R+450e6r RKQQ== 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=V6jfPwZkNeh5oW/xhyxIAPCS+jYbX5BnmAGa7tqS/UM=; b=aVFolQBRxIa3RsawwDlyLc+1H4tMHM/xbrwAS2fw3z+0lj97ta3zlZE7URtcDguMdq tSTeueROcbpF/L8iALiZd4Hvl7uKiDVJraoDLJY5++te/oEQO2si23WWbBHfP0j3fJj6 eezC12gvN8P5viCbGMRhBb3HvEfnnSuS0Mi8/RUI3Lvm2rbAf/lbQx+UF+ac7ngSpvv1 viGirF6eecSSkB5v+5UDnfIMOpV3/L2hCHIYShYMk4N5bN4ewQE01nMMOXnKjA2N7ifK sZhX0wKcTu1iBsa6MsF/BI0YO0zuXlrnGI6l5WugRdSfuuxpNhhyJHc62I0TTLlfe6uX SVyQ== X-Gm-Message-State: AOAM5321LpkT8Sjvd1zaeabd1iOtXVw0eS1XYi9FZfqxEwLXXu23ewFe tI7m1vipf6JMQLaI+yunC2dfKQ== X-Google-Smtp-Source: ABdhPJzvewHbh7Ug/phOO580pv1zq0+bZCsdfkc81eifmIcHg0fFb/d7vHs0RNWy2PR74Xir911t3A== X-Received: by 2002:aa7:c716:: with SMTP id i22mr2632276edq.94.1606296489038; Wed, 25 Nov 2020 01:28:09 -0800 (PST) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id p14sm867798edq.6.2020.11.25.01.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 01:28:08 -0800 (PST) Date: Wed, 25 Nov 2020 10:27:49 +0100 From: Jean-Philippe Brucker To: Jason Gunthorpe Cc: iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, joro@8bytes.org, catalin.marinas@arm.com, will@kernel.org, robin.murphy@arm.com, baolu.lu@linux.intel.com, Jonathan.Cameron@huawei.com, jacob.jun.pan@linux.intel.com, zhangfei.gao@linaro.org, xuzaibo@huawei.com, fenghua.yu@intel.com, eric.auger@redhat.com Subject: Re: [PATCH v10 12/13] iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind() Message-ID: <20201125092749.GA2445658@myrica> References: <20200918101852.582559-1-jean-philippe@linaro.org> <20200918101852.582559-13-jean-philippe@linaro.org> <20201124235800.GA242277@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201124235800.GA242277@nvidia.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Nov 24, 2020 at 07:58:00PM -0400, Jason Gunthorpe wrote: > On Fri, Sep 18, 2020 at 12:18:52PM +0200, Jean-Philippe Brucker wrote: > > > +/* Allocate or get existing MMU notifier for this {domain, mm} pair */ > > +static struct arm_smmu_mmu_notifier * > > +arm_smmu_mmu_notifier_get(struct arm_smmu_domain *smmu_domain, > > + struct mm_struct *mm) > > +{ > > + int ret; > > + struct arm_smmu_ctx_desc *cd; > > + struct arm_smmu_mmu_notifier *smmu_mn; > > + > > + list_for_each_entry(smmu_mn, &smmu_domain->mmu_notifiers, list) { > > + if (smmu_mn->mn.mm == mm) { > > + refcount_inc(&smmu_mn->refs); > > + return smmu_mn; > > + } > > + } > > + > > + cd = arm_smmu_alloc_shared_cd(mm); > > + if (IS_ERR(cd)) > > + return ERR_CAST(cd); > > + > > + smmu_mn = kzalloc(sizeof(*smmu_mn), GFP_KERNEL); > > + if (!smmu_mn) { > > + ret = -ENOMEM; > > + goto err_free_cd; > > + } > > + > > + refcount_set(&smmu_mn->refs, 1); > > + smmu_mn->cd = cd; > > + smmu_mn->domain = smmu_domain; > > + smmu_mn->mn.ops = &arm_smmu_mmu_notifier_ops; > > + > > + ret = mmu_notifier_register(&smmu_mn->mn, mm); > > + if (ret) { > > + kfree(smmu_mn); > > + goto err_free_cd; > > + } > > I suppose this hasn't been applied yet, but someone asked me to look > at this series.. It's queued for v5.11, but I could submit improvements for 5.12 > Why did you drop the change to mmu_notifier_get here? Dropped at v6 when I got rid of the io_mm cruft: https://lore.kernel.org/linux-iommu/20200430143424.2787566-1-jean-philippe@linaro.org/ > I'm strongly > trying to discourage static lists matching mm's like smmu_mn is > doing. This is handled by the core code, don't open code it.. We discussed this at v6, which wonkily stored the mn ops in the domain to obtain a unique notifier per {mm, domain}. A clean solution requires changing mm_notifier_get() to use an opaque token. Rather than testing {mm, ops} uniqueness it would compare {mm, ops, token}. I figured it wasn't worth the effort for a single driver, especially since the SMMU driver would still have one list matching because it needs to deal with both {mm, domain} and {mm, device} uniqueness. https://lore.kernel.org/linux-iommu/20200501121552.GA6012@infradead.org/ Thanks, Jean