Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4055984yba; Mon, 29 Apr 2019 13:00:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgcmu9Hki7cY7riqZ99iEq/URfzw6hOZUzXZJG2rqMl0RFnusxYb8oDwQS//iFxtnG1jlp X-Received: by 2002:a62:3684:: with SMTP id d126mr13593334pfa.70.1556568032954; Mon, 29 Apr 2019 13:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556568032; cv=none; d=google.com; s=arc-20160816; b=i8KBtEMVL2Zft4vOaKCv7BAmksba0n56iUxiVq+uKFOxrwyr9nw6dz/y+8j5qtcYIl RddoUoXEo+aS2xAQJb9jUM0km9rZEyWAjYFnwFBaOjWCTY0wQP3fn16+VcU82l/+L4OZ CwSYTN9zE5Rs06JWVNLGfj5cKdWf+NztCFpMcBvRgzvyGYaN/WrmmFEOf08QVZEr4dVk 7tMm3PFDR/JJfwI2bbzNUqfYvpJJsDlEEoL0Dd1z5dj6uNXjAESczaF2wbjC02HIX9/r wQjcaweSzehQFo96CqHu3RepZxzQOO7QZ4EYRvu+siThvDrT824jHf+1KQfuKlWykC8I sEnQ== 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=HVKUxPxuuJMnFYonXuUSbwrDVT+rVZMyiNc0SQsDW/bcrg9AxJnGrKaSR+PCtAglUV poR/4oaaT1ZL1QkGg1Pjq2qslSwRVgmUHaMgfgtZpwuufcRf8ToYee4GyNqmMvkVRnh+ uDRVhxgXGHtzGfdjOYPfQ6CwhhdJm3RPkLoIFJhiAgjmFIqbgpPLspEcxGv5RPVlbDkr LV2Og8a8eoJsG98mT5njajn3wWf6Hf+mVmYu5btPiVksRNKeit1VUlL5tNasnZiE/R5y 5OfMFgC91/6jrQX/PkC8hVJ+7LbFFKOVB9+2xZWXQA4jYPMlOSls4n7OpR1rGr9UHwNZ IZqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=la7J3wBv; 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 r2si18087884pfg.93.2019.04.29.13.00.17; Mon, 29 Apr 2019 13:00:32 -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=la7J3wBv; 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 S1729344AbfD2T7P (ORCPT + 99 others); Mon, 29 Apr 2019 15:59:15 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:31850 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729311AbfD2T7N (ORCPT ); Mon, 29 Apr 2019 15:59:13 -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=1556567953; x=1588103953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6yEgNpC7nkfK5Gt64tHVR1TWf8LgYKpoRswHlGybH9k=; b=la7J3wBvXstTbg4SiFPQvEBixJGU+7Mj/S4Eaip1+RpikvAxd5YZBEdQ 8+WfACwWo/1zg9Ix6yiOCNxbVN2g721hbPG/MKeimYJI8W4RqBjeea89q KhvX0aWt8HA0uEQBnTzODhbA5KfRkvc3wi+3Fp4zCqzNoNZj+7ieocTq8 Ml79LZalrcSSiYXNvQANMkrE/lfmHq4rysF4AT+TUAzwDpGNU7/ofkx8v hlCo1+Unz8PjnClvlm4RIMkuZ4ByIR0ueIl5bta7dr/YFE7dhm+qlKq9F xqiALXx8ybnI2h9FM8qlgiWFkvvc5Hr37bhoNDPNpVRKvx07Yzkcjn0uS g==; X-IronPort-AV: E=Sophos;i="5.60,410,1549900800"; d="scan'208";a="108309672" 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; 30 Apr 2019 03:58:12 +0800 IronPort-SDR: nnE+7rywavW8XrFdWFwhckRYvq20jD3vo+5IYylD3Woye3i2B8kqy4RZ5TJjUCVBz+EWQeK8lq wT10IOdbjDKNhIsg7guSFvNvqN5zQLk8grfrU5lbM/kLOVLQ5EemytBN4yIe+ITQVUPJ6zzFCm nh8Yc9Fd8FvLwbYwMYx6bokq4DbgtEGOO/SJ3tWmrSIDlYIAswarS+K1Co9DAJ347L41u6FpDr JDfbqpaJ35IyXRkaasw2cLgHHPYvPa/jsK4431T/at6Qh0NU3wRpIcMyGlNFlAAJ9uzBkRIVnc 91VnHZE1yVTSvVONqv20+QcQ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 29 Apr 2019 12:34:35 -0700 IronPort-SDR: UFWPaNgFKiyS+kM5SJyaKOUbUteycQhA9GHu35ZdcqxcIAwpMq8jMx6cNKm2y61EvnKQIFA4g6 adyt71wuZeOe/j/KIJZpFB2cH7aaoEu+AewDQCjkARDNK6tKK3Ss/l+or3zUgnpe45r8pEQkIk Y4X8GvyOZtE6EMtIew7DWbZqn+xPD9yVsW1Tg3JnbklQSamvfjNHbVdnBrVnlis/LKUG2/sMoI J22J0Ee7szjf8iEwrssNPsTdXyQfMfR6jgh0cXur2FRS7yIgCImTKqhsa+TrLQ0cRGszY6tVQd xPQ= Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 29 Apr 2019 12:58:12 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Albert Ou , Andrew Morton , Anup Patel , Borislav Petkov , Changbin Du , Gary Guo , "H. Peter Anvin" , Ingo Molnar , Kees Cook , linux-mm@kvack.org, linux-riscv@lists.infradead.org, Luc Van Oostenryck , Palmer Dabbelt , Thomas Gleixner , Vlastimil Babka , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Christoph Hellwig Subject: [PATCH v2 3/3] RISC-V: Update tlb flush counters Date: Mon, 29 Apr 2019 12:57:59 -0700 Message-Id: <20190429195759.18330-4-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190429195759.18330-1-atish.patra@wdc.com> References: <20190429195759.18330-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