Skip to content

Commit 1a5c134

Browse files
committed
sem: Move struct sem and struct sem_array into ipc/sem.c
All of the users are now in ipc/sem.c so make the definitions local to that file to make code maintenance easier. AKA to prevent rebuilding the entire kernel when one of these files is changed. Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent d8c6e85 commit 1a5c134

File tree

2 files changed

+35
-39
lines changed

2 files changed

+35
-39
lines changed

include/linux/sem.h

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,10 @@
22
#ifndef _LINUX_SEM_H
33
#define _LINUX_SEM_H
44

5-
#include <linux/atomic.h>
6-
#include <linux/rcupdate.h>
7-
#include <linux/cache.h>
8-
#include <linux/time64.h>
95
#include <uapi/linux/sem.h>
106

117
struct task_struct;
12-
13-
/* One semaphore structure for each semaphore in the system. */
14-
struct sem {
15-
int semval; /* current value */
16-
/*
17-
* PID of the process that last modified the semaphore. For
18-
* Linux, specifically these are:
19-
* - semop
20-
* - semctl, via SETVAL and SETALL.
21-
* - at task exit when performing undo adjustments (see exit_sem).
22-
*/
23-
int sempid;
24-
spinlock_t lock; /* spinlock for fine-grained semtimedop */
25-
struct list_head pending_alter; /* pending single-sop operations */
26-
/* that alter the semaphore */
27-
struct list_head pending_const; /* pending single-sop operations */
28-
/* that do not alter the semaphore*/
29-
time_t sem_otime; /* candidate for sem_otime */
30-
} ____cacheline_aligned_in_smp;
31-
32-
/* One sem_array data structure for each set of semaphores in the system. */
33-
struct sem_array {
34-
struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */
35-
time64_t sem_ctime; /* create/last semctl() time */
36-
struct list_head pending_alter; /* pending operations */
37-
/* that alter the array */
38-
struct list_head pending_const; /* pending complex operations */
39-
/* that do not alter semvals */
40-
struct list_head list_id; /* undo requests on this array */
41-
int sem_nsems; /* no. of semaphores in array */
42-
int complex_count; /* pending complex operations */
43-
unsigned int use_global_lock;/* >0: global lock required */
44-
45-
struct sem sems[];
46-
} __randomize_layout;
8+
struct sem_undo_list;
479

4810
#ifdef CONFIG_SYSVIPC
4911

ipc/sem.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,40 @@
8888
#include <linux/uaccess.h>
8989
#include "util.h"
9090

91+
/* One semaphore structure for each semaphore in the system. */
92+
struct sem {
93+
int semval; /* current value */
94+
/*
95+
* PID of the process that last modified the semaphore. For
96+
* Linux, specifically these are:
97+
* - semop
98+
* - semctl, via SETVAL and SETALL.
99+
* - at task exit when performing undo adjustments (see exit_sem).
100+
*/
101+
int sempid;
102+
spinlock_t lock; /* spinlock for fine-grained semtimedop */
103+
struct list_head pending_alter; /* pending single-sop operations */
104+
/* that alter the semaphore */
105+
struct list_head pending_const; /* pending single-sop operations */
106+
/* that do not alter the semaphore*/
107+
time_t sem_otime; /* candidate for sem_otime */
108+
} ____cacheline_aligned_in_smp;
109+
110+
/* One sem_array data structure for each set of semaphores in the system. */
111+
struct sem_array {
112+
struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */
113+
time64_t sem_ctime; /* create/last semctl() time */
114+
struct list_head pending_alter; /* pending operations */
115+
/* that alter the array */
116+
struct list_head pending_const; /* pending complex operations */
117+
/* that do not alter semvals */
118+
struct list_head list_id; /* undo requests on this array */
119+
int sem_nsems; /* no. of semaphores in array */
120+
int complex_count; /* pending complex operations */
121+
unsigned int use_global_lock;/* >0: global lock required */
122+
123+
struct sem sems[];
124+
} __randomize_layout;
91125

92126
/* One queue for each sleeping process in the system. */
93127
struct sem_queue {

0 commit comments

Comments
 (0)