Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7729874rwr; Wed, 10 May 2023 11:46:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Tq90HMk+e729nA1UE/S5+mfmQyWlyXnQHoAroB+rCx47uorFNon8HzWiMPCMyJXvJOEUb X-Received: by 2002:a17:90a:1f49:b0:250:bc7e:c3b2 with SMTP id y9-20020a17090a1f4900b00250bc7ec3b2mr5820259pjy.42.1683744382007; Wed, 10 May 2023 11:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683744381; cv=none; d=google.com; s=arc-20160816; b=TIh5Skj7n5LLNwLN4FDT8gk8sey01MJY8+22BbDygPKTxZhUsfqF7zOHAmjKYLdxkr r/dnhqChdPMQuJtNRBNjIAtI+BQQj4hHe4VyMe6I5/MOTvKWh0vkeITXtPWvYISBhiEP 6FFFIr1+xm3n27Z6/Kf84HvyZzXxlBWUwpjhKv7A0NP0NvcXAiPUymwhhmkE0QAnGcYN C+HebehL8jfnE82QbUL1BPfD5zunN+ad4y48qinHLgHm3rah9CsC7dyI6cEZGpwfxS2i WivGpCKDNc1u+a8mFLB5ibnBKIGkgZjB/0cOTyIR1nqh6POGzUDY9tt83JRZ49963WnF a+0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5xB9zgrPGRFH2AfNBD6V0/7nLP242FIxDrR/4YI5MyA=; b=GFC7LJUvUaIhL+Q2+2wHuRaHLfmDKVw+nWN2Pz8iwZ4w9Flk2ckjEWIgrGY1+qpwMX jvnHZ0r21hr60lAihIh/3KteedQI6ch+mY13AasNP0OnTde+U99pL17nt/+jXaghZtru 5Ar5IAQkcP8UrcynvJcxYasI3MV/CvtgQWRaxB+4RlpNmOh6CsFU786dtJYjub4mjw1P 7WZSnOkGtvu1BEcmYeGphT9Jw5uIaT5kHtLik7BqJPGD1myClGmxHoYvjCckaLtFrrZM Ra5QmlS9iwUUvkK96CW3L9fwvUW6HcPnrStKFRRLfclE0bAhhc01XHMyP+tPAb2OZG2T HvDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IwNrKLQi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw14-20020a17090b4d0e00b002467eaf62e0si18116722pjb.178.2023.05.10.11.46.09; Wed, 10 May 2023 11:46:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IwNrKLQi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236240AbjEJSS0 (ORCPT + 99 others); Wed, 10 May 2023 14:18:26 -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: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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=${atomic} \ + -v name_op=${name} \ + -v ret=${ret} \ + -v oldnew=${docbook_oldnew} \ + -v acqrel=${acqrel} \ + -v basefuncname=arch_${atomic}_${pfx}${name}${sfx} ' + BEGIN { + print "/**"; + sfxord = "_" acqrel; + if (acqrel == "full") + sfxord = ""; + print " * " basefuncname sfxord " - Atomic " name_op " with " acqrel " ordering"; + longname["add"] = "add"; + longname["sub"] = "subtract"; + longname["inc"] = "increment"; + longname["dec"] = "decrement"; + longname["and"] = "AND"; + longname["andnot"] = "complement then AND"; + longname["or"] = "OR"; + longname["xor"] = "XOR"; + longname["xchg"] = "exchange"; + longname["add_negative"] = "add"; + desc["i"] = "value to " longname[name_op]; + desc["v"] = "pointer of type " atomic "_t"; + desc["old"] = "desired old value to match"; + desc["new"] = "new value to put in"; + opmod = "with"; + if (name_op == "add") + opmod = "to"; + else if (name_op == "sub") + opmod = "from"; + } + + { + print " * @" $1 ": " desc[$1]; + have[$1] = 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 " acqrel " ordering."; + } else { + print " * Atomically " longname[name_op] " @v using " acqrel " ordering."; + } + if (name_op ~ /cmpxchg/ && ret == "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 == "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 == "xchg") { + print " * Return old value."; + } else if (name_op == "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 " */"; + }' -- 2.40.1