{"push_id":605142521,"size":1,"distinct_size":1,"ref":"refs/heads/lollipop_staging","head":"f5991409d5b09503cd87ca9989d5ec8954fbd0f0","before":"a1738b9c3b91d97c00aed4ddc6f8fcbf35e536ab","commits":[{"sha":"f5991409d5b09503cd87ca9989d5ec8954fbd0f0","author":{"email":"1cad85f151cc543af57dbef9a3c3fce0b81e874a@google.com","name":"Greg Thelen"},"message":"fs/dcache.c: add cond_resched() to shrink_dcache_parent()\n\ncommit 421348f1ca0bf17769dee0aed4d991845ae0536d upstream.\n\nCall cond_resched() in shrink_dcache_parent() to maintain interactivity.\n\nBefore this patch:\n\n\tvoid shrink_dcache_parent(struct dentry * parent)\n\t{\n\t\twhile ((found = select_parent(parent, &dispose)) != 0)\n\t\t\tshrink_dentry_list(&dispose);\n\t}\n\nselect_parent() populates the dispose list with dentries which\nshrink_dentry_list() then deletes.  select_parent() carefully uses\nneed_resched() to avoid doing too much work at once.  But neither\nshrink_dcache_parent() nor its called functions call cond_resched().  So\nonce need_resched() is set select_parent() will return single dentry\ndispose list which is then deleted by shrink_dentry_list().  This is\ninefficient when there are a lot of dentry to process.  This can cause\nsoftlockup and hurts interactivity on non preemptable kernels.\n\nThis change adds cond_resched() in shrink_dcache_parent().  The benefit\nof this is that need_resched() is quickly cleared so that future calls\nto select_parent() are able to efficiently return a big batch of dentry.\n\nThese additional cond_resched() do not seem to impact performance, at\nleast for the workload below.\n\nHere is a program which can cause soft lockup if other system activity\nsets need_resched().\n\n\tint main()\n\t{\n\t        struct rlimit rlim;\n\t        int i;\n\t        int f[100000];\n\t        char buf[20];\n\t        struct timeval t1, t2;\n\t        double diff;\n\n\t        /* cleanup past run */\n\t        system(\"rm -rf x\");\n\n\t        /* boost nfile rlimit */\n\t        rlim.rlim_cur = 200000;\n\t        rlim.rlim_max = 200000;\n\t        if (setrlimit(RLIMIT_NOFILE, &rlim))\n\t                err(1, \"setrlimit\");\n\n\t        /* make directory for files */\n\t        if (mkdir(\"x\", 0700))\n\t                err(1, \"mkdir\");\n\n\t        if (gettimeofday(&t1, NULL))\n\t                err(1, \"gettimeofday\");\n\n\t        /* populate directory with open files */\n\t        for (i = 0; i < 100000; i++) {\n\t                snprintf(buf, sizeof(buf), \"x/%d\", i);\n\t                f[i] = open(buf, O_CREAT);\n\t                if (f[i] == -1)\n\t                        err(1, \"open\");\n\t        }\n\n\t        /* close some of the files */\n\t        for (i = 0; i < 85000; i++)\n\t                close(f[i]);\n\n\t        /* unlink all files, even open ones */\n\t        system(\"rm -rf x\");\n\n\t        if (gettimeofday(&t2, NULL))\n\t                err(1, \"gettimeofday\");\n\n\t        diff = (((double)t2.tv_sec * 1000000 + t2.tv_usec) -\n\t                ((double)t1.tv_sec * 1000000 + t1.tv_usec));\n\n\t        printf(\"done: %g elapsed\\n\", diff/1e6);\n\t        return 0;\n\t}\n\nSigned-off-by: Greg Thelen <gthelen@google.com>\nSigned-off-by: Dave Chinner <david@fromorbit.com>\nSigned-off-by: Andrew Morton <akpm@linux-foundation.org>\nSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>\nSigned-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>","distinct":true,"url":"https://api.github.com/repos/Starship-Android/android_kernel_lge_hammerhead-starship/commits/f5991409d5b09503cd87ca9989d5ec8954fbd0f0"}]}