Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1458771lqj; Tue, 4 Jun 2024 02:05:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXLOt1RG4ZWC+Vim/q0DLQtPYONE3QruUPaCZE9brooBYiP+Rb0schsl0hqM2ppl0Wk7exca5Exn3mTwK4ZygoQT/nwoGSnzgVSFp7Lw== X-Google-Smtp-Source: AGHT+IFgxrmWji7g4kelhyk1spIAn26oNizM6d4+FqxUaI/MPCQ3L0avwcOXDQzb+vMUSfRaPDg9 X-Received: by 2002:a17:907:6d02:b0:a68:ed0b:8924 with SMTP id a640c23a62f3a-a68ed0b89b4mr474873566b.16.1717491914988; Tue, 04 Jun 2024 02:05:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717491914; cv=pass; d=google.com; s=arc-20160816; b=GApiDhLRtVbozbz5cZJAPJ0xrKvHxj03wwy/1qawJUgylZk4LQIDnYyJbRKHKgRepE MJ+C5IaQdQ7tJgqZF+ME1lVAygh5Yy6qrrdKFPfTdBikFGLsWOfPxvcEwtZLBOSgRFsT baNMmISVYR122zLFESIUA6znnUvsZNyY/NogsPnbKLsdepqdQjE3X3YloF3g60OIopHn uyl04NaRmOOvERaLxRULk0a7CE3tq1u6FYvQkR8fiKUcnjnabgRDQGWPPJ7mN/PhUP9j 7up7VztSrZliLEv8BVbkdPCPpZmLuWtPV2m5eLGX+CD/6uUfIvKb8341mQ3oRjmnKze9 Aapg== 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=EgfUmXsqgmNwj+rMaReGgCA4wiQq2XPkVYnu/r4iAGA=; fh=sok7+e0iisHWJawuhv/hH59K3rBopX7NrHCVZlsx5lw=; b=KwXnpiA25aZNgW5/fbhxcWzKFvO9inMpIrSUbKvnY2Bmsn/GJgxvcciPBZQ1BpWvMk bb5zGY0YhCh2+sSBLHeskoSizEbEBxKCNEmrB65QK23KEmQ3YRANH29vQdGCbn/jiq3D qckafFHzRIHUg8ZfU6VRYSHN8Ka/ELN2ElaaT2jtL54HfvFpvXemIHg+KlU8MnFTya0K hmkdEC05wnKNVspkTMWloGZvjDcEPj0fBr/7DGd/NNj7ArRcNU/DgVIDnJc5b+fTwXza iMo/mcZzsjg4bLpRhnuxhsbPcpaE5xgX1fXOit8ymB1SuUuz4oK3xChUR7VBhRF+qBAh cL5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=W1llwgMs; 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-200291-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200291-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 am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a68f2561096si239853066b.985.2024.06.04.02.05.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:05:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200291-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=W1llwgMs; 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-200291-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200291-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2C9471F27CD9 for ; Tue, 4 Jun 2024 08:56:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6798E142E83; Tue, 4 Jun 2024 08:56:21 +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="W1llwgMs" Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (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 4A7C2142900 for ; Tue, 4 Jun 2024 08:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717491380; cv=none; b=Pt8B0j6Iamvxr0x9u/CqS1IdhRMPWvYWwGiwZnVurgS44WJihWt3OrPkCypmFfEpivKnwv6j3scQsqig1Oq4yOyM0KDi9DJLAt8UEppnZ+oziIIBV0q1tZZGlr627rGdSKIOKvG3uvKOAMj48eNtmvMnfcLExler3RCE3o5tIZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717491380; c=relaxed/simple; bh=8cknAkmefqkx+qv8NvnS0Os0vDp4UwIBi3e26OJQHVk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=A/Y0s1/ilxM2WK2Fzhsc05XD/1A19vszac0REEnGJYRBvd42Ve4bwhLWEYR3FOIBq2Z4OtL32xhFEPqk4nSAoXK286vZNkqCwhV7Pf6KASf0b89LAUzxOM3VVAXXVcTcIygCelXMdK6cL2dXl/SG5YHp2v0ImJg6oxzn6+mU+QM= 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=W1llwgMs; arc=none smtp.client-ip=115.124.30.99 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=1717491369; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=EgfUmXsqgmNwj+rMaReGgCA4wiQq2XPkVYnu/r4iAGA=; b=W1llwgMsY1DsrMJp5C+UGXmPpWlqOhOH5AD/tmz1+p8sMAXnC8m5vXAuAzIeaTCYe2iFQVjhHcZXis+jpPiZaHrkqPXALL/sxeEw3QOdO2QB6cOFLEiLbiPtWijDnOjhwjEdf4+Ov+SVDslnTWmjRM6YeVden0LNleM5p7MtwBY= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R601e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032014031;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0W7qIn4D_1717491368; Received: from 30.97.56.67(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W7qIn4D_1717491368) by smtp.aliyun-inc.com; Tue, 04 Jun 2024 16:56:09 +0800 Message-ID: <89bd659b-a85f-48f2-98ce-f7522cdb95da@linux.alibaba.com> Date: Tue, 4 Jun 2024 16:56:08 +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] mm/gup: don't check page lru flag before draining it To: yangge1116@126.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, liuzixing@hygon.cn References: <1717488551-18053-1-git-send-email-yangge1116@126.com> From: Baolin Wang In-Reply-To: <1717488551-18053-1-git-send-email-yangge1116@126.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/6/4 16:09, yangge1116@126.com wrote: > From: yangge > > If a page is added in pagevec, its ref count increases one, remove > the page from pagevec decreases one. Page migration requires the > page is not referrened by others except page mapping. Before > migrating a page, we should try to drain the page from pagevec in > case the page is in it, however, folio_test_lru() is not sufficient > to tell whether the page is in pagevec or not, if the page is in > pagevec, the migration will fail. > > Remove the condition and drain lru once to ensure the page is not > referrenced by pagevec. This looks sane to me and seems a simple way to fix. > Signed-off-by: yangge > --- > mm/gup.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/gup.c b/mm/gup.c > index ca0f5ce..890dcbc 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -2411,7 +2411,7 @@ static unsigned long collect_longterm_unpinnable_pages( > continue; > } > > - if (!folio_test_lru(folio) && drain_allow) { > + if (drain_allow) { > lru_add_drain_all(); > drain_allow = false; > } You should rebase your code on the latest mm-unstable branch, as collect_longterm_unpinnable_pages() in the upstream has been replaced with collect_longterm_unpinnable_folios().