From patchwork Mon Oct 17 08:12:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfeng Ye X-Patchwork-Id: 3269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1329148wrs; Mon, 17 Oct 2022 01:17:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4TuJ8vtpb14w9+mmK50F1SV+7sXd70f9ydCUDT4WKwiJF0IIZMaN/ac8uud0DDgtqPYSI0 X-Received: by 2002:a17:902:ce0e:b0:17d:a730:3835 with SMTP id k14-20020a170902ce0e00b0017da7303835mr11204666plg.131.1665994649703; Mon, 17 Oct 2022 01:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665994649; cv=none; d=google.com; s=arc-20160816; b=dLW4f93F2srhk3TXdCzNZt+ceDLhkahMqM4Sn+GRScOvb+9x2bs18G61EnxUpm5pgL FPBPYYcM3xbyoLBoGMuWobYCsbggzpSfcLXFxE/16yZJ00XOfl1s0vTt2HI8WerLOayb MD+bTdj9+PDfldKgv7fMNqA66eZhranNMv7854f31mtzOjhe5ViG7g93YnLuKGS3q86Y BuqqyducdPlOS0Aaj7v25mUhmUo/qHrQYsHxb9zh/SWc5vFfdbnCu0Rs/MkaJuJisall +d0UNk7fQ4H6GVnFUqVQM8lmT0c/YtafKMdxDZvc3OpC/Z1bZ8boxkQcEJ1ayeqUPoFI ooNw== 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:to:from; bh=ZDoUrHprh/Gye5YC824UIX5IsNAu7mjmmOSJzmP8zm4=; b=eKJ9J+1mL9zJ7S9rAOIduWv/4TIA3vvc0PDJq3kiW25wm6n5bbpQ8guL3U+VL1+shL zbQlLZ+o7rtE7yjhPb7GJNBlgyYBz4VjFnJ2o6E2KD3LGO1snrDLuSSyL1I1tjzUJxVH EHFsrsMrdzVi0DMaN2tfA07MRe/6FHnOdlredLcjP7pGjbuXFmYtK1gtS4BA3dABmP8N eElYdkjT4UTcnfGS+7+RKTt25dHJ9ZUGbxn1dZU7sRJDpENI8R4rEoem2XU4EQwRpCqo vy4iG/IXvQMidaNhQDsLDI6oBL+idpgomB6g4hhDitHDJccnCZs/xkB1rSFZTprd7+aR LJQQ== 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 j3-20020a170903028300b0017a034f7246si13872582plr.560.2022.10.17.01.17.16; Mon, 17 Oct 2022 01:17:29 -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 S230096AbiJQIOG (ORCPT + 99 others); Mon, 17 Oct 2022 04:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230172AbiJQINo (ORCPT ); Mon, 17 Oct 2022 04:13:44 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 416F55C369 for ; Mon, 17 Oct 2022 01:13:40 -0700 (PDT) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MrV4j0fT1z1P7hZ; Mon, 17 Oct 2022 16:08:53 +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:13:04 +0800 From: y00318929 To: , , , , , Subject: [PATCH 5/5] arm64: mm: Add TLB flush trace on context switch Date: Mon, 17 Oct 2022 16:12:58 +0800 Message-ID: <20221017081258.3678830-6-yeyunfeng@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221017081258.3678830-1-yeyunfeng@huawei.com> References: <20221017081258.3678830-1-yeyunfeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.44.134.232] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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?1746922005887542183?= X-GMAIL-MSGID: =?utf-8?q?1746922005887542183?= From: Yunfeng Ye 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);