aboutsummaryrefslogtreecommitdiffstats
path: root/module/spl/spl-proc.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2009-12-04 15:54:12 -0800
committerBrian Behlendorf <[email protected]>2009-12-04 15:54:12 -0800
commitd04c8a563c09d6449d5663aa2b57840653defae5 (patch)
treedabaa7102180f3c4e18ac21e1f7fc3618e996bdb /module/spl/spl-proc.c
parentdb1aa22297d50fa19939e487b5cc7d1f5088c64e (diff)
Atomic64 compatibility for 32-bit systems without kernel support.
This patch is another step towards updating the code to handle the 32-bit kernels which I have not been regularly testing. This changes do not really impact the common case I'm expected which is the latest kernel running on an x86_64 arch. Until the linux-2.6.31 kernel the x86 arch did not have support for 64-bit atomic operations. Additionally, the new atomic_compat.h support for this case was wrong because it embedded a spinlock in the atomic variable which must always and only be 64-bits total. To handle these 32-bit issues we now simply fall back to the --enable-atomic-spinlock implementation if the kernel does not provide the 64-bit atomic funcs. The second issue this patch addresses is the DEBUG_KMEM assumption that there will always be atomic64 funcs available. On 32-bit archs this may not be true, and actually that's just fine. In that case the kernel will will never be able to allocate more the 32-bits worth anyway. So just check if atomic64 funcs are available, if they are not it means this is a 32-bit machine and we can safely use atomic_t's instead.
Diffstat (limited to 'module/spl/spl-proc.c')
-rw-r--r--module/spl/spl-proc.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/module/spl/spl-proc.c b/module/spl/spl-proc.c
index 08bcac625..dcd686c9e 100644
--- a/module/spl/spl-proc.c
+++ b/module/spl/spl-proc.c
@@ -409,8 +409,8 @@ proc_console_backoff(struct ctl_table *table, int write, struct file *filp,
#ifdef DEBUG_KMEM
static int
-proc_doatomic64(struct ctl_table *table, int write, struct file *filp,
- void __user *buffer, size_t *lenp, loff_t *ppos)
+proc_domemused(struct ctl_table *table, int write, struct file *filp,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
int rc = 0;
unsigned long min = 0, max = ~0, val;
@@ -425,7 +425,11 @@ proc_doatomic64(struct ctl_table *table, int write, struct file *filp,
if (write) {
*ppos += *lenp;
} else {
+# ifdef HAVE_ATOMIC64_T
val = atomic64_read((atomic64_t *)table->data);
+# else
+ val = atomic_read((atomic_t *)table->data);
+# endif /* HAVE_ATOMIC64_T */
rc = proc_doulongvec_minmax(&dummy, write, filp,
buffer, lenp, ppos);
}
@@ -861,9 +865,13 @@ static struct ctl_table spl_kmem_table[] = {
.ctl_name = CTL_KMEM_KMEMUSED,
.procname = "kmem_used",
.data = &kmem_alloc_used,
+# ifdef HAVE_ATOMIC64_T
.maxlen = sizeof(atomic64_t),
+# else
+ .maxlen = sizeof(atomic_t),
+# endif /* HAVE_ATOMIC64_T */
.mode = 0444,
- .proc_handler = &proc_doatomic64,
+ .proc_handler = &proc_domemused,
},
{
.ctl_name = CTL_KMEM_KMEMMAX,
@@ -879,9 +887,13 @@ static struct ctl_table spl_kmem_table[] = {
.ctl_name = CTL_KMEM_VMEMUSED,
.procname = "vmem_used",
.data = &vmem_alloc_used,
+# ifdef HAVE_ATOMIC64_T
.maxlen = sizeof(atomic64_t),
+# else
+ .maxlen = sizeof(atomic_t),
+# endif /* HAVE_ATOMIC64_T */
.mode = 0444,
- .proc_handler = &proc_doatomic64,
+ .proc_handler = &proc_domemused,
},
{
.ctl_name = CTL_KMEM_VMEMMAX,