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 0492AC32793 for ; Wed, 18 Jan 2023 18:07:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D34E6B0072; Wed, 18 Jan 2023 13:07:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7835D6B0075; Wed, 18 Jan 2023 13:07:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6249E6B007B; Wed, 18 Jan 2023 13:07:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 551906B0072 for ; Wed, 18 Jan 2023 13:07:23 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1CB778035D for ; Wed, 18 Jan 2023 18:07:23 +0000 (UTC) X-FDA: 80368701966.02.BE4B635 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf20.hostedemail.com (Postfix) with ESMTP id 624ED1C001F for ; Wed, 18 Jan 2023 18:07:21 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FCuOHZye; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf20.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674065241; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Dsa2aocPCtB2N2VNUCoUfZW6dXH2V8Mewh6jLvRwtQc=; b=vMQSngtEtP+G4MFZtf0hokqG1iEXqMw0iHc5Jh37T3c/N2rDKtL9RWo77Fy4SKcknRcuN5 1xoZC6HwC6PP1F8121J6sSPXQF1VTR4KUnO1gK4GPNr0oZEGImFSsljZ1bS8aJ94kUNlzD MTeIHr6Sjl7+HoXyKYFT4IyM6K/YcO0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FCuOHZye; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf20.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674065241; a=rsa-sha256; cv=none; b=F0KRYplj1pLtfHsAoRuuAJwMyU0NHCsYWOhTXsGAlU8iisyvpWWPCZ7Ym7dq8JfXCOy7bF zxHnieMi3osn5TUTpTeec+mzAniNzUetRauMX2d3dG9ORd3sW3F/R3aFWjlkn2a/D9jzu0 pL61Jegj1136O2geH8hATYYWCi9pyVE= Received: by mail-pf1-f177.google.com with SMTP id 20so21428752pfu.13 for ; Wed, 18 Jan 2023 10:07:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=Dsa2aocPCtB2N2VNUCoUfZW6dXH2V8Mewh6jLvRwtQc=; b=FCuOHZyepTHi7gBVSWYK4ZAG1R1GyXAjt45k7HU/e+J2/TOXkGaIlcMTkWPzL6AQJs BMssM/TlCWrrhHpZpPQtl0ThiH8QR3mf7xxrGpZIaSbL8MzCWGNyeOANjOjh3FND7D2T mYII1xTpS2gD+55lCre1KufwCRCWo3mtDL5WqrBcukGz2DEPXKCjhklhUhka8yXbngDE /EsO5bjZJseBPvvvXS6neG6OZfmOCFLCzjiCanYZ+eK6b90XJNjzWSOi3Kzbhu67t9qU ik+hjkBlFex34Vun+CpMe/18dSa2WxgK6YnUM7y1ZyMlqX8PPLOG+m1+vsC2amX+t2Yw cmTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dsa2aocPCtB2N2VNUCoUfZW6dXH2V8Mewh6jLvRwtQc=; b=iX0DFipXhqnxXK/KViWLtEsGcQxEwKn+0qPCPLYBFD/KM6tk8lf83Wjw82FEB0mOWD m6GSph+mcwqLc9zRw69R1lKhDsoZ/1vbYtpJ0pUZCHvND4d69/g7w5IMSVAU08OXqi9H PjK7r3F+nAF9/87VbHLdWM93faUXPgOCTjEyLghLDuBxQCrbMhaX5iLlVqrU22eOZfyS 5e7hqNZoZc2hPIYkePUjFenCIkO1b9LBO9Eiu6SrZZykFHmsjb8KVY68C/S5eusMPKd8 u7Y7fmnCo+Li5jb9/pV4lPAH4EVeSv47ByNfxJblIuxn7eVO/MM4M0wMDbMrE87lUWCs clxQ== X-Gm-Message-State: AFqh2krb+C8otpwwWFDo4VhPjncfjEF8Z6I9cVwOTKQ2Wms80kgaJ649 RyaBlzN+Fcso9XP3uyK/5tA= X-Google-Smtp-Source: AMrXdXvcKEV7N0L+zm7gPu+9r/5SzUMhU9m4gSPiasQJhwN77+MF+E6N0Sq3xmvXdPd7bmPRYrJNRA== X-Received: by 2002:a62:6302:0:b0:582:848c:6281 with SMTP id x2-20020a626302000000b00582848c6281mr8332366pfb.2.1674065240149; Wed, 18 Jan 2023 10:07:20 -0800 (PST) Received: from google.com ([2620:15c:211:201:68ba:bd93:858:15d5]) by smtp.gmail.com with ESMTPSA id v15-20020aa799cf000000b0056bc5ad4862sm14068907pfi.28.2023.01.18.10.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 10:07:19 -0800 (PST) Date: Wed, 18 Jan 2023 10:07:17 -0800 From: Minchan Kim To: Michal Hocko Cc: Andrew Morton , Suren Baghdasaryan , Matthew Wilcox , linux-mm , LKML , SeongJae Park Subject: Re: [PATCH 1/3] mm: return the number of pages successfully paged out Message-ID: References: <20230117231632.2734737-1-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 624ED1C001F X-Stat-Signature: 75mciisczj3q1xmx7ohndex1aijo5s9j X-HE-Tag: 1674065241-84583 X-HE-Meta: U2FsdGVkX18V6CGX9KozD5ezqI0gCz1i18CJS+TtJJlIP59Jr4L8du7sQ4dIAA231WHgxN9i8vjYLoi6GnkfS9M3oiBES5VING1hH8IJ68qrPg9c94YjTsN85Tl5UpAhuiCoygIFurI7ANc7s6BQP0+IHeouwKr1ObRm7BO/00xfSJdJKe13kb7Z4DGdjJRGwMeA28ECK5Da+lDJfcZ9wscVvRJaDF8qIYxFl2CtKpGI+lL3YB8SjTg3Ri4N6mPVs/Vi8U0xVkYymhIwwH5+r5XXHMLPUMbulM53lV6aA90wydQ/1nlrGySHYD4VAdKSBzQFoBHqRGykQlGyLBeUv6JKY6rgWQyllPF6zNAmQd9Trv8liYip4zrEkYfXIzmNI3DbaedDZBBYlx6wmf/9GH2hx8mesPfwIHG8DpjFAR5y1/Ju9LxFwZiLpx66+bel4pptttCSichw3+droAzQMssqkivqxZfioaokqzqkgvc7id1wYW7Zk3+iBo/t7ANUTuLksU+7P2tBn8iRp46mJQ7AcUHOVYNE+p/h76TXxgXlEEnsbC7KaFSA0jyeiWdxd371D2PrlyU7NfueETloG/vnenk7ba8SfVp7rF4PyynG38F3+f20jnuKJlqOll4pPCbGw0RWmukMaQVfKIIaC6Xt72MX1wu/rGxibNqomYbwCLKPdP+ucA+Rc/nrDB0BElOyBPvxgp9YetBPfVWi0tyLUKPcvDOLJnFvC6MwSBHiM3C5VSiIFIGhfTEOVwEb6/6Vi7Z79ylWobgDelGcIZ2UpYggePhM0mo3EiU+0unVXzkPKcRKG+NtbkiitEkYMY7Ci51V8bb+UgmdPGWKkzxBpDWMULA8U8UwmmxMA5b9XP/jSErw7IJag/69Wo+ley/jZ1YQaI2PVH5+gwfgOMK7GKgIE/2NVWs/+fya4D1ebSDtSBJ5aPqYKLBBn085WJ/9gkZosGBwTPu9IyZ Gan8e6eu xFmys5KfwVA8d/4Z6JoGJm5NYG/0JTFCf9UEmXh5r7KRgZN2rcQyE/XSiFZTDu1eW8z3qM7Uz+nITt+uAVS4QVZrxrbLG07i8deYAWn061ESm9cspCNx4ytjqJ8OMkvYR8GtjuT5SrzSTemh8IRsc4B5i/KU6dJo+yY8Y5mVkZOP3apJf74NOyz2VlGfRr2bb2daJFtOrVckOpbQUJ01Wrxq9A0DZntkoMiIlUpIEvuaLsm8TBXgSdZviWmuz5MXbBYRXRTApNQ5y3TpOEN26G/8nEFuR2Trd8vJ+EgkzMJ4Tgsk= 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: On Wed, Jan 18, 2023 at 06:35:32PM +0100, Michal Hocko wrote: > On Wed 18-01-23 09:09:36, Minchan Kim wrote: > > On Wed, Jan 18, 2023 at 10:10:44AM +0100, Michal Hocko wrote: > > > On Tue 17-01-23 15:16:30, Minchan Kim wrote: > > > > The reclaim_pages MADV_PAGEOUT uses needs to return the number of > > > > pages paged-out successfully, not only the number of reclaimed pages > > > > in the operation because those pages paged-out successfully will be > > > > reclaimed easily at the memory pressure due to asynchronous writeback > > > > rotation(i.e., PG_reclaim with folio_rotate_reclaimable). > > > > > > > > This patch renames the reclaim_pages with paging_out(with hope that > > > > it's clear from operation point of view) and then adds a additional > > > > stat in reclaim_stat to represent the number of paged-out but kept > > > > in the memory for rotation on writeback completion. > > > > > > > > With that stat, madvise_pageout can know how many pages were paged-out > > > > successfully as well as reclaimed. The return value will be used for > > > > statistics in next patch. > > > > > > I really fail to see the reson for the rename and paging_out doesn't > > > even make much sense as a name TBH. > > > > Currently, what we are doing to reclaim memory is > > > > reclaim_folio_list > > shrink_folio_list > > if (folio_mapped(folio)) > > try_to_unmap(folio) > > > > if (folio_test_dirty(folio)) > > pageout > > > > Based on the structure, pageout is just one of way to reclaim memory. > > > > With MADV_PAGEOUT, what user want to know how many pages > > were paged out as they requested(from userspace PoV, how many times > > pages fault happens in future accesses), not the number of reclaimed > > pages shrink_folio_list returns currently. > > > > In the sense, I wanted to distinguish between reclaim and pageout. > > But MADV_PAGEOUT is documented to trigger memory reclaim in general > not a pageout. Let me quote from the man page > : Reclaim a given range of pages. This is done to free up memory occupied > : by these pages. IMO, we need to change the documentation something like this. : Try to reclaim a given range of pages. The reclaim carries on the unmap pages from address space and then write them out to backing storage. It could help to free up memory occupied by these pages or improve memory reclaim efficiency. > > Sure anonymous pages can be paged out to the swap storage but with the > upcomming multi-tiering it can be also "paged out" to a lower tier. All > that leads to freeing up memory that is currently mapped by that address > range. I am not familiar with multi-tiering. However, thing is the operation of pageout is synchronous or not. If it's synchronous(IOW, when the pageout returns, the page was really written to the storage), yes, it can reclaim memory. If the backing storage is asynchrnous device (which is *major* these days), we cannot reclaim the memory but just wrote the page to the storage with hope it could help reclaim speed at next iteration of reclaim. > > Anyway, what do you actually meen by distinguishing between reclaim and > pageout. Aren't those just two names for the same thing? reclaim is realy memory freeing but pageout is just one of the way to achieve the memory freeing, which is not guaranteed depending on backing storage's speed.