diff mbox

[10/10] backport: implement alloc_percpu_gfp() for < 3.18.

Message ID 20180218132459.11011-11-luca@coelho.fi (mailing list archive)
State Accepted
Headers show

Commit Message

Luca Coelho Feb. 18, 2018, 1:24 p.m. UTC
From: Sara Sharon <sara.sharon@intel.com>

mac80211 now uses the alloc_percpu_gfp() function, which doesn't exist
in kernels older than 3.18.  Backport it accordingly.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 backport-include/linux/percpu.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 backport-include/linux/percpu.h

Comments

Hauke Mehrtens Feb. 18, 2018, 4:10 p.m. UTC | #1
On 02/18/2018 02:24 PM, Luca Coelho wrote:
> From: Sara Sharon <sara.sharon@intel.com>
> 
> mac80211 now uses the alloc_percpu_gfp() function, which doesn't exist
> in kernels older than 3.18.  Backport it accordingly.
> 
> Signed-off-by: Sara Sharon <sara.sharon@intel.com>
> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> ---
>  backport-include/linux/percpu.h | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>  create mode 100644 backport-include/linux/percpu.h
> 
> diff --git a/backport-include/linux/percpu.h b/backport-include/linux/percpu.h
> new file mode 100644
> index 000000000000..10be03cba795
> --- /dev/null
> +++ b/backport-include/linux/percpu.h
> @@ -0,0 +1,19 @@
> +/*
> + * Copyright (C) 2018 Intel Corporation
> + */
> +#ifndef __BACKPORT_PERCPU_H
> +#define __BACKPORT_PERCPU_H
> +#include_next <linux/percpu.h>
> +
> +#if LINUX_VERSION_IS_LESS(3,18,0)
> +static inline void __percpu *__alloc_gfp_warn(void)
> +{
> +	WARN(1, "Cannot backport alloc_percpu_gfp");
> +	return NULL;

Is this only called with GFP_KERNEL for now or why is it ok to only show
an error message here?

> +}
> +
> +#define alloc_percpu_gfp(type, gfp) \
> +	({ (gfp == GFP_KERNEL) ? alloc_percpu(type) : __alloc_gfp_warn(); })
> +#endif /* LINUX_VERSION_IS_LESS(3,18,0) */
> +
> +#endif /* __BACKPORT_PERCPU_H */
> 

--
To unsubscribe from this list: send the line "unsubscribe backports" in
Luca Coelho Feb. 18, 2018, 5:58 p.m. UTC | #2
On Sun, 2018-02-18 at 17:10 +0100, Hauke Mehrtens wrote:
> On 02/18/2018 02:24 PM, Luca Coelho wrote:
> > From: Sara Sharon <sara.sharon@intel.com>
> > 
> > mac80211 now uses the alloc_percpu_gfp() function, which doesn't
> > exist
> > in kernels older than 3.18.  Backport it accordingly.
> > 
> > Signed-off-by: Sara Sharon <sara.sharon@intel.com>
> > Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> > ---
> >  backport-include/linux/percpu.h | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >  create mode 100644 backport-include/linux/percpu.h
> > 
> > diff --git a/backport-include/linux/percpu.h b/backport-
> > include/linux/percpu.h
> > new file mode 100644
> > index 000000000000..10be03cba795
> > --- /dev/null
> > +++ b/backport-include/linux/percpu.h
> > @@ -0,0 +1,19 @@
> > +/*
> > + * Copyright (C) 2018 Intel Corporation
> > + */
> > +#ifndef __BACKPORT_PERCPU_H
> > +#define __BACKPORT_PERCPU_H
> > +#include_next <linux/percpu.h>
> > +
> > +#if LINUX_VERSION_IS_LESS(3,18,0)
> > +static inline void __percpu *__alloc_gfp_warn(void)
> > +{
> > +	WARN(1, "Cannot backport alloc_percpu_gfp");
> > +	return NULL;
> 
> Is this only called with GFP_KERNEL for now or why is it ok to only
> show
> an error message here?

Yes, exactly.  For now we only use it with GFP_KERNEL and backporting
for the other cases would be very difficult, so I took this shortcut
here.

--
Luca.
--
To unsubscribe from this list: send the line "unsubscribe backports" in
Hauke Mehrtens Feb. 28, 2018, 6:32 p.m. UTC | #3
On 02/18/2018 02:24 PM, Luca Coelho wrote:
> From: Sara Sharon <sara.sharon@intel.com>
> 
> mac80211 now uses the alloc_percpu_gfp() function, which doesn't exist
> in kernels older than 3.18.  Backport it accordingly.
> 
> Signed-off-by: Sara Sharon <sara.sharon@intel.com>
> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> ---
>  backport-include/linux/percpu.h | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>  create mode 100644 backport-include/linux/percpu.h
> 
> diff --git a/backport-include/linux/percpu.h b/backport-include/linux/percpu.h
> new file mode 100644
> index 000000000000..10be03cba795
> --- /dev/null
> +++ b/backport-include/linux/percpu.h

This path is wrong, please add this to
backport/backport-include/linux/percpu.h

As this was already applied, will you send a patch to fix this please.

> @@ -0,0 +1,19 @@
> +/*
> + * Copyright (C) 2018 Intel Corporation
> + */
> +#ifndef __BACKPORT_PERCPU_H
> +#define __BACKPORT_PERCPU_H
> +#include_next <linux/percpu.h>
> +
> +#if LINUX_VERSION_IS_LESS(3,18,0)
> +static inline void __percpu *__alloc_gfp_warn(void)
> +{
> +	WARN(1, "Cannot backport alloc_percpu_gfp");
> +	return NULL;
> +}
> +
> +#define alloc_percpu_gfp(type, gfp) \
> +	({ (gfp == GFP_KERNEL) ? alloc_percpu(type) : __alloc_gfp_warn(); })
> +#endif /* LINUX_VERSION_IS_LESS(3,18,0) */
> +
> +#endif /* __BACKPORT_PERCPU_H */
> 
--
To unsubscribe from this list: send the line "unsubscribe backports" in
Luca Coelho Feb. 28, 2018, 6:48 p.m. UTC | #4
On Wed, 2018-02-28 at 19:32 +0100, Hauke Mehrtens wrote:
> 
> On 02/18/2018 02:24 PM, Luca Coelho wrote:
> > From: Sara Sharon <sara.sharon@intel.com>
> > 
> > mac80211 now uses the alloc_percpu_gfp() function, which doesn't
> > exist
> > in kernels older than 3.18.  Backport it accordingly.
> > 
> > Signed-off-by: Sara Sharon <sara.sharon@intel.com>
> > Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> > ---
> >  backport-include/linux/percpu.h | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >  create mode 100644 backport-include/linux/percpu.h
> > 
> > diff --git a/backport-include/linux/percpu.h b/backport-
> > include/linux/percpu.h
> > new file mode 100644
> > index 000000000000..10be03cba795
> > --- /dev/null
> > +++ b/backport-include/linux/percpu.h
> 
> This path is wrong, please add this to
> backport/backport-include/linux/percpu.h
> 
> As this was already applied, will you send a patch to fix this
> please.

Oh, sorry.  My bad.  Our internal tree is a backport itself, so the
tree struct is different.  Usually the patches apply nicely and go to
the correct directories automatically (git magic), but I since this is
a new file, it couldn't detect anything similar and just added it to
the wrong place.

I'll send a fix.  Thanks for pointing out.

--
Cheers,
Luca.
--
To unsubscribe from this list: send the line "unsubscribe backports" in
diff mbox

Patch

diff --git a/backport-include/linux/percpu.h b/backport-include/linux/percpu.h
new file mode 100644
index 000000000000..10be03cba795
--- /dev/null
+++ b/backport-include/linux/percpu.h
@@ -0,0 +1,19 @@ 
+/*
+ * Copyright (C) 2018 Intel Corporation
+ */
+#ifndef __BACKPORT_PERCPU_H
+#define __BACKPORT_PERCPU_H
+#include_next <linux/percpu.h>
+
+#if LINUX_VERSION_IS_LESS(3,18,0)
+static inline void __percpu *__alloc_gfp_warn(void)
+{
+	WARN(1, "Cannot backport alloc_percpu_gfp");
+	return NULL;
+}
+
+#define alloc_percpu_gfp(type, gfp) \
+	({ (gfp == GFP_KERNEL) ? alloc_percpu(type) : __alloc_gfp_warn(); })
+#endif /* LINUX_VERSION_IS_LESS(3,18,0) */
+
+#endif /* __BACKPORT_PERCPU_H */