From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48750C433FE for ; Thu, 7 Oct 2021 19:55:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DAC97610C7 for ; Thu, 7 Oct 2021 19:55:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DAC97610C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5BEAC6B006C; Thu, 7 Oct 2021 15:55:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 56EDB6B0071; Thu, 7 Oct 2021 15:55:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45D6E900002; Thu, 7 Oct 2021 15:55:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0097.hostedemail.com [216.40.44.97]) by kanga.kvack.org (Postfix) with ESMTP id 326896B006C for ; Thu, 7 Oct 2021 15:55:44 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E2F23181C9918 for ; Thu, 7 Oct 2021 19:55:43 +0000 (UTC) X-FDA: 78670696566.09.0720FDF Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf06.hostedemail.com (Postfix) with ESMTP id 889C0801BEFA for ; Thu, 7 Oct 2021 19:55:43 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F1C360F6E; Thu, 7 Oct 2021 19:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1633636542; bh=l66xkvwo5JDJqPQgPip89gZwXEOnO407CqbFPpfYp94=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NSeYGN3XXLrQYf0fPcCt6hWBohOXv+xiotZkcXFQ7+M4XEPsvno7qUvSzhInEfkdm na9gMTTn3OoaSGuNFnHSOIEs1c+kqJVJe+nyBfC4krIYIcGU/spgPCxbMvUP/9futO kEDwoSwwNI8UT31HhqEGNTNN+DhPwAyl8Aej+Ruo= Date: Thu, 7 Oct 2021 12:55:41 -0700 From: Andrew Morton To: Vasily Averin Cc: Michal Hocko , Johannes Weiner , Vladimir Davydov , Tetsuo Handa , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@openvz.org Subject: Re: [PATCH mm v2] vmalloc: back off when the current task is OOM-killed Message-Id: <20211007125541.db0f3ff2bdbd8fa7dc1db03d@linux-foundation.org> In-Reply-To: <83efc664-3a65-2adb-d7c4-2885784cf109@virtuozzo.com> References: <83efc664-3a65-2adb-d7c4-2885784cf109@virtuozzo.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 889C0801BEFA X-Stat-Signature: os6daxwhxutk5r34gwd7ci5tnfgh936j Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=NSeYGN3X; dmarc=none; spf=pass (imf06.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1633636543-138827 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 5 Oct 2021 16:52:40 +0300 Vasily Averin wrote: > Huge vmalloc allocation on heavy loaded node can lead to a global > memory shortage. Task called vmalloc can have worst badness and > be selected by OOM-killer, however taken fatal signal does not > interrupt allocation cycle. Vmalloc repeat page allocaions > again and again, exacerbating the crisis and consuming the memory > freed up by another killed tasks. > > After a successful completion of the allocation procedure, a fatal > signal will be processed and task will be destroyed finally. > However it may not release the consumed memory, since the allocated > object may have a lifetime unrelated to the completed task. > In the worst case, this can lead to the host will panic > due to "Out of memory and no killable processes..." > > This patch allows OOM-killer to break vmalloc cycle, makes OOM more > effective and avoid host panic. It does not check oom condition directly, > however, and breaks page allocation cycle when fatal signal was received. > > This may trigger some hidden problems, when caller does not handle > vmalloc failures, or when rollaback after failed vmalloc calls own > vmallocs inside. However all of these scenarios are incorrect: > vmalloc does not guarantee successful allocation, it has never been called > with __GFP_NOFAIL and threfore either should not be used for any rollbacks > or should handle such errors correctly and not lead to critical > failures. > This needed a little rework due to https://lkml.kernel.org/r/20210928121040.2547407-1-chenwandun@huawei.com. Please check and retest sometime? --- a/mm/vmalloc.c~vmalloc-back-off-when-the-current-task-is-oom-killed +++ a/mm/vmalloc.c @@ -2887,6 +2887,9 @@ vm_area_alloc_pages(gfp_t gfp, int nid, page = NULL; while (nr_allocated < nr_pages) { + if (fatal_signal_pending(current)) + break; + if (nid == NUMA_NO_NODE) page = alloc_pages(gfp, order); else _