Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4315589ybb; Tue, 14 Apr 2020 05:01:54 -0700 (PDT) X-Google-Smtp-Source: APiQypKbtydHwVK0L0WXGDJObYmY1/oMUblaYfAgPBF7NQ4X9MuWz6DFE31TmPicHiut15JwZlmx X-Received: by 2002:a17:906:1502:: with SMTP id b2mr4759027ejd.359.1586865714033; Tue, 14 Apr 2020 05:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586865714; cv=none; d=google.com; s=arc-20160816; b=WmAy7kX7iUtaYz1NtLH0CDDaQm/sXb8bzNAWWtZRJc6PZX7WBTpLwClNarEcNQqOve uyTswFsB0nbkCvNP6ypUTZFPfy+6ycjcoCe8dKTlt3jsAMPPQyUBsG3kFK90c3+SwwSv H/5smTJcbO+d1Rz39uUSRahKZ0jnze/hCwIwwp8264clf8H+j863YykjkCIEYL6rKl9P 5dcvHZUJ9lBqHIK3Pk0G+/+Qw9sl08pLtFoYLU+/2EaPhHaB4mHTotkjKZu0BDLCCTRC 4ExukEu41/2bLu6VWhpBZTfH5H1wSWHqrUzCfxMg+ktBs2yGYKKGP86lwV+mXjfy+nOx F+uQ== 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=QaapbS3AwpMQJO1PlO7vQLfoDd/t8Pv7NCHZnFtR9R8=; b=lFKF3m1qdizh0J/3EeyS8jtJ7C1Ps4OMqJy+Zdte5hCrXnv4VWRdFpmAQR/80tqlUo fad7WK+5r7pszR3CrhuteApVdrl7wxP9C6sb5u2wHUNzp8zPo21fIE3xjdBNrmGv5e4r 833i584DPWazV1ATigcZMt0Lbed8EHVVkZMT4v2AQj1xbcvxhLOjyA57rrBwtYDB+tU9 OQUECOq7r/TGFCWagDpg1LHCenbjZJ2tFrd898FzO1/M2jgWQBjgpzkF8iw5d4B/1sig fQduvt0a2D+MU3wy3qFToXzCUf+4ldiTr3QXLHurzSvDqU4kqN4UmkiIk4R82Ys0ElJ3 bGzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for 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 ce9si7196059ejb.154.2020.04.14.05.01.29; Tue, 14 Apr 2020 05:01:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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: best guess record for 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 S1729886AbgDMNb4 (ORCPT + 99 others); Mon, 13 Apr 2020 09:31:56 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:35861 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729860AbgDMNbz (ORCPT ); Mon, 13 Apr 2020 09:31:55 -0400 Received: from mail-wm1-f72.google.com ([209.85.128.72]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jNzBo-0003if-SJ for linux-kernel@vger.kernel.org; Mon, 13 Apr 2020 13:31:53 +0000 Received: by mail-wm1-f72.google.com with SMTP id h22so1147809wml.1 for ; Mon, 13 Apr 2020 06:31:52 -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=QaapbS3AwpMQJO1PlO7vQLfoDd/t8Pv7NCHZnFtR9R8=; b=LDpcY0SHRN54MQX1X8AwMrYsgg+sSUCtgRKkt+ap34wfwLbeRacgzxMAT8Zjio7kC4 ZAriknCkgoRvCVHWlTHRmAmuM51Cz3YLE0OUIHVbE8sBLpkJWAQrkh4yXZuEXgRWrCqx bkx564XK6AaN1L+kEfBQZe7tOEV6er5dLmj9fOImKFJlrmF5B7EmFju7dQiFoF5bBHOu 7oqxX/bWWByebxUvitRDIWi8KR/4MWxHphq7Qm6xJCKX8CRE+b1sOj7KiqYaODCuS9vN cRH2hd1OsbuR9xqxHtn1gJkrITWZ6tyxZw/yPX/Th+oEEwQl30FMcfCBd22+GDUt//29 CSZg== X-Gm-Message-State: AGi0PuY4LSwRhxjtb0OeduQsjvEkMYAIi4+vq0Rsjlpjjij+aayyQ8lW PqfyIIunovh9MM6NzPrRbjiu8owoR/RUd5fzE/Wt1f2SfxlpXJT/2c1Tn715ahyePrwPCIRgkWG iQMRIYGoZa6Z3SdunbgVZVoRoCoGFylgTkQYhuzQ0pg== X-Received: by 2002:a7b:c247:: with SMTP id b7mr18717041wmj.35.1586784712514; Mon, 13 Apr 2020 06:31:52 -0700 (PDT) X-Received: by 2002:a7b:c247:: with SMTP id b7mr18717027wmj.35.1586784712276; Mon, 13 Apr 2020 06:31:52 -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 h17sm3289803wmm.6.2020.04.13.06.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 06:31:51 -0700 (PDT) Date: Mon, 13 Apr 2020 15:31:50 +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: <20200413133150.GA810380@xps-13> References: <20200413111810.GA801367@xps-13> <87a73f7d71.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a73f7d71.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 Mon, Apr 13, 2020 at 09:00:34PM +0800, Huang, Ying wrote: > Andrea Righi writes: > > [snip] > > > diff --git a/mm/swap_state.c b/mm/swap_state.c > > index ebed37bbf7a3..c71abc8df304 100644 > > --- a/mm/swap_state.c > > +++ b/mm/swap_state.c > > @@ -20,6 +20,7 @@ > > #include > > #include > > #include > > +#include > > #include > > > > #include > > @@ -507,6 +508,14 @@ static unsigned long swapin_nr_pages(unsigned long offset) > > max_pages = 1 << READ_ONCE(page_cluster); > > if (max_pages <= 1) > > return 1; > > + /* > > + * If current task is using too much memory or swapoff is running > > + * simply use the max readahead size. Since we likely want to load a > > + * lot of pages back into memory, using a fixed-size max readhaead can > > + * give better performance in this case. > > + */ > > + if (oom_task_origin(current)) > > + return max_pages; > > > > hits = atomic_xchg(&swapin_readahead_hits, 0); > > pages = __swapin_nr_pages(prev_offset, offset, hits, max_pages, > > Thinks this again. If my understanding were correct, the accessing > pattern during swapoff is sequential, why swap readahead doesn't work? > If so, can you root cause that firstly? Theoretically if the pattern is sequential the current heuristic should already select a big readahead size, but apparently it's not doing that. I'll repeat my tests tracing the readahead size during swapoff to see exactly what's going on here. Thanks, -Andrea