Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4745652pxj; Wed, 12 May 2021 12:14:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaPWlAegJgz/mXEkwb3wB5HXljH6OJ1PDqjFgdBm2HN/+D/WTt8qTkDx1RrjyFpEqdAGzq X-Received: by 2002:a17:906:c788:: with SMTP id cw8mr38805305ejb.190.1620846791938; Wed, 12 May 2021 12:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620846791; cv=none; d=google.com; s=arc-20160816; b=WZxauzPY1XGUjoNpeUUJWd6cohD7hapxx1NmLSfv3o5pZOXr3LhJNlOK+e4LMCvTBQ aLsx3mvbvVndTACyN8mi+tBeG+ZGU5XT37l79y8AN8ra0M/JzAXEm2BB88aPIRTeyD3V CmA8jjRgeYXwcoPIcgCvCsmT/tGWeZRnOG5t5tFSEhGHOphVmRaizA6rAF/UqGdEvdcc A2SUiEjKgIjsxlzF6qav3FDG8zxADv+wCSxZGlvY9CrCUElPpUIeq+gw3+iNszs3gkoB maxJEAXt0DF0pq6pYa103mQeAIRzO1GnKlsc1SGAAkRu6/J7u01FqC/4z1Ooo+oBM9CC tfHQ== 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=+8bdZyKwiT9dlkcaadkElYAB2rDVAAvdFO2BJ9w57X8=; b=vgTvj+gLBVcb9/GUNaQeBvgEL1ZTOf480NCHJNAd1KXHtTa4Rvv4usbshWhYYeUQcM dU2sx0SrRU19+ay/1FgvhSm7xzW9ow7et5Y2mHUn5HhvZxAA3adxkVm0ydiHJIlkLE3K Wz5D7fozFMAXYRIi4EfyPsA3627SUWAYA0SQ9f0CG+a6guvBg109g+HKcvrNcVMFP/yd a+Zk0V6TonZ3tjlbZNyAVDyT9wimhUpUKjssQ7gTeZmfHv33TGRcdLMPHGrygpd0GxlI s5MgRVkcubor0+9h6pqvtEFnJ6n8xOXdL6o3+4qE0SZKyD+2fDMiQ7U/XHaROQc0Ior0 Nkww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ppyffZ/S"; 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 v17si433518edq.94.2021.05.12.12.12.46; Wed, 12 May 2021 12:13: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="ppyffZ/S"; 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 S1376944AbhELS4F (ORCPT + 99 others); Wed, 12 May 2021 14:56:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:33526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244196AbhELQmm (ORCPT ); Wed, 12 May 2021 12:42:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 09CF561972; Wed, 12 May 2021 16:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620835895; bh=Kuj5VLvVSmkQihuj0Au0kkvyOA9Jauuyb4vJ/n3J6TE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ppyffZ/S2HH5l63CvFl1GgLipLd8eJgjYTarotXrdkSFEKO8VjjTeZqvVSb5IgpMv +MC9Whm80lIGWIO0rO/wK3KOMthZ2G4BPAyv9zXceeHW++2R0WKs8YFzh3kkRHW+ZR TjZMt3V/MRWen2EHVewYqw60v2HjQ88B2mGlV0rQ= 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.12 492/677] iommu: Fix a boundary issue to avoid performance drop Date: Wed, 12 May 2021 16:48:58 +0200 Message-Id: <20210512144853.731535713@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@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 5e7fe519430a..9ca6e6b8084d 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -547,7 +547,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