Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6902693rwb; Wed, 18 Jan 2023 10:46:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXsujdoue9RyKMUefOL/QW4vR+//Xtf85c+Mdp56jEBezihp+MayVpeUKUImxljwNSEd8iYH X-Received: by 2002:a17:90a:7787:b0:225:a226:9fbb with SMTP id v7-20020a17090a778700b00225a2269fbbmr7757459pjk.39.1674067604589; Wed, 18 Jan 2023 10:46:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674067604; cv=none; d=google.com; s=arc-20160816; b=IFX3KIzPLG66O4z1wpk1KUZx1+pGol35agh+saFZjY9iIWCAhfa4+8DKECIW13Go/6 ye/aZsObCslblfvr4yNJTAuUqSYJQO4kxRWYav5uupFWtk82AseQDmaEm6ZaZ4UVCTrx JUck/+TuJMal3FEkuX0TuPPG2U6QrlUigY8CNjAiclfqsmasUaDJPILCknloU5oLr+tl 4YlXy+aRO0+38w9OKNDPnhx9Y6lbgG4MJEpSzMf75dz19d3EpGTRmSeEPTOtx4MUdc5k njtalgCsydz8Z60SoAzZUT6bF34e3YA+HJ/PjnUXRr+PBMwv+XvT6VeN2yHzcaCD2c3H AfKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=Dsa2aocPCtB2N2VNUCoUfZW6dXH2V8Mewh6jLvRwtQc=; b=U2WoFjkxaHOOSkcYHUvSREVfeAapjyhz7tyYltBrl5xgNLAEUW9qhsXcMSJ/DFwqQi 069FFIBo+QhnaiMl5YNgV/3KuSjxgGafh/qxUSl2qFI/EJtHG3QO2Y+ZSkWj1tiU5Yea Ad2tQ0hwwDsNIjm2wb4UwuGRwnWOZovBdmpQ1ZRlUIDV71rVPNVvnWNHKbUp6sbaUOCn 20UJ6qR/QI/06Gpk7aP6tdCUX01HgAbHXJRZ0piygvMQ0SG+4E8mZp9AZ1wenKizEy7D rltswoOHioxIAH+2phu0OJ0DTS+0/9bnsD7TtoxcL1Eyj16TrZm6oPzh1nHQquylbjxc 53xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FCuOHZye; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oa3-20020a17090b1bc300b00228d9b953easi2901398pjb.53.2023.01.18.10.46.39; Wed, 18 Jan 2023 10:46:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FCuOHZye; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230301AbjARSIb (ORCPT + 45 others); Wed, 18 Jan 2023 13:08:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbjARSIB (ORCPT ); Wed, 18 Jan 2023 13:08:01 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A14344ED0C for ; Wed, 18 Jan 2023 10:07:20 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id 36so25103661pgp.10 for ; Wed, 18 Jan 2023 10:07:20 -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=XtPFTlZWUPiOLv0cnRoOfnhXQNNK8Tez0AXWufOG9QQaoY5G943Poq6vU5+/POZ0Q3 YZh3+vYMeCcEJaM55gbF+sWPWAqxMTo0i/7cLTQkj38A5KACmyIjx9zd418V49C3P7zC e3EmRPJT7aoazHFjhxhIov47l53L4N9OFr6YQePuXX8KqDuyZqacQvJrpmH91TY+Ggwh a7+sbgpzTC8bmgnlRRD1yHY3m2bcuOYxZbXZrQWt+a1lMlGce9DATbjffbpI7X31ndoG huWbT8LJSBwTvVSTbW6/mbeBFf43wngU/14yBUmYSbrlzjSrr3i3JGLt4jUEo0kly3rr U4kQ== X-Gm-Message-State: AFqh2kq3AKpmsUOxsXaLlgIX1s9yp3EE/xkCf4iIrqCrf1Xw9/I254tG wpyOjkyUSGwqJlH54ramWuI= 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) Sender: Minchan Kim 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-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.