From: Laurent Vivier <Laurent.Vivier@bull.net>
To: Ravikiran G Thirumalai <kiran@scalex86.org>
Cc: Andrew Morton <akpm@osdl.org>, Mingming Cao <cmm@us.ibm.com>,
Takashi Sato <sho@tnes.nec.co.jp>,
Badari Pulavarty <pbadari@us.ibm.com>,
linux-kernel@vger.kernel.org,
ext2-devel <ext2-devel@lists.sourceforge.net>
Subject: Re: [Ext2-devel] [PATCH 2/2] ext2/3: Support2^32-1blocks(e2fsprogs)
Date: Tue, 28 Mar 2006 09:15:26 +0200 [thread overview]
Message-ID: <1143530126.11560.6.camel@openx2.frec.bull.fr> (raw)
In-Reply-To: <20060327225847.GC3756@localhost.localdomain>
[-- Attachment #1.1: Type: text/plain, Size: 1956 bytes --]
Le mar 28/03/2006 à 00:58, Ravikiran G Thirumalai a écrit :
> On Mon, Mar 27, 2006 at 01:10:49PM -0800, Andrew Morton wrote:
> > Mingming Cao <cmm@us.ibm.com> wrote:
> > >
> > > I am wondering if we have (or plan to have) "long long " type of percpu
> > > counters? Andrew, Kiran, do you know?
> > >
> > > It seems right now the percpu counters are used mostly by ext2/3 for
> > > filesystem free blocks accounting. Right now the counter is "long" type,
> > > which is not enough if we want to extend the filesystem limit from 2**31
> > > to 2**32 on 32 bit machine.
> > >
> > > The patch from Takashi copies the whole percpu_count.h and create a new
> > > percpu_llcounter.h to support longlong type percpu counters. I am
> > > wondering is there any better way for this?
> > >
> >
> > I can't immediately think of anything smarter.
> >
> > One could of course implement a 64-bit percpu counter by simply
> > concatenating two 32-bit counters. That would be a little less efficient,
> > but would introduce less source code and would mean that we don't need to
> > keep two different implemetations in sync. But one would need to do a bit
> > of implementation, see how bad it looks.
>
> Since long long is 64 bits on both 32bit and 64 bit arches, we can just
> change percpu_counter type to long long (or s64) and just have one
> implementation of percpu_counter?
> But reads and writes on 64 bit counters may not be atomic on all 32 bit arches.
> So the implementation might have to be reviewed for that.
As 64bit per cpu counter is used only by ext3 and needed only on 64bit
architecture and when CONFIG_LBD is set, perhaps we can have only one
implementation, 32bit in the case of 32bit arch and 64bit in the case of
64bit arch + LBD, as I did in my 64bit patches for ext3 ?
Cheers,
Laurent
--
Laurent Vivier
Bull, Architect of an Open World (TM)
http://www.bullopensource.org/ext4
[-- Attachment #1.2: percpu.patch --]
[-- Type: text/x-patch, Size: 4594 bytes --]
Index: linux-2.6.16-lv/include/linux/percpu_counter.h
===================================================================
--- linux-2.6.16-lv.orig/include/linux/percpu_counter.h 2006-03-27 15:47:03.000000000 +0200
+++ linux-2.6.16-lv/include/linux/percpu_counter.h 2006-03-27 15:47:14.000000000 +0200
@@ -16,8 +16,13 @@
struct percpu_counter {
spinlock_t lock;
+#ifdef CONFIG_LBD
+ long long count;
+ long long *counters;
+#else
long count;
long *counters;
+#endif
};
#if NR_CPUS >= 16
@@ -30,7 +35,11 @@ static inline void percpu_counter_init(s
{
spin_lock_init(&fbc->lock);
fbc->count = 0;
+#ifdef CONFIG_LBD
+ fbc->counters = alloc_percpu(long long);
+#else
fbc->counters = alloc_percpu(long);
+#endif
}
static inline void percpu_counter_destroy(struct percpu_counter *fbc)
@@ -38,10 +47,17 @@ static inline void percpu_counter_destro
free_percpu(fbc->counters);
}
+#ifdef CONFIG_LBD
+void percpu_counter_mod(struct percpu_counter *fbc, long long amount);
+long long percpu_counter_sum(struct percpu_counter *fbc);
+
+static inline long long percpu_counter_read(struct percpu_counter *fbc)
+#else
void percpu_counter_mod(struct percpu_counter *fbc, long amount);
long percpu_counter_sum(struct percpu_counter *fbc);
static inline long percpu_counter_read(struct percpu_counter *fbc)
+#endif
{
return fbc->count;
}
@@ -50,9 +66,15 @@ static inline long percpu_counter_read(s
* It is possible for the percpu_counter_read() to return a small negative
* number for some counter which should never be negative.
*/
+#ifdef CONFIG_LBD
+static inline long long percpu_counter_read_positive(struct percpu_counter *fbc)
+{
+ long long ret = fbc->count;
+#else
static inline long percpu_counter_read_positive(struct percpu_counter *fbc)
{
long ret = fbc->count;
+#endif
barrier(); /* Prevent reloads of fbc->count */
if (ret > 0)
@@ -63,7 +85,11 @@ static inline long percpu_counter_read_p
#else
struct percpu_counter {
+#ifdef CONFIG_LBD
+ long long count;
+#else
long count;
+#endif
};
static inline void percpu_counter_init(struct percpu_counter *fbc)
@@ -76,24 +102,40 @@ static inline void percpu_counter_destro
}
static inline void
+#ifdef CONFIG_LBD
+percpu_counter_mod(struct percpu_counter *fbc, long long amount)
+#else
percpu_counter_mod(struct percpu_counter *fbc, long amount)
+#endif
{
preempt_disable();
fbc->count += amount;
preempt_enable();
}
+#ifdef CONFIG_LBD
+static inline long long percpu_counter_read(struct percpu_counter *fbc)
+#else
static inline long percpu_counter_read(struct percpu_counter *fbc)
+#endif
{
return fbc->count;
}
+#ifdef CONFIG_LBD
+static inline long long percpu_counter_read_positive(struct percpu_counter *fbc)
+#else
static inline long percpu_counter_read_positive(struct percpu_counter *fbc)
+#endif
{
return fbc->count;
}
+#ifdef CONFIG_LBD
+static inline long long percpu_counter_sum(struct percpu_counter *fbc)
+#else
static inline long percpu_counter_sum(struct percpu_counter *fbc)
+#endif
{
return percpu_counter_read_positive(fbc);
}
Index: linux-2.6.16-lv/mm/swap.c
===================================================================
--- linux-2.6.16-lv.orig/mm/swap.c 2006-03-27 15:47:03.000000000 +0200
+++ linux-2.6.16-lv/mm/swap.c 2006-03-27 15:47:14.000000000 +0200
@@ -479,10 +479,17 @@ static int cpu_swap_callback(struct noti
#endif /* CONFIG_SMP */
#ifdef CONFIG_SMP
+#ifdef CONFIG_LBD
+void percpu_counter_mod(struct percpu_counter *fbc, long long amount)
+{
+ long long count;
+ long long *pcount;
+#else
void percpu_counter_mod(struct percpu_counter *fbc, long amount)
{
long count;
long *pcount;
+#endif
int cpu = get_cpu();
pcount = per_cpu_ptr(fbc->counters, cpu);
@@ -503,15 +510,26 @@ EXPORT_SYMBOL(percpu_counter_mod);
* Add up all the per-cpu counts, return the result. This is a more accurate
* but much slower version of percpu_counter_read_positive()
*/
+#ifdef CONFIG_LBD
+long long percpu_counter_sum(struct percpu_counter *fbc)
+{
+ long long ret;
+#else
long percpu_counter_sum(struct percpu_counter *fbc)
{
long ret;
+#endif
int cpu;
spin_lock(&fbc->lock);
ret = fbc->count;
for_each_cpu(cpu) {
- long *pcount = per_cpu_ptr(fbc->counters, cpu);
+#ifdef CONFIG_LBD
+ long long *pcount;
+#else
+ long *pcount;
+#endif
+ pcount = per_cpu_ptr(fbc->counters, cpu);
ret += *pcount;
}
spin_unlock(&fbc->lock);
[-- Attachment #2: Ceci est une partie de message numériquement signée. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2006-03-28 7:15 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-25 13:33 sho
2006-03-26 22:37 ` Badari Pulavarty
2006-03-27 4:17 ` Takashi Sato
2006-03-27 18:45 ` Mingming Cao
2006-03-27 21:10 ` Andrew Morton
2006-03-27 22:58 ` Ravikiran G Thirumalai
2006-03-28 7:15 ` Laurent Vivier [this message]
2006-03-28 8:02 ` Ravikiran G Thirumalai
2006-03-28 10:34 ` Laurent Vivier
2006-03-28 18:01 ` Mingming Cao
2006-03-29 9:13 ` Laurent Vivier
[not found] ` <1143657317.4045.12.camel@dyn9047017067.beaverton.ibm.com>
2006-03-29 20:00 ` Ravikiran G Thirumalai
2006-03-29 20:38 ` Mingming Cao
2006-03-30 8:41 ` Ravikiran G Thirumalai
2006-03-30 1:38 ` [RFC][PATCH 0/2]Extend ext3 filesystem limit from 8TB to 16TB Mingming Cao
2006-03-30 1:54 ` Andrew Morton
2006-03-31 22:42 ` Mingming Cao
2006-04-02 20:13 ` Mingming Cao
2006-04-10 9:11 ` [Ext2-devel] " Laurent Vivier
2006-04-10 8:24 ` Andrew Morton
2006-04-13 15:26 ` Laurent Vivier
2006-04-17 21:07 ` Ravikiran G Thirumalai
2006-04-17 21:09 ` Arjan van de Ven
2006-04-17 21:32 ` Ravikiran G Thirumalai
2006-04-18 7:14 ` Laurent Vivier
2006-04-18 7:30 ` Arjan van de Ven
2006-04-18 10:57 ` Laurent Vivier
2006-04-18 19:08 ` Ravikiran G Thirumalai
2006-04-18 14:09 ` Laurent Vivier
2006-04-18 21:01 ` Mingming Cao
2006-04-20 11:28 ` Laurent Vivier
[not found] ` <1145543970.5872.38.camel@openx2.frec.bull.fr>
2006-04-21 11:17 ` Laurent Vivier
2006-04-10 16:57 ` Mingming Cao
2006-04-10 19:06 ` Mingming Cao
2006-04-11 7:07 ` Laurent Vivier
2006-04-14 17:23 ` Ravikiran G Thirumalai
2006-03-30 17:36 ` Andreas Dilger
2006-03-30 19:01 ` Mingming Cao
2006-03-30 17:40 ` Andreas Dilger
2006-03-30 19:16 ` Mingming Cao
2006-03-30 19:22 ` Mingming Cao
2006-03-31 6:42 ` Andreas Dilger
2006-03-31 13:33 ` Andi Kleen
2006-04-01 6:50 ` Nathan Scott
2006-05-26 5:00 ` [PATCH 0/2]Define ext3 in-kernel filesystem block types and extend " Mingming Cao
2006-05-26 18:08 ` Andrew Morton
2006-05-30 17:55 ` Mingming Cao
2006-03-30 1:39 ` [RFC][PATCH 1/2]ext3 block allocation/reservation fixes to support 2**32 block numbers Mingming Cao
2006-03-30 1:39 ` [RFC][PATCH 2/2]Other ext3 in-kernel block number type fix " Mingming Cao
-- strict thread matches above, loose matches on Subject: below --
2006-03-25 13:34 [Ext2-devel] [PATCH 2/2] ext2/3: Support2^32-1blocks(e2fsprogs) sho
2006-03-15 12:39 [PATCH 2/2] ext2/3: Support 2^32-1 blocks(e2fsprogs) Takashi Sato
2006-03-17 21:19 ` [Ext2-devel] " Badari Pulavarty
2006-03-18 5:57 ` [Ext2-devel] [PATCH 2/2] ext2/3: Support 2^32-1blocks(e2fsprogs) Takashi Sato
2006-03-22 23:45 ` Badari Pulavarty
2006-03-23 18:16 ` Badari Pulavarty
2006-03-24 1:54 ` [Ext2-devel] [PATCH 2/2] ext2/3: Support2^32-1blocks(e2fsprogs) Takashi Sato
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=1143530126.11560.6.camel@openx2.frec.bull.fr \
--to=laurent.vivier@bull.net \
--cc=akpm@osdl.org \
--cc=cmm@us.ibm.com \
--cc=ext2-devel@lists.sourceforge.net \
--cc=kiran@scalex86.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbadari@us.ibm.com \
--cc=sho@tnes.nec.co.jp \
/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
all inboxes | Powered by JetHome®