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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C46EC32771 for ; Mon, 26 Sep 2022 15:23:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E8176B00FA; Mon, 26 Sep 2022 11:23:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1995A8E0067; Mon, 26 Sep 2022 11:23:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 039998E0066; Mon, 26 Sep 2022 11:23:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DE6896B00FA for ; Mon, 26 Sep 2022 11:23:38 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AE818A0A1A for ; Mon, 26 Sep 2022 15:23:38 +0000 (UTC) X-FDA: 79954606116.04.453A141 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf13.hostedemail.com (Postfix) with ESMTP id F2A432001F for ; Mon, 26 Sep 2022 15:23:37 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5EE2B21EF4; Mon, 26 Sep 2022 15:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1664205816; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/QQNa5fjWpYSTINNZ8fkhajG7/HHXIdA5rA4AKSfwoc=; b=XHZoyzENCRIiGgTd/+ssg8u8SLzggAtIrjmeJmHRRhZnuW7nbag5ljev7ZALJKePOpt4JG ctbdLsvrk28VOBey7XZsYNI0eVyWmzlSah7hDNULEh6tffIGgLrdBkFJ1P7F6Ukol5flUB xECfGvDcjnLEnuVoYDbU/VbHMq4bjts= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4348C13486; Mon, 26 Sep 2022 15:23:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id m0CZDfjDMWPaIgAAMHmgww (envelope-from ); Mon, 26 Sep 2022 15:23:36 +0000 Date: Mon, 26 Sep 2022 17:23:35 +0200 From: Michal Hocko To: Florian Westphal Cc: linux-mm@kvack.org, akpm@linux-foundation.org, vbabka@suse.cz, urezki@gmail.com, linux-kernel@vger.kernel.org, Martin Zaharinov Subject: Re: [PATCH v2 mm] mm: fix BUG splat with kvmalloc + GFP_ATOMIC Message-ID: References: <20220926151650.15293-1-fw@strlen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220926151650.15293-1-fw@strlen.de> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664205818; a=rsa-sha256; cv=none; b=UbfbxVY43chN8Z5XKWzGxVlsts5jKDeUYi3hHhS4G6vthyTpSLLtHLsKN1bT3DSsJu1Ti0 vGaIkA7QIGOpV2cjSPSHv3QroThLnxIqHU2DnwJeWWJaam50gicYjM/CQk/BsXcvfmzg0n KhP5dbMfsP9gqb75a1pEzPipb1909iY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=XHZoyzEN; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf13.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664205818; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/QQNa5fjWpYSTINNZ8fkhajG7/HHXIdA5rA4AKSfwoc=; b=Q2BpehmbodfUOoSrIGqb24tnBIGP3RCf378K8UES5eMA5ohynNLPFQTWV76+qFcEWZVAGO EzdWxwHnjItOjNzv1HkFISKy3tPZ9FshxS5d/XY7vwZoxAU5DKbVkLxlDhMxdam5j+hujC TKxZoidrGAzo3IGSxZtXmcZe72F+gN4= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=XHZoyzEN; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf13.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspam-User: X-Stat-Signature: ofdt4tko5p9txfzi3676ewzjysd56qmt X-Rspamd-Queue-Id: F2A432001F X-Rspamd-Server: rspam06 X-HE-Tag: 1664205817-968698 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 Mon 26-09-22 17:16:50, Florian Westphal wrote: > Martin Zaharinov reports BUG with 5.19.10 kernel: > kernel BUG at mm/vmalloc.c:2437! > invalid opcode: 0000 [#1] SMP > CPU: 28 PID: 0 Comm: swapper/28 Tainted: G W O 5.19.9 #1 > [..] > RIP: 0010:__get_vm_area_node+0x120/0x130 > __vmalloc_node_range+0x96/0x1e0 > kvmalloc_node+0x92/0xb0 > bucket_table_alloc.isra.0+0x47/0x140 > rhashtable_try_insert+0x3a4/0x440 > rhashtable_insert_slow+0x1b/0x30 > [..] > > bucket_table_alloc uses kvzalloc(GPF_ATOMIC). If kmalloc fails, this now > falls through to vmalloc and hits code paths that assume GFP_KERNEL. > > Reported-by: Martin Zaharinov > Fixes: a421ef303008 ("mm: allow !GFP_KERNEL allocations for kvmalloc") > Suggested-by: Michal Hocko > Link: https://lore.kernel.org/linux-mm/Yy3MS2uhSgjF47dy@pc636/T/#t > Signed-off-by: Florian Westphal Maybe we can extend this to GFP_NOWAIT capable vmalloc call but I am not sure this exists or whether this is something vmalloc maintainers want to commit to. This is a clear and trivial fixup of the above commit. I would add this to the stable tree as well. Acked-by: Michal Hocko Thanks! > --- > mm/util.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mm/util.c b/mm/util.c > index c9439c66d8cf..346e40177bc6 100644 > --- a/mm/util.c > +++ b/mm/util.c > @@ -619,6 +619,10 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node) > if (ret || size <= PAGE_SIZE) > return ret; > > + /* non-sleeping allocations are not supported by vmalloc */ > + if (!gfpflags_allow_blocking(flags)) > + return NULL; > + > /* Don't even allow crazy sizes */ > if (unlikely(size > INT_MAX)) { > WARN_ON_ONCE(!(flags & __GFP_NOWARN)); > -- > 2.35.1 -- Michal Hocko SUSE Labs