Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp110259pxu; Thu, 3 Dec 2020 21:28:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJw07+Yl29Kk0qMz/C+36lUL0Y2PhfFhZlFgNXOMZZ3FGEJnyhL3+3FDJwok/A30GpPSKJZL X-Received: by 2002:a17:906:90d6:: with SMTP id v22mr5620708ejw.88.1607059728194; Thu, 03 Dec 2020 21:28:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607059728; cv=none; d=google.com; s=arc-20160816; b=Fo1ekDfHR/xtuIs2rufA4GAPZ1dN3Ndr0VnGXzDiJhWVYhF+FxVDxv6IMAGM/pCIyD 1WcOQOBLn+MLnM5n3585Z7uneB/LF0GRT41CoWM05B7a/qTkjPTa5RbZT/8p6nPe4A0x j3oC6ncojMdDX8JvfiAG/QrIjGZoKpW0UdDR7C+LE3lGaqH/FoWZZ7lBuwUoZdbWzhHr cV/3OlR0xkt7rbrFcK/KU43//4CA+rIkCFV/AU+rk+uM+ON4q2ma3y3G2kQ+GjeDl1uS p3aETFgIPnNV7CmTuCjEC0BVnjgNe8lmqIKd9e5Cq+HnqwpiY4Q5QXvpM19xnzZgI5gT +Taw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Ygem+AF26DglDyig3HJNTwLPvOszLqwbVF1Sx9Thp64=; b=zrX58R80MZxx1n4WTJ30vj/UPlYQveDeKtscqrTfd4cw6WGX6Nxdoj6515nuiw6kmW 3pLTA1OuKlJqnx5F63iGvFFawlQ+AyOR0DPmopsMBZkO2f3eIdPo/2q8Qjici6WHcXNM YAc9TuPSoiK7PYNhJz18NWbLqnr+cmjsMSvk8R3L6+QMfcXGxoyV7wIdFqmt43NlETHS 4MfC+wyW12+Vnf8KgGAveoyShQspKRQfkw+puNFGjIOquHASXw4FxDueE4qUQOZc5Qhr +Fl6BjJtxZ9l53c0iTG7l7G4NG8Q6N97WaGlMnSy2N4nBqS8Lim7lnEkvkn9zGt82e7m wQNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id z15si695685eju.429.2020.12.03.21.28.23; Thu, 03 Dec 2020 21:28:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726270AbgLDF1D (ORCPT + 99 others); Fri, 4 Dec 2020 00:27:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:48512 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725300AbgLDF1D (ORCPT ); Fri, 4 Dec 2020 00:27:03 -0500 From: Andy Lutomirski Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: Nicholas Piggin Cc: Anton Blanchard , Arnd Bergmann , linux-arch , LKML , Linux-MM , linuxppc-dev , Mathieu Desnoyers , X86 ML , Will Deacon , Catalin Marinas , Rik van Riel , Dave Hansen , Nadav Amit , Jann Horn , Andy Lutomirski Subject: [RFC v2 0/2] lazy mm refcounting Date: Thu, 3 Dec 2020 21:26:15 -0800 Message-Id: X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is part of a larger series here, but the beginning bit is irrelevant to the current discussion: https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/commit/?h=x86/mm&id=203d39d11562575fd8bd6a094d97a3a332d8b265 This is IMO a lot better than v1. It's now almost entirely in generic code. (It looks like it's 100% generic, but that's a lie -- the generic code currently that all possible lazy mm refs are in mm_cpumask(), and that's not true on all arches. So, if we take my approach, we'll need to have a little arch hook to control this.) Here's how I think it fits with various arches: x86: On bare metal (i.e. paravirt flush unavailable), the loop won't do much. The existing TLB shootdown when user tables are freed will empty mm_cpumask of everything but the calling CPU. So x86 ends up pretty close to as good as we can get short of reworking mm_cpumask() itself. arm64: It needs the fixup above for correctness, but I think performance should be pretty good. Compared to current kernels, we lose an mmgrab() and mmdrop() on each lazy transition, and we add a reasonably fast loop over all cpus on process exit. Someone (probably me) needs to make sure we don't need some extra barriers. power: Similar to x86. s390x: Should be essentially the same as arm64. Other arches: I don't know. Further research is required. What do you all think? Andy Lutomirski (2): [NEEDS HELP] x86/mm: Handle unlazying membarrier core sync in the arch code [MOCKUP] sched/mm: Lightweight lazy mm refcounting arch/x86/mm/tlb.c | 17 +++++- kernel/fork.c | 4 ++ kernel/sched/core.c | 134 +++++++++++++++++++++++++++++++++++++------ kernel/sched/sched.h | 11 +++- 4 files changed, 145 insertions(+), 21 deletions(-) -- 2.28.0