Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4623276pxj; Wed, 12 May 2021 09:27:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwErai9qcO2HZ4aNolZuTZw0EG6Ql5dLJ59zMRpBOt+CNNn+71naFjWYqyAdA7bUYQv9FSa X-Received: by 2002:aa7:c787:: with SMTP id n7mr9028220eds.309.1620836854635; Wed, 12 May 2021 09:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836854; cv=none; d=google.com; s=arc-20160816; b=l9o/ZPvvLPOvjDcLY7mpFgNp8pmTbKW1jEsFH+TP0HK4hRLjqWXtOWq9k9M08NYA4l LvIuPHeLCvaPzLp4EczPkVZYyiVhQUgmpXZsfeSsdQqlud1M1MmOi6kbYvR7SC1MtBsi 3TupIvLpsWw9+gQey6u7CfwcPAH5PXcrrVLXpykH9E+D1bo7DznDPvkRfuM/IoPJJF6W Dv0dUs1fz0y4YS0kaZ9hnFs2HB6Bqsdxjqp8kwRzCeA1gFo65T6Wysl3a8iRIHVjtepe Fs9sIzmWnZ8qzukjPtgjkS+HyYteco1lLZGJM3/9/luHV56pkB8O7TSMNW+IDjIiA6Uy 5bxw== 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=j0i+P+rQKUbN3Y6SICjyGVfR8c1qgjMY8Go9tdCG+3g=; b=LkKCgLojjnflGApfdhoz8V5WR1QB9StFVVJIeS9p6dSb7NhOmIptOWp2apQ6cwvkWL RChbl2KOwoYWYXL+k3gxsYGH3vKrGF6rzyM9SLqy7Cm1iOgYZ0UfiT2g3fJyLjFn2UGQ liXZaZfGihG1Rc1wZyA+0RlvJ2k+6CDpDi6Fm8MGb/kdp1gA4mfdzuWG5RqMyVIWby1m WbzTuWc+Kxowp65eq42FYtC5Nd6vuwtrB9YDAMJqrJSTm1RVEdY3hLO84gwMjwd+Ozrg vzliINMp7tODHO8egZ+ZYxaZSOaFqhMVRQ9tPjLhuXqH8IYyAORIYSc+iLk+hOmm3OVg TM+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jMLHSPXQ; 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 r26si364399ejz.429.2021.05.12.09.26.59; Wed, 12 May 2021 09:27:34 -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=jMLHSPXQ; 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 S236885AbhELQXR (ORCPT + 99 others); Wed, 12 May 2021 12:23:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:56692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236119AbhELPhE (ORCPT ); Wed, 12 May 2021 11:37:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A1E6561C45; Wed, 12 May 2021 15:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832705; bh=RLXRX7p9QBkk0qs1xA+Qk3UvYSFo6PoIGCtRjJsDlI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jMLHSPXQQmCFrzjeekOIcsLc07pd2KJSDn+9SIfupVCnBwdu285liIfUNqFPdEvr/ XOktMb9zOjHbcmwcVRYUNJx/IHixW2yjxbXrGPIOWj9KDyZBcp2MIbRCgHjQNys3yC Wry9Ld08Ozl6sxuZOXyj96pUM5dfUbji0UUctTEU= 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.10 389/530] iommu: Fix a boundary issue to avoid performance drop Date: Wed, 12 May 2021 16:48:19 +0200 Message-Id: <20210512144832.561371977@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 f11f5072af5d..e90c267e7f3e 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -544,7 +544,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