Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1777027imm; Thu, 16 Aug 2018 02:23:14 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw8mlp/7vDkDzi8IcEJRspDRUUCvXB8Qourz5376vaT0ccSvfYlgEwDO7AANmYvkc/mmcZ3 X-Received: by 2002:a62:1089:: with SMTP id 9-v6mr30670785pfq.30.1534411394338; Thu, 16 Aug 2018 02:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534411394; cv=none; d=google.com; s=arc-20160816; b=ISMbf9tC387QVRoL7/WuCLjXSuXj8BzVNO8CCpNt+sQAtzSdB4/L+wsHdAwjXm2eWs kQCLB/Vc3RSKcRRrjxWjhL+9G4WCx3q/STNLBsR4JiUymyyWttC7g7eaHBYcAttBvSj5 kwBsK8WLpXkqJIchgrI4a1YQ1PAxXtr1uK8YMddI0kGfgIYWDvO8tuIouTSKcUAKJEUG V6ZNEiF6isrBNOnHAB6EkRF1WeHeBLl3bpUcIpIehlNQv8ZoqNWCK3tAwmejO/Ntuq6Y e+7mNBzc+d/cyan05gXVKjyVFwGD2agSNRNcU2f1viT68Vfmu/gslfLRn5WNYIrKTJw1 mgHg== 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=1fL9fP2mUsZjBMw2Qx4rhXRtscUjahXuzo4vw109sIQ=; b=njcUtmmIDKT7+3GLls3Cssd3OdRpNaZaQBhZJ7SS/341c0Y7rSyLAIkI1uuN8QPp2X 8gkXkrnQ8Vp+NMcMX+kkr98V/Hsl0rkfizakuN4o5KAMzRoo/suzFqMhlcZwt0k3wk6L Ch0VJDa7vNaXeFNDUNSW2aGcoW3sbFAzkmw5Jq1PLY2a76Tnk4DBZnZ2+4i/6gRzBgN5 UEXKkN4vlv9P7vbVBD0E+EwrZTRxi7f3gbCW3suHa8A/gHdA4GCCZSQwa4KZdH6rlJeY RWvIQwJ/FBihsUU9jV+EAcsuN2sTlfKTilS9lbYXjTu6yxLqFetuouJa5TbcU59GpU2u 1J3g== 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 a33-v6si20778072plc.15.2018.08.16.02.22.34; Thu, 16 Aug 2018 02:23:14 -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 S2388315AbeHPI15 (ORCPT + 99 others); Thu, 16 Aug 2018 04:27:57 -0400 Received: from shelob.surriel.com ([96.67.55.147]:36210 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725813AbeHPI14 (ORCPT ); Thu, 16 Aug 2018 04:27:56 -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 1fqAt2-0008Ew-Cj; Thu, 16 Aug 2018 01:31:56 -0400 Message-ID: <1534397515.28585.138.camel@surriel.com> Subject: Re: [PATCH 2/7] x86,tlb: leave lazy TLB mode at page table free time From: Rik van Riel To: Andy Lutomirski Cc: LKML , X86 ML , Mike Galbraith , kernel-team , Ingo Molnar , Dave Hansen Date: Thu, 16 Aug 2018 01:31:55 -0400 In-Reply-To: References: <20180716190337.26133-1-riel@surriel.com> <20180716190337.26133-3-riel@surriel.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-2oDqfEy2y4FE1XCEbp4U" 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 --=-2oDqfEy2y4FE1XCEbp4U Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2018-08-15 at 18:54 -0700, Andy Lutomirski wrote: > On Mon, Jul 16, 2018 at 12:03 PM, Rik van Riel > wrote: > Hi Rik- >=20 > I was looking through this, and I see: >=20 > > -static void tlb_remove_table_one(void *table) > > +static void tlb_remove_table_one(void *table, struct mmu_gather > > *tlb) > > { > > /* > > * This isn't an RCU grace period and hence the page-tables=20 > > cannot be > > @@ -344,7 +348,7 @@ static void tlb_remove_table_one(void *table) > > * It is however sufficient for software page-table walkers > > that rely on > > * IRQ disabling. See the comment near struct > > mmu_table_batch. > > */ > > - smp_call_function(tlb_remove_table_smp_sync, NULL, 1); > > + smp_call_function(tlb_remove_table_smp_sync, tlb->mm, 1); > > __tlb_remove_table(table); > > } >=20 > But tlb_remove_table() doesn't always call > tlb_remove_table_one(). Do > the other paths through tlb_remove_table() do the right thing? Urghhh, reading through the code it seems that I got one case wrong. The obvious cases, where tlb->mm->mm_users >=3D 2, are both correct. The functions tlb_remove_table_one() and tlb_table_flush() both get rid of lazy TLB users of the MM. However, there is one case where we don't but should: /* * When there's less then two users of this mm there cannot be a * concurrent page-table walk. */ if (atomic_read(&tlb->mm->mm_users) < 2) { __tlb_remove_table(table); return; } I guess the obvious fix is to call tlb_flush_remove_tables() in the branch above. The first time it might shoot down a CPU in lazy TLB mode, while the second time it is called that CPU will have already switched to init_mm and no IPI is sent. Alternatively, we could always do the batching, even when mm_users is 1, and examine the bitmap with the other CPUs less frequently in the exit path. I can send in a patch for this tomorrow, or early next week, depending on what other stuff comes up... --=20 All Rights Reversed. --=-2oDqfEy2y4FE1XCEbp4U Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAlt1DEwACgkQznnekoTE 3oNk1gf/cEh6uBKvwp6xXUbkRLFNCumPKvLsRxYFUNwP/VQJAEEHl1pRv56Wg+RS YM4+KAWRaEJN/EhQT12zQseQsVzGO1KnRUTfOMQydZ4oONVTWHZCf1xX8ORVuLTM IPd+BBoOypfZO/AvBlKoqOYgC+WHAnMUnT0yTSKO1zptbdaYnxJTMOYqvxXOtC/P mj+EkZx3QjlvwXHdijTMPByCNAmxIhViRjxFAKMUfy+64w+tGhcA9bQ3ZEJw7SlU IZQGv5+xZgh2V2gTjNoVZSYd99V3CbFux6t0qx5NUJW6zwzAZMbzYyGyAMhu+Wec X6o/mLAAm9VkPgfLL5SkTre3Ag4Bgw== =IWLL -----END PGP SIGNATURE----- --=-2oDqfEy2y4FE1XCEbp4U--