Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp901491lqt; Fri, 19 Apr 2024 14:11:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXW90hwYxakvWiV/6QI5GrH44CuEKs2gOfJMbMK0bCRFA98K8wX+FmQ1kKJDwZDzedTUTjhet5is7xJc+T7obtW6cY3om+kAqlt6F4riw== X-Google-Smtp-Source: AGHT+IHL64ofNf2B5rxCuJv4PEMxO4Uv9BpBbvNkB0dpnd1eLd80E3pMDenDf+jQ2I+VmD9fVNN/ X-Received: by 2002:a9d:6e9a:0:b0:6eb:cdda:7ec with SMTP id a26-20020a9d6e9a000000b006ebcdda07ecmr3550033otr.25.1713561101939; Fri, 19 Apr 2024 14:11:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713561101; cv=pass; d=google.com; s=arc-20160816; b=ycK4uBJ93I0hvFIovgakZdr73MQmuugV4/0JaWmjGArnv3BP4ddByWjsfS9n2z1JRe 8t7E1lLuUkajQyrzmf+IzkSh66PwkcuHvsdxl4pt2CvMpOmp03KDLn5k14pXaf5FZK13 y+6sBxNN+6lsroLJ36jLR3OV1tbkM8flWiaRJl8C7fqqT8NzaJM5Aek7da6lTSZALARm HNBwZ+zbxilNg8E9/k5IRUkEUVdJRHSlzYXOryam9+zDBsTZQmr9L831OjDRheKBYaBI EZeJ5DFYHDA9sz03l3todgZd8gPf7ga+kgayjxY74Q5r3lFawY/PWVnLce6XkjxnMLdy CtUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=ruoGm2t9R6PTKTRtlViKl4QFSCLMTXFvVN6ZUeDpMP0=; fh=w86B1O3uw5qkjRr6tlF3a5IbuHMS2t+6qiUVps5MaKo=; b=CZ2ZPMgh8NQpNE52CALwMUkSVfFDMb8O7PFJ8nS/819ybwKEBb46vdPx97mr2jxWy8 LdfY0rwqtcIHPjzm5YU43LxP8HydEUyBczQ+N6Ede0Ieyxaj9SosFWWcCsY7L3z6mP49 RRrHJgEKxpUGAA2+hc/o+QzXY4bZ0Tt2bUA8lYBLzoErjjwzFcqJ26jtUagnhGTG0P/z sqKnare1eOIU+ffWNYJf/eOgXk2lddlqwg1rhRu9+hiPV3oJgQJwJd09+AJ9chmL8j1G iQpwjbUkKKZfsG6B4TBl41TZPOVkUdjb31mgf7Vrmnye+RSNJprMZxdeD1xYSWXsvV88 w1rQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=Be69wG4e; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-151961-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151961-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c19-20020a05620a201300b0078d5f107da9si4651805qka.15.2024.04.19.14.11.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 14:11:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151961-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=Be69wG4e; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-151961-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151961-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A67001C215CC for ; Fri, 19 Apr 2024 21:11:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 776022E417; Fri, 19 Apr 2024 21:11:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Be69wG4e" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9142C107B2 for ; Fri, 19 Apr 2024 21:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713561095; cv=none; b=e5vNy6clE6EhW/lkr6NBh1cU2b+yGoUQTrWe6y9ca7rJT35JcDnT/f4Ig7AS2/HHNnz7HYc8WoIwgw2dIafN3svBmj3Z9lWpOHRADICAZKfLbIl48HhbxK9rXjdG4T9fZBAhj6Ho1UOXP1By8Trz/6YHzfjCrOfdagFnNF8g6sM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713561095; c=relaxed/simple; bh=w8dLaSxgMuSudghS89tIqDLnH8VPQ5WVdoqYlYsDR7g=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=ZeCw0cLYAvZqDd++gyG81OYRFHKTX0PSJbh71xuqcQGUXuaO0sT+/5UGMEyxv50Xfudtb9tSvc8N4flGu7f+9mD5Z8EdM9MZ4CCpdm70bLkbf7lQBGMFfI1sal8UttRHVQ0VB6i5Xet5bZ4fqH1lBtQlWijotpVJK0LBzAEws80= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=Be69wG4e; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D809AC072AA; Fri, 19 Apr 2024 21:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1713561095; bh=w8dLaSxgMuSudghS89tIqDLnH8VPQ5WVdoqYlYsDR7g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Be69wG4ezgeGYP4OVW5eLAmclKIBFx6mIN91Bd7X9P65FmiY+vwfQwtX8jwtWVFBq wk60NWbmL7XNkXjTuR6i2Ezn+O40I1iXFbJuIfHZqA3HtIgt6VpUKj3Z1oqSj2aQeo KkzR3SfHpZ6ZNx9RNtxfzzxHQswatZoTiQTAwFXg= Date: Fri, 19 Apr 2024 14:11:34 -0700 From: Andrew Morton To: Miaohe Lin Cc: , , , , Subject: Re: [PATCH v2] mm/hugetlb: fix DEBUG_LOCKS_WARN_ON(1) when dissolve_free_hugetlb_folio() Message-Id: <20240419141134.464ea3a1ef3d0e93c6711c93@linux-foundation.org> In-Reply-To: <20240419085819.1901645-1-linmiaohe@huawei.com> References: <20240419085819.1901645-1-linmiaohe@huawei.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 19 Apr 2024 16:58:19 +0800 Miaohe Lin wrote: > When I did memory failure tests recently, below warning occurs: > > DEBUG_LOCKS_WARN_ON(1) > WARNING: CPU: 8 PID: 1011 at kernel/locking/lockdep.c:232 __lock_acquire+0xccb/0x1ca0 > Modules linked in: mce_inject hwpoison_inject > CPU: 8 PID: 1011 Comm: bash Kdump: loaded Not tainted 6.9.0-rc3-next-20240410-00012-gdb69f219f4be #3 > > ... > > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1773,7 +1773,7 @@ static void __update_and_free_hugetlb_folio(struct hstate *h, > * If vmemmap pages were allocated above, then we need to clear the > * hugetlb flag under the hugetlb lock. > */ > - if (clear_flag) { > + if (folio_test_hugetlb(folio)) { > spin_lock_irq(&hugetlb_lock); > __folio_clear_hugetlb(folio); > spin_unlock_irq(&hugetlb_lock); Please let's prepare backportable fixes against current mainline, not mm-unstable. Because fixes against current -rcX and earlier will be upstreamed ahead of the mm-unstable and mm-stable material. I did this: --- a/mm/hugetlb.c~mm-hugetlb-fix-debug_locks_warn_on1-when-dissolve_free_hugetlb_folio +++ a/mm/hugetlb.c @@ -1781,7 +1781,7 @@ static void __update_and_free_hugetlb_fo * If vmemmap pages were allocated above, then we need to clear the * hugetlb destructor under the hugetlb lock. */ - if (clear_dtor) { + if (folio_test_hugetlb(folio)) { spin_lock_irq(&hugetlb_lock); __clear_hugetlb_destructor(h, folio); spin_unlock_irq(&hugetlb_lock); _