Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2864989pxb; Tue, 19 Jan 2021 07:57:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJws/T/3swwfqV/JsvSfso4pRD/J77+gerGOZbUTNaT3EwrrasJcU0snlNzZnoj9iJWACBtz X-Received: by 2002:a05:6402:160f:: with SMTP id f15mr3936837edv.348.1611071852821; Tue, 19 Jan 2021 07:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611071852; cv=none; d=google.com; s=arc-20160816; b=gbBpA+NaIHkLD/TQKsetJp+EZojQhb2qVdoapDsLk4kBrP4d5FDk2XNyWzaGOb04wr x4yx4K7daQ/6w+gys7N1M67yay1WZTmfWmLPHuBfdL2c9Rdf7cnJ6xY0hwT3e2FwUUzl xMh9b4VFtj2/iiGQKB2NInk6YOIWrOWN5vwvXDj8Qh0eisZ+8mMqUNysW5kMgkl+pbMu HUmJDdXNppCX3wTnsJ3qmpQ0+tCg+LrpI7ubPlu32yWAVg3pckrBj0GvSsiBe1JKWgSo PsMvu4GnccKfKIdMch4w06m+Vj1nIH2QkL2yRd/3u/YSkwHinixFvmiKF7WjtW99ejE7 lg9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=kCO6Ja/9T0ZWzLSTAYsi1B+AmhSomL/4dxV35Lz8Guk=; b=XptnzLTv1ahq11D7oGtxktZOZkjpSAn/uCN/zcaoxW8d2XWoyJZsE06/ED+PdnThYN 0tcMTKCjQ6kYcp3d4FESHgcNqfnT6txiADrHV0qoyHDICbt1B8gMrM4SoYpCnHuDh6Vd TsHqGHTDAtDqLHyJu/PgWSqWV4lNq6JfBNFMBzs0d6mFgvS4F9LN9GPuHE4NkZswd32h CGmUhhicH69vTmCyaxDWLe8/VVPQA8T2uG+CaBd9nRnnPoTjbUq08ws9+O9H2EVIkhZP BXYny7Q/lpAEvRpsEw3bSTIjTWO1l8AaOkTlQQ6ClCzvnDufmnBXpbhB443Y132VUlec jV1A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do4si6769914ejc.295.2021.01.19.07.57.09; Tue, 19 Jan 2021 07:57:32 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391629AbhASPzZ (ORCPT + 99 others); Tue, 19 Jan 2021 10:55:25 -0500 Received: from foss.arm.com ([217.140.110.172]:37278 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728824AbhASPxb (ORCPT ); Tue, 19 Jan 2021 10:53:31 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 79CDDD6E; Tue, 19 Jan 2021 07:52:43 -0800 (PST) Received: from [10.57.39.58] (unknown [10.57.39.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7CA143F66E; Tue, 19 Jan 2021 07:52:42 -0800 (PST) Subject: Re: [PATCH 1/2 v2] dma-iommu: use static-key to minimize the impact in the fast-path To: Christoph Hellwig , Lianbo Jiang Cc: linux-kernel@vger.kernel.org, thomas.lendacky@amd.com, will@kernel.org, iommu@lists.linux-foundation.org References: <20210119111616.12761-1-lijiang@redhat.com> <20210119111616.12761-2-lijiang@redhat.com> <20210119152641.GA3453587@infradead.org> From: Robin Murphy Message-ID: Date: Tue, 19 Jan 2021 15:52:41 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210119152641.GA3453587@infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-01-19 15:26, Christoph Hellwig wrote: > On Tue, Jan 19, 2021 at 07:16:15PM +0800, Lianbo Jiang wrote: >> +static DEFINE_STATIC_KEY_FALSE(__deferred_attach); > > Why the strange underscores? Wouldn't iommu_deferred_attach_enabled > be a better name? > >> - if (unlikely(iommu_dma_deferred_attach(dev, domain))) >> + if (static_branch_unlikely(&__deferred_attach) && >> + iommu_dma_deferred_attach(dev, domain)) > > Also insted of duplicating this logic in three places, maybe rename > iommu_dma_deferred_attach to __iommu_dma_deferred_attach and create > a small inline wrapper for it? Once patch #2 is in place, I really don't see any point. The "helper" would add a minimum of 5 lines to save at most 3, and would have to be annotated as always_inline - which a whole other camp of people would probably object to - in order for the static branch to be properly useful. It's not as if this is a complex or hard-to-read expression, so IMO having 3 lines repeated 3 times is objectively better than having 2 lines necessarily repeated 3 times plus having to scroll up and find several more lines to follow what it's doing. Robin.