Re: PATCH: allow percentile size of tmpfs (2.5.66 / 2.4.20-pre2)

From: CaT (cat@zip.com.au)
Date: Tue Apr 01 2003 - 09:54:34 EST


On Tue, Apr 01, 2003 at 03:43:09PM +0100, Hugh Dickins wrote:
> There's plenty of room in unsigned long long size, yes, but si.totalram
> is only an unsigned long, so the arithmetic as you have it starts out
> overflowing an unsigned long.

Ahh yes.

> I don't know yet what it should say: RH2.96-110 is getting confused
> by the do_div(size, 100) I have there (to respect Xavier's point),
> and this is definitely _not_ worth adding a compiler dependency for.

Would a cast be bad? ie:

--- linux/mm/shmem.c.old Sun Mar 30 00:51:39 2003
+++ linux/mm/shmem.c Sun Mar 30 03:23:47 2003
@@ -1630,6 +1630,12 @@
                 if (!strcmp(this_char,"size")) {
                         unsigned long long size;
                         size = memparse(value,&rest);
+ if (*rest == '%') {
+ struct sysinfo si;
+ si_meminfo(&si);
+ size = ((unsigned long long)si.totalram << PAGE_CACHE_SHIFT) / 100 * size;
+ rest++;
+ }
                         if (*rest)
                                 goto bad_val;
                         *blocks = size >> PAGE_CACHE_SHIFT;

-- 
"Other countries of course, bear the same risk. But there's no doubt his
hatred is mainly directed at us. After all this is the guy who tried to
kill my dad."
        - George W. Bush Jr, Leader of the United States Regime
          September 26, 2002 (from a political fundraiser in Houston, Texas)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Apr 07 2003 - 22:00:13 EST