Embedded Linux development
 help / color / mirror / Atom feed
* Re: [PATCH] detour TTY driver
From: Alan Cox @ 2010-05-29 22:54 UTC (permalink / raw)
  To: Samo Pogacnik; +Cc: linux-embedded, linux kernel, Randy Dunlap
In-Reply-To: <1275171436.2122.29.camel@itpsd6lap>

> Randy, Alan: Would you be so kind to comment on usability and
> acceptability of this tty driver approach? Thanks.

Not sure the naming is ideal (detour what where, simply calling it
'/dev/ttyprintk' might be clearer - but this is detail

> +void set_console_detour(void)
> +{
> +	console_detour = 1;
> +}
> +EXPORT_SYMBOL(set_console_detour);

module parameters can be set compiled in with modulename.option=foo so
there are easier ways to do that.

> + * Our simple preformatting:
> + * - every cr is replaced by '^'nl combination
> + * - every non cr or nl ended write is padded with '\'nl combination
> + * - adds a detour source tag in front of each line

This seems to make it more ambiguous


> +/*
> + *	Dummy tty ops open for succesfull terminal device open.
> + */
> +static int dty_open(struct tty_struct *tty, struct file *filp)
> +{
> +	return 0;

The kernel really expects posix behaviour but I'm not sure how much it
really matters in this case. Fixing that isn't hard though (use tty_port
helpers and basically no supporting functions)


> +	/* register our fops write function */
> +	tty_default_fops(&detour_fops);
> +	detour_fops.write = detour_write;

No. The behaviour of a tty is very precisely defined by the standards and
stomping over things you shouldn't is not good at all. Remember your tty
sets its own initial termios settings so you can set those to give the
initial behaviour you want. You need the tty layer here in your case
anyway as you don't have sufficient locking otherwise !

Also I'd provide a write_room method which always answers 'lots'

Do you need a recursion check. Suppose I open this device and capture
printk console messages to it ? Alternatively maybe you need an ioctl
handler to trap that case and reject it as a stupidity filter (or both ?)

> +	cdev_init(&dty_driver->cdev, &detour_fops);
> +
> +	/* create our unnumbered device */
> +	device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 3), NULL,
> +		dty_driver->name);

These need to check for failures.


> +static void initial_console_redirect(void)
> +{
> +	long ret;
> +
> +	/* re-register our fops write function */
> +	detour_fops.write = detour_write;
> +
> +	detour_file.f_dentry = &detour_dentry;
> +	detour_file.f_dentry->d_inode = &detour_inode;
> +	detour_file.f_op = &detour_fops;
> +	detour_file.f_mode |= FMODE_WRITE;
> +	security_file_alloc(&detour_file);
> +	INIT_LIST_HEAD(&detour_file.f_u.fu_list);
> +
> +	detour_inode.i_rdev = MKDEV(TTYAUX_MAJOR, 3);
> +	security_inode_alloc(&detour_inode);
> +	INIT_LIST_HEAD(&detour_inode.inotify_watches);
> +
> +	ret = detour_fops.open(&detour_inode, &detour_file);
> +	printk(KERN_INFO "detour_fops.open() returned %ld\n", ret);
> +	ret = detour_fops.unlocked_ioctl(&detour_file, TIOCCONS, 0);
> +	printk(KERN_INFO "detour_fops.ioctl() returned %ld\n", ret);
> +}

Bletch.. I'm really opposed to this kind of hackery. Fix your userspace a
tiny bit.

So
- Write only tty that uses printk: Looks good to me, implementation
  quibbles only
- Magic kernel hacks to shuffle things around in the initial console
  logic - hideous. I still really think you need to fix your userspace

^ permalink raw reply

* Re: [PATCH] detour TTY driver
From: Samo Pogacnik @ 2010-05-29 22:17 UTC (permalink / raw)
  To: linux-embedded; +Cc: linux kernel, Randy Dunlap, Alan Cox
In-Reply-To: <1273918658.2341.17.camel@itpsd6lap>

On Sat, 15 May 2010 12:17:00 +0200 Samo Pogacnik wrote:
> Hi,
> 
> Here is the initial suggestion for a simple detour TTY driver, which
> provides the ability to write user messages through printk. This allows
> user output to be inlined with kernel output. Together with printk
> time-stamping enabled, a detailed boot sequence analyses is possible.
> Additionally, console logs could have been stored through the same
> mechanism as kernel messages and does not require the system logger to
> be started very/too soon.
> 
Hi again,

This version of patch provides the ability to initially redirect console
to "detour TTY" (on driver initialization), if "detour" boot command
line option is set. 

best regards, Samo

p.s.
Randy, Alan: Would you be so kind to comment on usability and
acceptability of this tty driver approach? Thanks.

---
Signed-off-by: Samo Pogacnik <samo_pogacnik@t-2.net>
diff --git a_linux/Documentation/devices.txt b_linux/Documentation/devices.txt
index 53d64d3..f889097 100644
--- a_linux/Documentation/devices.txt
+++ b_linux/Documentation/devices.txt
@@ -239,6 +239,7 @@ Your cooperation is appreciated.
 		  0 = /dev/tty		Current TTY device
 		  1 = /dev/console	System console
 		  2 = /dev/ptmx		PTY master multiplex
+		  3 = /dev/detour	Detour via printk TTY device
 		 64 = /dev/cua0		Callout device for ttyS0
 		    ...
 		255 = /dev/cua191	Callout device for ttyS191
diff --git a_linux/Documentation/kernel-parameters.txt b_linux/Documentation/kernel-parameters.txt
index 839b21b..1fd9f09 100644
--- a_linux/Documentation/kernel-parameters.txt
+++ b_linux/Documentation/kernel-parameters.txt
@@ -623,6 +623,8 @@ and is between 256 and 4096 characters. It is defined in the file
 			Defaults to the default architecture's huge page size
 			if not specified.
 
+	detour		[KNL] Initial console redirect via detour tty.
+
 	dhash_entries=	[KNL]
 			Set number of hash buckets for dentry cache.
 
diff --git a_linux/drivers/char/Kconfig b_linux/drivers/char/Kconfig
index 3141dd3..f81781d 100644
--- a_linux/drivers/char/Kconfig
+++ b_linux/drivers/char/Kconfig
@@ -485,6 +485,21 @@ config LEGACY_PTY_COUNT
 	  When not in use, each legacy PTY occupies 12 bytes on 32-bit
 	  architectures and 24 bytes on 64-bit architectures.
 
+config DETOUR_TTY
+	bool "TTY driver to detour user output via printk"
+	default n
+	---help---
+	  If you say Y here, the support for writing user messages (i.e.
+	  console messages) via printk is available.
+
+	  The feature is useful to inline user messages with kernel
+	  messages.
+	  In order to use this feature, you should output user messages
+	  to /dev/detour. By setting boot command line option "detour",
+	  the console is initially redirected to detour TTY.
+
+	  If unsure, say N.
+
 config BRIQ_PANEL
 	tristate 'Total Impact briQ front panel driver'
 	depends on PPC_CHRP
diff --git a_linux/drivers/char/Makefile b_linux/drivers/char/Makefile
index f957edf..b84db55 100644
--- a_linux/drivers/char/Makefile
+++ b_linux/drivers/char/Makefile
@@ -11,6 +11,7 @@ obj-y	 += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o tty_buffer.o t
 
 obj-$(CONFIG_LEGACY_PTYS)	+= pty.o
 obj-$(CONFIG_UNIX98_PTYS)	+= pty.o
+obj-$(CONFIG_DETOUR_TTY)	+= dty.o
 obj-y				+= misc.o
 obj-$(CONFIG_VT)		+= vt_ioctl.o vc_screen.o selection.o keyboard.o
 obj-$(CONFIG_BFIN_JTAG_COMM)	+= bfin_jtag_comm.o
diff --git a_linux/drivers/char/dty.c b_linux/drivers/char/dty.c
new file mode 100644
index 0000000..4c9018f
--- /dev/null
+++ b_linux/drivers/char/dty.c
@@ -0,0 +1,183 @@
+/*
+ *  linux/drivers/char/detour.c
+ *
+ *  Copyright (C) 2010  Samo Pogacnik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the smems of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+/*
+ * This pseudo device allows user to make printk messages. It is possible
+ * to store "console" messages inline with kernel messages for better analyses
+ * of the boot process, for example.
+ */
+
+#include <linux/security.h>
+#include <linux/device.h>
+#include <linux/tty.h>
+
+static int console_detour;
+static struct tty_driver *dty_driver;
+
+/*
+ * Set console_detour to 1.
+ */
+void set_console_detour(void)
+{
+	console_detour = 1;
+}
+EXPORT_SYMBOL(set_console_detour);
+
+/*
+ * Our simple preformatting:
+ * - every cr is replaced by '^'nl combination
+ * - every non cr or nl ended write is padded with '\'nl combination
+ * - adds a detour source tag in front of each line
+ *
+ * This is useful for logging purposes (kind of a logging ldisc?).
+ */
+static const char *detour_tag = "[D] ";
+#define DETOUR_STR_SIZE 508
+
+static void detour_printk(const unsigned char *buf, int count)
+{
+	static char tmp[DETOUR_STR_SIZE + 4];
+	static int curr;
+	int i;
+
+	for (i = 0; i < count; i++) {
+		tmp[curr] = buf[i];
+		if (curr < DETOUR_STR_SIZE) {
+			switch (buf[i]) {
+			case '\r':
+				tmp[curr] = '^';
+				tmp[curr + 1] = '\n';
+				tmp[curr + 2] = '\0';
+				printk(KERN_INFO "%s%s", detour_tag, tmp);
+				curr = 0;
+				if (buf[i + 1] == '\n')
+					i++;
+				break;
+			case '\n':
+				tmp[curr + 1] = '\0';
+				printk(KERN_INFO "%s%s", detour_tag, tmp);
+				curr = 0;
+				break;
+			default:
+				curr++;
+			}
+		} else {
+			/* end of tmp buffer reached: cut the message in two */
+			tmp[curr + 1] = '\\';
+			tmp[curr + 2] = '\n';
+			tmp[curr + 3] = '\0';
+			printk(KERN_INFO "%s%s", detour_tag, tmp);
+			curr = 0;
+		}
+	}
+	if (curr > 0) {
+		/* non nl or cr terminated message */
+		tmp[curr + 0] = '\\';
+		tmp[curr + 1] = '\n';
+		tmp[curr + 2] = '\0';
+		printk(KERN_INFO "%s%s", detour_tag, tmp);
+		curr = 0;
+	}
+}
+
+/*
+ *	Dummy tty ops open for succesfull terminal device open.
+ */
+static int dty_open(struct tty_struct *tty, struct file *filp)
+{
+	return 0;
+}
+
+/*
+ *	File ops (not tty ops) write avoids ldisc inserting additional CRs.
+ *	We simply throw this to our preformatter, which calls printk.
+ */
+static ssize_t detour_write(struct file *file, const char __user *buf,
+	size_t count, loff_t *ppos)
+{
+	detour_printk(buf, count);
+	return count;
+}
+
+static const struct tty_operations dty_ops = {
+	.open = dty_open,
+};
+
+static struct file_operations detour_fops;
+static void initial_console_redirect(void);
+
+static int __init dty_init(void)
+{
+	dty_driver = alloc_tty_driver(1);
+	if (!dty_driver)
+		panic("Couldn't allocate pty driver");
+
+	dty_driver->owner = THIS_MODULE;
+	dty_driver->driver_name = "dty";
+	dty_driver->name = "detour";
+	dty_driver->major = TTYAUX_MAJOR;
+	dty_driver->minor_start = 3;
+	dty_driver->num = 1;
+	dty_driver->type = TTY_DRIVER_TYPE_CONSOLE;
+	dty_driver->init_termios = tty_std_termios;
+	dty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
+		TTY_DRIVER_DYNAMIC_DEV;
+	tty_set_operations(dty_driver, &dty_ops);
+
+	if (tty_register_driver(dty_driver))
+		panic("Couldn't register dty driver");
+
+	/* register our fops write function */
+	tty_default_fops(&detour_fops);
+	detour_fops.write = detour_write;
+
+	cdev_init(&dty_driver->cdev, &detour_fops);
+
+	/* create our unnumbered device */
+	device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 3), NULL,
+		dty_driver->name);
+
+	if (console_detour > 0)
+		initial_console_redirect();
+
+	return 0;
+}
+module_init(dty_init);
+
+/*
+ * Support for internal handling of console redirection via detour.
+ */
+static struct file detour_file;
+static struct inode detour_inode;
+static struct dentry detour_dentry;
+
+static void initial_console_redirect(void)
+{
+	long ret;
+
+	/* re-register our fops write function */
+	detour_fops.write = detour_write;
+
+	detour_file.f_dentry = &detour_dentry;
+	detour_file.f_dentry->d_inode = &detour_inode;
+	detour_file.f_op = &detour_fops;
+	detour_file.f_mode |= FMODE_WRITE;
+	security_file_alloc(&detour_file);
+	INIT_LIST_HEAD(&detour_file.f_u.fu_list);
+
+	detour_inode.i_rdev = MKDEV(TTYAUX_MAJOR, 3);
+	security_inode_alloc(&detour_inode);
+	INIT_LIST_HEAD(&detour_inode.inotify_watches);
+
+	ret = detour_fops.open(&detour_inode, &detour_file);
+	printk(KERN_INFO "detour_fops.open() returned %ld\n", ret);
+	ret = detour_fops.unlocked_ioctl(&detour_file, TIOCCONS, 0);
+	printk(KERN_INFO "detour_fops.ioctl() returned %ld\n", ret);
+}
diff --git a_linux/init/main.c b_linux/init/main.c
index 5c85402..be9dee9 100644
--- a_linux/init/main.c
+++ b_linux/init/main.c
@@ -263,6 +263,18 @@ static int __init loglevel(char *str)
 
 early_param("loglevel", loglevel);
 
+#ifdef CONFIG_DETOUR_TTY
+extern void set_console_detour(void);
+
+static int __init detour(char *str)
+{
+	set_console_detour();
+	return 0;
+}
+
+early_param("detour", detour);
+#endif
+
 /*
  * Unknown boot options get handed to init, unless they look like
  * unused parameters (modprobe will find them in /proc/cmdline).


^ permalink raw reply related

* Re: [PATCH 2/2] Squashfs-tools: add LZO support
From: Chan Jeong @ 2010-05-28  8:10 UTC (permalink / raw)
  To: 'kirk w', squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: 'Phillip Lougher', 'Gunho Lee',
	'Tim Bird', linux-embedded-u79uwXL29TY76Z2rM5mHXA,
	'Hyo Jun Im'
In-Reply-To: <000301cafae5$9da966a0$d8fc33e0$@jeong-Hm3cg6mZ9cc@public.gmane.org>

Hi,

Here are some figures for Squashfs file read time. The lzo1x-999 
would be better than lzo1x-1 in most cases and lzo1x-999 is also
used for lzo-compressed kernel.

Uncompressed size: 9.86 MiB

on a X86 PC (2.4GHz)
gzip       : 3.96 MiB 0.17s
lzo1x-1    : 5.25 MiB 0.10s
lzo1x-999  : 4.28 MiB 0.09s

on a MIPS board (403 MHz)
gzip       : 3.96 MiB 1.01s
lzo1x-1    : 5.25 MiB 1.17s
lzo1x-999  : 4.28 MiB 1.05s

The Squashfs-gzip is better than Squashfs-lzo1x-999 on my mips board
which has very poor NAND flash read performance.

Chan Jeong

-----Original Message-----
From: Chan Jeong [mailto:chan.jeong-Hm3cg6mZ9cc@public.gmane.org] 
Sent: Monday, May 24, 2010 11:06 AM
To: 'kirk w'; squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: 'Phillip Lougher'; 'Gunho Lee'; 'Tim Bird'; linux-embedded-u79uwXL29TasMV2rI37PzA@public.gmane.orgorg; 'Hyo Jun Im'
Subject: Re: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support

Hi,

Yes, you can try lzo1x-999 compression just with 2-line change.
The increased compression level, lzo1x-999, would be better than lzo1x-1
for slow I/O storage and higher CPU.

If you have any chance to share some test result like decompression 
time comparison, it would be nice.

Thanks,
Chan Jeong

--- lzo_wrapper.c.orig	2010-05-24 10:28:02.000000000 +0900
+++ lzo_wrapper.c	2010-05-24 10:41:23.000000000 +0900
@@ -43,7 +43,7 @@ int lzo_compress(void **strm, char *d, c
 			goto malloc_failed;
 
 		/* work memory */
-		if((buffers[0] = malloc(LZO1X_1_MEM_COMPRESS)) == NULL)
+		if((buffers[0] = malloc(LZO1X_999_MEM_COMPRESS)) == NULL)
 			goto malloc_failed;
 
 		/* temporal output buffer */
@@ -53,7 +53,7 @@ int lzo_compress(void **strm, char *d, c
 
 	wrkmem = buffers[0];
 	out = buffers[1];
-	res = lzo1x_1_compress((lzo_bytep)s, size, out, &outlen, wrkmem);
+	res = lzo1x_999_compress((lzo_bytep)s, size, out, &outlen, wrkmem);
 	if(res != LZO_E_OK) {
 		/*
 		 * All other errors return failure, with the compressor

-----Original Message-----
From: linux-embedded-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org [mailto:linux-embedded-owner@vger.kernel.org] On Behalf Of kirk w
Sent: Saturday, May 22, 2010 12:54 PM
To: squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org; Chan Jeong
Cc: 'Phillip Lougher'; 'Gunho Lee'; 'Tim Bird'; linux-embedded-u79uwXL29TasMV2rI37PzA@public.gmane.orgorg; 'Hyo Jun Im'
Subject: Re: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support

Hi,

Thanks for the patches. Is there a way to increase the compression level? Right now my file system compressed with zlib is 176MB and
with this patch using lzo it's 232MB. I've read that lzo's compression level can be increased to near zlib levels, but compression
times suffer. Compression times don't matter to me, but increased decompression speed is intriguing.   

Thanks again,

Kirk

--- On Tue, 5/18/10, Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org> wrote:

> From: Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
> Subject: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
> To: squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Cc: "'Phillip Lougher'" <phillip-cnXvMjJKhjYG2Il/BtU0GPXRex20P6io@public.gmane.org>, "'Gunho Lee'" <gunho.lee-Hm3cg6mZ9cc@public.gmane.org>, "'Tim Bird'" <tim.bird-mEdOJwZ7QcZBDgjK7y7TUQ@public.gmane.org>,
linux-embedded-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "'Hyo Jun Im'" <hyojun.im-Hm3cg6mZ9cc@public.gmane.org>
> Date: Tuesday, May 18, 2010, 12:05 AM
> This patch adds LZO compression and
> decompression to Squashfs tools.
> 
> The patch is against the latest cvs version and requires
> the LZO library
> from http://www.oberhumer.com/opensource/lzo.
> 
> Signed-off-by: Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
> ---
>  Makefile      |   20
> +++++++++++
>  compressor.c  |    7 ++++
>  lzo_wrapper.c |   99
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  squashfs_fs.h |    1 
>  4 files changed, 127 insertions(+)
> 
> diff -uprN -x .cvs squashfs-tools.cvs.orig/Makefile
> squashfs-tools.cvs/Makefile
> --- squashfs-tools.cvs.orig/Makefile   
> 2010-05-13 02:17:06.000000000 +0900
> +++ squashfs-tools.cvs/Makefile   
> 2010-05-18 11:36:58.000000000 +0900
> @@ -15,6 +15,18 @@
>  #LZMA_SUPPORT = 1
>  #LZMA_DIR = ../../../LZMA/lzma465
>  
> +#
> +# Building LZO support
> +#
> +# The LZO library (http://www.oberhumer.com/opensource/lzo/)
> is supported.
> +#
> +# To build using the LZO library (2.0.3 used in
> development, other versions may
> +# work) - download, unpack, build and install it,
> uncomment and set LZO_DIR to
> +# installed directory prefix, and uncomment the
> LZO_SUPPORT line below.
> +
> +#LZO_SUPPORT = 1
> +#LZO_DIR = /usr/local
> +
>  #Compression default.
>  COMP_DEFAULT = gzip
>  
> @@ -47,6 +59,14 @@ UNSQUASHFS_OBJS += xz_wrapper.o
>  LIBS += -llzma
>  endif
>  
> +ifdef LZO_SUPPORT
> +CFLAGS += -DLZO_SUPPORT
> +INCLUDEDIR += -I$(LZO_DIR)/include
> +MKSQUASHFS_OBJS += lzo_wrapper.o
> +UNSQUASHFS_OBJS += lzo_wrapper.o
> +LIBS += -L$(LZO_DIR)/lib -llzo2
> +endif
> +
>  .PHONY: all
>  all: mksquashfs unsquashfs
>  
> diff -uprN -x .cvs squashfs-tools.cvs.orig/compressor.c
> squashfs-tools.cvs/compressor.c
> --- squashfs-tools.cvs.orig/compressor.c   
> 2009-08-29 10:05:34.000000000 +0900
> +++ squashfs-tools.cvs/compressor.c   
> 2010-05-18 11:37:46.000000000 +0900
> @@ -29,6 +29,8 @@ extern int gzip_compress(void **, char *
>  extern int gzip_uncompress(char *, char *, int, int, int
> *);
>  extern int lzma_compress(void **, char *, char *, int,
> int, int *);
>  extern int lzma_uncompress(char *, char *, int, int, int
> *);
> +extern int lzo_compress(void **, char *, char *, int, int,
> int *);
> +extern int lzo_uncompress(char *, char *, int, int, int
> *);
>  
>  struct compressor compressor[] = {
>      { gzip_compress, gzip_uncompress,
> ZLIB_COMPRESSION, "gzip", 1 },
> @@ -37,6 +39,11 @@ struct compressor compressor[] = {
>  #else
>      { NULL, NULL, LZMA_COMPRESSION, "lzma",
> 0 },
>  #endif
> +#ifdef LZO_SUPPORT
> +    { lzo_compress, lzo_uncompress,
> LZO_COMPRESSION, "lzo", 1 },
> +#else
> +    { NULL, NULL, LZO_COMPRESSION, "lzo", 0
> },
> +#endif
>      { NULL, NULL , 0, "unknown", 0}
>  };
>  
> diff -uprN -x .cvs squashfs-tools.cvs.orig/lzo_wrapper.c
> squashfs-tools.cvs/lzo_wrapper.c
> --- squashfs-tools.cvs.orig/lzo_wrapper.c   
> 1970-01-01 09:00:00.000000000 +0900
> +++ squashfs-tools.cvs/lzo_wrapper.c   
> 2010-05-18 11:59:30.000000000 +0900
> @@ -0,0 +1,99 @@
> +/*
> + * Copyright (c) 2010 LG Electronics
> + * Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
> + *
> + * This program is free software; you can redistribute it
> and/or
> + * modify it under the terms of the GNU General Public
> License
> + * as published by the Free Software Foundation; either
> version 2,
> + * or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be
> useful,
> + * but WITHOUT ANY WARRANTY; without even the implied
> warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General
> Public License
> + * along with this program; if not, write to the Free
> Software
> + * Foundation, 59 Temple Place - Suite 330, Boston, MA
> 02111-1307, USA.
> + *
> + * lzo_wrapper.c
> + */
> +
> +#include <stdlib.h>
> +#include <string.h>
> +
> +#include <lzo/lzoconf.h>
> +#include <lzo/lzo1x.h>
> +
> +/* worst-case expansion calculation during compression,
> +   see LZO FAQ for more information */
> +#define LZO_OUTPUT_BUFFER_SIZE(size)   
> (size + (size/16) + 64 + 3)
> +
> +int lzo_compress(void **strm, char *d, char *s, int size,
> int block_size,
> +        int *error)
> +{
> +    int res = 0;
> +    lzo_bytep out;
> +    lzo_uint outlen;
> +    lzo_voidp wrkmem;
> +    void **buffers = (void **)*strm;
> +
> +    if(buffers == NULL) {
> +        if((buffers = *strm
> = calloc(2, sizeof(void *))) == NULL)
> +           
> goto malloc_failed;
> +
> +        /* work memory */
> +        if((buffers[0] =
> malloc(LZO1X_1_MEM_COMPRESS)) == NULL)
> +           
> goto malloc_failed;
> +
> +        /* temporal output
> buffer */
> +        if((buffers[1] =
> malloc(LZO_OUTPUT_BUFFER_SIZE(block_size))) == NULL)
> +           
> goto malloc_failed;
> +    }
> +
> +    wrkmem = buffers[0];
> +    out = buffers[1];
> +    res = lzo1x_1_compress((lzo_bytep)s,
> size, out, &outlen, wrkmem);
> +    if(res != LZO_E_OK) {
> +        /*
> +         * All
> other errors return failure, with the compressor
> +         *
> specific error code in *error
> +         */
> +        *error = res;
> +        return -1;
> +    }
> +
> +    if(outlen >= size) {
> +        /*
> +         * Output
> buffer overflow. Return out of buffer space
> +         */
> +        return 0;
> +    }
> +
> +    /*
> +     * Success, return the
> compressed size.
> +     */
> +    memcpy(d, out, outlen);
> +    return outlen;
> +
> +malloc_failed:
> +    if(buffers) {
> +        if(buffers[0]) {
> +           
> free(buffers[0]);
> +        }
> +        free(buffers);
> +    }
> +    return -1;
> +}
> +
> +
> +int lzo_uncompress(char *d, char *s, int size, int
> block_size, int *error)
> +{
> +    int res;
> +    lzo_uint bytes = block_size;
> +    
> +    res = lzo1x_decompress((lzo_bytep)s,
> size, (lzo_bytep)d, &bytes, NULL);
> +
> +    *error = res;
> +    return res == LZO_E_OK ? bytes : -1;
> +}
> diff -uprN -x .cvs squashfs-tools.cvs.orig/squashfs_fs.h
> squashfs-tools.cvs/squashfs_fs.h
> --- squashfs-tools.cvs.orig/squashfs_fs.h   
> 2010-05-13 04:28:38.000000000 +0900
> +++ squashfs-tools.cvs/squashfs_fs.h   
> 2010-05-18 11:43:22.000000000 +0900
> @@ -238,6 +238,7 @@ typedef long long   
>     squashfs_inode_t;
>  
>  #define ZLIB_COMPRESSION    1
>  #define LZMA_COMPRESSION    2
> +#define LZO_COMPRESSION   
>     3
>  
>  struct squashfs_super_block {
>      unsigned int   
>     s_magic;
> 
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Squashfs-devel mailing list
> Squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/squashfs-devel
> 


      

--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


------------------------------------------------------------------------------

_______________________________________________
Squashfs-devel mailing list
Squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/squashfs-devel


------------------------------------------------------------------------------

^ permalink raw reply

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Ming Lei @ 2010-05-24 15:19 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-kernel, linux-embedded, linux-arm-kernel, a.p.zijlstra
In-Reply-To: <20100524144539.GE21117@n2100.arm.linux.org.uk>

2010/5/24 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> which needs to be redone with a little more understanding, like the
> following patch.  Note: you will need the previous patch as well,
> which is separate because it addresses a *different* issue.

OK, the two patches do fix the 'unannotated irqs-on' lockdep warning.

Thanks,

-- 
Lei Ming

^ permalink raw reply

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Russell King - ARM Linux @ 2010-05-24 14:45 UTC (permalink / raw)
  To: Ming Lei; +Cc: linux-kernel, linux-embedded, linux-arm-kernel, a.p.zijlstra
In-Reply-To: <20100524222033.12b25f2a@tom-lei>

On Mon, May 24, 2010 at 10:20:33PM +0800, Ming Lei wrote:
> On Mon, 24 May 2010 11:14:16 +0100
> Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> 
> > Right, I see what the problem is now - it's all to do with threads
> > created with kernel_thread() confusing lockdep.
> > 
> > I'm of the opinion that all your changes in entry*.S are the wrong
> > way to fix this - not only does it add additional overhead where
> > none is really necessary, it adds additional complexity.
> > 
> > So, here's a patch to solve the warning you quoted.
> 
> No, your patch does not fix the issue, I still can see the lockdep
> warning after applying it against Linux 2.6.34-next-20100524.

No, my patch fixes the issue you raised in the dump.  This is a new
lockdep issue which is unrelated to the first dump.

What's wrong is:

commit 0d928b0b616d1c5c5fe76019a87cba171ca91633
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Thu Aug 13 20:38:17 2009 +0200

    Complete irq tracing support for ARM

    Before this patch enabling and disabling irqs in assembler code and by
    the hardware wasn't tracked completly.

    I had to transpose two instructions in arch/arm/lib/bitops.h because
    restore_irqs doesn't preserve the flags with CONFIG_TRACE_IRQFLAGS=y

    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Cc: Russell King <linux@arm.linux.org.uk>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Ingo Molnar <mingo@redhat.com>

    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

which needs to be redone with a little more understanding, like the
following patch.  Note: you will need the previous patch as well,
which is separate because it addresses a *different* issue.

diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 7ee48e7..3fd7861 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -162,8 +162,6 @@ ENDPROC(__und_invalid)
 	@  r4 - orig_r0 (see pt_regs definition in ptrace.h)
 	@
 	stmia	r5, {r0 - r4}
-
-	asm_trace_hardirqs_off
 	.endm
 
 	.align	5
@@ -204,7 +202,7 @@ __dabt_svc:
 	@
 	@ IRQs off again before pulling preserved data off the stack
 	@
-	disable_irq
+	disable_irq_notrace
 
 	@
 	@ restore SPSR and restart the instruction
@@ -218,6 +216,9 @@ ENDPROC(__dabt_svc)
 __irq_svc:
 	svc_entry
 
+#ifdef CONFIG_TRACE_IRQFLAGS
+	bl	trace_hardirqs_off
+#endif
 #ifdef CONFIG_PREEMPT
 	get_thread_info tsk
 	ldr	r8, [tsk, #TI_PREEMPT]		@ get preempt count
@@ -291,7 +292,7 @@ __und_svc:
 	@
 	@ IRQs off again before pulling preserved data off the stack
 	@
-1:	disable_irq
+1:	disable_irq_notrace
 
 	@
 	@ restore SPSR and restart the instruction
@@ -327,7 +328,7 @@ __pabt_svc:
 	@
 	@ IRQs off again before pulling preserved data off the stack
 	@
-	disable_irq
+	disable_irq_notrace
 
 	@
 	@ restore SPSR and restart the instruction
@@ -393,8 +394,6 @@ ENDPROC(__pabt_svc)
 	@ Clear FP to mark the first stack frame
 	@
 	zero_fp
-
-	asm_trace_hardirqs_off
 	.endm
 
 	.macro	kuser_cmpxchg_check
@@ -465,9 +464,6 @@ __irq_usr:
  THUMB(	movne	r0, #0		)
  THUMB(	strne	r0, [r0]	)
 #endif
-#ifdef CONFIG_TRACE_IRQFLAGS
-	bl	trace_hardirqs_on
-#endif
 
 	mov	why, #0
 	b	ret_to_user

^ permalink raw reply related

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Ming Lei @ 2010-05-24 14:20 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-kernel, linux-embedded, linux-arm-kernel, a.p.zijlstra
In-Reply-To: <20100524101416.GA21117@n2100.arm.linux.org.uk>

On Mon, 24 May 2010 11:14:16 +0100
Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:

> Right, I see what the problem is now - it's all to do with threads
> created with kernel_thread() confusing lockdep.
> 
> I'm of the opinion that all your changes in entry*.S are the wrong
> way to fix this - not only does it add additional overhead where
> none is really necessary, it adds additional complexity.
> 
> So, here's a patch to solve the warning you quoted.

No, your patch does not fix the issue, I still can see the lockdep
warning after applying it against Linux 2.6.34-next-20100524.

Follows the dmesg info:

Texas Instruments X-Loader 1.4.4ss (Apr 13 2010 - 22:36:28)
Beagle Rev C4
Reading boot sector
Loading u-boot.bin from mmc


U-Boot 2010.03 (May 04 2010 - 08:48:31)

OMAP3530-GP ES3.1, CPU-OPP2, L3-165MHz, Max clock-720Mhz
OMAP3 Beagle board + LPDDR/NAND
I2C:   ready
DRAM:  256 MB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial

Probing for expansion boards, if none are connected you'll see a harmless I2C error.

timed out in wait_for_pin: I2C_STAT=0
I2C read: I/O error
Unrecognized expansion board: 0
Beagle Rev C4
Die ID #16c00004000000000403730515017007
Hit any key to stop autoboot:  3 \b\b\b 2 \b\b\b 1 \b\b\b 0 
OMAP3 beagleboard.org # prit\b \bntenv
baudrate=115200
loadaddr=0x80200000
rdaddr=0x81600000
console=ttyS2,115200n8
optargs=
mmcargs=setenv bootargs console=${console} ${optargs} root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait
ramargs=setenv bootargs console=${console} ${optargs} root=/dev/ram0 rw ramdisk_size=32768 initrd=${rdaddr},32M
ubifsargs=setenv bootargs console=${console} ${optargs} root=ubi0:beagleroot ubi.mtd=4 rw rootfstype=ubifs
jffs2args=setenv bootargs console=${console} ${optargs} root=/dev/mtdblock4 rw rootfstype=jffs2
loadbootscript=fatload mmc 0 ${loadaddr} boot.scr
bootscript=echo Running bootscript from mmc ...; autoscr ${loadaddr}
loadramdisk=fatload mmc 0 ${rdaddr} ramdisk.gz
ramboot=echo Booting from ramdisk.gz ...; run ramargs; bootm ${loadaddr}
mmcboot=echo Booting from mmc ...; run mmcargs; bootm ${loadaddr}
nandboot=echo Booting from nand ...; run jffs2args; nand read ${loadaddr} 280000 400000; bootm ${loadaddr}
usbtty=cdc_acm
stdout=serial,usbtty
stdin=serial,usbtty
stderr=serial,usbtty
serial=16c00004000000000403730515017007
dieid#=16c00004000000000403730515017007
restore_c41=mmc init;fatload mmc 0 82000000 MLO;nand unlock;nandecc hw;nand erase 0 80000;nand write 82000000 0 20000;nand write 82000000 20000 20000;nand write 82000000 40000 20000;nand write 82000000 60000 20000
restore_c42=fatload mmc 0 0x80200000 u-boot.bin;nand unlock;nandecc sw;nand erase 80000 160000;nand write 0x80200000 80000 160000
mtdids=nand0=nand
bootcmd=mmc init;run loaduimage;run mmcboot
restore_fac=if mmc init; then if run loadbootscript; then run bootscript; else if run loaduimage; then if run loadramdisk;then run ramboot; else run mmcboot; fi; else run nandboot; fi; fi; else run nandboot; fi
loaduimage=fatload mmc 0 ${loadaddr} uImage
bootdelay=3
buddy=unknown
mpurate=720

Environment size: 1771/131068 bytes
OMAP3 beagleboard.org # setenv loaduimage 'fatload mmc 0 ${loadaddr} uImage-next'
OMAP3 beagleboard.org # run bootcmd
mmc1 is available
reading uImage-next

2707936 bytes read
Booting from mmc ...
## Booting kernel from Legacy Image at 80200000 ...
   Image Name:   Linux-2.6.34-next-20100524+
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2707872 Bytes =  2.6 MB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.000000] Linux version 2.6.34-next-20100524+ (tom@tom-lei) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #56 PREEMPT Mon May 24 21:56:03 CST 2010
[    0.000000] CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), cr=10c53c7f
[    0.000000] CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] Machine: OMAP3 Beagle Board
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] OMAP3430/3530 ES3.1 (l2cache iva sgx neon isp )
[    0.000000] SRAM: Mapped pa 0x40200000 to va 0xfe400000 size: 0x100000
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 65024
[    0.000000] Kernel command line: console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait
[    0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Memory: 128MB 128MB = 256MB total
[    0.000000] Memory: 245020k/245020k available, 17124k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
[    0.000000]     vmalloc : 0xd0800000 - 0xf8000000   ( 632 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xd0000000   ( 256 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .init : 0xc0008000 - 0xc0039000   ( 196 kB)
[    0.000000]       .text : 0xc0039000 - 0xc050d000   (4944 kB)
[    0.000000]       .data : 0xc0564000 - 0xc0717ab0   (1743 kB)
[    0.000000] Hierarchical RCU implementation.
[    0.000000] 	Verbose stalled-CPUs detection is disabled.
[    0.000000] NR_IRQS:402
[    0.000000] Clocking rate (Crystal/Core/MPU): 26.0/332/500 MHz
[    0.000000] omap_hwmod: l3_hwmod: cannot be enabled (3)
[    0.000000] omap_hwmod: l4_core_hwmod: cannot be enabled (3)
[    0.000000] omap_hwmod: l4_per_hwmod: cannot be enabled (3)
[    0.000000] omap_hwmod: l4_wkup_hwmod: cannot be enabled (3)
[    0.000000] Reprogramming SDRC clock to 332000000 Hz
[    0.000000] GPMC revision 5.0
[    0.000000] IRQ: Found an INTC at 0xfa200000 (revision 4.0) with 96 interrupts
[    0.000000] Total of 96 interrupts on 1 active controller
[    0.000000] OMAP GPIO hardware version 2.5
[    0.000000] OMAP clockevent source: GPTIMER12 at 32768 Hz
[    0.000000] Console: colour dummy device 80x30
[    0.000000] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.000000] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.000000] ... MAX_LOCK_DEPTH:          48
[    0.000000] ... MAX_LOCKDEP_KEYS:        8191
[    0.000000] ... CLASSHASH_SIZE:          4096
[    0.000000] ... MAX_LOCKDEP_ENTRIES:     16384
[    0.000000] ... MAX_LOCKDEP_CHAINS:      32768
[    0.000000] ... CHAINHASH_SIZE:          16384
[    0.000000]  memory used by lock dependency info: 3951 kB
[    0.000000]  per task-struct memory footprint: 2304 bytes
[    0.000000] ------------------------
[    0.000000] | Locking API testsuite:
[    0.000000] ----------------------------------------------------------------------------
[    0.000000]                                  | spin |wlock |rlock |mutex | wsem | rsem |
[    0.000000]   --------------------------------------------------------------------------
[    0.000000]                      A-A deadlock:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]                  A-B-B-A deadlock:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]              A-B-B-C-C-A deadlock:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]              A-B-C-A-B-C deadlock:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]          A-B-B-C-C-D-D-A deadlock:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]          A-B-C-D-B-D-D-A deadlock:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]          A-B-C-D-B-C-D-A deadlock:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]                     double unlock:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]                   initialize held:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]                  bad unlock order:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
[    0.000000]   --------------------------------------------------------------------------
[    0.000000]               recursive read-lock:             |  ok  |             |  ok  |
[    0.000000]            recursive read-lock #2:             |  ok  |             |  ok  |
[    0.000000]             mixed read-write-lock:             |  ok  |             |  ok  |
[    0.000000]             mixed write-read-lock:             |  ok  |             |  ok  |
[    0.000000]   --------------------------------------------------------------------------
[    0.000000]      hard-irqs-on + irq-safe-A/12:  ok  |  ok  |  ok  |
[    0.000000]      soft-irqs-on + irq-safe-A/12:  ok  |  ok  |  ok  |
[    0.000000]      hard-irqs-on + irq-safe-A/21:  ok  |  ok  |  ok  |
[    0.000000]      soft-irqs-on + irq-safe-A/21:  ok  |  ok  |  ok  |
[    0.000000]        sirq-safe-A => hirqs-on/12:  ok  |  ok  |  ok  |
[    0.000000]        sirq-safe-A => hirqs-on/21:  ok  |  ok  |  ok  |
[    0.000000]          hard-safe-A + irqs-on/12:  ok  |  ok  |  ok  |
[    0.000000]          soft-safe-A + irqs-on/12:  ok  |  ok  |  ok  |
[    0.000000]          hard-safe-A + irqs-on/21:  ok  |  ok  |  ok  |
[    0.000000]          soft-safe-A + irqs-on/21:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #1/123:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #1/123:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #1/132:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #1/132:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #1/213:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #1/213:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #1/231:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #1/231:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #1/312:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #1/312:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #1/321:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #1/321:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #2/123:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #2/123:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #2/132:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #2/132:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #2/213:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #2/213:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #2/231:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #2/231:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #2/312:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #2/312:  ok  |  ok  |  ok  |
[    0.000000]     hard-safe-A + unsafe-B #2/321:  ok  |  ok  |  ok  |
[    0.000000]     soft-safe-A + unsafe-B #2/321:  ok  |  ok  |  ok  |
[    0.000000]       hard-irq lock-inversion/123:  ok  |  ok  |  ok  |
[    0.000000]       soft-irq lock-inversion/123:  ok  |  ok  |  ok  |
[    0.000000]       hard-irq lock-inversion/132:  ok  |  ok  |  ok  |
[    0.000000]       soft-irq lock-inversion/132:  ok  |  ok  |  ok  |
[    0.000000]       hard-irq lock-inversion/213:  ok  |  ok  |  ok  |
[    0.000000]       soft-irq lock-inversion/213:  ok  |  ok  |  ok  |
[    0.000000]       hard-irq lock-inversion/231:  ok  |  ok  |  ok  |
[    0.000000]       soft-irq lock-inversion/231:  ok  |  ok  |  ok  |
[    0.000000]       hard-irq lock-inversion/312:  ok  |  ok  |  ok  |
[    0.000000]       soft-irq lock-inversion/312:  ok  |  ok  |  ok  |
[    0.000000]       hard-irq lock-inversion/321:  ok  |  ok  |  ok  |
[    0.000000]       soft-irq lock-inversion/321:  ok  |  ok  |  ok  |
[    0.000000]       hard-irq read-recursion/123:  ok  |
[    0.000000]       soft-irq read-recursion/123:  ok  |
[    0.000000]       hard-irq read-recursion/132:  ok  |
[    0.000000]       soft-irq read-recursion/132:  ok  |
[    0.000000]       hard-irq read-recursion/213:  ok  |
[    0.000000]       soft-irq read-recursion/213:  ok  |
[    0.000000]       hard-irq read-recursion/231:  ok  |
[    0.000000]       soft-irq read-recursion/231:  ok  |
[    0.000000]       hard-irq read-recursion/312:  ok  |
[    0.000000]       soft-irq read-recursion/312:  ok  |
[    0.000000]       hard-irq read-recursion/321:  ok  |
[    0.000000]       soft-irq read-recursion/321:  ok  |
[    0.000000] -------------------------------------------------------
[    0.000000] Good, all 218 testcases passed! |
[    0.000000] ---------------------------------
[    0.000000] Calibrating delay loop... 497.82 BogoMIPS (lpj=1941504)
[    0.000000] Mount-cache hash table entries: 512
[    0.000000] CPU: Testing write buffer coherency: ok
[    0.000000] devtmpfs: initialized
[    0.000000] regulator: core version 0.5
[    0.000000] NET: Registered protocol family 16
[    0.000000] Found NAND on CS0
[    0.000000] Registering NAND on CS0
[    0.000000] Unable to get DVI reset GPIO
[    0.000000] hw perfevents: enabled with ARMv7 Cortex-A8 PMU driver, 5 counters available
[    0.000274] OMAP DMA hardware revision 4.0
[    0.415679] bio: create slab <bio-0> at 0
[    0.469024] SCSI subsystem initialized
[    0.482971] usbcore: registered new interface driver usbfs
[    0.490814] usbcore: registered new interface driver hub
[    0.495025] usbcore: registered new device driver usb
[    0.505828] i2c_omap i2c_omap.1: bus 1 rev3.12 at 2600 kHz
[    0.552673] twl4030: PIH (irq 7) chaining IRQs 368..375
[    0.553161] twl4030: power (irq 373) chaining IRQs 376..383
[    0.561676] twl4030: gpio (irq 368) chaining IRQs 384..401
[    0.588470] regulator: VUSB1V5: 1500 mV normal standby
[    0.602264] regulator: VUSB1V8: 1800 mV normal standby
[    0.615051] regulator: VUSB3V1: 3100 mV normal standby
[    0.644683] twl4030_usb twl4030_usb: Initialized TWL4030 USB module
[    0.662658] regulator: VMMC1: 1850 <--> 3150 mV at 3000 mV normal standby
[    0.675537] regulator: VDAC: 1800 mV normal standby
[    0.689483] regulator: VDVI: 1800 mV normal standby
[    0.706085] regulator: VSIM: 1800 <--> 3000 mV at 1800 mV normal standby
[    0.709747] i2c_omap i2c_omap.3: bus 3 rev3.12 at 100 kHz
[    0.736755] Advanced Linux Sound Architecture Driver Version 1.0.23.
[    0.757629] Switching to clocksource 32k_counter
[    1.133636] musb_hdrc: version 6.0, musb-dma, otg (peripheral+host), debug=0
[    1.139038] musb_hdrc musb_hdrc: USB OTG mode controller at fa0ab000 using DMA, IRQ 92
[    1.147277] NET: Registered protocol family 2
[    1.150573] IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
[    1.159820] TCP established hash table entries: 8192 (order: 4, 65536 bytes)
[    1.160766] TCP bind hash table entries: 8192 (order: 6, 327680 bytes)
[    1.169006] TCP: Hash tables configured (established 8192 bind 8192)
[    1.169189] TCP reno registered
[    1.169311] UDP hash table entries: 128 (order: 1, 12288 bytes)
[    1.170135] UDP-Lite hash table entries: 128 (order: 1, 12288 bytes)
[    1.175537] NET: Registered protocol family 1
[    1.183532] RPC: Registered udp transport module.
[    1.183563] RPC: Registered tcp transport module.
[    1.183624] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    1.196899] PMU: registered new PMU device of type 0
[    1.200012] NetWinder Floating Point Emulator V0.97 (double precision)
[    1.231811] VFS: Disk quotas dquot_6.5.2
[    1.232421] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    1.256347] JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[    1.261993] msgmni has been set to 478
[    1.278167] alg: No test for stdrng (krng)
[    1.279144] io scheduler noop registered
[    1.279174] io scheduler deadline registered
[    1.280242] io scheduler cfq registered (default)
[    1.352478] OMAP DSS rev 2.0
[    1.353668] OMAP DISPC rev 3.0
[    1.354309] OMAP VENC rev 2
[    1.954925] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    2.023956] serial8250.0: ttyS0 at MMIO 0x4806a000 (irq = 72) is a ST16654
[    2.058380] serial8250.1: ttyS1 at MMIO 0x4806c000 (irq = 73) is a ST16654
[    2.093322] serial8250.2: ttyS2 at MMIO 0x49020000 (irq = 74) is a ST16654
[    3.225219] console [ttyS2] enabled
[    3.494750] brd: module loaded
[    3.627441] loop: module loaded
[    3.684173] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    3.692993] ehci-omap ehci-omap.0: OMAP-EHCI Host Controller
[    3.715576] ehci-omap ehci-omap.0: new USB bus registered, assigned bus number 1
[    3.726104] ehci-omap ehci-omap.0: irq 77, io mem 0x48064800
[    3.742553] ehci-omap ehci-omap.0: USB 2.0 started, EHCI 1.00
[    3.753845] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    3.760864] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    3.768249] usb usb1: Product: OMAP-EHCI Host Controller
[    3.773742] usb usb1: Manufacturer: Linux 2.6.34-next-20100524+ ehci_hcd
[    3.780517] usb usb1: SerialNumber: ehci-omap.0
[    3.811676] hub 1-0:1.0: USB hub found
[    3.817016] hub 1-0:1.0: 3 ports detected
[    3.870391] i2c /dev entries driver
[    3.901184] IR NEC protocol handler initialized
[    3.905792] IR RC5(x) protocol handler initialized
[    3.911102] IR RC6 protocol handler initialized
[    3.915832] IR JVC protocol handler initialized
[    3.920410] IR Sony protocol handler initialized
[    3.925659] Linux video capture interface: v2.00
[    3.939971] cpuidle: using governor ladder
[    3.944122] cpuidle: using governor menu
[    4.089355] No device for DAI omap-mcbsp-dai-0
[    4.094024] No device for DAI omap-mcbsp-dai-1
[    4.098541] No device for DAI omap-mcbsp-dai-2
[    4.103179] No device for DAI omap-mcbsp-dai-3
[    4.107666] No device for DAI omap-mcbsp-dai-4
[    4.112335] OMAP3 Beagle/Devkit8000 SoC init
[    4.133605] asoc: twl4030 <-> omap-mcbsp-dai-0 mapping ok
[    4.237731] ALSA device list:
[    4.240722]   #0: omap3beagle (twl4030)
[    4.246368] TCP cubic registered
[    4.249664] NET: Registered protocol family 17
[    4.256347] NET: Registered protocol family 15
[    4.263702] Power Management for TI OMAP3.
[    4.518066] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 1
[    4.527282] mmc0: new SD card at address 0001
[    4.546081] mmcblk0: mmc0:0001 064MB 118 MiB 
[    4.559875]  mmcblk0:
[    4.569396]  p1 p2
[    4.609100] kmemleak: Kernel memory leak detector initialized
[    4.616729] omapfb omapfb: no driver for display
[    4.621643] omapfb omapfb: failed to setup omapfb
[    4.628204] kmemleak: Automatic memory scanning thread started
[    4.654388] regulator_init_complete: incomplete constraints, leaving VDVI on
[    4.662261] regulator_init_complete: incomplete constraints, leaving VDAC on
[    4.670959] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    4.715393] EXT3-fs: barriers not enabled
[    4.932281] EXT3-fs (mmcblk0p2): warning: mounting unchecked fs, running e2fsck is recommended
[    4.941253] kjournald starting.  Commit interval 5 seconds
[    4.956970] EXT3-fs (mmcblk0p2): using internal journal
[    4.962463] EXT3-fs (mmcblk0p2): recovery complete
[    4.978637] EXT3-fs (mmcblk0p2): mounted filesystem with writeback data mode
[    4.986999] VFS: Mounted root (ext3 filesystem) on device 179:2.
[    5.001312] devtmpfs: mounted
[    5.004943] Freeing init memory: 196K
[    5.093475] ------------[ cut here ]------------
[    5.098205] WARNING: at kernel/lockdep.c:3163 check_flags+0xcc/0x1dc()
[    5.104766] Modules linked in:
[    5.107910] [<c0040130>] (unwind_backtrace+0x0/0xf8) from [<c03d29cc>] (dump_stack+0x20/0x24)
[    5.116546] [<c03d29cc>] (dump_stack+0x20/0x24) from [<c006fce0>] (warn_slowpath_common+0x5c/0x74)
[    5.125579] [<c006fce0>] (warn_slowpath_common+0x5c/0x74) from [<c006fd24>] (warn_slowpath_null+0x2c/0x34)
[    5.135314] [<c006fd24>] (warn_slowpath_null+0x2c/0x34) from [<c009e840>] (check_flags+0xcc/0x1dc)
[    5.144378] [<c009e840>] (check_flags+0xcc/0x1dc) from [<c00a0b80>] (lockdep_trace_alloc+0x3c/0xfc)
[    5.153503] [<c00a0b80>] (lockdep_trace_alloc+0x3c/0xfc) from [<c0103d98>] (__kmalloc+0x6c/0x1fc)
[    5.162475] [<c0103d98>] (__kmalloc+0x6c/0x1fc) from [<c014a8d8>] (load_elf_binary+0x8cc/0x125c)
[    5.171356] [<c014a8d8>] (load_elf_binary+0x8cc/0x125c) from [<c010e03c>] (search_binary_handler+0x168/0x35c)
[    5.181365] [<c010e03c>] (search_binary_handler+0x168/0x35c) from [<c010f654>] (do_execve+0x224/0x320)
[    5.190765] [<c010f654>] (do_execve+0x224/0x320) from [<c003d7d4>] (kernel_execve+0x48/0x90)
[    5.199279] [<c003d7d4>] (kernel_execve+0x48/0x90) from [<c0039588>] (run_init_process+0x24/0x2c)
[    5.208251] [<c0039588>] (run_init_process+0x24/0x2c) from [<c003962c>] (init_post+0x9c/0xe4)
[    5.216857] [<c003962c>] (init_post+0x9c/0xe4) from [<c0008684>] (kernel_init+0x128/0x168)
[    5.225189] [<c0008684>] (kernel_init+0x128/0x168) from [<c003b10c>] (kernel_thread_exit+0x0/0x8)
[    5.234130] ---[ end trace b9d526d4d7022271 ]---
[    5.238800] possible reason: unannotated irqs-on.
[    5.243530] irq event stamp: 340905
[    5.247070] hardirqs last  enabled at (340904): [<c03d67b0>] _raw_spin_unlock_irqrestore+0x4c/0x78
[    5.256134] hardirqs last disabled at (340905): [<c0039b24>] __dabt_svc+0x64/0x80
[    5.263702] softirqs last  enabled at (340499): [<c0076da8>] __do_softirq+0x218/0x234
[    5.271606] softirqs last disabled at (340466): [<c0076e2c>] irq_exit+0x68/0xbc
init started: BusyBox v1.9.0 (2008-02-26 15:40:22 IST)
starting pid 429, tty '': '/etc/init.d/rcS'

    OMAP3EVM (v0.90) : System initialization...

    Kernel release : Linux 2.6.34-next-20100524+
    Kernel version : #56 PREEMPT Mon May 24 21:56:03 CST 2010

 Mounting /proc             : [SUCCESS]
 Mounting /sys              : [SUCCESS]
 Mounting /dev/pts          : [SUCCESS]
 Enabling hot-plug          : [SUCCESS]
 Populating /dev            : mkdir: cannot create directory '/dev/snd': File exists
[    6.570556] hub 1-0:1.0: __pm_runtime_suspend() from workqueue!
[    6.576568] hub 1-0:1.0: __pm_runtime_suspend() returns 0!
[    6.593933] usb usb1: __pm_runtime_suspend()!
[    6.598907] usb usb1: __pm_runtime_suspend() returns 0!
[SUCCESS]
 Mounting other filesystems : [SUCCESS]
 Starting syslogd           : Jan  1 00:00:10 OMAP3EVM syslog.info syslogd started: BusyBox v1.9.0
[SUCCESS]
 Starting telnetd           : 
[SUCCESS]

System initialization complete.

Please press Enter to activate this console. starting pid 452, tty '': '/bin/sh'

    Setting shell environment ...
    - Path
    - Aliases
    - Touchscreen

    Done!

[root@OMAP3EVM /]# 


^ permalink raw reply

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Russell King - ARM Linux @ 2010-05-24 10:14 UTC (permalink / raw)
  To: Ming Lei; +Cc: linux-kernel, linux-embedded, linux-arm-kernel, a.p.zijlstra
In-Reply-To: <20100524071921.GA17528@n2100.arm.linux.org.uk>

On Mon, May 24, 2010 at 08:19:21AM +0100, Russell King - ARM Linux wrote:
> On Mon, May 24, 2010 at 11:23:55AM +0800, Ming Lei wrote:
> > On Sun, 23 May 2010 20:47:46 +0100
> > Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> > > Moreover, I put to you that it's utterly pointless - and a waste of
> > > CPU time - telling lockdep about the IRQ masking when an exception
> > 
> > Yes, the patch still tries to remove the pointless trace of IRQ masking,
> > such as: replace disable_irq with disable_irq_notrace.
> > 
> > > occurs, and it's also pointless telling lockdep about the IRQ
> > > unmasking when we resume userspace.
> > 
> > Even it is pointless, but if lockdep doesn't see the IRQ unmasking, the 
> > warning "unannotated irqs-on" will be triggered and lockdep doe not work
> > any longer, so we have to remove the warning to make lockdep workable on
> > ARM, could you agree on it?  It is the main purpose of the patch.
> 
> I'm sorry, I think we have a communication issue; you're not understanding
> the points that I'm making.  I feel I'm wasting my time trying to explain
> it.
> 
> I'm not merging your patch as-is because I believe it to be wrong.

Right, I see what the problem is now - it's all to do with threads
created with kernel_thread() confusing lockdep.

I'm of the opinion that all your changes in entry*.S are the wrong
way to fix this - not only does it add additional overhead where
none is really necessary, it adds additional complexity.

So, here's a patch to solve the warning you quoted.

diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index acf5e6f..a5f8fd0 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -351,17 +351,25 @@ EXPORT_SYMBOL(dump_fpu);
 
 /*
  * Shuffle the argument into the correct register before calling the
- * thread function.  r1 is the thread argument, r2 is the pointer to
- * the thread function, and r3 points to the exit function.
+ * thread function.  r4 is the thread argument, r5 is the pointer to
+ * the thread function, and r6 points to the exit function.
  */
 extern void kernel_thread_helper(void);
 asm(	".pushsection .text\n"
 "	.align\n"
 "	.type	kernel_thread_helper, #function\n"
 "kernel_thread_helper:\n"
-"	mov	r0, r1\n"
-"	mov	lr, r3\n"
-"	mov	pc, r2\n"
+#ifdef CONFIG_TRACE_IRQFLAGS
+"	bl	trace_hardirqs_on\n"
+#endif
+#if __LINUX_ARM_ARCH__ >= 6
+"	cpsie	i\n"
+#else
+"	msr	cpsr_c, r7\n"
+#endif
+"	mov	r0, r4\n"
+"	mov	lr, r6\n"
+"	mov	pc, r5\n"
 "	.size	kernel_thread_helper, . - kernel_thread_helper\n"
 "	.popsection");
 
@@ -391,11 +399,12 @@ pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
 
 	memset(&regs, 0, sizeof(regs));
 
-	regs.ARM_r1 = (unsigned long)arg;
-	regs.ARM_r2 = (unsigned long)fn;
-	regs.ARM_r3 = (unsigned long)kernel_thread_exit;
+	regs.ARM_r4 = (unsigned long)arg;
+	regs.ARM_r5 = (unsigned long)fn;
+	regs.ARM_r6 = (unsigned long)kernel_thread_exit;
+	regs.ARM_r7 = SVC_MODE | PSR_ISETSTATE;
 	regs.ARM_pc = (unsigned long)kernel_thread_helper;
-	regs.ARM_cpsr = SVC_MODE | PSR_ENDSTATE | PSR_ISETSTATE;
+	regs.ARM_cpsr = SVC_MODE | PSR_ENDSTATE | PSR_ISETSTATE | PSR_I_BIT;
 
 	return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
 }

^ permalink raw reply related

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Russell King - ARM Linux @ 2010-05-24  7:19 UTC (permalink / raw)
  To: Ming Lei; +Cc: linux-arm-kernel, linux-embedded, a.p.zijlstra, linux-kernel
In-Reply-To: <20100524112355.18424622@tom-lei>

On Mon, May 24, 2010 at 11:23:55AM +0800, Ming Lei wrote:
> On Sun, 23 May 2010 20:47:46 +0100
> Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> > Moreover, I put to you that it's utterly pointless - and a waste of
> > CPU time - telling lockdep about the IRQ masking when an exception
> 
> Yes, the patch still tries to remove the pointless trace of IRQ masking,
> such as: replace disable_irq with disable_irq_notrace.
> 
> > occurs, and it's also pointless telling lockdep about the IRQ
> > unmasking when we resume userspace.
> 
> Even it is pointless, but if lockdep doesn't see the IRQ unmasking, the 
> warning "unannotated irqs-on" will be triggered and lockdep doe not work
> any longer, so we have to remove the warning to make lockdep workable on
> ARM, could you agree on it?  It is the main purpose of the patch.

I'm sorry, I think we have a communication issue; you're not understanding
the points that I'm making.  I feel I'm wasting my time trying to explain
it.

I'm not merging your patch as-is because I believe it to be wrong.

^ permalink raw reply

* Re: [PATCH 1/2] Squashfs: add LZO decompression support
From: Chan Jeong @ 2010-05-24  6:53 UTC (permalink / raw)
  To: 'Phillip Lougher'
  Cc: 'Hyo Jun Im',
	squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	'Tim Bird', linux-embedded-u79uwXL29TY76Z2rM5mHXA,
	'Gunho Lee'
In-Reply-To: <4BF9E921.6090609-cnXvMjJKhjYG2Il/BtU0GPXRex20P6io@public.gmane.org>

> Chan Jeong wrote:
> > Hi,
> >
> > This patch series adds LZO decompression support to Squashfs,
> > using in-kernel LZO decompression library and Squashfs
> > decompressor entries.
> >
> > The patch series also includes LZO support for Squashfs tools.
> >
> > Signed-off-by: Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
> 
> Hi Chan
> 
> Thanks for the patches.  How much testing have these patches had?
>  From an eyeball of the code (and a check of the LZO decompressor
> code in the kernel) they look OK.
> 
> I'm currently considering whether to push these for mainline in
> the current 2.6.35 merge window.  I'd like to push them in this
> merge window, however, pushing them now is definitely cutting things
> fine because they were only posted for review after the merge window
> opened (and the established etiquette is the merge window is to push
> things that were posted for review and ideally in linux-next well
> before the merge window opened).
> 
> So, some idea of how much testing these patches have had would
> increase my confidence about pushing them in this merge window.
> 
> Thanks
> 
> Phillip

Hi Phillip,

Thank you for your feedback. I have done much testing with those
patches on X86 PCs and a MIPS-based TV product.

Actually the TV product has been working fine with Squashfs-zlib
filesystem images, and after replacement with lzo images, it is
running good for long-run test and all TV functions such as video,
audio, UI and networking are working fine as well.

And Here is just clean-up for the first patch. The kcalloc() is
safer for lzo workspace pointer array, because it returns zeroed
memory.

Thanks,
Chan Jeong

--
diff --git a/fs/squashfs/lzo_wrapper.c b/fs/squashfs/lzo_wrapper.c
index 6577cfa..02a767a 100644
--- a/fs/squashfs/lzo_wrapper.c
+++ b/fs/squashfs/lzo_wrapper.c
@@ -38,7 +38,7 @@ static void *lzo_init(struct squashfs_sb_info *msblk)
 {
 	void **streams;
 
-	streams = (void **)kmalloc(sizeof(void *) * 2, GFP_KERNEL);
+	streams = (void **)kcalloc(2, sizeof(void *), GFP_KERNEL);
 	if (streams == NULL)
 		goto failed;
 
@@ -56,11 +56,9 @@ static void *lzo_init(struct squashfs_sb_info *msblk)
 
 failed:
 	ERROR("Failed to allocate lzo workspace\n");
-	if (streams) {
-		if (streams[0])
-			vfree(streams[0]);
-		kfree(streams);
-	}
+	if (streams)
+		vfree(streams[0]);
+	kfree(streams);
 	return NULL;
 }
 
@@ -68,8 +66,11 @@ failed:
 static void lzo_free(void *stream)
 {
 	void **streams = (void **)stream;
-	vfree(streams[1]);
-	vfree(streams[0]);
+
+	if (streams) {
+		vfree(streams[1]);
+		vfree(streams[0]);
+	}
 	kfree(streams);
 }
 


------------------------------------------------------------------------------

^ permalink raw reply related

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Ming Lei @ 2010-05-24  3:23 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-arm-kernel, linux-embedded, a.p.zijlstra, linux-kernel
In-Reply-To: <20100523194746.GE950@n2100.arm.linux.org.uk>

On Sun, 23 May 2010 20:47:46 +0100
Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:

> Let me explain again.  We have this series of actions:
> 
> - in userspace
> - exception happens
> - cpu disables interrupts itself
> - save state
> - enable interrupts, and tell lockdep that IRQs are unmasked
> - we process the exception, and ultimately call ret_fast_syscall or
>   ret_slow_syscall
> 
> Now, what was happening in existing kernels is:
> 
> POINT A.
> - disable interrupts, and tell lockdep that IRQs are masked
> - check for any work pending
>   - if work pending, call function - with IRQs still masked
>   - go back to point A.
> - restore state
> - resume userspace, which implicitly re-enables IRQs
> 
> This results in a balanced and afaics correct setup.  Lockdep doesn't
> care about the state of userspace - it only cares about state (and its
> code only ever runs) when we're in kernel mode.
> 
> With your change above, what's happening is the above is replaced by:
> 
> POINT A.
> - disable interrupts, but don't tell lockdep that IRQs are masked
> - check for any work pending
>   - if work pending, call function - with IRQs still masked
> 	*but* lockdep believes IRQs are enabled.  Therefore, I believe
> 	false warnings are probable from things like the scheduler,
> 	signal handling paths, etc.
>   - go back to point A.
> - restore state
> - resume userspace, which implicitly re-enables IRQs
> 
> So can you now see why I believe the above change I've quoted is
> wrong?

Yes, you are right, so we can fix it by the two ways below:

	-keep disable_irq in ret_slow_syscall, also add a extra 
	trace_ret_hardirqs_on before resume userspace.
or 
	-replace disable_irq with disable_irq_notrace in ret_slow_syscall
	and ret_fast_syscall, also add a extra trace_ret_hardirqs_off if
	there are works pending

seems the 2nd way is more efficient.

> 
> Moreover, I put to you that it's utterly pointless - and a waste of
> CPU time - telling lockdep about the IRQ masking when an exception

Yes, the patch still tries to remove the pointless trace of IRQ masking,
such as: replace disable_irq with disable_irq_notrace.

> occurs, and it's also pointless telling lockdep about the IRQ
> unmasking when we resume userspace.

Even it is pointless, but if lockdep doesn't see the IRQ unmasking, the 
warning "unannotated irqs-on" will be triggered and lockdep doe not work
any longer, so we have to remove the warning to make lockdep workable on
ARM, could you agree on it?  It is the main purpose of the patch.

The warning was reported before and still exists in 2.6.34 and -next tree:

        http://marc.info/?l=linux-arm-kernel&m=126047420005553&w=2


Thanks,
Ming Lei

^ permalink raw reply

* Re: [Squashfs-devel] [PATCH 1/2] Squashfs: add LZO decompression support
From: Phillip Lougher @ 2010-05-24  2:49 UTC (permalink / raw)
  To: Chan Jeong
  Cc: squashfs-devel, 'Gunho Lee', 'Tim Bird',
	linux-embedded, 'Hyo Jun Im'
In-Reply-To: <001a01caf63e$0280ef50$0782cdf0$@jeong@lge.com>

Chan Jeong wrote:
> Hi,
> 
> This patch series adds LZO decompression support to Squashfs,
> using in-kernel LZO decompression library and Squashfs 
> decompressor entries.
> 
> The patch series also includes LZO support for Squashfs tools.
> 
> Signed-off-by: Chan Jeong <chan.jeong@lge.com>

Hi Chan

Thanks for the patches.  How much testing have these patches had?
 From an eyeball of the code (and a check of the LZO decompressor
code in the kernel) they look OK.

I'm currently considering whether to push these for mainline in
the current 2.6.35 merge window.  I'd like to push them in this
merge window, however, pushing them now is definitely cutting things
fine because they were only posted for review after the merge window
opened (and the established etiquette is the merge window is to push
things that were posted for review and ideally in linux-next well
before the merge window opened).

So, some idea of how much testing these patches have had would
increase my confidence about pushing them in this merge window.

Thanks

Phillip


^ permalink raw reply

* Re: [PATCH 2/2] Squashfs-tools: add LZO support
From: Chan Jeong @ 2010-05-24  2:05 UTC (permalink / raw)
  To: 'kirk w', squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: 'Phillip Lougher', 'Gunho Lee',
	'Tim Bird', linux-embedded-u79uwXL29TY76Z2rM5mHXA,
	'Hyo Jun Im'
In-Reply-To: <649098.60021.qm-J6A/OvMbNTOORdMXk8NaZPu2YVrzzGjVVpNB7YpNyf8@public.gmane.org>

Hi,

Yes, you can try lzo1x-999 compression just with 2-line change.
The increased compression level, lzo1x-999, would be better than lzo1x-1
for slow I/O storage and higher CPU.

If you have any chance to share some test result like decompression 
time comparison, it would be nice.

Thanks,
Chan Jeong

--- lzo_wrapper.c.orig	2010-05-24 10:28:02.000000000 +0900
+++ lzo_wrapper.c	2010-05-24 10:41:23.000000000 +0900
@@ -43,7 +43,7 @@ int lzo_compress(void **strm, char *d, c
 			goto malloc_failed;
 
 		/* work memory */
-		if((buffers[0] = malloc(LZO1X_1_MEM_COMPRESS)) == NULL)
+		if((buffers[0] = malloc(LZO1X_999_MEM_COMPRESS)) == NULL)
 			goto malloc_failed;
 
 		/* temporal output buffer */
@@ -53,7 +53,7 @@ int lzo_compress(void **strm, char *d, c
 
 	wrkmem = buffers[0];
 	out = buffers[1];
-	res = lzo1x_1_compress((lzo_bytep)s, size, out, &outlen, wrkmem);
+	res = lzo1x_999_compress((lzo_bytep)s, size, out, &outlen, wrkmem);
 	if(res != LZO_E_OK) {
 		/*
 		 * All other errors return failure, with the compressor

-----Original Message-----
From: linux-embedded-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org [mailto:linux-embedded-owner@vger.kernel.org] On Behalf Of kirk w
Sent: Saturday, May 22, 2010 12:54 PM
To: squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org; Chan Jeong
Cc: 'Phillip Lougher'; 'Gunho Lee'; 'Tim Bird'; linux-embedded-u79uwXL29TasMV2rI37PzA@public.gmane.orgorg; 'Hyo Jun Im'
Subject: Re: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support

Hi,

Thanks for the patches. Is there a way to increase the compression level? Right now my file system compressed with zlib is 176MB and
with this patch using lzo it's 232MB. I've read that lzo's compression level can be increased to near zlib levels, but compression
times suffer. Compression times don't matter to me, but increased decompression speed is intriguing.   

Thanks again,

Kirk

--- On Tue, 5/18/10, Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org> wrote:

> From: Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
> Subject: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
> To: squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Cc: "'Phillip Lougher'" <phillip-cnXvMjJKhjYG2Il/BtU0GPXRex20P6io@public.gmane.org>, "'Gunho Lee'" <gunho.lee-Hm3cg6mZ9cc@public.gmane.org>, "'Tim Bird'" <tim.bird-mEdOJwZ7QcZBDgjK7y7TUQ@public.gmane.org>,
linux-embedded-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "'Hyo Jun Im'" <hyojun.im-Hm3cg6mZ9cc@public.gmane.org>
> Date: Tuesday, May 18, 2010, 12:05 AM
> This patch adds LZO compression and
> decompression to Squashfs tools.
> 
> The patch is against the latest cvs version and requires
> the LZO library
> from http://www.oberhumer.com/opensource/lzo.
> 
> Signed-off-by: Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
> ---
>  Makefile      |   20
> +++++++++++
>  compressor.c  |    7 ++++
>  lzo_wrapper.c |   99
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  squashfs_fs.h |    1 
>  4 files changed, 127 insertions(+)
> 
> diff -uprN -x .cvs squashfs-tools.cvs.orig/Makefile
> squashfs-tools.cvs/Makefile
> --- squashfs-tools.cvs.orig/Makefile   
> 2010-05-13 02:17:06.000000000 +0900
> +++ squashfs-tools.cvs/Makefile   
> 2010-05-18 11:36:58.000000000 +0900
> @@ -15,6 +15,18 @@
>  #LZMA_SUPPORT = 1
>  #LZMA_DIR = ../../../LZMA/lzma465
>  
> +#
> +# Building LZO support
> +#
> +# The LZO library (http://www.oberhumer.com/opensource/lzo/)
> is supported.
> +#
> +# To build using the LZO library (2.0.3 used in
> development, other versions may
> +# work) - download, unpack, build and install it,
> uncomment and set LZO_DIR to
> +# installed directory prefix, and uncomment the
> LZO_SUPPORT line below.
> +
> +#LZO_SUPPORT = 1
> +#LZO_DIR = /usr/local
> +
>  #Compression default.
>  COMP_DEFAULT = gzip
>  
> @@ -47,6 +59,14 @@ UNSQUASHFS_OBJS += xz_wrapper.o
>  LIBS += -llzma
>  endif
>  
> +ifdef LZO_SUPPORT
> +CFLAGS += -DLZO_SUPPORT
> +INCLUDEDIR += -I$(LZO_DIR)/include
> +MKSQUASHFS_OBJS += lzo_wrapper.o
> +UNSQUASHFS_OBJS += lzo_wrapper.o
> +LIBS += -L$(LZO_DIR)/lib -llzo2
> +endif
> +
>  .PHONY: all
>  all: mksquashfs unsquashfs
>  
> diff -uprN -x .cvs squashfs-tools.cvs.orig/compressor.c
> squashfs-tools.cvs/compressor.c
> --- squashfs-tools.cvs.orig/compressor.c   
> 2009-08-29 10:05:34.000000000 +0900
> +++ squashfs-tools.cvs/compressor.c   
> 2010-05-18 11:37:46.000000000 +0900
> @@ -29,6 +29,8 @@ extern int gzip_compress(void **, char *
>  extern int gzip_uncompress(char *, char *, int, int, int
> *);
>  extern int lzma_compress(void **, char *, char *, int,
> int, int *);
>  extern int lzma_uncompress(char *, char *, int, int, int
> *);
> +extern int lzo_compress(void **, char *, char *, int, int,
> int *);
> +extern int lzo_uncompress(char *, char *, int, int, int
> *);
>  
>  struct compressor compressor[] = {
>      { gzip_compress, gzip_uncompress,
> ZLIB_COMPRESSION, "gzip", 1 },
> @@ -37,6 +39,11 @@ struct compressor compressor[] = {
>  #else
>      { NULL, NULL, LZMA_COMPRESSION, "lzma",
> 0 },
>  #endif
> +#ifdef LZO_SUPPORT
> +    { lzo_compress, lzo_uncompress,
> LZO_COMPRESSION, "lzo", 1 },
> +#else
> +    { NULL, NULL, LZO_COMPRESSION, "lzo", 0
> },
> +#endif
>      { NULL, NULL , 0, "unknown", 0}
>  };
>  
> diff -uprN -x .cvs squashfs-tools.cvs.orig/lzo_wrapper.c
> squashfs-tools.cvs/lzo_wrapper.c
> --- squashfs-tools.cvs.orig/lzo_wrapper.c   
> 1970-01-01 09:00:00.000000000 +0900
> +++ squashfs-tools.cvs/lzo_wrapper.c   
> 2010-05-18 11:59:30.000000000 +0900
> @@ -0,0 +1,99 @@
> +/*
> + * Copyright (c) 2010 LG Electronics
> + * Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
> + *
> + * This program is free software; you can redistribute it
> and/or
> + * modify it under the terms of the GNU General Public
> License
> + * as published by the Free Software Foundation; either
> version 2,
> + * or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be
> useful,
> + * but WITHOUT ANY WARRANTY; without even the implied
> warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General
> Public License
> + * along with this program; if not, write to the Free
> Software
> + * Foundation, 59 Temple Place - Suite 330, Boston, MA
> 02111-1307, USA.
> + *
> + * lzo_wrapper.c
> + */
> +
> +#include <stdlib.h>
> +#include <string.h>
> +
> +#include <lzo/lzoconf.h>
> +#include <lzo/lzo1x.h>
> +
> +/* worst-case expansion calculation during compression,
> +   see LZO FAQ for more information */
> +#define LZO_OUTPUT_BUFFER_SIZE(size)   
> (size + (size/16) + 64 + 3)
> +
> +int lzo_compress(void **strm, char *d, char *s, int size,
> int block_size,
> +        int *error)
> +{
> +    int res = 0;
> +    lzo_bytep out;
> +    lzo_uint outlen;
> +    lzo_voidp wrkmem;
> +    void **buffers = (void **)*strm;
> +
> +    if(buffers == NULL) {
> +        if((buffers = *strm
> = calloc(2, sizeof(void *))) == NULL)
> +           
> goto malloc_failed;
> +
> +        /* work memory */
> +        if((buffers[0] =
> malloc(LZO1X_1_MEM_COMPRESS)) == NULL)
> +           
> goto malloc_failed;
> +
> +        /* temporal output
> buffer */
> +        if((buffers[1] =
> malloc(LZO_OUTPUT_BUFFER_SIZE(block_size))) == NULL)
> +           
> goto malloc_failed;
> +    }
> +
> +    wrkmem = buffers[0];
> +    out = buffers[1];
> +    res = lzo1x_1_compress((lzo_bytep)s,
> size, out, &outlen, wrkmem);
> +    if(res != LZO_E_OK) {
> +        /*
> +         * All
> other errors return failure, with the compressor
> +         *
> specific error code in *error
> +         */
> +        *error = res;
> +        return -1;
> +    }
> +
> +    if(outlen >= size) {
> +        /*
> +         * Output
> buffer overflow. Return out of buffer space
> +         */
> +        return 0;
> +    }
> +
> +    /*
> +     * Success, return the
> compressed size.
> +     */
> +    memcpy(d, out, outlen);
> +    return outlen;
> +
> +malloc_failed:
> +    if(buffers) {
> +        if(buffers[0]) {
> +           
> free(buffers[0]);
> +        }
> +        free(buffers);
> +    }
> +    return -1;
> +}
> +
> +
> +int lzo_uncompress(char *d, char *s, int size, int
> block_size, int *error)
> +{
> +    int res;
> +    lzo_uint bytes = block_size;
> +    
> +    res = lzo1x_decompress((lzo_bytep)s,
> size, (lzo_bytep)d, &bytes, NULL);
> +
> +    *error = res;
> +    return res == LZO_E_OK ? bytes : -1;
> +}
> diff -uprN -x .cvs squashfs-tools.cvs.orig/squashfs_fs.h
> squashfs-tools.cvs/squashfs_fs.h
> --- squashfs-tools.cvs.orig/squashfs_fs.h   
> 2010-05-13 04:28:38.000000000 +0900
> +++ squashfs-tools.cvs/squashfs_fs.h   
> 2010-05-18 11:43:22.000000000 +0900
> @@ -238,6 +238,7 @@ typedef long long   
>     squashfs_inode_t;
>  
>  #define ZLIB_COMPRESSION    1
>  #define LZMA_COMPRESSION    2
> +#define LZO_COMPRESSION   
>     3
>  
>  struct squashfs_super_block {
>      unsigned int   
>     s_magic;
> 
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Squashfs-devel mailing list
> Squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/squashfs-devel
> 


      

--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


------------------------------------------------------------------------------

^ permalink raw reply

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Russell King - ARM Linux @ 2010-05-23 19:47 UTC (permalink / raw)
  To: Ming Lei; +Cc: linux-arm-kernel, linux-embedded, a.p.zijlstra, linux-kernel
In-Reply-To: <AANLkTinV9Na9zxYMIfTr893Ynnc0YOk2B6uPKEa9s4R1@mail.gmail.com>

On Sun, May 23, 2010 at 11:07:50PM +0800, Ming Lei wrote:
> 2010/5/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> > On Sun, May 23, 2010 at 09:44:20PM +0800, Ming Lei wrote:
> >> 2010/5/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> >> >>  ENTRY(ret_to_user)
> >> >>  ret_slow_syscall:
> >> >> -     disable_irq                             @ disable interrupts
> >> >> +     disable_irq_notrace                             @ disable interrupts
> >> >
> >> > I think this one does need to be traced - the pending work functions are
> >> > all C code which could call back into lockdep.
> >>
> >> If there are pending works, schedule will be called to give cpu to it,
> >> I wonder why the work function to be scheduled will be run with irq
> >> disabled. Seems we should enable irq again before calling schedule,
> >> not sure.
> >
> > No.  I'm talking about things like do_notify_resume().
> >
> > I think the above should be left as-is, so that as far as lockdep is
> > concerned, IRQs are off while userspace runs.  What happens between
> > returning to userspace and re-entering the kernel has no bearing what
> > so ever on lockdep.
> >
> 
> Oh, trace_ret_hardirqs_on has to be added before returning to user-space to
> remove the warning, like x86 and mips. If you agree, I'd like to post
> a new version patch.

Let me explain again.  We have this series of actions:

- in userspace
- exception happens
- cpu disables interrupts itself
- save state
- enable interrupts, and tell lockdep that IRQs are unmasked
- we process the exception, and ultimately call ret_fast_syscall or
  ret_slow_syscall

Now, what was happening in existing kernels is:

POINT A.
- disable interrupts, and tell lockdep that IRQs are masked
- check for any work pending
  - if work pending, call function - with IRQs still masked
  - go back to point A.
- restore state
- resume userspace, which implicitly re-enables IRQs

This results in a balanced and afaics correct setup.  Lockdep doesn't
care about the state of userspace - it only cares about state (and its
code only ever runs) when we're in kernel mode.

With your change above, what's happening is the above is replaced by:

POINT A.
- disable interrupts, but don't tell lockdep that IRQs are masked
- check for any work pending
  - if work pending, call function - with IRQs still masked
	*but* lockdep believes IRQs are enabled.  Therefore, I believe
	false warnings are probable from things like the scheduler,
	signal handling paths, etc.
  - go back to point A.
- restore state
- resume userspace, which implicitly re-enables IRQs

So can you now see why I believe the above change I've quoted is wrong?

Moreover, I put to you that it's utterly pointless - and a waste of CPU
time - telling lockdep about the IRQ masking when an exception occurs,
and it's also pointless telling lockdep about the IRQ unmasking when we
resume userspace.

^ permalink raw reply

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Ming Lei @ 2010-05-23 15:07 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-arm-kernel, linux-embedded, a.p.zijlstra, linux-kernel
In-Reply-To: <20100523141300.GD950@n2100.arm.linux.org.uk>

2010/5/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> On Sun, May 23, 2010 at 09:44:20PM +0800, Ming Lei wrote:
>> 2010/5/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
>> >>  ENTRY(ret_to_user)
>> >>  ret_slow_syscall:
>> >> -     disable_irq                             @ disable interrupts
>> >> +     disable_irq_notrace                             @ disable interrupts
>> >
>> > I think this one does need to be traced - the pending work functions are
>> > all C code which could call back into lockdep.
>>
>> If there are pending works, schedule will be called to give cpu to it,
>> I wonder why the work function to be scheduled will be run with irq
>> disabled. Seems we should enable irq again before calling schedule,
>> not sure.
>
> No.  I'm talking about things like do_notify_resume().
>
> I think the above should be left as-is, so that as far as lockdep is
> concerned, IRQs are off while userspace runs.  What happens between
> returning to userspace and re-entering the kernel has no bearing what
> so ever on lockdep.
>

Oh, trace_ret_hardirqs_on has to be added before returning to user-space to
remove the warning, like x86 and mips. If you agree, I'd like to post
a new version
patch.

Thanks,

-- 
Lei Ming

^ permalink raw reply

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Russell King - ARM Linux @ 2010-05-23 14:13 UTC (permalink / raw)
  To: Ming Lei; +Cc: linux-arm-kernel, linux-embedded, a.p.zijlstra, linux-kernel
In-Reply-To: <AANLkTikRp0EHxshKYq39p18ymoRNAtyHrNm3yq6A49-r@mail.gmail.com>

On Sun, May 23, 2010 at 09:44:20PM +0800, Ming Lei wrote:
> 2010/5/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> >>  ENTRY(ret_to_user)
> >>  ret_slow_syscall:
> >> -     disable_irq                             @ disable interrupts
> >> +     disable_irq_notrace                             @ disable interrupts
> >
> > I think this one does need to be traced - the pending work functions are
> > all C code which could call back into lockdep.
> 
> If there are pending works, schedule will be called to give cpu to it,
> I wonder why the work function to be scheduled will be run with irq
> disabled. Seems we should enable irq again before calling schedule,
> not sure.

No.  I'm talking about things like do_notify_resume().

I think the above should be left as-is, so that as far as lockdep is
concerned, IRQs are off while userspace runs.  What happens between
returning to userspace and re-entering the kernel has no bearing what
so ever on lockdep.

^ permalink raw reply

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Ming Lei @ 2010-05-23 13:44 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-arm-kernel, linux-embedded, a.p.zijlstra, linux-kernel
In-Reply-To: <20100523123801.GC950@n2100.arm.linux.org.uk>

2010/5/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
>>  ENTRY(ret_to_user)
>>  ret_slow_syscall:
>> -     disable_irq                             @ disable interrupts
>> +     disable_irq_notrace                             @ disable interrupts
>
> I think this one does need to be traced - the pending work functions are
> all C code which could call back into lockdep.

If there are pending works, schedule will be called to give cpu to it, I wonder
why the work function to be scheduled will be run with irq disabled.
Seems we should enable irq again before calling schedule, not sure.

> Also, I'm nervious about applying this patch without seeing more people
> test it.

I test the patch on my beagle board and is OK, and if you don't apply one
patch into your tree, there are few people who may test it since they have to
parse the raw email patch(which is more inconvenient than 'git pull') for test
if they want to do.

Thanks,
-- 
Lei Ming

^ permalink raw reply

* Re: [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: Russell King - ARM Linux @ 2010-05-23 12:38 UTC (permalink / raw)
  To: tom.leiming; +Cc: linux-arm-kernel, linux-embedded, a.p.zijlstra, linux-kernel
In-Reply-To: <1274615328-27953-1-git-send-email-tom.leiming@gmail.com>

On Sun, May 23, 2010 at 07:48:48PM +0800, tom.leiming@gmail.com wrote:
> diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
> index 2c1db77..ed471a7 100644
> --- a/arch/arm/kernel/entry-common.S
> +++ b/arch/arm/kernel/entry-common.S
> @@ -58,7 +58,7 @@ work_resched:
>   */
>  ENTRY(ret_to_user)
>  ret_slow_syscall:
> -	disable_irq				@ disable interrupts
> +	disable_irq_notrace				@ disable interrupts

I think this one does need to be traced - the pending work functions are
all C code which could call back into lockdep.

Also, I'm nervious about applying this patch without seeing more people
test it.

^ permalink raw reply

* [RESEND PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: tom.leiming @ 2010-05-23 11:48 UTC (permalink / raw)
  To: linux
  Cc: linux-arm-kernel, linux-embedded, a.p.zijlstra, linux-kernel,
	Ming Lei

From: Ming Lei <tom.leiming@gmail.com>

This patch fixes the 'unannotated irqs-on' lockdep warning[1]:

This patch introduces macro of trace_ret_hardirqs_on, which will
call trace_hardirqs_on if I flag in the stored CPSR is zero.

In the path of returning to user-space, the patch replaces disable_irq
with disable_irq_notrace in ret_to_user to avoid the 'unannotated irqs-on'
lockdep warning since hardirqs is always enabled before returning to user.

In the path of returning to kernel-space, the patch still replaces
disable_irq with disable_irq_notrace in __xxx_svc handler and adds
trace_hardirqs_on before calling svc_exit to trace the possible hardirqs on
event for avoiding the possible 'unannotated irqs-on' lockdep warning.

The patch not only fixes the warning[1] to make lockdep usable on ARM,
but also improves the efficiency if lockdep is enabled:

	- remove one calling for asm_trace_hardirqs_on before returning
to user-space
	- convert asm_trace_hardirqs_on to trace_hardirqs_on in the
path of returning to kernel space from exception and __only__ call it if
harirqs will be enabled before returning.

[1]
	CPU: Testing write buffer coherency: ok
	------------[ cut here ]------------
	WARNING: at kernel/lockdep.c:3145 check_flags+0xcc/0x1dc()
	Modules linked in:
	[<c0035120>] (unwind_backtrace+0x0/0xf8) from [<c0355374>] (dump_stack+0x20/0x24)
	[<c0355374>] (dump_stack+0x20/0x24) from [<c0060c04>] (warn_slowpath_common+0x58/0x70)
	[<c0060c04>] (warn_slowpath_common+0x58/0x70) from [<c0060c3c>] (warn_slowpath_null+0x20/0x24)
	[<c0060c3c>] (warn_slowpath_null+0x20/0x24) from [<c008f224>] (check_flags+0xcc/0x1dc)
	[<c008f224>] (check_flags+0xcc/0x1dc) from [<c00945dc>] (lock_acquire+0x50/0x140)
	[<c00945dc>] (lock_acquire+0x50/0x140) from [<c0358434>] (_raw_spin_lock+0x50/0x88)
	[<c0358434>] (_raw_spin_lock+0x50/0x88) from [<c00fd114>] (set_task_comm+0x2c/0x60)
	[<c00fd114>] (set_task_comm+0x2c/0x60) from [<c007e184>] (kthreadd+0x30/0x108)
	[<c007e184>] (kthreadd+0x30/0x108) from [<c0030104>] (kernel_thread_exit+0x0/0x8)
	---[ end trace 1b75b31a2719ed1c ]---
	possible reason: unannotated irqs-on.
	irq event stamp: 3
	hardirqs last  enabled at (2): [<c0059bb0>] finish_task_switch+0x48/0xb0
	hardirqs last disabled at (3): [<c002f0b0>] ret_slow_syscall+0xc/0x1c
	softirqs last  enabled at (0): [<c005f3e0>] copy_process+0x394/0xe5c
	softirqs last disabled at (0): [<(null)>] (null)

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 arch/arm/kernel/entry-armv.S   |   31 +++++++++++++++++--------------
 arch/arm/kernel/entry-common.S |    2 +-
 arch/arm/kernel/entry-header.S |    7 +++++++
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 7ee48e7..42d33cf 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -204,13 +204,15 @@ __dabt_svc:
 	@
 	@ IRQs off again before pulling preserved data off the stack
 	@
-	disable_irq
+	disable_irq_notrace
 
 	@
 	@ restore SPSR and restart the instruction
+	@ trace possible hardirqs on event before returning
 	@
-	ldr	r2, [sp, #S_PSR]
-	svc_exit r2				@ return from exception
+	ldr	r4, [sp, #S_PSR]
+	trace_ret_hardirqs_on r4
+	svc_exit r4				@ return from exception
  UNWIND(.fnend		)
 ENDPROC(__dabt_svc)
 
@@ -235,10 +237,7 @@ __irq_svc:
 	blne	svc_preempt
 #endif
 	ldr	r4, [sp, #S_PSR]		@ irqs are already disabled
-#ifdef CONFIG_TRACE_IRQFLAGS
-	tst	r4, #PSR_I_BIT
-	bleq	trace_hardirqs_on
-#endif
+	trace_ret_hardirqs_on r4
 	svc_exit r4				@ return from exception
  UNWIND(.fnend		)
 ENDPROC(__irq_svc)
@@ -291,13 +290,15 @@ __und_svc:
 	@
 	@ IRQs off again before pulling preserved data off the stack
 	@
-1:	disable_irq
+1:	disable_irq_notrace
 
 	@
 	@ restore SPSR and restart the instruction
+	@ trace possible hardirqs on event before returning
 	@
-	ldr	r2, [sp, #S_PSR]		@ Get SVC cpsr
-	svc_exit r2				@ return from exception
+	ldr	r4, [sp, #S_PSR]		@ Get SVC cpsr
+	trace_ret_hardirqs_on r4
+	svc_exit r4				@ return from exception
  UNWIND(.fnend		)
 ENDPROC(__und_svc)
 
@@ -327,13 +328,15 @@ __pabt_svc:
 	@
 	@ IRQs off again before pulling preserved data off the stack
 	@
-	disable_irq
+	disable_irq_notrace
 
 	@
 	@ restore SPSR and restart the instruction
-	@
-	ldr	r2, [sp, #S_PSR]
-	svc_exit r2				@ return from exception
+	@ trace possible hardirqs on event before returning
+	@	
+	ldr	r4, [sp, #S_PSR]
+	trace_ret_hardirqs_on r4
+	svc_exit r4				@ return from exception
  UNWIND(.fnend		)
 ENDPROC(__pabt_svc)
 
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 2c1db77..ed471a7 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -58,7 +58,7 @@ work_resched:
  */
 ENTRY(ret_to_user)
 ret_slow_syscall:
-	disable_irq				@ disable interrupts
+	disable_irq_notrace				@ disable interrupts
 	ldr	r1, [tsk, #TI_FLAGS]
 	tst	r1, #_TIF_WORK_MASK
 	bne	work_pending
diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
index d93f976..ac51ce3 100644
--- a/arch/arm/kernel/entry-header.S
+++ b/arch/arm/kernel/entry-header.S
@@ -30,6 +30,13 @@
 #error "Please fix"
 #endif
 
+	.macro trace_ret_hardirqs_on, rspsr
+#ifdef CONFIG_TRACE_IRQFLAGS
+	tst 	\rspsr, #PSR_I_BIT
+	bleq	trace_hardirqs_on
+#endif
+	.endm
+
 	.macro	zero_fp
 #ifdef CONFIG_FRAME_POINTER
 	mov	fp, #0
-- 
1.6.2.5

^ permalink raw reply related

* Re: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
From: kirk w @ 2010-05-22  3:53 UTC (permalink / raw)
  To: squashfs-devel, Chan Jeong
  Cc: 'Phillip Lougher', 'Gunho Lee',
	'Tim Bird', linux-embedded, 'Hyo Jun Im'
In-Reply-To: <001b01caf63f$4c5fcdc0$e51f6940$@jeong@lge.com>

Hi,

Thanks for the patches. Is there a way to increase the compression level? Right now my file system compressed with zlib is 176MB and with this patch using lzo it's 232MB. I've read that lzo's compression level can be increased to near zlib levels, but compression times suffer. Compression times don't matter to me, but increased decompression speed is intriguing.   

Thanks again,

Kirk

--- On Tue, 5/18/10, Chan Jeong <chan.jeong@lge.com> wrote:

> From: Chan Jeong <chan.jeong@lge.com>
> Subject: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
> To: squashfs-devel@lists.sourceforge.net
> Cc: "'Phillip Lougher'" <phillip@lougher.demon.co.uk>, "'Gunho Lee'" <gunho.lee@lge.com>, "'Tim Bird'" <tim.bird@am.sony.com>, linux-embedded@vger.kernel.org, "'Hyo Jun Im'" <hyojun.im@lge.com>
> Date: Tuesday, May 18, 2010, 12:05 AM
> This patch adds LZO compression and
> decompression to Squashfs tools.
> 
> The patch is against the latest cvs version and requires
> the LZO library
> from http://www.oberhumer.com/opensource/lzo.
> 
> Signed-off-by: Chan Jeong <chan.jeong@lge.com>
> ---
>  Makefile      |   20
> +++++++++++
>  compressor.c  |    7 ++++
>  lzo_wrapper.c |   99
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  squashfs_fs.h |    1 
>  4 files changed, 127 insertions(+)
> 
> diff -uprN -x .cvs squashfs-tools.cvs.orig/Makefile
> squashfs-tools.cvs/Makefile
> --- squashfs-tools.cvs.orig/Makefile   
> 2010-05-13 02:17:06.000000000 +0900
> +++ squashfs-tools.cvs/Makefile   
> 2010-05-18 11:36:58.000000000 +0900
> @@ -15,6 +15,18 @@
>  #LZMA_SUPPORT = 1
>  #LZMA_DIR = ../../../LZMA/lzma465
>  
> +#
> +# Building LZO support
> +#
> +# The LZO library (http://www.oberhumer.com/opensource/lzo/)
> is supported.
> +#
> +# To build using the LZO library (2.0.3 used in
> development, other versions may
> +# work) - download, unpack, build and install it,
> uncomment and set LZO_DIR to
> +# installed directory prefix, and uncomment the
> LZO_SUPPORT line below.
> +
> +#LZO_SUPPORT = 1
> +#LZO_DIR = /usr/local
> +
>  #Compression default.
>  COMP_DEFAULT = gzip
>  
> @@ -47,6 +59,14 @@ UNSQUASHFS_OBJS += xz_wrapper.o
>  LIBS += -llzma
>  endif
>  
> +ifdef LZO_SUPPORT
> +CFLAGS += -DLZO_SUPPORT
> +INCLUDEDIR += -I$(LZO_DIR)/include
> +MKSQUASHFS_OBJS += lzo_wrapper.o
> +UNSQUASHFS_OBJS += lzo_wrapper.o
> +LIBS += -L$(LZO_DIR)/lib -llzo2
> +endif
> +
>  .PHONY: all
>  all: mksquashfs unsquashfs
>  
> diff -uprN -x .cvs squashfs-tools.cvs.orig/compressor.c
> squashfs-tools.cvs/compressor.c
> --- squashfs-tools.cvs.orig/compressor.c   
> 2009-08-29 10:05:34.000000000 +0900
> +++ squashfs-tools.cvs/compressor.c   
> 2010-05-18 11:37:46.000000000 +0900
> @@ -29,6 +29,8 @@ extern int gzip_compress(void **, char *
>  extern int gzip_uncompress(char *, char *, int, int, int
> *);
>  extern int lzma_compress(void **, char *, char *, int,
> int, int *);
>  extern int lzma_uncompress(char *, char *, int, int, int
> *);
> +extern int lzo_compress(void **, char *, char *, int, int,
> int *);
> +extern int lzo_uncompress(char *, char *, int, int, int
> *);
>  
>  struct compressor compressor[] = {
>      { gzip_compress, gzip_uncompress,
> ZLIB_COMPRESSION, "gzip", 1 },
> @@ -37,6 +39,11 @@ struct compressor compressor[] = {
>  #else
>      { NULL, NULL, LZMA_COMPRESSION, "lzma",
> 0 },
>  #endif
> +#ifdef LZO_SUPPORT
> +    { lzo_compress, lzo_uncompress,
> LZO_COMPRESSION, "lzo", 1 },
> +#else
> +    { NULL, NULL, LZO_COMPRESSION, "lzo", 0
> },
> +#endif
>      { NULL, NULL , 0, "unknown", 0}
>  };
>  
> diff -uprN -x .cvs squashfs-tools.cvs.orig/lzo_wrapper.c
> squashfs-tools.cvs/lzo_wrapper.c
> --- squashfs-tools.cvs.orig/lzo_wrapper.c   
> 1970-01-01 09:00:00.000000000 +0900
> +++ squashfs-tools.cvs/lzo_wrapper.c   
> 2010-05-18 11:59:30.000000000 +0900
> @@ -0,0 +1,99 @@
> +/*
> + * Copyright (c) 2010 LG Electronics
> + * Chan Jeong <chan.jeong@lge.com>
> + *
> + * This program is free software; you can redistribute it
> and/or
> + * modify it under the terms of the GNU General Public
> License
> + * as published by the Free Software Foundation; either
> version 2,
> + * or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be
> useful,
> + * but WITHOUT ANY WARRANTY; without even the implied
> warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General
> Public License
> + * along with this program; if not, write to the Free
> Software
> + * Foundation, 59 Temple Place - Suite 330, Boston, MA
> 02111-1307, USA.
> + *
> + * lzo_wrapper.c
> + */
> +
> +#include <stdlib.h>
> +#include <string.h>
> +
> +#include <lzo/lzoconf.h>
> +#include <lzo/lzo1x.h>
> +
> +/* worst-case expansion calculation during compression,
> +   see LZO FAQ for more information */
> +#define LZO_OUTPUT_BUFFER_SIZE(size)   
> (size + (size/16) + 64 + 3)
> +
> +int lzo_compress(void **strm, char *d, char *s, int size,
> int block_size,
> +        int *error)
> +{
> +    int res = 0;
> +    lzo_bytep out;
> +    lzo_uint outlen;
> +    lzo_voidp wrkmem;
> +    void **buffers = (void **)*strm;
> +
> +    if(buffers == NULL) {
> +        if((buffers = *strm
> = calloc(2, sizeof(void *))) == NULL)
> +           
> goto malloc_failed;
> +
> +        /* work memory */
> +        if((buffers[0] =
> malloc(LZO1X_1_MEM_COMPRESS)) == NULL)
> +           
> goto malloc_failed;
> +
> +        /* temporal output
> buffer */
> +        if((buffers[1] =
> malloc(LZO_OUTPUT_BUFFER_SIZE(block_size))) == NULL)
> +           
> goto malloc_failed;
> +    }
> +
> +    wrkmem = buffers[0];
> +    out = buffers[1];
> +    res = lzo1x_1_compress((lzo_bytep)s,
> size, out, &outlen, wrkmem);
> +    if(res != LZO_E_OK) {
> +        /*
> +         * All
> other errors return failure, with the compressor
> +         *
> specific error code in *error
> +         */
> +        *error = res;
> +        return -1;
> +    }
> +
> +    if(outlen >= size) {
> +        /*
> +         * Output
> buffer overflow. Return out of buffer space
> +         */
> +        return 0;
> +    }
> +
> +    /*
> +     * Success, return the
> compressed size.
> +     */
> +    memcpy(d, out, outlen);
> +    return outlen;
> +
> +malloc_failed:
> +    if(buffers) {
> +        if(buffers[0]) {
> +           
> free(buffers[0]);
> +        }
> +        free(buffers);
> +    }
> +    return -1;
> +}
> +
> +
> +int lzo_uncompress(char *d, char *s, int size, int
> block_size, int *error)
> +{
> +    int res;
> +    lzo_uint bytes = block_size;
> +    
> +    res = lzo1x_decompress((lzo_bytep)s,
> size, (lzo_bytep)d, &bytes, NULL);
> +
> +    *error = res;
> +    return res == LZO_E_OK ? bytes : -1;
> +}
> diff -uprN -x .cvs squashfs-tools.cvs.orig/squashfs_fs.h
> squashfs-tools.cvs/squashfs_fs.h
> --- squashfs-tools.cvs.orig/squashfs_fs.h   
> 2010-05-13 04:28:38.000000000 +0900
> +++ squashfs-tools.cvs/squashfs_fs.h   
> 2010-05-18 11:43:22.000000000 +0900
> @@ -238,6 +238,7 @@ typedef long long   
>     squashfs_inode_t;
>  
>  #define ZLIB_COMPRESSION    1
>  #define LZMA_COMPRESSION    2
> +#define LZO_COMPRESSION   
>     3
>  
>  struct squashfs_super_block {
>      unsigned int   
>     s_magic;
> 
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Squashfs-devel mailing list
> Squashfs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/squashfs-devel
> 


      

^ permalink raw reply

* Squashfs extended attribute file system support
From: Phillip Lougher @ 2010-05-19  3:41 UTC (permalink / raw)
  To: Linux Embedded Maillist; +Cc: Phillip Lougher

Hi,

As promised way back in 2008, I have finished xattr support for Squashfs.

Xattr layout highlights

1. Layout can store up to 2^48 bytes of compressed xattr data.
2. Number of xattrs per inode unlimited.
3. Total size of xattr data per inode 2^48 bytes of compressed data.
4. Up to 4 Gbytes of data per xattr value.
5. Inline and out-of-line xattr values supported for higher performance
    in xattr scanning (listxattr & getxattr), and to allow xattr value
    de-duplication.
6. Both whole inode xattr duplicate detection and individual xattr value
    duplicate detection supported.  These can obviously nest, file C's
    xattrs can be a complete duplicate of file B, and file B's xattrs
    can be a partial duplicate of file A.
7. Xattr name prefix types stored, allowing the redundant "user.", "trusted."
    etc. characters to be eliminated and more concisely stored.
8. Support for files, directories, symbolic links, device nodes, fifos
    and sockets.

Xattr support for mksquashfs is now in squashfs CVS.  Support for xattrs in
mksquashfs append mode, and in Unsquashfs will be finished ASAP.

The latest version of mksquashfs in CVS can be obtained here

http://sourceforge.net/projects/squashfs/develop

Kernel xattr support is in git, here

git://git.kernel.org/pub/scm/linux/kernel/git/pkl/squashfs-xattr.git master

gitweb http://git.kernel.org/?p=linux/kernel/git/pkl/squashfs-xattr.git;a=summary

Phillip

^ permalink raw reply

* [PATCH 2/2] Squashfs-tools: add LZO support
From: Chan Jeong @ 2010-05-18  4:05 UTC (permalink / raw)
  To: squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: 'Phillip Lougher', 'Gunho Lee',
	'Tim Bird', linux-embedded-u79uwXL29TY76Z2rM5mHXA,
	'Hyo Jun Im'

This patch adds LZO compression and decompression to Squashfs tools.

The patch is against the latest cvs version and requires the LZO library
from http://www.oberhumer.com/opensource/lzo.

Signed-off-by: Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
---
 Makefile      |   20 +++++++++++
 compressor.c  |    7 ++++
 lzo_wrapper.c |   99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 squashfs_fs.h |    1 
 4 files changed, 127 insertions(+)

diff -uprN -x .cvs squashfs-tools.cvs.orig/Makefile squashfs-tools.cvs/Makefile
--- squashfs-tools.cvs.orig/Makefile	2010-05-13 02:17:06.000000000 +0900
+++ squashfs-tools.cvs/Makefile	2010-05-18 11:36:58.000000000 +0900
@@ -15,6 +15,18 @@
 #LZMA_SUPPORT = 1
 #LZMA_DIR = ../../../LZMA/lzma465
 
+#
+# Building LZO support
+#
+# The LZO library (http://www.oberhumer.com/opensource/lzo/) is supported.
+#
+# To build using the LZO library (2.0.3 used in development, other versions may
+# work) - download, unpack, build and install it, uncomment and set LZO_DIR to
+# installed directory prefix, and uncomment the LZO_SUPPORT line below.
+
+#LZO_SUPPORT = 1
+#LZO_DIR = /usr/local
+
 #Compression default.
 COMP_DEFAULT = gzip
 
@@ -47,6 +59,14 @@ UNSQUASHFS_OBJS += xz_wrapper.o
 LIBS += -llzma
 endif
 
+ifdef LZO_SUPPORT
+CFLAGS += -DLZO_SUPPORT
+INCLUDEDIR += -I$(LZO_DIR)/include
+MKSQUASHFS_OBJS += lzo_wrapper.o
+UNSQUASHFS_OBJS += lzo_wrapper.o
+LIBS += -L$(LZO_DIR)/lib -llzo2
+endif
+
 .PHONY: all
 all: mksquashfs unsquashfs
 
diff -uprN -x .cvs squashfs-tools.cvs.orig/compressor.c squashfs-tools.cvs/compressor.c
--- squashfs-tools.cvs.orig/compressor.c	2009-08-29 10:05:34.000000000 +0900
+++ squashfs-tools.cvs/compressor.c	2010-05-18 11:37:46.000000000 +0900
@@ -29,6 +29,8 @@ extern int gzip_compress(void **, char *
 extern int gzip_uncompress(char *, char *, int, int, int *);
 extern int lzma_compress(void **, char *, char *, int, int, int *);
 extern int lzma_uncompress(char *, char *, int, int, int *);
+extern int lzo_compress(void **, char *, char *, int, int, int *);
+extern int lzo_uncompress(char *, char *, int, int, int *);
 
 struct compressor compressor[] = {
 	{ gzip_compress, gzip_uncompress, ZLIB_COMPRESSION, "gzip", 1 },
@@ -37,6 +39,11 @@ struct compressor compressor[] = {
 #else
 	{ NULL, NULL, LZMA_COMPRESSION, "lzma", 0 },
 #endif
+#ifdef LZO_SUPPORT
+	{ lzo_compress, lzo_uncompress, LZO_COMPRESSION, "lzo", 1 },
+#else
+	{ NULL, NULL, LZO_COMPRESSION, "lzo", 0 },
+#endif
 	{ NULL, NULL , 0, "unknown", 0}
 };
 
diff -uprN -x .cvs squashfs-tools.cvs.orig/lzo_wrapper.c squashfs-tools.cvs/lzo_wrapper.c
--- squashfs-tools.cvs.orig/lzo_wrapper.c	1970-01-01 09:00:00.000000000 +0900
+++ squashfs-tools.cvs/lzo_wrapper.c	2010-05-18 11:59:30.000000000 +0900
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2010 LG Electronics
+ * Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * lzo_wrapper.c
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <lzo/lzoconf.h>
+#include <lzo/lzo1x.h>
+
+/* worst-case expansion calculation during compression,
+   see LZO FAQ for more information */
+#define LZO_OUTPUT_BUFFER_SIZE(size)	(size + (size/16) + 64 + 3)
+
+int lzo_compress(void **strm, char *d, char *s, int size, int block_size,
+		int *error)
+{
+	int res = 0;
+	lzo_bytep out;
+	lzo_uint outlen;
+	lzo_voidp wrkmem;
+	void **buffers = (void **)*strm;
+
+	if(buffers == NULL) {
+		if((buffers = *strm = calloc(2, sizeof(void *))) == NULL)
+			goto malloc_failed;
+
+		/* work memory */
+		if((buffers[0] = malloc(LZO1X_1_MEM_COMPRESS)) == NULL)
+			goto malloc_failed;
+
+		/* temporal output buffer */
+		if((buffers[1] = malloc(LZO_OUTPUT_BUFFER_SIZE(block_size))) == NULL)
+			goto malloc_failed;
+	}
+
+	wrkmem = buffers[0];
+	out = buffers[1];
+	res = lzo1x_1_compress((lzo_bytep)s, size, out, &outlen, wrkmem);
+	if(res != LZO_E_OK) {
+		/*
+		 * All other errors return failure, with the compressor
+		 * specific error code in *error
+		 */
+		*error = res;
+		return -1;
+	}
+
+	if(outlen >= size) {
+		/*
+		 * Output buffer overflow. Return out of buffer space
+		 */
+		return 0;
+	}
+
+	/*
+	 * Success, return the compressed size.
+	 */
+	memcpy(d, out, outlen);
+	return outlen;
+
+malloc_failed:
+	if(buffers) {
+		if(buffers[0]) {
+			free(buffers[0]);
+		}
+		free(buffers);
+	}
+	return -1;
+}
+
+
+int lzo_uncompress(char *d, char *s, int size, int block_size, int *error)
+{
+	int res;
+	lzo_uint bytes = block_size;
+	
+	res = lzo1x_decompress((lzo_bytep)s, size, (lzo_bytep)d, &bytes, NULL);
+
+	*error = res;
+	return res == LZO_E_OK ? bytes : -1;
+}
diff -uprN -x .cvs squashfs-tools.cvs.orig/squashfs_fs.h squashfs-tools.cvs/squashfs_fs.h
--- squashfs-tools.cvs.orig/squashfs_fs.h	2010-05-13 04:28:38.000000000 +0900
+++ squashfs-tools.cvs/squashfs_fs.h	2010-05-18 11:43:22.000000000 +0900
@@ -238,6 +238,7 @@ typedef long long		squashfs_inode_t;
 
 #define ZLIB_COMPRESSION	1
 #define LZMA_COMPRESSION	2
+#define LZO_COMPRESSION		3
 
 struct squashfs_super_block {
 	unsigned int		s_magic;


------------------------------------------------------------------------------

^ permalink raw reply

* [PATCH 1/2] Squashfs: add LZO decompression support
From: Chan Jeong @ 2010-05-18  3:55 UTC (permalink / raw)
  To: squashfs-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: 'Phillip Lougher', 'Gunho Lee',
	'Tim Bird', linux-embedded-u79uwXL29TY76Z2rM5mHXA,
	'Hyo Jun Im'

Hi,

This patch series adds LZO decompression support to Squashfs,
using in-kernel LZO decompression library and Squashfs 
decompressor entries.

The patch series also includes LZO support for Squashfs tools.

Signed-off-by: Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
---
 fs/squashfs/Kconfig        |    5 ++
 fs/squashfs/Makefile       |    1 +
 fs/squashfs/decompressor.c |    6 ++
 fs/squashfs/lzo_wrapper.c  |  144 ++++++++++++++++++++++++++++++++++++++++++++
 fs/squashfs/squashfs.h     |    3 +
 5 files changed, 159 insertions(+), 0 deletions(-)

diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig
index 25a00d1..79e3ca4 100644
--- a/fs/squashfs/Kconfig
+++ b/fs/squashfs/Kconfig
@@ -26,6 +26,11 @@ config SQUASHFS
 
 	  If unsure, say N.
 
+config SQUASHFS_LZO
+	bool "Include support for LZO compressed file systems"
+	depends on SQUASHFS
+	select LZO_DECOMPRESS
+
 config SQUASHFS_EMBEDDED
 
 	bool "Additional option for memory-constrained systems" 
diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
index df8a19e..4dd3e14 100644
--- a/fs/squashfs/Makefile
+++ b/fs/squashfs/Makefile
@@ -5,3 +5,4 @@
 obj-$(CONFIG_SQUASHFS) += squashfs.o
 squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
 squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o
+squashfs-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
diff --git a/fs/squashfs/decompressor.c b/fs/squashfs/decompressor.c
index 157478d..24af9ce 100644
--- a/fs/squashfs/decompressor.c
+++ b/fs/squashfs/decompressor.c
@@ -40,9 +40,11 @@ static const struct squashfs_decompressor squashfs_lzma_unsupported_comp_ops = {
 	NULL, NULL, NULL, LZMA_COMPRESSION, "lzma", 0
 };
 
+#ifndef CONFIG_SQUASHFS_LZO
 static const struct squashfs_decompressor squashfs_lzo_unsupported_comp_ops = {
 	NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0
 };
+#endif
 
 static const struct squashfs_decompressor squashfs_unknown_comp_ops = {
 	NULL, NULL, NULL, 0, "unknown", 0
@@ -51,7 +53,11 @@ static const struct squashfs_decompressor squashfs_unknown_comp_ops = {
 static const struct squashfs_decompressor *decompressor[] = {
 	&squashfs_zlib_comp_ops,
 	&squashfs_lzma_unsupported_comp_ops,
+#ifdef CONFIG_SQUASHFS_LZO
+	&squashfs_lzo_comp_ops,
+#else
 	&squashfs_lzo_unsupported_comp_ops,
+#endif
 	&squashfs_unknown_comp_ops
 };
 
diff --git a/fs/squashfs/lzo_wrapper.c b/fs/squashfs/lzo_wrapper.c
new file mode 100644
index 0000000..6577cfa
--- /dev/null
+++ b/fs/squashfs/lzo_wrapper.c
@@ -0,0 +1,144 @@
+/*
+ * Squashfs - a compressed read only filesystem for Linux
+ *
+ * Copyright (c) 2010 LG Electronics
+ * Chan Jeong <chan.jeong-Hm3cg6mZ9cc@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * lzo_wrapper.c
+ */
+
+#include <linux/mutex.h>
+#include <linux/buffer_head.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/lzo.h>
+
+#include "squashfs_fs.h"
+#include "squashfs_fs_sb.h"
+#include "squashfs_fs_i.h"
+#include "squashfs.h"
+#include "decompressor.h"
+
+
+static void *lzo_init(struct squashfs_sb_info *msblk)
+{
+	void **streams;
+
+	streams = (void **)kmalloc(sizeof(void *) * 2, GFP_KERNEL);
+	if (streams == NULL)
+		goto failed;
+
+	/* input workspace */
+	streams[0] = vmalloc(msblk->block_size);
+	if (streams[0] == NULL)
+		goto failed;
+
+	/* output workspace */
+	streams[1] = vmalloc(msblk->block_size);
+	if (streams[1] == NULL)
+		goto failed;
+
+	return streams;
+
+failed:
+	ERROR("Failed to allocate lzo workspace\n");
+	if (streams) {
+		if (streams[0])
+			vfree(streams[0]);
+		kfree(streams);
+	}
+	return NULL;
+}
+
+
+static void lzo_free(void *stream)
+{
+	void **streams = (void **)stream;
+	vfree(streams[1]);
+	vfree(streams[0]);
+	kfree(streams);
+}
+
+
+static int lzo_uncompress(struct squashfs_sb_info *msblk, void **buffer,
+	struct buffer_head **bh, int b, int offset, int length, int srclength,
+	int pages)
+{
+	int lzo_err;
+	int avail, bytes, k = 0, page;
+	void **streams = (void **)msblk->stream;
+	void *in;
+
+	mutex_lock(&msblk->read_data_mutex);
+
+	bytes = length;
+	in = streams[0];
+	while (k < b) {
+		avail = min(bytes, msblk->devblksize - offset);
+		bytes -= avail;
+		wait_on_buffer(bh[k]);
+		if (!buffer_uptodate(bh[k]))
+			goto release_mutex;
+
+		if (k == 0 && avail == 0) {
+			offset = 0;
+			put_bh(bh[k++]);
+			continue;
+		}
+
+		memcpy(in, bh[k]->b_data + offset, avail);
+		in += avail;
+		offset = 0;
+		put_bh(bh[k++]);
+	}
+
+	bytes = in - streams[0];
+	length = msblk->block_size;
+	lzo_err = lzo1x_decompress_safe(streams[0], bytes, streams[1], &length);
+	if (lzo_err != LZO_E_OK)
+		goto release_mutex;
+
+	bytes = length;
+	in = streams[1];
+	page = 0;
+	while (page < pages && bytes > 0) {
+		avail = min((int)PAGE_CACHE_SIZE, bytes);
+		memcpy(buffer[page++], in, avail);
+		in += avail;
+		bytes -= avail;
+	}
+
+	mutex_unlock(&msblk->read_data_mutex);
+	return length;
+
+release_mutex:
+	mutex_unlock(&msblk->read_data_mutex);
+
+	for (; k < b; k++)
+		put_bh(bh[k]);
+
+	return -EIO;
+}
+
+const struct squashfs_decompressor squashfs_lzo_comp_ops = {
+	.init = lzo_init,
+	.free = lzo_free,
+	.decompress = lzo_uncompress,
+	.id = LZO_COMPRESSION,
+	.name = "lzo",
+	.supported = 1
+};
diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h
index fe2587a..1f0ee85 100644
--- a/fs/squashfs/squashfs.h
+++ b/fs/squashfs/squashfs.h
@@ -94,3 +94,6 @@ extern const struct address_space_operations squashfs_symlink_aops;
 
 /* zlib_wrapper.c */
 extern const struct squashfs_decompressor squashfs_zlib_comp_ops;
+
+/* lzo_wrappers.c */
+extern const struct squashfs_decompressor squashfs_lzo_comp_ops;


------------------------------------------------------------------------------

^ permalink raw reply related

* [PATCH] detour TTY driver
From: Samo Pogacnik @ 2010-05-15 10:17 UTC (permalink / raw)
  To: linux-embedded; +Cc: linux kernel

Hi,

Here is the initial suggestion for a simple detour TTY driver, which
provides the ability to write user messages through printk. This allows
user output to be inlined with kernel output. Together with printk
time-stamping enabled, a detailed boot sequence analyses is possible.
Additionally, console logs could have been stored through the same
mechanism as kernel messages and does not require the system logger to
be started very/too soon.

regards, Samo

---
Signed-off-by: Samo Pogacnik <samo_pogacnik@t-2.net>
diff --git a_linux-2.6.33.3/Documentation/devices.txt b_linux-2.6.33.3/Documentation/devices.txt
index 53d64d3..f889097 100644
--- a_linux-2.6.33.3/Documentation/devices.txt
+++ b_linux-2.6.33.3/Documentation/devices.txt
@@ -239,6 +239,7 @@ Your cooperation is appreciated.
 		  0 = /dev/tty		Current TTY device
 		  1 = /dev/console	System console
 		  2 = /dev/ptmx		PTY master multiplex
+		  3 = /dev/detour	Detour via printk TTY device
 		 64 = /dev/cua0		Callout device for ttyS0
 		    ...
 		255 = /dev/cua191	Callout device for ttyS191
diff --git a_linux-2.6.33.3/drivers/char/Kconfig b_linux-2.6.33.3/drivers/char/Kconfig
index e023682..4d21e2d 100644
--- a_linux-2.6.33.3/drivers/char/Kconfig
+++ b_linux-2.6.33.3/drivers/char/Kconfig
@@ -485,6 +485,20 @@ config LEGACY_PTY_COUNT
 	  When not in use, each legacy PTY occupies 12 bytes on 32-bit
 	  architectures and 24 bytes on 64-bit architectures.
 
+config DETOUR_TTY
+	bool "TTY driver to detour user output via printk"
+	default n
+	---help---
+	  If you say Y here, the support for writing user messages (i.e.
+	  console messages) via printk is available.
+
+	  The feature is useful to inline user messages with kernel
+	  messages.
+	  In order to use this feature, you should output user messages
+	  to /dev/detour.
+
+	  If unsure, say N.
+
 config BRIQ_PANEL
 	tristate 'Total Impact briQ front panel driver'
 	depends on PPC_CHRP
diff --git a_linux-2.6.33.3/drivers/char/Makefile b_linux-2.6.33.3/drivers/char/Makefile
index f957edf..b84db55 100644
--- a_linux-2.6.33.3/drivers/char/Makefile
+++ b_linux-2.6.33.3/drivers/char/Makefile
@@ -11,6 +11,7 @@ obj-y	 += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o tty_buffer.o t
 
 obj-$(CONFIG_LEGACY_PTYS)	+= pty.o
 obj-$(CONFIG_UNIX98_PTYS)	+= pty.o
+obj-$(CONFIG_DETOUR_TTY)	+= dty.o
 obj-y				+= misc.o
 obj-$(CONFIG_VT)		+= vt_ioctl.o vc_screen.o selection.o keyboard.o
 obj-$(CONFIG_BFIN_JTAG_COMM)	+= bfin_jtag_comm.o
diff --git a_linux-2.6.33.3/drivers/char/dty.c b_linux-2.6.33.3/drivers/char/dty.c
new file mode 100644
index 0000000..3ffe248
--- /dev/null
+++ b_linux-2.6.33.3/drivers/char/dty.c
@@ -0,0 +1,137 @@
+/*
+ *  linux/drivers/char/detour.c
+ *
+ *  Copyright (C) 2010  Samo Pogacnik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the smems of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+/*
+ * This pseudo device allows user to make printk messages. It is possible
+ * to store "console" messages inline with kernel messages for better analyses
+ * of the boot process, for example.
+ */
+
+#include <linux/device.h>
+#include <linux/tty.h>
+
+static struct tty_driver *dty_driver;
+
+static const char *detour_tag = "[D] ";
+#define DETOUR_STR_SIZE 508
+
+/*
+ *	Our simple preformatting:
+ *	- every cr is replaced by '^'nl combination
+ *	- every non cr or nl ended write is padded with '\'nl combination
+ *	- adds a detour source tag in front of each line
+ *
+ * 	This is useful for logging purposes (kind of a logging ldisc?).
+ */
+static void detour_printk(const unsigned char *buf, int count)
+{
+	static char tmp[DETOUR_STR_SIZE + 4];
+	static int curr;
+	int i;
+
+	for (i = 0; i < count; i++) {
+		tmp[curr] = buf[i];
+		if (curr < DETOUR_STR_SIZE) {
+			switch (buf[i]) {
+			case '\r':
+				tmp[curr] = '^';
+				tmp[curr + 1] = '\n';
+				tmp[curr + 2] = '\0';
+				printk(KERN_INFO "%s%s", detour_tag, tmp);
+				curr = 0;
+				if (buf[i + 1] == '\n')
+					i++;
+				break;
+			case '\n':
+				tmp[curr + 1] = '\0';
+				printk(KERN_INFO "%s%s", detour_tag, tmp);
+				curr = 0;
+				break;
+			default:
+				curr++;
+			}
+		} else {
+			/* end of tmp buffer reached: cut the message in two */
+			tmp[curr + 1] = '\\';
+			tmp[curr + 2] = '\n';
+			tmp[curr + 3] = '\0';
+			printk(KERN_INFO "%s%s", detour_tag, tmp);
+			curr = 0;
+		}
+	}
+	if (curr > 0) {
+		/* non nl or cr terminated message */
+		tmp[curr + 0] = '\\';
+		tmp[curr + 1] = '\n';
+		tmp[curr + 2] = '\0';
+		printk(KERN_INFO "%s%s", detour_tag, tmp);
+		curr = 0;
+	}
+}
+
+/*
+ *	Dummy tty ops open for succesfull terminal device open.
+ */
+static int dty_open(struct tty_struct *tty, struct file *filp)
+{
+	return 0;
+}
+
+/*
+ *	File ops (not tty ops) write avoids ldisc inserting additional CRs.
+ *	We simply throw this to our preformatter, which calls printk.
+ */
+static ssize_t detour_write(struct file *file, const char __user *buf,
+	size_t count, loff_t *ppos)
+{
+	detour_printk(buf, count);
+	return count;
+}
+
+static const struct tty_operations dty_ops = {
+	.open = dty_open,
+};
+
+static struct file_operations detour_fops;
+
+static int __init dty_init(void)
+{
+	dty_driver = alloc_tty_driver(1);
+	if (!dty_driver)
+		panic("Couldn't allocate pty driver");
+
+	dty_driver->owner = THIS_MODULE;
+	dty_driver->driver_name = "dty";
+	dty_driver->name = "detour";
+	dty_driver->major = TTYAUX_MAJOR;
+	dty_driver->minor_start = 3;
+	dty_driver->num = 1;
+	dty_driver->type = TTY_DRIVER_TYPE_CONSOLE;
+	dty_driver->init_termios = tty_std_termios;
+	dty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
+		TTY_DRIVER_DYNAMIC_DEV;
+	tty_set_operations(dty_driver, &dty_ops);
+
+	if (tty_register_driver(dty_driver))
+		panic("Couldn't register dty driver");
+
+	/* register our fops write function */
+	tty_default_fops(&detour_fops);
+	detour_fops.write = detour_write;
+
+	cdev_init(&dty_driver->cdev, &detour_fops);
+
+	/* create our unnumbered device */
+	device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 3), NULL,
+		dty_driver->name);
+
+	return 0;
+}
+module_init(dty_init);
 

^ permalink raw reply related

* [PATCH] tagged console logging detour via printk
From: Samo Pogacnik @ 2010-05-10 17:02 UTC (permalink / raw)
  To: linux-embedded; +Cc: linux kernel

Hi,

This version of console detour patch provides tagging of console
messages, when sent to printk. This may result in logs like this:
...
May  6 22:41:27 lap1 kernel: [    1.092979] Freeing unused kernel memory: 548k freed
May  6 22:41:27 lap1 kernel: [    1.094503] Write protecting the kernel text: 3564k
May  6 22:41:27 lap1 kernel: [    1.094739] Write protecting the kernel read-only data: 1736k
May  6 22:41:27 lap1 kernel: [C][    1.099902] Mounting proc filesystem
May  6 22:41:27 lap1 kernel: [C][    1.100165] Mounting sysfs filesystem
May  6 22:41:27 lap1 kernel: [C][    1.100440] Creating /dev
May  6 22:41:27 lap1 kernel: [C][    1.101835] Creating initial device nodes
...
...
May  6 22:41:27 lap1 kernel: [C][   25.313917] Bringing up interface eth0:  \
May  6 22:41:27 lap1 kernel: [   25.433672] eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
May  6 22:41:27 lap1 kernel: [C][   30.863244] ESC[60G\
May  6 22:41:27 lap1 kernel: [C][   30.863319] [\
May  6 22:41:27 lap1 kernel: [C][   30.863443] ESC[0;32m\
May  6 22:41:27 lap1 kernel: [C][   30.863499]   OK  \
May  6 22:41:27 lap1 kernel: [C][   30.863617] ESC[0;39m\
May  6 22:41:27 lap1 kernel: [C][   30.863663] ]\
May  6 22:41:27 lap1 kernel: [C][   30.863710] ^
...
May  6 22:41:27 lap1 kernel: [C][   31.327576] Starting system logger: \
...

It would have been possible for the system logger to use the console tag
and replace the "kernel" with e.g. "console" word for console messages.
The other thing the system logger could do is to fix its time stamps for
messages generated before logger start-up based on printk time stamp
(see the last message in the example log)...

regards, 
Samo

p.s.
I'll provide also an independent detour tty driver as Alan suggested.

---
Signed-off-by: Samo Pogacnik <samo_pogacnik@t-2.net>
diff --git a_linux-2.6.33.3/Documentation/kernel-parameters.txt b_linux-2.6.33.3/Documentation/kernel-parameters.txt
index e2c7487..ab0072c 100644
--- a_linux-2.6.33.3/Documentation/kernel-parameters.txt
+++ b_linux-2.6.33.3/Documentation/kernel-parameters.txt
@@ -628,6 +628,8 @@ and is between 256 and 4096 characters. It is defined in the file
 			Defaults to the default architecture's huge page size
 			if not specified.
 
+	detour		[KNL] Enable console logging detour via printk.
+
 	dhash_entries=	[KNL]
 			Set number of hash buckets for dentry cache.
 
diff --git a_linux-2.6.33.3/drivers/char/Kconfig b_linux-2.6.33.3/drivers/char/Kconfig
index e023682..43c552e 100644
--- a_linux-2.6.33.3/drivers/char/Kconfig
+++ b_linux-2.6.33.3/drivers/char/Kconfig
@@ -88,6 +88,22 @@ config VT_HW_CONSOLE_BINDING
 	 information. For framebuffer console users, please refer to
 	 <file:Documentation/fb/fbcon.txt>.
 
+config CONSOLE_DETOUR
+	bool "Support for console detour via printk"
+	default n
+	---help---
+	  If you say Y here, the support for writing console messages via
+	  printk is included into the console code.
+
+	  The feature is useful to catch all console log messages.
+	  In order to use this feature, you should specify kernel command line
+	  option "detour" or write a positive number into
+	  /proc/sys/kernel/console_detour. You can disable the feature on-line
+	  by writing zero into the proc file. By writing a negative value into
+	  the proc file, the feature is disabled permanently (until next boot).
+
+	  If unsure, say N.
+
 config DEVKMEM
 	bool "/dev/kmem virtual device support"
 	default y
diff --git a_linux-2.6.33.3/drivers/char/tty_io.c b_linux-2.6.33.3/drivers/char/tty_io.c
index 76253cf..f77de34 100644
--- a_linux-2.6.33.3/drivers/char/tty_io.c
+++ b_linux-2.6.33.3/drivers/char/tty_io.c
@@ -1087,6 +1087,13 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf,
 	}
 	spin_unlock(&redirect_lock);
 
+#ifdef CONFIG_CONSOLE_DETOUR
+	if (console_detour) {
+		console_printk_detour(buf, count);
+		if (!p)
+			return count;
+	}
+#endif
 	if (p) {
 		ssize_t res;
 		res = vfs_write(p, buf, count, &p->f_pos);
diff --git a_linux-2.6.33.3/include/linux/console.h b_linux-2.6.33.3/include/linux/console.h
index dcca533..354a7a8 100644
--- a_linux-2.6.33.3/include/linux/console.h
+++ b_linux-2.6.33.3/include/linux/console.h
@@ -108,6 +108,13 @@ struct console {
 	struct	 console *next;
 };
 
+extern int console_detour;
+extern void console_printk_detour(const unsigned char *buf, int count);
+
+struct ctl_table;
+int detour_sysctl_handler(struct ctl_table *table, int write,
+		void __user *buffer, size_t *length, loff_t *ppos);
+
 extern int console_set_on_cmdline;
 
 extern int add_preferred_console(char *name, int idx, char *options);
diff --git a_linux-2.6.33.3/init/main.c b_linux-2.6.33.3/init/main.c
index 512ba15..add9e95 100644
--- a_linux-2.6.33.3/init/main.c
+++ b_linux-2.6.33.3/init/main.c
@@ -25,6 +25,7 @@
 #include <linux/bootmem.h>
 #include <linux/acpi.h>
 #include <linux/tty.h>
+#include <linux/console.h>
 #include <linux/gfp.h>
 #include <linux/percpu.h>
 #include <linux/kmod.h>
@@ -249,6 +250,14 @@ static int __init loglevel(char *str)
 
 early_param("loglevel", loglevel);
 
+static int __init detour(char *str)
+{
+	console_detour = 1;
+	return 0;
+}
+
+early_param("detour", detour);
+
 /*
  * Unknown boot options get handed to init, unless they look like
  * unused parameters (modprobe will find them in /proc/cmdline).
diff --git a_linux-2.6.33.3/kernel/printk.c b_linux-2.6.33.3/kernel/printk.c
index 1751c45..9897ecb 100644
--- a_linux-2.6.33.3/kernel/printk.c
+++ b_linux-2.6.33.3/kernel/printk.c
@@ -655,6 +655,8 @@ static int recursion_bug;
 static int new_text_line = 1;
 static char printk_buf[1024];
 
+static const char *detour_tag = "[C]";
+
 int printk_delay_msec __read_mostly;
 
 static inline void printk_delay(void)
@@ -753,6 +755,15 @@ asmlinkage int vprintk(const char *fmt, va_list args)
 			printed_len += 3;
 			new_text_line = 0;
 
+			if ((p[0] == detour_tag[0]) &&
+			    (p[1] == detour_tag[1]) &&
+			    (p[2] == detour_tag[2])) {
+				int i;
+
+				for (i = 0; i < 3; i++, p++)
+					emit_log_char(*p);
+			}
+
 			if (printk_time) {
 				/* Follow the token with the time */
 				char tbuf[50], *tp;
@@ -1368,6 +1379,80 @@ static int __init disable_boot_consoles(void)
 }
 late_initcall(disable_boot_consoles);
 
+/*
+ * This option can be enabled with kernel command line option "detour" or
+ * through a proc file (/proc/sys/kernel/console_detour). It enables console
+ * logging through printk, if supported by enabled console.
+ */
+int console_detour;
+EXPORT_SYMBOL(console_detour);
+
+#define DETOUR_STR_SIZE 508
+void console_printk_detour(const unsigned char *buf, int count)
+{
+	static char tmp[DETOUR_STR_SIZE + 4];
+	static int curr;
+	int i;
+
+	for (i = 0; i < count; i++) {
+		tmp[curr] = buf[i];
+		if (curr < DETOUR_STR_SIZE) {
+			switch (buf[i]) {
+			case '\r':
+				tmp[curr] = '^';
+				tmp[curr + 1] = '\n';
+				tmp[curr + 2] = '\0';
+				printk(KERN_INFO "%s%s", detour_tag, tmp);
+				curr = 0;
+				if (buf[i + 1] == '\n')
+					i++;
+				break;
+			case '\n':
+				tmp[curr + 1] = '\0';
+				printk(KERN_INFO "%s%s", detour_tag, tmp);
+				curr = 0;
+				break;
+			default:
+				curr++;
+			}
+		} else {
+			/* end of tmp buffer reached: cut the message in two */
+			tmp[curr + 1] = '\\';
+			tmp[curr + 2] = '\n';
+			tmp[curr + 3] = '\0';
+			printk(KERN_INFO "%s%s", detour_tag, tmp);
+			curr = 0;
+		}
+	}
+	if (curr > 0) {
+		/* not nl or cr terminated message */
+		tmp[curr + 0] = '\\';
+		tmp[curr + 1] = '\n';
+		tmp[curr + 2] = '\0';
+		printk(KERN_INFO "%s%s", detour_tag, tmp);
+		curr = 0;
+	}
+}
+EXPORT_SYMBOL(console_printk_detour);
+
+int detour_sysctl_handler(struct ctl_table *table, int write,
+	void __user *buffer, size_t *length, loff_t *ppos)
+{
+	static int disable_forever;
+
+	proc_dointvec(table, write, buffer, length, ppos);
+	if (write) {
+		if ((console_detour < 0) || (disable_forever != 0)) {
+			disable_forever = 1;
+			console_detour = 0;
+			return 0;
+		}
+		if (console_detour > 1)
+			console_detour = 1;
+	}
+	return 0;
+}
+
 #if defined CONFIG_PRINTK
 
 /*
diff --git a_linux-2.6.33.3/kernel/sysctl.c b_linux-2.6.33.3/kernel/sysctl.c
index 8a68b24..ab644cb 100644
--- a_linux-2.6.33.3/kernel/sysctl.c
+++ b_linux-2.6.33.3/kernel/sysctl.c
@@ -50,6 +50,7 @@
 #include <linux/ftrace.h>
 #include <linux/slow-work.h>
 #include <linux/perf_event.h>
+#include <linux/console.h>
 
 #include <asm/uaccess.h>
 #include <asm/processor.h>
@@ -936,6 +937,13 @@ static struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
+	{
+		.procname	= "console_detour",
+		.data		= &console_detour,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &detour_sysctl_handler,
+	},
 /*
  * NOTE: do not add new entries to this table unless you have read
  * Documentation/sysctl/ctl_unnumbered.txt



^ permalink raw reply related

* [PATCH] ARM: fix 'unannotated irqs-on' lockdep warning
From: tom.leiming @ 2010-05-10 14:27 UTC (permalink / raw)
  To: linux
  Cc: linux-arm-kernel, linux-embedded, a.p.zijlstra, linux-kernel,
	Ming Lei

From: Ming Lei <tom.leiming@gmail.com>

This patch fixes the 'unannotated irqs-on' lockdep warning below:

	CPU: Testing write buffer coherency: ok
	------------[ cut here ]------------
	WARNING: at kernel/lockdep.c:3145 check_flags+0xcc/0x1dc()
	Modules linked in:
	[<c0035120>] (unwind_backtrace+0x0/0xf8) from [<c0355374>] (dump_stack+0x20/0x24)
	[<c0355374>] (dump_stack+0x20/0x24) from [<c0060c04>] (warn_slowpath_common+0x58/0x70)
	[<c0060c04>] (warn_slowpath_common+0x58/0x70) from [<c0060c3c>] (warn_slowpath_null+0x20/0x24)
	[<c0060c3c>] (warn_slowpath_null+0x20/0x24) from [<c008f224>] (check_flags+0xcc/0x1dc)
	[<c008f224>] (check_flags+0xcc/0x1dc) from [<c00945dc>] (lock_acquire+0x50/0x140)
	[<c00945dc>] (lock_acquire+0x50/0x140) from [<c0358434>] (_raw_spin_lock+0x50/0x88)
	[<c0358434>] (_raw_spin_lock+0x50/0x88) from [<c00fd114>] (set_task_comm+0x2c/0x60)
	[<c00fd114>] (set_task_comm+0x2c/0x60) from [<c007e184>] (kthreadd+0x30/0x108)
	[<c007e184>] (kthreadd+0x30/0x108) from [<c0030104>] (kernel_thread_exit+0x0/0x8)
	---[ end trace 1b75b31a2719ed1c ]---
	possible reason: unannotated irqs-on.
	irq event stamp: 3
	hardirqs last  enabled at (2): [<c0059bb0>] finish_task_switch+0x48/0xb0
	hardirqs last disabled at (3): [<c002f0b0>] ret_slow_syscall+0xc/0x1c
	softirqs last  enabled at (0): [<c005f3e0>] copy_process+0x394/0xe5c
	softirqs last disabled at (0): [<(null)>] (null)

This patch introduces macro of trace_ret_hardirqs_on, which will
call trace_hardirqs_on if I flag in the stored CPSR is zero.

In the path of returning to user-space, the patch replaces disable_irq
with disable_irq_notrace in ret_to_user to avoid the 'unannotated irqs-on'
lockdep warning since hardirqs is always enabled before returning to user.

In the path of returning to kernel-space, the patch still replaces
disable_irq with disable_irq_notrace in __xxx_svc handler and adds
trace_hardirqs_on before calling svc_exit to trace the possible hardirqs on
event for avoiding the possible 'unannotated irqs-on' lockdep warning.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 arch/arm/kernel/entry-armv.S   |   31 +++++++++++++++++--------------
 arch/arm/kernel/entry-common.S |    2 +-
 arch/arm/kernel/entry-header.S |    7 +++++++
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index e6a0fb0..7202adf 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -204,13 +204,15 @@ __dabt_svc:
 	@
 	@ IRQs off again before pulling preserved data off the stack
 	@
-	disable_irq
+	disable_irq_notrace
 
 	@
 	@ restore SPSR and restart the instruction
+	@ trace possible hardirqs on event before returning
 	@
-	ldr	r2, [sp, #S_PSR]
-	svc_exit r2				@ return from exception
+	ldr	r4, [sp, #S_PSR]
+	trace_ret_hardirqs_on r4
+	svc_exit r4				@ return from exception
  UNWIND(.fnend		)
 ENDPROC(__dabt_svc)
 
@@ -235,10 +237,7 @@ __irq_svc:
 	blne	svc_preempt
 #endif
 	ldr	r4, [sp, #S_PSR]		@ irqs are already disabled
-#ifdef CONFIG_TRACE_IRQFLAGS
-	tst	r4, #PSR_I_BIT
-	bleq	trace_hardirqs_on
-#endif
+	trace_ret_hardirqs_on r4
 	svc_exit r4				@ return from exception
  UNWIND(.fnend		)
 ENDPROC(__irq_svc)
@@ -291,13 +290,15 @@ __und_svc:
 	@
 	@ IRQs off again before pulling preserved data off the stack
 	@
-1:	disable_irq
+1:	disable_irq_notrace
 
 	@
 	@ restore SPSR and restart the instruction
+	@ trace possible hardirqs on event before returning
 	@
-	ldr	r2, [sp, #S_PSR]		@ Get SVC cpsr
-	svc_exit r2				@ return from exception
+	ldr	r4, [sp, #S_PSR]		@ Get SVC cpsr
+	trace_ret_hardirqs_on r4
+	svc_exit r4				@ return from exception
  UNWIND(.fnend		)
 ENDPROC(__und_svc)
 
@@ -327,13 +328,15 @@ __pabt_svc:
 	@
 	@ IRQs off again before pulling preserved data off the stack
 	@
-	disable_irq
+	disable_irq_notrace
 
 	@
 	@ restore SPSR and restart the instruction
-	@
-	ldr	r2, [sp, #S_PSR]
-	svc_exit r2				@ return from exception
+	@ trace possible hardirqs on event before returning
+	@	
+	ldr	r4, [sp, #S_PSR]
+	trace_ret_hardirqs_on r4
+	svc_exit r4				@ return from exception
  UNWIND(.fnend		)
 ENDPROC(__pabt_svc)
 
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 2c1db77..ed471a7 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -58,7 +58,7 @@ work_resched:
  */
 ENTRY(ret_to_user)
 ret_slow_syscall:
-	disable_irq				@ disable interrupts
+	disable_irq_notrace				@ disable interrupts
 	ldr	r1, [tsk, #TI_FLAGS]
 	tst	r1, #_TIF_WORK_MASK
 	bne	work_pending
diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
index d93f976..ac51ce3 100644
--- a/arch/arm/kernel/entry-header.S
+++ b/arch/arm/kernel/entry-header.S
@@ -30,6 +30,13 @@
 #error "Please fix"
 #endif
 
+	.macro trace_ret_hardirqs_on, rspsr
+#ifdef CONFIG_TRACE_IRQFLAGS
+	tst 	\rspsr, #PSR_I_BIT
+	bleq	trace_hardirqs_on
+#endif
+	.endm
+
 	.macro	zero_fp
 #ifdef CONFIG_FRAME_POINTER
 	mov	fp, #0
-- 
1.6.2.5

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox