From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754431Ab0AEDlG (ORCPT ); Mon, 4 Jan 2010 22:41:06 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753435Ab0AEDlF (ORCPT ); Mon, 4 Jan 2010 22:41:05 -0500 Received: from mail-vw0-f192.google.com ([209.85.212.192]:48731 "EHLO mail-vw0-f192.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753481Ab0AEDlB convert rfc822-to-8bit (ORCPT ); Mon, 4 Jan 2010 22:41:01 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=mVgdj8kMoSaSwLm/LcswJaOy5vgrZO6RCD5N++5C/39KaG3fxehyCkHGeIoQPhG773 cvNn+yNadQ3mNpAj3dJJp1Nz8Gpveb6VjdxUT1sqt9TUzttiYH1YfDu4PSVdoRir6lII J3kita80BDc+k0ta5HtTXxEatfqxbcO+KESss= MIME-Version: 1.0 In-Reply-To: <20100105021652.GA29428@localhost> References: <20091225000717.GA26949@yahoo-inc.com> <87aax18xms.fsf@basil.nowhere.org> <20091230051540.GA16308@localhost> <20091230052402.GB26364@localhost> <873a2s8hmp.fsf@basil.nowhere.org> <20100104045020.GA21021@localhost> <28c262361001032120v284e92b5ub1211f3d1fca6140@mail.gmail.com> <20100104121642.GA12266@localhost> <28c262361001041746j1270e2d2i79a932efca861dc5@mail.gmail.com> <20100105021652.GA29428@localhost> Date: Tue, 5 Jan 2010 12:40:59 +0900 Message-ID: <28c262361001041940x310450a0na71da4089263b0ba@mail.gmail.com> Subject: Re: [RFC][PATCH v3] readahead: introduce O_RANDOM for POSIX_FADV_RANDOM From: Minchan Kim To: Wu Fengguang Cc: Andi Kleen , Andrew Morton , Quentin Barnes , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , Nick Piggin , Steven Whitehouse , David Howells , Al Viro , Jonathan Corbet , Christoph Hellwig Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 5, 2010 at 11:16 AM, Wu Fengguang wrote: > On Tue, Jan 05, 2010 at 09:46:09AM +0800, Minchan Kim wrote: >> On Mon, Jan 4, 2010 at 9:16 PM, Wu Fengguang wrote: >> > Hi Minchan, >> > >> > On Mon, Jan 04, 2010 at 01:20:49PM +0800, Minchan Kim wrote: >> >> > --- linux.orig/mm/readahead.c   2010-01-04 12:39:29.000000000 +0800 >> >> > +++ linux/mm/readahead.c        2010-01-04 12:39:30.000000000 +0800 >> >> > @@ -501,6 +501,12 @@ void page_cache_sync_readahead(struct ad >> >> >        if (!ra->ra_pages) >> >> >                return; >> >> > >> >> > +       /* be dumb */ >> >> > +       if (filp->f_flags & O_RANDOM) { >> >> > +               force_page_cache_readahead(mapping, filp, offset, req_size); >> >> > +               return; >> >> > +       } >> >> > + >> >> >> >> Let me have a dumb question. :) >> >> >> >> How about testing O_RANDOM in front of ra_pages testing? >> >> >> >> My intention is that although we turn off ra, it would be better to read >> >> contiguous block all at once than readpage() callback doing I/O >> >> one page at a time. >> >> >> >> Is it break some semantics or happen some problem in ondemand readahead? >> > >> > Yes it will have some problem with shrink_readahead_size_eio(), which >> > want to disable readahead and use ->readpage() when ra_pages==0. >> > >> > Do you have specific use case in mind? The file systems that set >> > ra_pages=0 seems to don't need readahead, too. >> >> Never mind. It's just out of curiosity. :) >> >> I thought although user disable readahead, we could enhance file I/O >> with one readpages not multiple readpage if we know the user want to >> read big contiguous blocks. > > Yes, not-break-large-read-into-pages would be good for HD/SSD drives > when readahead is disabled. > > Currently, ->ra_pages is somehow overloaded in its ==0 case. As you > said, it's in fact possible to disable readahead while still limiting > read IO size to a non-zero ->ra_pages. > >> But I though it break current readahead off semantics. right? > > It can be done by applying the ->ra_pages limit to O_RANDOM. This also > makes O_RANDOM safer to use: > > @@ -497,6 +497,13 @@ void page_cache_sync_readahead(struct ad >                               struct file_ra_state *ra, struct file *filp, >                               pgoff_t offset, unsigned long req_size) >  { > +       /* be dumb */ > +       if (filp->f_flags & O_RANDOM) { > +               req_size = clamp_t(unsigned long, req_size, 1, ra->ra_pages); > +               force_page_cache_readahead(mapping, filp, offset, req_size); > +               return; > +       } > + >        /* no read-ahead */ >        if (!ra->ra_pages) >                return; > > To make real change, we need an interface for the user to disable > whole-partition readahead by setting O_RANDOM instead of ra_pages=0. > That would be a hard sell.. Okay. I understand. Thanks, Wu. -- Kind regards, Minchan Kim