On Wed, 4 Apr 2018 08:23:40 +0200
Michal Hocko <mho...@kernel.org> wrote:

> If you are afraid of that then you can have a look at 
> {set,clear}_current_oom_origin()
> which will automatically select the current process as an oom victim and
> kill it.

Would it even receive the signal? Does alloc_pages_node() even respond
to signals? Because the OOM happens while the allocation loop is
running.

I tried it out, I did the following:

        set_current_oom_origin();
        for (i = 0; i < nr_pages; i++) {
                struct page *page;
                /*
                 * __GFP_RETRY_MAYFAIL flag makes sure that the allocation fails
                 * gracefully without invoking oom-killer and the system is not
                 * destabilized.
                 */
                bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()),
                                    GFP_KERNEL | __GFP_RETRY_MAYFAIL,
                                    cpu_to_node(cpu));
                if (!bpage)
                        goto free_pages;

                list_add(&bpage->list, pages);

                page = alloc_pages_node(cpu_to_node(cpu),
                                        GFP_KERNEL | __GFP_RETRY_MAYFAIL, 0);
                if (!page)
                        goto free_pages;
                bpage->page = page_address(page);
                rb_init_page(bpage->page);
        }
        clear_current_oom_origin();

The first time I ran my ring buffer memory stress test, it killed the
stress test. The second time I ran it, it killed polkitd.

Still doesn't help as much as the original patch.

You haven't convinced me that using si_mem_available() is a bad idea.
If anything, you've solidified my confidence in it.

-- Steve

Reply via email to