From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj2-f43.google.com (mail-pj2-f43.google.com [74.125.227.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 453594FDA48 for ; Fri, 2 Oct 2026 17:10:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790961006; cv=none; b=Wi8kqBZi7vmWf6h2jsBqZip6IjGIWCzh8e0km3IIC88tPbVbuoxf9pOTQJoAXgSy7UcKFLVxnc8ID5DIAgq67LvsNUxZ8Td5MgFlYYxY+sZwfvZ2gu7tMDvG2PL5v3Gzps0rc+m2SIB6G4OzxADi7OUjcpwv0W63tPxnPYE4VMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790961006; c=relaxed/simple; bh=9wEbN2n5LQFaWEnfgc/fjcdj12CgL82mEepIN/jxNKo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rAlmhceu3OWHrP0LvTKG7IjCIwvxnXVORJ7Q6YQ35XyyQvKE3BlxsB5QJpQSPCgVgEe/IU4tqX4HYAUjc2d0hfgXDeWA/ia64pSxeeiwyDS2JDyjlSj/I4ep097q1ingyKMf3wQxa1IzH3USBAZ3uBPmUHNgVDUEzQQoqlwggpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dalPDMRq; arc=none smtp.client-ip=74.125.227.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dalPDMRq" Received: by mail-pj2-f43.google.com with SMTP id 98e67ed59e1d1-398b3b189e0so111678a91.2 for ; Fri, 02 Oct 2026 10:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790960998; x=1791565798; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=InVY38nfxVAqb/WmgYkdpIBcCwx01OQ8UJwYgwWPio4=; b=dalPDMRqF/pTMZKC7gM+vbuuHhe+AzE9gT3Z6UtI20aEydFwMb2S3ppM8uHDc4kq67 H/5HHerSCV+pGQ6iNfXLUDLrmLvI9zQHbE+D8F14nVDrMeZZ76mjeF4RYasyIGFuyHjc bJZ1eRwSeTr09fQyXxUTfGaW9GEcX6NrqQb7BXe9o/VWo1heh6veKHTWuc+bb6y1XWeT 7ieFI9GptxE5VYBmWMT3+gdABLWqRDSPcE3jmT4m/e1sxCTm8dgYz59rAb3+fi01bSTh 4/1sIBX8Mogz+e84NsEJZy107IZm5s5lIh0jrd5wCH0gpKTXZ4JHAut6q0afhEaOaJdZ +ynw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790960998; x=1791565798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=InVY38nfxVAqb/WmgYkdpIBcCwx01OQ8UJwYgwWPio4=; b=iOoB/4XfYjfJW9KuZ6jdR3WQpTZWJCegmRtNSgHWKr+aFUVlNbw40O+aWcMQ5WMvx4 kLOSAMIZsKl/Qn+nRgMIr2tuZbYp+bA2y6HPuGnhZhaieL9Ct+Ie7ynio2srap4YQEmn v6rmnOmupXZQI45RAc1t7GK1J26DRA0Yp+TNz3w8/1OyBIraZnua1dD7y+rbGGmMHw+z UUhN8ePAO207CYp2zuar0JUVYIy1usMRhR9HEVVBioej/hGOssj2eyrBlDSzRc1YZlet HoNe8GCUvi4Rf+QoAGO/Y82eth7jnfFLo1fvPPJMDJhMHQJtmGA7D1gemxV+Z3WghaUk 6Ekg== X-Forwarded-Encrypted: i=1; AKwUvBzX8LZE6PHYk/Tol5vA53bKFLrEy8tml9c4ywmd9WuwYK7zySfLsReoxHW3l+93Pt0nt0cZcxDR24Ol1CRltqk=@vger.kernel.org X-Gm-Message-State: AFq9FYJZOLnofJnGafhuHcv69DeS+6VQcvl0qXh3wx6gQ7hqt5lYjuiE 048mBb8+eC7x9+PBf1Tuh1gJ+2KdV9f5exmuyYh83e0+OsHOgzh/3Zqh X-Gm-Gg: AYBFou3YyXY23+NxsK5xnDqsQzemnmOnYOV5+aMjMr7mT8okG/xgK98qOBKIkeIPZhO 03qTFICjpCDGnaRePzAm5dTJ/tpJZbWSTOJf2Xwy4/Ri7InfJJV7Cp6IUxESVrYgU3Y2kpr0ZgQ gd1ZXaXYJuodJz+cZAycrGrAJO4XoT4fy64MMjU7jNMH4WX4sInU+I0opOoe7gSuVl+Oj+KxPPc WWLRG1n5Dqxw2PGVjLITXGPgJwf/WXddnqXqsCGZXLkUgSA22MKU6ookWLIVREvpxMZbcCZauJo 7+Kq+6xwWguC7wbkJSTvg2gdlEEGCe1UjkVEfOL23vWfrBnmqECL3qJRBprpxToI10Nec8lmH3I 8C1WcBh7R6V+WPgyHROxgqVHfPxUFK4LD20NviLkdJ1Tyv4Sy0Ve3HWONZBLR37tl3ENZyiON/r P7iG7yTm/1eHr8Em5nPc4h0+fxvHD7KudE+ztBULINrd4vmfXFS4IQcZ1V3c2mld8oilnT7C0rf OCDAfRj8cI43UGBPw== X-Received: by 2002:a17:90b:39ac:b0:3a4:a7eb:1da7 with SMTP id 98e67ed59e1d1-3a6ce7f8bcbmr2920094a91.42.1790960997498; Fri, 02 Oct 2026 10:09:57 -0700 (PDT) Received: from kernel.tail6741c6.ts.net ([185.220.238.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3a7024d0f5fsm1597719a91.0.2026.10.02.10.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:09:57 -0700 (PDT) From: Kunwu Chan To: paulmck@kernel.org, corbet@lwn.net, mingo@redhat.com, frederic@kernel.org, neeraj.upadhyay@kernel.org, josh@joshtriplett.org, urezki@gmail.com, dave@stgolabs.net, lianux.mm@gmail.com Cc: stern@rowland.harvard.edu, parri.andrea@gmail.com, will@kernel.org, peterz@infradead.org, boqun@kernel.org, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com, dlustig@nvidia.com, joelagnelf@nvidia.com, skhan@linuxfoundation.org, rdunlap@infradead.org, longman@redhat.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, qiang.zhang@linux.dev, kunwu.chan@gmail.com, brads@mainlining.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, lkmm@lists.linux.dev, linux-doc@vger.kernel.org, rcu@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH RFC v2 05/15] hazptr: add debug option to force the acquire slow path Date: Sat, 3 Oct 2026 01:08:37 +0800 Message-ID: <20261002170847.3653663-6-kunwu.chan@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261002170847.3653663-1-kunwu.chan@gmail.com> References: <20261002170847.3653663-1-kunwu.chan@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a debug option that makes hazptr_acquire() always enter __hazptr_acquire(), even when a per-CPU slot is available. This allows the slow path, including its lock acquisition, to be exercised by lockdep-heavy workloads. It also lets hazptrtorture exercise the slow path without requiring the per-CPU slots to be exhausted. Suggested-by: Boqun Feng Signed-off-by: Kunwu Chan --- include/linux/hazptr.h | 3 ++- kernel/rcu/Kconfig.debug | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/linux/hazptr.h b/include/linux/hazptr.h index 275cbe54b075..4ee02d23abc9 100644 --- a/include/linux/hazptr.h +++ b/include/linux/hazptr.h @@ -245,7 +245,8 @@ void *hazptr_acquire(struct hazptr_ctx *ctx, void * const *addr_p) ctx->acquire_cpu = smp_processor_id(); ctx->acquire_caller = _THIS_IP_; #endif - if (unlikely(slot->addr)) + if (IS_ENABLED(CONFIG_HAZPTR_ACQUIRE_FORCE_SLOWPATH) || + unlikely(slot->addr)) return __hazptr_acquire(ctx, addr_p); WRITE_ONCE(slot->addr, READ_ONCE(hazptr_wildcard)); /* Store B */ diff --git a/kernel/rcu/Kconfig.debug b/kernel/rcu/Kconfig.debug index 7c3c6017b266..3a2e9d7f58f8 100644 --- a/kernel/rcu/Kconfig.debug +++ b/kernel/rcu/Kconfig.debug @@ -265,4 +265,14 @@ config HAZPTR_DEBUG Say Y here if you want to enable those assert, N otherwise. +config HAZPTR_ACQUIRE_FORCE_SLOWPATH + bool "Force hazard-pointer acquire into the slow path" + depends on DEBUG_KERNEL + default n + help + Make hazptr_acquire() always enter __hazptr_acquire(). + This is useful for testing slow-path locking, especially + with lockdep. It also lets hazptrtorture exercise the slow + path without filling the per-CPU slots. + endmenu # "RCU Debugging" -- 2.43.0