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 7/7] kobject: convert uevent_seqnum to seqnum_ops Date: Wed, 3 Feb 2021 11:12:03 -0700 [thread overview] Message-ID: <3ddd122c266e8cb460542d852e9b703c6eef2141.1612314468.git.skhan@linuxfoundation.org> (raw) In-Reply-To: <cover.1612314468.git.skhan@linuxfoundation.org> Sequence Number api provides interfaces for unsigned atomic up counters leveraging atomic_t and atomic64_t ops underneath. Convert uevent_seqnum atomic counter to use seqnum_ops. Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> --- include/linux/kobject.h | 3 ++- kernel/ksysfs.c | 3 ++- lib/kobject_uevent.c | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index ea30529fba08..8990e40344a2 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -27,6 +27,7 @@ #include <linux/atomic.h> #include <linux/workqueue.h> #include <linux/uidgid.h> +#include <linux/seqnum_ops.h> #define UEVENT_HELPER_PATH_LEN 256 #define UEVENT_NUM_ENVP 64 /* number of env pointers */ @@ -38,7 +39,7 @@ extern char uevent_helper[]; #endif /* counter to tag the uevent, read only except for the kobject core */ -extern u64 uevent_seqnum; +extern struct seqnum64 uevent_seqnum; /* * The actions here must match the index to the string array diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 35859da8bd4f..15836f6e5998 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -17,6 +17,7 @@ #include <linux/sched.h> #include <linux/capability.h> #include <linux/compiler.h> +#include <linux/seqnum_ops.h> #include <linux/rcupdate.h> /* rcu_expedited and rcu_normal */ @@ -31,7 +32,7 @@ static struct kobj_attribute _name##_attr = \ static ssize_t uevent_seqnum_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - return sprintf(buf, "%llu\n", (unsigned long long)uevent_seqnum); + return sprintf(buf, "%llu\n", seqnum64_get(&uevent_seqnum)); } KERNEL_ATTR_RO(uevent_seqnum); diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 7998affa45d4..3a7b2648f084 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -28,9 +28,10 @@ #include <net/sock.h> #include <net/netlink.h> #include <net/net_namespace.h> +#include <linux/seqnum_ops.h> -u64 uevent_seqnum; +struct seqnum64 uevent_seqnum; #ifdef CONFIG_UEVENT_HELPER char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; #endif @@ -584,7 +585,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, mutex_lock(&uevent_sock_mutex); /* we will send an event, so request a new sequence number */ - retval = add_uevent_var(env, "SEQNUM=%llu", ++uevent_seqnum); + retval = add_uevent_var(env, "SEQNUM=%llu", + seqnum64_inc(&uevent_seqnum)); if (retval) { mutex_unlock(&uevent_sock_mutex); goto exit; @@ -687,7 +689,8 @@ static int uevent_net_broadcast(struct sock *usk, struct sk_buff *skb, int ret; /* bump and prepare sequence number */ - ret = snprintf(buf, sizeof(buf), "SEQNUM=%llu", ++uevent_seqnum); + ret = snprintf(buf, sizeof(buf), "SEQNUM=%llu", + seqnum64_inc(&uevent_seqnum)); if (ret < 0 || (size_t)ret >= sizeof(buf)) return -ENOMEM; ret++; -- 2.27.0
WARNING: multiple messages have this Message-ID (diff)
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: devel@driverdev.osuosl.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan <skhan@linuxfoundation.org> Subject: [PATCH v3 7/7] kobject: convert uevent_seqnum to seqnum_ops Date: Wed, 3 Feb 2021 11:12:03 -0700 [thread overview] Message-ID: <3ddd122c266e8cb460542d852e9b703c6eef2141.1612314468.git.skhan@linuxfoundation.org> (raw) In-Reply-To: <cover.1612314468.git.skhan@linuxfoundation.org> Sequence Number api provides interfaces for unsigned atomic up counters leveraging atomic_t and atomic64_t ops underneath. Convert uevent_seqnum atomic counter to use seqnum_ops. Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> --- include/linux/kobject.h | 3 ++- kernel/ksysfs.c | 3 ++- lib/kobject_uevent.c | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index ea30529fba08..8990e40344a2 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -27,6 +27,7 @@ #include <linux/atomic.h> #include <linux/workqueue.h> #include <linux/uidgid.h> +#include <linux/seqnum_ops.h> #define UEVENT_HELPER_PATH_LEN 256 #define UEVENT_NUM_ENVP 64 /* number of env pointers */ @@ -38,7 +39,7 @@ extern char uevent_helper[]; #endif /* counter to tag the uevent, read only except for the kobject core */ -extern u64 uevent_seqnum; +extern struct seqnum64 uevent_seqnum; /* * The actions here must match the index to the string array diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 35859da8bd4f..15836f6e5998 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -17,6 +17,7 @@ #include <linux/sched.h> #include <linux/capability.h> #include <linux/compiler.h> +#include <linux/seqnum_ops.h> #include <linux/rcupdate.h> /* rcu_expedited and rcu_normal */ @@ -31,7 +32,7 @@ static struct kobj_attribute _name##_attr = \ static ssize_t uevent_seqnum_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - return sprintf(buf, "%llu\n", (unsigned long long)uevent_seqnum); + return sprintf(buf, "%llu\n", seqnum64_get(&uevent_seqnum)); } KERNEL_ATTR_RO(uevent_seqnum); diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 7998affa45d4..3a7b2648f084 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -28,9 +28,10 @@ #include <net/sock.h> #include <net/netlink.h> #include <net/net_namespace.h> +#include <linux/seqnum_ops.h> -u64 uevent_seqnum; +struct seqnum64 uevent_seqnum; #ifdef CONFIG_UEVENT_HELPER char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; #endif @@ -584,7 +585,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, mutex_lock(&uevent_sock_mutex); /* we will send an event, so request a new sequence number */ - retval = add_uevent_var(env, "SEQNUM=%llu", ++uevent_seqnum); + retval = add_uevent_var(env, "SEQNUM=%llu", + seqnum64_inc(&uevent_seqnum)); if (retval) { mutex_unlock(&uevent_sock_mutex); goto exit; @@ -687,7 +689,8 @@ static int uevent_net_broadcast(struct sock *usk, struct sk_buff *skb, int ret; /* bump and prepare sequence number */ - ret = snprintf(buf, sizeof(buf), "SEQNUM=%llu", ++uevent_seqnum); + ret = snprintf(buf, sizeof(buf), "SEQNUM=%llu", + seqnum64_inc(&uevent_seqnum)); if (ret < 0 || (size_t)ret >= sizeof(buf)) return -ENOMEM; ret++; -- 2.27.0 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2021-02-03 18:19 UTC|newest] Thread overview: 28+ 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 ` Shuah Khan 2021-02-03 18:11 ` [PATCH v3 1/7] seqnum_ops: " Shuah Khan 2021-02-03 18:11 ` Shuah Khan 2021-02-04 9:20 ` Peter Zijlstra 2021-02-04 9:20 ` Peter Zijlstra 2021-02-05 9:58 ` Greg KH 2021-02-05 9:58 ` Greg KH 2021-02-05 20:03 ` Shuah Khan 2021-02-05 20:03 ` Shuah Khan 2021-02-05 22:16 ` Luck, Tony 2021-02-05 22:16 ` Luck, Tony 2021-02-08 3:55 ` Randy Dunlap 2021-02-08 3:55 ` Randy Dunlap 2021-02-03 18:11 ` [PATCH v3 2/7] selftests: lib:test_seqnum_ops: add new test for seqnum_ops Shuah Khan 2021-02-03 18:11 ` Shuah Khan 2021-02-03 18:11 ` [PATCH v3 3/7] drivers/acpi: convert seqno to use seqnum_ops Shuah Khan 2021-02-03 18:11 ` Shuah Khan 2021-02-04 14:01 ` Rafael J. Wysocki 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 ` 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 ` Shuah Khan 2021-02-03 18:12 ` [PATCH v3 6/7] drivers/staging/rtl8188eu: " Shuah Khan 2021-02-03 18:12 ` Shuah Khan 2021-02-03 18:12 ` Shuah Khan [this message] 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=3ddd122c266e8cb460542d852e9b703c6eef2141.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.