From nobody Wed Feb 11 08:16:42 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A37FCC77B7D for ; Wed, 10 May 2023 18:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236250AbjEJSS1 (ORCPT ); Wed, 10 May 2023 14:18:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235791AbjEJSSG (ORCPT ); Wed, 10 May 2023 14:18:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D99847ABB; Wed, 10 May 2023 11:17:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2CBD563F7E; Wed, 10 May 2023 18:17:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EB2BC4339B; Wed, 10 May 2023 18:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683742644; bh=M24YCjX89zrGo9hYrVbnM541YXT/QdSaa04NmGeV1Kw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IwNrKLQiM4yEdY6dWQJDqXWcesIHahzZBEqAGGtQ447tYWiSNEApxDQwXUOjpEp6R J+wReUPEoXom8oYdwM6CqS1S2LdicSusW+2/fo373mB/XtrVjEnPSdLSbEDbfgHsbj GJMYhpQEDHxblTH31IUYtifLIMO/tsxJmH4Xjz5I+NvuMKDpu4iY6C7rOJQyR+vzvF dQbx0460xkB/3k7AvmWYCbbkBmUX4GyXue1UKOgK2xQyEdaKbNtUi6s9x6D2kWk8mE EBsBIyMdV+b//2hbywVmq7VxMgxiQvkqiQTTa+VYdP/OtkpzHMmD2JVy1UNjQT7z6C Qru4NcBSFkTWA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id EFA9CCE1F4C; Wed, 10 May 2023 11:17:18 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, akiyks@gmail.com, linux-doc@vger.kernel.org, kernel-team@meta.com, "Paul E. McKenney" , Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland Subject: [PATCH locking/atomic 13/19] locking/atomic: Script to auto-generate acquire, fence, and release headers Date: Wed, 10 May 2023 11:17:11 -0700 Message-Id: <20230510181717.2200934-13-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <19135936-06d7-4705-8bc8-bb31c2a478ca@paulmck-laptop> References: <19135936-06d7-4705-8bc8-bb31c2a478ca@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The scripts/atomic/fallbacks/{acquire,fence,release} scripts require almost identical scripting to automatically generated the required kernel-doci headers. Therefore, provide a single acqrel.sh script that does this work. This new script is to be invoked from each of those scripts using the "." command, and with the shell variable "acqrel" set to either "acquire", "full", or "release". Signed-off-by: Paul E. McKenney Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Mark Rutland --- scripts/atomic/acqrel.sh | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 scripts/atomic/acqrel.sh diff --git a/scripts/atomic/acqrel.sh b/scripts/atomic/acqrel.sh new file mode 100644 index 000000000000..5009a54fdac5 --- /dev/null +++ b/scripts/atomic/acqrel.sh @@ -0,0 +1,67 @@ +echo ${args} | tr -d ' ' | tr ',' '\012' | + awk -v atomic=3D${atomic} \ + -v name_op=3D${name} \ + -v ret=3D${ret} \ + -v oldnew=3D${docbook_oldnew} \ + -v acqrel=3D${acqrel} \ + -v basefuncname=3Darch_${atomic}_${pfx}${name}${sfx} ' + BEGIN { + print "/**"; + sfxord =3D "_" acqrel; + if (acqrel =3D=3D "full") + sfxord =3D ""; + print " * " basefuncname sfxord " - Atomic " name_op " with " acqrel " o= rdering"; + longname["add"] =3D "add"; + longname["sub"] =3D "subtract"; + longname["inc"] =3D "increment"; + longname["dec"] =3D "decrement"; + longname["and"] =3D "AND"; + longname["andnot"] =3D "complement then AND"; + longname["or"] =3D "OR"; + longname["xor"] =3D "XOR"; + longname["xchg"] =3D "exchange"; + longname["add_negative"] =3D "add"; + desc["i"] =3D "value to " longname[name_op]; + desc["v"] =3D "pointer of type " atomic "_t"; + desc["old"] =3D "desired old value to match"; + desc["new"] =3D "new value to put in"; + opmod =3D "with"; + if (name_op =3D=3D "add") + opmod =3D "to"; + else if (name_op =3D=3D "sub") + opmod =3D "from"; + } + + { + print " * @" $1 ": " desc[$1]; + have[$1] =3D 1; + } + + END { + print " *"; + if (name_op ~ /cmpxchg/) { + print " * Atomically compares @new to *@v, and if equal,"; + print " * stores @new to *@v, providing " acqrel " ordering."; + } else if (have["i"]) { + print " * Atomically " longname[name_op] " @i " opmod " @v using " acqr= el " ordering."; + } else { + print " * Atomically " longname[name_op] " @v using " acqrel " ordering= ."; + } + if (name_op ~ /cmpxchg/ && ret =3D=3D "bool") { + print " * Returns @true if the cmpxchg operation succeeded,"; + print " * and false otherwise. Either way, stores the old"; + print " * value of *@v to *@old."; + } else if (name_op =3D=3D "cmpxchg") { + print " * Returns the old value *@v regardless of the result of"; + print " * the comparison. Therefore, if the return value is not"; + print " * equal to @old, the cmpxchg operation failed."; + } else if (name_op =3D=3D "xchg") { + print " * Return old value."; + } else if (name_op =3D=3D "add_negative") { + print " * Return @true if the result is negative, or @false when" + print " * the result is greater than or equal to zero."; + } else { + print " * Return " oldnew " value."; + } + print " */"; + }' --=20 2.40.1