Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4681028pxj; Wed, 12 May 2021 10:45:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywhu++SQeBWqZaUKO+vMGzmZPHn8QdIuYIwhZm8S/0oThlvj2r9B9WUGYhjcBa0iCoUASi X-Received: by 2002:a05:6402:849:: with SMTP id b9mr30782374edz.126.1620841391616; Wed, 12 May 2021 10:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620841391; cv=none; d=google.com; s=arc-20160816; b=GMhf7WOknjlYp6S2ady/kelffS4tgnMT/3Pdnb7hgkQjnTSlvBLt8hQRYSU4CHGeB+ 7L5gH2y0tIbjPBljT34Je4jcxoqzmc52G5tHYHK2Bvr2gYtbcUMuLo2QBbD8iTPOiAKw Sopmuq8O9UT5CmOhFcSC9QaFll1raWSX0gO33oO12d0azN/sxzI+5V/1XF9nvCvLrB1X YlvORNhigmYEmyim2pB54LPmaMbzKL/dPyRgRWT7MFbVKvh1e5srzPrrULccf3CpsI69 u0RiKhhICG+BMlWgQYe9Q7IjKlXOSn62K2ZaRuJVNyJic8T1N/OZlxMwmfK9QMFnMrvf cwrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AQOuq3blKaylQZODOkHIkCErqP7yQjwe6xTdZ2lH/FQ=; b=0BM6U7utWSzETmHV+7PxH5Icg847LSzbntgoAdHvHNp9A3BOcl26aMjjony2AYfJyT 2E2niaBkFfWanNqIWby7iHNX10Rr0OxRjFV0LuR7mG2GfO1CM0QmEDhROsf+HMRNXu0V St6A0hXG7xHZDO8xGsjuo/FeQxMXievb5kfps2biNdsU0Lk/t15fvGuTnntQVIlYtAzl SEF50IwOXbzZReEu9HOQTLiI0kWNfMgf6Ni+DO0oILyEjK50JMt6BQSsB4A6umc3nQR4 Dy5fzNS6g9Gax00I3hqWtpnRTC1EkDHkFMptQdPWe7GRz5XJYh5ZGsdjhXayHC6K6/Sn 7MYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aCWjpBgF; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si577116ejz.231.2021.05.12.10.42.44; Wed, 12 May 2021 10:43:11 -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=@linuxfoundation.org header.s=korg header.b=aCWjpBgF; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349545AbhELRm2 (ORCPT + 99 others); Wed, 12 May 2021 13:42:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239927AbhELQQd (ORCPT ); Wed, 12 May 2021 12:16:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 29EB661D63; Wed, 12 May 2021 15:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620834175; bh=KBawGH7cOPdiNXLwMIdd2SmB5YDFAtaR1s+kD1CEdtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aCWjpBgFOns5nm0p0Xt23eR1s8UeMh43+/zfhxKl7AC/y4M7pmib2ovqFFK4UiVHX uhiOzzMeUWxxzSp7sTMWh/UhfGPxZUYCL/SXl05XRNGRpdXldfUfDgF+nyjMM5G/DZ 0vP/ZHxXuVkI253SbW7fvKgcyBKPxr0It/f7slQ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiang Chen , Will Deacon , Joerg Roedel , Sasha Levin Subject: [PATCH 5.11 437/601] iommu: Fix a boundary issue to avoid performance drop Date: Wed, 12 May 2021 16:48:34 +0200 Message-Id: <20210512144842.229299788@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen [ Upstream commit 3431c3f660a39f6ced954548a59dba6541ce3eb1 ] After the change of patch ("iommu: Switch gather->end to the inclusive end"), the performace drops from 1600+K IOPS to 1200K in our kunpeng ARM64 platform. We find that the range [start1, end1) actually is joint from the range [end1, end2), but it is considered as disjoint after the change, so it needs more times of TLB sync, and spends more time on it. So fix the boundary issue to avoid performance drop. Fixes: 862c3715de8f ("iommu: Switch gather->end to the inclusive end") Signed-off-by: Xiang Chen Acked-by: Will Deacon Link: https://lore.kernel.org/r/1616643504-120688-1-git-send-email-chenxiang66@hisilicon.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- include/linux/iommu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index d63d3e9cc7b6..3e82f0dce3cc 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -546,7 +546,7 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain, * structure can be rewritten. */ if (gather->pgsize != size || - end < gather->start || start > gather->end) { + end + 1 < gather->start || start > gather->end + 1) { if (gather->pgsize) iommu_iotlb_sync(domain, gather); gather->pgsize = size; -- 2.30.2