Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp380477imm; Thu, 28 Jun 2018 22:39:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdaE+VIh7+qCH9W/3Wtr7iAOtcPD84sRx+svzL+aRkXZmOMhVowwZdCRQllvCgIc0nH04AQ X-Received: by 2002:a62:a3d1:: with SMTP id q78-v6mr12896473pfl.5.1530250780269; Thu, 28 Jun 2018 22:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530250780; cv=none; d=google.com; s=arc-20160816; b=fg6OPRmWr2sPQDF0el/cpCpHagnmPbUBqhN6AWFKmL5IV02Ys2ZtJ1Ir8Hfo0WOunB WBTv6+Z12QE64krydMhNe+p2FywVIgOf/x4E1gy4N5GCH5dvr7MBxahysUV0gk2F0fzw 5I/IV5J44fCYU87MmkJE5DP/0dFlt58EnyGui5l1M9ILoNuWd3vOxf9fGK8VewwIFe2G Bha4zlySwWwjQamS5EF2T/85OYhxBGGe6iyc9Kd9rJRtACo9n1h791jK/SVBt5Xv/sqi hpx7WFll9Vl1295eIac+tp+uAVnZdd538UVGG5sme/vm+czKTTwPCfnrdepLua9tJQoE GnPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to:date :cc:to:from:subject:message-id:arc-authentication-results; bh=+SHXm872o/KGM0dShhrI94baMlYj9jVEiMWMYTR6aOg=; b=UQOCCVce9+eHDqHscLFjGYSOUnl0OhVmfgCz5yNHJnr2nBQ/Yw3gYmOgzS3E4EHQUW Bj7FhG1J0uK+YNiYJ5K1Ip2Yu06+xcws691H83UfIAFO7S56gJOFB5ZilVJPr845T2xi LvejeGTVdZ580+Xf8cXP5L2GIDB8lU3lpNLwHJN16mShg8FqXLME0Gf1N62zyhtaE+Ic rF2y8Jt96CPCfFC+SJwQ6zt/de+JEq1ZspHPrQemFxdPqVNxSdX5I2gqB6kNJ7Wy2/2D ZDibII9AuUilhjWAodxF/68QrYJTsteLrHjZemsDyzIaRw7dteuFtmjhj4EJ1dZl4K1g 3EIA== 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 w11-v6si7295365pgp.140.2018.06.28.22.39.23; Thu, 28 Jun 2018 22:39: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; 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 S935884AbeF1UF0 (ORCPT + 99 others); Thu, 28 Jun 2018 16:05:26 -0400 Received: from shelob.surriel.com ([96.67.55.147]:32970 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933391AbeF1UFZ (ORCPT ); Thu, 28 Jun 2018 16:05:25 -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 1fYdAN-00048a-2e; Thu, 28 Jun 2018 16:05:19 -0400 Message-ID: <1530216318.16379.4.camel@surriel.com> Subject: Re: [PATCH 3/6] x86,tlb: make lazy TLB mode lazier From: Rik van Riel To: Andy Lutomirski Cc: LKML , X86 ML , Dave Hansen , Ingo Molnar , kernel-team , Thomas Gleixner , Mike Galbraith , songliubraving@fb.com Date: Thu, 28 Jun 2018 16:05:18 -0400 In-Reply-To: References: <20180626173126.12296-1-riel@surriel.com> <20180626173126.12296-4-riel@surriel.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-gt597znUsnfNZWhHLAGr" X-Mailer: Evolution 3.26.6 (3.26.6-1.fc27) Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-gt597znUsnfNZWhHLAGr Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2018-06-27 at 11:10 -0700, Andy Lutomirski wrote: >=20 > You left this comment: >=20 > /* > * We don't currently support having a real mm loaded > without > * our cpu set in mm_cpumask(). We have all the > bookkeeping > * in place to figure out whether we would need to > flush > * if our cpu were cleared in mm_cpumask(), but we > don't > * currently use it. > */ >=20 > Presumably you should either clear the cpu from mm_cpumask when lazy > or you shoudl update the comment. The lazy TLB mode leaves the mm loaded, AND the cpu set in mm_cpumask(). However, I guess while the comment is technically accurate, it is no longer relevant, so I will update it :) > > + /* > > + * Switching straight from one thread in a process > > to another > > + * thread in the same process requires no TLB flush > > at all. > > + */ > > + if (!was_lazy) > > + return; >=20 > Comment doesn't match code. Maybe add "... if we weren't lazy"? Done. > > + > > + /* > > + * The code below checks whether there was a TLB > > flush while > > + * this CPU was in lazy TLB mode. The barrier > > ensures ordering > > + * with the TLB invalidation code advancing > > .tlb_gen. > > + */ > > + smp_rmb(); >=20 > I think it may need to be smp_mb(). You're trying to order > this_cpu_write() against subsequent reads. I have updated the barrier to an smp_mb(). > In general, the changes to this function are very hard to review > because you're mixing semantic changes and restructuring the > function. > Is there any way you could avoid that? Or maybe just open-code a > tlb_gen check in the unlazying path? >=20 >=20 > > + /* > > + * Instead of sending IPIs to CPUs in lazy TLB mode, move > > that > > + * CPU's TLB state to TLBSTATE_FLUSH, causing the TLB to be > > flushed > > + * at the next context switch, or at page table free time. > > + */ >=20 > Stale comment? Will fix. I am running some last tests now, and will send v3 soon. --=20 All Rights Reversed. --=-gt597znUsnfNZWhHLAGr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAls1P34ACgkQznnekoTE 3oPEngf/dwHqRR+66WXIupND84IXM2X5ZB/5AIuhWTh58dUTCjlW0HCFSB0Pq2UG 6S0O/fxhbF1LXFX+vPguajrEzNYLUfSwX7SQo0QxtCn3GKJ5HCmyMqg9UMqgNB85 0HRLeR+bwIbrspsEqJhCIjIKn7L3Qhzh4FP60BAuNl83kp0gD9gGlDW0PVcHY2VY 03/dmUc66ZJzvKz8k7b1bwO/8SbwR/PkfAGTj7X/DLNcD6qEWZ9JgUnqHpQk08Ig vhau2aPVbGFOCaqAHIFOXiEDYAJam73JQSxL+Fj7Fd89b4JEQungpQZzjxw7uo4e /aygOzYxfQkdMdci7f9ttHPcelW7Qw== =5M0S -----END PGP SIGNATURE----- --=-gt597znUsnfNZWhHLAGr--