Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2674429imm; Mon, 16 Jul 2018 12:04:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcxdQRlYDggKxGMLPxVY/P5FZMpw+iOnCpiGgXMjUWHaCpYT8gZhZXvT3/pDEjyjFw/1ANJ X-Received: by 2002:a17:902:622:: with SMTP id 31-v6mr17689270plg.135.1531767875194; Mon, 16 Jul 2018 12:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531767875; cv=none; d=google.com; s=arc-20160816; b=n4dKWAWNIrA2rUGpY1KrCJD9njTcD0tP/puXkKKW2noJ3S2R1Bzp56aW8ge7cxEX/y WzDQdVYHyFJPIvbU6X5iRqldxZ35O7XxNiJkR2xum/ZTXxBBUklWi5ZMvjpKz/zflJoX ITXu44hJCB/0rHc0w3/mLBTEjWIELyoZ1hiCuiq98kv5AsM+6GaBDAz51CobJ/RpAYrO FZiGIMbzuIC9lVSaeKYLS27S0cWC1GlhDMCTbGIvzz7lFZfwnM/A8mtR0cZcF2SWkueE oejvVMmSL/QsaMDo1DU2C8dvvnoPZuCAKTdPs8LD9OgWjLf+tilyaCyWwtMsLzSdfVd0 k8zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rQKmogq67vWrNAmeYQGnFSnYREpqU/0RVynkdx48kdA=; b=LnQPS41tfLIsuPAPgkvk5OEx1NXIdeRehb9Grd5Oyb96r/zjTU8q0qqp2xTRAunco+ D5zxOqXPdXoZ/7qgxE1Q4xoz3LSvUOPyWlWwAIVD1Lf9964zYgbLPJhzYO4BFUEjbwE6 t3Eg0SZoSzygrhJ0/JjgFydTWVhtm8JCp+LSYFS1rnBgmeTL4tXbWoAUrVUpAnw94VRV WIOdX0eIcZFEm4c1nLaz3pI3IiNRVCnB5lDv/V2XqCvoLGo2PxwSOY+OOAJochasvXF0 nbUf4foOmFBBIxa6RJn2ZNNypfdnp4h67K+F3MY26ZOolNbSrIHMfOL81+8IytpwX0ea SpJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28-v6si31008657pgk.111.2018.07.16.12.04.20; Mon, 16 Jul 2018 12:04:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729793AbeGPTc3 (ORCPT + 99 others); Mon, 16 Jul 2018 15:32:29 -0400 Received: from shelob.surriel.com ([96.67.55.147]:36086 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728470AbeGPTc3 (ORCPT ); Mon, 16 Jul 2018 15:32:29 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ff8ma-0003RH-Eg; Mon, 16 Jul 2018 15:03:40 -0400 From: Rik van Riel To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, luto@kernel.org, efault@gmx.de, kernel-team@fb.com, mingo@kernel.org, dave.hansen@intel.com Subject: [PATCH v6 0/7] x86,tlb,mm: make lazy TLB mode even lazier Date: Mon, 16 Jul 2018 15:03:30 -0400 Message-Id: <20180716190337.26133-1-riel@surriel.com> X-Mailer: git-send-email 2.14.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Song noticed switch_mm_irqs_off taking a lot of CPU time in recent kernels, using 1.9% of a 48 CPU system during a netperf run. Digging into the profile, the atomic operations in cpumask_clear_cpu and cpumask_set_cpu are responsible for about half of that CPU use. However, the CPUs running netperf are simply switching back and forth between netperf and the idle task, which does not require any changes to the mm_cpumask if lazy TLB mode were used. Additionally, the init_mm cpumask ends up being the most heavily contended one in the system, for no reason at all. Making really lazy TLB mode work again on modern kernels, by sending a shootdown IPI only when page table pages are being unmapped, we get back some performance. v6 addresses the comment and Signed-off-by issues pointed out by Ingo. On memcache workloads on 2 socket systems, this patch series seems to reduce total system CPU use by 1-2%. On Song's netbench tests, CPU use in the context switch time is about cut in half. These patches also provide a little memory savings by shrinking the size of mm_struct, especially on distro kernels compiled with a gigantically large NR_CPUS.