Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1246020ybt; Thu, 9 Jul 2020 02:15:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3F5GQsxMOwj8MenNHTITGLbaAIs7f6Mk7fzjS8AiLTvpfDbbyVZPTQjwDlqYWvvwX7eQB X-Received: by 2002:a17:906:1491:: with SMTP id x17mr57090731ejc.416.1594286121385; Thu, 09 Jul 2020 02:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594286121; cv=none; d=google.com; s=arc-20160816; b=OiblF5f6V5zVcioSfmJ6kNOiVrBvj+SXYsTLT1fygDnZP1irxsRz6o2NVf9QyakzWg Jds6imGiQJUEUEqI4Gkz6G8Ta8xDTT67VLlDgWMguB8bh3Xi2yxp0Lc1SJiTfIQGKxBn UunzvCWKcYeqW7Qvxn6z5qgmF1C3WGL/a83T35kONPWVWgzjQA7fgPoke1Sc79oJzklC qnUJAElhUfZHb9FDa59diZo9aALFq6I2tr3EDRSzGtjPEHGXn70kpfJFoL6eMFsek7eq YpP4pAlDPSRhGm6UgkobIFpPLXj9gWQXm6euyyjZmILXm2IxlCqOeEksQsCK79uu43Mx fwuw== 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=4673yWuwlY5tAjrf39cxDP7TXCJMRMVY/+/hs40rwy0=; b=ia3AXvyoX3Jx4tsL6sGN8eQomF+FpgVZPrGFAf3TGBV/XR8ErnoGF6treD1h1uc653 hxMhdX6Wm3hXgcowfqNHlrsYu6WPxprsRoVCANBywlrrp89vH2y1LDxYhiut3jtLpRPw zyVXZb5o4thLHgUQ3yi3xgLEJjkA23XoufeyI3YN4OXqDfwi2Yfit2ck0tZi66jvuCEz DsHITZFAfkdhSBVcRHo98XLz0xyjwuAHgEtZqWXNRc+wJn1x5yKXivqsgmMvBSyB4U0g FOM1pH+fB7jZr/TOaFkQwiS5vpI3CTj7SrrgdCZL3gZIEr8pBsQOD7I2kv8abiMH8ssI 4uUA== 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 i2si1584466eds.437.2020.07.09.02.14.59; Thu, 09 Jul 2020 02:15:21 -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 S1726319AbgGIJOn (ORCPT + 99 others); Thu, 9 Jul 2020 05:14:43 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7827 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726122AbgGIJOn (ORCPT ); Thu, 9 Jul 2020 05:14:43 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 19FFA74278D008C4810B; Thu, 9 Jul 2020 17:14:40 +0800 (CST) Received: from [127.0.0.1] (10.174.186.75) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Thu, 9 Jul 2020 17:14:29 +0800 Subject: Re: [PATCH v1 2/2] arm64: tlb: Use the TLBI RANGE feature in arm64 To: , , , , , , CC: , , , , , , , , References: <20200709091054.1698-1-yezhenyu2@huawei.com> <20200709091054.1698-3-yezhenyu2@huawei.com> From: Zhenyu Ye Message-ID: <362990d2-3948-9820-e2d9-aa1ff1c8b068@huawei.com> Date: Thu, 9 Jul 2020 17:14:28 +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: <20200709091054.1698-3-yezhenyu2@huawei.com> 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 17:10, Zhenyu Ye wrote: > + /* > + * When cpu does not support TLBI RANGE feature, we flush the tlb > + * entries one by one at the granularity of 'stride'. > + * When cpu supports the TLBI RANGE feature, then: > + * 1. If pages is odd, flush the first page through non-RANGE > + * instruction; > + * 2. For remaining pages: The minimum range granularity is decided > + * by 'scale', so we can not flush all pages by one instruction > + * in some cases. > + * > + * For example, when the pages = 0xe81a, let's start 'scale' from > + * maximum, and find right 'num' for each 'scale': > + * > + * When scale = 3, we can flush no pages because the minumum > + * range is 2^(5*3 + 1) = 0x10000. > + * When scale = 2, the minimum range is 2^(5*2 + 1) = 0x800, we can > + * flush 0xe800 pages this time, the num = 0xe800/0x800 - 1 = 0x1c. > + * Remain pages is 0x1a; > + * When scale = 1, the minimum range is 2^(5*1 + 1) = 0x40, no page > + * can be flushed. > + * When scale = 0, we flush the remaining 0x1a pages, the num = > + * 0x1a/0x2 - 1 = 0xd. > + * > + * However, in most scenarios, the pages = 1 when flush_tlb_range() is > + * called. Start from scale = 3 or other proper value (such as scale = > + * ilog2(pages)), will incur extra overhead. > + * So increase 'scale' from 0 to maximum, the flush order is exactly > + * opposite to the example. > + */ The comments may be too long, probably should be moved to commit messages. Thanks, Zhenyu