Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp643775ybz; Wed, 15 Apr 2020 15:49:13 -0700 (PDT) X-Google-Smtp-Source: APiQypKNCMM4CRbhHB4uoxxYrCDaJQZ4Cxu1Yc23tzifhJ/oBnCo2xzhhrfrSlsw/KI5m8YqZHez X-Received: by 2002:a17:906:29c4:: with SMTP id y4mr7115933eje.95.1586990953194; Wed, 15 Apr 2020 15:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586990953; cv=none; d=google.com; s=arc-20160816; b=Ke7ftqUTI8IJqq7Tw/5d8CEWjApJGWZuvcElazHGGnvL/HpOEv0UoRAWNcMqtfLWfV G6z4DR2FKvU7g+Iahz8rbivLi0RcWpNQOOP0NcD9I7WuyM/oJBZozL+SlyH3VntW5SBh 4YIgHeWUZs9vKrd2R054kWSG20nUUZmblXJ5KMmPy7bdaKAy8tLCkqQRAlve14/JivLv 7564MFVe/wrE2iS1gWP690z3lUjp5I8cA8MknrYhEUP6fGRqiKYUzOIPycV+3IoIyyOw wwbh0o/wmqhXuMc9zfHtJ2DMKSmzVUgKsoa3/wZyUA0H1GddDGvljdxQULSq9wzRaJXc GJzA== 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=hJDx2/Ye85WrB55AQggZQs08fhv4a4xuGB8LKsw6eUc=; b=OPiaZAtVPZbUsY3mfz8EP44F/6rACELF9sX1GXtcTFbjfotdY3pOWJTgoAMfTKDp8f SJIMqzey5VullvrfdX5QfhmP5Vb0WGlwoTDwsqSeBFD9XeMker97Qmyeu3zI1HTxRwkR GPfitWk/UszeogLRD6EgjYmh2wpDrWTAOmnB2l3YFg/N7cZr9KV+XftvPKCN05YeHMK9 q900KNuuDqtFxfLAJh8rUgUyWmi9WesiLQ/GTzrIqKQKtHtYtmfH5FYTik4J85InLR1F ZzOffJjD90Y9NkqdJmelhEd4G/RuFOQB9gF9mmz+N9e2dCjg/XLsDVo8xfXRGMco8sVu 4sQA== 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 pk26si7082473ejb.404.2020.04.15.15.48.50; Wed, 15 Apr 2020 15:49:13 -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 S2405270AbgDOJUE (ORCPT + 99 others); Wed, 15 Apr 2020 05:20:04 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:54967 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2895317AbgDOJTw (ORCPT ); Wed, 15 Apr 2020 05:19:52 -0400 Received: from mail-wr1-f72.google.com ([209.85.221.72]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jOeD0-0006T8-PL for linux-kernel@vger.kernel.org; Wed, 15 Apr 2020 09:19:50 +0000 Received: by mail-wr1-f72.google.com with SMTP id m5so7141812wru.15 for ; Wed, 15 Apr 2020 02:19:50 -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=hJDx2/Ye85WrB55AQggZQs08fhv4a4xuGB8LKsw6eUc=; b=n1Vu0549MAm2KAXygRpbubp0/gO4yLioSSvg4qyYEXphX4egWn0YSDTJ3OxaURICsn 7ZBEs6vu0tKH83Wgl2+AI7skmuWS4VMU/8Ozn//QPhtDYXYExrzQRHH3yL4yxNOPu22y Sm5VqpmP2+SrIlAvi144/JFcrPF5POWujX/i85HWozRugWj7gJSqjFPmHTv6FozZoQU1 0LG2zs6EWXBDlPKAmilvEOiU6SHVJY2kwiahefpYyExvJ1/Gx80yYpfo4D7CD2v9eE0B q5pOPGfU94y5a6stjAV7SiGq5/uYljHlFuhfs668XzIeHQcFTMfSZMiUJaAkyuliHtXt Iklg== X-Gm-Message-State: AGi0PuZrLMY6M3mq5+zq3cGIUaC4aubUZ+i0IElbvacmzQGdqVqqf3N/ bzWX3Vr9hsYPJm4LhMnBracUGF0UuhRqyfTrLoi1Zpyimru/yNNjF40wP9XTXbNpKDvOWcv7Gj7 Vxh/qT5OeOxnQNMMd1t4OhlBwKH38L6EpOr/4HZX4QQ== X-Received: by 2002:a5d:53c4:: with SMTP id a4mr26991560wrw.47.1586942390435; Wed, 15 Apr 2020 02:19:50 -0700 (PDT) X-Received: by 2002:a5d:53c4:: with SMTP id a4mr26991543wrw.47.1586942390161; Wed, 15 Apr 2020 02:19:50 -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 j124sm21831962wmb.25.2020.04.15.02.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 02:19:49 -0700 (PDT) Date: Wed, 15 Apr 2020 11:19:48 +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 v2] mm: swap: use fixed-size readahead during swapoff Message-ID: <20200415091948.GH810380@xps-13> References: <20200413111810.GA801367@xps-13> <87a73f7d71.fsf@yhuang-dev.intel.com> <20200413133150.GA810380@xps-13> <87wo6i6efn.fsf@yhuang-dev.intel.com> <20200414130520.GF810380@xps-13> <87v9m1zd83.fsf@yhuang-dev.intel.com> <20200415073239.GG810380@xps-13> <87imi1yz07.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87imi1yz07.fsf@yhuang-dev.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 15, 2020 at 03:44:08PM +0800, Huang, Ying wrote: > Andrea Righi writes: > > > mm/swapfile.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/mm/swapfile.c b/mm/swapfile.c > > index 9fd47e6f7a86..cb9eb517178d 100644 > > --- a/mm/swapfile.c > > +++ b/mm/swapfile.c > > @@ -1944,7 +1944,9 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, > > vmf.pmd = pmd; > > last_ra = atomic_read(&last_readahead_pages); > > atomic_set(&swapin_readahead_hits, last_ra); > > You need to remove the above 2 lines firstly. Meh... too much enthusiasm, and I definitely need more coffee this morning. Here's the right patch applied: diff --git a/mm/swapfile.c b/mm/swapfile.c index 5871a2aa86a5..8b38441b66fa 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1940,7 +1940,9 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, vmf.vma = vma; vmf.address = addr; vmf.pmd = pmd; - page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE, &vmf); + page = lookup_swap_cache(entry, vma, addr); + if (!page) + page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE, &vmf); if (!page) { if (*swap_map == 0 || *swap_map == SWAP_MAP_BAD) goto try_next; And following the right results: r::swapin_nr_pages(unsigned long offset):unsigned long:$retval COUNT EVENT 1618 $retval = 1 4960 $retval = 2 41315 $retval = 4 103521 $retval = 8 swapoff time: 12.19s So, not as good as the fixed-size readahead, but it's definitely an improvement, considering that the swapoff time is ~22s without this patch applied. I think this change can be a simple and reasonable compromise. Thanks again and sorry for the noise, -Andrea