lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070612090230.19ab939c.akpm@linux-foundation.org>
Date:	Tue, 12 Jun 2007 09:02:30 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Jens Axboe <jens.axboe@...cle.com>
Cc:	Peter Zijlstra <peterz@...radead.org>, linux-kernel@...r.kernel.org
Subject: Re: splice: move balance_dirty_pages_ratelimited() outside of   
 splice actor

On Tue, 12 Jun 2007 14:44:50 +0200 Jens Axboe <jens.axboe@...cle.com> wrote:

> On Tue, Jun 12 2007, Peter Zijlstra wrote:
> > On Tue, 2007-06-12 at 14:10 +0200, Jens Axboe wrote:
> > > On Tue, Jun 12 2007, Peter Zijlstra wrote:
> > > > On Tue, 2007-06-12 at 13:31 +0200, Jens Axboe wrote:
> > > > 
> > > > > Would you prefer this change, then? I'd prefer keeping the current code,
> > > > > unless it's absolutely critical that we call
> > > > > balance_dirty_pages_ratelimited() for each and every page instead of eg
> > > > > every 16 pages here.
> > > > 
> > > > For that we should call:
> > > >   balance_dirty_pages_ratelimited_nr(mapping, nr);
> > > > 
> > > > Which is ok, for small nr.
> > > 
> > > OK, then this should be better:

yup, the patch looks fine, thanks.

It will in practice be OK calling balance_dirty_pages() once per 16 pages
but one should try to be a good little kernel citizen and do the right
thing, I guess.

> > > diff --git a/fs/splice.c b/fs/splice.c
> > > index 25ec9c8..ed40967 100644
> > > --- a/fs/splice.c
> > > +++ b/fs/splice.c
> > > @@ -844,6 +883,9 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
> > >  	sd.file = out;
> > >  	ret = __splice_from_pipe(pipe, &sd, pipe_to_file);
> > >  	if (ret > 0) {
> > > +		unsigned long nr_pages;
> > > +
> > > +		nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
> > 
> > perhaps?
> > 	nr_pages = DIV_ROUND_UP(ret, PAGE_CACHE_SIZE); 
> > 
> > not sure how horrid that turns out to be; you never know with gcc.
> 
> Well, I think such macros are horribly ugly and that the original code
> is MUCH easier to read.

I think the macros are pretty foul too (perhaps we should migrate it to
"div_round_up()").

But we should migrate to them.  Because once one has learned what a
particular helper like this does, the code becomes more readable, more
understandable and easier to verify correct behaviour.  Whereas the
open-coded arithmetic is _always_ suspect and always needs to be checked
each time one's eye passes over it.

And then there's the ongoing pitter-patter of "convert to DIV_ROUND_UP"
patches in my inbox ;)

It's not, however, our biggest problem.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ