Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4131977rwi; Mon, 17 Oct 2022 01:47:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7uuwAytrjt8/W7O/Lsh33oKY2epRG+w6uO0F6Zo4aJ9jg6FO/zXosrBz0SfpaiDv35RcSL X-Received: by 2002:a17:906:9b92:b0:791:9355:cb89 with SMTP id dd18-20020a1709069b9200b007919355cb89mr2059117ejc.498.1665996475998; Mon, 17 Oct 2022 01:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665996475; cv=none; d=google.com; s=arc-20160816; b=sNuxwwezpPb6esjOBAWRhoF8BwAHZ9wniX1QmBX2OEznPOCqGtLBEafSfK3iWCPSuG /fbIpBlznQk/opkkW20aMuNxT64v/y8YZKOOu7fd3faYneFNv7YiAQ1qKOz2J5KA3YUp ZPoK0keKwJKPIoYDq37bG7Pqm0N52ZY8mIA8uRh89wt4r2umAOaqxBt/yCn3TY1hll7X sFws8iJiET4t5qguuiex5KeGgkrHM+mY+kkzE5PQTUZAAN+FEc0cwh61hNWRQYy9wwbk aVPn/jqzS68PKWCVjNYoC5YNsOYn74VMsWKOIs+P0tcjU7ClRBKzFUmhLduMzn53YjWn FQ1g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jCu+4znLSuE/OTsfOjncHEPAAfMaK6kVAKxyIDP7/H0=; b=UuC5RRFJZ0ZwuaJIeeCWHdVey4NgtyxrxHe0/IrahBk3mH/BvIkbrsWqwQJHrhJwZ1 3tTt80YZpIntLKVk6dySSC1VmJf8j8bTG5v0P1u7nvonGbEu2ey9QWMJO4AOGHGZutPf iMXiquIryDnfdgaNk6c6/6k/MAG8wxUKndv8qbULZWKDxErE17g8FcBdl5a4fkbHDuFx LHOWrzpm45aX6wtb9iq6h/AmWNhWDLc5AUmEikEmy/lxBWmS3KWMGh3QaV0Zye9649BZ 0pqda2fvCZxLwjR/Yhfix9uUiBeCQpmzGsiryIalEXfM3bSFqZn4MGkQGsXaeltJqXdG Nc/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t25-20020a50ab59000000b0045a0cb0ff54si8699400edc.118.2022.10.17.01.47.30; Mon, 17 Oct 2022 01:47:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230316AbiJQId6 (ORCPT + 99 others); Mon, 17 Oct 2022 04:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbiJQIdi (ORCPT ); Mon, 17 Oct 2022 04:33:38 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5DD44F383 for ; Mon, 17 Oct 2022 01:33:31 -0700 (PDT) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MrVYK0JYdzpWC0; Mon, 17 Oct 2022 16:30:13 +0800 (CST) Received: from huawei.com (10.44.134.232) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 17 Oct 2022 16:32:08 +0800 From: Yunfeng Ye To: , , , , , CC: Subject: [PATCH 5/5] arm64: mm: Add TLB flush trace on context switch Date: Mon, 17 Oct 2022 16:32:03 +0800 Message-ID: <20221017083203.3690346-6-yeyunfeng@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221017083203.3690346-1-yeyunfeng@huawei.com> References: <20221017083203.3690346-1-yeyunfeng@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.44.134.232] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We do not know how many times the TLB is flushed on context switch. Adding trace_tlb_flush() in check_and_switch_context() may be useful. Signed-off-by: Yunfeng Ye --- arch/arm64/mm/context.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c index 0ea3e7485ae7..eab470a97620 100644 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c @@ -19,6 +19,8 @@ #include #include +#include + struct asid_bitmap { unsigned long *map; unsigned long nr; @@ -60,6 +62,8 @@ static DEFINE_STATIC_KEY_FALSE(asid_isolation_enable); #define ctxid2asid(asid) ((asid) & ~ASID_MASK) #define asid2ctxid(asid, genid) ((asid) | (genid)) +#define TLB_FLUSH_ALL (-1) + /* Get the ASIDBits supported by the current CPU */ static u32 get_cpu_asid_bits(void) { @@ -416,8 +420,10 @@ void check_and_switch_context(struct mm_struct *mm) atomic64_set(&mm->context.id, asid); } - if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) + if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) { local_flush_tlb_all(); + trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL); + } atomic64_set(this_cpu_ptr(&active_asids), asid); raw_spin_unlock_irqrestore(&cpu_asid_lock, flags); -- 2.27.0