Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6255911ybv; Tue, 18 Feb 2020 13:05:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzAiyzsT4Pdz39cqjkaEP5OI4gHCnX4Ey8Bk7LE9MnUwbah6ge9r4VnMI7/tJMU083/4U2K X-Received: by 2002:a9d:6b17:: with SMTP id g23mr17510450otp.139.1582059954661; Tue, 18 Feb 2020 13:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582059954; cv=none; d=google.com; s=arc-20160816; b=mku9OKTtipm23mB3owNtG+98d8G9fbq9dJar/7boArviFeGl+KIkaQMXufnIKFG4Xo Vsj6hxeSdInVDOnTd8aPV/jJkm4+WN/t8JABJTdmx9rRm6RpTMFA3yyBTp3RpAFj7LKO g4lNcVQJH/OmbDTAd6awdXuP0b3YyewT+sI6+V2irA2zEnBXanHvLW/ZwHaBr9fZSt09 aSwjsXd5nksZtx1pO2f5QMOHroGHZZljIohnSHuk3OCO9zvlukc0DuKp1xirdc9IBC0d WRTGI3P7TX5qtOj7pE4RS68cGh0c3Qds6soNVTGinhcaDnoyAtSm1dp5LJ1zNVeGfIb4 e0Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=3Tzi4YVjiGJU778/orjIDa7TSGwRy5taBn2/82oa+aQ=; b=XcOAOqiKC3BO59+0BHSmRuUbVILzdk2/KPMnucTc5UmesEOFpsW/VEbYBzFrEnIItr +irf8nOsJGvXCPeEjq22zICRHGtOfhFc++cdQIjaDOujDS5fAYUL6J9hsD6NZSzORoWN v87MuBkIycYsK+UPoUXZqgH+HeW5InezUnv1DzHb7oROLSIODKD2S66K1r6SeaRXwY3p +ZrdAWU4Vy3jvdrUqnvTMHV7+8X3qe/jDrX9mA6e9gpf9raRKGgho6lNhSAj2kAo0Xp+ fpvk7+oeJ+P1F6yp3NWLI8gkBhdJd37URlG066KkCvXtf1kZ+U1f7NgTAT2RvH3tthea 385g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=hqloiqBq; 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=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d12si2181165otc.307.2020.02.18.13.05.40; Tue, 18 Feb 2020 13:05:54 -0800 (PST) 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=@nvidia.com header.s=n1 header.b=hqloiqBq; 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=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbgBRVFb (ORCPT + 99 others); Tue, 18 Feb 2020 16:05:31 -0500 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:4342 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726482AbgBRVFb (ORCPT ); Tue, 18 Feb 2020 16:05:31 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 18 Feb 2020 13:04:58 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Tue, 18 Feb 2020 13:05:30 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Tue, 18 Feb 2020 13:05:30 -0800 Received: from [10.110.48.28] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 18 Feb 2020 21:05:29 +0000 Subject: Re: [PATCH v6 01/19] mm: Return void from various readahead functions To: Matthew Wilcox , CC: , , , , , , , , References: <20200217184613.19668-1-willy@infradead.org> <20200217184613.19668-2-willy@infradead.org> X-Nvconfidentiality: public From: John Hubbard Message-ID: <29d2d7ca-7f2b-7eb4-78bc-f2af36c4c426@nvidia.com> Date: Tue, 18 Feb 2020 13:05:29 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200217184613.19668-2-willy@infradead.org> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1582059898; bh=3Tzi4YVjiGJU778/orjIDa7TSGwRy5taBn2/82oa+aQ=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=hqloiqBqSuZGaYGkXI4y6uimyehARyGnYG70bfDk3yOB18R9uLM8BT6oDtBGecU3N Lqh9rx/iPO8/U18g2E2WaBCVhqRRwzPmIxsQ4YC2mK2lo21KXP1fIEhVpBLHsqVF2u +spNTSr0xUh2VFGuB3TbrYt/WmzmxtalFBYvXAWqVE5C7DowzCVSWA4uRMCnWv175V kKKp/N0Kuc4S7BOtfyFTo9/gvcyiICIqWPfvulCk6nDeR68LOPk75LEKPAc8BezVTf 8/m4QzBRgIOBFNjb8rgcd5NrIT05x92/7JvGII/CGcNWKq5/Y9GhpYvAylBzuSi2WH gxTDwXiR8jocQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/17/20 10:45 AM, Matthew Wilcox wrote: > From: "Matthew Wilcox (Oracle)" > > ondemand_readahead has two callers, neither of which use the return value. > That means that both ra_submit and __do_page_cache_readahead() can return > void, and we don't need to worry that a present page in the readahead > window causes us to return a smaller nr_pages than we ought to have. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > mm/internal.h | 8 ++++---- > mm/readahead.c | 24 ++++++++++-------------- > 2 files changed, 14 insertions(+), 18 deletions(-) This is an easy review and obviously correct, so: Reviewed-by: John Hubbard Thoughts for the future of the API: I will add that I could envision another patchset that went in the opposite direction, and attempted to preserve the information about how many pages were successfully read ahead. And that would be nice to have (at least IMHO), even all the way out to the syscall level, especially for the readahead syscall. Of course, vague opinions about how the API might be improved are less pressing than cleaning up the code now--I'm just bringing this up because I suspect some people will wonder, "wouldn't it be helpful if I the syscall would tell me what happened here? Success (returning 0) doesn't necessarily mean any pages were even read ahead." It just seems worth mentioning. thanks, -- John Hubbard NVIDIA > > diff --git a/mm/internal.h b/mm/internal.h > index 3cf20ab3ca01..f779f058118b 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -49,18 +49,18 @@ void unmap_page_range(struct mmu_gather *tlb, > unsigned long addr, unsigned long end, > struct zap_details *details); > > -extern unsigned int __do_page_cache_readahead(struct address_space *mapping, > +extern void __do_page_cache_readahead(struct address_space *mapping, > struct file *filp, pgoff_t offset, unsigned long nr_to_read, > unsigned long lookahead_size); > > /* > * Submit IO for the read-ahead request in file_ra_state. > */ > -static inline unsigned long ra_submit(struct file_ra_state *ra, > +static inline void ra_submit(struct file_ra_state *ra, > struct address_space *mapping, struct file *filp) > { > - return __do_page_cache_readahead(mapping, filp, > - ra->start, ra->size, ra->async_size); > + __do_page_cache_readahead(mapping, filp, > + ra->start, ra->size, ra->async_size); > } > > /* > diff --git a/mm/readahead.c b/mm/readahead.c > index 2fe72cd29b47..8ce46d69e6ae 100644 > --- a/mm/readahead.c > +++ b/mm/readahead.c > @@ -149,10 +149,8 @@ static int read_pages(struct address_space *mapping, struct file *filp, > * the pages first, then submits them for I/O. This avoids the very bad > * behaviour which would occur if page allocations are causing VM writeback. > * We really don't want to intermingle reads and writes like that. > - * > - * Returns the number of pages requested, or the maximum amount of I/O allowed. > */ > -unsigned int __do_page_cache_readahead(struct address_space *mapping, > +void __do_page_cache_readahead(struct address_space *mapping, > struct file *filp, pgoff_t offset, unsigned long nr_to_read, > unsigned long lookahead_size) > { > @@ -166,7 +164,7 @@ unsigned int __do_page_cache_readahead(struct address_space *mapping, > gfp_t gfp_mask = readahead_gfp_mask(mapping); > > if (isize == 0) > - goto out; > + return; > > end_index = ((isize - 1) >> PAGE_SHIFT); > > @@ -211,8 +209,6 @@ unsigned int __do_page_cache_readahead(struct address_space *mapping, > if (nr_pages) > read_pages(mapping, filp, &page_pool, nr_pages, gfp_mask); > BUG_ON(!list_empty(&page_pool)); > -out: > - return nr_pages; > } > > /* > @@ -378,11 +374,10 @@ static int try_context_readahead(struct address_space *mapping, > /* > * A minimal readahead algorithm for trivial sequential/random reads. > */ > -static unsigned long > -ondemand_readahead(struct address_space *mapping, > - struct file_ra_state *ra, struct file *filp, > - bool hit_readahead_marker, pgoff_t offset, > - unsigned long req_size) > +static void ondemand_readahead(struct address_space *mapping, > + struct file_ra_state *ra, struct file *filp, > + bool hit_readahead_marker, pgoff_t offset, > + unsigned long req_size) > { > struct backing_dev_info *bdi = inode_to_bdi(mapping->host); > unsigned long max_pages = ra->ra_pages; > @@ -428,7 +423,7 @@ ondemand_readahead(struct address_space *mapping, > rcu_read_unlock(); > > if (!start || start - offset > max_pages) > - return 0; > + return; > > ra->start = start; > ra->size = start - offset; /* old async_size */ > @@ -464,7 +459,8 @@ ondemand_readahead(struct address_space *mapping, > * standalone, small random read > * Read as is, and do not pollute the readahead state. > */ > - return __do_page_cache_readahead(mapping, filp, offset, req_size, 0); > + __do_page_cache_readahead(mapping, filp, offset, req_size, 0); > + return; > > initial_readahead: > ra->start = offset; > @@ -489,7 +485,7 @@ ondemand_readahead(struct address_space *mapping, > } > } > > - return ra_submit(ra, mapping, filp); > + ra_submit(ra, mapping, filp); > } > > /** >