From patchwork Tue Oct 8 13:50: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: 13826520 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 1503CCEF173 for ; Tue, 8 Oct 2024 13:52:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 997D86B0096; Tue, 8 Oct 2024 09:52:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 91B256B0093; Tue, 8 Oct 2024 09:52:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E0AA6B0095; Tue, 8 Oct 2024 09:52:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5EE8E6B0089 for ; Tue, 8 Oct 2024 09:52:44 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 63F1DACCBA for ; Tue, 8 Oct 2024 13:52:41 +0000 (UTC) X-FDA: 82650575448.07.91453A1 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf24.hostedemail.com (Postfix) with ESMTP id 4EDAD180025 for ; Tue, 8 Oct 2024 13:52:42 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=V+pRK6MX; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf24.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=1728395536; a=rsa-sha256; cv=none; b=wYXGlUkLO/ITFyOTYsxx1tbn5U9K1PLK86y/H4X5Z0Gxavw8PiIJHKNzATAYWuyZBNJ1XH bpEHRbVk6jz1yJw0fua9BZzuk1AzOyGnR9w0/8qE/As+PLcpiKnXbsP5YRTtG06TQ/4NCD 0NhpiBQeyBUC9ZF/aL0AIgWOefbYY0k= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=V+pRK6MX; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf24.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=1728395536; 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=wgV2+7MfZdUlRSibwZ/xMy3YdayQbJLzKgyLHwme9rI=; b=ACj00twkrFZym2MqrjFFgB/Y6csmjLjEvcmzmYdzDBLxP1yNa0eN64ImEXkOZAzBzfvH7h EA/PquPy3HQGlHGwu91ybzp1z5oezZBJJ62K0QHMkun3s5vLypF5Y8SMCo2+O1XDteFYto 3v5ArOqhxXOhirdDYi+tsn7lidRXwbk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1728395561; bh=FurOAuuDNyUm/lojkmHDOe6nk3DPDbcIuia0hHtIFVU=; h=From:To:Cc:Subject:Date:From; b=V+pRK6MX3xsgw8mxC5ocgt9ecpxOaeYcizHJSHxGqKPMB55/9+VVRyH9/BYKf0/WU XCehtZvwFLdGZX/66cztTUcV4wgveUeHlWDezPzi/wkbZchF1sV+l1th68dF/+I6aK llRpK/GzhQa6Pgsq+ofQZL/XxPGJ1rjsQSt7Q8ApI5LeDq7tlRP08bG20BL8U8e0pe yGz5e3/I1IgzfXIHWgrKByaJzrdjcVMQ9p2MMDjR1M0KPzpLVis9Zsq411lu97IUu9 cUmQLDT4zwhuwsGaE3W5RGABiDB9Dknne7FMg+T+41f8OLi3mgqe7puL+Qafdu257a FO7e4tun0B3mw== 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 4XNHX8539XzLqn; Tue, 8 Oct 2024 09:52:40 -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 v3 0/4] sched+mm: Track lazy active mm existence with hazard pointers Date: Tue, 8 Oct 2024 09:50:30 -0400 Message-Id: <20241008135034.1982519-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: zjggjh67taaww6aojfuwcztsk9jm7xtq X-Rspamd-Queue-Id: 4EDAD180025 X-Rspamd-Server: rspam02 X-HE-Tag: 1728395562-427292 X-HE-Meta: U2FsdGVkX19hThxAxVZEUEq8h+ftD4+e5wwuYfDi6NRuSryrri7UZFMWzxQX4w81lLojpXJOhtPv+xN1a4yJZhYUIIZQXmqxXZozJ4MutHKQptj1JhQkgbzNinIoqZKxcW2S1wqZhR1dJCbLlVWBetKUz/PWT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IwSH/MMCuph1O6NeN7Bz66Oa/gx40H4n6xoeTYo25WDmz0StWFLV5uSplIOai0JIF53gkFbhrQOOGVOn65U4/LZnsrev/Y9Jqb0RTiNaCtOy8M80WWzdhY3NkO5Yv9RKtVRIMp9OV4HRvZW8mqywsOpBq2aUR24xCYLSlcEKpHeHnFTE34G102RUz7hVF1vqbYLEVx6nnCu2cmuDZeYTEk6e4HC7xMPmSv/MCNQt47xwySYKv6kMvdjZqlkLA31HYePNk9/12SJD+rAx7JJg/x1D5AvOopGNld12Qw5dfBD/qOSkGmlCZgFUCR4vssGVeLDhJckDih4bpkzw43DK7NVDhMRty9lD8njslvL+PkRO4r0Y0aBvYw2aKFz8fFI27NXEQLLyTQ+L187RGa16iqn0jxMwlQyGN156J8XvK6feKYE8p09MmUf+cOL8LBes/qC88VZck7s9LVeXEccFD9q9ltG+IK2l+90wK+zoCcVGiMCd4QAbyjZ4nTk41gMh5zqKTHyBIE4NplxUwW9l4/k9Z8vRyOvzOTYndM0hcM6ogueLanKpA4nfhuxTvVzTPW8WxHCmxuXGbKHYP0OVh+vwTFyaZqy1XC/XVs8xRaeWU3TnUngmjWWPJTp6PnkLqOzGaFtAIj4XSCGgitAoGXK7rKHsYI6/ICS1ny9mT27RToljffZKUidc+EzcWpdkN4XBY1E7pdCyZd Cn/bpTvD 3IwYkkANtAY= 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: [ I'm posting a v3 taking care of feedback from Peter Zijlstra and Paul E. McKenney 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() hazptr: 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/hazptr.h | 165 ++++++++++++++++++++++++++ include/linux/mm_types.h | 3 - include/linux/sched/mm.h | 68 ++++------- kernel/Makefile | 2 +- kernel/exit.c | 4 +- kernel/fork.c | 47 ++------ kernel/hazptr.c | 51 ++++++++ kernel/sched/sched.h | 8 +- lib/Kconfig.debug | 10 -- 15 files changed, 358 insertions(+), 166 deletions(-) create mode 100644 include/linux/hazptr.h create mode 100644 kernel/hazptr.c