Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3084328imm; Sun, 29 Jul 2018 09:57:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdLofRDmymRrsdOYm412SdjfjYJ97q1DcajqZJeretHf/Dx9va/b8Mlhf8pQjrrmdWuAvYj X-Received: by 2002:a63:5350:: with SMTP id t16-v6mr13207295pgl.196.1532883432470; Sun, 29 Jul 2018 09:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532883432; cv=none; d=google.com; s=arc-20160816; b=B1OovCaJaf4sCI4XKyO1wqKlq9YfvKb5TYjHJNPLc/n0tiwNPh+gS+Od0MhbjGNsMj 6JjHyK6B54onncmCy2f2cS/UCm/8ialdaf4vImv3/Gft3+caSAWnQQrJNnX2P4t0cRGG trG4RqCRioE5C7oEIV802038qnbZYpWWRBQru9XplMchVj59zSiArNq3zZOZw/ddJ2W/ ZaRlTpQP+/3AiyBpjJkCFF7bSbiUUpQJcyuwHb2bw36f9wRT30J5o/MzBnEMne8WfMzx TY6INsrw0EmA6YKpIpzfuFfGQEv07sJYRv+mHt5WheHevMRkebqZSD3HPuoLHcEo5jnE t/VQ== 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=U+4dXga+UPDKWo4EaSfhqBv62n4hDakSf1YIuikVF6I=; b=wejTxeDx2L9kyI6WUQHycSE2wDmxLlEuHhUJ9OLPObWQ/VP3/fpPTzgiOK/0uvFmRf BXyVEcDimmQv1yAKn2dL47gHDkL0Lyg5u1jMM7GhQozOfh/Fj8kY/1qtU4R0ppU8j4pq nGfYKW0QkTx8HIfKNPnwyADy0wRn9v9eOKZXHwl+cQkEpjlCNCvKkkLW0mu5gWSqVWQh YW2DFABBzeUOWLhKR/arpG96E3h8RFBdIDq5Q7Og9mBLoiu/dOOCdTZL14GtUjrEIcce g7MzFnhafXEcGuXDS5a+H3hp5/2Tsdkwks7KY4cS3IW9XMrUPvZ75hFuLIJ2j8HCjUeo hw3Q== 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 d124-v6si8600918pfg.366.2018.07.29.09.56.44; Sun, 29 Jul 2018 09:57:12 -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 S1726513AbeG2S00 (ORCPT + 99 others); Sun, 29 Jul 2018 14:26:26 -0400 Received: from shelob.surriel.com ([96.67.55.147]:47952 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbeG2S00 (ORCPT ); Sun, 29 Jul 2018 14:26:26 -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 1fjoyJ-00005D-6J; Sun, 29 Jul 2018 12:55:07 -0400 Message-ID: <1532883305.28585.17.camel@surriel.com> Subject: Re: [PATCH 10/10] mm,sched: conditionally skip lazy TLB mm refcounting From: Rik van Riel To: Andy Lutomirski Cc: Andy Lutomirski , LKML , kernel-team , Peter Zijlstra , X86 ML , Vitaly Kuznetsov , Ingo Molnar , Mike Galbraith , Dave Hansen , Catalin Marinas , Benjamin Herrenschmidt Date: Sun, 29 Jul 2018 12:55:05 -0400 In-Reply-To: References: <20180728215357.3249-1-riel@surriel.com> <20180728215357.3249-11-riel@surriel.com> <1532866319.28585.12.camel@surriel.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-MYo/Jv5bfiIuWaF+WkM8" 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 --=-MYo/Jv5bfiIuWaF+WkM8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 2018-07-29 at 08:29 -0700, Andy Lutomirski wrote: > > On Jul 29, 2018, at 5:11 AM, Rik van Riel wrote: > >=20 > > > On Sat, 2018-07-28 at 21:21 -0700, Andy Lutomirski wrote: > > > On Sat, Jul 28, 2018 at 2:53 PM, Rik van Riel > > > wrote: > > > > Conditionally skip lazy TLB mm refcounting. When an > > > > architecture > > > > has > > > > CONFIG_ARCH_NO_ACTIVE_MM_REFCOUNTING enabled, an mm that is > > > > used in > > > > lazy TLB mode anywhere will get shot down from exit_mmap, and > > > > there > > > > in no need to incur the cache line bouncing overhead of > > > > refcounting > > > > a lazy TLB mm. > > >=20 > > > Unless I've misunderstood something, this patch results in idle > > > tasks > > > whose active_mm has been freed still having active_mm pointing at > > > freed memory.=20 > >=20 > > Patch 9/10 is supposed to ensure that the lazy TLB CPUs get > > switched to init_mm before an mm is freed. No CPU should ever > > have its active_mm pointing at a freed mm. > >=20 > > Your message made me re-read the code, and now I realize that > > leave_mm does not actually do that. > >=20 > > Looking at the other callers of leave_mm, I might not be the > > only one surprised by that; xen_drop_mm_ref comes to mind. > >=20 > > I guess I should some code to leave_mm to have it actually > > clear active_mm and call the conditional refcount drop helper > > function. > >=20 > > Does that clear up the confusion? >=20 > Kind of. But what=E2=80=99s the point of keeping active_mm? On architect= ures > that opt in to the new mode, there won=E2=80=99t be any code that cares a= bout > it=E2=80=99s value. What=E2=80=99s the benefit of keeping it around? If= you ifdef > it out, then it can=E2=80=99t possibly point to freed memory, and there= =E2=80=99s > nothing to worry about. I would like to get to that point, but in a way that does not leave the code too difficult to follow. Getting rid of ->active_mm in context_switch() is straightforward, but I am not sure at all what to do about idle_task_exit() for example. All the subtleties I ran into just with this phase of the code suggests (to me at least) that we should probably do this one step at a time. I agree on the same end goal, though :) --=20 All Rights Reversed. --=-MYo/Jv5bfiIuWaF+WkM8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAltd8WkACgkQznnekoTE 3oOKvAf/SIM1JQB9eK0FIQ0gFeL9UlTwdU2KfwwhEGof/tXFMGIhThoxC65/IYl/ UEKj/dwslfUIipfYoctzJ8NpYlp8lTZqw/lNVNDgI43NAw23sqWMClabCnAyl4nS HXXeBstU9py1ZYujz0re3MBHklWl7sd0bF6/0zLq1WyJUUYTbAffwt9ZqO2HrG2x YNz6y6mLGkYy6L5Ow3Y2Esr1xyq64+y1wPYbr73jelx5xUaL7vH1QeEX5COe9+Bh Va1c4p6gUrWb2epEopbUHILZ+kfoGQ1co+Oxj71oP+RCJorMuGqC4a6nqvqXY0y7 iY4H4SFhJfXx2+nodIkPOouTGbC2vQ== =IYfO -----END PGP SIGNATURE----- --=-MYo/Jv5bfiIuWaF+WkM8--