From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753568Ab2D1Iw4 (ORCPT ); Sat, 28 Apr 2012 04:52:56 -0400 Received: from mga02.intel.com ([134.134.136.20]:29098 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753281Ab2D1Iwx (ORCPT ); Sat, 28 Apr 2012 04:52:53 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,352,1309762800"; d="scan'208";a="134675347" From: Alex Shi To: andi.kleen@intel.com, tim.c.chen@linux.intel.com, jeremy@goop.org, chrisw@sous-sol.org, akataria@vmware.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, rostedt@goodmis.org, fweisbec@gmail.com Cc: riel@redhat.com, luto@mit.edu, alex.shi@intel.com, avi@redhat.com, len.brown@intel.com, paul.gortmaker@windriver.com, dhowells@redhat.com, fenghua.yu@intel.com, borislav.petkov@amd.com, yinghai@kernel.org, cpw@sgi.com, steiner@sgi.com, linux-kernel@vger.kernel.org, yongjie.ren@intel.com Subject: [PATCH 0/3] TLB flush range optimization Date: Sat, 28 Apr 2012 16:51:36 +0800 Message-Id: <1335603099-2624-1-git-send-email-alex.shi@intel.com> X-Mailer: git-send-email 1.7.5.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry. forget cc to lkml just now. Added. This patcheset change flush_tlb_range from flushing all to one by one 'invlpg'. The following macro benchmark measured the performance improvement. and the testing result show in the related commit log. Any comments are appreciated! Thanks for comments from Andi and Tim in developing! -------------- /* mprotect.c This is a macrobenchmark for TLB flush range testing. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Copyright (C) Intel 2012 Coypright Alex Shi alex.shi@intel.com gcc -o mprotect mprotect.c -lrt -lpthread -O2 #perf stat -e r881,r882,r884 -e r801,r802,r810,r820,r840,r880,r807 -e rc01 -e r4901,r4902,r4910,r4920,r4940,r4980 -e r5f01 -e rbd01,rdb20 -e r4f02 -e r8004,r8201,r8501,r8502,r8504,r8510,r8520,r8540,r8580 -e rae01,rc820,rc102,rc900 -e r8600 -e rcb10 ./mprotect */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #define FILE_SIZE (1024*1024*1024) #define PAGE_SIZE 4096 #ifndef MAP_HUGETLB #define MAP_HUGETLB 0x40000 #endif long getnsec(clockid_t clockid) { struct timespec ts; if (clock_gettime(clockid, &ts) == -1) perror("clock_gettime failed"); return (long) ts.tv_sec * 1000000000 + (long) ts.tv_nsec; } //data for threads struct data{ int *readp; void *startaddr; int rw; int loop; }; volatile int * threadstart; //thread for memory accessing void *accessmm(void *data){ struct data *d = data; long *actimes; char x; int i, k; int randn[PAGE_SIZE]; for (i=0;irw == 0) for (*actimes=0; *threadstart == 1; (*actimes)++) for (k=0; k < *d->readp; k++) x = *(volatile char *)(d->startaddr + randn[k]%FILE_SIZE); else for (*actimes=0; *threadstart == 1; (*actimes)++) for (k=0; k < *d->readp; k++) *(char *)(d->startaddr + randn[k]%FILE_SIZE) = 1; return actimes; } int main(int argc, char *argv[]) { static char optstr[] = "n:l:p:w:ht:"; int n = 32; /* default flush entries number */ int l = 1024; /* default loop times */ int p = 512; /* default accessed page number, after mprotect */ int er = 0, rw = 0, h = 0, t = 0; /* d: debug; h: use huge page; t thread number */ int pagesize = PAGE_SIZE; /*default for regular page */ volatile char x; int i, j, k, c; void *m1, *startaddr; volatile void *tempaddr; clockid_t clockid = CLOCK_MONOTONIC; unsigned long start, stop, mptime, actime; int randn[PAGE_SIZE]; pthread_t pid[1024]; void * res; struct data data; for (i=0;i