From mboxrd@z Thu Jan 1 00:00:00 1970 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 B64B3CDD1CD for ; Fri, 27 Sep 2024 18:13:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34FEA6B0122; Fri, 27 Sep 2024 14:13:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 300526B0123; Fri, 27 Sep 2024 14:13:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A1116B0124; Fri, 27 Sep 2024 14:13:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id F011A6B0122 for ; Fri, 27 Sep 2024 14:13:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A06C740E7F for ; Fri, 27 Sep 2024 18:13:29 +0000 (UTC) X-FDA: 82611315738.04.EB19A06 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by imf24.hostedemail.com (Postfix) with ESMTP id 8FC5918000A for ; Fri, 27 Sep 2024 18:13:27 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=ULlWC3z5; spf=pass (imf24.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.178 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727460684; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZUX1kCLvq6+bfGUvOV4xSkP3/ox8tqlvT0bJqmyP1AA=; b=3iYsB9MwGuzQE/e2Ek12BBAxYOQH1BWg/xH+CfNQbhvmztnwjhEqT/NuVQcbkW1BYrOIlK SEK8Y57HYSL2FF1i9LMY+ExiQ0IcxWFAdfX28JTENuJ/dxuAw5Rge9GhC3MB9OZY5TBm42 eJPGvgxLrGuE6xPK8WiL0ATYywXL6YA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727460684; a=rsa-sha256; cv=none; b=5DJ7R93pBZVm+7L45bNMDoHwfN710S2d7r0MMex1Tval3Vv6Mu6eShXoDzqIqe3RzhZN6F rLfIhFa3Nmq36Ehhg60za8f3ZNvHb0HJApSX6hPcf8/Es0zBPZSqOm8ecINkXv3AHtov/X 8UeAbWYqCtNkQhrZVsp0+uzF4TeWbHo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=ULlWC3z5; spf=pass (imf24.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.178 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2f761461150so36531221fa.0 for ; Fri, 27 Sep 2024 11:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1727460806; x=1728065606; darn=kvack.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ZUX1kCLvq6+bfGUvOV4xSkP3/ox8tqlvT0bJqmyP1AA=; b=ULlWC3z5LlSA07IZZDmmLgokLtbUbndaAvrvUisz7Vf0/Le8wZT+Cf7Hvs8Fia83cY 6a0Z7rGLCJl3rBNQCBkzaRnVmp9CYriSRDjb57E5YjIEqW4dmefX3kn9Dm9LZsvJFeV0 dgw4qEwe6qB/IFjdjl3tz/iDq7XTH6IFlnJHM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727460806; x=1728065606; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZUX1kCLvq6+bfGUvOV4xSkP3/ox8tqlvT0bJqmyP1AA=; b=QELOBwooTsx/R+vqOKTH+imjNd7RgE7joFwtZrVWBCsS5G0pnqIDSHpbDN7wkOhuhM 4zLOO2cBzbHwQ+MRluRC9brbLdzlh2NTmSxNQ4Si1IH7FNcMjtp8X29Cn1mcN3K3u10F 3dduSJ9JTPxc739ZQHPm5A3wlWSZPnc+hNgjmvcEBsreAeBJaAi4Plz3aSZEfTw8rp/H qQ0noVHD4hP5464aDizfVl51WzTdgSZ9uR1hJxMyC1R1SBKDv5dGaGWcXkcF2Zw+TpIC cKGrI06J0svlLgRC+qwBBBmsra7u45wqGbLU0NKb2bHBhRMFZz1CZhqhYxd8LKiNmfN9 Ptog== X-Forwarded-Encrypted: i=1; AJvYcCXT/3IL7zHR7618ryURoJRL4yhL8d02kR+m9W51s2hmub/pmb/bHdhkPL0imp4bG/oOEA1jPOl/SQ==@kvack.org X-Gm-Message-State: AOJu0YxINs72HjU4jHsFjJyPRsoI6AH5XLlwtiXEpxWdrWkQteXTe0hh QkrqLE0H/hg4f01z97zDXQQntVZW8H096Do4MX36Q8ziUCnakqHMRhysIebjWGvDiVCFEZtkjmf aNA7IyQ== X-Google-Smtp-Source: AGHT+IESEGBt9JQHM/QYi08HOVNoUHgpjhLp1k+Jeyljvys8yOxluO3jQbpyQMCw0snnvvWRt+nT7Q== X-Received: by 2002:a2e:742:0:b0:2f1:67de:b536 with SMTP id 38308e7fff4ca-2f9d3e5ae5fmr29136501fa.24.1727460805461; Fri, 27 Sep 2024 11:13:25 -0700 (PDT) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com. [209.85.208.182]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2f9d4618f39sm4082781fa.117.2024.09.27.11.13.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Sep 2024 11:13:24 -0700 (PDT) Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2fabb837ddbso13691821fa.1 for ; Fri, 27 Sep 2024 11:13:23 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUQK9I8sdZD+ujFQHUixkqWeWf+vH267FMhmVwiapMYTEzSTTQTmrWsbA8oMrN0sQ9TWnJULfpS1w==@kvack.org X-Received: by 2002:a2e:b8c8:0:b0:2f7:562d:cb5b with SMTP id 38308e7fff4ca-2f9d3e3d465mr41944381fa.7.1727460802851; Fri, 27 Sep 2024 11:13:22 -0700 (PDT) MIME-Version: 1.0 References: <4167e6f5-4ff9-4aaa-915e-c1e692ac785a@efficios.com> <48992c9f-6c61-4716-977c-66e946adb399@efficios.com> <2b2aea37-06fe-40cb-8458-9408406ebda6@efficios.com> <55633835-242c-4d7f-875b-24b16f17939c@huaweicloud.com> <54487a36-f74c-46c3-aed7-fc86eaaa9ca2@huaweicloud.com> <0b262fe5-2fc5-478d-bf66-f208723238d5@efficios.com> <7e1c8a5e-c110-414c-8fb2-022eacc2bd4a@efficios.com> <34ec590c-b109-44a0-8bfe-8aafc6e7ad64@efficios.com> In-Reply-To: <34ec590c-b109-44a0-8bfe-8aafc6e7ad64@efficios.com> From: Linus Torvalds Date: Fri, 27 Sep 2024 11:13:06 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers To: Mathieu Desnoyers Cc: Boqun Feng , Jonas Oberhauser , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, lkmm@lists.linux.dev, "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , "Uladzislau Rezki (Sony)" , rostedt , Lai Jiangshan , Zqiang , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Mark Rutland , Thomas Gleixner , Kent Overstreet , Vlastimil Babka , maged.michael@gmail.com, Neeraj Upadhyay , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: zemumr5hprt9fhz7phh4z13tsw11ci4j X-Rspamd-Queue-Id: 8FC5918000A X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727460807-480947 X-HE-Meta: U2FsdGVkX1+Bw2NiMaETt9RtlFNOXKeom0Eryon4CelswUVavRr7j06UEPV4OIj1pqNVx52ARxIx2Xo9bT5wsuS5OpNeeEJgMW7e6K0A6lhx5t9+xTFPS/dQBWAASbqMmRAvrZh7AihZ4KBWiNcts4gUiVgBwmBkHh8zOMuxx76/+V7fF/LrXA0yxrJsVYkverQyZfTFT+ANIUBI+vJXAwsiKE+wBPrTw52oBb407cq5p2FU6LWbtd7eg9CFqHZaznR9dOxW7PP14X0a7jCWu0gMtyAstENpf5PlIf8hnrDfeVfa3MRYdCcyt1lk44DqitLWKhl7lPxCdv+wnhTuW277cQABxyjIuSN0aRqAmWVxUfmGgt16uBs8WPB0htSR+9IaswEal4MWjIwWVdeZZ0fJtMQnq4ifgrX2kkzJJ0LexQwEa/44GGoFCJjDhozVPbvjn3ig/DoQphBy67WYBZ/9GA3obWvigG65irqqgJ8SeFvzIVSl3H7yX3xwDbCZrLLyRCkYYBCeQRjtpvPNWquqRJDIt7yxSmGOzwzkfsc1idwPPw0nUR9PnN4h6z9gyO96MKezlurPNgSigYS2NUj/ZpvvWq+ojebn6f0wHImUku7jWyoVgSZnW6MTaH3MmdiC+EFF/ipt2H/N6OlwruNUKmpfPFXPZqe7JGW+/F35Bg/ayNdfE98Vv26z2DuatDi8cOXEEYwM+x1DfwWYNYeQ5TUTXGQr+2lvr0YAN61e9BWiV335ru2M51iAQ7BHX/+XuHuaMnbdXZzb5BbPnmC46HicPAb6zPYIZOAkD6/KJbHic6EM8p7xLq7/6XrWiV0v3oDdB+6VVKPwX/2dgHHSkKmwm/9S7Ew8oenCLC/uxtuI3xhwAC44KCqQ8+v63Vff6TUuIB6da2yWJyQz9G9jdiXnMzgw5iH0OfDWoqTmcWJDZNw0RTpi8SOAyyQbEVr2ZMtSoe+5g6CaQlK PRpkhDXZ jXN/rplrPRZoPsf17UswxkuXZMPd2+K5g59lZqkgH4LdLTnMxfkXU85B4Uh71d8fZiHUBMRjQUr0AuAPKgOIumPa91fyUZUTllrbwLn/or6wZOgQXl//t66LTz8xf9eA1aVetWr6wdY5r5WsCPvBhoZK/nXE4RHrIiNe+UD3keOtgHM33V4ofct1FtUH1TRNtFVUmUk5NonKwQVrNF5PSKOxQOnGjV0pzX/pCEVRpwS7tYkPuHtsYh5p91y+Qgfxm0A6S+Qr6I114CTaaZC1dfF2LgLW7+fqD6FtMpd+7xwg8T2ditymv9V350/6fiVcnWDSFbW4t+QKiYJlfVcV2vSS1QX0DvumL7je6AXsfyvX/Vqq1ql9vX7KoFKht8X7pOaEqxquQjNZoBdNnRCxuLkrsnF5HXVXrEO3evq/MsXIbNkyRATfGnlQhrCfNtu+Kjtfrm3uj4f2t1nzgYMBO1vlFHh7IxcjrXT2nGo5CbfLlFKLkj0Ek/1TJ9u6W6y9aJ1BeRchSEDlGW3l8KQnthBe18lL2zQClUNrM4x6GegnOr56OKnSs+14If5eFSAwEyBgJm1QKOgDZoxU/MeOpa4A1v7Fdju++PYUQ 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: On Fri, 27 Sept 2024 at 10:53, Mathieu Desnoyers wrote: > > > (b) the value barrier needs to be on *both* values so that the order > > of the equality testing doesn't matter. > > If we use OPTIMIZER_HIDE_VAR() on both parameters, it indeed minimizes > the odds that someone get the order wrong, but it disallows using > ADDRESS_EQ() with a constant parameter No it doesn't. This is trivial - just hide the source of the *comparison*, so that the compiler doesn't know what you are comparing, and can't use it to then replace one with the other: static __always_inline bool compare_ptr(const volatile void *a, const volatile void *b) { OPTIMIZER_HIDE_VAR(a); OPTIMIZER_HIDE_VAR(b); return a == b; } compares two arbitrary pointer values without allowing the compiler to then use the comparison result to use either of the original values as a replacement for the other. And yes, that "hide both" model will cause a bit more register pressure, because the compiler will now compare two values that it really thinks are potentially different from the originals. So you'll have two "useless" temporaries that contain the same values as the source pointers, but if that's the cost of having a comparison that the compiler can't see, that's fine. Making it a bit less obvious, you can hide just one of the variables - you don't actually need to hide both m(but for clarity, maybe you want to). Because even hiding the value one from the compiler will mean that it can't use the comparison to decide that the originals are equal, even if one of them is unhidden. No? Linus