From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3557222F388 for ; Thu, 18 Jun 2026 05:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781761964; cv=none; b=KRlVYz5HiOir9m1gk1pqCyw3b+SzRj5WK+8/DRk0ozsX9yliIT/gSWEWPMnaCgprojxGm6tK1Zyc1lLeGg8h92iL++oiplz/GPmVZCXZN4peE8J8MSNZ6ObxjByLpTsPwlRVWNM3qdIbo7WMgAbo2b/K1HYXDebAf8NvPo7HClQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781761964; c=relaxed/simple; bh=F+I0LoD+aqTSv8wRL7gBRAgcGQEfBSjTIPJF1KSUwH0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=umt+fP3iOhzZSaqafztfgrwR8oorUiiA0L1awwOLQB6pVOyOadR967gxFMQwSatj3kL+748fGww1NVpnOPNByf7JVIRYcXlr6UgtDNK+jx+KSKmi/QCkgjN7GjohMGuGkFaWAoPABI6/K7y4f9IZx+nre/hbA+faTU1PUfc2Pp0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Zbj/NUEk; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zbj/NUEk" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5ad49da7123so461155e87.0 for ; Wed, 17 Jun 2026 22:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781761961; x=1782366761; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lUW7N1WdM4gjkll3SORybiTywWoSQednVL16A3MVWc4=; b=Zbj/NUEkR0SUZetlIrHLAQomTi9JOW568nhs8yWatSwK+GTfsy7knonnKwVYopOP8W 5xeQkOnKZagu/cgkkWJ7pS4pzfFVlhphXG/wgPA7P+R5FwNr4vRH8wIz6RvxKjR5lTeG C55xl1aT6k0VgbSwTvx11B5Sv02K1C/QG+XSbb9eu1BKn/HOxAzsnN56DRrr0/FI8/EK Kz1fR2zkYuXcNDeHCJW6ihDz9JgvgrObTq3CZbbYPLID7AQN5++Zx1rmJPaZ44SnQg5Y f63AOF3nUgbJCCtFzz7/DcxSoqnG3MCEgv/niQx57GGpQ8PRJF909afkmTuMwxCm+NVB d/yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781761961; x=1782366761; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lUW7N1WdM4gjkll3SORybiTywWoSQednVL16A3MVWc4=; b=hezwo21ftUfCjBFHuhCrFZrvYlDRbm7tlKIrQl2OeXW+KbdEkgFmtZj+k81IvM7TUz zPpFG4cN4kQ+JVJPmg46gmaMWEbonO8WfdfF/m9FkQLz41SVc4E0yg2pb/Vl3LPaARhI CUU4fAn4l8mLI893ikHZJpdthgiK6F5qLVNF9OIf/T8QNhe7RMUD7aPCkyo7zOJ7ZvJa kACwViD51LPcDo7TLRpk39uf5jd/oWeQjAcBnWNcSrVRSmMVIIJmUS8JUoP9FTewSCYK a9W3Oxa5ukDCQfDSGxVp8HBjxGEkfeZkPb0sUdbW3GxD7KFA7NuFSM3qGeS9hjWzzRwB nvPQ== X-Forwarded-Encrypted: i=1; AFNElJ+HH54R8Ht/voYz63483L7FVhxrhPsg4LybYLx0Deas7disgbTZpwLDogIm6bHO43XQm8gWD8CIktfFhao=@vger.kernel.org X-Gm-Message-State: AOJu0YyLiJAJ8QTShCziyTwvn4TAtw5g3ZB9sRbCXSb4GH02BWqfmZDn UhU6sx9z7leKjLQrh4azHdgM14LwHXyoQkesYZBIjY/xzNmSULAsEITc X-Gm-Gg: AfdE7ckSgcfpxUPSSPs6lZ0E8jwmDZM/6Zz2SIv7hLcWydDadDwkNFs8bWb/gOzbgCH yp/1r9gQp8U4HH92C13kL7UFgSe8mVmKaal5ItxTCSlylRptin0EzpGF4a4S4C2uv/elg8UdplB 1DB3FzIzyt6VGtL7+IYxtLRDOYnQ0KgYXUKrC/6kfdGrQO1RGKBjTYW0bo/Uz/IzWf9/PN9kVv9 gdrlMacZihlRiknERXnauEn7AnIM3nCDO5LjQ/2FRvEpwbZLB68vOBBc2H5opnISJ5TinjoqVg6 47V3++iwVLCPcl6hCNiuNntnbLZr64QTpFt+B3OkSIqJQUYjmzd3zSvPUZYRXcwp32GVRvsYyUF CuBW5lBPJFILt2mWntRe45xlABvr1YICqH7Q2sXYBzFbVQcjUEfFix5AYcxCyXW0ZBz6o2zmUDa Nz2FOso0tw+iR+uQJcUdl5Yg== X-Received: by 2002:a05:6512:6381:b0:5ad:4a8d:cf29 with SMTP id 2adb3069b0e04-5ad4d650fdamr502051e87.12.1781761961132; Wed, 17 Jun 2026 22:52:41 -0700 (PDT) Received: from localhost ([188.234.148.119]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ad2e161ee7sm5031554e87.13.2026.06.17.22.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 22:52:39 -0700 (PDT) From: Mikhail Gavrilov To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Vitaly Prosyak Cc: David Airlie , Simona Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mikhail Gavrilov Subject: [PATCH] drm/amdgpu: do not enter fs_reclaim under notifier_lock in lockdep training Date: Thu, 18 Jun 2026 10:52:16 +0500 Message-ID: <20260618055216.56191-1-mikhail.v.gavrilov@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit amdgpu_lockdep_init() trains lockdep on the driver lock ordering by taking a chain of dummy locks in order and calling fs_reclaim_acquire() in the middle of it. The fs_reclaim_acquire()/fs_reclaim_release() pair is placed while notifier_lock (amdgpu_notifier_lock_key) is held, which teaches lockdep that it is legal to enter memory reclaim with the MMU notifier lock held: notifier_lock -> vram_lock -> reset_domain->sem -> reset_lock -> fs_reclaim notifier_lock is, however, acquired from the MMU notifier invalidate callback amdgpu_hmm_invalidate_gfx(), which mm/ runs from inside memory reclaim via __mmu_notifier_invalidate_range_start(). That establishes the mandatory reverse ordering: fs_reclaim -> mmu_notifier_invalidate_range_start -> notifier_lock The two together form a cycle. It stays dormant until reclaim first unmaps a page covered by an amdgpu userptr interval notifier, at which point kswapd closes the loop and lockdep reports a false circular locking dependency: WARNING: possible circular locking dependency detected kswapd0/268 is trying to acquire lock: (&amdgpu_notifier_lock_key){+.+.}, at: amdgpu_hmm_invalidate_gfx but task is already holding lock: (mmu_notifier_invalidate_range_start){+.+.}, at: try_to_unmap_one A lock that is taken inside an MMU notifier callback must never be held across a reclaiming allocation, so the fs_reclaim annotation does not belong inside the notifier_lock region. Drop it. The remaining chain still teaches the intended lock nesting. Fixes: 1d0f5838b126 ("drm/amdgpu: Add lockdep annotations for lock ordering validation") Signed-off-by: Mikhail Gavrilov --- drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c index d5d71fd7c70d..eeb3b5007f80 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c @@ -150,12 +150,6 @@ int amdgpu_lockdep_init(void) /* Level 6: Reset control lock */ mutex_lock(&reset_ctl.reset_lock); - /* - * Mark potential memory reclaim boundary. - * GPU operations might trigger memory allocation/reclaim. - */ - fs_reclaim_acquire(GFP_KERNEL); - /* Level 7: SRBM register access */ mutex_lock(&srbm_mutex); @@ -175,8 +169,6 @@ int amdgpu_lockdep_init(void) mutex_unlock(&grbm_idx_mutex); mutex_unlock(&srbm_mutex); - fs_reclaim_release(GFP_KERNEL); - mutex_unlock(&reset_ctl.reset_lock); up_read(&reset_domain->sem); mutex_unlock(&vram_lock); -- 2.54.0