From patchwork Mon Oct 17 08:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfeng Ye X-Patchwork-Id: 3281 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1334842wrs; Mon, 17 Oct 2022 01:37:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5OmnO2B7WK4nuVdwU5RW8cpRHQsqCzV9d/jJvu8O+e9XNacwz6S1rhuyuj4d9qdbMmH+Pl X-Received: by 2002:a05:6402:249f:b0:453:eb1b:1f8b with SMTP id q31-20020a056402249f00b00453eb1b1f8bmr9046875eda.235.1665995872654; Mon, 17 Oct 2022 01:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665995872; cv=none; d=google.com; s=arc-20160816; b=LLlmtnYwJF1oI3sY8sK7QA7i/nWACY0tibT2mhkExagW/TY1o09sIRgp8nZF1vdDMh 2z+hGmBE/V04xPItLI34Y0Za27Z2f5I8b4Sm52C65pWKvTCw6rYUznPY7Elk63gsrqnv HMY+WDxpzCGEMiw+/z69+eqeSN3xIFO5nIM6Mgtu2aJ8it1NfspLCsYanX+k1Q6Rod9o 0bEvysfdAaHERyB8YeQRl0zKGfhGA4CCMCIZAEQqb6O2CmNXJ9kGMoMFRZzLwNCut28B g6KEvqRrMuclM/gYvm4zP0UCFCb5bqSuO1qauw0eRRfna5Ej8PHcI4rvYt/rXy+weSqt zTXw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l15-20020a170906794f00b007882926848bsi9026651ejo.818.2022.10.17.01.37.26; Mon, 17 Oct 2022 01:37:52 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746923288078658422?= X-GMAIL-MSGID: =?utf-8?q?1746923288078658422?= 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);