Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3277472pxk; Mon, 21 Sep 2020 09:29:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZXeJ7s/Ps/AKObS6tfkiFKOCS6pL9LF2EopCw02YHpksN7PLhsrZm1Mrc/8GrnOjWfNwj X-Received: by 2002:a17:906:eced:: with SMTP id qt13mr226705ejb.357.1600705792319; Mon, 21 Sep 2020 09:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600705792; cv=none; d=google.com; s=arc-20160816; b=csa19V6l7koEatSljh7yc284gHt2J+oNzpdpQe+yNlswTh82dIdn9l4r9fbP1dPM2T 4Ub0+Ga/8lZ9IxdqwL0aku+dgORA8Os/cYh5M64DbQigmBmEAj5w0CaSf4HyLDqYS2up Z9a3QqxbD6g2iOl/BDmW2jXzsq+/smDk77ilz6FcSwP08RVS+R+QztiROrfLHEVq5KIU ZIAf4ry9XlNgPY/XMxWGpq82GrkNx/bx/ogspnr3DYcSMjb6myQur6qFT8Ch8wcgU+Fk G9iEeR4glQeEpDSyh8SmD8DSha1DEGlRwDdlxjkDq1ZtCvrZ5N+0y9ugI6f/dGqV7Aij WYug== 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; bh=thDClgHDaKGbmUezXRj7DdU1OZCmKXxi2A/KuiV5pMQ=; b=aJEKInYOdV4QTfDvqb1xNdqZ5SuBXBOhaIRoCtK7c+qm4TzLBtInXhJQs64AWyDug2 /IDhhMlSBrM1mdVEig32perWfgcktMUqdCgKp6WRksSgvi0vbv6Ux54E0KXl0n8DhFBY iuODWigG/c7bjDJuctWQdXgEugRRHKAmfRY/o/roWHnL2fnTtcrero0+LeBvOH1qF2Mp a4T8p4ZmXgA6CP12Z/IjbO4pL6dO8Z2tzTbQl2hK23Ea3Ms/BESlJwQ0Qn1cOsjOo0XO Sfxd1/HZfnUukey2egIwLu3B27I8mBoY7rpmtQrT60o5dr621Nap0QCgmfL16pOmenT3 Bcsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q25si8296991edb.467.2020.09.21.09.29.28; Mon, 21 Sep 2020 09:29:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728317AbgIUQ12 (ORCPT + 99 others); Mon, 21 Sep 2020 12:27:28 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:39658 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbgIUQ11 (ORCPT ); Mon, 21 Sep 2020 12:27:27 -0400 Received: from mail-wm1-f69.google.com ([209.85.128.69]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kKOey-0003Q9-Ao for linux-kernel@vger.kernel.org; Mon, 21 Sep 2020 16:27:24 +0000 Received: by mail-wm1-f69.google.com with SMTP id w3so40992wmg.4 for ; Mon, 21 Sep 2020 09:27:24 -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=mrvqDwjJkEIwZh3Kn3zoSMRgB4nB8ow0N2SoxHykdPxu4q4+IBlWy5nFESqMzgh1ZF 213ZzeUDwMYuaAkXr91aqf0g00GcbqkjGe9k2Dy+J2XK8xRwgFfnhqaVGw7cMMb024Fz /NSPOAgNI9+LURYd3mXYwQWbttafCPes8dUaLtmbyosy5PVB55zfRSLxHLLBT0XXyUD7 utYZ+PuTdcnMVfh01dT7pkVq3V+tDttnUACc79acXIjKxZ2wntxf33zSp90sHCABkV+F 7z+sVWiNupmBVFeC56mRbqGUUBLP2fGDvYqEokAO4aYoB0BF+jXL6qctetD4PncmIEEn oOow== X-Gm-Message-State: AOAM531Qmw0oqi5AVYZZS3AOI7dgQcMWzAjcEWP7gxfpgi6dSOOmOjX7 ZFpttJ8T7QcbmhRase7n9AdVd/18wbGjP67hyQlA8IN4uvqGpj/epYjoniQ2NNPhzwAymDCXDkY tBncKL6qlOlinUD0ts6QHDiT8ldymmtz8oyGp3F5w4g== X-Received: by 2002:a5d:6a47:: with SMTP id t7mr574919wrw.75.1600705643860; Mon, 21 Sep 2020 09:27:23 -0700 (PDT) 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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