Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1168605ybt; Wed, 8 Jul 2020 23:53:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRM0WkEbGo3OESS1ba8e8+aK02Rz3xThR/zjtl4HfWswAIQ0P4PbD1eiqVN+L6102TklIo X-Received: by 2002:aa7:c6d3:: with SMTP id b19mr68149827eds.207.1594277630715; Wed, 08 Jul 2020 23:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594277630; cv=none; d=google.com; s=arc-20160816; b=q/VaDP9dJXn44wLpohcBo9sCQOjf78jkEOXQEyLrTSdSHRlHvIi+rjX/ShjX+CA3zU BKeKfOMGp9yLWb/rI6GS/vIYVl165SPUWBmjb3K2fkJqrIkt8fSpbLNslNXeYZdaGyI1 cuMIPB6jTaMpqA5nOmEZFcoJ7e9V5nnIxWXrR/GFq9e2y3qnE/2j0ka8qJrErPEbvipf x53cuBXflVc7CumxGdLEDcQj9EZ0XRdPjVRXNB34Nl3/ecZyAMEciBuJRu6Hpl6vif6F 51fws3W2MtXqPpCzkHWuzvosLZ0hvVCb6PJrMOJsgppzeTxvMIhXQ8gEp4uWiqQYCf6r U/+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=4PC7vGbWFfOJ7dcg1j6+ycMQXJs2djGsvPdgWG12S5s=; b=A4hTALZogOSF0c2EQGMlR0n8Z/bE30vjPOtJBdU1oa5wYi4EQwmjOd1uVmKcvRld71 XyGYi1yBKUGrxOBUJPGFYX9wvM8ubXsMnfkS88IHxJqb/K/AoJU7UULEdnCIu2TPMXoc dGIE6XbDb9Gj6J7E1y/6IQF6OdyTckMI2SdyeiWapZfAda6EmbwLGwQQYslLfJ+wN2fX l0RJWX+Dkb8ePb2Ppd3rWuky2apoG8eroH9QjyYvCDquVZg9CWpCf4hcu8LdYZi8yo91 ML6MwcQc/094+hZFwkHGi1GBn8vnCJuI0VueUL8ZzE0ovZaZcXv6cZykyELN6k9E1sHy P/OA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz22si1243756ejb.742.2020.07.08.23.53.27; Wed, 08 Jul 2020 23:53:50 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726220AbgGIGvT (ORCPT + 99 others); Thu, 9 Jul 2020 02:51:19 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7825 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726119AbgGIGvT (ORCPT ); Thu, 9 Jul 2020 02:51:19 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 1BB15177614AC0946EA4; Thu, 9 Jul 2020 14:51:16 +0800 (CST) Received: from [127.0.0.1] (10.174.186.75) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Thu, 9 Jul 2020 14:51:07 +0800 Subject: Re: [RFC PATCH v5 2/2] arm64: tlb: Use the TLBI RANGE feature in arm64 To: Catalin Marinas CC: , , , , , , , , , , , , , , References: <20200708124031.1414-1-yezhenyu2@huawei.com> <20200708124031.1414-3-yezhenyu2@huawei.com> <20200708182451.GF6308@gaia> From: Zhenyu Ye Message-ID: <27a4d364-d967-c644-83ed-805ba75f13f6@huawei.com> Date: Thu, 9 Jul 2020 14:51:05 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20200708182451.GF6308@gaia> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.186.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/7/9 2:24, Catalin Marinas wrote: > On Wed, Jul 08, 2020 at 08:40:31PM +0800, Zhenyu Ye wrote: >> Add __TLBI_VADDR_RANGE macro and rewrite __flush_tlb_range(). >> >> In this patch, we only use the TLBI RANGE feature if the stride == PAGE_SIZE, >> because when stride > PAGE_SIZE, usually only a small number of pages need >> to be flushed and classic tlbi intructions are more effective. > > Why are they more effective? I guess a range op would work on this as > well, say unmapping a large THP range. If we ignore this stride == > PAGE_SIZE, it could make the code easier to read. > OK, I will remove the stride == PAGE_SIZE here. >> We can also use 'end - start < threshold number' to decide which way >> to go, however, different hardware may have different thresholds, so >> I'm not sure if this is feasible. >> >> Signed-off-by: Zhenyu Ye >> --- >> arch/arm64/include/asm/tlbflush.h | 104 ++++++++++++++++++++++++++---- >> 1 file changed, 90 insertions(+), 14 deletions(-) > > Could you please rebase these patches on top of the arm64 for-next/tlbi > branch: > > git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/tlbi > OK, I will send a formal version patch of this series soon. >> >> - if ((end - start) >= (MAX_TLBI_OPS * stride)) { >> + if ((!cpus_have_const_cap(ARM64_HAS_TLBI_RANGE) && >> + (end - start) >= (MAX_TLBI_OPS * stride)) || >> + range_pages >= MAX_TLBI_RANGE_PAGES) { >> flush_tlb_mm(vma->vm_mm); >> return; >> } > > Is there any value in this range_pages check here? What's the value of > MAX_TLBI_RANGE_PAGES? If we have TLBI range ops, we make a decision here > but without including the stride. Further down we use the stride to skip > the TLBI range ops. > MAX_TLBI_RANGE_PAGES is defined as __TLBI_RANGE_PAGES(31, 3), which is decided by ARMv8.4 spec. The address range is determined by below formula: [BADDR, BADDR + (NUM + 1) * 2^(5*SCALE + 1) * PAGESIZE) Which has nothing to do with the stride. After removing the stride == PAGE_SIZE below, there will be more clear. >> } > > I think the algorithm is correct, though I need to work it out on a > piece of paper. > > The code could benefit from some comments (above the loop) on how the > range is built and the right scale found. > OK. Thanks, Zhenyu