[PATCH 2/4] compat: backport work_busy()

From: Luis R. Rodriguez
Date: Mon Mar 19 2012 - 23:28:36 EST


From: "Luis R. Rodriguez" <mcgrof@xxxxxxxxxxxxx>

Best we can do is just tell the users of we are WORK_BUSY_PENDING
for older kernels. The ckmake log:

Trying kernel 3.3.0-030300rc2-generic [OK]
Trying kernel 3.2.2-030202-generic [OK]
Trying kernel 3.1.10-030110-generic [OK]
Trying kernel 3.0.18-030018-generic [OK]
Trying kernel 2.6.39-02063904-generic [OK]
Trying kernel 2.6.38-13-generic [OK]
Trying kernel 2.6.38-02063808-generic [OK]
Trying kernel 2.6.37-02063706-generic [OK]
Trying kernel 2.6.36-02063604-generic [OK]
Trying kernel 2.6.35-02063512-generic [OK]
Trying kernel 2.6.34-02063410-generic [OK]
Trying kernel 2.6.33-02063305-generic [OK]
Trying kernel 2.6.32-02063255-generic [OK]
Trying kernel 2.6.31-22-generic [OK]
Trying kernel 2.6.31-02063113-generic [OK]
Trying kernel 2.6.30-02063010-generic [OK]
Trying kernel 2.6.29-02062906-generic [OK]
Trying kernel 2.6.28-02062810-generic [OK]
Trying kernel 2.6.27-020627-generic [OK]
Trying kernel 2.6.26-020626-generic [OK]
Trying kernel 2.6.25-020625-generic [OK]
Trying kernel 2.6.24-020624-generic [OK]

Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxxxxxxx>
---
compat/compat-2.6.36.c | 24 ++++++++++++++++++++++++
include/linux/compat-2.6.28.h | 4 ++++
include/linux/compat-2.6.36.h | 8 ++++++++
3 files changed, 36 insertions(+)

diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c
index b79609c..9190ecd 100644
--- a/compat/compat-2.6.36.c
+++ b/compat/compat-2.6.36.c
@@ -145,6 +145,30 @@ void compat_flush_scheduled_work(void)
}
EXPORT_SYMBOL_GPL(compat_flush_scheduled_work);

+/**
+ * work_busy - test whether a work is currently pending or running
+ * @work: the work to be tested
+ *
+ * Test whether @work is currently pending or running. There is no
+ * synchronization around this function and the test result is
+ * unreliable and only useful as advisory hints or for debugging.
+ * Especially for reentrant wqs, the pending state might hide the
+ * running state.
+ *
+ * RETURNS:
+ * OR'd bitmask of WORK_BUSY_* bits.
+ */
+unsigned int work_busy(struct work_struct *work)
+{
+ unsigned int ret = 0;
+
+ if (work_pending(work))
+ ret |= WORK_BUSY_PENDING;
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(work_busy);
+
void compat_system_workqueue_create()
{
system_wq = alloc_workqueue("events", 0, 0);
diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h
index c0ca70b..e336f39 100644
--- a/include/linux/compat-2.6.28.h
+++ b/include/linux/compat-2.6.28.h
@@ -9,6 +9,8 @@
#include <linux/if_ether.h>
#include <linux/usb.h>
#include <linux/types.h>
+#include <linux/types.h>
+#include <linux/cpumask.h>

#ifndef ETH_P_PAE
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
@@ -16,6 +18,8 @@

#include <linux/pci.h>

+typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } compat_cpumask_t;
+
#if defined(CONFIG_X86) || defined(CONFIG_X86_64) || defined(CONFIG_PPC)
/*
* CONFIG_PHYS_ADDR_T_64BIT was added as new to all architectures
diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h
index 4768e63..56d5961 100644
--- a/include/linux/compat-2.6.36.h
+++ b/include/linux/compat-2.6.36.h
@@ -168,6 +168,14 @@ int compat_schedule_delayed_work_on(int cpu,
unsigned long delay);
void compat_flush_scheduled_work(void);

+enum {
+ /* bit mask for work_busy() return values */
+ WORK_BUSY_PENDING = 1 << 0,
+ WORK_BUSY_RUNNING = 1 << 1,
+};
+
+extern unsigned int work_busy(struct work_struct *work);
+
#define schedule_work(work) compat_schedule_work(work)
#define schedule_work_on(cpu, work) compat_schedule_work_on(cpu, work)
#define schedule_delayed_work(dwork, delay) compat_schedule_delayed_work(dwork, delay)
--
1.7.10.rc1.22.gf5241

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/