Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp8820lqr; Tue, 4 Jun 2024 18:35:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVT6Yfaum087x56E7lnpHnX/mAS5lUzDvD8qeRCsDyLBUFwBou8WVGWV7MpwEP4P1bJmD4Xm35pignYQWKEYD5n6d8nziFWqr1l1/LHPw== X-Google-Smtp-Source: AGHT+IHsdBEQ0EXs4LHekvM36yWHOEMbYyDgu9THidkJqpV2KoPDhxGinkdX192OL1Bww3NnBqDH X-Received: by 2002:a17:906:7b92:b0:a63:5745:e3f4 with SMTP id a640c23a62f3a-a69a023a81amr65712266b.65.1717551336729; Tue, 04 Jun 2024 18:35:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717551336; cv=pass; d=google.com; s=arc-20160816; b=BQ4ykTXwc9PkTMA3EdhH9IFVe53q56NXTgnANukLyCUrSQB6/cCVBS/7AF0vAUMxbZ cmRnLAKswEvGtoRodd8ghiHZ3jViGg2f5Ue2YtrOU7UXHjlpu2kO/+tV/TkDy8bOksPN enQhOzPLb/kJKTPHWs0aazbrMbPC0EhHrdCLCtcTOke6hP8Cs1Ho/vRbv+w6aNhDNI5J 27hHelC4U/pi8ntXWjpI8qBJ5EUN3NFDPv5oxm7loBvIMxxK6Criuk40oC24qtQHSj6s FuKVkYTPRaeZ610vXgSMN50XcOcRobYY5fsyDcQ+zhNcBgm6552qsNkPrL/4x6Qt6Ejz Ni4Q== 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:dkim-signature; bh=XqtLqw5329DmSQfIZ97wQcsPfrI3RrJ1xo0vGF5vAKA=; fh=ErWg2eqMCdsjnvO8mP7oxWvGH1ILFNCwIK3pP249FWo=; b=XTOXCBZooQ9FakRpQSW+RwWWfFlSZ7GJW6/17evamTeZLbKn0pi17Fbgt0Gr+bAS5i RK7MvloryKHWnMO3VwlessrAV6ViKgJSIsGlgMKhjL8Ve/C6WclLV4jbmSDFQb3D7Fqk SJajv9dBXZLp9ZjeRHroJl32K8TIvg5dQmWqFDeUcIqTUZLoDe3x0aNY8eiAgUVkKa70 /BFB8a+Oud0qONUOfnvRx5AJBI9Ue+DaceMbZuhnTq4hMj1uOFKJOBZakPBLKNbj+ZDU oTvM7xB3V1cTrP4Q985f517UCBACjJT5vXZH52WI2h6K95e/XyV3+VqihFhBfreafSCu bEdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=pFoh1fj5; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-201650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a68f2d6ac7bsi316351166b.743.2024.06.04.18.35.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 18:35:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=pFoh1fj5; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-201650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.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 6AB851F235F6 for ; Wed, 5 Jun 2024 01:35:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56E2850A6D; Wed, 5 Jun 2024 01:35:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b="pFoh1fj5" Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.6]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C8348F44 for ; Wed, 5 Jun 2024 01:35:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.6 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717551327; cv=none; b=ijhrXZD2OUoiiwvJb5FgDXvZ0lz37fTn3zAhLhZ3+gj3I2QiYfC3DqQU8B68PrKiqIfC1xWXCOkmhOiMCuaDhSDVMTQMt7PMVxRXR5WDGVnziyHazRylep6hiXMA6WD45lDwJuNNazoUMSDC0Bo5EIusJvFed7bDtghwZoiTTZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717551327; c=relaxed/simple; bh=5fyKHdGKG1mTxB7nJ7EFX6bjUuDwMA88Vxme/x1HbiU=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=YUUY00pkIsO7S0gCbRmlU+piyRwZj6hNa6vQ2s117wjYnFwPH+BJMlJYNB13wFjGrf9GzXnoTGlUv32xu6zAPQVFF/Vh3jQrr6bg+Ikjfu/j9TYi4suRJVoKUgynsqwBc8Tu6hw+rEDmeHfSt7wSNxbDI6kn/HCCdPxvpkPw4Mo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b=pFoh1fj5; arc=none smtp.client-ip=220.197.31.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Subject:From:Message-ID:Date:MIME-Version: Content-Type; bh=XqtLqw5329DmSQfIZ97wQcsPfrI3RrJ1xo0vGF5vAKA=; b=pFoh1fj5y+mAh6u0Re9hvnRfG8mQP4A+VCS8o8oatud3SM4lxHVK3p4jtVdAd/ f7Ba/2Z+uPIbY6qa6Q0u8xT7K604BYH80LaTjSD3lcN13c2dp2xPC7uN4SnsP5Q4 jVQ1XcBBQpTtrwWjkK2WTCMrpTECtuO4thb8W2uGJwQss= Received: from [172.21.21.216] (unknown [118.242.3.34]) by gzga-smtp-mta-g1-1 (Coremail) with SMTP id _____wD3nzTOvF9mJD+PAg--.13775S2; Wed, 05 Jun 2024 09:18:07 +0800 (CST) Subject: Re: [PATCH] mm/gup: don't check page lru flag before draining it To: David Hildenbrand , akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, baolin.wang@linux.alibaba.com, liuzixing@hygon.cn References: <1717498121-20926-1-git-send-email-yangge1116@126.com> <0d7a4405-9a2e-4bd1-ba89-a31486155233@redhat.com> From: yangge1116 Message-ID: Date: Wed, 5 Jun 2024 09:18:06 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <0d7a4405-9a2e-4bd1-ba89-a31486155233@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3nzTOvF9mJD+PAg--.13775S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJr1rCrWxuFyDJry3ZF45GFg_yoW8XF1Dpr W8KwnxKrsrKFWakrZrX3s8ZryFy3ySyF48tF13Wr129FsxXw1jkr1Ika13uay3Gry5u3Z2 9a15JF1vvFs0vaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07boDGrUUUUU= X-CM-SenderInfo: 51dqwwjhrrila6rslhhfrp/1tbiWR70G2VLajynIwABsV 在 2024/6/4 下午9:47, David Hildenbrand 写道: > On 04.06.24 12:48, 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 referenced 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 >> referenced by pagevec. > > What you are saying is that we might have a page on which > folio_test_lru() succeeds, that was added to one of the cpu_fbatches, > correct? Yes > > Can you describe under which circumstances that happens? > If we call folio_activate() to move a page from inactive LRU list to active LRU list, the page is not only in LRU list, but also in one of the cpu_fbatches. void folio_activate(struct folio *folio) { if (folio_test_lru(folio) && !folio_test_active(folio) && !folio_test_unevictable(folio)) { struct folio_batch *fbatch; folio_get(folio); //After this, folio is in LRU list, and its ref count have increased one. local_lock(&cpu_fbatches.lock); fbatch = this_cpu_ptr(&cpu_fbatches.activate); folio_batch_add_and_move(fbatch, folio, folio_activate_fn); local_unlock(&cpu_fbatches.lock); } }