Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp238643lqq; Thu, 13 Jun 2024 01:20:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVI4KuyRLn0hKvfRKSoVQByNiPS1WI7Ej7LNCoMNOFZtDp56Xxh4RssETIfFn5aRA0e/122qR6AEoYALtblgwPZaUCcbA/z8rDV8xtAtg== X-Google-Smtp-Source: AGHT+IHSLtcbQqc78pHdb9jRLunJENFweZkbPnGzub7GGRjvzEaVGj6iOild4eRO8G7WWy5rOvkc X-Received: by 2002:a05:6e02:1a67:b0:374:8928:83a4 with SMTP id e9e14a558f8ab-375cd17829bmr45534615ab.14.1718266852140; Thu, 13 Jun 2024 01:20:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718266852; cv=pass; d=google.com; s=arc-20160816; b=BMrSHqZvDE9dq5Dm2AQSowNOGKzKdfwBRpDX/KbJrd832RZ9/MOQ1Y128ds821Yq9T lWS428g7iX2pcETLCJPcZD3K8iDEYA5SPRIjLPA08eGxDZF96XSaBswL7n6Dv3v8YU5w VLh6URsWnawFjWQ3hs1zB9pf7o+TKcFLNV19OB8LprIxx/D+xfEHNMwGABRtbmYjSChv pg9BfHGYFiWlhff0mUmCuZa2bZda5I5ODaQpste+dZyEDj1FqmmQGNstCXW2nwN0CBBG tggA9WkFLAa4WfMXf4xIhrbebGqBUPRq2NFigenZyU+i71rQfrGukBIerW1Tceo+VMtc UJiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=/lFAuOYmr8Us+EmOEoVPRlzvuNvNZ/fszqFE/s0Rh5g=; fh=kA/6mFGuquvvUlpa7b9EvU4dDN7fdldZED6GYdCzhPY=; b=LMTffJKjukdJalPJv5VJxn1MGjnPvNI0gAmu53Ksvs2Kib3qMu95DwLR9EtEJF3OHT Z5PCmVf8ZqTeWCDlpLnZGSuvIkIJZj64vcbfZxszoMiKK42wjI4H76iEo3o5eaOQFLtU Gtq1DWtg+jKQCWoQyeAvHYISqDJ3ZI75+2Ga1B3KcALAUV9NhwZElrjSoHx03PL8n+ow lwW5MkERmnazLr+pQ7AgYW6191HXVz07IgtfOxXCO1ci614q6HQIxRPNL9T7E9GlWFkF EVDQFvrPCx8+PjWdxoQztJwHqMdDrHyeQdjjkiRQ8bUwSg8JrerGLBFJP2MdtsbKhXhd Pg2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=JuEYxjOF; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-212792-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212792-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fede81e6d8si819913a12.188.2024.06.13.01.20.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 01:20:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212792-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=JuEYxjOF; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-212792-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212792-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B690628600E for ; Thu, 13 Jun 2024 08:20:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C94F913D50A; Thu, 13 Jun 2024 08:20:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="JuEYxjOF" Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (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 970DF13D2B9 for ; Thu, 13 Jun 2024 08:20:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.110 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718266844; cv=none; b=msrKK+wvgEyvMzV/vaxXPTf+b0HugUnPa2I0r/imILSk9Hw4RmP4YsOxP2MXuEJtNnAjB6fadJuqEVc218sd7CdqBL/hESkg5P/1yosZP62cFQUHEq2O/XXUBL3uUtziGuv/3DaWaPuvW8kA2lbNPQIz2odQJE9cF2ynJe6QnJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718266844; c=relaxed/simple; bh=orlF50pUCxxA5Usyh9chuvbjIHC8m2eoiF0E/m3gv0A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=akKrVfHk/NRLB7tZsQdmJCPtuEnDQ7d9NgzpYdFD5/aO7kGg73K2sY+NzU7tt+DHMAxvXz5UhkgVA6FDS2xpOOpTQ3b2dM/5djyhMV3+prx68w4pQdTNVhLdH/CLDwQOy38JKIEYviwY65YxHsgYeQ8+fcKlhd4WwovDC49d6oA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=JuEYxjOF; arc=none smtp.client-ip=115.124.30.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1718266839; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=/lFAuOYmr8Us+EmOEoVPRlzvuNvNZ/fszqFE/s0Rh5g=; b=JuEYxjOF1U4tB4h+wwSoa1YAzTLpjswX+k2Ehu0gwlae5vI0XnP2a8k2ljEhQ9RrPcvbQmFG+ioZkpI9YUvYrtCoPBDyh16fGErc0sKZlsTQ35+lSJfbP9o3N3GnRPCOUkh19sLJ90OKEJ61IcRi+amE666UsTrM8oOsqzKshLE= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067112;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0W8NU4Xs_1718266836; Received: from 30.97.56.57(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W8NU4Xs_1718266836) by smtp.aliyun-inc.com; Thu, 13 Jun 2024 16:20:37 +0800 Message-ID: Date: Thu, 13 Jun 2024 16:20:36 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 4/4] mm/vmscan: avoid split lazyfree THP during shrink_folio_list() To: Lance Yang , akpm@linux-foundation.org Cc: 21cnbao@gmail.com, david@redhat.com, fengwei.yin@intel.com, libang.li@antgroup.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, maskray@google.com, mhocko@suse.com, minchan@kernel.org, peterx@redhat.com, ryan.roberts@arm.com, shy828301@gmail.com, sj@kernel.org, songmuchun@bytedance.com, wangkefeng.wang@huawei.com, willy@infradead.org, xiehuan09@gmail.com, ziy@nvidia.com, zokeefe@google.com References: <20240610120809.66601-1-ioworker0@gmail.com> <20240613072858.16512-1-ioworker0@gmail.com> From: Baolin Wang In-Reply-To: <20240613072858.16512-1-ioworker0@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/6/13 15:28, Lance Yang wrote: > Hi Andrew, > > I'd like to fix the bug[1] I mentioned previously. Could you please fold the > following changes into this patch? > > [1] https://lore.kernel.org/linux-mm/20240613065521.15960-1-ioworker0@gmail.com/ > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index f409ea9fcc18..425374ae06ed 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2707,10 +2707,8 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma, > if (unlikely(page_folio(page) != folio)) > return false; > > - if (folio_test_dirty(folio) || pmd_dirty(orig_pmd)) { > - folio_set_swapbacked(folio); > + if (folio_test_dirty(folio) || pmd_dirty(orig_pmd)) > return false; > - } > > orig_pmd = pmdp_huge_clear_flush(vma, addr, pmdp); > > @@ -2737,10 +2735,8 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma, > * > * The only folio refs must be one from isolation plus the rmap(s). > */ > - if (folio_test_dirty(folio) || pmd_dirty(orig_pmd)) > - folio_set_swapbacked(folio); > - > - if (folio_test_swapbacked(folio) || ref_count != map_count + 1) { > + if (folio_test_dirty(folio) || pmd_dirty(orig_pmd) || > + ref_count != map_count + 1) { > set_pmd_at(mm, addr, pmdp, orig_pmd); > return false; > } > diff --git a/mm/rmap.c b/mm/rmap.c > index b9e5943c8349..393e2c11c44c 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1824,12 +1824,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, > */ > if (unlikely(folio_test_swapbacked(folio) != > folio_test_swapcache(folio))) { > - /* > - * unmap_huge_pmd_locked() will unmark a > - * PMD-mapped folio as lazyfree if the folio or > - * its PMD was redirtied. > - */ > - WARN_ON_ONCE(!pmd_mapped); > + WARN_ON_ONCE(1); > goto walk_done_err; > } > You can also drop the unused 'pmd_mapped' variable now.