Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp267365ybg; Mon, 8 Jun 2020 23:24:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhMGgWnzSzCH/Xzzjp5szsn5W3Te1F12YYU1U+sipOsiNeXYmxafsWiCOEI8FlaS/ySLPp X-Received: by 2002:a17:906:4d0b:: with SMTP id r11mr23617789eju.59.1591683894788; Mon, 08 Jun 2020 23:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591683894; cv=none; d=google.com; s=arc-20160816; b=ayhZfY6vlzQca5BkYeuLpm9ad55GqL9Th3FgJTMFqlTR+2B41U5VIA7gQxqdBjbz55 6xh+XO3Ar86hNnTxOhT4zaCukqpoHkAuj8Dq4WX3I9UmqfkQseJw8bTloU1/+ukpFDE9 vk7HBC1pG0L3DF/+xwid06YGbR0P7O8BGoHcdsPIUVViOa+XtF9+hKlDsBLHlMJZBMDw KtDQgPEtvxhdbC45Tmbn6f5clQnKS/9qC2K1qirHXsMG78cePn7X92rdsp/cdGqfU4/6 AC4HPqaWSQL3s1e/NhIdrj27484O593H6tdBqIEQ6QLmTztcQi52Vp/0H88ZglrHE5Vc PyHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qjb8qEBmbuxNu1rg1xJE74o0cBFJkDEp4RqvXUvcj7g=; b=qvxnAykor8J7TPBHQflkWMDHUJ+yJxwmgdrvZLf4b0lm95MVIIOiIM3LBHg/251D6Q 2FQ6JJlTMEuWspKeCrcV7E9dzLvmoo6t+nrR+qgxD9JmhAWBeEsvArGLGS2dk7EqOQ4S 53jqvs6kZqfyPV5Mv6UfDcat2YbkNisfTfzw+jrArGsq4QirU0mX+dRir3HxovRynPqy /rxB78lOe6kk2gCYrKeSGkt46y0XOKqK4pBsnIKz7F+Pcqcpk3eqX1A59U38dRL2GjDq srFIM2EDq0jpGJRJROYEygsL5hyfA+yO45C/nyhhzzJttMH84/pdhMDVg2oUnbt6YwbY bFEQ== 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 l2si8514290ejg.443.2020.06.08.23.24.31; Mon, 08 Jun 2020 23:24:54 -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 S1727040AbgFIGTi (ORCPT + 99 others); Tue, 9 Jun 2020 02:19:38 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:59192 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726886AbgFIGTh (ORCPT ); Tue, 9 Jun 2020 02:19:37 -0400 Received: from mail-wr1-f69.google.com ([209.85.221.69]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jiXbi-0008Bn-Rl for linux-kernel@vger.kernel.org; Tue, 09 Jun 2020 06:19:34 +0000 Received: by mail-wr1-f69.google.com with SMTP id o1so8111066wrm.17 for ; Mon, 08 Jun 2020 23:19:34 -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=qjb8qEBmbuxNu1rg1xJE74o0cBFJkDEp4RqvXUvcj7g=; b=S/9SLjWLHRV/ddT+xOwWdA9ovM1awHVF7CZQvj5qeY7knBX008wIM/xTICixElSFT0 dRQ3ybqWr5RvgdMlCdmbom+uYpo16XhhPIBQOpz24ZtRGMj7PSer334DPhqvRCWRaSem mFAt10tGBUIOqVX1+JuAe8UtNspnlEIztUY9L9CZngyjXUXByUMbA7Id3M6Of5KTRSnv JAW6asDnz2QFhYfzuZQCeIgeAyR9GEUn1Twjip/2TNCwZZSGF0+XYiU6dUydchnlTVmJ JpwLzxLw+4ceEMBEmC1gesWP6NNCFO9fw6ic/f2N9hbk31Dno0B0TmRMX4jv2U2McPHW wQzw== X-Gm-Message-State: AOAM533KZDiTISYQ+UoQcXBnPgmUdAaDZMi1hd9H/HIFd/tJYSrRbAdc rkonBSQA5eCjrhAO/QWApxqhlneJCFWFutlIckB6k6/1hpH7iEMgXGPwDnBV//kAotpHv5hkXi3 17EUxVL5Cpbx6/PWj70s/OoNXdlMzWBUP7lQbDTQQsw== X-Received: by 2002:adf:f611:: with SMTP id t17mr2488213wrp.69.1591683574301; Mon, 08 Jun 2020 23:19:34 -0700 (PDT) X-Received: by 2002:adf:f611:: with SMTP id t17mr2488180wrp.69.1591683573984; Mon, 08 Jun 2020 23:19:33 -0700 (PDT) Received: from localhost (host-79-43-135-105.retail.telecomitalia.it. [79.43.135.105]) by smtp.gmail.com with ESMTPSA id s7sm2062721wrr.60.2020.06.08.23.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2020 23:19:33 -0700 (PDT) Date: Tue, 9 Jun 2020 08:19:31 +0200 From: Andrea Righi To: Luigi Semenzato Cc: 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: <20200609061931.GH8413@xps-13> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 08, 2020 at 03:23:22PM -0700, Luigi Semenzato wrote: > Hi Andrea, > > 1. This mechanism is quite general. It is possible that, although > hibernation may be an important use, there will be other uses for it. > I suggest leaving the hibernation example and performance analysis, > but not mentioning PM or hibernation in the patch subject. I was actually thinking to make this feature even more generic, since there might be other potential users of this forced "memory reclaim" feature outside hibernation. So, instead of adding the new sysfs files under /sys/power/mm_reclaim/, maybe move them to /sys/kernel/mm/ (since it's more like a mm feature, rather than a PM/hibernation feature). > > 2. It may be useful to have run_show() return the number of pages > reclaimed in the last attempt. (I had suggested something similar in > https://lore.kernel.org/linux-mm/CAA25o9SxajRaa+ZyhvTYdaKdXokcrNYXgEUimax4sUJGCmRYLA@mail.gmail.com/). I like this idea, I'll add that in the next version. > > 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. > > Thanks! Thanks for your review! -Andrea