From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6B26D49205 for ; Mon, 18 Nov 2024 09:41:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2CB96B00B5; Mon, 18 Nov 2024 04:41:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB5716B009D; Mon, 18 Nov 2024 04:41:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2D256B00CA; Mon, 18 Nov 2024 04:41:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A8D966B00B5 for ; Mon, 18 Nov 2024 04:41:55 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 25DD9160130 for ; Mon, 18 Nov 2024 09:41:55 +0000 (UTC) X-FDA: 82798721670.01.3F323B5 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id 82F45120019 for ; Mon, 18 Nov 2024 09:40:44 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of chenridong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=chenridong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731922847; a=rsa-sha256; cv=none; b=iWXY1+SJnl81V92lA3WfR5bhWTnmUNCHGbaTmASS0EVNfBMZMUWO9Wkj4Rk2phWgHNVTSf TBzlPtPKdE3kVOYh//UfGjcFJlL2vggd+X6ERVqdGyYYjwEc2sPwMjh9NDp9qWQAvBRTKR 9XSOGBx+ePNbTMDsLxhuC/PfYpxaKOg= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of chenridong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=chenridong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731922847; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qguQePobUJnedgEGmpdstshjgtRLLGQ1kbVchnyE9Z4=; b=hNyZE5BTQe6phuPCL7zydlnud8309bkk8rZNthVZx9zZdUQYxFvK0ZjSnnshY+XrBAUH37 wCtvZOhY4kSgS2j+iBNgci9sCpk9pUBFsN8av63nXdQs+cEh0ItGhiI0TSgWAeTnCoh2HZ z7uCp3M1gh6dL0oqmzpvR+imw9NtDtM= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4XsMyk2xDqz10Rxr; Mon, 18 Nov 2024 17:39:10 +0800 (CST) Received: from kwepemd100013.china.huawei.com (unknown [7.221.188.163]) by mail.maildlp.com (Postfix) with ESMTPS id 45A50140393; Mon, 18 Nov 2024 17:41:46 +0800 (CST) Received: from [10.67.109.79] (10.67.109.79) by kwepemd100013.china.huawei.com (7.221.188.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Mon, 18 Nov 2024 17:41:45 +0800 Message-ID: <03c18a7b-24fa-4ee6-8682-63f1a81363e5@huawei.com> Date: Mon, 18 Nov 2024 17:41:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 1/1] mm/vmscan: move the written-back folios to the tail of LRU after shrinking To: Barry Song <21cnbao@gmail.com>, Matthew Wilcox CC: Chen Ridong , , , , , , , , , , , References: <20241116091658.1983491-1-chenridong@huaweicloud.com> <20241116091658.1983491-2-chenridong@huaweicloud.com> Content-Language: en-US From: chenridong In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.109.79] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemd100013.china.huawei.com (7.221.188.163) X-Rspam-User: X-Rspamd-Queue-Id: 82F45120019 X-Rspamd-Server: rspam01 X-Stat-Signature: 3irs1n3au7pb3ku4h3keor8yf9yeqafm X-HE-Tag: 1731922844-662750 X-HE-Meta: U2FsdGVkX1+Rcn5eo2CBlkJH9mTuUOfhGsYU8JqhzACDkM9mnJdLCuX3I0Zh/FQ/O3FHyaCZoIfjM8aLkm6iL130zWVWiKFgR1FCnV7Pp0Dt0NzJQSMeGuUfUSTU93Skj93sxpgUf532jzffHEG0n2WQ8O1KRzA4lNA2TMYD8uh/FqpvMkXNCku+yWbt2xDAEelWkn+oKqelhiX/F8WbW7ar7ZPZJjKu0PS35qXYbDbf79oAmvEy5abkcBlEZBtclACQ4fvCQkJhUFoa0meTATlevaW0HnuQwE6EqAg2IkeZmezVSShU274/pt1JTO9hdRRsfvSQ+DZ1twxVqEpKe55SJCOFV4ilXrytg4XBzn/6UwRTIxdpXuQtfXv9KadqpUKjOzDyyvfzqTYnppdM6I885Ehu/e34eSEXgzmGImCiMhxC4ONGKjzLdFANMMInpwneO/s7yVx1Gxh6r2TH7Wqcf1Fgo6T07NA7RS1w1i/YJHPEwq7rMA62kJ6XlsqDMTUpgYiUHpJ6j+VA8ajOOVetvItIQKZbGDcVhN+E7e4jQxc/aMB9fZ4kDB7sciE7n9R6FtNb3CI3qUbKgOGyoZjoap8IwgLpWfu8FZEEy6I/RW6aoB8w7C5Y7iaXD0PHY9UztmKgknlzsLo0LMUZdB5vLVyUSrOfq9LCVzUCjmjI0ObSGGrI/3BQAGRZ48B2oTw1giTBurwIagxKoRnInC89ZZg22GAsSVYr5q8er6r9buQtwQOJzfD1AlEM7zegPdQ8E8FVa47y+Kp8IhcDNb4Q2aa4C35dxlfe8lW+QSD1bPNamA5VbA67mtfYlHM1oXZtXLR/i7qCi18G2h2/pl/zwWlbA2e5vXjJBy2Sudtk6UwQ04eSdCIYU3rVqu9WF2iEs9f0sdM7hFbEnqoFtkjvtdoX25BBp9Jr7VQjJ1+plvfMpAzhNS2nlJYy5jW9kQXev6vJkY/GAaTg4Ow wTGUyw3J I10DKbPuayB9Hnw0J6M6k2f6T/2y0R5KVuxSgT+g+zrU/lVt21yJhJZC7bM72Y1AbWJIZBZnPpI/X6ixZiERCCwY54PmcHCp8teW1w6T2p4vImqOc0XN+2jDSr02AMDfXdYI09JJ/6J0PCagKYR4sj4qRR0vw9WlAfpA8EqBScGgb+zqluAc2JyFUIAWATQTJEkCaP9iEZi3t5XoqT7boZAV/dZzThe0E7H0jguLUvNgG0FYx2974HCtTiiTyTi7qH3Wh X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2024/11/18 12:14, Barry Song wrote: > On Mon, Nov 18, 2024 at 5:03 PM Matthew Wilcox wrote: >> >> On Sat, Nov 16, 2024 at 09:16:58AM +0000, Chen Ridong wrote: >>> 2. In shrink_page_list function, if folioN is THP(2M), it may be splited >>> and added to swap cache folio by folio. After adding to swap cache, >>> it will submit io to writeback folio to swap, which is asynchronous. >>> When shrink_page_list is finished, the isolated folios list will be >>> moved back to the head of inactive lru. The inactive lru may just look >>> like this, with 512 filioes have been move to the head of inactive lru. >> >> I was hoping that we'd be able to stop splitting the folio when adding >> to the swap cache. Ideally. we'd add the whole 2MB and write it back >> as a single unit. > > This is already the case: adding to the swapcache doesn’t require splitting > THPs, but failing to allocate 2MB of contiguous swap slots will. > >> >> This is going to become much more important with memdescs. We'd have to >> allocate 512 struct folios to do this, which would be about 10 4kB pages, >> and if we're trying to swap out memory, we're probably low on memory. >> >> So I don't like this solution you have at all because it doesn't help us >> get to the solution we're going to need in about a year's time. >> > > Ridong might need to clarify why this splitting is occurring. If it’s due to the > failure to allocate swap slots, we still need a solution to address it. > > Thanks > Barry shrink_folio_list add_to_swap folio_alloc_swap get_swap_pages scan_swap_map_slots /* * Swapfile is not block device or not using clusters so unable * to allocate large entries. */ if (!(si->flags & SWP_BLKDEV) || !si->cluster_info) return 0; In my test, I use a file as swap, which is not 'SWP_BLKDEV'. So it failed to get get_swap_pages. I think this is a race issue between 'shrink_folio_list' executing and writing back asynchronously. In my test, 512 folios(THP split) were added to swap, only about 60 folios had not been written back when 'move_folios_to_lru' was invoked after 'shrink_folio_list'. What if writing back faster? Maybe this will happen even 32 folios(without THP) are in the 'folio_list' of shrink_folio_list's inputs. Best regards, Ridong