From patchwork Tue Mar 26 21:25:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13605129 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 0075EC54E67 for ; Tue, 26 Mar 2024 21:25:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8266B6B009C; Tue, 26 Mar 2024 17:25:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D72A6B009D; Tue, 26 Mar 2024 17:25:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69EBD6B009E; Tue, 26 Mar 2024 17:25:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5A2E06B009C for ; Tue, 26 Mar 2024 17:25:40 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1371EA06CF for ; Tue, 26 Mar 2024 21:25:40 +0000 (UTC) X-FDA: 81940472040.27.D4FBF89 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf26.hostedemail.com (Postfix) with ESMTP id 08F4D140009 for ; Tue, 26 Mar 2024 21:25:37 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=0sjzousd; spf=pass (imf26.hostedemail.com: domain of axboe@kernel.dk designates 209.85.210.169 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711488338; 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:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=ZJ3F1D6B6rnhqeAOjvuuDp7X9AY29P64QERcCUxde3c=; b=UL6WfT8dRWH88q3DZq5+7NsyegAarchsTYsJEgRQhtSEeel22Y43dDe9ogJdILpmcLsFy6 +N0qchNVJ1a8GsJd6OSP7dvHAqOLx1g3IC7bSvK8GUTVXcoVuAxA41PnhhUNbBg5EsaJEd ymzpfVXmFeHZKBmUz1ZBtbxBV7Yt0kM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711488338; a=rsa-sha256; cv=none; b=W1GM+XTe5zzUlhlqwku3gApJasuCfXZVJYPip7VBTyKQERfwyBZkBSHC+EQXvGRX2JmdwD o904jNN+/6RLaAYUtVHPEmj+iPMKdTCwWV2B12cK37sI9nJnCrJNn/re2H+R5ujgENF+g7 i1XWaD+XwmlVZeAmWgK2dr3Gxqpk4ZI= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=0sjzousd; spf=pass (imf26.hostedemail.com: domain of axboe@kernel.dk designates 209.85.210.169 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6e694337fffso856975b3a.1 for ; Tue, 26 Mar 2024 14:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1711488336; x=1712093136; darn=kvack.org; h=content-transfer-encoding:cc:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ZJ3F1D6B6rnhqeAOjvuuDp7X9AY29P64QERcCUxde3c=; b=0sjzousdoSUQeInUlfZxJ/RV3MwT2NzqzCFxv1naa0pSA1vMY5qIO+0AH6E0hZU6dU 8zIZ37A3tiubZN9TZyf97/hEPhDZ0erDX5DNJIgUQTDDYpIEm4OaV9UuG3QfI00zDIMS KLCuSgVYYAeXElFS/nhNcGHUGp8oNcsPRWHrxkAb7bLuihWoBFmwraVI/ZFI0491AnRP pIewpa8mF/I84WVWTKwCFUdz4afRsmfkFHNzPTBdAXFnX137aYHf63UFOV1WwmoZVD6N +618+csOdQwXtpK580Nx0ftryLyieErWar0j7L3W0A9tBblbBRMT81d+DguKIPm6Rmum 1/YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711488336; x=1712093136; h=content-transfer-encoding:cc:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=ZJ3F1D6B6rnhqeAOjvuuDp7X9AY29P64QERcCUxde3c=; b=KG+h/4pdvnKBySBLzpfls1aDJkLRqNOczBjlZLtRmT/DyFfftsd0KpuT3P0EZkXPK1 ApS/Jn4vVO9rC8raSggdZJg4lUtJ9uM1iP4fJpTRKShOhZQnJgl0iUOKTYZZsjzV35Sq /r6RlgMJmoXXaKfWlg1QJ3LEEQc3JEamwqu0EqnjpTF4SLJx2+0HN476syG1Wd1JP0Xw fFwD7k2uIYZmuJjTurA7VVhb4CBsC/c59Fnvuc00Htr6hR8ZcqosFoEflsG1S2E4XsQA mYN//sMm/zGdoPP90n4GxQILILbk84vWGXDe/4HY2y+h5rRcWOT3SXda+AtdWHzhKr+9 eHHQ== X-Gm-Message-State: AOJu0YwSrp4bF1PgUk62SGgyMRpN7VYRmUXVqzniER4uCy5xGHOIvrBG CIgybq05U1MDdvIcNQuwx2tYxsCHGYzNqTIk8XsjIGlBbBOxDnT+D2Zqo6/Yizbb8Whwf+ab2g0 E X-Google-Smtp-Source: AGHT+IHZqrY9J2vYobsw3w1zuxuVfLSWCyd/QKzH9N+hRTZddSjWTYC2QqBxdIqw/T3idw8hFA7kmA== X-Received: by 2002:a17:902:8483:b0:1dd:7c4c:c6b6 with SMTP id c3-20020a170902848300b001dd7c4cc6b6mr12063664plo.5.1711488335819; Tue, 26 Mar 2024 14:25:35 -0700 (PDT) Received: from ?IPV6:2620:10d:c096:122::1:2343? ([2620:10d:c090:600::1:b4b4]) by smtp.gmail.com with ESMTPSA id ju9-20020a170903428900b001dee4bee1acsm7298375plb.224.2024.03.26.14.25.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Mar 2024 14:25:35 -0700 (PDT) Message-ID: Date: Tue, 26 Mar 2024 15:25:34 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Linux-MM , Andrew Morton From: Jens Axboe Subject: [PATCH] mm: vmalloc: annotate find_vmap_area_exceed_addr_lock() for lockdep Cc: "Uladzislau Rezki (Sony)" X-Stat-Signature: ascyd57bdwb9q9x74rmy76ufb3qxn5bg X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 08F4D140009 X-Rspam-User: X-HE-Tag: 1711488337-608736 X-HE-Meta: U2FsdGVkX191IkUabPFMBsz22BLJtduqboqRW867s6yRg/PcGKvb4NChSdeHwumaz01z439st3y3ZXI+EBcberBKjZnfUxW9ULiX0Hr1SCNIP8D2oTjO4GEp2M6Hszy7pxDWfrbjXuwBoeQiJdu+Df47+iFjp9it3vdWr62T4pCWO8h0Jz/sVM/8SFLN7NMlICwJLuShG4FpyLFPRF2hZP477bwpukCFHMvzbgutOqO7fgSlnopsWS9jA3qRf5H5/773iXkjbbd2G4ngq367ui9Jf9OfNacOn4bBnLqc3+q7MlhtCS1KFR8uXvkv1gLHD9kV7vadH2zO0p3qfu+Ns4zeQgjIHXSdIpDf3iOON5KUVKWkND4Ed/Lt9vY5+mdAfWfQBVnQlYEm+RslFPv2N/ifxY8t9DvnfGjrBDgdVzUwYlDu07PnlX5OPhLPIUH1y7uJ3gT077a6iPgnou+5zfYXYAQXROVjfuThHNs1UB3fc63MLYzLQRa5yQtIOZh3lOJMzWVQpeW5mj37EL7jbKejMgY+MviWe00eGLFNKi8yTDwas/pBf7Dhi2qG192sYkpM8SVuvx6YAQtYGqjpiB+dv0hPBaHy//T6Sr2lYwuQKBNIRmesShj6WLOkqVgFh8cmQ/ivCTjv2PDicUv8b0Z3DOYKHjM5oa1dbVA6qWFYGF0Uz7PnX5QCXWClnxCEp7gHyH/rhmKkFXAyg1f+ddZ2egCjAP5hM+wI0HR6/c9Tqrj9t27xo5Yodj+uFAIEHDiZlVx1y8hPZXTR/pAiGGUKqBOWTFTwOYjaszLFZrdbMmxkgV9azliZU4L5OBKckGWxuiB9g4cyJ2VVF7l5yW3svCkNK519quBbDJLZ5AchgR42dcpO4RlV6/zGrhaYDxHXRnGz8OAydtWeXDCKY5ZunEG1ro/igKlMn/Ztm1/ujPrKZ5t4nD0UXxOoOVldQ4jd6IZ/8hh042F4FAD JVh6Vg+e EVqJwx4xqsMsCn5nO21raLO76jiGB55RuAbKblh902tlp7k8xbglm7p1YbX50YTxJWNLH1TQub7gtZJPsllxhf+QJUGZT3eycbF6JiTXkUNIW+KsZN/clI866784wUu9XoVM9ap8MOQP/m/AZ4YUXjNTihpxyoYPxHxbuffhRmLCUqVY/zw2HCiqgJvq9vA2IytquYMx6QxKSa2XsSbytSwM3dJdmpBROU2T8ZXheRoui58rLJ8cJLX4AzymsbH/05H2YIrhXEb2SLWZy+yeIDWUKwU85UJxhozte7DWWZp7qB+lqfWVjpXB84cmAC6WnSQJjTBeoBdcYhZBj+anCJq1flbM4Pkgpx/l+SGSc+J5OZVgsbV9XC3Ovm4c46+fq3jnPslD6AZrw1kf+uFD9k4j6AGeuEjQjT67SEg/7JIqg98X4584mFZI3ZNdJc9mAbx5cE5GTz5qvZyPkfBAL7kZFYmQyHFpEIZGP 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: lockdep gets confused with the nested locking: ============================================ WARNING: possible recursive locking detected 6.9.0-rc1-00060-ged3ccc57b108-dirty #6140 Not tainted -------------------------------------------- drgn/455 is trying to acquire lock: ffff0000c00131d0 (&vn->busy.lock/1){+.+.}-{2:2}, at: find_vmap_area_exceed_addr_lock+0x64/0x124 but task is already holding lock: ffff0000c0011878 (&vn->busy.lock/1){+.+.}-{2:2}, at: find_vmap_area_exceed_addr_lock+0x64/0x124 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&vn->busy.lock/1); lock(&vn->busy.lock/1); *** DEADLOCK *** May be due to missing lock nesting notation 3 locks held by drgn/455: #0: ffff800081ecbba8 (kclist_lock){++++}-{3:3}, at: read_kcore_iter+0x5c/0xa24 #1: ffff800081ea7688 (page_offline_rwsem){.+.+}-{3:3}, at: page_offline_freeze+0x14/0x1c #2: ffff0000c0011878 (&vn->busy.lock/1){+.+.}-{2:2}, at: find_vmap_area_exceed_addr_lock+0x64/0x124 stack backtrace: CPU: 5 PID: 455 Comm: drgn Not tainted 6.9.0-rc1-00060-ged3ccc57b108-dirty #6140 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x90/0xe4 show_stack+0x14/0x1c dump_stack_lvl+0x84/0xc0 dump_stack+0x14/0x1c print_deadlock_bug+0x24c/0x334 __lock_acquire+0xdf4/0x20e0 lock_acquire+0x204/0x330 _raw_spin_lock_nested+0x40/0x54 find_vmap_area_exceed_addr_lock+0x64/0x124 vread_iter+0x44/0x428 read_kcore_iter+0x170/0xa24 proc_reg_read_iter+0x7c/0xcc vfs_read+0x220/0x2c4 ksys_pread64+0x74/0xb4 __arm64_sys_pread64+0x1c/0x24 invoke_syscall+0x44/0x104 el0_svc_common.constprop.0+0xb4/0xd4 do_el0_svc+0x18/0x20 el0_svc+0x44/0x108 el0t_64_sync_handler+0x118/0x124 el0t_64_sync+0x168/0x16c which seems to be because it's missing the proper nested annotation. Add the level annotation to make lockdep happy about this use case. Fixes: 53becf32aec1 ("mm: vmalloc: support multiple nodes in vread_iter") Signed-off-by: Jens Axboe Tested-by: Jens Axboe Tested-by: Omar Sandoval diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 22aa63f4ef63..26a69fa6809c 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1032,7 +1032,7 @@ find_vmap_area_exceed_addr_lock(unsigned long addr, struct vmap_area **va) for (i = 0; i < nr_vmap_nodes; i++) { vn = &vmap_nodes[i]; - spin_lock(&vn->busy.lock); + spin_lock_nested(&vn->busy.lock, i); va_lowest = __find_vmap_area_exceed_addr(addr, &vn->busy.root); if (va_lowest) { if (!va_node || va_lowest->va_start < (*va)->va_start) {