2012-03-20 03:27:07

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH 0/4] compat: March 19 backport work

From: "Luis R. Rodriguez" <[email protected]>

With the latest linux-next we get failures to build compat-wireless,
this addresses compilation down to 2.6.33. I could use help with tracing
backport for kernels <= 2.6.32, that is please try against 2.6.32, I hit
an issue there.

Review of this is greatly appreciated. I've already pushed this out as
at least I can verify this does not break compilation for older kernels.
Run time testing against older kernels for the system workqueue stuff
would be greatly appreciated as well.

Luis R. Rodriguez (4):
compat: backport system work queues system_wq and system_long_wq
compat: backport work_busy()
compat: fix load time issue with kfifo backport
compat: add some tracing backport work

compat/compat-2.6.36.c | 77 ++++++++++++++++++++++++++++++++++++++++-
include/linux/compat-2.6.28.h | 4 +++
include/linux/compat-2.6.36.h | 40 +++++++++++++++++++++
include/linux/tracepoint.h | 40 +++++++++++++++++++++
scripts/gen-compat-config.sh | 2 +-
5 files changed, 161 insertions(+), 2 deletions(-)

--
1.7.10.rc1.22.gf5241



2012-03-20 03:27:20

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH 3/4] compat: fix load time issue with kfifo backport

From: "Luis R. Rodriguez" <[email protected]>

The CONFIG_COMPAT_KFIFO config option must be defined
to CONFIG_COMPAT_KFIFO=y instead of CONFIG_COMPAT_KFIFO=m
as the kfifo object is not a module, its simply part of
the compat module. This should fix users of the kfifo
backport on kernels older than 2.6.36.

Signed-off-by: Luis R. Rodriguez <[email protected]>
---
scripts/gen-compat-config.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh
index 423d595..5d6e34c 100755
--- a/scripts/gen-compat-config.sh
+++ b/scripts/gen-compat-config.sh
@@ -59,5 +59,5 @@ if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} = "y" ]]; then
fi

if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "y" ]]; then
- echo "CONFIG_COMPAT_KFIFO=m"
+ echo "CONFIG_COMPAT_KFIFO=y"
fi
--
1.7.10.rc1.22.gf5241


2012-03-20 12:11:39

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 4/4] compat: add some tracing backport work

On Mon, 2012-03-19 at 20:27 -0700, Luis R. Rodriguez wrote:
> From: "Luis R. Rodriguez" <[email protected]>
>
> Its not really easy to backport the tracing stuff, but
> lets give it a shot. We should simply review how many
> subsystems we want tracing for and for what target kernels
> we want that enabled for. It doesn't make sense to
> backport tracing if we won't have much users.

Frankly, I don't really want to think about backporting tracing since
it's so complex internally ...

It seems worthwhile though to have macros that disable tracing instead
of having to have a patch.

johannes


2012-03-28 10:00:32

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH 4/4] compat: add some tracing backport work

On Mon, Mar 26, 2012 at 08:58:22AM -0400, Luis R. Rodriguez wrote:
> On Mon, Mar 26, 2012 at 10:49:28AM +0200, Johannes Berg wrote:
> > On Wed, 2012-03-21 at 21:29 -0700, Luis R. Rodriguez wrote:
> >
> > > But no dice. I then figured it may be my kernel with
> > > CONFIG_TRACEPOINTS=y and indeed that is the case -- so we have to
> > > consider the case where the target kernel may have tracing enabled and
> > > we have to disable it somehow. Undef'ing CONFIG_TRACEPOINTS and
> > > DECLARE_TRACE doesn't really do it.
> >
> > Oh, ok, yuck. So I guess we can't easily disable tracing if it's enabled
> > in the base kernel ...
>
> Its a bit tough.

I've managed to backport tracing it seems, even when CONFIG_TRACEPOINTS
is enabled. The patch below covers that. I'll spew out the latest
error log on compaling compat-wireless though, this is down on
2.6.31.

/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c: In function ‘if_sdio_power_on’:
/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c:771:19: warning: unused variable ‘host’
/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c: In function ‘if_sdio_power_save’:
/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c:1071:2: error: implicit declaration of function ‘pm_runtime_put_sync’
/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c: In function ‘if_sdio_power_restore’:
/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c:1081:2: error: implicit declaration of function ‘pm_runtime_get_sync’
/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c: In function ‘if_sdio_probe’:
/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c:1231:2: error: implicit declaration of function ‘pm_runtime_put_noidle’
/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c: In function ‘if_sdio_remove’:
/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.c:1268:2: error: implicit declaration of function ‘pm_runtime_get_noresume’
make[4]: *** [/home/mcgrof/devel/compat-wireless/drivers/net/wireless/libertas/if_sdio.o] Error 1

This compilation issue is not related to tracing and seems trivial to
resolve. So hey this is great progress..

>From 7d549b33d180b96a6b34e1c9d1298a1c1ec557d4 Mon Sep 17 00:00:00 2001
From: "Luis R. Rodriguez" <[email protected]>
Date: Wed, 28 Mar 2012 02:45:07 -0700
Subject: [PATCH] compat: complete tracepoint backport

Tested also against compat-wireless against:

* 2.6.33
* 2.6.32

I'm happy with this.

compat ckmake:

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 <[email protected]>
---
include/linux/tracepoint.h | 145 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 140 insertions(+), 5 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index a5bd743..44c9a5d 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -13,10 +13,12 @@
#define TP_STRUCT__entry(args...) args
#endif

-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
/* Backports 091ad365, a rename */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
#define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE
+#endif

+/* Backpports 2939b0469 */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
#define TP_PROTO TPPROTO
#define TP_ARGS TPARGS
@@ -24,7 +26,143 @@
#define TP_RAW_FMT TPRAWFMT
#endif

-#endif
+/* Force disabling tracing */
+
+#undef TRACE_EVENT
+#define TRACE_EVENT(name, proto, ...) \
+DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(...)
+#undef DEFINE_EVENT
+
+#define DEFINE_EVENT(template, name, proto, args) \
+ DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+
+#undef DECLARE_TRACE_NOARGS
+#define DECLARE_TRACE_NOARGS(name) \
+ __DECLARE_TRACE(name, void, , 1, void *__data, __data)
+
+
+/* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
+
+#undef DECLARE_TRACE
+#define DECLARE_TRACE(name, proto, args) \
+ __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \
+ PARAMS(void *__data, proto), \
+ PARAMS(__data, args))
+
+#undef DECLARE_TRACE_CONDITION
+#define DECLARE_TRACE_CONDITION(name, proto, args, cond) \
+ __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
+ PARAMS(void *__data, proto), \
+ PARAMS(__data, args))
+
+#else
+
+#undef DECLARE_TRACE
+#define DECLARE_TRACE(name, proto, args) \
+ __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \
+ PARAMS(void *__data, proto), \
+ PARAMS(__data, args))
+
+#undef DECLARE_TRACE_CONDITION
+#define DECLARE_TRACE_CONDITION(name, proto, args, cond) \
+ __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
+ PARAMS(void *__data, proto), \
+ PARAMS(__data, args))
+#endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
+
+/* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
+
+/* Backports c420970ef476d7d68df119711700666224001f43 */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
+
+#undef __DECLARE_TRACE
+#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
+ static inline void trace_##name(proto) \
+ { } \
+ static inline void trace_##name##_rcuidle(proto) \
+ { } \
+ static inline int \
+ register_trace_##name(void (*probe)(proto)) \
+ { \
+ return -ENOSYS; \
+ } \
+ static inline void \
+ unregister_trace_##name(void (*probe)(proto)) \
+ { \
+ return -ENOSYS; \
+ } \
+ static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
+ { \
+ }
+#else
+
+#undef __DECLARE_TRACE
+#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
+ static inline void trace_##name(proto) \
+ { } \
+ static inline void trace_##name##_rcuidle(proto) \
+ { } \
+ static inline int \
+ register_trace_##name(void (*probe)(proto)) \
+ { \
+ return -ENOSYS; \
+ } \
+ static inline int \
+ unregister_trace_##name(void (*probe)(proto)) \
+ { \
+ return -ENOSYS; \
+ } \
+ static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
+ { \
+ }
+#endif /* backport c420970ef476d7d68df119711700666224001f43 */
+
+#else
+
+#undef __DECLARE_TRACE
+#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
+ static inline void trace_##name(proto) \
+ { } \
+ static inline void trace_##name##_rcuidle(proto) \
+ { } \
+ static inline int \
+ register_trace_##name(void (*probe)(data_proto), \
+ void *data) \
+ { \
+ return -ENOSYS; \
+ } \
+ static inline int \
+ unregister_trace_##name(void (*probe)(data_proto), \
+ void *data) \
+ { \
+ return -ENOSYS; \
+ } \
+ static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
+ { \
+ }
+
+#endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
+
+#undef DEFINE_TRACE_FN
+#define DEFINE_TRACE_FN(name, reg, unreg)
+
+#undef DEFINE_TRACE
+#define DEFINE_TRACE(name)
+
+#undef EXPORT_TRACEPOINT_SYMBOL_GPL
+#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
+
+#undef EXPORT_TRACEPOINT_SYMBOL
+#define EXPORT_TRACEPOINT_SYMBOL(name)
+
+#ifdef CONFIG_TRACEPOINTS
+#else /* CONFIG_TRACEPOINTS */
+#endif /* CONFIG_TRACEPOINTS */

#else /* just disable tracing */

@@ -42,9 +180,6 @@ static inline void trace_ ## name(proto) {}
#define TP_ARGS(args...) args
#define TP_CONDITION(args...) args

-struct tracepoint_iter {
-};
-
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */

#endif /* _COMPAT_LINUX_TRACEPOINT_H */
--
1.7.10.rc1.22.gf5241


2012-03-20 14:29:34

by Anderson Lizardo

[permalink] [raw]
Subject: Re: [Lf_driver_backport] [PATCH 2/4] compat: backport work_busy()

Hi Luiz,

[I'm subscribed only to lf_driver_backport]

On Tue, Mar 20, 2012 at 9:50 AM, Luis R. Rodriguez <[email protected]> wrote:
> On Tue, Mar 20, 2012 at 5:07 AM, Johannes Berg
> <[email protected]> wrote:
>> On Mon, 2012-03-19 at 20:26 -0700, Luis R. Rodriguez wrote:
>>> From: "Luis R. Rodriguez" <[email protected]>
>>>
>>> Best we can do is just tell the users of we are WORK_BUSY_PENDING
>>> for older kernels. The ckmake log:
>>
>> [...]
>>
>>> + * 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.
>>
>> What's this needed for? It seems if it's used only for hints/debugging
>> we should not need the function, or possibly simply return some
>> pointless combination like -1?
>
> net/bluetooth/hci_core.c:1701: ?if (work_busy(&hdev->le_scan))

Did you consider making this change bluetooth specific (e.g. under
patches/16-bluetooth.patch with LINUX_VERSION_CODE check) so that
work_pending() is used on this location for older kernels? Or are
there other users for work_busy() besides bluetooth?

I talked with the author of this code (CC'd) and he said it should be
safe to make this replacement.

Another change I made sometime ago (specifically to bluetooth code)
for it to build with older kenels (2.6.32 in my case), was to change
this line in net/bluetooth/hci_core.c:

queue_work(system_long_wq, &hdev->le_scan);

to:

schedule_work(&hdev->le_scan);

Again, I checked with the original author and we believe it is okay to
do this (I also lightly tested these changes).

Hope that helps. Best Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

2012-03-20 13:51:06

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH 2/4] compat: backport work_busy()

On Tue, Mar 20, 2012 at 5:07 AM, Johannes Berg
<[email protected]> wrote:
> On Mon, 2012-03-19 at 20:26 -0700, Luis R. Rodriguez wrote:
>> From: "Luis R. Rodriguez" <[email protected]>
>>
>> Best we can do is just tell the users of we are WORK_BUSY_PENDING
>> for older kernels. The ckmake log:
>
> [...]
>
>> + * 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.
>
> What's this needed for? It seems if it's used only for hints/debugging
> we should not need the function, or possibly simply return some
> pointless combination like -1?

net/bluetooth/hci_core.c:1701: if (work_busy(&hdev->le_scan))

Luis

2012-03-20 12:07:06

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 2/4] compat: backport work_busy()

On Mon, 2012-03-19 at 20:26 -0700, Luis R. Rodriguez wrote:
> From: "Luis R. Rodriguez" <[email protected]>
>
> Best we can do is just tell the users of we are WORK_BUSY_PENDING
> for older kernels. The ckmake log:

[...]

> + * 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.

What's this needed for? It seems if it's used only for hints/debugging
we should not need the function, or possibly simply return some
pointless combination like -1?

johannes


2012-03-20 03:27:24

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH 4/4] compat: add some tracing backport work

From: "Luis R. Rodriguez" <[email protected]>

Its not really easy to backport the tracing stuff, but
lets give it a shot. We should simply review how many
subsystems we want tracing for and for what target kernels
we want that enabled for. It doesn't make sense to
backport tracing if we won't have much users.

For now add some code that at least does not break building.

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 <[email protected]>
---
include/linux/tracepoint.h | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 9f5add1..a5bd743 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -4,7 +4,47 @@
#include <linux/version.h>

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
+
#include_next <linux/tracepoint.h>
+
+/* Backports f42c85e7 */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...) args
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+/* Backports 091ad365, a rename */
+#define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
+#define TP_PROTO TPPROTO
+#define TP_ARGS TPARGS
+#define TP_FMT TPFMT
+#define TP_RAW_FMT TPRAWFMT
+#endif
+
+#endif
+
+#else /* just disable tracing */
+
+/* Disable all tracing */
+#undef TRACE_EVENT
+#define TRACE_EVENT(name, proto, ...) \
+static inline void trace_ ## name(proto) {}
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(...)
+#undef DEFINE_EVENT
+#define DEFINE_EVENT(evt_class, name, proto, ...) \
+static inline void trace_ ## name(proto) {}
+
+#define TP_PROTO(args...) args
+#define TP_ARGS(args...) args
+#define TP_CONDITION(args...) args
+
+struct tracepoint_iter {
+};
+
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */

#endif /* _COMPAT_LINUX_TRACEPOINT_H */
--
1.7.10.rc1.22.gf5241


2012-03-20 13:54:12

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH 4/4] compat: add some tracing backport work

On Tue, Mar 20, 2012 at 5:16 AM, Johannes Berg
<[email protected]> wrote:
> In other words:
>
>>  #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
>
> I'd change this to 2.6.33 so

I think I tried this approach as well.

>>  #include_next <linux/tracepoint.h>
>
> I don't have to think about this:
>
>> +/* Backports f42c85e7 */
>> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
>> +#undef TP_STRUCT__entry
>> +#define TP_STRUCT__entry(args...) args
>> +#endif
>> +
>> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
>> +/* Backports 091ad365, a rename */
>> +#define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE
>> +
>> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
>> +#define TP_PROTO TPPROTO
>> +#define TP_ARGS TPARGS
>> +#define TP_FMT TPFMT
>> +#define TP_RAW_FMT TPRAWFMT
>> +#endif
>> +
>> +#endif
>
>
> This seems worthwhile and looks good:
>
>> +#else /* just disable tracing */
>> +
>> +/* Disable all tracing */
>> +#undef TRACE_EVENT
>> +#define TRACE_EVENT(name, proto, ...) \
>> +static inline void trace_ ## name(proto) {}
>> +#undef DECLARE_EVENT_CLASS
>> +#define DECLARE_EVENT_CLASS(...)
>> +#undef DEFINE_EVENT
>> +#define DEFINE_EVENT(evt_class, name, proto, ...) \
>> +static inline void trace_ ## name(proto) {}
>> +
>> +#define TP_PROTO(args...)  args
>> +#define TP_ARGS(args...)   args
>> +#define TP_CONDITION(args...)      args
>
> That doesn't seem to be needed since these are used inside the other
> macros only?
>
>> +struct tracepoint_iter {
>> +};
>
> Not sure why that would be needed?

Sure, yeah I think I tried disabling as you suggested and ran into
compilation issues with mac80211 on 2.6.31.

Luis

2012-03-20 12:16:07

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 4/4] compat: add some tracing backport work

In other words:

> #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))

I'd change this to 2.6.33 so

> #include_next <linux/tracepoint.h>

I don't have to think about this:

> +/* Backports f42c85e7 */
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
> +#undef TP_STRUCT__entry
> +#define TP_STRUCT__entry(args...) args
> +#endif
> +
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
> +/* Backports 091ad365, a rename */
> +#define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE
> +
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
> +#define TP_PROTO TPPROTO
> +#define TP_ARGS TPARGS
> +#define TP_FMT TPFMT
> +#define TP_RAW_FMT TPRAWFMT
> +#endif
> +
> +#endif


This seems worthwhile and looks good:

> +#else /* just disable tracing */
> +
> +/* Disable all tracing */
> +#undef TRACE_EVENT
> +#define TRACE_EVENT(name, proto, ...) \
> +static inline void trace_ ## name(proto) {}
> +#undef DECLARE_EVENT_CLASS
> +#define DECLARE_EVENT_CLASS(...)
> +#undef DEFINE_EVENT
> +#define DEFINE_EVENT(evt_class, name, proto, ...) \
> +static inline void trace_ ## name(proto) {}
> +
> +#define TP_PROTO(args...) args
> +#define TP_ARGS(args...) args
> +#define TP_CONDITION(args...) args

That doesn't seem to be needed since these are used inside the other
macros only?

> +struct tracepoint_iter {
> +};

Not sure why that would be needed?

johannes


2012-03-26 12:58:29

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH 4/4] compat: add some tracing backport work

On Mon, Mar 26, 2012 at 10:49:28AM +0200, Johannes Berg wrote:
> On Wed, 2012-03-21 at 21:29 -0700, Luis R. Rodriguez wrote:
>
> > But no dice. I then figured it may be my kernel with
> > CONFIG_TRACEPOINTS=y and indeed that is the case -- so we have to
> > consider the case where the target kernel may have tracing enabled and
> > we have to disable it somehow. Undef'ing CONFIG_TRACEPOINTS and
> > DECLARE_TRACE doesn't really do it.
>
> Oh, ok, yuck. So I guess we can't easily disable tracing if it's enabled
> in the base kernel ...

Its a bit tough.

> > We may need to redefine each macro to some COMPAT_TRACE_ macro, not sure yet.
>
> That would require patches again though, no fun either.

Agreed.

I've gotten a bit farther:

This is not yet complete. At least for mac80211 we fail with:

CC [M] /home/mcgrof/devel/compat-wireless/net/mac80211/driver-trace.o
In file included from include/trace/ftrace.h:554:0,
from include/trace/define_trace.h:96,
from /home/mcgrof/devel/compat-wireless/include/trace/define_trace.h:4,
from /home/mcgrof/devel/compat-wireless/net/mac80211/driver-trace.h:1559,
from /home/mcgrof/devel/compat-wireless/net/mac80211/driver-trace.c:8:
/home/mcgrof/devel/compat-wireless/net/mac80211/./driver-trace.h: In function ‘ftrace_test_probe_drv_return_void’:
/home/mcgrof/devel/compat-wireless/net/mac80211/./driver-trace.h:111:2: error: implicit declaration of function ‘check_trace_callback_type_drv_return_void’

This is against v2.6.33

And ckmake log:

mcgrof@tux ~/compat (git::master)$ ckmake
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 [FAILED]
Trying kernel 2.6.36-02063604-generic [FAILED]
Trying kernel 2.6.35-02063512-generic [FAILED]
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]


---
include/linux/tracepoint.h | 57 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 4 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index a5bd743..4930600 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -10,13 +10,16 @@
/* Backports f42c85e7 */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
#undef TP_STRUCT__entry
+/* XXX: Is this right when CONFIG_TRACEPOINTS is enabled ? */
#define TP_STRUCT__entry(args...) args
#endif

-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
/* Backports 091ad365, a rename */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
#define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE
+#endif

+/* Backpports 2939b0469 */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
#define TP_PROTO TPPROTO
#define TP_ARGS TPARGS
@@ -24,7 +27,53 @@
#define TP_RAW_FMT TPRAWFMT
#endif

-#endif
+/* Force disabling tracing */
+#undef TRACE_EVENT
+#define TRACE_EVENT(name, proto, ...) \
+static inline void trace_ ## name(proto) {}
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(...)
+#undef DEFINE_EVENT
+#define DEFINE_EVENT(evt_class, name, proto, ...) \
+static inline void trace_ ## name(proto) {}
+
+#undef __DECLARE_TRACE
+#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
+ static inline void trace_##name(proto) \
+ { } \
+ static inline void trace_##name##_rcuidle(proto) \
+ { } \
+ static inline int \
+ register_trace_##name(void (*probe)(data_proto), \
+ void *data) \
+ { \
+ return -ENOSYS; \
+ } \
+ static inline int \
+ unregister_trace_##name(void (*probe)(data_proto), \
+ void *data) \
+ { \
+ return -ENOSYS; \
+ } \
+ static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
+ { \
+ }
+
+#undef DEFINE_TRACE_FN
+#define DEFINE_TRACE_FN(name, reg, unreg)
+
+#undef DEFINE_TRACE
+#define DEFINE_TRACE(name)
+
+#undef EXPORT_TRACEPOINT_SYMBOL_GPL
+#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
+
+#undef EXPORT_TRACEPOINT_SYMBOL
+#define EXPORT_TRACEPOINT_SYMBOL(name)
+
+#ifdef CONFIG_TRACEPOINTS
+#else /* CONFIG_TRACEPOINTS */
+#endif /* CONFIG_TRACEPOINTS */

#else /* just disable tracing */

@@ -42,8 +91,8 @@ static inline void trace_ ## name(proto) {}
#define TP_ARGS(args...) args
#define TP_CONDITION(args...) args

-struct tracepoint_iter {
-};
+//struct tracepoint_iter {
+//};

#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */

--
1.7.10.rc1.22.gf5241


2012-03-26 08:49:32

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 4/4] compat: add some tracing backport work

On Wed, 2012-03-21 at 21:29 -0700, Luis R. Rodriguez wrote:

> But no dice. I then figured it may be my kernel with
> CONFIG_TRACEPOINTS=y and indeed that is the case -- so we have to
> consider the case where the target kernel may have tracing enabled and
> we have to disable it somehow. Undef'ing CONFIG_TRACEPOINTS and
> DECLARE_TRACE doesn't really do it.

Oh, ok, yuck. So I guess we can't easily disable tracing if it's enabled
in the base kernel ...

> We may need to redefine each macro to some COMPAT_TRACE_ macro, not sure yet.

That would require patches again though, no fun either.

johannes


2012-03-20 03:27:15

by Luis R. Rodriguez

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

From: "Luis R. Rodriguez" <[email protected]>

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 <[email protected]>
---
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


2012-03-22 04:29:30

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH 4/4] compat: add some tracing backport work

On Tue, Mar 20, 2012 at 6:53 AM, Luis R. Rodriguez <[email protected]> wrote:
> On Tue, Mar 20, 2012 at 5:16 AM, Johannes Berg
> <[email protected]> wrote:
> Sure, yeah I think I tried disabling as you suggested and ran into
> compilation issues with mac80211 on 2.6.31.

I tested again by only having this:


mcgrof@tux ~/compat (git::master)$ cat include/linux/tracepoint.h
#ifndef _COMPAT_LINUX_TRACEPOINT_H
#define _COMPAT_LINUX_TRACEPOINT_H 1

#include <linux/version.h>

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,33))

#include_next <linux/tracepoint.h>

#else /* just disable tracing */

/* Disable all tracing */
#undef TRACE_EVENT
#define TRACE_EVENT(name, proto, ...) \
static inline void trace_ ## name(proto) {}
#undef DECLARE_EVENT_CLASS
#define DECLARE_EVENT_CLASS(...)
#undef DEFINE_EVENT
#define DEFINE_EVENT(evt_class, name, proto, ...) \
static inline void trace_ ## name(proto) {}

#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,33)) */

#endif /* _COMPAT_LINUX_TRACEPOINT_H */

And then by using compat-wireless tag
compat-wireless-2012-03-14-3-g98cc995 against linux-next tag
next-20120314 I can only compile up to 2.6.34. Anything older I get
compilation errors which seem to point to somehow DEFINE_EVENT()
failing.

./scripts/gen-compat-autoconf.sh
/home/mcgrof/devel/compat-wireless/.config
/home/mcgrof/devel/compat-wireless/config.mk >
include/linux/compat_autoconf.h
make -C /lib/modules/2.6.33-02063305-generic/build
M=/home/mcgrof/devel/compat-wireless modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.33-02063305-generic'
CC [M] /home/mcgrof/devel/compat-wireless/compat/main.o
In file included from include/linux/kmemtrace.h:12:0,
from include/linux/slub_def.h:13,
from include/linux/slab.h:162,
from include/linux/percpu.h:5,
from
/usr/src/linux-headers-2.6.33-02063305-generic/arch/x86/include/asm/local.h:4,
from include/linux/module.h:20,
from include/linux/textsearch.h:7,
from include/linux/skbuff.h:27,
from include/linux/if_ether.h:124,
from include/linux/netdevice.h:29,
from
/home/mcgrof/devel/compat-wireless/include/linux/compat-2.6.29.h:5,
from
/home/mcgrof/devel/compat-wireless/include/linux/compat-2.6.h:49,
from <command-line>:1:
include/trace/events/kmem.h:81:11: error: expected ‘)’ before ‘(’ token

Now this kmem.h line 81 has:

DEFINE_EVENT(kmem_alloc, kmalloc,

TP_PROTO(unsigned long call_site, const void *ptr,
size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),

TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
);

This is then fixed by adding TP_PROTO and TP_ARGS to our backport:

#define TP_PROTO(args...) args
#define TP_ARGS(args...) args
#define TP_CONDITION(args...) args

But then we get:

./scripts/gen-compat-autoconf.sh
/home/mcgrof/devel/compat-wireless/.config
/home/mcgrof/devel/compat-wireless/config.mk >
include/linux/compat_autoconf.h
make -C /lib/modules/2.6.33-02063305-generic/build
M=/home/mcgrof/devel/compat-wireless modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.33-02063305-generic'
CC [M] /home/mcgrof/devel/compat-wireless/compat/main.o
In file included from include/linux/kmemtrace.h:12:0,
from include/linux/slub_def.h:13,
from include/linux/slab.h:162,
from include/linux/percpu.h:5,
from
/usr/src/linux-headers-2.6.33-02063305-generic/arch/x86/include/asm/local.h:4,
from include/linux/module.h:20,
from include/linux/textsearch.h:7,
from include/linux/skbuff.h:27,
from include/linux/if_ether.h:124,
from include/linux/netdevice.h:29,
from
/home/mcgrof/devel/compat-wireless/include/linux/compat-2.6.29.h:5,
from
/home/mcgrof/devel/compat-wireless/include/linux/compat-2.6.h:49,
from <command-line>:1:
include/trace/events/kmem.h:292:41: error: expected ‘)’ before ‘(’ token

And also:

include/linux/module.h:543:47: warning: ‘struct tracepoint_iter’
declared inside parameter list
include/linux/module.h:543:47: warning: its scope is only this
definition or declaration, which is probably not what you want
make[3]: *** [/home/mcgrof/devel/compat-wireless/compat/main.o] Error 1
make[2]: *** [/home/mcgrof/devel/compat-wireless/compat] Error 2
make[1]: *** [_module_/home/mcgrof/devel/compat-wireless] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.33-02063305-generic'
make: *** [modules] Error 2

I'm trying to work my way through disabling this properly but haven't
figured out yet how. I tried adding:

#undef DECLARE_TRACE
#define DECLARE_TRACE(name, proto, ...) \
static inline void trace_ ## name(proto) {}

#undef DEFINE_EVENT_PRINT
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))

But no dice. I then figured it may be my kernel with
CONFIG_TRACEPOINTS=y and indeed that is the case -- so we have to
consider the case where the target kernel may have tracing enabled and
we have to disable it somehow. Undef'ing CONFIG_TRACEPOINTS and
DECLARE_TRACE doesn't really do it.

We may need to redefine each macro to some COMPAT_TRACE_ macro, not sure yet.

Luis

2012-03-20 03:27:12

by Luis R. Rodriguez

[permalink] [raw]
Subject: [PATCH 1/4] compat: backport system work queues system_wq and system_long_wq

From: "Luis R. Rodriguez" <[email protected]>

mcgrof@tux ~/linux-stable (git::master)$ git describe --contains d320c038
v2.6.36-rc1~506^2~26

The commit d320c038 added some new system workqueues to allow us
to categorize order of priority on workqueue items. We had already
backported usage of system_nrt_wq but hadn't backported usage of
system_wq or system_long_wq. We address this now in this patch
by also ensuring that flush_workqueue() will flush these as
designed, that is only prioritizing system_wq. Given that older
kernels would be using the older keventd_wq for now we flush
that and then system_wq, allowing users of the system_long_wq
to be delayed as intended for backported kernel code using this
framework.

For newer kernels this is a no-op.

commit d320c03830b17af64e4547075003b1eeb274bc6c
Author: Tejun Heo <[email protected]>
Date: Tue Jun 29 10:07:14 2010 +0200

workqueue: s/__create_workqueue()/alloc_workqueue()/, and add system workqueues

This patch makes changes to make new workqueue features available to
its users.

* Now that workqueue is more featureful, there should be a public
workqueue creation function which takes paramters to control them.
Rename __create_workqueue() to alloc_workqueue() and make 0
max_active mean WQ_DFL_ACTIVE. In the long run, all
create_workqueue_*() will be converted over to alloc_workqueue().

* To further unify access interface, rename keventd_wq to system_wq
and export it.

* Add system_long_wq and system_nrt_wq. The former is to host long
running works separately (so that flush_scheduled_work() dosen't
take so long) and the latter guarantees any queued work item is
never executed in parallel by multiple CPUs. These will be used by
future patches to update workqueue users.

Signed-off-by: Tejun Heo <[email protected]>

The ckmake [documented on 0] 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]

[0] https://github.com/mcgrof/compat/wiki

Cc: Tejun Heo <[email protected]>
Signed-off-by: Luis R. Rodriguez <[email protected]>
---
compat/compat-2.6.36.c | 53 ++++++++++++++++++++++++++++++++++++++++-
include/linux/compat-2.6.36.h | 32 +++++++++++++++++++++++++
2 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c
index dfab2ea..b79609c 100644
--- a/compat/compat-2.6.36.c
+++ b/compat/compat-2.6.36.c
@@ -95,16 +95,67 @@ EXPORT_SYMBOL_GPL(compat_usb_scuttle_anchored_urbs);

#endif /* CONFIG_COMPAT_USB_URB_THREAD_FIX */

+struct workqueue_struct *system_wq __read_mostly;
+struct workqueue_struct *system_long_wq __read_mostly;
struct workqueue_struct *system_nrt_wq __read_mostly;
+EXPORT_SYMBOL_GPL(system_wq);
+EXPORT_SYMBOL_GPL(system_long_wq);
EXPORT_SYMBOL_GPL(system_nrt_wq);

+int compat_schedule_work(struct work_struct *work)
+{
+ return queue_work(system_wq, work);
+}
+EXPORT_SYMBOL_GPL(compat_schedule_work);
+
+int compat_schedule_work_on(int cpu, struct work_struct *work)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
+ return queue_work_on(cpu, system_wq, work);
+#else
+ return queue_work(system_wq, work);
+#endif
+}
+EXPORT_SYMBOL_GPL(compat_schedule_work_on);
+
+int compat_schedule_delayed_work(struct delayed_work *dwork,
+ unsigned long delay)
+{
+ return queue_delayed_work(system_wq, dwork, delay);
+}
+EXPORT_SYMBOL_GPL(compat_schedule_delayed_work);
+
+int compat_schedule_delayed_work_on(int cpu,
+ struct delayed_work *dwork,
+ unsigned long delay)
+{
+ return queue_delayed_work_on(cpu, system_wq, dwork, delay);
+}
+EXPORT_SYMBOL_GPL(compat_schedule_delayed_work_on);
+
+void compat_flush_scheduled_work(void)
+{
+ /*
+ * It is debatable which one we should prioritize first, lets
+ * go with the old kernel's one first for now (keventd_wq) and
+ * if think its reasonable later we can flip this around.
+ */
+ flush_workqueue(system_wq);
+ flush_scheduled_work();
+}
+EXPORT_SYMBOL_GPL(compat_flush_scheduled_work);
+
void compat_system_workqueue_create()
{
+ system_wq = alloc_workqueue("events", 0, 0);
+ system_long_wq = alloc_workqueue("events_long", 0, 0);
system_nrt_wq = create_singlethread_workqueue("events_nrt");
- WARN_ON(!system_nrt_wq);
+ BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq);
}

void compat_system_workqueue_destroy()
{
+ destroy_workqueue(system_wq);
+ destroy_workqueue(system_long_wq);
destroy_workqueue(system_nrt_wq);
}
diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h
index 314fb35..4768e63 100644
--- a/include/linux/compat-2.6.36.h
+++ b/include/linux/compat-2.6.36.h
@@ -137,11 +137,43 @@ static inline void skb_tx_timestamp(struct sk_buff *skb)
{
}

+/*
+ * System-wide workqueues which are always present.
+ *
+ * system_wq is the one used by schedule[_delayed]_work[_on]().
+ * Multi-CPU multi-threaded. There are users which expect relatively
+ * short queue flush time. Don't queue works which can run for too
+ * long.
+ *
+ * system_long_wq is similar to system_wq but may host long running
+ * works. Queue flushing might take relatively long.
+ *
+ * system_nrt_wq is non-reentrant and guarantees that any given work
+ * item is never executed in parallel by multiple CPUs. Queue
+ * flushing might take relatively long.
+ */
+extern struct workqueue_struct *system_wq;
+extern struct workqueue_struct *system_long_wq;
extern struct workqueue_struct *system_nrt_wq;

void compat_system_workqueue_create(void);
void compat_system_workqueue_destroy(void);

+int compat_schedule_work(struct work_struct *work);
+int compat_schedule_work_on(int cpu, struct work_struct *work);
+int compat_schedule_delayed_work(struct delayed_work *dwork,
+ unsigned long delay);
+int compat_schedule_delayed_work_on(int cpu,
+ struct delayed_work *dwork,
+ unsigned long delay);
+void compat_flush_scheduled_work(void);
+
+#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)
+#define schedule_delayed_work_on(cpu, dwork, delay) compat_schedule_delayed_work_on(cpu, dwork, delay)
+#define flush_scheduled_work(a) compat_flush_scheduled_work(a)
+
#define br_port_exists(dev) (dev->br_port)

#else
--
1.7.10.rc1.22.gf5241


2012-03-20 14:30:46

by Anderson Lizardo

[permalink] [raw]
Subject: Re: [Lf_driver_backport] [PATCH 2/4] compat: backport work_busy()

On Tue, Mar 20, 2012 at 10:29 AM, Anderson Lizardo
<[email protected]> wrote:
> Hi Luiz,

s/Luiz/Luis/ of course :)

Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

2012-04-05 12:33:10

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 4/4] compat: add some tracing backport work

On Wed, 2012-03-28 at 06:00 -0400, Luis R. Rodriguez wrote:

> I've managed to backport tracing it seems, even when CONFIG_TRACEPOINTS
> is enabled.

Nope, you've managed to completely kill tracing.


> +#undef __DECLARE_TRACE
> +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
> + static inline void trace_##name(proto) \
> + { } \
> + static inline void trace_##name##_rcuidle(proto) \
> + { } \
> + static inline int \
> + register_trace_##name(void (*probe)(proto)) \
> + { \
> + return -ENOSYS; \
> + } \
> + static inline void \
> + unregister_trace_##name(void (*probe)(proto)) \
> + { \
> + return -ENOSYS; \
> + } \
> + static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
> + { \
> + }

All of this simply completely kills tracing. Worse, the tracepoints get
registered, but their trace_##name functions do nothing, so you can
think that they're there, but they never record data ...

The old way was much better. Can we just let 2.6.24 and the other
ancients die in peace?

johannes