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 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 DC477C2BA19 for ; Mon, 13 Apr 2020 09:00:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8500820678 for ; Mon, 13 Apr 2020 09:00:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8500820678 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 E0E2B8E00D0; Mon, 13 Apr 2020 05:00:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBEB98E0001; Mon, 13 Apr 2020 05:00:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAC648E00D0; Mon, 13 Apr 2020 05:00:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id B1FBB8E0001 for ; Mon, 13 Apr 2020 05:00:03 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 71D21A753 for ; Mon, 13 Apr 2020 09:00:03 +0000 (UTC) X-FDA: 76702234686.10.boys52_3aa2ebb733545 X-HE-Tag: boys52_3aa2ebb733545 X-Filterd-Recvd-Size: 5300 Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Apr 2020 09:00:02 +0000 (UTC) Received: from mail-wm1-f71.google.com ([209.85.128.71]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jNuwj-00027B-Aq for linux-mm@kvack.org; Mon, 13 Apr 2020 09:00:01 +0000 Received: by mail-wm1-f71.google.com with SMTP id f81so2520050wmf.2 for ; Mon, 13 Apr 2020 02:00:01 -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=dqaVgDuR+jsoqCcuhbWmbCJxWXz5zIXCT9Qm1oMFDEg=; b=Up0ERWGgoFYRQFuA6eQ+8jat8XAUm9an7RlnTnvKmAlgqb7OMNT9OFt8VQEu/LIA9w cSeRlaHhh4RrISFh1oD5f+ceXZoY9ICmGhlP5Fk59hBeLF8E/xNjrKbk0wiSb58mknzg PFSAeiJjuaY2u+7HIix2WuwR8QNJ+ojVfOniMZAtlWgT9ZNzb/+8kRnIAdlAXrLCvwap fO1SgwAE7j+7w7DuYta0yC93IawxkT27eI31HVG7OgnlZE+5ZaG/nlJBq3LdM8YxqPun WU0Z9Rj4PKwDsbnIV2c7+8JR9DGmR7PExbeRRCosvVJlvfQNL2KNbSDxfySxI1yd9MBd JCpw== X-Gm-Message-State: AGi0PuYmETaYNnVPGIylk6dOhap9vk4CCV8oft5szWoyh9aPdLxRV6bz +vTACcTT5NgxS6ImJoKef4acfPlMVXHRvQ98Y/XkgzmxqzZwcm37vA4CRPeluF0N/wHNHJ/OKP2 3aPX5sEAuWeGipmskuh9kVtKPEwo/ X-Received: by 2002:a05:600c:29c2:: with SMTP id s2mr6231408wmd.111.1586768400906; Mon, 13 Apr 2020 02:00:00 -0700 (PDT) X-Google-Smtp-Source: APiQypI6ZEAMCe4PeQmXuzneBQEL00VI+kt+86GcGd2t8+RrOemXQ9+gOPyd/IPCHDxWNN6beyUQRA== X-Received: by 2002:a05:600c:29c2:: with SMTP id s2mr6231381wmd.111.1586768400509; Mon, 13 Apr 2020 02:00:00 -0700 (PDT) Received: from localhost (host123-127-dynamic.36-79-r.retail.telecomitalia.it. [79.36.127.123]) by smtp.gmail.com with ESMTPSA id m15sm13477488wmc.35.2020.04.13.01.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 02:00:00 -0700 (PDT) Date: Mon, 13 Apr 2020 10:59:58 +0200 From: Andrea Righi To: "Huang, Ying" Cc: Andrew Morton , Minchan Kim , Anchal Agarwal , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: swap: introduce fixed-size readahead policy Message-ID: <20200413085958.GA777469@xps-13> References: <20200412150449.GA740985@xps-13> <87d08c89fl.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d08c89fl.fsf@yhuang-dev.intel.com> 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, Apr 13, 2020 at 09:24:14AM +0800, Huang, Ying wrote: > Andrea Righi writes: > > > Introduce a new fixed-size swap-in readahead policy that can be selected > > at run-time. > > > > 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. > > > > This patch introduces a new sysfs interface > > (/sys/kernel/mm/swap/swap_ra_policy) that can be set as following: > > > > - 0: current scaling swap-in readahead policy (default) > > - 1: fixed-size readahead policy (size is determined by > > vm.page-cluster) > > > > 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). > > I don't know whether the use case is important or not. Usually the > performance of swapoff doesn't matter. Maybe you can provide some > information on this. In general yes, I agree, swapoff performance is not that important. This particular optimization has been tested a lot in the Ubuntu AWS kernel and it seems to speed up consistently the resume of hibernated EC2 instances (see also [1]). So we were considering to upstream this, if we find a way to make it more suitable for mainline inclusion. [1] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Hibernate.html > > Even if it's important, I don't think we really need to add another ABI. > You can just optimize the swapoff performance inside kernel. And we may > not even need to add a new policy, just use cluster readahead and > increase swapin_readahead_hits in swapoff if cluster readahead is used. OK, instead of adding a new ABI I can make this optimization directly in the kernel, so that when swapoff runs it can automatically use the fixed-size cluster readahead and continue using the default readahead for everything else. I'll play a bit with this and will send a new patch. Thanks! -Andrea