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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56D90C43465 for ; Mon, 21 Sep 2020 16:27:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD66E2396D for ; Mon, 21 Sep 2020 16:27:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD66E2396D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 56D2E900091; Mon, 21 Sep 2020 12:27:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51D9390008B; Mon, 21 Sep 2020 12:27:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 433C0900091; Mon, 21 Sep 2020 12:27:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id 2998690008B for ; Mon, 21 Sep 2020 12:27:28 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D0775362C for ; Mon, 21 Sep 2020 16:27:27 +0000 (UTC) X-FDA: 77287598934.12.cent63_3d11d4227146 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id B533718002DBD for ; Mon, 21 Sep 2020 16:27:27 +0000 (UTC) X-HE-Tag: cent63_3d11d4227146 X-Filterd-Recvd-Size: 6049 Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Sep 2020 16:27:26 +0000 (UTC) Received: from mail-wm1-f70.google.com ([209.85.128.70]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kKOez-0003Qb-Mn for linux-mm@kvack.org; Mon, 21 Sep 2020 16:27:25 +0000 Received: by mail-wm1-f70.google.com with SMTP id a7so45910wmc.2 for ; Mon, 21 Sep 2020 09:27:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=thDClgHDaKGbmUezXRj7DdU1OZCmKXxi2A/KuiV5pMQ=; b=pzXz5e1DaeiIEubl8Vvl/tXbmPT61to7SZx3KeTia7dM723vgxyoHobdNg/I338xis Sg6TeaM3QhJVLCe24dOW2nzHoMKjVBssSCcRZtj258E3o13aQ7G2MqyciyQdnsey9/Tg 82U71UmDMI3L2knlK3xN2a2ST+8Xfsr98RhQPTIat/5Ff3fIiPAsgHMbo8r4uj6Y3Cyq GS2WJz/NMVjlCmqjmiY71LtkOZO7kpYtN+FiM29NEZLk8HrrHmtfbdUIbrwyb2FcFd76 /zBdOdHWXbiDP7xjx079xvhWt4mXlsrKs/WSy/cpYUQzH+im6jEughDWN7y/qosR20TQ xJBQ== X-Gm-Message-State: AOAM530L0IRlfYmO85GRxLlHkhxrkPf7nmavXaQy+lMgPZzmkCMY1czr jBoQwPCwyZ6GQHNBtbKWDTqIELq6TnLxOukPX9yfWJa31DFroaNEzwTSBSAOktxP165cWJvmvxO BIOCf8bGN8LZGuCI8NPFoV06gRk7x X-Received: by 2002:a5d:6a47:: with SMTP id t7mr574920wrw.75.1600705643860; Mon, 21 Sep 2020 09:27:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgJrK69H5PmmGl9KT2Fwv90aaZb1pxl44DuDt74XBRogjWPGU1j/n5jv6ePksnPSVZYiRRZg== X-Received: by 2002:a5d:6a47:: with SMTP id t7mr574894wrw.75.1600705643549; Mon, 21 Sep 2020 09:27:23 -0700 (PDT) Received: from localhost (host-79-50-195-5.retail.telecomitalia.it. [79.50.195.5]) by smtp.gmail.com with ESMTPSA id q15sm21147833wrr.8.2020.09.21.09.27.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:27:22 -0700 (PDT) Date: Mon, 21 Sep 2020 18:27:21 +0200 From: Andrea Righi To: "Rafael J. Wysocki" Cc: Luigi Semenzato , Pavel Machek , linux-kernel , Linux Memory Management List , Linux PM , Andrew Morton , Len Brown , "Rafael J . Wysocki" Subject: Re: [RFC PATCH 2/2] PM: hibernate: introduce opportunistic memory reclaim Message-ID: <20200921162721.GB3203@xps-13> References: <20200609061931.GH8413@xps-13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon, Sep 21, 2020 at 05:36:30PM +0200, Rafael J. Wysocki wrote: ... > > > 3. It is not clear how much mm_reclaim/release is going to help. If > > > the preloading of the swapped-out pages uses some kind of LIFO order, > > > and can batch multiple pages, then it might help. Otherwise demand > > > paging is likely to be more effective. If the preloading does indeed > > > help, it may be useful to explain why in the commit message. > > > > Swap readahead helps a lot in terms of performance if we preload all at > > once. But I agree that for the majority of cases on-demand paging just > > works fine. > > > > My specific use-case for mm_reclaim/release is to make sure a VM > > that is just resumed is immediately "fast" by preloading the swapped-out > > pages back to memory all at once. > > > > Without mm_reclaim/release I've been using the trick of running swapoff > > followed by a swapon to force all the pages back to memory, but it's > > kinda ugly and I was looking for a better way to do this. I've been > > trying also the ptrace() + reading all the VMAs via /proc/pid/mem, it > > works, but it's not as fast as swapoff+swapon or mm_reclaim/release. > > > > I'll report performance numbers of mm_reclaim/release vs ptrace() + > > /proc/pid/mem in the next version of this patch. > > Sorry for the huge delay. > > I'm wondering what your vision regarding the use of this mechanism in > practice is? > > In the "Testing" part of the changelog you say that "in the > 5.7-mm_reclaim case a user-space daemon detects when the system is > idle and triggers the opportunistic memory reclaim via > /sys/power/mm_reclaim/run", but this may not be entirely practical, > because hibernation is not triggered every time the system is idle. > > In particular, how much time is required for the opportunistic reclaim > to run before hibernation so as to make a significant difference? > > Thanks! Hi Raphael, the typical use-case for this feature is to hibernate "spot" cloud instances (low-priority instances that can be stopped at any time to prioritize more privileged instances, see for example [1]). In this scenario hibernation can be used as a "nicer" way to stop low priority instances, instead of shutting them down. Opportunistic memory reclaim doesn't really reduce the time to hibernate overall: performance wise regular hibernation and hibernation w/ opportunistic reclaim require pretty much the same time. But the advantage of opportunistic reclaim is that we can "prepare" a system for hibernation using some idle time, so when we really need to hibernate a low priority instance, because a high priority instance requires to run, hibernation can be significantly faster. What do you think about it? Do you see a better way to achieve this goal? Thanks, -Andrea [1] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-interruptions.html