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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 7673CC2BA2B for ; Tue, 14 Apr 2020 01:45:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 36D0E206B6 for ; Tue, 14 Apr 2020 01:45:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36D0E206B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A7E428E0003; Mon, 13 Apr 2020 21:45:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A2E7B8E0001; Mon, 13 Apr 2020 21:45:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96AAF8E0003; Mon, 13 Apr 2020 21:45:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id 811B38E0001 for ; Mon, 13 Apr 2020 21:45:44 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4392C181AEF23 for ; Tue, 14 Apr 2020 01:45:44 +0000 (UTC) X-FDA: 76704769008.21.brass37_6c3ab3d47f83d X-HE-Tag: brass37_6c3ab3d47f83d X-Filterd-Recvd-Size: 3756 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 01:45:43 +0000 (UTC) IronPort-SDR: n+6n7IcpgDpBBlbfL6kWJoq71moVDPVZ58IWhOFtegSBSpvD83vFr5+54BHxowcM310ay7O+N0 iFKCFLAWDagA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2020 18:45:42 -0700 IronPort-SDR: UexRrFsjgpHMwK9A/oshz470Jyjmt45pDLe5ZgnWgwlNmXbLHxziiQ0KeEPirtr6TXqNxuNBWf KflPfxfdcp7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,381,1580803200"; d="scan'208";a="256353181" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by orsmga006.jf.intel.com with ESMTP; 13 Apr 2020 18:45:40 -0700 From: "Huang\, Ying" To: Andrea Righi Cc: Andrew Morton , Minchan Kim , Anchal Agarwal , , Subject: Re: [PATCH v2] mm: swap: use fixed-size readahead during swapoff References: <20200413111810.GA801367@xps-13> <875ze37cle.fsf@yhuang-dev.intel.com> <20200413132658.GB801367@xps-13> Date: Tue, 14 Apr 2020 09:45:39 +0800 In-Reply-To: <20200413132658.GB801367@xps-13> (Andrea Righi's message of "Mon, 13 Apr 2020 15:26:58 +0200") Message-ID: <87sgh66drw.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii 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: Andrea Righi writes: > On Mon, Apr 13, 2020 at 09:13:33PM +0800, Huang, Ying wrote: >> Andrea Righi writes: >> >> > The global swap-in readahead policy takes in account the previous access >> > patterns, using a scaling heuristic to determine the optimal readahead >> > chunk dynamically. >> > >> > This works pretty well in most cases, but like any heuristic there are >> > specific cases when this approach is not ideal, for example the swapoff >> > scenario. >> > >> > During swapoff we just want to load back into memory all the swapped-out >> > pages and for this specific use case a fixed-size readahead is more >> > efficient. >> > >> > The specific use case this patch is addressing is to improve swapoff >> > performance when a VM has been hibernated, resumed and all memory needs >> > to be forced back to RAM by disabling swap (see the test case below). >> >> Why do you need to swapoff after resuming? The swap device isn't used >> except hibernation? I guess the process is, >> >> 1) add swap device to VM >> 2) hibernate >> 3) resume >> 4) swapoff > > Correct, the swap device is used only for hibernation, when the system > is resumed the swap is disabled (swapoff). > >> >> Some pages are swapped out in step 2? If os, can we just set >> /proc/sys/vm/swappiness to 0 to avoid swapping in step 2? > > Sorry, can you elaborate more on this? All anonymous pages are swapped > out during step 2, it doesn't matter if we set swappiness to 0, they are > swapped out anyway, because we need save them somewhere in order to > hibernate, shutting down the system. All pages will be written to the swap device in step 2. But the normal swapout path isn't used. So these pages will be restored in step 3 instead of step 4. But at the beginning of step 2, system may try to reclaim some pages, the reclaimed anonymous pages will be restored in step 4. This may be avoided via setting /proc/sys/vm/swappiness to 0 before step 2. Best Regards, Huang, Ying > Thanks, > -Andrea