Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp365659lqt; Thu, 18 Apr 2024 19:19:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHelxpOQZqzDMKR2JBr/74NR1sjo3Okheh6TFIA+WsYsTmbbG+cdVcShJNfTvzwICWdA9ql0U5M3Zk49hvtSQ1kAD5pQvIYegInWU96Q== X-Google-Smtp-Source: AGHT+IHDu7dc32eMLpx2mVOkvRTm7V9cAfMN6wV+7jVZv7oTCNSZZKP2d2e5aCw8TEbDmmNpyzzw X-Received: by 2002:a05:6102:2ea:b0:47b:bda4:c31d with SMTP id j10-20020a05610202ea00b0047bbda4c31dmr831537vsj.2.1713493149271; Thu, 18 Apr 2024 19:19:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713493149; cv=pass; d=google.com; s=arc-20160816; b=BhJiFRAA1yE72b3AnRZvS8Cg6tEvxedG9KbyTe4fxX71VSkjVduGaQkDGdRIRFfIX8 XK3dDh8raTuWMOm2qfKbkGsCNUnjm/XQtdWffXNaZ3HyTuzjBxfw7hRYK9/YvRelMtEe 4pQRABqxY0sn8EbjrXjX3OPgvQZApb+yJx/yvXOhAhI0FScbFbTF6LD/ej6sAM17GJIU B7GApOpWWESZ1jkM5MPjQ60x513GdeiNyzpI9yAR7VD0UPsMmfToy/wkmNutZJTRsPSr TQrnTEsoTy/UmF/MrvZ52XawvFSbMUZI6MR7LU6mcHF7CjDU99DCiv/AsK5Vy22vzM9d ijvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=LfcB5SiLqUCuDbUa6yk9sH8/9LyqjjYuP2Y+IKXjKA4=; fh=uwxrUnd5CilMlTP4uxXMkorlykUSMH+LFESBIfn1HPE=; b=ScXib36k8/8zQcdvOlxgu/hmUOGYLQIKxpooSYKcuf1Ku/KsY2vF3i1FVWDZ84jEk0 nudceGXb+KroBfdL9k4byXfjw9BhCatQWDYC1juIUR49XEzbnxXFKTCI96MSKdQGh6cI cZMglPl1g2y7S9J+RXiQguuyv3MHJF+BVtVNgrUSWUh6xk9xJWtAiSUpOG+FKsJALqVh VZc4Ftm8dT52eyyddoZYLlyHw555U/iBH0W9wtZ9tiW1O7XaWXqUzTzVgTua3azzXqP3 KUlfHgvaAOwwQsat6KptIEzt9WifJRsjycYfqRMDyr1qJDa1OxrfDHBZR6f09qkl3b7/ zyOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-150936-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id wa13-20020a05620a4d0d00b0078ede2c40d0si2867733qkn.740.2024.04.18.19.19.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 19:19:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150936-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; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-150936-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 02DDF1C20E91 for ; Fri, 19 Apr 2024 02:19:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CAFD4C6B; Fri, 19 Apr 2024 02:19:03 +0000 (UTC) Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (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 9093A15BB for ; Fri, 19 Apr 2024 02:18:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713493142; cv=none; b=ff0DHZHgNeaI84ulDyRsFDVf/2TH8QtNUBgRZf+fgfh0ZDoQD87e79abDE69TzXHaYlDpIprUVjAmtq0rRaQ59F8eowMYm+KlegB2R0OItNLRBHgszTWdoqRFjVty4BjUa9THdIphcPA8PiqMZ3SY+X31Mv4vZ1y/giZjCFk2pw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713493142; c=relaxed/simple; bh=Kw4J7cCMZF0zsSyFSO8IizbZzmfPw9W9XDnU3vd2Sp4=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=DzQLNo5lUab84JllK2op+E1CIXcnvfiVWoZYk/ipU+Je9Ebhh2K5NCivHeh4eyub5UJBdesIEI6aqhC+3JGfgW7AB3ulygwZpMw9TIZU3DQeArNX/HRE3Q13yfPSc2Yi6dtT4vPcv4ZDgEgeVPb9d/nIsabhr2F414uZQ2JqItQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4VLHrg1XRVz1wrQT; Fri, 19 Apr 2024 09:59:31 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id 74ABA14035F; Fri, 19 Apr 2024 10:00:30 +0800 (CST) Received: from [10.173.135.154] (10.173.135.154) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 19 Apr 2024 10:00:29 +0800 Subject: Re: [PATCH 1/2] mm/hugetlb: fix DEBUG_LOCKS_WARN_ON(1) when dissolve_free_hugetlb_folio() To: Oscar Salvador CC: , , , , , , References: <20240418022000.3524229-1-linmiaohe@huawei.com> <20240418022000.3524229-2-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: <32c97464-fcc2-18a2-5b72-8602cffa895a@huawei.com> Date: Fri, 19 Apr 2024 10:00:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) On 2024/4/18 20:41, Oscar Salvador wrote: > On Thu, Apr 18, 2024 at 04:00:42PM +0800, Miaohe Lin wrote: >> On 2024/4/18 12:05, Oscar Salvador wrote: >>> On Thu, Apr 18, 2024 at 10:19:59AM +0800, Miaohe Lin wrote: >>>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >>>> index 26ab9dfc7d63..1da9a14a5513 100644 >>>> --- a/mm/hugetlb.c >>>> +++ b/mm/hugetlb.c >>>> @@ -1788,7 +1788,8 @@ static void __update_and_free_hugetlb_folio(struct hstate *h, >>>> destroy_compound_gigantic_folio(folio, huge_page_order(h)); >>>> free_gigantic_folio(folio, huge_page_order(h)); >>>> } else { >>>> - INIT_LIST_HEAD(&folio->_deferred_list); >>>> + if (!folio_test_hugetlb(folio)) >>>> + INIT_LIST_HEAD(&folio->_deferred_list); >>> >>> Ok, it took me a bit to figure this out. >>> >>> So we basically init __deferred_list when we know that >>> folio_put will not end up calling free_huge_folio >>> because a previous call to remove_hugetlb_folio has already cleared the >>> bit. >>> >>> Maybe Matthew thought that any folio ending here would not end up in >>> free_huge_folio (which is the one fiddling subpool). >>> >>> I mean, fix looks good because if hugetlb flag is cleared, >>> destroy_large_folio will go straight to free_the_page, but the >>> whole thing is a bit subtle. >> >> AFAICS, this is the most straightforward way to fix the issue. Do you have any suggestions >> on how to fix this in a more graceful way? > > Not from the top of my head. > Anyway, I have been thinking for a while that this code needs some love, > so I will check how this can be untangled. That would be really nice. Thanks Oscar. . > >