From 03ba4131783cc9e872f8bb26a03f15bc11f27564 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Sat, 19 Sep 1998 19:15:08 +0000 Subject: - Merge with Linux 2.1.121. - Bugfixes. --- ipc/sem.c | 10 +++++----- ipc/shm.c | 38 +++++++++++++++++++++++++++++++++++++- ipc/util.c | 6 +++++- 3 files changed, 47 insertions(+), 7 deletions(-) (limited to 'ipc') diff --git a/ipc/sem.c b/ipc/sem.c index 0ab578584..655047cf2 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -56,7 +56,7 @@ static int max_semid = 0; static unsigned short sem_seq = 0; -__initfunc(void sem_init (void)) +void __init sem_init (void) { int i; @@ -466,10 +466,10 @@ asmlinkage int sys_semctl (int semid, int semnum, int cmd, union semun arg) if (ipcperms (ipcp, S_IRUGO)) goto out; switch (cmd) { - case GETVAL : return curr->semval; - case GETPID : return curr->sempid; - case GETNCNT: return count_semncnt(sma,semnum); - case GETZCNT: return count_semzcnt(sma,semnum); + case GETVAL : err = curr->semval; goto out; + case GETPID : err = curr->sempid; goto out; + case GETNCNT: err = count_semncnt(sma,semnum); goto out; + case GETZCNT: err = count_semzcnt(sma,semnum); goto out; case GETALL: array = arg.array; break; diff --git a/ipc/shm.c b/ipc/shm.c index c7568b784..0ec61b1e3 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -3,6 +3,7 @@ * Copyright (C) 1992, 1993 Krishna Balasubramanian * Many improvements/fixes by Bruno Haible. * Replaced `struct shm_desc' by `struct vm_area_struct', July 1994. + * Fixed the shm swap deallocation (shm_unuse()), August 1998 Andrea Arcangeli. */ #include @@ -45,7 +46,7 @@ static ulong swap_attempts = 0; static ulong swap_successes = 0; static ulong used_segs = 0; -__initfunc(void shm_init (void)) +void __init shm_init (void) { int id; @@ -837,3 +838,38 @@ int shm_swap (int prio, int gfp_mask) shm_rss--; return 1; } + +/* + * Free the swap entry and set the new pte for the shm page. + */ +static void shm_unuse_page(struct shmid_ds *shp, unsigned long idx, + unsigned long page, unsigned long entry) +{ + pte_t pte; + + pte = pte_mkdirty(mk_pte(page, PAGE_SHARED)); + shp->shm_pages[idx] = pte_val(pte); + atomic_inc(&mem_map[MAP_NR(page)].count); + shm_rss++; + + swap_free(entry); + shm_swp--; +} + +/* + * unuse_shm() search for an eventually swapped out shm page. + */ +void shm_unuse(unsigned long entry, unsigned long page) +{ + int i, n; + + for (i = 0; i < SHMMNI; i++) + if (shm_segs[i] != IPC_UNUSED && shm_segs[i] != IPC_NOID) + for (n = 0; n < shm_segs[i]->shm_npages; n++) + if (shm_segs[i]->shm_pages[n] == entry) + { + shm_unuse_page(shm_segs[i], n, + page, entry); + return; + } +} diff --git a/ipc/util.c b/ipc/util.c index c7933273a..7cb2f24dd 100644 --- a/ipc/util.c +++ b/ipc/util.c @@ -24,7 +24,7 @@ extern void sem_init (void), msg_init (void), shm_init (void); -__initfunc(void ipc_init (void)) +void __init ipc_init (void) { sem_init(); msg_init(); @@ -125,4 +125,8 @@ asmlinkage int sys_shmctl (int shmid, int cmd, struct shmid_ds *buf) return -ENOSYS; } +void shm_unuse(unsigned long entry, unsigned long page) +{ +} + #endif /* CONFIG_SYSVIPC */ -- cgit v1.2.3