From patchwork Sat Mar 23 14:15:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13600662 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 7AAAEC6FD1F for ; Sat, 23 Mar 2024 14:15:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95D1F6B007B; Sat, 23 Mar 2024 10:15:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90DD86B0082; Sat, 23 Mar 2024 10:15:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D4A26B0083; Sat, 23 Mar 2024 10:15:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6DD526B007B for ; Sat, 23 Mar 2024 10:15:51 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D3CA1A08EC for ; Sat, 23 Mar 2024 14:15:50 +0000 (UTC) X-FDA: 81928502460.28.514D576 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf17.hostedemail.com (Postfix) with ESMTP id 11EE84000E for ; Sat, 23 Mar 2024 14:15:48 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kjN0HxmZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.50 as permitted sender) smtp.mailfrom=urezki@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711203349; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=Q39pmMHfSXy620p4ACbgyFL1kmjGFJZhr6o67AZsyVU=; b=LZGbAKn6g1GXK8cOUknUCHWT0Iq5SVKQaQZqbYrTyMh21CrT4eP2mOwJASKwI6HH7Fn4ha mjYWEjoQzue/1KXiO6pj5lXFyxYBo3b6Woyghv+AHcLEIKBDnE37PioKwMwuZOxls0C8Dn 62viIlJPf4zSeD10PJbdu9wS5U8XtGg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kjN0HxmZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.50 as permitted sender) smtp.mailfrom=urezki@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711203349; a=rsa-sha256; cv=none; b=rznBGY6tJP+EHrg89v3Ar5hxpANyKlsOMPVT2bcxjSzXkh1tdspCtNvBtLhPnSlgXwOTkA xi8AjfgS4OL2Ic2Ciga2FItfP1kqnFtnM9aUbhxVAe9xNl8L0oa6Ay7KsmlVu5N4YtkLwA 0ge0+FDf4iiJsPj1qjJ484b/4oSuvmE= Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-51588f70d2dso3526640e87.3 for ; Sat, 23 Mar 2024 07:15:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711203347; x=1711808147; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Q39pmMHfSXy620p4ACbgyFL1kmjGFJZhr6o67AZsyVU=; b=kjN0HxmZeHztr6a0VJ9vVDU9kRAgepBdzv1c74ohxrAYO3NgsBE+Jcg0wQLsKVU7AF uigMqmUKVCoAuqzzpFVNfUNO7kDkqDK37tn5Pu5oChxicfo9rixxEMY/Hzeok7I97Htt pISR4Qz+FRkIoGFMjN3MPPkr/K5MQRPuNBGJ1YhvRhKtApwuqRSvCznmneVcK/XtY+P7 TpzH74HTupVIKaiwsZw/04JBF6Ww58zRVi8TdIr/1aVI1IjhIqukTrPrrwGGYFT6jY17 l2Aik/ujO9cS5nnGf82Uo4l9KupqmrHo8vZQ84TjV9zhAqtjbI6KEWyQgH1UWg+j+CaV u93Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711203347; x=1711808147; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Q39pmMHfSXy620p4ACbgyFL1kmjGFJZhr6o67AZsyVU=; b=upnkIDGT/6+fqnkt8LYWNeK628qpM7dV5MjX+Xg6Mf3rEbBw8H/E1qgS02BtdYDk8E idjHyygOl+kHjul+NUiq0zoGz6LSrFYRZzM50T8abL0mA4mi/tC11r8Q779eczyu6UiG AiOurVJ42pqqmdeXvyAkwSSZHZe7ZjbFp6gBjLpcm0mCI3wGwTacVp+AAW58Z9ORxPYw sHDpD0BPZ3IFumkAUcV35LE6+m/K7J+Pl0S7gUJFFeL0J7w2gR0m24S8VQJLfqEuPU70 XTv4u0+bmB2bPZfloFv+2ZTuKq3fGKL+Sz9O90DFzl7zq1QjUjaZeLMe1JTdoLWSO3s3 YPWA== X-Gm-Message-State: AOJu0YwtrX15gEssk5pryayKntrsRy0/P7rVNB17Ugh6tJ8ZTI9pvMUN 14dUfmUxpJcY5MnrXTMnCsfe6eZkJ2ClOaNjF7jzpFWmvagb+vnVgRWxH7Ee X-Google-Smtp-Source: AGHT+IEOcvSOI+g3mDtFgwckNpK2y/h8PWX/aXFX85Y+t0cl7kJaPnDU9DVeAuDHV8jbkyf237PTPA== X-Received: by 2002:a19:431a:0:b0:513:cffc:e74 with SMTP id q26-20020a19431a000000b00513cffc0e74mr1445334lfa.52.1711203346804; Sat, 23 Mar 2024 07:15:46 -0700 (PDT) Received: from pc638.lan (host-185-121-47-193.sydskane.nu. [185.121.47.193]) by smtp.gmail.com with ESMTPSA id w3-20020a05651203c300b005131c5285f8sm306892lfp.107.2024.03.23.07.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 07:15:46 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: linux-mm@kvack.org, Andrew Morton Cc: LKML , Baoquan He , Lorenzo Stoakes , Christoph Hellwig , Matthew Wilcox , Dave Chinner , Guenter Roeck , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 1/1] mm: vmalloc: Bail out early in find_vmap_area() if vmap is not init Date: Sat, 23 Mar 2024 15:15:44 +0100 Message-Id: <20240323141544.4150-1-urezki@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 11EE84000E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: hn38iirm3bjyrqyfggr3skghe74chc9d X-HE-Tag: 1711203348-122123 X-HE-Meta: U2FsdGVkX1/GOjRWed6Icav5wEef3OSd1Oh3SsL6TwxOO6olg4yWnabSbIuMehkD34lWASufuhn5JhgCIL3kuBdSwR2F16cIqUoZfBnZhZms8v5mfAH4Pu0nZnNk+GyotP9rH/g6pOIsbmV9spGtc3FbX4RwJMFr7EJkjJijZsv12xTuEywASW715C/dHPF721XlFcXSmhTS5+4B0rZ8fJ4vzDWgEhv2wKaMCeQ7L6S2vtmI5fIKasl9NCfRAY9HLJKP4OmRKy/Oc5g4Iuz4W2ESwBfAR+Q7l//7DY7noJMXR6Y/tiWyFdVg+vfD+oU+eba1qEDNsRzfXxMHfU3GP9YBm+glycvVw8BGhA9Woy65pKUkSNzAq8HSuNZkhK5jwMZVeOSRqjCp8E9VU5+fp1ltcxBRPOrNK7kRFI6k25T3DP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cXN+Mx/j6qbun 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: List-Subscribe: List-Unsubscribe: During the boot the s390 system triggers "spinlock bad magic" messages if the spinlock debugging is enabled: [ 0.465445] BUG: spinlock bad magic on CPU#0, swapper/0 [ 0.465490] lock: single+0x1860/0x1958, .magic: 00000000, .owner: /-1, .owner_cpu: 0 [ 0.466067] CPU: 0 PID: 0 Comm: swapper Not tainted 6.8.0-12955-g8e938e398669 #1 [ 0.466188] Hardware name: QEMU 8561 QEMU (KVM/Linux) [ 0.466270] Call Trace: [ 0.466470] [<00000000011f26c8>] dump_stack_lvl+0x98/0xd8 [ 0.466516] [<00000000001dcc6a>] do_raw_spin_lock+0x8a/0x108 [ 0.466545] [<000000000042146c>] find_vmap_area+0x6c/0x108 [ 0.466572] [<000000000042175a>] find_vm_area+0x22/0x40 [ 0.466597] [<000000000012f152>] __set_memory+0x132/0x150 [ 0.466624] [<0000000001cc0398>] vmem_map_init+0x40/0x118 [ 0.466651] [<0000000001cc0092>] paging_init+0x22/0x68 [ 0.466677] [<0000000001cbbed2>] setup_arch+0x52a/0x708 [ 0.466702] [<0000000001cb6140>] start_kernel+0x80/0x5c8 [ 0.466727] [<0000000000100036>] startup_continue+0x36/0x40 it happens because such system tries to access some vmap areas whereas the vmalloc initialization is not even yet done: [ 0.465490] lock: single+0x1860/0x1958, .magic: 00000000, .owner: /-1, .owner_cpu: 0 [ 0.466067] CPU: 0 PID: 0 Comm: swapper Not tainted 6.8.0-12955-g8e938e398669 #1 [ 0.466188] Hardware name: QEMU 8561 QEMU (KVM/Linux) [ 0.466270] Call Trace: [ 0.466470] dump_stack_lvl (lib/dump_stack.c:117) [ 0.466516] do_raw_spin_lock (kernel/locking/spinlock_debug.c:87 kernel/locking/spinlock_debug.c:115) [ 0.466545] find_vmap_area (mm/vmalloc.c:1059 mm/vmalloc.c:2364) [ 0.466572] find_vm_area (mm/vmalloc.c:3150) [ 0.466597] __set_memory (arch/s390/mm/pageattr.c:360 arch/s390/mm/pageattr.c:393) [ 0.466624] vmem_map_init (./arch/s390/include/asm/set_memory.h:55 arch/s390/mm/vmem.c:660) [ 0.466651] paging_init (arch/s390/mm/init.c:97) [ 0.466677] setup_arch (arch/s390/kernel/setup.c:972) [ 0.466702] start_kernel (init/main.c:899) [ 0.466727] startup_continue (arch/s390/kernel/head64.S:35) [ 0.466811] INFO: lockdep is turned off. ... [ 0.718250] vmalloc init - busy lock init 0000000002871860 [ 0.718328] vmalloc init - busy lock init 00000000028731b8 Some background. It worked before because the lock that is in question was statically defined and initialized. As of now, the locks and data structures are initialized in the vmalloc_init() function. To address that issue add the check whether the "vmap_initialized" variable is set, if not find_vmap_area() bails out on entry returning NULL. Fixes: 72210662c5a2 ("mm: vmalloc: offload free_vmap_area_lock lock") Signed-off-by: Uladzislau Rezki (Sony) Tested-by: Guenter Roeck Reviewed-by: Baoquan He Signed-off-by: Heiko Carstens Acked-by: Heiko Carstens --- mm/vmalloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 22aa63f4ef63..0d77d171b5d9 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2343,6 +2343,9 @@ struct vmap_area *find_vmap_area(unsigned long addr) struct vmap_area *va; int i, j; + if (unlikely(!vmap_initialized)) + return NULL; + /* * An addr_to_node_id(addr) converts an address to a node index * where a VA is located. If VA spans several zones and passed