Commit a2155fcc65fbf5d0c49a263fac855c831ee17a99

Authored by balrog
1 parent cb3bc233

Swap only altered elements of the grouplist in getgroups() (Kirill Shutemov).

getgroups() returns the number of supplementary group IDs, so it's
unnessary to swap the entire array.  It can dramatically speed up
the syscall: on recent Linux kernels NGROUPS_MAX=65536.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5267 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 2 additions and 2 deletions
linux-user/syscall.c
... ... @@ -5253,7 +5253,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
5253 5253 target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);
5254 5254 if (!target_grouplist)
5255 5255 goto efault;
5256   - for(i = 0;i < gidsetsize; i++)
  5256 + for(i = 0;i < ret; i++)
5257 5257 target_grouplist[i] = tswap16(grouplist[i]);
5258 5258 unlock_user(target_grouplist, arg2, gidsetsize * 2);
5259 5259 }
... ... @@ -5407,7 +5407,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
5407 5407 ret = -TARGET_EFAULT;
5408 5408 goto fail;
5409 5409 }
5410   - for(i = 0;i < gidsetsize; i++)
  5410 + for(i = 0;i < ret; i++)
5411 5411 target_grouplist[i] = tswap32(grouplist[i]);
5412 5412 unlock_user(target_grouplist, arg2, gidsetsize * 4);
5413 5413 }
... ...