.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * cn_proc.c - process events connector |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * Based on cn_fork.c by Guillaume Thouvenin <guillaume.thouvenin@bull.net> |
---|
6 | 7 | * Original copyright notice follows: |
---|
7 | 8 | * 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 |
---|
23 | 9 | */ |
---|
24 | 10 | |
---|
25 | 11 | #include <linux/kernel.h> |
---|
.. | .. |
---|
32 | 18 | #include <linux/pid_namespace.h> |
---|
33 | 19 | |
---|
34 | 20 | #include <linux/cn_proc.h> |
---|
35 | | -#include <linux/locallock.h> |
---|
| 21 | +#include <linux/local_lock.h> |
---|
36 | 22 | |
---|
37 | 23 | /* |
---|
38 | 24 | * Size of a cn_msg followed by a proc_event structure. Since the |
---|
.. | .. |
---|
53 | 39 | static atomic_t proc_event_num_listeners = ATOMIC_INIT(0); |
---|
54 | 40 | static struct cb_id cn_proc_event_id = { CN_IDX_PROC, CN_VAL_PROC }; |
---|
55 | 41 | |
---|
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 | +}; |
---|
59 | 50 | |
---|
60 | 51 | static inline void send_msg(struct cn_msg *msg) |
---|
61 | 52 | { |
---|
62 | | - local_lock(send_msg_lock); |
---|
| 53 | + local_lock(&local_event.lock); |
---|
63 | 54 | |
---|
64 | | - msg->seq = __this_cpu_inc_return(proc_event_counts) - 1; |
---|
| 55 | + msg->seq = __this_cpu_inc_return(local_event.count) - 1; |
---|
65 | 56 | ((struct proc_event *)msg->data)->cpu = smp_processor_id(); |
---|
66 | 57 | |
---|
67 | 58 | /* |
---|
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. |
---|
70 | 61 | * |
---|
71 | 62 | * If cn_netlink_send() fails, the data is not sent. |
---|
72 | 63 | */ |
---|
73 | 64 | cn_netlink_send(msg, 0, CN_IDX_PROC, GFP_NOWAIT); |
---|
74 | 65 | |
---|
75 | | - local_unlock(send_msg_lock); |
---|
| 66 | + local_unlock(&local_event.lock); |
---|
76 | 67 | } |
---|
77 | 68 | |
---|
78 | 69 | void proc_fork_connector(struct task_struct *task) |
---|