Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2560624imm; Sat, 28 Jul 2018 21:23:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfBsEwfCVr9dpw9ghtd+pqdhri8IrixN70Hj2VijiB5ndsxyqBSYy6FmNG0urR1KdYI1uUL X-Received: by 2002:a65:450a:: with SMTP id n10-v6mr11362049pgq.392.1532838228405; Sat, 28 Jul 2018 21:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532838228; cv=none; d=google.com; s=arc-20160816; b=YuaY/NVdJIgtkdvWZyd0Xr5+ZWDCMsombgjAC7dy2Cbh/nyHiWNgBycTN2ScAts3HP qM5vh111RaViq1wJB+ly6RW8ceEnBMloYb0dLqq6tSGqfl4UzwElaKN9VOQs6XRoVrMc gy3rkL4M9crQuvIug26ehqmGuRcOmw/spky0k0xLG+AvZ9d4lcQHbebxWk5bhSPyf7Yq UzIDWEOmwuSAGl/GsnuMzQMtkbdiPWI1te1rL7xsKTei/27yqPQjwcHFcZEV/17n016B v2Yakw3EvBU4mIcz3uzfd4s9foBRWS3+NjErcQqvaDujoMnVJ70ZWd5O1+jyhqHcD+2n wT+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=8gveFQqn+hDqGgQrjtyMJKTv/DpWGwRpUq1kMqEzPV8=; b=Hg5XIjVI72tznAylwyh9W8Ol/k4QnIhzVJ+3CT1ytg0ufCyHbUAvSTbafxde+Xjd2B rVMfhI34qpoymbflaFy56D0i1CbgtE9a9z508Ja2Wo0mP2lddKUSVIvbi6GawGP9ocmm milI01f8NQ+RPZyzZcOsSd5SVVqbTgsNDBiulGiECNGt2OtjDAvnuNrbgHdaCvZshiXh iR1sWBekS5js/oQ5huAbKSTj8Q1Ul6SvMDR17lf6lg5PwucJl1bCOyjaFmbzEo9gM5re su0P/WDDkvCNHSlRrBkGJGDOwNTcQAQ1gW7u6GqnhGBDKlCDGjT8hpMqVijAWoTBT/OG IVcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z+ol9vto; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11-v6si6875739plq.456.2018.07.28.21.23.34; Sat, 28 Jul 2018 21:23:48 -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=@kernel.org header.s=default header.b=Z+ol9vto; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726241AbeG2FvB (ORCPT + 99 others); Sun, 29 Jul 2018 01:51:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:48056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbeG2FvB (ORCPT ); Sun, 29 Jul 2018 01:51:01 -0400 Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 16AA4208A6 for ; Sun, 29 Jul 2018 04:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1532838123; bh=8gveFQqn+hDqGgQrjtyMJKTv/DpWGwRpUq1kMqEzPV8=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=Z+ol9vtoMgeysRRZ9zhLHWCpeEgLAFU5C2LCDZAITo5bteHoe49A9yzwsfjZC+41o XT6fTF/5HsxEYPEZyVelYHO858gZEhJ+x038eiMHbms8NErrp/sgZvV3NF0lBkbWWH Y4CsYy45noa3afNK10Qgheamkkkpe0Y5Qnw9008o= Received: by mail-wm0-f46.google.com with SMTP id t25-v6so9831655wmi.3 for ; Sat, 28 Jul 2018 21:22:03 -0700 (PDT) X-Gm-Message-State: AOUpUlG1knnoa7iFXu5L6oWvwPuhYmHnrM3WWXNpjbTkI+GatGQcbn5o 35UfdREJxubvZ43Z4Lv2n7ceMN8OGFWKgwujaqQn6w== X-Received: by 2002:a1c:8b0d:: with SMTP id n13-v6mr9448227wmd.46.1532838121605; Sat, 28 Jul 2018 21:22:01 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:548:0:0:0:0:0 with HTTP; Sat, 28 Jul 2018 21:21:41 -0700 (PDT) In-Reply-To: <20180728215357.3249-7-riel@surriel.com> References: <20180728215357.3249-1-riel@surriel.com> <20180728215357.3249-7-riel@surriel.com> From: Andy Lutomirski Date: Sat, 28 Jul 2018 21:21:41 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 06/10] mm,x86: skip cr4 and ldt reload when mm stays the same To: Rik van Riel Cc: LKML , kernel-team , Peter Zijlstra , Andrew Lutomirski , X86 ML , Vitaly Kuznetsov , Ingo Molnar , Mike Galbraith , Dave Hansen , will.daecon@arm.com, Catalin Marinas , Benjamin Herrenschmidt Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 28, 2018 at 2:53 PM, Rik van Riel wrote: > When switching back from lazy TLB mode to a thread of the same process > that switched into lazy TLB mode, we still have the cr4 (and sometimes > LDT) of that process loaded, and there is no need to reload it. > > When there was no TLB flush while the CPU was in lazy TLB mode, the > current code in switch_mm_irqs_off already avoids the reload, by > returning early. > > However, when the TLB contents on the CPU are out of date, and we > flush the TLB for the task, we fall through to the regular context > switching code. This patch teaches that code to skip the cr4 and LDT > flushes when switching back to the same mm after a flush. Acked-by: Andy Lutomirski