lkml.org 
[lkml]   [2012]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v3] staging: android/lowmemorykiller: Don't grab tasklist_lock
    On 02/03, Anton Vorontsov wrote:
    >
    > @@ -132,7 +133,7 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
    > }
    > selected_oom_adj = min_adj;
    >
    > - read_lock(&tasklist_lock);
    > + rcu_read_lock();
    > for_each_process(p) {
    > struct mm_struct *mm;
    > struct signal_struct *sig;
    > @@ -180,12 +181,12 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
    > lowmem_deathpending = selected;
    > task_handoff_register(&task_nb);
    > #endif
    > - force_sig(SIGKILL, selected);
    > + send_sig(SIGKILL, selected, 0);
    > rem -= selected_tasksize;
    > }
    > lowmem_print(4, "lowmem_shrink %lu, %x, return %d\n",
    > sc->nr_to_scan, sc->gfp_mask, rem);
    > - read_unlock(&tasklist_lock);
    > + rcu_read_unlock();

    I think this is correct. As for ->mm check please look at
    find_lock_task_mm().

    You can also remove the !sig check.

    And, forgot to mention. There is another reason why mm != NULL
    check is wrong (send_sig_all too). A kernel thread can do use_mm().
    You should also check PF_KTHREAD.

    Oleg.



    \
     
     \ /
      Last update: 2012-02-03 17:45    [W:3.093 / U:0.292 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site