Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4026714img; Tue, 26 Mar 2019 01:14:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCWVA7XB817YQT6bq+yvuxSg8K2xVbBb2w6Ep6e+iUeiqBRd/EDvHG9wBWNEf0vqKhtxx/ X-Received: by 2002:a63:618d:: with SMTP id v135mr27683311pgb.2.1553588043578; Tue, 26 Mar 2019 01:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553588043; cv=none; d=google.com; s=arc-20160816; b=hYqMcKtt075z3P9oPm10alHdZorfKihBrue3AHCc5rszp5fMs5Ezc4ZLK6Pcayap6Z M9+xyvCwA99BR02pHkYkJNOHCzE6YosWncQUeohp1b71tM6fmsWWoCJ5KVty6KY8IOaI fOesceEiFanj/CTYE38r+sc04f7ag5xx+uVQOQ0Q82/gt2Rx5JHLy7GnMylXEoA4THMb +jeqi15ldHJ5GQQ8KqvzJDQPFu6zLZsM4SruqLfpPiXe8JHyJ9hOuJmlXY8oZ7ixi0Hb EvLqKD3pHClmrArG5vPVVrWK0Kmn2qA4L8IfTtnLmivYldS2JiIul3WTXexDhWniDYib ETZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YdFwkF4eUySjbpG+38wjJdvK3fCy24c6M03FoBUoupk=; b=gzv8uQ3DmNe5Ah/YEhDJFlObXivIJT6vaWDAAzfk1WPiW5BIiMMu+sDFyiTG2hW7XC nWV7nsk8Nc5hFdCZ30+yw2qY5uOG7AL85FjUylYNF66mQKN7Z3fTNb+FQafoGynIOo+c 0dpc1dw7Vm5PgQEj76e4iYXWkMswymKxuZDMj3VqxEfDi7hbCcxBeP7E5snKtd+vpc7n hT9bdgzVP+sru1CV4Ddl6tC2Qa7E2G6k8y4GUOsRjASIYH1J/4DhxCUa90xVIfRK5TtX D7Xyn2f6pIrGI6VuOoK9BWpym7CYG6ig5uA7qws/Zk1+HkNPiHywi6cjYhQLESdeRVVU /ykQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=k6XFJyGw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si14377824pgj.535.2019.03.26.01.13.49; Tue, 26 Mar 2019 01:14:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=k6XFJyGw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731155AbfCZIMo (ORCPT + 99 others); Tue, 26 Mar 2019 04:12:44 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:33961 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731109AbfCZIMo (ORCPT ); Tue, 26 Mar 2019 04:12:44 -0400 Received: by mail-io1-f68.google.com with SMTP id n11so9996212ioh.1 for ; Tue, 26 Mar 2019 01:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YdFwkF4eUySjbpG+38wjJdvK3fCy24c6M03FoBUoupk=; b=k6XFJyGwJ9uMM5uZPWX/AMT7fviQV0Ld1mcPlddQHs0cPIvKIZsAGtkGGxowospoCT dtY6QW0pQBRdQZw/Pzw1xGUnrxiMWMMWQoLuH0L+NTAhjv0l+Yb/scBRb8Eepi2+jpsZ +ZfSqGLB3qiRjeQWh0Tgul4DOKaGm71Q8paP7zVq4PLWFJDKx4e7zw5OVJkORY5a2mpV ReGqnFwm0nuny+7m0ehupOQZYBEJ5uTlS1sAE9PGHyJC7FgYKKgwDVuTukwLz/+hRlTd MGNnI3tJskCS+Wu1/Aa6+rE98oi17qFjkFteyqgBOHmpSXEWFl1O8/BEaF0M9h/LvEhh k/iQ== 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:user-agent; bh=YdFwkF4eUySjbpG+38wjJdvK3fCy24c6M03FoBUoupk=; b=kQW9OvlxROyD45rO9FZlC0v4VCLEHZLn/kuuYRzxE67zG7ZD/UUkA6PVBf9XFZZ1nE xkAqZkOthKoaQ86W1IkwS1jn2l4zA8SqtJEzYJ18mUEZ2K9fVecVq+jywvCUUVIie5zv AfGTUGuz+VBJd825UxzpjVFTQY9iNJ3corlqDlLcwYhX7pJK6sx6q3ILTcRCCgTGW5uA 1kRtFn2mOgZ3uTkikvjfwPAsDcnsa9XhtpcUyJwNTxRBnCiztw+tP369i/RE+lq92KUP xCwO1IxnXDmwJ9SErweZ47Pqvux2dVQyzcf/0l3N7TmOh+QVjQFFhy8ehFuqWFk7yx+O T1hg== X-Gm-Message-State: APjAAAVAKQpPQmMbo3pXI1WC+IgDLn0SQ/BIFavXaAGbJMK6FXuLwqfp I9G02NKEgIlAjDu64LH4fllQEg== X-Received: by 2002:a5e:db48:: with SMTP id r8mr20194656iop.220.1553587962220; Tue, 26 Mar 2019 01:12:42 -0700 (PDT) Received: from google.com ([2401:fa00:fc:202:858d:45ea:f905:5ed4]) by smtp.gmail.com with ESMTPSA id t62sm6882457ita.35.2019.03.26.01.12.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Mar 2019 01:12:41 -0700 (PDT) Date: Tue, 26 Mar 2019 16:12:33 +0800 From: Martin Liu To: Fengguang Wu Cc: Mark Salyzyn , akpm@linux-foundation.org, axboe@kernel.dk, dchinner@redhat.com, jenhaochen@google.com, salyzyn@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [RFC PATCH] mm: readahead: add readahead_shift into backing device Message-ID: <20190326081233.GA175058@google.com> References: <20190322154610.164564-1-liumartin@google.com> <20190325121628.zxlogz52go6k36on@wfg-t540p.sh.intel.com> <9b194e61-f2d0-82cb-30ac-95afb493b894@android.com> <20190326013058.ykdwxbfkk3x3pvtu@wfg-t540p.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190326013058.ykdwxbfkk3x3pvtu@wfg-t540p.sh.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 26, 2019 at 09:30:58AM +0800, Fengguang Wu wrote: > On Mon, Mar 25, 2019 at 09:59:31AM -0700, Mark Salyzyn wrote: > > On 03/25/2019 05:16 AM, Fengguang Wu wrote: > > > Martin, > > > > > > On Fri, Mar 22, 2019 at 11:46:11PM +0800, Martin Liu wrote: > > > > As the discussion https://lore.kernel.org/patchwork/patch/334982/ > > > > We know an open file's ra_pages might run out of sync from > > > > bdi.ra_pages since sequential, random or error read. Current design > > > > is we have to ask users to reopen the file or use fdavise system > > > > call to get it sync. However, we might have some cases to change > > > > system wide file ra_pages to enhance system performance such as > > > > enhance the boot time by increasing the ra_pages or decrease it to > > > > > > Do you have examples that some distro making use of larger ra_pages > > > for boot time optimization? > > > > Android (if you are willing to squint and look at android-common AOSP > > kernels as a Distro). > > OK. I wonder how exactly Android makes use of it. Since phones are not > using hard disks, so should benefit less from large ra_pages. Would > you kindly point me to the code? > Yes, one of the example is as below. https://source.android.com/devices/tech/perf/boot-times#optimizing-i-o- efficiency > > > Suppose N read streams with equal read speed. The thrash-free memory > > > requirement would be (N * 2 * ra_pages). > > > > > > If N=1000 and ra_pages=1MB, it'd require 2GB memory. Which looks > > > affordable in mainstream servers. > > That is 50% of the memory on a high end Android device ... > > Yeah but I'm obviously not talking Android device here. Will a phone > serve 1000 concurrent read streams? > For Android, some important, persistent services and native HALs might hold fd for a long time unless request a restart action and then would impact overall user experience(guess more than 100). For some low end devices which is a big portion of Android devices, their memory size might be even smaller. Thus, when the device is under memory pressure, this might bring more overhead to impact the performance. As current design, we don't have a way to shrink readahead immediately. This interface gives the flexibility to an adiminstrator to decide how readahed to participate the mitigation level base on the metric it has. > > > Sorry but it sounds like introducing an unnecessarily twisted new > > > interface. I'm afraid it fixes the pain for 0.001% users while > > > bringing more puzzle to the majority others. > > >2B Android devices on the planet is 0.001%? > > Nope. Sorry I didn't know about the Android usage. > Actually nobody mentioned it in the past discussions. > > > I am not defending the proposed interface though, if there is something > > better that can be used, then looking into: > > > > > > Then let fadvise() and shrink_readahead_size_eio() adjust that > > > per-file ra_pages_shift. > > Sounds like this would require a lot from init to globally audit and > > reduce the read-ahead for all open files? > > It depends. In theory it should be possible to create a standalone > kernel module to dump the page cache and get the current snapshot of > all cached file pages. It'd be a one-shot action and don't require > continuous auditing. > > [RFC] kernel facilities for cache prefetching > https://lwn.net/Articles/182128 > > This tool may also work. It's quick to get the list of opened files by > walking /proc/*/fd/, however not as easy to get the list of cached > file names. > > https://github.com/tobert/pcstat > > Perhaps we can do a simplified /proc/filecache that only dumps the > list of cached file names. Then let mincore() based tools take care > of the rest work. > Thanks for the information, they are very useful. For Android, it would keep updating pretty frequently and the lists might need to be updated as the end users install apps, runtime optimization or get new OTA. Therefore, this might request pretty much effort to maintain this. Please kindly correct me if any misunderstanding. Thanks. Regards, Martin