Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1938018rbb; Tue, 27 Feb 2024 06:06:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUz5roN4vhPZrluj8n0pxvYetL/Tfz5fi8Gjc64TdzWACErZ4qXJGqCnXwVjZrxmOD1l6NoLoOqud9MkqPo+oZaOG5mBwpt0UeSDge9Yw== X-Google-Smtp-Source: AGHT+IFUoll9XTKCrPO/dupqETO0jIXpIjlg7o0C15Eq1FUvJbkSKP9SB9tGjz9FkHRJ9HYrOFO4 X-Received: by 2002:a05:6a20:ce4d:b0:1a0:f616:32be with SMTP id id13-20020a056a20ce4d00b001a0f61632bemr3041771pzb.10.1709042812619; Tue, 27 Feb 2024 06:06:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709042812; cv=pass; d=google.com; s=arc-20160816; b=hWOmZA13mkAMmli1XueBTC1DkDQrg3Ws7Y1YOG0QSYOj72Fo+x5gAZcdFZAqrUEH5m 11xMq/lIpJE4imnd1ezWJYAunlBe3XNHGZohA5LOtUCCDsWzJawsFnYIjh49p++1SIZ2 9uio8ysMa6G0LwSn9yYr0cxbowtD67gwBEwq5+mbDXm59Un7Nmk+afr2wnYuAw0jvRcX Sugxbs4KPby1Pg0RI1r5AY400Ur+iIkudv/kqKzJQYwIaIMy4YKU9GerXDOKTw57aQ8p w0nvd/0pjWfJP8BdPl1GAZgcmoAGTaLUCCW539JvI1DBk8mZxNeX3RYWAV2lkplmQXGr zYmA== 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 :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=iD6EY4+1hVPsmIrld7YXS+D+hCApNNoJBpDuGcpZNkk=; fh=7dsO43byblrXXGh37JV/xiVl1tAFpYzwe48GXflrK5k=; b=OfyNSg6b2CmZVyAOoIfBkT6tRD9qOjUwVGzi3EzDHfYtktxQkNeQvoY/6lW7s1VC2Y MxryEt7R6mwc82F28qrPR/1J/kc7RvkQo3W/2D0Y4zi4jfk6eBlO4NJUDX/ncqirq+PF /bSUJ9/oZQlQC8pIaZhRROpIUbARj/6AwHpcPvDd7WXzfhzZcotxUTETTDrrPfdplbaA 06GvLLE4kbP4cKU3QXssYI5ENfqg/x3+X62XqAe3GZEqGTCvz4ctpcfSArXmPtPneVt9 zOrgXKvHbW8GxvLH+ZsXbE6/K4AJ2lo4Hx142zqzVX6dFWlCHwA/oWdWWxlp6LdW7SyJ CguQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-83326-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83326-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b19-20020a056a000cd300b006e50ddc35acsi4039588pfv.388.2024.02.27.06.06.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:06:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83326-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-83326-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83326-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EBF6AB2EEEF for ; Tue, 27 Feb 2024 13:38:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99BCC13EFE0; Tue, 27 Feb 2024 13:37:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D93713AA2F for ; Tue, 27 Feb 2024 13:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709041063; cv=none; b=LcylXLuOFIoxQxL3vwldPlWnx8zmmlvlwlASy3cVliag95uVvKdVIYUjA9EqywTTwbwWqDegss9CGmPGmjlWKW6hLoy9Mt9mcB2Ps1CLlJLR8F1HYfSib7iB5SZjx3Vyyjtb9I1OMm7RdNPqunxzSe1QZWQt8m0g6CHTYTTSKM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709041063; c=relaxed/simple; bh=VbywaFmN5QFS1W+PB43Dluw9OIE+JY09v7rj137vPrM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GevXJw2ElhCfoIj0Pe18JLpbpGjLkBwDwc3GCiJ/trMkHCjWBKTd3ucdOaqyrIdI3WflKH6j6fx1JvpMHsVptaDTsX3cY8KJMO7jay62Xrcg2h7OyNhs2vSCdPWuNc2O0DvHWN2/K71kRsIAWZLuEwP/fupuJubzVS4MNPZMT44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 23959DA7; Tue, 27 Feb 2024 05:38:19 -0800 (PST) Received: from [10.1.30.188] (XHFQ2J9959.cambridge.arm.com [10.1.30.188]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7BC343F73F; Tue, 27 Feb 2024 05:37:38 -0800 (PST) Message-ID: <6a55e785-73dd-4951-bad8-2670810a13b6@arm.com> Date: Tue, 27 Feb 2024 13:37:37 +0000 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 v3 4/4] mm: swap: Swap-out small-sized THP without splitting Content-Language: en-GB To: Barry Song <21cnbao@gmail.com> Cc: akpm@linux-foundation.org, david@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, shy828301@gmail.com, wangkefeng.wang@huawei.com, willy@infradead.org, xiang@kernel.org, ying.huang@intel.com, yuzhao@google.com, chrisl@kernel.org, surenb@google.com, hanchuanhua@oppo.com References: <20231025144546.577640-5-ryan.roberts@arm.com> <20240205095155.7151-1-v-songbaohua@oppo.com> From: Ryan Roberts In-Reply-To: <20240205095155.7151-1-v-songbaohua@oppo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 05/02/2024 09:51, Barry Song wrote: > +Chris, Suren and Chuanhua > > Hi Ryan, > >> + /* >> + * __scan_swap_map_try_ssd_cluster() may drop si->lock during discard, >> + * so indicate that we are scanning to synchronise with swapoff. >> + */ >> + si->flags += SWP_SCANNING; >> + ret = __scan_swap_map_try_ssd_cluster(si, &offset, &scan_base, order); >> + si->flags -= SWP_SCANNING; > > nobody is using this scan_base afterwards. it seems a bit weird to > pass a pointer. > >> --- a/mm/vmscan.c >> +++ b/mm/vmscan.c >> @@ -1212,11 +1212,13 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, >> if (!can_split_folio(folio, NULL)) >> goto activate_locked; >> /* >> - * Split folios without a PMD map right >> - * away. Chances are some or all of the >> - * tail pages can be freed without IO. >> + * Split PMD-mappable folios without a >> + * PMD map right away. Chances are some >> + * or all of the tail pages can be freed >> + * without IO. >> */ >> - if (!folio_entire_mapcount(folio) && >> + if (folio_test_pmd_mappable(folio) && >> + !folio_entire_mapcount(folio) && >> split_folio_to_list(folio, >> folio_list)) >> goto activate_locked; >> -- > > Chuanhua and I ran this patchset for a couple of days and found a race > between reclamation and split_folio. this might cause applications get > wrong data 0 while swapping-in. > > in case one thread(T1) is reclaiming a large folio by some means, still > another thread is calling madvise MADV_PGOUT(T2). and at the same time, > we have two threads T3 and T4 to swap-in in parallel. T1 doesn't split > and T2 does split as below, Hi Barry, Do you have a test case you can share that provokes this problem? And is this a separate problem to the race you solved with TTU_SYNC or is this solving the same problem? Thanks, Ryan