Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1739197
| From | Gargi Sharma <gs051095@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/4] pid: Replace pid bitmap implementation with IDR API |
| Date | 2017-09-25 19:50 +0200 |
| Message-ID | <utFG2-198-15@gated-at.bofh.it> (permalink) |
| References | <utB9n-6tv-9@gated-at.bofh.it> <utB9o-6tv-17@gated-at.bofh.it> <utD1v-7Jk-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Sep 25, 2017 at 8:29 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> On 09/25, Gargi Sharma wrote:
>>
>> void zap_pid_ns_processes(struct pid_namespace *pid_ns)
>> {
>> - int nr;
>> + int nr = 2;
>> int rc;
>> struct task_struct *task, *me = current;
>> int init_pids = thread_group_leader(me) ? 1 : 2;
>> + struct pid *pid;
>>
>> /* Don't allow any more processes into the pid namespace */
>> disable_pid_allocation(pid_ns);
>> @@ -240,8 +230,8 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
>> *
>> */
>> read_lock(&tasklist_lock);
>> - nr = next_pidmap(pid_ns, 1);
>> - while (nr > 0) {
>> + pid = idr_get_next(&pid_ns->idr, &nr);
>> + while (pid) {
>> rcu_read_lock();
>>
>> task = pid_task(find_vpid(nr), PIDTYPE_PID);
>> @@ -250,7 +240,8 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
>>
>> rcu_read_unlock();
>>
>> - nr = next_pidmap(pid_ns, nr);
>> + nr++;
>> + pid = idr_get_next(&pid_ns->idr, &nr);
>> }
>> read_unlock(&tasklist_lock);
>
> Then you should probably rewrite this code using idr_for_each_entry_continue() ?
Yes, I missed this macro in the idr library.
>
> And why do you need find_vpid(nr) if you already have "pid" ?
Thanks for the feedback! Yes, it is not needed anymore and can be removed.
Best,
Gargi
>
> Oleg.
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/4] pid: Replace pid bitmap implementation with IDR API Gargi Sharma <gs051095@gmail.com> - 2017-09-25 15:00 +0200
Re: [PATCH 1/4] pid: Replace pid bitmap implementation with IDR API Rik van Riel <riel@surriel.com> - 2017-09-25 15:20 +0200
Re: [PATCH 1/4] pid: Replace pid bitmap implementation with IDR API Oleg Nesterov <oleg@redhat.com> - 2017-09-25 17:00 +0200
Re: [PATCH 1/4] pid: Replace pid bitmap implementation with IDR API Gargi Sharma <gs051095@gmail.com> - 2017-09-25 19:50 +0200
Re: [PATCH 1/4] pid: Replace pid bitmap implementation with IDR API Oleg Nesterov <oleg@redhat.com> - 2017-09-25 17:30 +0200
Re: [PATCH 1/4] pid: Replace pid bitmap implementation with IDR API Gargi Sharma <gs051095@gmail.com> - 2017-09-25 19:50 +0200
csiph-web