* [PATCH] lib: lz4: fixed zram with lz4 on big endian machines
@ 2016-04-08 15:23 ` Rui Salvaterra
0 siblings, 0 replies; 8+ messages in thread
From: Rui Salvaterra @ 2016-04-08 15:23 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, sergey.senozhatsky, sergey.senozhatsky.work, gregkh,
eunb.song, minchan, chanho.min, kyungsik.lee, Rui Salvaterra,
stable
Based on Sergey's test patch [1], this fixes zram with lz4 compression on big endian cpus. Tested on ppc64 with no regression on x86_64.
[1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4
Cc: stable@vger.kernel.org
Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
---
lib/lz4/lz4defs.h | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
index abcecdc..a98c08c 100644
--- a/lib/lz4/lz4defs.h
+++ b/lib/lz4/lz4defs.h
@@ -11,8 +11,7 @@
/*
* Detects 64 bits mode
*/
-#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
- || defined(__ppc64__) || defined(__LP64__))
+#if defined(CONFIG_64BIT)
#define LZ4_ARCH64 1
#else
#define LZ4_ARCH64 0
@@ -25,9 +24,7 @@
typedef struct _U16_S { u16 v; } U16_S;
typedef struct _U32_S { u32 v; } U32_S;
typedef struct _U64_S { u64 v; } U64_S;
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) \
- || defined(CONFIG_ARM) && __LINUX_ARM_ARCH__ >= 6 \
- && defined(ARM_EFFICIENT_UNALIGNED_ACCESS)
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
#define A16(x) (((U16_S *)(x))->v)
#define A32(x) (((U32_S *)(x))->v)
@@ -35,6 +32,10 @@ typedef struct _U64_S { u64 v; } U64_S;
#define PUT4(s, d) (A32(d) = A32(s))
#define PUT8(s, d) (A64(d) = A64(s))
+
+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
+ (d = s - A16(p))
+
#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
do { \
A16(p) = v; \
@@ -51,12 +52,15 @@ typedef struct _U64_S { u64 v; } U64_S;
#define PUT8(s, d) \
put_unaligned(get_unaligned((const u64 *) s), (u64 *) d)
-#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
- do { \
- put_unaligned(v, (u16 *)(p)); \
- p += 2; \
+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
+ (d = s - get_unaligned_le16(p))
+
+#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
+ do { \
+ put_unaligned_le16(v, (u16 *)(p)); \
+ p += 2; \
} while (0)
-#endif
+#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
#define COPYLENGTH 8
#define ML_BITS 4
@@ -138,10 +142,7 @@ typedef struct _U64_S { u64 v; } U64_S;
#define LZ4_NBCOMMONBYTES(val) (__builtin_ctz(val) >> 3)
#endif
-#endif
-
-#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
- (d = s - get_unaligned_le16(p))
+#endif /* LZ4_ARCH64 */
#define LZ4_WILDCOPY(s, d, e) \
do { \
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] lib: lz4: fixed zram with lz4 on big endian machines
@ 2016-04-08 15:23 ` Rui Salvaterra
0 siblings, 0 replies; 8+ messages in thread
From: Rui Salvaterra @ 2016-04-08 15:23 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, sergey.senozhatsky, sergey.senozhatsky.work, gregkh,
eunb.song, minchan, chanho.min, kyungsik.lee, Rui Salvaterra,
stable
Based on Sergey's test patch [1], this fixes zram with lz4 compression on big endian cpus. Tested on ppc64 with no regression on x86_64.
[1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4
Cc: stable@vger.kernel.org
Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
---
lib/lz4/lz4defs.h | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
index abcecdc..a98c08c 100644
--- a/lib/lz4/lz4defs.h
+++ b/lib/lz4/lz4defs.h
@@ -11,8 +11,7 @@
/*
* Detects 64 bits mode
*/
-#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
- || defined(__ppc64__) || defined(__LP64__))
+#if defined(CONFIG_64BIT)
#define LZ4_ARCH64 1
#else
#define LZ4_ARCH64 0
@@ -25,9 +24,7 @@
typedef struct _U16_S { u16 v; } U16_S;
typedef struct _U32_S { u32 v; } U32_S;
typedef struct _U64_S { u64 v; } U64_S;
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) \
- || defined(CONFIG_ARM) && __LINUX_ARM_ARCH__ >= 6 \
- && defined(ARM_EFFICIENT_UNALIGNED_ACCESS)
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
#define A16(x) (((U16_S *)(x))->v)
#define A32(x) (((U32_S *)(x))->v)
@@ -35,6 +32,10 @@ typedef struct _U64_S { u64 v; } U64_S;
#define PUT4(s, d) (A32(d) = A32(s))
#define PUT8(s, d) (A64(d) = A64(s))
+
+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
+ (d = s - A16(p))
+
#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
do { \
A16(p) = v; \
@@ -51,12 +52,15 @@ typedef struct _U64_S { u64 v; } U64_S;
#define PUT8(s, d) \
put_unaligned(get_unaligned((const u64 *) s), (u64 *) d)
-#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
- do { \
- put_unaligned(v, (u16 *)(p)); \
- p += 2; \
+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
+ (d = s - get_unaligned_le16(p))
+
+#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
+ do { \
+ put_unaligned_le16(v, (u16 *)(p)); \
+ p += 2; \
} while (0)
-#endif
+#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
#define COPYLENGTH 8
#define ML_BITS 4
@@ -138,10 +142,7 @@ typedef struct _U64_S { u64 v; } U64_S;
#define LZ4_NBCOMMONBYTES(val) (__builtin_ctz(val) >> 3)
#endif
-#endif
-
-#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
- (d = s - get_unaligned_le16(p))
+#endif /* LZ4_ARCH64 */
#define LZ4_WILDCOPY(s, d, e) \
do { \
--
2.7.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] lib: lz4: fixed zram with lz4 on big endian machines
2016-04-08 15:23 ` Rui Salvaterra
@ 2016-04-08 16:50 ` Greg KH
-1 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2016-04-08 16:50 UTC (permalink / raw)
To: Rui Salvaterra
Cc: linux-kernel, linux-mm, sergey.senozhatsky,
sergey.senozhatsky.work, eunb.song, minchan, chanho.min,
kyungsik.lee, stable
On Fri, Apr 08, 2016 at 04:23:24PM +0100, Rui Salvaterra wrote:
> Based on Sergey's test patch [1], this fixes zram with lz4 compression on big endian cpus. Tested on ppc64 with no regression on x86_64.
Please wrap your text at 72 columns in a changelog comment.
>
> [1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
Please attribute Sergey here in the signed-off-by area with a
"Suggested-by:" type mark
> ---
> lib/lz4/lz4defs.h | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
> index abcecdc..a98c08c 100644
> --- a/lib/lz4/lz4defs.h
> +++ b/lib/lz4/lz4defs.h
> @@ -11,8 +11,7 @@
> /*
> * Detects 64 bits mode
> */
> -#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
> - || defined(__ppc64__) || defined(__LP64__))
> +#if defined(CONFIG_64BIT)
This patch seems to do two different things, clean up the #if tests, and
change the endian of some calls. Can you break this up into 2 different
patches?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] lib: lz4: fixed zram with lz4 on big endian machines
@ 2016-04-08 16:50 ` Greg KH
0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2016-04-08 16:50 UTC (permalink / raw)
To: Rui Salvaterra
Cc: linux-kernel, linux-mm, sergey.senozhatsky,
sergey.senozhatsky.work, eunb.song, minchan, chanho.min,
kyungsik.lee, stable
On Fri, Apr 08, 2016 at 04:23:24PM +0100, Rui Salvaterra wrote:
> Based on Sergey's test patch [1], this fixes zram with lz4 compression on big endian cpus. Tested on ppc64 with no regression on x86_64.
Please wrap your text at 72 columns in a changelog comment.
>
> [1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
Please attribute Sergey here in the signed-off-by area with a
"Suggested-by:" type mark
> ---
> lib/lz4/lz4defs.h | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
> index abcecdc..a98c08c 100644
> --- a/lib/lz4/lz4defs.h
> +++ b/lib/lz4/lz4defs.h
> @@ -11,8 +11,7 @@
> /*
> * Detects 64 bits mode
> */
> -#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
> - || defined(__ppc64__) || defined(__LP64__))
> +#if defined(CONFIG_64BIT)
This patch seems to do two different things, clean up the #if tests, and
change the endian of some calls. Can you break this up into 2 different
patches?
thanks,
greg k-h
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] lib: lz4: fixed zram with lz4 on big endian machines
2016-04-08 16:50 ` Greg KH
(?)
@ 2016-04-08 19:51 ` Rui Salvaterra
2016-04-08 20:05 ` Greg KH
-1 siblings, 1 reply; 8+ messages in thread
From: Rui Salvaterra @ 2016-04-08 19:51 UTC (permalink / raw)
To: Greg KH
Cc: Chanho Min, Sergey Senozhatsky, eunb.song, linux-kernel,
kyungsik.lee, stable, minchan, sergey.senozhatsky, linux-mm
[-- Attachment #1: Type: text/plain, Size: 1558 bytes --]
On 8 Apr 2016 17:50, "Greg KH" <gregkh@linuxfoundation.org> wrote:
>
> On Fri, Apr 08, 2016 at 04:23:24PM +0100, Rui Salvaterra wrote:
> > Based on Sergey's test patch [1], this fixes zram with lz4 compression
on big endian cpus. Tested on ppc64 with no regression on x86_64.
>
> Please wrap your text at 72 columns in a changelog comment.
>
> >
> > [1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4
> >
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
>
> Please attribute Sergey here in the signed-off-by area with a
> "Suggested-by:" type mark
>
> > ---
> > lib/lz4/lz4defs.h | 29 +++++++++++++++--------------
> > 1 file changed, 15 insertions(+), 14 deletions(-)
> >
> > diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
> > index abcecdc..a98c08c 100644
> > --- a/lib/lz4/lz4defs.h
> > +++ b/lib/lz4/lz4defs.h
> > @@ -11,8 +11,7 @@
> > /*
> > * Detects 64 bits mode
> > */
> > -#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
> > - || defined(__ppc64__) || defined(__LP64__))
> > +#if defined(CONFIG_64BIT)
>
> This patch seems to do two different things, clean up the #if tests, and
> change the endian of some calls. Can you break this up into 2 different
> patches?
>
> thanks,
>
> greg k-h
Hi Greg,
Thanks for the review (and patience). The 64-bit #if test is actually part
of the fix, since __ppc64__ isn't defined anywhere and we'd fall into the
32-bit definitions for ppc64. I can send the other one separately, for
sure. I'll do a v2 tomorrow.
Thanks,
Rui
[-- Attachment #2: Type: text/html, Size: 2296 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] lib: lz4: fixed zram with lz4 on big endian machines
2016-04-08 19:51 ` Rui Salvaterra
2016-04-08 20:05 ` Greg KH
@ 2016-04-08 20:05 ` Greg KH
0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2016-04-08 20:05 UTC (permalink / raw)
To: Rui Salvaterra
Cc: Chanho Min, Sergey Senozhatsky, eunb.song, linux-kernel,
kyungsik.lee, stable, minchan, sergey.senozhatsky, linux-mm
On Fri, Apr 08, 2016 at 08:51:17PM +0100, Rui Salvaterra wrote:
>
> On 8 Apr 2016 17:50, "Greg KH" <gregkh@linuxfoundation.org> wrote:
> >
> > On Fri, Apr 08, 2016 at 04:23:24PM +0100, Rui Salvaterra wrote:
> > > Based on Sergey's test patch [1], this fixes zram with lz4 compression on
> big endian cpus. Tested on ppc64 with no regression on x86_64.
> >
> > Please wrap your text at 72 columns in a changelog comment.
> >
> > >
> > > [1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4
> > >
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
> >
> > Please attribute Sergey here in the signed-off-by area with a
> > "Suggested-by:" type mark
> >
> > > ---
> > > lib/lz4/lz4defs.h | 29 +++++++++++++++--------------
> > > 1 file changed, 15 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
> > > index abcecdc..a98c08c 100644
> > > --- a/lib/lz4/lz4defs.h
> > > +++ b/lib/lz4/lz4defs.h
> > > @@ -11,8 +11,7 @@
> > > /*
> > > * Detects 64 bits mode
> > > */
> > > -#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
> > > - || defined(__ppc64__) || defined(__LP64__))
> > > +#if defined(CONFIG_64BIT)
> >
> > This patch seems to do two different things, clean up the #if tests, and
> > change the endian of some calls. Can you break this up into 2 different
> > patches?
> >
> > thanks,
> >
> > greg k-h
>
> Hi Greg,
>
> Thanks for the review (and patience). The 64-bit #if test is actually part of
> the fix, since __ppc64__ isn't defined anywhere and we'd fall into the 32-bit
> definitions for ppc64. I can send the other one separately, for sure. I'll do a
> v2 tomorrow.
Ah, well document that please, it was not obvious at all that this was
required.
thanks,
greg k-h-
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] lib: lz4: fixed zram with lz4 on big endian machines
@ 2016-04-08 20:05 ` Greg KH
0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2016-04-08 20:05 UTC (permalink / raw)
To: Rui Salvaterra
Cc: Chanho Min, Sergey Senozhatsky, eunb.song, linux-kernel,
kyungsik.lee, stable, minchan, sergey.senozhatsky, linux-mm
On Fri, Apr 08, 2016 at 08:51:17PM +0100, Rui Salvaterra wrote:
>
> On 8 Apr 2016 17:50, "Greg KH" <gregkh@linuxfoundation.org> wrote:
> >
> > On Fri, Apr 08, 2016 at 04:23:24PM +0100, Rui Salvaterra wrote:
> > > Based on Sergey's test patch [1], this fixes zram with lz4 compression on
> big endian cpus. Tested on ppc64 with no regression on x86_64.
> >
> > Please wrap your text at 72 columns in a changelog comment.
> >
> > >
> > > [1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4
> > >
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
> >
> > Please attribute Sergey here in the signed-off-by area with a
> > "Suggested-by:" type mark
> >
> > > ---
> > >� lib/lz4/lz4defs.h | 29 +++++++++++++++--------------
> > >� 1 file changed, 15 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
> > > index abcecdc..a98c08c 100644
> > > --- a/lib/lz4/lz4defs.h
> > > +++ b/lib/lz4/lz4defs.h
> > > @@ -11,8 +11,7 @@
> > >� /*
> > >� �* Detects 64 bits mode
> > >� �*/
> > > -#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
> > > -� � �|| defined(__ppc64__) || defined(__LP64__))
> > > +#if defined(CONFIG_64BIT)
> >
> > This patch seems to do two different things, clean up the #if tests, and
> > change the endian of some calls.� Can you break this up into 2 different
> > patches?
> >
> > thanks,
> >
> > greg k-h
>
> Hi Greg,
>
> Thanks for the review (and patience). The 64-bit #if test is actually part of
> the fix, since __ppc64__ isn't defined anywhere and we'd fall into the 32-bit
> definitions for ppc64. I can send the other one separately, for sure. I'll do a
> v2 tomorrow.
Ah, well document that please, it was not obvious at all that this was
required.
thanks,
greg k-h-
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] lib: lz4: fixed zram with lz4 on big endian machines
@ 2016-04-08 20:05 ` Greg KH
0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2016-04-08 20:05 UTC (permalink / raw)
To: Rui Salvaterra
Cc: Chanho Min, Sergey Senozhatsky, eunb.song, linux-kernel,
kyungsik.lee, stable, minchan, sergey.senozhatsky, linux-mm
On Fri, Apr 08, 2016 at 08:51:17PM +0100, Rui Salvaterra wrote:
>
> On 8 Apr 2016 17:50, "Greg KH" <gregkh@linuxfoundation.org> wrote:
> >
> > On Fri, Apr 08, 2016 at 04:23:24PM +0100, Rui Salvaterra wrote:
> > > Based on Sergey's test patch [1], this fixes zram with lz4 compression on
> big endian cpus. Tested on ppc64 with no regression on x86_64.
> >
> > Please wrap your text at 72 columns in a changelog comment.
> >
> > >
> > > [1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4
> > >
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
> >
> > Please attribute Sergey here in the signed-off-by area with a
> > "Suggested-by:" type mark
> >
> > > ---
> > > lib/lz4/lz4defs.h | 29 +++++++++++++++--------------
> > > 1 file changed, 15 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
> > > index abcecdc..a98c08c 100644
> > > --- a/lib/lz4/lz4defs.h
> > > +++ b/lib/lz4/lz4defs.h
> > > @@ -11,8 +11,7 @@
> > > /*
> > > * Detects 64 bits mode
> > > */
> > > -#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
> > > - || defined(__ppc64__) || defined(__LP64__))
> > > +#if defined(CONFIG_64BIT)
> >
> > This patch seems to do two different things, clean up the #if tests, and
> > change the endian of some calls. Can you break this up into 2 different
> > patches?
> >
> > thanks,
> >
> > greg k-h
>
> Hi Greg,
>
> Thanks for the review (and patience). The 64-bit #if test is actually part of
> the fix, since __ppc64__ isn't defined anywhere and we'd fall into the 32-bit
> definitions for ppc64. I can send the other one separately, for sure. I'll do a
> v2 tomorrow.
Ah, well document that please, it was not obvious at all that this was
required.
thanks,
greg k-h-
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-04-08 20:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08 15:23 [PATCH] lib: lz4: fixed zram with lz4 on big endian machines Rui Salvaterra
2016-04-08 15:23 ` Rui Salvaterra
2016-04-08 16:50 ` Greg KH
2016-04-08 16:50 ` Greg KH
2016-04-08 19:51 ` Rui Salvaterra
2016-04-08 20:05 ` Greg KH
2016-04-08 20:05 ` Greg KH
2016-04-08 20:05 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.