[Top] [All Lists]

Re: [PATCH-v3 3/6] vfs: don't let the dirty time inodes get more than a

To: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
Subject: Re: [PATCH-v3 3/6] vfs: don't let the dirty time inodes get more than a day stale
From: Theodore Ts'o <tytso@xxxxxxx>
Date: Tue, 25 Nov 2014 10:55:22 -0500
Cc: Linux Filesystem Development List <linux-fsdevel@xxxxxxxxxxxxxxx>, Ext4 Developers List <linux-ext4@xxxxxxxxxxxxxxx>, Linux btrfs Developers List <linux-btrfs@xxxxxxxxxxxxxxx>, XFS Developers <xfs@xxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=W3/QWuJtzDpqvI1RDdMxS62EgEGVYSL1lE+d+W30V/k=; b=MpGA+A9wzQmbGypWSy0uDbQASFNINGKG9dYxOspTwThMFd/PrC7sggNWODJ/NgZKBTo3Bz5Xl7Eog2HLDmBLW576zh+wtvJ42HZPq5/7w5trh6IzEO2ivn7g4hBLSg0hPtYgLrGAPeNK6d/MQJs+InNU2S6DP6EcrGWrI+qh5cw=;
In-reply-to: <87ioi3iayu.fsf@xxxxxxxxxxxxxxxxxx>
References: <1416893674-419-1-git-send-email-tytso@xxxxxxx> <1416893674-419-4-git-send-email-tytso@xxxxxxx> <87ioi3iayu.fsf@xxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.23 (2014-03-12)
On Tue, Nov 25, 2014 at 03:58:01PM +0100, Rasmus Villemoes wrote:
> I think days_since_boot was a lot clearer than daycode. In any case,
> please make the comment and the code consistent.

Yeah, I was going back and forth between days since the epoch and days
since boot, but found it was more efficient to calculate the days
since boot.  Sure, I'll go back to days_since_boot.

> You should probably divide by the number of seconds in a day, not the
> number of jiffies in a day.

Right, brain hiccup on my part, will fix.

> Isn't div_u64 mostly for when the divisor is not known at compile time?
> Technically, "(u64)uptime.tv_sec / 86400" is of course a u64/u64 division,
> but the compiler should see that the divisor is only 32 bits and hence
> should be able to generate code which is at least as efficient as
> whatever inline asm the arch provides for u64/u32 divisions.

The problem with doing u64/u64 divisions is that the compiler will
call out to a (non-existent) library function on some architectures.
For example, try compiling the following using: with "gcc -S -m32

int main(int argc, char **argv)
        unsigned long long t = time(0);

        printf("%llu\n", t / 86400);

You will find in the .S file the following:

        pushl   $0
        pushl   $86400
        pushl   %edx
        pushl   %eax
        call    __udivdi3

It will work finn compiling for x86_64, but if you do this and push
out a git branch, you will soon get a very nice e-mail from the ktest
bot explaining how you've broken the build on the i386 architecture
since the kernel doesn't provide __udivdi3.
Hence if you are doing any kind of divisions involving u64, you have
to use the functions in include/linux/math64.h, and div_u64 is, per

 * div_u64 - unsigned 64bit divide with 32bit divisor
 * This is the most common 64bit divide and should be used if possible,
 * as many 32bit archs can optimize this variant better than a full 64bit
 * divide.


                                        - Ted

<Prev in Thread] Current Thread [Next in Thread>