[06/28] shmem: Move pr_info to open_fd_of_real_pid()

Submitted by Kirill Tkhai on June 5, 2017, 5:24 p.m.

Details

Message ID 149668345935.25229.16075947820765222094.stgit@localhost.localdomain
State New
Series "Support sockets leaked to child user_ns task"
Headers show

Commit Message

Kirill Tkhai June 5, 2017, 5:24 p.m.
Just to not allocate path buffer twice.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/shmem.c |    5 -----
 criu/util.c  |    1 +
 2 files changed, 1 insertion(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/shmem.c b/criu/shmem.c
index fbfba0060..2af8f8802 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -441,16 +441,11 @@  int collect_shmem(int pid, struct vma_area *vma)
 
 static int shmem_wait_and_open(struct shmem_info *si, VmaEntry *vi)
 {
-	char path[128];
 	int pid, ret;
 
 	pr_info("Waiting for the %lx shmem to appear\n", si->shmid);
 	futex_wait_while(&si->lock, 0);
 
-	snprintf(path, sizeof(path), "/proc/%d/fd/%d",
-		si->pid, si->fd);
-
-	pr_info("Opening shmem [%s] \n", path);
 	pid = pstree_pid_by_virt(si->pid)->real;
 	ret = open_fd_of_real_pid(pid, si->fd, O_RDWR);
 	futex_inc_and_wake(&si->lock);
diff --git a/criu/util.c b/criu/util.c
index 99119c1c3..7ff40e2f8 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -1234,6 +1234,7 @@  int open_fd_of_real_pid(pid_t pid, int fd, int flags)
 	int ret;
 
 	ret = sprintf(path, "%d/fd/%d", pid, fd);
+	pr_info("Opening real [%s]\n", path);
 	if (flags == O_RDONLY)
 		ret = userns_call(fn_open_proc_r, UNS_FDOUT, path, ret + 1, -1);
 	else if (flags == O_WRONLY)

Comments

Andrei Vagin June 6, 2017, 5:22 p.m.
On Mon, Jun 05, 2017 at 08:24:19PM +0300, Kirill Tkhai wrote:
> Just to not allocate path buffer twice.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  criu/shmem.c |    5 -----
>  criu/util.c  |    1 +
>  2 files changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/criu/shmem.c b/criu/shmem.c
> index fbfba0060..2af8f8802 100644
> --- a/criu/shmem.c
> +++ b/criu/shmem.c
> @@ -441,16 +441,11 @@ int collect_shmem(int pid, struct vma_area *vma)
>  
>  static int shmem_wait_and_open(struct shmem_info *si, VmaEntry *vi)
>  {
> -	char path[128];
>  	int pid, ret;
>  
>  	pr_info("Waiting for the %lx shmem to appear\n", si->shmid);
>  	futex_wait_while(&si->lock, 0);
>  
> -	snprintf(path, sizeof(path), "/proc/%d/fd/%d",
> -		si->pid, si->fd);
> -
> -	pr_info("Opening shmem [%s] \n", path);
>  	pid = pstree_pid_by_virt(si->pid)->real;
>  	ret = open_fd_of_real_pid(pid, si->fd, O_RDWR);
>  	futex_inc_and_wake(&si->lock);
> diff --git a/criu/util.c b/criu/util.c
> index 99119c1c3..7ff40e2f8 100644
> --- a/criu/util.c
> +++ b/criu/util.c
> @@ -1234,6 +1234,7 @@ int open_fd_of_real_pid(pid_t pid, int fd, int flags)
>  	int ret;
>  
>  	ret = sprintf(path, "%d/fd/%d", pid, fd);
> +	pr_info("Opening real [%s]\n", path);

I think we ca be a bit more informative here:

Opening /proc/%s on the criu side

>  	if (flags == O_RDONLY)
>  		ret = userns_call(fn_open_proc_r, UNS_FDOUT, path, ret + 1, -1);
>  	else if (flags == O_WRONLY)
>
Kirill Tkhai June 6, 2017, 10:10 p.m.
On 06.06.2017 20:22, Andrei Vagin wrote:
> On Mon, Jun 05, 2017 at 08:24:19PM +0300, Kirill Tkhai wrote:
>> Just to not allocate path buffer twice.
>>
>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>> ---
>>  criu/shmem.c |    5 -----
>>  criu/util.c  |    1 +
>>  2 files changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/criu/shmem.c b/criu/shmem.c
>> index fbfba0060..2af8f8802 100644
>> --- a/criu/shmem.c
>> +++ b/criu/shmem.c
>> @@ -441,16 +441,11 @@ int collect_shmem(int pid, struct vma_area *vma)
>>  
>>  static int shmem_wait_and_open(struct shmem_info *si, VmaEntry *vi)
>>  {
>> -	char path[128];
>>  	int pid, ret;
>>  
>>  	pr_info("Waiting for the %lx shmem to appear\n", si->shmid);
>>  	futex_wait_while(&si->lock, 0);
>>  
>> -	snprintf(path, sizeof(path), "/proc/%d/fd/%d",
>> -		si->pid, si->fd);
>> -
>> -	pr_info("Opening shmem [%s] \n", path);
>>  	pid = pstree_pid_by_virt(si->pid)->real;
>>  	ret = open_fd_of_real_pid(pid, si->fd, O_RDWR);
>>  	futex_inc_and_wake(&si->lock);
>> diff --git a/criu/util.c b/criu/util.c
>> index 99119c1c3..7ff40e2f8 100644
>> --- a/criu/util.c
>> +++ b/criu/util.c
>> @@ -1234,6 +1234,7 @@ int open_fd_of_real_pid(pid_t pid, int fd, int flags)
>>  	int ret;
>>  
>>  	ret = sprintf(path, "%d/fd/%d", pid, fd);
>> +	pr_info("Opening real [%s]\n", path);
> I think we ca be a bit more informative here:
>
> Opening /proc/%s on the criu side

Ok
>
>>  	if (flags == O_RDONLY)
>>  		ret = userns_call(fn_open_proc_r, UNS_FDOUT, path, ret + 1, -1);
>>  	else if (flags == O_WRONLY)
>>