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: 13826526 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 630EF1DF274; Tue, 8 Oct 2024 13:52:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395571; cv=none; b=WyjRsFfHtlcw+ECnhygMrMN4rjZ0ApxhlRF0SsuIIhJFcAjqaaczMQ83jr2URUuDsW1QPtOEhksD4u3qO3xIK1QqcdEe3mkGPvomcB7Tb52m808GxRYsxgXSlYMAQwr1rzFDaGka8/vcfo/t1MLoEWcZujBzE1jPKzpZ4HOCLUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395571; c=relaxed/simple; bh=FurOAuuDNyUm/lojkmHDOe6nk3DPDbcIuia0hHtIFVU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=PY1PBE2ib/c0YPQCulNWEZCjJFGqkJtBnxU89E8U10xrm/UrUO2yZ6I1p3++K7VW0TLFI7t18M2b1TxLfjL4zUDPnhUJLION1ILto/xTwx27ajBHUPdoNcSYYG1VI5WUAEzFzzJKcU31xumwQcwhjeHPboplS825E9st/cHCwOw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=V+pRK6MX; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="V+pRK6MX" 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 Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 [ 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