Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5278837yba; Wed, 10 Apr 2019 15:46:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXV1VtVGcRGKEO9PH4wCoSphF2J/cWXCBkRC5ofL2piKZSzH01k7opyI8MRLmHFi09TbiG X-Received: by 2002:a63:751d:: with SMTP id q29mr44038402pgc.215.1554936363436; Wed, 10 Apr 2019 15:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554936363; cv=none; d=google.com; s=arc-20160816; b=sHMTBz4UpbVR9RSNekwKS/G7WWI8natAKKAQuSE7/LWk1Xu3KgJ5fUHQZpVTiIfpOQ bMx8M0UGYM2sqJ79OhyTi5n8sC4aHM11v2kv1TcISZRpSG01+gUO2e1JyzdktONpAuDu r4ZS4gYIpn3xunge5kGL8ihQJ3qfSnTcuZfQdTJWZltGFLbsFGiUunEO+S+xnh9krmEl 5CYSZ9gSWuFYLu4cZTUZDOTg6usgcVHCtnF4EJR5I0UKu1IixayAwgVJUkL2rv0tCQwX QF624GXga0fjCANdGm2ocqtLBkndDl+o8STZkgq9a6uq0mBCrpHcGpAoHnNEbqenbgND q5Cg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr:dkim-signature; bh=7Bip8Y5X/mEZXPj+LvDt3Chr3J9dT6n58JPfRJ35Uag=; b=q3Z1XW9Xv2FMbC3PZijfDqUMYBKh8sH6aUTUVlFcFS9QyEbzoESkO9xPd25d4QYyS2 cH1Z5otPNPnh8OOQu3CvsbhEvyGV+eou/fi6xjoNv+oIxUCL2E9StS3vgXdVT+9Dlwyd KjoC1gG1OKMstkq3VUBYZlEgfRk/yLvvePxi3+pUH1zpAC7IqerDpSmqs1uPu4kOkOjy a0VOeJ7iiuPbjmwubq9YDYhvBsmLLUT/QG1oUjfIOR48bCNx72/oG6KtbEXhIcVQ6qOo t3LEaf2eaknn7PfN9/h0KFwEVnV7TGWDqmcUBhfYxZDM+vSBLeWMyCYtqLPDhH+K9Bmj 0zAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=WesuLTYu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a192si14819007pge.50.2019.04.10.15.45.47; Wed, 10 Apr 2019 15:46:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=WesuLTYu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726783AbfDJWpN (ORCPT + 99 others); Wed, 10 Apr 2019 18:45:13 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:49965 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726215AbfDJWpM (ORCPT ); Wed, 10 Apr 2019 18:45:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1554936312; x=1586472312; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6yEgNpC7nkfK5Gt64tHVR1TWf8LgYKpoRswHlGybH9k=; b=WesuLTYuoDr4aSbtRzjFbyKdzfS0RbbUEXykMO4k2b0LjV52rurMQs6I ZQnFyNVEtFh8B9SBDvzHB8XN2BI2K6i8KaXhp1An7cxXeP+27v9fG1kuV iWi7SseHJb81cKcHjFMwPj64TghIzzl1+8vbd4/nWJvpG1wscGpNN6oKx KHxJPSStLedl1OI5lqgVlDJhtUIuq32iqIjGGc1ERad0WruU+XPgqCoHn HnCPcSJ7HviDf9AkBMyRnpR8OfB18XKUHcUeuMguCjctEvoqWzL4QMhXO ei7muFU5UtjuB8OSnq5s/ccqb4omlJiF053fa0FNu39Q9zLEmlplJKojo w==; X-IronPort-AV: E=Sophos;i="5.60,335,1549900800"; d="scan'208";a="105470411" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Apr 2019 06:45:11 +0800 IronPort-SDR: zhZITZdwmBB0kC8dxnS31dgSwEoT/u/ZCnXKN13+WvF+9SDGGkfBjGjuOA+JAedigN+yUWnXIk VvubPvY7Hwcj/Oy2qlY+GwkR7lD5rSJGgw0hRV0yRZE2OimI8gdXtt2C1fPaI1mASi5mK0B7bh 5xo4eyLJGDoC5wDq2JXSt/h0f4HnG4fag6dHUfPyJ5MmzZwVkrZiq0H+xZo+IjZnzfHUt6qMD3 J32lNZ0v3hGytm6Nw5jpRrySq9lQ2EESkgrwZZ9muHddS8JJFM4NZnBQtrHs7kudXy5oSnrkuW 2/W2TSb/Wmypbu2w5DX1cor7 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 10 Apr 2019 15:22:06 -0700 IronPort-SDR: P2tizofEJwBlpXqmdmig2RJ0YQsu23QOCnvgmUAG1H9rvnUHED5nQrQKgVeUFCSMXkVPqz1NFe jVls7ismmD3tpCPVsDdnoyEZqRXuR7C9+3hklSCia+lTFejGZIY6Q2TZc+TZk3F3ayZp+sYZL9 cwsesGy1YxUmbyDiHop/skE8vqRZ3kJWRkllwFplbjXgILSGHQWar81YpZhK+vWWucV0XLsM1T qfB+wvJwOeof4gZPbGRNVWLyYP5n1fcfj873zD0K2rvuxAU5c3n5CefKEFwYSgkUKpPyxC6A78 lYk= Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 10 Apr 2019 15:45:11 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Albert Ou , Anup Patel , Borislav Petkov , Gary Guo , "H. Peter Anvin" , Ingo Molnar , linux-riscv@lists.infradead.org, Luc Van Oostenryck , Palmer Dabbelt , Thomas Gleixner , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Subject: [2/3] RISC-V: Update tlb flush counters Date: Wed, 10 Apr 2019 15:44:48 -0700 Message-Id: <20190410224449.10877-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190410224449.10877-1-atish.patra@wdc.com> References: <20190410224449.10877-1-atish.patra@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The TLB flush counters under vmstat seems to be very helpful while debugging TLB flush performance in RISC-V. Update the counters in every TLB flush methods respectively. Signed-off-by: Atish Patra --- arch/riscv/include/asm/tlbflush.h | 5 +++++ arch/riscv/mm/tlbflush.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/riscv/include/asm/tlbflush.h b/arch/riscv/include/asm/tlbflush.h index 29a780ca232a..19779a083f52 100644 --- a/arch/riscv/include/asm/tlbflush.h +++ b/arch/riscv/include/asm/tlbflush.h @@ -9,6 +9,7 @@ #define _ASM_RISCV_TLBFLUSH_H #include +#include /* * Flush entire local TLB. 'sfence.vma' implicitly fences with the instruction @@ -16,11 +17,13 @@ */ static inline void local_flush_tlb_all(void) { + count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL); __asm__ __volatile__ ("sfence.vma" : : : "memory"); } static inline void local_flush_tlb_mm(struct mm_struct *mm) { + count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL); /* Flush ASID 0 so that global mappings are not affected */ __asm__ __volatile__ ("sfence.vma x0, %0" : : "r" (0) : "memory"); } @@ -28,6 +31,7 @@ static inline void local_flush_tlb_mm(struct mm_struct *mm) static inline void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long addr) { + count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE); __asm__ __volatile__ ("sfence.vma %0, %1" : : "r" (addr), "r" (0) : "memory"); @@ -35,6 +39,7 @@ static inline void local_flush_tlb_page(struct vm_area_struct *vma, static inline void local_flush_tlb_kernel_page(unsigned long addr) { + count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE); __asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory"); } diff --git a/arch/riscv/mm/tlbflush.c b/arch/riscv/mm/tlbflush.c index ceee76f14a0a..8072d7da32bb 100644 --- a/arch/riscv/mm/tlbflush.c +++ b/arch/riscv/mm/tlbflush.c @@ -4,6 +4,8 @@ */ #include +#include +#include #include #define SFENCE_VMA_FLUSH_ALL ((unsigned long) -1) @@ -110,6 +112,7 @@ static void ipi_remote_sfence_vma(void *info) unsigned long size = data->size; unsigned long i; + count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED); if (size == SFENCE_VMA_FLUSH_ALL) { local_flush_tlb_all(); } @@ -129,6 +132,8 @@ static void ipi_remote_sfence_vma_asid(void *info) unsigned long size = data->size; unsigned long i; + count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED); + /* Flush entire MM context */ if (size == SFENCE_VMA_FLUSH_ALL) { __asm__ __volatile__ ("sfence.vma x0, %0" : : "r" (asid) @@ -158,6 +163,13 @@ static void remote_sfence_vma(unsigned long start, unsigned long size) static void remote_sfence_vma_asid(cpumask_t *mask, unsigned long start, unsigned long size, unsigned long asid) { + int cpuid = smp_processor_id(); + + if (cpumask_equal(mask, cpumask_of(cpuid))) + count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL); + else + count_vm_tlb_event(NR_TLB_REMOTE_FLUSH); + if (tlbi_ipi) { struct tlbi info = { .start = start, -- 2.21.0