Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp478787rwl; Wed, 5 Apr 2023 03:39:52 -0700 (PDT) X-Google-Smtp-Source: AKy350ZXGFuv4xpDg23BoGZtrOBGJgjsu03TSBdOdeuvVWGHRA21/SS2gg6enwqgU73cV3aSadpa X-Received: by 2002:a17:90b:1bc4:b0:23f:6d4e:72b3 with SMTP id oa4-20020a17090b1bc400b0023f6d4e72b3mr6053164pjb.25.1680691192066; Wed, 05 Apr 2023 03:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680691192; cv=none; d=google.com; s=arc-20160816; b=XTZAALLjJclIJKgw9V580au/iwIFxze088WG5wd83hG2ModiKH5CjU01YDo3Ksbsfe 2Pze9BeumiZf4y4BtJIr8Lg2bIfZPbkB4BoOuvJXASmIR2JTXTpW8UIIem50UAet+uS3 GiKuv6szZ3OiF4O2iUUYWtN3Hq5bohIYwisPkqE213owJa8Msuy6DUQC1dhHpVnq0ZmH W0C64y94KkdsAAA7HLTkzmTr9RQEaDbW9721VdujUMu82eiNCyzBsH8bRWdtG5hfjdED Xolmdc8HAXygM7dEpIii/2W2tITQiiJcNeeoRfXgjb4FxJJKibX07nOvH8i63XcyC896 YB2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=mvB9npGWQFwrqKSjHhyitvudP9oMfuXQt6r9bIhbFzE=; b=0WJA+Om8nP+Tybm7NGi+NY2olnoRAeuJw1FaPnwYSD/fmIYJzGLbwyXzNL6HT8MU3M 0X2ojGRMC89Mc0/cNJSTjvW5sgtGUC+j8qKccEJQCT7b6iqf7WPB7hlY3EV/3Y3ROkod LgLJmlcNejBjp59PLlGvFfSUFT/tL4vRszgXT/xvAGqWMMratmTz2MQwjdpuTuztKmCc 53FfbdoeQnszwFFdolZB6APjPx+jicfkHbtRLF+hS/K79l5XbLtMOGhILIEvPxQius1+ uM8DRPMljSBvCyXnPB/GeGy6nfHALfH4Bgogaj0QInFnGsDHBsCQZm4i/7CUx+SHiR7d 278w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fa21-20020a17090af0d500b002368e89eecesi1080584pjb.180.2023.04.05.03.39.40; Wed, 05 Apr 2023 03:39:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237684AbjDEKjR (ORCPT + 99 others); Wed, 5 Apr 2023 06:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237635AbjDEKjP (ORCPT ); Wed, 5 Apr 2023 06:39:15 -0400 Received: from outbound-smtp14.blacknight.com (outbound-smtp14.blacknight.com [46.22.139.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD7B4C23 for ; Wed, 5 Apr 2023 03:39:13 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp14.blacknight.com (Postfix) with ESMTPS id 8F9891C4325 for ; Wed, 5 Apr 2023 11:39:12 +0100 (IST) Received: (qmail 9016 invoked from network); 5 Apr 2023 10:39:12 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.21.103]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 5 Apr 2023 10:39:12 -0000 Date: Wed, 5 Apr 2023 11:39:10 +0100 From: Mel Gorman To: Baolin Wang Cc: akpm@linux-foundation.org, osalvador@suse.de, vbabka@suse.cz, william.lam@bytedance.com, mike.kravetz@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] mm: compaction: fix the possible deadlock when isolating hugetlb pages Message-ID: <20230405103910.t2774qzhs2tne72q@techsingularity.net> References: <73d6250a90707649cc010731aedc27f946d722ed.1678962352.git.baolin.wang@linux.alibaba.com> <7ab3bffebe59fb419234a68dec1e4572a2518563.1678962352.git.baolin.wang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <7ab3bffebe59fb419234a68dec1e4572a2518563.1678962352.git.baolin.wang@linux.alibaba.com> X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 16, 2023 at 07:06:47PM +0800, Baolin Wang wrote: > When trying to isolate a migratable pageblock, it can contain several > normal pages or several hugetlb pages (e.g. CONT-PTE 64K hugetlb on arm64) > in a pageblock. That means we may hold the lru lock of a normal page to > continue to isolate the next hugetlb page by isolate_or_dissolve_huge_page() > in the same migratable pageblock. > > However in the isolate_or_dissolve_huge_page(), it may allocate a new hugetlb > page and dissolve the old one by alloc_and_dissolve_hugetlb_folio() if the > hugetlb's refcount is zero. That means we can still enter the direct compaction > path to allocate a new hugetlb page under the current lru lock, which > may cause possible deadlock. > > To avoid this possible deadlock, we should release the lru lock when trying > to isolate a hugetbl page. Moreover it does not make sense to take the lru > lock to isolate a hugetlb, which is not in the lru list. > > Fixes: 369fa227c219 ("mm: make alloc_contig_range handle free hugetlb pages") > Signed-off-by: Baolin Wang > Reviewed-by: Vlastimil Babka > Reviewed-by: Mike Kravetz Acked-by: Mel Gorman -- Mel Gorman SUSE Labs