Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp776972yba; Fri, 26 Apr 2019 08:34:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVTNL8aTiYhyRk1V+pccBsnm+sWq21/EvMxn9nF4UuoxAKXbKRJpPgef0SDjWczId67mPm X-Received: by 2002:a17:902:e693:: with SMTP id cn19mr33570794plb.255.1556292880063; Fri, 26 Apr 2019 08:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556292880; cv=none; d=google.com; s=arc-20160816; b=cw011JiUSk8GreiICgasHAMpxq45BSJypgulYM1FvLmOD5NvRgh7qyGcJWxlnaiwiJ 1eRebvTL5LDp3Xbt9diAFngTDmfe52nKplKiYe/haG0veYE9VCEhrN4zXhPEgs1il20Z E5EVSz2bjMOuhJA5nDrjvkukjxMowGtOw/wr9nsWqi1KF1MX72Yca8NOCb6ELbuq63su z7XqzuL8Lv53kZMv1o9eV6qSpiaiFoi01cIDgQgzXXaaXhwSmUAsZ7aBgdqhU0yBZbJu 2bXlt9wagk3wEe5Us6Brj3PAbY8PdhoP1lOxQPDONQJ6nPjQFL4TDqXCTLxLUhvIXOxe pGCQ== 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 :dkim-signature; bh=G+5WsbuuHSwf0oNxPHkpZsl8HtDzIrn5jcvXnz9HzZI=; b=nvzT1ztkokby8Gj3GYhjWm1WGg28k9fHdXDvRAdLa57rzCsB+uxAEeH4a3DG3co/tQ WTDf+ygcJ2eKB2yVM8jhE+pLytwxxLnYUEROOnXBUPMcpXItNk68JpwRW9n3BcXlPXdp +0JSJFmUR1BW/JxUZ3d4J6+gnEGQ25K23Tl7hbDt1/68vHF/QoUR994TXGrV7fwx0Wno tE8diCBg71mFZFHt1WhQbGBGKF/hj6vr9YaQoVZKF/4Y/Z1TQlUmlLouDHW7RCnOm3/h bu/OV2BOsK4ZB2HqYWGEBZjxb5HzIv0RM6Bi/VWZyWhzKVqzjDZYuiRDdSu8YEnmKo6z KESg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HrBdGumP; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si15808346pgh.357.2019.04.26.08.34.24; Fri, 26 Apr 2019 08:34:40 -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=pass header.i=@gmail.com header.s=20161025 header.b=HrBdGumP; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726874AbfDZPdE (ORCPT + 99 others); Fri, 26 Apr 2019 11:33:04 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39104 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbfDZPdC (ORCPT ); Fri, 26 Apr 2019 11:33:02 -0400 Received: by mail-pf1-f194.google.com with SMTP id i17so1905312pfo.6; Fri, 26 Apr 2019 08:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G+5WsbuuHSwf0oNxPHkpZsl8HtDzIrn5jcvXnz9HzZI=; b=HrBdGumPDRRmjDk3Jm3Nh0HA9cb+1O9+msLfCbRcMhUdmqXwSCFaRC0JvTXur91qQz dZpXDHoVR6blJldO2R7vCpWRbHxcURkhDkJbbnCDg8Gms+HMAtbUXIMEJetgDsM8Bl6t Ig/RAsnl3m0zkZeX+u13Uk0sPbIP9QmKLo7wTZ0GZ+bzbtOyLsdwB0u/ULFt9+iMUwu7 9VD9I/tfGPWeBOrdyIRRU7cZO0XqzbLAJXdda0b+z5+6/D2JSqdN5lb15di4ziKesITt exy4teIInzhpulOVBSCio2BS8bOkN4ZxqT6EYc2gjVUGIyCPKpS/A1ivCALh66x+tobu XYzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G+5WsbuuHSwf0oNxPHkpZsl8HtDzIrn5jcvXnz9HzZI=; b=X90PEdk0KE0E8tLmtR3nWP9R+izA3+XViNI1Gay6ol1mt0iqUnT/MNa1Ifyh3Wb/iA vn6czIYv8gRZZ211OQTTQQEGis6GkUZMuhPvHSeTjihRBGQKwKO/6K9g4njLECoSQaes UiaAvxoPeARDj3FFeAg2Bd6CIdPGyWc9ZoM617hwRoeE4KrvUZTq0lFteSPQ4eqyHJrK zjzHyQO03vswQmUx09rNfD4rAYHb0OYpjsq2EuX5pANNcKmOyYx30Uipr4ECtAXVfuLl zrBK0sd0BOHBN8fB7T+ir0WaTcOEZhsYd7MRdrUbedi366oIDoRgaOYoiVX4++s0+cBy d0QQ== X-Gm-Message-State: APjAAAW0yrupT3RpLr4gOI0YLtXaWcawTbjBwfWFcsnei1CEbmSgTny4 cJXyk2G2kcixJZxlugPnn1E= X-Received: by 2002:a63:5466:: with SMTP id e38mr44958494pgm.340.1556292781358; Fri, 26 Apr 2019 08:33:01 -0700 (PDT) Received: from localhost.localdomain ([104.238.181.70]) by smtp.gmail.com with ESMTPSA id b1sm29024833pgq.15.2019.04.26.08.32.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 08:33:00 -0700 (PDT) From: Changbin Du To: Jonathan Corbet Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, mchehab+samsung@kernel.org, Changbin Du Subject: [PATCH 09/27] Documentation: x86: convert tlb.txt to reST Date: Fri, 26 Apr 2019 23:31:32 +0800 Message-Id: <20190426153150.21228-10-changbin.du@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190426153150.21228-1-changbin.du@gmail.com> References: <20190426153150.21228-1-changbin.du@gmail.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 This converts the plain text documentation to reStructuredText format and add it to Sphinx TOC tree. No essential content change. Signed-off-by: Changbin Du --- Documentation/x86/index.rst | 1 + Documentation/x86/{tlb.txt => tlb.rst} | 30 ++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) rename Documentation/x86/{tlb.txt => tlb.rst} (81%) diff --git a/Documentation/x86/index.rst b/Documentation/x86/index.rst index 9a0b5f38ef6b..fd54b859db9b 100644 --- a/Documentation/x86/index.rst +++ b/Documentation/x86/index.rst @@ -15,3 +15,4 @@ Linux x86 Support entry_64 earlyprintk zero-page + tlb diff --git a/Documentation/x86/tlb.txt b/Documentation/x86/tlb.rst similarity index 81% rename from Documentation/x86/tlb.txt rename to Documentation/x86/tlb.rst index 6a0607b99ed8..82ec58ae63a8 100644 --- a/Documentation/x86/tlb.txt +++ b/Documentation/x86/tlb.rst @@ -1,5 +1,12 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======= +The TLB +======= + When the kernel unmaps or modified the attributes of a range of memory, it has two choices: + 1. Flush the entire TLB with a two-instruction sequence. This is a quick operation, but it causes collateral damage: TLB entries from areas other than the one we are trying to flush will be @@ -10,6 +17,7 @@ memory, it has two choices: damage to other TLB entries. Which method to do depends on a few things: + 1. The size of the flush being performed. A flush of the entire address space is obviously better performed by flushing the entire TLB than doing 2^48/PAGE_SIZE individual flushes. @@ -33,7 +41,7 @@ well. There is essentially no "right" point to choose. You may be doing too many individual invalidations if you see the invlpg instruction (or instructions _near_ it) show up high in profiles. If you believe that individual invalidations being -called too often, you can lower the tunable: +called too often, you can lower the tunable:: /sys/kernel/debug/x86/tlb_single_page_flush_ceiling @@ -43,7 +51,7 @@ Setting it to 1 is a very conservative setting and it should never need to be 0 under normal circumstances. Despite the fact that a single individual flush on x86 is -guaranteed to flush a full 2MB [1], hugetlbfs always uses the full +guaranteed to flush a full 2MB [1]_, hugetlbfs always uses the full flushes. THP is treated exactly the same as normal memory. You might see invlpg inside of flush_tlb_mm_range() show up in @@ -54,15 +62,15 @@ Essentially, you are balancing the cycles you spend doing invlpg with the cycles that you spend refilling the TLB later. You can measure how expensive TLB refills are by using -performance counters and 'perf stat', like this: +performance counters and 'perf stat', like this:: -perf stat -e - cpu/event=0x8,umask=0x84,name=dtlb_load_misses_walk_duration/, - cpu/event=0x8,umask=0x82,name=dtlb_load_misses_walk_completed/, - cpu/event=0x49,umask=0x4,name=dtlb_store_misses_walk_duration/, - cpu/event=0x49,umask=0x2,name=dtlb_store_misses_walk_completed/, - cpu/event=0x85,umask=0x4,name=itlb_misses_walk_duration/, - cpu/event=0x85,umask=0x2,name=itlb_misses_walk_completed/ + perf stat -e + cpu/event=0x8,umask=0x84,name=dtlb_load_misses_walk_duration/, + cpu/event=0x8,umask=0x82,name=dtlb_load_misses_walk_completed/, + cpu/event=0x49,umask=0x4,name=dtlb_store_misses_walk_duration/, + cpu/event=0x49,umask=0x2,name=dtlb_store_misses_walk_completed/, + cpu/event=0x85,umask=0x4,name=itlb_misses_walk_duration/, + cpu/event=0x85,umask=0x2,name=itlb_misses_walk_completed/ That works on an IvyBridge-era CPU (i5-3320M). Different CPUs may have differently-named counters, but they should at least @@ -70,6 +78,6 @@ be there in some form. You can use pmu-tools 'ocperf list' (https://github.com/andikleen/pmu-tools) to find the right counters for a given CPU. -1. A footnote in Intel's SDM "4.10.4.2 Recommended Invalidation" +.. [1] A footnote in Intel's SDM "4.10.4.2 Recommended Invalidation" says: "One execution of INVLPG is sufficient even for a page with size greater than 4 KBytes." -- 2.20.1