From: Shuah Khan <skhan@linuxfoundation.org>
To: corbet@lwn.net, gregkh@linuxfoundation.org, peterz@infradead.org,
keescook@chromium.org, rafael@kernel.org, lenb@kernel.org,
james.morse@arm.com, tony.luck@intel.com, bp@alien8.de
Cc: Shuah Khan <skhan@linuxfoundation.org>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-acpi@vger.kernel.org, linux-kselftest@vger.kernel.org,
devel@driverdev.osuosl.org
Subject: [PATCH v3 2/7] selftests: lib:test_seqnum_ops: add new test for seqnum_ops
Date: Wed, 3 Feb 2021 11:11:58 -0700 [thread overview]
Message-ID: <08e6ceb7608d008faf9e28e4f08361af5618cf07.1612314468.git.skhan@linuxfoundation.org> (raw)
In-Reply-To: <cover.1612314468.git.skhan@linuxfoundation.org>
Add a new selftest for testing seqnum_ops. This test loads test_seqnum_ops
test module and unloads it. The test module runs tests and prints results
to dmesg.
Sequence Number api provides interfaces for unsigned atomic up counters
leveraging atomic_t and atomic64_t ops underneath.
There are a number of atomic_t usages in the kernel where atomic_t api
is used for counting sequence numbers and other statistical counters.
Several of these usages, convert atomic_read() and atomic_inc_return()
return values to unsigned. Introducing sequence number ops supports
these use-cases with a standard core-api.
Sequence Number ops provide interfaces to initialize, increment and get
the sequence number. These ops also check for overflow and log message to
indicate when overflow occurs.
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
Documentation/core-api/seqnum_ops.rst | 9 +++++++++
MAINTAINERS | 1 +
include/linux/seqnum_ops.h | 2 ++
tools/testing/selftests/lib/Makefile | 1 +
tools/testing/selftests/lib/config | 1 +
tools/testing/selftests/lib/test_seqnum_ops.sh | 10 ++++++++++
6 files changed, 24 insertions(+)
create mode 100755 tools/testing/selftests/lib/test_seqnum_ops.sh
diff --git a/Documentation/core-api/seqnum_ops.rst b/Documentation/core-api/seqnum_ops.rst
index ed4eba394799..6db2c9120885 100644
--- a/Documentation/core-api/seqnum_ops.rst
+++ b/Documentation/core-api/seqnum_ops.rst
@@ -51,3 +51,12 @@ Returns sequence number value. ::
.. warning::
seqnum32 wraps around to INT_MIN when it overflows.
+
+Where are the seqnum_ops and how to use and test them?
+------------------------------------------------------
+
+.. kernel-doc:: include/linux/seqnum_ops.h
+
+Please see lib/test_seqnum_ops.c for examples usages and test module.
+Please find selftest: testing/selftests/lib/test_seqnum_ops.sh
+Please check dmesg for results after running test_seqnum_ops.sh.
diff --git a/MAINTAINERS b/MAINTAINERS
index f9fe1438a8cd..70b9eeb995f7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16241,6 +16241,7 @@ L: linux-kernel@vger.kernel.org
S: Maintained
F: include/linux/seqnum_ops.h
F: lib/test_seqnum_ops.c
+F: tools/testing/selftests/lib/test_seqnum_ops.sh
SIMPLE FIRMWARE INTERFACE (SFI)
S: Obsolete
diff --git a/include/linux/seqnum_ops.h b/include/linux/seqnum_ops.h
index e8d8481445d3..d540b62d1aa4 100644
--- a/include/linux/seqnum_ops.h
+++ b/include/linux/seqnum_ops.h
@@ -18,6 +18,8 @@
*
* Reference and API guide:
* Documentation/core-api/seqnum_ops.rst for more information.
+ * lib/test_seqnum_ops.c - example usages and test module
+ * tools/testing/selftests/lib/test_seqnum_ops.sh
*/
#ifndef __LINUX_SEQNUM_OPS_H
diff --git a/tools/testing/selftests/lib/Makefile b/tools/testing/selftests/lib/Makefile
index a105f094676e..1818444f0e97 100644
--- a/tools/testing/selftests/lib/Makefile
+++ b/tools/testing/selftests/lib/Makefile
@@ -5,5 +5,6 @@
all:
TEST_PROGS := printf.sh bitmap.sh prime_numbers.sh strscpy.sh
+TEST_PROGS += test_seqnum_ops.sh
include ../lib.mk
diff --git a/tools/testing/selftests/lib/config b/tools/testing/selftests/lib/config
index b80ee3f6e265..674ed2a2ac82 100644
--- a/tools/testing/selftests/lib/config
+++ b/tools/testing/selftests/lib/config
@@ -3,3 +3,4 @@ CONFIG_TEST_BITMAP=m
CONFIG_PRIME_NUMBERS=m
CONFIG_TEST_STRSCPY=m
CONFIG_TEST_BITOPS=m
+CONFIG_TEST_SEQNUM_OPS=m
diff --git a/tools/testing/selftests/lib/test_seqnum_ops.sh b/tools/testing/selftests/lib/test_seqnum_ops.sh
new file mode 100755
index 000000000000..fdce16b220ba
--- /dev/null
+++ b/tools/testing/selftests/lib/test_seqnum_ops.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2020 Shuah Khan <skhan@linuxfoundation.org>
+# Copyright (c) 2020 The Linux Foundation
+#
+# Tests the Sequence Number Ops interfaces using test_seqnum_ops
+# kernel module
+#
+$(dirname $0)/../kselftest/module.sh "test_seqnum_ops" test_seqnum_ops
--
2.27.0
next prev parent reply other threads:[~2021-02-03 18:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-03 18:11 [PATCH v3 0/7] Introduce Sequence Number Ops Shuah Khan
2021-02-03 18:11 ` [PATCH v3 1/7] seqnum_ops: " Shuah Khan
2021-02-04 9:20 ` Peter Zijlstra
2021-02-05 9:58 ` Greg KH
2021-02-05 20:03 ` Shuah Khan
2021-02-05 22:16 ` Luck, Tony
2021-02-08 3:55 ` Randy Dunlap
2021-02-03 18:11 ` Shuah Khan [this message]
2021-02-03 18:11 ` [PATCH v3 3/7] drivers/acpi: convert seqno to use seqnum_ops Shuah Khan
2021-02-04 14:01 ` Rafael J. Wysocki
2021-02-03 18:12 ` [PATCH v3 4/7] drivers/acpi/apei: convert seqno to seqnum_ops Shuah Khan
2021-02-03 18:12 ` [PATCH v3 5/7] drivers/staging/rtl8723bs: convert event_seq to use seqnum_ops Shuah Khan
2021-02-03 18:12 ` [PATCH v3 6/7] drivers/staging/rtl8188eu: " Shuah Khan
2021-02-03 18:12 ` [PATCH v3 7/7] kobject: convert uevent_seqnum to seqnum_ops Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08e6ceb7608d008faf9e28e4f08361af5618cf07.1612314468.git.skhan@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=james.morse@arm.com \
--cc=keescook@chromium.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).