[Devel] [PATCH] properly charge and uncharge shmem
Vladimir Davydov
vdavydov at parallels.com
Tue May 19 01:03:06 PDT 2015
On Mon, May 18, 2015 at 10:57:35PM +0300, panda at cloudlinux.com wrote:
> From: Andrew Perepechko <panda at cloudlinux.com>
>
> Currently, shmem_lock immediately and
> unconditionally uncharges what it has
> just charged for a lock request.
>
> This, indeed, causes a double uncharge
> with something like the following:
>
> shmid = shmget(12345, 8192, IPC_CREAT | 0666);
> rc = shmctl(shmid, SHM_LOCK, NULL);
> shmctl(shmid, IPC_RMID, 0);
>
> with the following in the kernel log:
>
> [ 455.815025] Uncharging too much 2 h 0, res lockedpages ub 0
>
> Signed-off-by: Andrew Perepechko <panda at cloudlinux.com>
> ---
> mm/shmem.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index a6b3e30..d09a230 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1359,11 +1359,13 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user)
> mapping_set_unevictable(file->f_mapping);
> }
> if (!lock && (info->flags & VM_LOCKED) && user) {
> + ub_lockedshm_uncharge(info, inode->i_size);
> user_shm_unlock(inode->i_size, user);
> info->flags &= ~VM_LOCKED;
> mapping_clear_unevictable(file->f_mapping);
> }
> - retval = 0;
> + spin_unlock(&info->lock);
> + return 0;
Yeah, I lost this hunk when porting shmem accounting from RH6. Thank you
for catching it!
Acked-by: Vladimir Davydov <vdavydov at parallels.com>
>
> out_nomem:
> ub_lockedshm_uncharge(info, inode->i_size);
More information about the Devel
mailing list