From: Andreas Dilger <adilger@sun.com>
To: Andrew Perepechko <Andrew.Perepechko@sun.com>
Cc: Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org,
Johann Lombardi <Johann.Lombardi@sun.com>,
Zhiyong Landen tian <Zhiyong.Tian@sun.com>,
Alex Lyashkov <Alexey.Lyashkov@sun.com>
Subject: Re: [RFC] quota: 64-bit limits with vfs
Date: Sat, 15 Mar 2008 22:45:06 +0800 [thread overview]
Message-ID: <20080315144506.GT3542@webber.adilger.int> (raw)
In-Reply-To: <200803151624.02791.andrew.perepechko@sun.com>
On Mar 15, 2008 16:24 +0300, Andrew Perepechko wrote:
> On Saturday 15 March 2008 07:23:16 Andreas Dilger wrote:
> > In a few places you add new on-stack variables like "sb", but they aren't
> > used more than 1 or 2 times. While it makes the code a tiny bit clearer
> > (though not largely so for "sb" because it is only dquot->dq_sb) it does
> > increase the stack usage, and that is never a good idea.
>
> I agree. Probably, it makes sense to rollback sb change. Though this may lead
> to additional line breaks.
Line breaks don't consume stack space ;-).
> > Hmm, allocating "fakedquot" on the stack just to compare it to zero
> > doesn't seem like a good use of space. What about doing the memcmp()
> > against page_address(ZERO_PAGE(0))? It might be nice to have a permanent
> > mapping of ZERO_PAGE(0) like void *zero_buffer that can be used for this.
>
> What do you think about something like this?
>
> +static union v2_disk_dqblk emptydquot;
> +static union v2_disk_dqblk fakedquot[2] = {
> + {.disk_dqblk_r0 = {.dqb_itime = __constant_cpu_to_le64(1LLU)}},
> + {.disk_dqblk_r1 = {.dqb_itime = __constant_cpu_to_le64(1LLU)}}
> +};
Yes, since these structures are constant there are no multi-thread issues.
Not only does this use less stack space, but it is better performing as
well due to less memset() overhead.
NB - it seems you have whitespace at the end of some lines, please remove it.
>@@ -724,9 +724,7 @@ static int v2_read_dquot(struct dquot *d
> else {
> ret = 0;
> /* We need to escape back all-zero structure */
>- memset(&empty, 0, dqblksz);
>- DQF_PUT(&empty, rev, dqb_itime, 1);
>- if (!memcmp(&empty, &ddquot, dqblksz))
>+ if (!memcmp(&fakedquot[rev], &ddquot, dqblksz))
> DQF_PUT(&ddquot, rev, dqb_itime, 0);
> }
I wonder if there is a CPU instruction "compare memory with zero" that
would be available for something like this, that could be used like:
if (!memzcmp(&ddquot, dqblksz))
DQF_PUT(&ddquot, rev, dqb_itime, 0);
I know I've had to use a few hacks like this to check if some buffer is
zero filled, so having it efficiently done by the CPU would be a win.
It would be possible to use something like generic_find_first_bit():
#define memzcmp(ptr, bytes) (generic_find_first_bit(ptr, bytes*8) >= bytes*8)
which breaks down to an assembly instruction "bsfq" on x86_64 if the
parameter is constant. That might make it more efficient to have 2
separate codepaths here with a constant "bytes" parameter so that the
larger memzcmp() can be optimized.
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
next prev parent reply other threads:[~2008-03-15 14:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-06 13:41 [RFC] quota: 64-bit limits with vfs Andrew Perepechko
2008-03-06 14:48 ` Jan Kara
2008-03-09 22:46 ` Andrew Perepechko
2008-03-10 16:26 ` Jan Kara
2008-03-10 17:13 ` Andrew Perepechko
2008-03-10 17:20 ` Jan Kara
2008-03-14 13:08 ` Andrew Perepechko
2008-03-15 4:23 ` Andreas Dilger
2008-03-15 13:24 ` Andrew Perepechko
2008-03-15 13:32 ` Andrew Perepechko
2008-03-15 14:45 ` Andreas Dilger [this message]
2008-03-15 18:58 ` [RFC] quota: 64-bit limits with vfs, updated Andrew Perepechko
2008-03-15 22:47 ` Andreas Dilger
2008-03-16 1:14 ` Andrew Perepechko
2008-03-16 11:21 ` Andrew Perepechko
2008-03-17 14:35 ` Jan Kara
2008-03-20 21:37 ` Andrew Perepechko
2008-03-21 1:04 ` Andreas Dilger
2008-03-21 9:14 ` Andrew Perepechko
2008-03-21 10:24 ` Andrew Perepechko
2008-03-17 14:51 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080315144506.GT3542@webber.adilger.int \
--to=adilger@sun.com \
--cc=Alexey.Lyashkov@sun.com \
--cc=Andrew.Perepechko@sun.com \
--cc=Johann.Lombardi@sun.com \
--cc=Zhiyong.Tian@sun.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).