From patchwork Fri Oct 4 18:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13822867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35311CF8840 for ; Fri, 4 Oct 2024 18:29:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B61406B02D0; Fri, 4 Oct 2024 14:29:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B109E6B03B2; Fri, 4 Oct 2024 14:29:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9897C6B03B3; Fri, 4 Oct 2024 14:29:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 78AAE6B02D0 for ; Fri, 4 Oct 2024 14:29:46 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 17AE01401AA for ; Fri, 4 Oct 2024 18:29:46 +0000 (UTC) X-FDA: 82636758372.24.3E37EEA Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf10.hostedemail.com (Postfix) with ESMTP id 7715EC000F for ; Fri, 4 Oct 2024 18:29:43 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=VS52UYd6; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf10.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728066487; a=rsa-sha256; cv=none; b=nxZFs8l5Tox/1CDV+L5v0HTmd5qH67ybKRirMAcV9mCNHo44AjTsxTVGqUFnDrGqbM4vBK SIOZfrJ8NK1+dER5FdpuN3pS6Kv5uBMOnxI5h0rfWssoGS4dDjOMAR0o1FVNeaIToww4gp AhOJCIRewppjeDIAANuOZtAiD9Sas2I= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=VS52UYd6; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf10.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728066487; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=le5kLDf+aWECNALrZzvCw0eeDTkxQo34TkKN9+RaI/g=; b=kRYb0KGFIjOggCig+Fo9DwzkSGyUGPhoeAn2RPJIMWGKKihPyYMXcoFPN18mAh9x+sXuO/ YOpjFkZwEOyYMt1QMjRyAZJU+76v9rP3sLNwAvBJongEa8A1TLQrYS12Kn1LgCRFOkQlfj ZeqkIIQ9+V2VKLZusrNMeoo6ZIiZcO4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1728066582; bh=MWud5rJYcp01tmdb0smF8P75Q+GNmRWixrTxRl8zMFk=; h=From:To:Cc:Subject:Date:From; b=VS52UYd6+pQ4D/wAPhBdWsqtEtpep/nQzQlFII7jB0tQjkbxdphiSbOO47RuvZJr5 YoKQkqOk6PPn6iN5nZRaPyW59k2aH2pVMplcLapIJhKo0GeF1q0uU2qsuZh7nxpe3y 7fklJJTiI+F7n4MJvqrALtgx0pn+a9fqvrfcIwZiVJf0CZFirgN6tGC/Kue7bQAG18 pMTIXQ6GiKQhpKcp0qC9687F5LVTmryf7P585gxI9MUzdnM6bvYVNYp8lGHPbgPO9h lqXRJBJIMftkexbY+fkLFpO5yRRPPKtOR+iGJp3jTyclNd6g14SyTS0wYtIQ2axrKk pK3SuYKswUsLg== Received: from thinkos.internal.efficios.com (96-127-217-162.qc.cable.ebox.net [96.127.217.162]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4XKxsd5z2nzMpK; Fri, 4 Oct 2024 14:29:41 -0400 (EDT) From: Mathieu Desnoyers To: Boqun Feng Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Linus Torvalds , Andrew Morton , Peter Zijlstra , Nicholas Piggin , Michael Ellerman , Greg Kroah-Hartman , Sebastian Andrzej Siewior , "Paul E. McKenney" , Will Deacon , Alan Stern , John Stultz , Neeraj Upadhyay , Frederic Weisbecker , Joel Fernandes , Josh Triplett , Uladzislau Rezki , Steven Rostedt , Lai Jiangshan , Zqiang , Ingo Molnar , Waiman Long , Mark Rutland , Thomas Gleixner , Vlastimil Babka , maged.michael@gmail.com, Mateusz Guzik , Jonas Oberhauser , rcu@vger.kernel.org, linux-mm@kvack.org, lkmm@lists.linux.dev Subject: [RFC PATCH v2 0/4] sched+mm: Track lazy active mm existence with hazard pointers Date: Fri, 4 Oct 2024 14:27:30 -0400 Message-Id: <20241004182734.1761555-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 7715EC000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: mbn86xf5uus6m7p5wwtmumk3u7wftnaa X-HE-Tag: 1728066583-492211 X-HE-Meta: U2FsdGVkX183Xq9i2EN4w9AkaT30M2Vtc8kuRF3AqZrPzNzhOUCuZo7vTgy3pg5jhH6JxnxfbhTR0t5iwcy5sMjqcADpTO3nAKFr5Oqa1BH4ZcEjLKl5vWMEtQXZsX8bCI7DF9gO/Ca7wSzPdQSppQ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3CmA2vX1M/rhDYTm6uiISno9VH3UkBc2+FvW6epSdBidm4YSsgA0teSDseWlstVwHAFADZKdrGTXOv3+WUNatPmwgTMv1h+I1YwtHrsW7FIPwkORBuxmu4fUGC84abueSWxCuW4nQcOTX4UG/r0JqJboACS4B8EI9m+XQFCvwBGfMpJdrjYlmkK6hHUFkCpwpLkegZ4ugM/c9xIgMfwaGnIoZggAE1cP3aTZo7wAY+OrBPy3moA0x2Iyf/2JEiFYXkJnX6bAMh+7SabTOcBs8hTU3AYXWPYF89cGOcIQHu/4ERUm4zm2R5JpuHUUXKFe30P5LHfjjNmPlQf8MfWEiqbjyOHcbUpFUwyzcv5HFlYVoU9aDNNETOLJBmf1cVVge14KUO2KJUfuDCmyNmnVle0r8nGlS1FUP22wCjXkW80WEdNqN04vk9jSCMo1jKSL4Tl7Mjb5/zlIQ4hivl4GMey8oFt+Rs2DhGVFOT/WGjY8QKiDFOVNWEr9YWIXZGPmMwux/UNLhm167WW0lm2O3N8EtijAlEVedSKl0auUbz+DZBxmgiAZxgK90b+QqS3zrJcH8xBXcW82kUZ2UGMwRXeaHeRkWJAfonbWpDBQTHc+cFlnkTUxjbFKZ3kmURBYLsDnvBJG11S7O7sstVMzQCAJWlIFciIBnvsSU1rpdye7ztaw8jTH1IPOhw3byDX0YjrjOkyK93SRkH0/ksAfPOpUgYkrqX7alL20KUYQ3b/+drzHeeIJP e7xJPlC8 uOli1gf8iBU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: [ Based on recent discussion with Linus, it appears that this series just proves that it's time to get rid of active mm altogether: https://lore.kernel.org/lkml/CAHk-=wgztWbA4z85xKob4eS9P=Nt5h4j=HnN+Pc90expskiCRA@mail.gmail.com/ I'm posting a v2 fixing minor issues from v1 in case it can be useful to try hazard pointers with other use-cases, or for further benchmarking of active mm tracking impact. ] Hazard pointers appear to be a good fit for replacing refcount based lazy active mm tracking. Highlight: will-it-scale context_switch1_threads nr threads (-t) speedup 1 -0.2% 2 +0.4% 3 +0.2% 6 +0.6% 12 +0.8% 24 +3% 48 +12% 96 +21% 192 +28% 384 +4% 768 -0.6% This series applies on top of v6.11.1. Signed-off-by: Mathieu Desnoyers Cc: Linus Torvalds Cc: Andrew Morton Cc: Peter Zijlstra Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Greg Kroah-Hartman Cc: Sebastian Andrzej Siewior Cc: "Paul E. McKenney" Cc: Will Deacon Cc: Alan Stern Cc: John Stultz Cc: Neeraj Upadhyay Cc: Boqun Feng Cc: Frederic Weisbecker Cc: Joel Fernandes Cc: Josh Triplett Cc: Uladzislau Rezki Cc: Steven Rostedt Cc: Lai Jiangshan Cc: Zqiang Cc: Ingo Molnar Cc: Waiman Long Cc: Mark Rutland Cc: Thomas Gleixner Cc: Vlastimil Babka Cc: maged.michael@gmail.com Cc: Mateusz Guzik Cc: Jonas Oberhauser Cc: rcu@vger.kernel.org Cc: linux-mm@kvack.org Cc: lkmm@lists.linux.dev Mathieu Desnoyers (4): compiler.h: Introduce ptr_eq() to preserve address dependency Documentation: RCU: Refer to ptr_eq() hp: Implement Hazard Pointers sched+mm: Use hazard pointers to track lazy active mm existence Documentation/RCU/rcu_dereference.rst | 38 ++++++- Documentation/mm/active_mm.rst | 9 +- arch/Kconfig | 32 ------ arch/powerpc/Kconfig | 1 - arch/powerpc/mm/book3s64/radix_tlb.c | 23 +--- include/linux/compiler.h | 63 ++++++++++ include/linux/hp.h | 158 ++++++++++++++++++++++++++ include/linux/mm_types.h | 3 - include/linux/sched/mm.h | 71 +++++------- kernel/Makefile | 2 +- kernel/exit.c | 4 +- kernel/fork.c | 47 ++------ kernel/hp.c | 46 ++++++++ kernel/sched/sched.h | 8 +- lib/Kconfig.debug | 10 -- 15 files changed, 350 insertions(+), 165 deletions(-) create mode 100644 include/linux/hp.h create mode 100644 kernel/hp.c