Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4676754rwb; Wed, 17 Aug 2022 04:24:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR5IzNG/EkJx7yQk9PUfSyzA9z+sBkX21jd53pu4ryswhipqN2RUdD1ibrDgBkLmi6QCHd7F X-Received: by 2002:a05:6a00:27a0:b0:52f:8766:82ec with SMTP id bd32-20020a056a0027a000b0052f876682ecmr25322979pfb.17.1660735478879; Wed, 17 Aug 2022 04:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660735478; cv=none; d=google.com; s=arc-20160816; b=mtaKKtnybPaPy0kQyVvM+HJ92RJ/6IhHvYnzyQWQqiCol0Y+BQm80e0/i5W0mY6e5F lfjW8ZAT5N81259rWx00FWKLbdnpF2Ajltff3/2bEL1B0eQOCuzEx5tdR4ahFveCVu6H M2x5RFHSod6wnU6JTyfxO35xfncvZAGW8XdNkj7s4GXMcxaoCOFpwqUExUPD0Kt88yZb ElWccEaadhfRimc2tGp5OCD9u9KeOudXsj9mo/oPoqcBrlRo0lXxByzBqkGtlqFtUfIz paiqCjjsuMpkhUaXw9cxmdWFd4CdFbvhNOGaYRqhGVQdyjTqKFdk2AqUIqhO/nTR4Brd WKOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=u1hSG/Tu9HO/XEOiVhOq2/r27knxo6FUP0Uq+goiDSs=; b=MJ6Dd8aWaAGOtQ6Ry5eXBTqJ1N5r/bjGo24MiQV0VuwFaC+gA8kCsFzsfhmrpZXQz2 TbTuP9JxrvritVZHKC5y1Gkagj24xVYmxGVrWrWQsJtQjXIFHyZL5EqcY9J1YalvwPXm fq/+PJCH9fvhSaICycwXltQV5YCQS+OIpe7342xU2Px2el2dmWhl9Whwl9q/IJftyed3 2a2dHAWKXBDGWmg1k7fbOcnHUfEU+ay820+TtlHO8flSS5ohEGY8aPdD1s2x9Y8+eld/ AUITaxnrXaGg2gt6LBuCqXwK/1orT0LCsCLZhI3jbOdOV4cfnyW184Uyyw7vgXXlKSkl /ZtQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v65-20020a632f44000000b0041bd0985ea9si15858223pgv.671.2022.08.17.04.24.28; Wed, 17 Aug 2022 04:24:38 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236190AbiHQLMK (ORCPT + 99 others); Wed, 17 Aug 2022 07:12:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233689AbiHQLMJ (ORCPT ); Wed, 17 Aug 2022 07:12:09 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4E35676772 for ; Wed, 17 Aug 2022 04:12:08 -0700 (PDT) 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 D7CD6113E; Wed, 17 Aug 2022 04:12:08 -0700 (PDT) Received: from [10.57.13.141] (unknown [10.57.13.141]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 315443F67D; Wed, 17 Aug 2022 04:12:07 -0700 (PDT) Message-ID: <4f5e43ca-c02a-07bd-0c8e-1a90be49fec9@arm.com> Date: Wed, 17 Aug 2022 12:12:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH 2/3] iova: Remove magazine BUG_ON() checks Content-Language: en-GB To: John Garry , joro@8bytes.org, will@kernel.org Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <1660730984-30333-1-git-send-email-john.garry@huawei.com> <1660730984-30333-3-git-send-email-john.garry@huawei.com> From: Robin Murphy In-Reply-To: <1660730984-30333-3-git-send-email-john.garry@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 2022-08-17 11:09, John Garry wrote: > Two of the magazine helpers have BUG_ON() checks, as follows: > - iova_magazine_pop() - here we ensure that the mag is not empty. However we > already ensure that in the only caller, __iova_rcache_get(). > - iova_magazine_push() - here we ensure that the mag is not full. However > we already ensure that in the only caller, __iova_rcache_insert(). > > As described, the two bug checks are pointless so drop them. In some ways it's logical to have assertions to make sure that callers *are* already checking so as not to call incorrectly. However I'm inclined to agree that this particular case is very niche, with little chance of any new callers being added, so they're not offering much value, especially on performance-critical paths. Acked-by: Robin Murphy > Signed-off-by: John Garry > --- > drivers/iommu/iova.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c > index 580fdf669922..8aece052ce72 100644 > --- a/drivers/iommu/iova.c > +++ b/drivers/iommu/iova.c > @@ -694,8 +694,6 @@ static unsigned long iova_magazine_pop(struct iova_magazine *mag, > int i; > unsigned long pfn; > > - BUG_ON(iova_magazine_empty(mag)); > - > /* Only fall back to the rbtree if we have no suitable pfns at all */ > for (i = mag->size - 1; mag->pfns[i] > limit_pfn; i--) > if (i == 0) > @@ -710,8 +708,6 @@ static unsigned long iova_magazine_pop(struct iova_magazine *mag, > > static void iova_magazine_push(struct iova_magazine *mag, unsigned long pfn) > { > - BUG_ON(iova_magazine_full(mag)); > - > mag->pfns[mag->size++] = pfn; > } >