From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from YT5PR01CU002.outbound.protection.outlook.com (mail-canadacentralazon11021098.outbound.protection.outlook.com [40.107.192.98]) (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 9D999D531 for ; Sat, 11 Jul 2026 13:48:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.192.98 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783777705; cv=fail; b=MzeyUFvdaNGlxTnPP2tmZtQHJhUj/uDQFx2QloVQbBhUOI/LR8B4e3nVGuGhy260VBZNq94ljPnQvPLRQOlDaiWAyfhr21Ozce5Qy6WvUCIARnOJFLcY3HawxAJVLajlrgjraBJIMGC37qmgl0i67nRztPiy8OLJldVCa4Yl9FY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783777705; c=relaxed/simple; bh=7teOblg8ZX2m5msb/GKcSuEnuAodRstwpP73FXpmZac=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=brNfOgkI3+4A4EDnRY3+EoeyK0O82cwfsKtLQOT96KfXpgNEyUJpTVtl9Lp+6dFfc2hp6XI2Kn8akXgweVPhMg4GElQ7Io+BsB7G6wo3OneDDRP37v/uYCvix1W4tM8ja+Kjvs3J5xMF1ubqT/qiKukOQDvw1EgA71czT463qzQ= ARC-Authentication-Results:i=2; 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=C08x0rG+; arc=fail smtp.client-ip=40.107.192.98 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="C08x0rG+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JCG7kQVL8i8cfNEUnrkjWo2eZPotrDDP7NMimjYSC8uA+e7pmlQlsLzR2VDXh3fnLBoMkkaRJqgnjPc4XH2tOdzuvakpHWXQfBFplDTdTMDUuA4EyduQhKiJE4AXTnxAlUZFyqX+9qroWJIkWzrNxJaRSSOtpLiuNBDLyaKPpl19tnEgmnocsLyeVMUFeFs7XS1o7nDs3ke+2fC66ANXlEKgTtMPWgGsSFTuGR9UflPur/g3BGTPpQUxr2+Cp/0/k6Dc3sWbP5Wi9M1YCKrYCLe6pAgYY35mi/DIJq+YznDa/RG4P24nrCxaqKQaOv/erZn+VnhSevbUKqyZZsLg4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=betdlodRFFY4vL+J7O4qVJFdFfUh/q1g0JCXkUmjW3o=; b=Rn7S/A/eOFLag91porv8JhAGXrddtopL9gcqdd1U+Tq8mSTJH2JDkb9/Gi5488Nv9YepKVZlSJoy/RMThX9EupOFc75G5RsegJd6RZICbLMdpj/U8H19vI5phXvvXA1ddw9yrMEXoJ4N0RUx7SoKoP/cE0re3LGsaFPZzigh5b77mT2UgNDWH1hrnfBR7uz9Ewsx9//0Ps2QBQ1XP8oZeDOBe+dNx2nXmJehWEZGNyT/Uzl1i92hUkiDrdFE9QhatgH9Kq66LJGbBPURH5wqtFup0IIqQjx5+Putbko3DPAQYhh6MxUW+MaLz3+HjF8iRH0NH+m3CU2fkqubeo0e4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=efficios.com; dmarc=pass action=none header.from=efficios.com; dkim=pass header.d=efficios.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=betdlodRFFY4vL+J7O4qVJFdFfUh/q1g0JCXkUmjW3o=; b=C08x0rG+H9HSlJcSrzaQsS2dxNX7NgHq1QdQQPOvXeuMhnkYw9bVnqIjLBTRUWOQc/UBiSL/L7qwubxhr2SzKdOaOQkfIi81jocRi33rqNvk0H0S7ieY+f1kGlNzSuw+jwKcbeNdW9wnKxcrRO9imy0FfVTClP5Y6qISIOnzloDM+qyf11x5UBVvvR6scfXu1qiQsZpgkQUYXrxrHkpOt3yNsEtIZrvFkkQ6YEhOkWyYb0IRLVzk4KUaRQhF8FCjqjgKCDY2Ah0e/k6mZThpPOu8tvxIqHwRpB+eLdVQbWvjCzxDgqHXgHfkFLJVMIf3n1u2MuDdU6lXFOOylZkVLg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=efficios.com; Received: from YT2PR01MB9175.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:be::5) by YT2PPFC9D71B7A9.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b08::486) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.18; Sat, 11 Jul 2026 13:48:19 +0000 Received: from YT2PR01MB9175.CANPRD01.PROD.OUTLOOK.COM ([fe80::6004:a862:d45d:90c1]) by YT2PR01MB9175.CANPRD01.PROD.OUTLOOK.COM ([fe80::6004:a862:d45d:90c1%4]) with mapi id 15.21.0181.019; Sat, 11 Jul 2026 13:48:19 +0000 Message-ID: <8179f07b-e6c5-4e77-869d-a5cbb0201662@efficios.com> Date: Sat, 11 Jul 2026 09:48:18 -0400 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] hazptr: Introduce CONFIG_HAZPTR_DEBUG misuse detection To: paulmck@kernel.org Cc: Boqun Feng , linux-kernel@vger.kernel.org References: <20260709183009.6814-1-mathieu.desnoyers@efficios.com> <20260709183009.6814-2-mathieu.desnoyers@efficios.com> <2402b90a-7f26-4ef8-b5ff-b3c92d1be9d0@paulmck-laptop> <55079bd3-b049-4e0f-9225-ad41e3562500@efficios.com> <222ca62f-a39f-4b6e-b5b4-7e40bb5ceb36@paulmck-laptop> <2c7f97fa-8429-4fbb-bb33-53e015629f01@paulmck-laptop> <2d801522-6a77-47ad-8daf-d23cc85cbb7a@efficios.com> <9282757b-8b73-4f40-ae8b-239a587d36f9@paulmck-laptop> <64b9de0c-a620-493a-bec7-a2f617149d36@efficios.com> <7394f8f9-7b49-4d8a-8a24-c1074f4242be@paulmck-laptop> From: Mathieu Desnoyers Content-Language: en-US In-Reply-To: <7394f8f9-7b49-4d8a-8a24-c1074f4242be@paulmck-laptop> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: YQBPR0101CA0231.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:66::8) To YT2PR01MB9175.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:be::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: YT2PR01MB9175:EE_|YT2PPFC9D71B7A9:EE_ X-MS-Office365-Filtering-Correlation-Id: 8836d085-e993-4bff-2b5f-08dedf5310e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|10070799003|23010399003|376014|1800799024|56012099006|5023799004|4143699003|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: ztuhzplT81A6HU3r/ZOORYRJVVi2Gz46cVlB6ALev0B9AVmQ7Ure6/OJIwWGAFlVMRYxzDaP7ydg+dJD66YA4MCZSifEkPRUm/zin0q2wpltR0wymjZiZhtpfGi4IFBbEfqL6q29ioyqN0K3mPLGZurTNxZKYFEE4nTjVtDcbktXbjppvvk00Pfmr3j0uuVNVS5KM/UdQt3N+s4MeNEIzngp4o43TQ8FEmlgGLwvmQOm7nQLCR49XuAZX60nln2DoGGTAfEiV+FoaTerDv11fzLkSBRnP5p5gO5YcAmyl8Ul31BHaNVLFFLjzmFN8kGFDMBwpMSRc7M8ovvaKWEbLnH437y01bbR/Fv5ddGIxWwlNcoku7rDCFwE/ILnnpsxJfwvsWkTlmdx/5de+WkQpzUiJCpNaAq5oHEx7AixqYYiIjnNf6uWSXN1XL7XDomAaByAdNuLU9vXXIQOdC4GtfUZudAqGbW+0WQjpZKpXitQX0bGsM2w6xFMnbPSbv9B3I/Mq6MyVBhJypW40rfKJYEYh3OsNUNHdp06FxEjNkexyi5UurgbxrtakyVJpYlEjp9fBWO7f2Yoj4iAzURK4P6Q6hpNxXA75AcQtgbdNWA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YT2PR01MB9175.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(10070799003)(23010399003)(376014)(1800799024)(56012099006)(5023799004)(4143699003)(6133799003)(22082099003)(18002099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VXI2MFZuekMrVHhGZjBVd3p0cnZ5bUVnWlpmbHJvUkZXVmhTaEJCY3gxb3c3?= =?utf-8?B?NTJVZUIyRWxObUo4NzJqTGpocUJsRmhQazR3Wk04Q0hRN2dEMjZtN0xYSEpp?= =?utf-8?B?SUs5WHBwTFE0alhaMVJLK3hEZUY4eTVYdDBMaDBvbjJYZzZUZ09lbVFaRytC?= =?utf-8?B?b0hZaDFSOVgzYnltWmthcisyTmNsZ2lPZUR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?utf-8?B?YnBIa0xvZWF5Y3dCOW9ERmRvVndqbGo3T0YzSGNucXdkRjB4N0pqcU1NYll6?= =?utf-8?B?ditYTFI2c0F4dHZpdWhhbkFIMFlhQy8vVFByUVd6QUVVU0lTcnY5WmRjNUdJ?= =?utf-8?B?Y0VGeW8rMzkwNDl2OThIdUlnWEE1VCt6NU9udmRSRGhJRFozQVVlMjVHQWgw?= =?utf-8?B?M1dZTlBXckJkOU5NOGRCTmV6OWpCcm9WWjUrS0hOSkhrTStjdnBDUmdUL1Nh?= =?utf-8?B?YmlTRFU1TXR5VTYwblFFTmp2bUhPQ1JGZC92amZqOWFmZTlRd1orU2ViNDVU?= =?utf-8?B?bktRRE1VRzlyUGk1Wi85OTdid20vam13Q2VEU2g2clhpWm1KQmpjQkdzMWti?= =?utf-8?Q?tPxnkV7mOyXi7l+P3An1dpd26twJV90iIwGBxth4ModUH?= X-MS-Exchange-AntiSpam-MessageData-1: ueU0OpVfxC7RFbw6g/ehSxjlVNOR8aO1waw= X-OriginatorOrg: efficios.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8836d085-e993-4bff-2b5f-08dedf5310e0 X-MS-Exchange-CrossTenant-AuthSource: YT2PR01MB9175.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2026 13:48:19.3747 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4f278736-4ab6-415c-957e-1f55336bd31e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +OZw64QEaq9TU4PR8lqTamFg9CP+Tvj7oAryFsOWS48SdzQ8yhd2BmJDKEClrHJCUpqWuA1HIqPLoNEsr6Pcbb3IvpxgIEKwX1wwi749ifk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT2PPFC9D71B7A9 On 2026-07-10 15:07, Paul E. McKenney wrote: >> >> We should really rename this given that it detaches the hazptr ctx from >> the execution _context_ (irq handler or thread). Not sure how to name it >> though. > > hazptr_detach_from_context()? > > I am leaving this alone for the moment, easy to change later. I just wonder if that name brings confusion. Is "context" the execution context or the "hazptr ctx" context ? I fear this is really a good opportunity to confuse everyone. [...] > >> Maybe just call it hazptr_detach() ? > > That would be your choice, not mine. ;-) I find that hazptr_detach is probably better here. It does not state it detaches "what", but at least there is no shortcut confusion with the overloaded "context" wording. [...] > > +/** > + * hazptr_detach_from_task - Allow a hazard pointer to be released by some other task > + * > + * @ctx: The hazard-pointer context to be migrated. > + * > + * By default, a given hazptr_acquire() and the corresponding > + * hazptr_release() must run in a single execution context, for example, > + * the context of a single task or a single interrupt handler. When you > + * have acquired a hazard pointer in one context and need to release it > + * in another, you must invoke hazptr_detach_from_task() on that hazard > + * pointer's context. It is permissible to invoke hazptr_detach_from_task() > + * multiple times on the same @ctx while it is protecting the same pointer, > + * however, the first invocation absolutely must be in the same context > + * that did the hazptr_acquire(), and must take place after the return > + * from that hazptr_acquire(). > + * > + * For example, if a hazard pointer is acquired by a task and > + * released by a timer handler, that task would need to pass the hazard > + * pointer's context to hazptr_detach_from_task() after return from the > + * hazptr_acquire() and before arming the timer (or at least before the > + * handler had a chance to access that hazard-pointer context). good. > + */ > static inline > void hazptr_detach_from_task(struct hazptr_ctx *ctx) > { > @@ -160,12 +182,26 @@ void hazptr_note_context_switch(void) > } > } > > -/* > - * hazptr_acquire: Load pointer at address and protect with hazard pointer. > +/** > + * hazptr_acquire - Load pointer at address and protect with hazard pointer. > + * > + * @ctx: The hazard-pointer context to be passed to hazptr_release(). > + * @addr_p: Pointer to the pointer that is to be hazard-pointer protected. > * > * Load @addr_p, and protect the loaded pointer with hazard pointer. > - * When using hazptr_acquire from interrupt handlers, the acquired slots > - * need to be released before returning from the interrupt handler. > + * This protection is roughly similar to that of a reference counter, and > + * ends with a later call to hazptr_release(). Perhaps worthwhile to hint at the vast performance/scalability/memory footprint/cache line footprint difference between hazptr and refcount to justify why both exist here ? AFAIU there is partial overlap between refcount, hazptr, and RCU, each with their own strengths and weaknesses. We should prepare a summary table for the end users wondering which is the right tool for their use-case. > + * > + * By default, the call to hazptr_release() must be running in the same > + * execution context as the corresponding hazptr_acquire(), for example, > + * within the same task or interrupt handler. When it is necessary > + * to instead call hazptr_release() from some other context, pass @ctx > + * to hazptr_detach_from_task() in the original context after invoking > + * hazptr_acquire() but before making the hazard pointer available to that > + * other context. > + * > + * It is not permissible to invoke hazptr_acquire() twice on the same @ctx > + * without an intervening hazptr_release(). good > * > * Returns a non-NULL protected address if the loaded pointer is non-NULL. > * Returns NULL if the loaded pointer is NULL. > @@ -233,7 +269,23 @@ void hazptr_release_debug(struct hazptr_ctx *ctx, void *addr) > static inline void hazptr_release_debug(struct hazptr_ctx *ctx, void *addr) { } > #endif > > -/* Release the protected hazard pointer from @slot. */ > +/** > + * hazptr_release - Release the specified hazard pointer > + * > + * @ctx: The hazard-pointer context that was passed to hazptr_acquire(). > + * @addr_p: The pointer that is to be hazard-pointer unprotected. > + * > + * Release the protected hazard pointer recorded in @ctx. > + * > + * By default, hazptr_release() must execute in the same execution context > + * that invoked the corresponding hazptr_acquire(), for example, within the > + * same task or the same interrupt handler. However, if this restriction > + * is problematic for your use case, please see hazptr_detach_from_task(). > + * > + * It is permissible (though unwise from a maintainability viewpoint) > + * to invoke hazptr_release() twice on the same @ctx without an intervening > + * hazptr_acquire(). Good! Thanks, Mathieu > + */ > static inline > void hazptr_release(struct hazptr_ctx *ctx, void *addr) > { -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com