hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/connector/cn_proc.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * cn_proc.c - process events connector
34 *
....@@ -5,21 +6,6 @@
56 * Based on cn_fork.c by Guillaume Thouvenin <guillaume.thouvenin@bull.net>
67 * Original copyright notice follows:
78 * Copyright (C) 2005 BULL SA.
8
- *
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
239 */
2410
2511 #include <linux/kernel.h>
....@@ -32,7 +18,7 @@
3218 #include <linux/pid_namespace.h>
3319
3420 #include <linux/cn_proc.h>
35
-#include <linux/locallock.h>
21
+#include <linux/local_lock.h>
3622
3723 /*
3824 * Size of a cn_msg followed by a proc_event structure. Since the
....@@ -53,26 +39,31 @@
5339 static atomic_t proc_event_num_listeners = ATOMIC_INIT(0);
5440 static struct cb_id cn_proc_event_id = { CN_IDX_PROC, CN_VAL_PROC };
5541
56
-/* proc_event_counts is used as the sequence number of the netlink message */
57
-static DEFINE_PER_CPU(__u32, proc_event_counts) = { 0 };
58
-static DEFINE_LOCAL_IRQ_LOCK(send_msg_lock);
42
+/* local_event.count is used as the sequence number of the netlink message */
43
+struct local_event {
44
+ local_lock_t lock;
45
+ __u32 count;
46
+};
47
+static DEFINE_PER_CPU(struct local_event, local_event) = {
48
+ .lock = INIT_LOCAL_LOCK(lock),
49
+};
5950
6051 static inline void send_msg(struct cn_msg *msg)
6152 {
62
- local_lock(send_msg_lock);
53
+ local_lock(&local_event.lock);
6354
64
- msg->seq = __this_cpu_inc_return(proc_event_counts) - 1;
55
+ msg->seq = __this_cpu_inc_return(local_event.count) - 1;
6556 ((struct proc_event *)msg->data)->cpu = smp_processor_id();
6657
6758 /*
68
- * Preemption remains disabled during send to ensure the messages are
69
- * ordered according to their sequence numbers.
59
+ * local_lock() disables preemption during send to ensure the messages
60
+ * are ordered according to their sequence numbers.
7061 *
7162 * If cn_netlink_send() fails, the data is not sent.
7263 */
7364 cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_NOWAIT);
7465
75
- local_unlock(send_msg_lock);
66
+ local_unlock(&local_event.lock);
7667 }
7768
7869 void proc_fork_connector(struct task_struct *task)