Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3374326imu; Mon, 24 Dec 2018 00:13:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/WWA5VdUAZ0qSE6OIngGqI0LjzLu/KgDcrgVnWXo5la4OybwwA4pxT2aIVzm+0rXJwdlG4k X-Received: by 2002:a62:4e83:: with SMTP id c125mr12420723pfb.101.1545639187114; Mon, 24 Dec 2018 00:13:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545639187; cv=none; d=google.com; s=arc-20160816; b=t6FhAIlp/BpYOcCxTwGerszf9qhfz636jotOc+e3kx1EcSOnM+wDhDE6xihuIh0kNP DrL3NlEWXB16GGh6OZ6ttHDPdar0xaTBu/G5R2zcLYPgPlMgPHjzMnoNtvXWHx4No1so bxUcsDuYNwauz2H7zU97BzTK7zFyYflEbhtPyzMwlNexr+jL+VeEw8zXG1lxto8UPx1u ah4Bsd0U4Ksqp4mKosuGdZyKbT3RMKt+n5QuYyAEVgoa6k2H/tCblApeJAQLVjDggvao 6PU7UM3FAIGpNC0eEtQVPhJsi2MtIOdK1w/3DlHeeUT3meraEeP1HQFbWrqIbk6bS1O+ +rzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=/Nwqr8wwUXHc0CDsTYsZgjq9LrEKW0Go+sUOzblQbzA=; b=x/l2yJfCpMSi+E/QK34UVZAEeoNzOijsjjxl7IBWvrxR9g2fVDRU6zEnMxG35G7TR2 hLQlAUdw68n4J6iMpmxkvGeDptakaTMjB3AImxgZdbj6Yr/4JYmERu5WeOP+xjsKjas4 SyQzK9NxTFGZmujs9l9+TzmqFN3yF2434tS7F2NVxEPRds008sbmOZ2gv3/tThXoiKGM snkf3OO3PAZcHo03teDZ5GnU26Wd25kkBqKkalBcXxYZFBnuH4/h8moixJta0e5opThk VnEqSez4MEkyv1IaljonAnseiIs9XMz70oEB8uH3HHtit+riFgmqtf8XYxG50ieKSiXs v8jA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 133si28936603pfc.61.2018.12.24.00.12.51; Mon, 24 Dec 2018 00:13:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726805AbeLXILB (ORCPT + 99 others); Mon, 24 Dec 2018 03:11:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:35358 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725984AbeLXILB (ORCPT ); Mon, 24 Dec 2018 03:11:01 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 355B0AD72; Mon, 24 Dec 2018 08:10:59 +0000 (UTC) Date: Mon, 24 Dec 2018 09:10:56 +0100 From: Michal Hocko To: Nicholas Mc Guire Cc: David Rientjes , Nicholas Mc Guire , Andrew Morton , Chintan Pandya , Andrey Ryabinin , Arun KS , Joe Perches , "Luis R. Rodriguez" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC] mm: vmalloc: do not allow kzalloc to fail Message-ID: <20181224081056.GD9063@dhcp22.suse.cz> References: <1545337437-673-1-git-send-email-hofrat@osadl.org> <20181222080421.GB26155@osadl.at> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181222080421.GB26155@osadl.at> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 22-12-18 09:04:21, Nicholas Mc Guire wrote: > On Fri, Dec 21, 2018 at 01:58:39PM -0800, David Rientjes wrote: > > On Thu, 20 Dec 2018, Nicholas Mc Guire wrote: > > > > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > > > index 871e41c..1c118d7 100644 > > > --- a/mm/vmalloc.c > > > +++ b/mm/vmalloc.c > > > @@ -1258,7 +1258,7 @@ void __init vmalloc_init(void) > > > > > > /* Import existing vmlist entries. */ > > > for (tmp = vmlist; tmp; tmp = tmp->next) { > > > - va = kzalloc(sizeof(struct vmap_area), GFP_NOWAIT); > > > + va = kzalloc(sizeof(*va), GFP_NOWAIT | __GFP_NOFAIL); > > > va->flags = VM_VM_AREA; > > > va->va_start = (unsigned long)tmp->addr; > > > va->va_end = va->va_start + tmp->size; > > > > Hi Nicholas, > > > > You're right that this looks wrong because there's no guarantee that va is > > actually non-NULL. __GFP_NOFAIL won't help in init, unfortunately, since > > we're not giving the page allocator a chance to reclaim so this would > > likely just end up looping forever instead of crashing with a NULL pointer > > dereference, which would actually be the better result. > > > tried tracing the __GFP_NOFAIL path and had concluded that it would > end in out_of_memory() -> panic("System is deadlocked on memory\n"); > which also should point cleanly to the cause - but I?m actually not > that sure if that trace was correct in all cases. No, we do not trigger the memory reclaim path nor the oom killer when using GFP_NOWAIT. In fact the current implementation even ignores __GFP_NOFAIL AFAICS (so I was wrong about the endless loop but I suspect that we used to loop fpr __GFP_NOFAIL at some point in the past). The patch simply doesn't have any effect. But the primary objection is that the behavior might change in future and you certainly do not want to get stuck in the boot process without knowing what is going on. Crashing will tell you that quite obviously. Although I have hard time imagine how that could happen in a reasonably configured system. > > You could do > > > > BUG_ON(!va); > > > > to make it obvious why we crashed, however. It makes it obvious that the > > crash is intentional rather than some error in the kernel code. > > makes sense - that atleast makes it imediately clear from the code > that there is no way out from here. How does it differ from blowing up right there when dereferencing flags? It would be clear from the oops. -- Michal Hocko SUSE Labs