akpm@xxxxxxxxxxxxxxxxxxxx writes: > The patch titled > Subject: kernel/fork.c: unshare(): use swap() to make code cleaner > has been added to the -mm tree. Its filename is > unshare-use-swap-to-make-code-cleaner.patch > > This patch should soon appear at > https://ozlabs.org/~akpm/mmots/broken-out/unshare-use-swap-to-make-code-cleaner.patch > and later at > https://ozlabs.org/~akpm/mmotm/broken-out/unshare-use-swap-to-make-code-cleaner.patch > > Before you just go and hit "reply", please: > a) Consider who else should be cc'ed > b) Prefer to cc a suitable mailing list as well > c) Ideally: find the original patch on the mailing list and do a > reply-to-all to that, adding suitable additional cc's > > *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** > > The -mm tree is included into linux-next and is updated > there every 3-4 working days Why is the swap macro spelled in lower case? Given that there is no way to write swap as a function I would think we would want to write SWAP instead of swap to make it clear swap is a macro. Eric > ------------------------------------------------------ > From: Ran Xiaokai <ran.xiaokai@xxxxxxxxxx> > Subject: kernel/fork.c: unshare(): use swap() to make code cleaner > > Use swap() instead of reimplementing it. > > Link: https://lkml.kernel.org/r/20210909022046.8151-1-ran.xiaokai@xxxxxxxxxx > Signed-off-by: Ran Xiaokai <ran.xiaokai@xxxxxxxxxx> > Cc: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxx> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> > Cc: Eric W. Biederman <ebiederm@xxxxxxxxxxxx> > Cc: Jens Axboe <axboe@xxxxxxxxx> > Cc: Alexey Gladkov <legion@xxxxxxxxxx> > Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > --- > > kernel/fork.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > --- a/kernel/fork.c~unshare-use-swap-to-make-code-cleaner > +++ a/kernel/fork.c > @@ -3078,7 +3078,7 @@ int unshare_fd(unsigned long unshare_fla > int ksys_unshare(unsigned long unshare_flags) > { > struct fs_struct *fs, *new_fs = NULL; > - struct files_struct *fd, *new_fd = NULL; > + struct files_struct *new_fd = NULL; > struct cred *new_cred = NULL; > struct nsproxy *new_nsproxy = NULL; > int do_sysvsem = 0; > @@ -3165,11 +3165,8 @@ int ksys_unshare(unsigned long unshare_f > spin_unlock(&fs->lock); > } > > - if (new_fd) { > - fd = current->files; > - current->files = new_fd; > - new_fd = fd; > - } > + if (new_fd) > + swap(current->files, new_fd); > > task_unlock(current); > > _ > > Patches currently in -mm which might be from ran.xiaokai@xxxxxxxxxx are > > unshare-use-swap-to-make-code-cleaner.patch