All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] modpost: Ignore ARC specific non-alloc sections
From: Vineet Gupta @ 2012-12-28  4:42 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Tony Lindgren, linux-kernel, linux-arch
In-Reply-To: <20121227204816.GA2068@merkur.ravnborg.org>

On Friday 28 December 2012 02:18 AM, Sam Ravnborg wrote:
> On Thu, Dec 27, 2012 at 04:17:20PM +0530, Vineet Gupta wrote:
>> ARC relocatable object files contain one/more .gnu.linkonce.arcextmap.*
>> sections (collated by kernel/vmlinux.lds into .arcextmap in final link).
>> This section is used by debuggers to display the extension instructions
>> and need-not be loaded by target (hence !SHF_ALLOC)
>>
>> The final kernel binary only needs .arcextmap entry in modpost's ignore
>> list (section_white_list[]). However when building modules, modpost scans
>> each object file individually, hence tripping on non-aggregated
>> .gnu.linkonce.arcextmap.* entries as well.
> 
> The list exist for this particular purpose.
> So acked.
> 
>>
>> Thus need for the 2 entires !
>>
>> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> 
> 	Sam
> 

Thx,
-Vineet

^ permalink raw reply

* Re: [PATCH] modpost: Ignore ARC specific non-alloc sections
From: Vineet Gupta @ 2012-12-28  4:42 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Tony Lindgren, linux-kernel, linux-arch
In-Reply-To: <20121227204816.GA2068@merkur.ravnborg.org>

On Friday 28 December 2012 02:18 AM, Sam Ravnborg wrote:
> On Thu, Dec 27, 2012 at 04:17:20PM +0530, Vineet Gupta wrote:
>> ARC relocatable object files contain one/more .gnu.linkonce.arcextmap.*
>> sections (collated by kernel/vmlinux.lds into .arcextmap in final link).
>> This section is used by debuggers to display the extension instructions
>> and need-not be loaded by target (hence !SHF_ALLOC)
>>
>> The final kernel binary only needs .arcextmap entry in modpost's ignore
>> list (section_white_list[]). However when building modules, modpost scans
>> each object file individually, hence tripping on non-aggregated
>> .gnu.linkonce.arcextmap.* entries as well.
> 
> The list exist for this particular purpose.
> So acked.
> 
>>
>> Thus need for the 2 entires !
>>
>> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> 
> 	Sam
> 

Thx,
-Vineet

^ permalink raw reply

* Re: mkfs crash
From: Kent Overstreet @ 2012-12-28  4:31 UTC (permalink / raw)
  To: Pim van den Berg; +Cc: linux-bcache-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <50DC3977.2080209-IXGSG4U2CCrz+pZb47iToQ@public.gmane.org>

On Thu, Dec 27, 2012 at 01:05:11PM +0100, Pim van den Berg wrote:
> Hi,
> 
> I'm successfully using bcache on 1 partition of my system for a while
> now. The SSD is split in 2 partitions to be able to enable bcache on
> another partition too.
> 
> The first partition is setup like this:
> /dev/md3 (mdadm, RAID1, bcache backing device)
> - /dev/bcache0
> 
> I tried to setup the second partition like this:
> /dev/md4 (mdadm, RAID1)
> - /dev/dm-0 (luks, bcache backing device)
>   - /dev/bcache3
> 
> All goes well until I try to create an ext4 (or ext3) filesystem on it.
> The mkfs command crashes and couple of 1000 lines show up in my syslog
> (the full log is over here:
> http://pommi.nethuis.nl/storage/software/bcache/log/mkfs-crash.log):
> 
> [1631972.332656] bcache: Caching dm-0 as bcache3 on set
> 6bc79688-a6e0-4c21-8f44-59b0083b8169
> [1631983.772362] CPU 0
> [1631983.772380] Pid: 28707, comm: mkfs.ext4 Not tainted 3.2.33-kvm
> #1                  /DH67CF
> [1631983.772420] RIP: 0010:[<ffffffff813f91ca>]  [<ffffffff813f91ca>]
> bch_mark_sectors_bypassed+0x1a/0x35
> [1631983.772465] RSP: 0018:ffff880165cadbf8  EFLAGS: 00000a06
> [1631983.772486] RAX: ffff8801128e0010 RBX: ffff880165fd0318 RCX:
> ffff880165cadc30
> [1631983.772521] RDX: 2000000000000000 RSI: 00000000007fffff RDI:
> ffff880165fd0318
> [1631983.772556] RBP: ffff880165cadbf8 R08: ffff88021e802be0 R09:
> 00000000ffffff02
> [1631983.772592] R10: 00000000ffffff01 R11: ffff880165cadc78 R12:
> ffff8801128e0000
> [1631983.772627] R13: ffff880118450000 R14: ffff880165cadc68 R15:
> 0000000000000000
> [1631983.772662] FS:  000067d4ad65e760(0000) GS:ffff88021fa00000(0000)
> knlGS:0000000000000000
> [1631983.772699] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [1631983.772722] CR2: 0000000001958908 CR3: 0000000163c68000 CR4:
> 00000000000406f0
> [1631983.772757] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
> 0000000000000000
> [1631983.772792] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7:
> 0000000000000400
> [1631983.772827] Process mkfs.ext4 (pid: 28707, threadinfo
> ffff880133edacf0, task ffff880133eda800)
> [1631983.772880]  ffff880165cadc48 ffffffff813f08dc 0000001065cadc48
> ffff880163fe0000
> [1631983.772919]  ffff8801128e0000 ffff880165fd0318 ffff8801128e0000
> ffff880165fd0378
> [1631983.772957]  ffff880165cadc68 ffff880165cadc58 ffff880165cadca8
> ffffffff813f1ae0
> [1631983.773015]  [<ffffffff813f08dc>] check_should_skip+0x31f/0x335
> [1631983.773039]  [<ffffffff813f1ae0>] request_write+0x7d/0x267
> [1631983.773061]  [<ffffffff813f1dc8>] cached_dev_make_request+0xfe/0x1ad
> [1631983.773087]  [<ffffffff8127edff>] generic_make_request+0x17c/0x1d2
> [1631983.773110]  [<ffffffff8127ef25>] submit_bio+0xd0/0xdb
> [1631983.773133]  [<ffffffff81284a3d>] blkdev_issue_discard+0x158/0x1a7
> [1631983.773156]  [<ffffffff812850bb>] blkdev_ioctl+0x2f7/0x69c
> [1631983.773180]  [<ffffffff811191f8>] block_ioctl+0x32/0x36
> [1631983.773203]  [<ffffffff810fe7e2>] do_vfs_ioctl+0x5aa/0x5fa
> [1631983.773226]  [<ffffffff810fe874>] sys_ioctl+0x42/0x65
> [1631983.773250]  [<ffffffff815657b6>] system_call_fastpath+0x18/0x1d
> [1631983.773384] Call Trace:
> [1631983.773401]  [<ffffffff813f08dc>] check_should_skip+0x31f/0x335
> [1631983.773424]  [<ffffffff813f1ae0>] request_write+0x7d/0x267
> [1631983.773447]  [<ffffffff813f1dc8>] cached_dev_make_request+0xfe/0x1ad
> [1631983.773470]  [<ffffffff8127edff>] generic_make_request+0x17c/0x1d2
> [1631983.773499]  [<ffffffff8127ef25>] submit_bio+0xd0/0xdb
> [1631983.773520]  [<ffffffff81284a3d>] blkdev_issue_discard+0x158/0x1a7
> [1631983.773544]  [<ffffffff812850bb>] blkdev_ioctl+0x2f7/0x69c
> [1631983.773567]  [<ffffffff811191f8>] block_ioctl+0x32/0x36
> [1631983.773590]  [<ffffffff810fe7e2>] do_vfs_ioctl+0x5aa/0x5fa
> [1631983.773613]  [<ffffffff810fe874>] sys_ioctl+0x42/0x65
> [1631983.773635]  [<ffffffff815657b6>] system_call_fastpath+0x18/0x1d
> 
> I'm using the 3.2.33 Linux kernel with
> grsecurity-2.9.1-3.2.33-201211072000 and bcache v3.2.28-384-gcafb412.
> 
> I've tried to set it up this way multiple times but I hit the same
> problem each time. Because I'm successfully running bcache on a mdadm
> device, I thought there was an issue with the luks part. So I tested
> this part with a USB thumb drive as a backing device:
> 
> /dev/sdd
> - /dev/dm-0 (luks, bcache backing device)
>   - /dev/bcache1
> 
> In this case the bcache device worked without a problem. As you can see
> in the stacktrace, bch_mark_sectors_bypassed (a piece of bcache code)
> causes the crash. Do you know what is going wrong here?

That is _odd_. I'm scratching my head over what could possibly have gone
wrong _there_. bch_mark_sectors_bypassed() doesn't do much, I think the
only thing that _could_ go wrong is derefing a bad pointer but if either
of the pointers it derefs are bad things should've exploded earlier.

Maybe I'm blind but I'm also not seeing what exactly the kernel is
complaining about - no null pointer deref, no BUG(), no oops, just a
bunch of backtraces. That's kind of bizzare.

Send me your .config, maybe you've got something flipped off.

Might be worth building a kernel with a bunch of debug stuff turned on -
slab debugging for sure.

I may have to try and replicate it on my end. At least it's something
that happens reliably...

^ permalink raw reply

* net-next is OPEN
From: David Miller @ 2012-12-28  4:31 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel, linux-wireless


The net-next tree is now open for submissions.

Thanks.

^ permalink raw reply

* [PATCH] fs/ext*,f2fs,jffs2,reiserfs: give comments for acl size and count calculation
From: Chen Gang @ 2012-12-28  4:31 UTC (permalink / raw)
  To: jack, akpm, adilger.kernel, Theodore Ts'o, jaegeuk.kim, dwmw2,
	torvalds, linux-ext4, linux-f2fs-devel, linux-mtd, reiserfs-devel


  give comments (by Theodore Ts'o)

    ACL_USER_OBJ ACL_USER*[1] ACL_GROUP_OBJ ACL_GROUP*[1] ACL_MASK[2] ACL_OTHER

    [1] Where * is the regexp sense of "0 or more times"
    [2] Only if there is at least one ACL_USER or ACL_GROUP tag;
        otherwise skip ACL_MASK.

  use macro instead of hard code number (by Chen Gang)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 fs/ext2/acl.h             |   10 +++++-----
 fs/ext3/acl.h             |   10 +++++-----
 fs/ext4/acl.h             |   10 +++++-----
 fs/f2fs/acl.c             |   12 +++++++-----
 fs/jffs2/acl.c            |   15 +++++++++------
 fs/reiserfs/acl.h         |   10 +++++-----
 include/linux/posix_acl.h |    9 +++++++++
 7 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
index 503bfb0..9af79d0 100644
--- a/fs/ext2/acl.h
+++ b/fs/ext2/acl.h
@@ -25,13 +25,13 @@ typedef struct {
 
 static inline size_t ext2_acl_size(int count)
 {
-	if (count <= 4) {
+	if (count <= ACL_MAX_SHORT_ENTRY) {
 		return sizeof(ext2_acl_header) +
 		       count * sizeof(ext2_acl_entry_short);
 	} else {
 		return sizeof(ext2_acl_header) +
-		       4 * sizeof(ext2_acl_entry_short) +
-		       (count - 4) * sizeof(ext2_acl_entry);
+		       ACL_MAX_SHORT_ENTRY * sizeof(ext2_acl_entry_short) +
+		       (count - ACL_MAX_SHORT_ENTRY) * sizeof(ext2_acl_entry);
 	}
 }
 
@@ -39,7 +39,7 @@ static inline int ext2_acl_count(size_t size)
 {
 	ssize_t s;
 	size -= sizeof(ext2_acl_header);
-	s = size - 4 * sizeof(ext2_acl_entry_short);
+	s = size - ACL_MAX_SHORT_ENTRY * sizeof(ext2_acl_entry_short);
 	if (s < 0) {
 		if (size % sizeof(ext2_acl_entry_short))
 			return -1;
@@ -47,7 +47,7 @@ static inline int ext2_acl_count(size_t size)
 	} else {
 		if (s % sizeof(ext2_acl_entry))
 			return -1;
-		return s / sizeof(ext2_acl_entry) + 4;
+		return s / sizeof(ext2_acl_entry) + ACL_MAX_SHORT_ENTRY;
 	}
 }
 
diff --git a/fs/ext3/acl.h b/fs/ext3/acl.h
index dbc921e..b1cf2c0 100644
--- a/fs/ext3/acl.h
+++ b/fs/ext3/acl.h
@@ -25,13 +25,13 @@ typedef struct {
 
 static inline size_t ext3_acl_size(int count)
 {
-	if (count <= 4) {
+	if (count <= ACL_MAX_SHORT_ENTRY) {
 		return sizeof(ext3_acl_header) +
 		       count * sizeof(ext3_acl_entry_short);
 	} else {
 		return sizeof(ext3_acl_header) +
-		       4 * sizeof(ext3_acl_entry_short) +
-		       (count - 4) * sizeof(ext3_acl_entry);
+		       ACL_MAX_SHORT_ENTRY * sizeof(ext3_acl_entry_short) +
+		       (count - ACL_MAX_SHORT_ENTRY) * sizeof(ext3_acl_entry);
 	}
 }
 
@@ -39,7 +39,7 @@ static inline int ext3_acl_count(size_t size)
 {
 	ssize_t s;
 	size -= sizeof(ext3_acl_header);
-	s = size - 4 * sizeof(ext3_acl_entry_short);
+	s = size - ACL_MAX_SHORT_ENTRY * sizeof(ext3_acl_entry_short);
 	if (s < 0) {
 		if (size % sizeof(ext3_acl_entry_short))
 			return -1;
@@ -47,7 +47,7 @@ static inline int ext3_acl_count(size_t size)
 	} else {
 		if (s % sizeof(ext3_acl_entry))
 			return -1;
-		return s / sizeof(ext3_acl_entry) + 4;
+		return s / sizeof(ext3_acl_entry) + ACL_MAX_SHORT_ENTRY;
 	}
 }
 
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h
index 18cb39e..66d1fa3 100644
--- a/fs/ext4/acl.h
+++ b/fs/ext4/acl.h
@@ -25,13 +25,13 @@ typedef struct {
 
 static inline size_t ext4_acl_size(int count)
 {
-	if (count <= 4) {
+	if (count <= ACL_MAX_SHORT_ENTRY) {
 		return sizeof(ext4_acl_header) +
 		       count * sizeof(ext4_acl_entry_short);
 	} else {
 		return sizeof(ext4_acl_header) +
-		       4 * sizeof(ext4_acl_entry_short) +
-		       (count - 4) * sizeof(ext4_acl_entry);
+		       ACL_MAX_SHORT_ENTRY * sizeof(ext4_acl_entry_short) +
+		       (count - ACL_MAX_SHORT_ENTRY) * sizeof(ext4_acl_entry);
 	}
 }
 
@@ -39,7 +39,7 @@ static inline int ext4_acl_count(size_t size)
 {
 	ssize_t s;
 	size -= sizeof(ext4_acl_header);
-	s = size - 4 * sizeof(ext4_acl_entry_short);
+	s = size - ACL_MAX_SHORT_ENTRY * sizeof(ext4_acl_entry_short);
 	if (s < 0) {
 		if (size % sizeof(ext4_acl_entry_short))
 			return -1;
@@ -47,7 +47,7 @@ static inline int ext4_acl_count(size_t size)
 	} else {
 		if (s % sizeof(ext4_acl_entry))
 			return -1;
-		return s / sizeof(ext4_acl_entry) + 4;
+		return s / sizeof(ext4_acl_entry) + ACL_MAX_SHORT_ENTRY;
 	}
 }
 
diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index fed74d1..42e0070 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -22,13 +22,15 @@
 
 static inline size_t f2fs_acl_size(int count)
 {
-	if (count <= 4) {
+	if (count <= ACL_MAX_SHORT_ENTRY) {
 		return sizeof(struct f2fs_acl_header) +
 			count * sizeof(struct f2fs_acl_entry_short);
 	} else {
 		return sizeof(struct f2fs_acl_header) +
-			4 * sizeof(struct f2fs_acl_entry_short) +
-			(count - 4) * sizeof(struct f2fs_acl_entry);
+			ACL_MAX_SHORT_ENTRY
+			 * sizeof(struct f2fs_acl_entry_short) +
+			(count - ACL_MAX_SHORT_ENTRY)
+			 * sizeof(struct f2fs_acl_entry);
 	}
 }
 
@@ -36,7 +38,7 @@ static inline int f2fs_acl_count(size_t size)
 {
 	ssize_t s;
 	size -= sizeof(struct f2fs_acl_header);
-	s = size - 4 * sizeof(struct f2fs_acl_entry_short);
+	s = size - ACL_MAX_SHORT_ENTRY * sizeof(struct f2fs_acl_entry_short);
 	if (s < 0) {
 		if (size % sizeof(struct f2fs_acl_entry_short))
 			return -1;
@@ -44,7 +46,7 @@ static inline int f2fs_acl_count(size_t size)
 	} else {
 		if (s % sizeof(struct f2fs_acl_entry))
 			return -1;
-		return s / sizeof(struct f2fs_acl_entry) + 4;
+		return s / sizeof(struct f2fs_acl_entry) + ACL_MAX_SHORT_ENTRY;
 	}
 }
 
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index 223283c..48ef4b8 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -25,13 +25,15 @@
 
 static size_t jffs2_acl_size(int count)
 {
-	if (count <= 4) {
+	if (count <= ACL_MAX_SHORT_ENTRY) {
 		return sizeof(struct jffs2_acl_header)
 		       + count * sizeof(struct jffs2_acl_entry_short);
 	} else {
 		return sizeof(struct jffs2_acl_header)
-		       + 4 * sizeof(struct jffs2_acl_entry_short)
-		       + (count - 4) * sizeof(struct jffs2_acl_entry);
+		       + ACL_MAX_SHORT_ENTRY
+				 * sizeof(struct jffs2_acl_entry_short)
+		       + (count - ACL_MAX_SHORT_ENTRY)
+				 * sizeof(struct jffs2_acl_entry);
 	}
 }
 
@@ -40,15 +42,16 @@ static int jffs2_acl_count(size_t size)
 	size_t s;
 
 	size -= sizeof(struct jffs2_acl_header);
-	if (size < 4 * sizeof(struct jffs2_acl_entry_short)) {
+	if (size < ACL_MAX_SHORT_ENTRY * sizeof(struct jffs2_acl_entry_short)) {
 		if (size % sizeof(struct jffs2_acl_entry_short))
 			return -1;
 		return size / sizeof(struct jffs2_acl_entry_short);
 	} else {
-		s = size - 4 * sizeof(struct jffs2_acl_entry_short);
+		s = size - ACL_MAX_SHORT_ENTRY
+				 * sizeof(struct jffs2_acl_entry_short);
 		if (s % sizeof(struct jffs2_acl_entry))
 			return -1;
-		return s / sizeof(struct jffs2_acl_entry) + 4;
+		return s / sizeof(struct jffs2_acl_entry) + ACL_MAX_SHORT_ENTRY;
 	}
 }
 
diff --git a/fs/reiserfs/acl.h b/fs/reiserfs/acl.h
index f096b80..cb967a3 100644
--- a/fs/reiserfs/acl.h
+++ b/fs/reiserfs/acl.h
@@ -20,13 +20,13 @@ typedef struct {
 
 static inline size_t reiserfs_acl_size(int count)
 {
-	if (count <= 4) {
+	if (count <= ACL_MAX_SHORT_ENTRY) {
 		return sizeof(reiserfs_acl_header) +
 		    count * sizeof(reiserfs_acl_entry_short);
 	} else {
 		return sizeof(reiserfs_acl_header) +
-		    4 * sizeof(reiserfs_acl_entry_short) +
-		    (count - 4) * sizeof(reiserfs_acl_entry);
+		    ACL_MAX_SHORT_ENTRY * sizeof(reiserfs_acl_entry_short) +
+		    (count - ACL_MAX_SHORT_ENTRY) * sizeof(reiserfs_acl_entry);
 	}
 }
 
@@ -34,7 +34,7 @@ static inline int reiserfs_acl_count(size_t size)
 {
 	ssize_t s;
 	size -= sizeof(reiserfs_acl_header);
-	s = size - 4 * sizeof(reiserfs_acl_entry_short);
+	s = size - ACL_MAX_SHORT_ENTRY * sizeof(reiserfs_acl_entry_short);
 	if (s < 0) {
 		if (size % sizeof(reiserfs_acl_entry_short))
 			return -1;
@@ -42,7 +42,7 @@ static inline int reiserfs_acl_count(size_t size)
 	} else {
 		if (s % sizeof(reiserfs_acl_entry))
 			return -1;
-		return s / sizeof(reiserfs_acl_entry) + 4;
+		return s / sizeof(reiserfs_acl_entry) + ACL_MAX_SHORT_ENTRY;
 	}
 }
 
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 7931efe..d75d2f6 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -26,6 +26,15 @@
 #define ACL_MASK		(0x10)
 #define ACL_OTHER		(0x20)
 
+/*
+ * ACL_USER_OBJ ACL_USER*[1] ACL_GROUP_OBJ ACL_GROUP*[1] ACL_MASK[2] ACL_OTHER
+ *
+ * [1] Where * is the regexp sense of "0 or more times"
+ * [2] Only if there is at least one ACL_USER or ACL_GROUP tag;
+ *     otherwise skip ACL_MASK.
+ */
+#define ACL_MAX_SHORT_ENTRY     (4)
+
 /* permissions in the e_perm field */
 #define ACL_READ		(0x04)
 #define ACL_WRITE		(0x02)
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH] bnx2x: use ARRAY_SIZE where possible
From: David Miller @ 2012-12-28  4:30 UTC (permalink / raw)
  To: eilong; +Cc: sasha.levin, netdev, linux-kernel
In-Reply-To: <1356252567.15507.1.camel@lb-tlvb-eilong.il.broadcom.com>

From: "Eilon Greenstein" <eilong@broadcom.com>
Date: Sun, 23 Dec 2012 10:49:27 +0200

> On Thu, 2012-12-20 at 14:11 -0500, Sasha Levin wrote:
>> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> 
> Acked-by Eilon Greenstein <eilong@broadcom.com>

Applied.

^ permalink raw reply

* Bad magic number and
From: sham pavman @ 2012-12-28  4:29 UTC (permalink / raw)
  To: kernelnewbies
In-Reply-To: <CAGdaadbgEpagiT0hR1nDpSm--TKGUpFLdQikZ_qGkxi_82+BCA@mail.gmail.com>

I've tried that as well.. and the result is the same.
I've little idea on how to start debugging.
If you can provide some info it would be great.

Thanks
On Fri, Dec 28, 2012 at 6:37 AM, Mulyadi Santosa
<mulyadi.santosa@gmail.com>wrote:

> Hi...
>
> On Wed, Dec 26, 2012 at 12:19 PM, sham pavman <shampavman.cg@gmail.com>
> wrote:
> > <SNIP>
> >  mkfs -t ext4 /dev/sdb
> > mke2fs 1.42 (29-Nov-2011)
>
> try using mkfs.ext4 instead....
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121228/8fb0e513/attachment.html 

^ permalink raw reply

* Re: [PATCH 2/2] vhost: handle polling failure
From: Jason Wang @ 2012-12-28  4:29 UTC (permalink / raw)
  To: gaowanlong; +Cc: mst, kvm, virtualization, netdev, linux-kernel
In-Reply-To: <50DC1C8F.3020008@cn.fujitsu.com>

On 12/27/2012 06:01 PM, Wanlong Gao wrote:
> On 12/27/2012 02:39 PM, Jason Wang wrote:
>> > Currently, polling error were ignored in vhost. This may lead some issues (e.g
>> > kenrel crash when passing a tap fd to vhost before calling TUNSETIFF). Fix this
>> > by:
> Can this kernel crash be reproduced by hand?
>
> Thanks,
> Wanlong Gao
>
>> > 
Yes, it could be simply reproduced by: open a tap fd but does not cal
TUNSETIFF, then pass it to qemu and enable vhost.

^ permalink raw reply

* Re: [PATCH 2/2] vhost: handle polling failure
From: Jason Wang @ 2012-12-28  4:29 UTC (permalink / raw)
  To: gaowanlong; +Cc: netdev, virtualization, linux-kernel, kvm, mst
In-Reply-To: <50DC1C8F.3020008@cn.fujitsu.com>

On 12/27/2012 06:01 PM, Wanlong Gao wrote:
> On 12/27/2012 02:39 PM, Jason Wang wrote:
>> > Currently, polling error were ignored in vhost. This may lead some issues (e.g
>> > kenrel crash when passing a tap fd to vhost before calling TUNSETIFF). Fix this
>> > by:
> Can this kernel crash be reproduced by hand?
>
> Thanks,
> Wanlong Gao
>
>> > 
Yes, it could be simply reproduced by: open a tap fd but does not cal
TUNSETIFF, then pass it to qemu and enable vhost.

^ permalink raw reply

* Unhandled kernel unaligned access on IP32 w/ network I/O && 3.7.1?
From: Joshua Kinard @ 2012-12-28  4:27 UTC (permalink / raw)
  To: Linux MIPS List

[-- Attachment #1: Type: text/plain, Size: 3305 bytes --]

Has anyone run into an unhandled kernel unaligned access under 3.7.1?  I've
triggered it twice w/ network I/O on an SGI IP32 machine, however, the stack
trace does not appear to be specific to any of IP32's own drivers.  3.6.7
was very stable, and the two oopses I've triggered so far both happened
under 3.7.1.

It looks like the culprit is in sk_stream_alloc_skb or tcp_sendmsg, however,
I have little experience in the higher-level networking stack within Linux
and wanted to see if anyone else has triggered this on other MIPS systems.

Seems to happen when I am logged in via SSH (on IPv6) and generating a burst
of console output.

Unhandled kernel unaligned access[#3]:
Cpu 0
$ 0   : 0000000000000000 0000000000000010 0000000000000000 bfffff005671271c
$ 4   : 0000000000000000 0000000000000000 0000000000000000 0000000000000000
$ 8   : 980000005c24e000 0000000000000000 980000005c24e000 00000000000000cc
$12   : ffffffff9001fce1 000000001000001e fffffffffffff000 000000000000001f
$16   : 980000005c00fa40 ffffffffde0300b8 ffffff0000000000 0000000000000005
$20   : 000000007f875700 00000000000005a8 0000000000000008 0000000000000005
$24   : 0000000000000001 00000000000003f0
$28   : 980000005c00c000 980000005c00fa10 0000000000000000 ffffffff800059a0
Hi    : 0000000007a11c93
Lo    : b645a1cac992645e
epc   : ffffffff8000b700 do_ade+0x1b0/0x480
    Tainted: G      D
ra    : ffffffff800059a0 ret_from_exception+0x0/0x24
Status: 9001fce3    KX SX UX KERNEL EXL IE
Cause : 00000010
BadVA : bfffff005671271c
PrId  : 00002733 (RM7000)
Process rsync (pid: 3844, threadinfo=980000005c00c000,
task=980000005fada000, tls=0000000077dc9490)
Stack : 980000005c24e6a0 9800000056712664 980000005c228000 00000000000005a8
        0000000000000005 ffffffff800059a0 0000000000000000 0000000000000010
        00000000000000d0 0000000000000000 980000005c228000 00000000000008a0
        0000000000000000 0000000000000000 980000005c24e000 0000000000000000
        980000005c24e000 00000000000000cc 0000000000000020 ffffffff80223b6c
        fffffffffffff000 000000000000001f 9800000056712664 980000005c228000
        00000000000005a8 0000000000000005 000000007f875700 00000000000005a8
        0000000000000008 0000000000000005 0000000000000001 00000000000003f0
        0000000000000014 ffffffff802de0d0 980000005c00c000 980000005c00fb70
        0000000000000000 ffffffff80334ef8 ffffffff9001fce3 0000000007a11c93
        ...
Call Trace:
[<ffffffff8000b700>] do_ade+0x1b0/0x480
[<ffffffff800059a0>] ret_from_exception+0x0/0x24
[<ffffffff80334f24>] sk_stream_alloc_skb+0x6c/0x118
[<ffffffff80335e8c>] tcp_sendmsg+0x6fc/0xe90
[<ffffffff802d3744>] sock_aio_write+0x10c/0x150
[<ffffffff800b48c4>] do_sync_write+0x9c/0x108
[<ffffffff800b4a98>] vfs_write+0x168/0x180
[<ffffffff800b4bbc>] SyS_write+0x54/0xb8
[<ffffffff80013538>] handle_sys+0x118/0x13c


Code: 00441024  5440ffe6  de030100 <68730000> 6c730007  24030000  14600040
00000000  8e020124
---[ end trace e5d137adb9de32d0 ]---


-- 
Joshua Kinard
Gentoo/MIPS
kumba@gentoo.org
4096R/D25D95E3 2011-03-28

"The past tempts us, the present confuses us, the future frightens us.  And
our lives slip away, moment by moment, lost in that vast, terrible in-between."

--Emperor Turhan, Centauri Republic


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 834 bytes --]

^ permalink raw reply

* [Buildroot] Setting up Perf for buildroot
From: Kaiwan Billimoria @ 2012-12-28  4:26 UTC (permalink / raw)
  To: buildroot

Hi All,

I saw this message titled "[Buildroot] elfutils and the perf userspace
tool" (see below) on the buildroot mailing list. Last email is shown below:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dear Bogdan Radulescu,

On Thu, 6 Dec 2012 08:10:12 -0800 (PST), Bogdan Radulescu wrote:

> I noticed now that this is in the newer versions. I tried to build it
> without libelf even though it will be pretty crippled but still I
> didn't have any luck. http://pastie.org/pastes/5489305/text
>
> I tried with using 3.7-rc3. In 3.4.22 isn't patched for building
> without libelf. On which version did you manage to build it for ARM?

I never built perf for ARM so far, so I can't really help,
unfortunately.

Thomas
-- 
Thomas Petazzoni, Free Electrons
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


I too am very interested in getting the 'perf' tools onto buildroot.
I would be willing to try this and submit a patch for the same (in fact I
already have one from
another source that seems to work, successfully cross-compiling perf for
ARM), but before that, I have a question:

What would be the appropriate location in the buildroot tree for 'perf'?
Packages branch? Am asking as, of course, perf is a Linux *kernel* (but)
user-space component/tool (it lives under <kernel-src-tree>/tools/perf).
So should we look at inserting a patch as part of the 'kernel' menu or
under 'packages' itself?

TIA!
Kaiwan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20121228/b16fcefb/attachment-0001.html>

^ permalink raw reply

* Re: [PATCH] arm: dma mapping: export arm iommu functions
From: Prathyush K @ 2012-12-28  4:23 UTC (permalink / raw)
  To: Marek Szyprowski; +Cc: Prathyush K, linux-arm-kernel, linaro-mm-sig, linux-mm
In-Reply-To: <50DC580C.7080507@samsung.com>

[-- Attachment #1: Type: text/plain, Size: 2033 bytes --]

On Thu, Dec 27, 2012 at 7:45 PM, Marek Szyprowski
<m.szyprowski@samsung.com>wrote:

> Hello,
>
>
> On 12/27/2012 8:14 AM, Prathyush K wrote:
>
>> This patch adds EXPORT_SYMBOL calls to the three arm iommu
>> functions - arm_iommu_create_mapping, arm_iommu_free_mapping
>> and arm_iommu_attach_device. These functions can now be called
>> from dynamic modules.
>>
>
> Could You describe a bit more why those functions might be needed by
> dynamic modules?
>
> Hi Marek,

We are adding iommu support to exynos gsc and s5p-mfc.
And these two drivers need to be built as modules to improve boot time.

We're calling these three functions from inside these drivers:
e.g.
mapping = arm_iommu_create_mapping(&platform_bus_type, 0x20000000, SZ_256M,
4);
arm_iommu_attach_device(mdev, mapping);



>
>  Signed-off-by: Prathyush K <prathyush.k@samsung.com>
>> ---
>>   arch/arm/mm/dma-mapping.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
>> index 6b2fb87..c0f0f43 100644
>> --- a/arch/arm/mm/dma-mapping.c
>> +++ b/arch/arm/mm/dma-mapping.c
>> @@ -1797,6 +1797,7 @@ err2:
>>   err:
>>         return ERR_PTR(err);
>>   }
>> +EXPORT_SYMBOL(arm_iommu_**create_mapping);
>>
>
> EXPORT_SYMOBL_GPL() ?
>
>
Right, it should be EXPORT_SYMOBL_GPL().

Will update in next patch.



>
>    static void release_iommu_mapping(struct kref *kref)
>>   {
>> @@ -1813,6 +1814,7 @@ void arm_iommu_release_mapping(**struct
>> dma_iommu_mapping *mapping)
>>         if (mapping)
>>                 kref_put(&mapping->kref, release_iommu_mapping);
>>   }
>> +EXPORT_SYMBOL(arm_iommu_**release_mapping);
>>     /**
>>    * arm_iommu_attach_device
>> @@ -1841,5 +1843,6 @@ int arm_iommu_attach_device(struct device *dev,
>>         pr_debug("Attached IOMMU controller to %s device.\n",
>> dev_name(dev));
>>         return 0;
>>   }
>> +EXPORT_SYMBOL(arm_iommu_**attach_device);
>>     #endif
>>
>
> Best regards
> --
> Marek Szyprowski
> Samsung Poland R&D Center
>
>
> Regards,
Prathyush

[-- Attachment #2: Type: text/html, Size: 4018 bytes --]

^ permalink raw reply

* [PATCH] arm: dma mapping: export arm iommu functions
From: Prathyush K @ 2012-12-28  4:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <50DC580C.7080507@samsung.com>

On Thu, Dec 27, 2012 at 7:45 PM, Marek Szyprowski
<m.szyprowski@samsung.com>wrote:

> Hello,
>
>
> On 12/27/2012 8:14 AM, Prathyush K wrote:
>
>> This patch adds EXPORT_SYMBOL calls to the three arm iommu
>> functions - arm_iommu_create_mapping, arm_iommu_free_mapping
>> and arm_iommu_attach_device. These functions can now be called
>> from dynamic modules.
>>
>
> Could You describe a bit more why those functions might be needed by
> dynamic modules?
>
> Hi Marek,

We are adding iommu support to exynos gsc and s5p-mfc.
And these two drivers need to be built as modules to improve boot time.

We're calling these three functions from inside these drivers:
e.g.
mapping = arm_iommu_create_mapping(&platform_bus_type, 0x20000000, SZ_256M,
4);
arm_iommu_attach_device(mdev, mapping);



>
>  Signed-off-by: Prathyush K <prathyush.k@samsung.com>
>> ---
>>   arch/arm/mm/dma-mapping.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
>> index 6b2fb87..c0f0f43 100644
>> --- a/arch/arm/mm/dma-mapping.c
>> +++ b/arch/arm/mm/dma-mapping.c
>> @@ -1797,6 +1797,7 @@ err2:
>>   err:
>>         return ERR_PTR(err);
>>   }
>> +EXPORT_SYMBOL(arm_iommu_**create_mapping);
>>
>
> EXPORT_SYMOBL_GPL() ?
>
>
Right, it should be EXPORT_SYMOBL_GPL().

Will update in next patch.



>
>    static void release_iommu_mapping(struct kref *kref)
>>   {
>> @@ -1813,6 +1814,7 @@ void arm_iommu_release_mapping(**struct
>> dma_iommu_mapping *mapping)
>>         if (mapping)
>>                 kref_put(&mapping->kref, release_iommu_mapping);
>>   }
>> +EXPORT_SYMBOL(arm_iommu_**release_mapping);
>>     /**
>>    * arm_iommu_attach_device
>> @@ -1841,5 +1843,6 @@ int arm_iommu_attach_device(struct device *dev,
>>         pr_debug("Attached IOMMU controller to %s device.\n",
>> dev_name(dev));
>>         return 0;
>>   }
>> +EXPORT_SYMBOL(arm_iommu_**attach_device);
>>     #endif
>>
>
> Best regards
> --
> Marek Szyprowski
> Samsung Poland R&D Center
>
>
> Regards,
Prathyush
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121228/4aee24a0/attachment-0001.html>

^ permalink raw reply

* [PATCH 3/4] arm: vt8500: Convert debug-macro.S to be multiplatform friendly
From: Alexey Charkov @ 2012-12-28  4:21 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1356650452-16559-4-git-send-email-linux@prisktech.co.nz>

On Dec 28, 2012 3:21 AM, "Tony Prisk" <linux@prisktech.co.nz> wrote:
>
> This patch moves debug-macro.S from arm/mach-vt8500/include/mach to
> arm/include/debug/vt8500.S to provide multiplatform support.

Hi Tony!

Looks like you haven't included the new file.

Best,
Alexey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121228/5390c721/attachment-0001.html>

^ permalink raw reply

* [PATCH v2 9/9] Makefile: add USE_WILDMATCH to use wildmatch as fnmatch
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1356667854-8686-1-git-send-email-pclouds@gmail.com>

This is similar to NO_FNMATCH but it uses wildmatch instead of
compat/fnmatch. This is an intermediate step to let wildmatch be used
as fnmatch replacement for wider audience before it replaces fnmatch
completely and compat/fnmatch is removed.

fnmatch in test-wildmatch is not impacted by this and is the only
place that NO_FNMATCH or NO_FNMATCH_CASEFOLD remain active when
USE_WILDMATCH is set.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Makefile          |  6 ++++++
 git-compat-util.h | 13 +++++++++++++
 test-wildmatch.c  |  3 +++
 3 files changed, 22 insertions(+)

diff --git a/Makefile b/Makefile
index bc868d1..24e2774 100644
--- a/Makefile
+++ b/Makefile
@@ -99,6 +99,9 @@ all::
 # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
 # FNM_CASEFOLD GNU extension.
 #
+# Define USE_WILDMATCH if you want to use Git's wildmatch
+# implementation as fnmatch
+#
 # Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
 # in the C library.
 #
@@ -1625,6 +1628,9 @@ ifdef NO_FNMATCH_CASEFOLD
 	COMPAT_OBJS += compat/fnmatch/fnmatch.o
 endif
 endif
+ifdef USE_WILDMATCH
+	COMPAT_CFLAGS += -DUSE_WILDMATCH
+endif
 ifdef NO_SETENV
 	COMPAT_CFLAGS += -DNO_SETENV
 	COMPAT_OBJS += compat/setenv.o
diff --git a/git-compat-util.h b/git-compat-util.h
index 02f48f6..b2c7638 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -106,7 +106,9 @@
 #include <sys/time.h>
 #include <time.h>
 #include <signal.h>
+#ifndef USE_WILDMATCH
 #include <fnmatch.h>
+#endif
 #include <assert.h>
 #include <regex.h>
 #include <utime.h>
@@ -238,6 +240,17 @@ extern char *gitbasename(char *);
 
 #include "compat/bswap.h"
 
+#ifdef USE_WILDMATCH
+#include "wildmatch.h"
+#define FNM_PATHNAME WM_PATHNAME
+#define FNM_CASEFOLD WM_CASEFOLD
+#define FNM_NOMATCH  WM_NOMATCH
+static inline int fnmatch(const char *pattern, const char *string, int flags)
+{
+	return wildmatch(pattern, string, flags, NULL);
+}
+#endif
+
 /* General helper functions */
 extern void vreportf(const char *prefix, const char *err, va_list params);
 extern void vwritef(int fd, const char *prefix, const char *err, va_list params);
diff --git a/test-wildmatch.c b/test-wildmatch.c
index ac86800..a3e2643 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -1,3 +1,6 @@
+#ifdef USE_WILDMATCH
+#undef USE_WILDMATCH  /* We need real fnmatch implementation here */
+#endif
 #include "cache.h"
 #include "wildmatch.h"
 
-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply related

* [PATCH v2 8/9] wildmatch: advance faster in <asterisk> + <literal> patterns
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1356667854-8686-1-git-send-email-pclouds@gmail.com>

compat, '*/*/*' on linux-2.6.git file list 2000 times, before:
wildmatch 7s 985049us
fnmatch   2s 735541us or 34.26% faster

and after:
wildmatch 4s 492549us
fnmatch   0s 888263us or 19.77% slower

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t3070-wildmatch.sh |  6 ++++++
 wildmatch.c          | 21 +++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
index 4cdb13b..dcbc8bc 100755
--- a/t/t3070-wildmatch.sh
+++ b/t/t3070-wildmatch.sh
@@ -207,6 +207,9 @@ match 0 x foo '*/*/*'
 match 0 x foo/bar '*/*/*'
 match 1 x foo/bba/arr '*/*/*'
 match 0 x foo/bb/aa/rr '*/*/*'
+match 1 x abcXdefXghi '*X*i'
+match 0 x ab/cXd/efXg/hi '*X*i'
+match 1 x ab/cXd/efXg/hi '*/*X*/*/*i'
 
 pathmatch 1 foo foo
 pathmatch 0 foo fo
@@ -226,5 +229,8 @@ pathmatch 0 foo '*/*/*'
 pathmatch 0 foo/bar '*/*/*'
 pathmatch 1 foo/bba/arr '*/*/*'
 pathmatch 1 foo/bb/aa/rr '*/*/*'
+pathmatch 1 abcXdefXghi '*X*i'
+pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'
+pathmatch 1 ab/cXd/efXg/hi '*Xg*i'
 
 test_done
diff --git a/wildmatch.c b/wildmatch.c
index f6d45d5..40eda08 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -132,6 +132,27 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
 			while (1) {
 				if (t_ch == '\0')
 					break;
+				/*
+				 * Try to advance faster when an asterisk is
+				 * followed by a literal. We know in this case
+				 * that the the string before the literal
+				 * must belong to "*".
+				 */
+				if (!is_glob_special(*p)) {
+					p_ch = *p;
+					if ((flags & WM_CASEFOLD) && ISUPPER(p_ch))
+						p_ch = tolower(p_ch);
+					while ((t_ch = *text) != '\0' &&
+					       (!(flags & WM_PATHNAME) || t_ch != '/')) {
+						if ((flags & WM_CASEFOLD) && ISUPPER(t_ch))
+							t_ch = tolower(t_ch);
+						if (t_ch == p_ch)
+							break;
+						text++;
+					}
+					if (t_ch != p_ch)
+						return WM_NOMATCH;
+				}
 				if ((matched = dowild(p, text, flags)) != WM_NOMATCH) {
 					if (!match_slash || matched != WM_ABORT_TO_STARSTAR)
 						return matched;
-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply related

* [PATCH v2 7/9] wildmatch: make a special case for "*/" with FNM_PATHNAME
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1356667854-8686-1-git-send-email-pclouds@gmail.com>

Normally we need recursion for "*". In this case we know that it
matches everything until "/" so we can skip the recursion.

glibc, '*/*/*' on linux-2.6.git file list 2000 times
before:
wildmatch 8s 74513us
fnmatch   1s 97042us or 13.59% faster
after:
wildmatch 3s 521862us
fnmatch   3s 488616us or 99.06% slower

Same test with compat/fnmatch:
wildmatch 8s 110763us
fnmatch   2s 980845us or 36.75% faster
wildmatch 3s 522156us
fnmatch   1s 544487us or 43.85% slower

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t3070-wildmatch.sh |  8 ++++++++
 wildmatch.c          | 12 ++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
index dbfa903..4cdb13b 100755
--- a/t/t3070-wildmatch.sh
+++ b/t/t3070-wildmatch.sh
@@ -203,6 +203,10 @@ match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/
 match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
 match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
 match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
+match 0 x foo '*/*/*'
+match 0 x foo/bar '*/*/*'
+match 1 x foo/bba/arr '*/*/*'
+match 0 x foo/bb/aa/rr '*/*/*'
 
 pathmatch 1 foo foo
 pathmatch 0 foo fo
@@ -218,5 +222,9 @@ pathmatch 0 foo/bba/arr 'foo/*z'
 pathmatch 0 foo/bba/arr 'foo/**z'
 pathmatch 1 foo/bar 'foo?bar'
 pathmatch 1 foo/bar 'foo[/]bar'
+pathmatch 0 foo '*/*/*'
+pathmatch 0 foo/bar '*/*/*'
+pathmatch 1 foo/bba/arr '*/*/*'
+pathmatch 1 foo/bb/aa/rr '*/*/*'
 
 test_done
diff --git a/wildmatch.c b/wildmatch.c
index 0c8edb8..f6d45d5 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -116,6 +116,18 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
 						return WM_NOMATCH;
 				}
 				return WM_MATCH;
+			} else if (*p == '/' && (flags & WM_PATHNAME) && !match_slash) {
+				/*
+				 * an asterisk followed by a slash
+				 * with WM_PATHNAME matches the next
+				 * directory
+				 */
+				const char *slash = strchr((char*)text, '/');
+				if (!slash)
+					return WM_NOMATCH;
+				text = (const uchar*)slash;
+				/* the slash is consumed by the top-level for loop */
+				break;
 			}
 			while (1) {
 				if (t_ch == '\0')
-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply related

* [PATCH v2 6/9] test-wildmatch: add "perf" command to compare wildmatch and fnmatch
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1356667854-8686-1-git-send-email-pclouds@gmail.com>

It takes a text file, a pattern, a number <n> and pathname flag. Each
line in the text file is matched against the pattern <n> times. If
"pathname" is given, FNM_PATHNAME is used.

test-wildmatch is built with -O2 and tested against glibc 2.14.1 (also
-O2) and compat/fnmatch. The input file is linux-2.6.git file list.
<n> is 2000. The complete command list is at the end.

wildmatch is beaten in the following cases. Apparently it needs some
improvement in FNM_PATHNAME case:

glibc, '*/*/*' with FNM_PATHNAME:
wildmatch 8s 1559us
fnmatch   1s 11877us or 12.65% faster

compat, '*/*/*' with FNM_PATHNAME:
wildmatch 7s 922458us
fnmatch   2s 905111us or 36.67% faster

compat, '*/*/*' without FNM_PATHNAME:
wildmatch 7s 264201us
fnmatch   2s 1897us or 27.56% faster

compat, '[a-z]*/[a-z]*/[a-z]*' with FNM_PATHNAME:
wildmatch 8s 742827us
fnmatch   0s 922943us or 10.56% faster

compat, '[a-z]*/[a-z]*/[a-z]*' without FNM_PATHNAME:
wildmatch 8s 284520us
fnmatch   0s 6936us or 0.08% faster

The rest of glibc numbers
-------------------------

'Documentation/*'
wildmatch 1s 529479us
fnmatch   1s 98263us or 71.81% slower

'drivers/*'
wildmatch 1s 988288us
fnmatch   1s 192049us or 59.95% slower

'Documentation/*' pathname
wildmatch 1s 557507us
fnmatch   1s 93696us or 70.22% slower

'drivers/*' pathname
wildmatch 2s 161626us
fnmatch   1s 230372us or 56.92% slower

'[Dd]ocu[Mn]entation/*'
wildmatch 1s 776581us
fnmatch   1s 471693us or 82.84% slower

'[Dd]o?u[Mn]en?ati?n/*'
wildmatch 1s 770770us
fnmatch   1s 555727us or 87.86% slower

'[Dd]o?u[Mn]en?ati?n/*' pathname
wildmatch 1s 783507us
fnmatch   1s 537029us or 86.18% slower

'[A-Za-z][A-Za-z]??*'
wildmatch 4s 110386us
fnmatch   4s 926306us or 119.85% slower

'[A-Za-z][A-Za-z]??'
wildmatch 3s 918114us
fnmatch   3s 686175us or 94.08% slower

'[A-Za-z][A-Za-z]??*' pathname
wildmatch 4s 453746us
fnmatch   4s 955856us or 111.27% slower

'[A-Za-z][A-Za-z]??' pathname
wildmatch 3s 896646us
fnmatch   3s 733828us or 95.82% slower

'*/*/*'
wildmatch 7s 287985us
fnmatch   1s 74083us or 14.74% slower

'[a-z]*/[a-z]*/[a-z]*' pathname
wildmatch 8s 796659us
fnmatch   1s 568409us or 17.83% slower

'[a-z]*/[a-z]*/[a-z]*'
wildmatch 8s 316559us
fnmatch   3s 430652us or 41.25% slower

The rest of compat numbers
--------------------------

'Documentation/*'
wildmatch 1s 520389us
fnmatch   0s 62579us or 4.12% slower

'drivers/*'
wildmatch 1s 955354us
fnmatch   0s 190109us or 9.72% slower

'Documentation/*' pathname
wildmatch 1s 561675us
fnmatch   0s 55336us or 3.54% slower

'drivers/*' pathname
wildmatch 2s 106100us
fnmatch   0s 219680us or 10.43% slower

'[Dd]ocu[Mn]entation/*'
wildmatch 1s 750810us
fnmatch   0s 542721us or 31.00% slower

'[Dd]o?u[Mn]en?ati?n/*'
wildmatch 1s 724791us
fnmatch   0s 538948us or 31.25% slower

'[Dd]o?u[Mn]en?ati?n/*' pathname
wildmatch 1s 731403us
fnmatch   0s 537474us or 31.04% slower

'[A-Za-z][A-Za-z]??*'
wildmatch 4s 28555us
fnmatch   1s 67297us or 26.49% slower

'[A-Za-z][A-Za-z]??'
wildmatch 3s 838279us
fnmatch   0s 880005us or 22.93% slower

'[A-Za-z][A-Za-z]??*' pathname
wildmatch 4s 379476us
fnmatch   1s 55643us or 24.10% slower

'[A-Za-z][A-Za-z]??' pathname
wildmatch 3s 830910us
fnmatch   0s 849699us or 22.18% slower

The following commands are used:

LANG=C ./test-wildmatch perf /tmp/filelist.txt 'Documentation/*' 2000
LANG=C ./test-wildmatch perf /tmp/filelist.txt 'drivers/*' 2000
LANG=C ./test-wildmatch perf /tmp/filelist.txt 'Documentation/*' 2000 pathname
LANG=C ./test-wildmatch perf /tmp/filelist.txt 'drivers/*' 2000 pathname
LANG=C ./test-wildmatch perf /tmp/filelist.txt '[Dd]ocu[Mn]entation/*' 2000
LANG=C ./test-wildmatch perf /tmp/filelist.txt '[Dd]o?u[Mn]en?ati?n/*' 2000
LANG=C ./test-wildmatch perf /tmp/filelist.txt '[Dd]o?u[Mn]en?ati?n/*' 2000 pathname
LANG=C ./test-wildmatch perf /tmp/filelist.txt '[A-Za-z][A-Za-z]??*' 2000
LANG=C ./test-wildmatch perf /tmp/filelist.txt '[A-Za-z][A-Za-z]??' 2000
LANG=C ./test-wildmatch perf /tmp/filelist.txt '[A-Za-z][A-Za-z]??*' 2000 pathname
LANG=C ./test-wildmatch perf /tmp/filelist.txt '[A-Za-z][A-Za-z]??' 2000 pathname
LANG=C ./test-wildmatch perf /tmp/filelist.txt '*/*/*' 2000
LANG=C ./test-wildmatch perf /tmp/filelist.txt '*/*/*' 2000 pathname
LANG=C ./test-wildmatch perf /tmp/filelist.txt '[a-z]*/[a-z]*/[a-z]*' 2000 pathname
LANG=C ./test-wildmatch perf /tmp/filelist.txt '[a-z]*/[a-z]*/[a-z]*' 2000

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 test-wildmatch.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/test-wildmatch.c b/test-wildmatch.c
index a5f4833..ac86800 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -1,9 +1,82 @@
 #include "cache.h"
 #include "wildmatch.h"
 
+static int perf(int ac, char **av)
+{
+	struct timeval tv1, tv2;
+	struct stat st;
+	int fd, i, n, flags1 = 0, flags2 = 0;
+	char *buffer, *p;
+	uint32_t usec1, usec2;
+	const char *lang;
+	const char *file = av[0];
+	const char *pattern = av[1];
+
+	lang = getenv("LANG");
+	if (lang && strcmp(lang, "C"))
+		die("Please test it on C locale.");
+
+	if ((fd = open(file, O_RDONLY)) == -1 || fstat(fd, &st))
+		die_errno("file open");
+
+	buffer = xmalloc(st.st_size + 2);
+	if (read(fd, buffer, st.st_size) != st.st_size)
+		die_errno("read");
+
+	buffer[st.st_size] = '\0';
+	buffer[st.st_size + 1] = '\0';
+	for (i = 0; i < st.st_size; i++)
+		if (buffer[i] == '\n')
+			buffer[i] = '\0';
+
+	n = atoi(av[2]);
+	if (av[3] && !strcmp(av[3], "pathname")) {
+		flags1 = WM_PATHNAME;
+		flags2 = FNM_PATHNAME;
+	}
+
+	gettimeofday(&tv1, NULL);
+	for (i = 0; i < n; i++) {
+		for (p = buffer; *p; p += strlen(p) + 1)
+			wildmatch(pattern, p, flags1, NULL);
+	}
+	gettimeofday(&tv2, NULL);
+
+	usec1 = (uint32_t)tv2.tv_sec * 1000000 + tv2.tv_usec;
+	usec1 -= (uint32_t)tv1.tv_sec * 1000000 + tv1.tv_usec;
+	printf("wildmatch %ds %dus\n",
+	       (int)(usec1 / 1000000),
+	       (int)(usec1 % 1000000));
+
+	gettimeofday(&tv1, NULL);
+	for (i = 0; i < n; i++) {
+		for (p = buffer; *p; p += strlen(p) + 1)
+			fnmatch(pattern, p, flags2);
+	}
+	gettimeofday(&tv2, NULL);
+
+	usec2 = (uint32_t)tv2.tv_sec * 1000000 + tv2.tv_usec;
+	usec2 -= (uint32_t)tv1.tv_sec * 1000000 + tv1.tv_usec;
+	if (usec2 > usec1)
+		printf("fnmatch   %ds %dus or %.2f%% slower\n",
+		       (int)((usec2 - usec1) / 1000000),
+		       (int)((usec2 - usec1) % 1000000),
+		       (float)(usec2 - usec1) / usec1 * 100);
+	else
+		printf("fnmatch   %ds %dus or %.2f%% faster\n",
+		       (int)((usec1 - usec2) / 1000000),
+		       (int)((usec1 - usec2) % 1000000),
+		       (float)(usec1 - usec2) / usec1 * 100);
+	return 0;
+}
+
 int main(int argc, char **argv)
 {
 	int i;
+
+	if (!strcmp(argv[1], "perf"))
+		return perf(argc - 2, argv + 2);
+
 	for (i = 2; i < argc; i++) {
 		if (argv[i][0] == '/')
 			die("Forward slash is not allowed at the beginning of the\n"
-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply related

* [PATCH v2 5/9] wildmatch: support "no FNM_PATHNAME" mode
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1356667854-8686-1-git-send-email-pclouds@gmail.com>

So far, wildmatch() has always honoured directory boundary and there
was no way to turn it off. Make it behave more like fnmatch() by
requiring all callers that want the FNM_PATHNAME behaviour to pass
that in the equivalent flag WM_PATHNAME. Callers that do not specify
WM_PATHNAME will get wildcards like ? and * in their patterns matched
against '/', just like not passing FNM_PATHNAME to fnmatch().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 dir.c                |  2 +-
 t/t3070-wildmatch.sh | 27 +++++++++++++++++++++++++++
 test-wildmatch.c     |  6 ++++--
 wildmatch.c          | 13 +++++++++----
 wildmatch.h          |  1 +
 5 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/dir.c b/dir.c
index 175a182..6ef0396 100644
--- a/dir.c
+++ b/dir.c
@@ -595,7 +595,7 @@ int match_pathname(const char *pathname, int pathlen,
 	}
 
 	return wildmatch(pattern, name,
-			 ignore_case ? WM_CASEFOLD : 0,
+			 WM_PATHNAME | (ignore_case ? WM_CASEFOLD : 0),
 			 NULL) == 0;
 }
 
diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
index d5bafef..dbfa903 100755
--- a/t/t3070-wildmatch.sh
+++ b/t/t3070-wildmatch.sh
@@ -29,6 +29,18 @@ match() {
     fi
 }
 
+pathmatch() {
+    if [ $1 = 1 ]; then
+	test_expect_success "pathmatch:    match '$2' '$3'" "
+	    test-wildmatch pathmatch '$2' '$3'
+	"
+    else
+	test_expect_success "pathmatch: no match '$2' '$3'" "
+	    ! test-wildmatch pathmatch '$2' '$3'
+	"
+    fi
+}
+
 # Basic wildmat features
 match 1 1 foo foo
 match 0 0 foo bar
@@ -192,4 +204,19 @@ match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/
 match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
 match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
 
+pathmatch 1 foo foo
+pathmatch 0 foo fo
+pathmatch 1 foo/bar foo/bar
+pathmatch 1 foo/bar 'foo/*'
+pathmatch 1 foo/bba/arr 'foo/*'
+pathmatch 1 foo/bba/arr 'foo/**'
+pathmatch 1 foo/bba/arr 'foo*'
+pathmatch 1 foo/bba/arr 'foo**'
+pathmatch 1 foo/bba/arr 'foo/*arr'
+pathmatch 1 foo/bba/arr 'foo/**arr'
+pathmatch 0 foo/bba/arr 'foo/*z'
+pathmatch 0 foo/bba/arr 'foo/**z'
+pathmatch 1 foo/bar 'foo?bar'
+pathmatch 1 foo/bar 'foo[/]bar'
+
 test_done
diff --git a/test-wildmatch.c b/test-wildmatch.c
index 4bb23b4..a5f4833 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -12,9 +12,11 @@ int main(int argc, char **argv)
 			argv[i] += 3;
 	}
 	if (!strcmp(argv[1], "wildmatch"))
-		return !!wildmatch(argv[3], argv[2], 0, NULL);
+		return !!wildmatch(argv[3], argv[2], WM_PATHNAME, NULL);
 	else if (!strcmp(argv[1], "iwildmatch"))
-		return !!wildmatch(argv[3], argv[2], WM_CASEFOLD, NULL);
+		return !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD, NULL);
+	else if (!strcmp(argv[1], "pathmatch"))
+		return !!wildmatch(argv[3], argv[2], 0, NULL);
 	else if (!strcmp(argv[1], "fnmatch"))
 		return !!fnmatch(argv[3], argv[2], FNM_PATHNAME);
 	else
diff --git a/wildmatch.c b/wildmatch.c
index 68e4213..0c8edb8 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -77,14 +77,17 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
 			continue;
 		case '?':
 			/* Match anything but '/'. */
-			if (t_ch == '/')
+			if ((flags & WM_PATHNAME) && t_ch == '/')
 				return WM_NOMATCH;
 			continue;
 		case '*':
 			if (*++p == '*') {
 				const uchar *prev_p = p - 2;
 				while (*++p == '*') {}
-				if ((prev_p == text || *prev_p == '/') ||
+				if (!(flags & WM_PATHNAME))
+					/* without WM_PATHNAME, '*' == '**' */
+					match_slash = 1;
+				else if ((prev_p == text || *prev_p == '/') ||
 				    (*p == '\0' || *p == '/' ||
 				     (p[0] == '\\' && p[1] == '/'))) {
 					/*
@@ -103,7 +106,8 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
 				} else
 					return WM_ABORT_MALFORMED;
 			} else
-				match_slash = 0;
+				/* without WM_PATHNAME, '*' == '**' */
+				match_slash = flags & WM_PATHNAME ? 0 : 1;
 			if (*p == '\0') {
 				/* Trailing "**" matches everything.  Trailing "*" matches
 				 * only if there are no more slash characters. */
@@ -214,7 +218,8 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
 				} else if (t_ch == p_ch)
 					matched = 1;
 			} while (prev_ch = p_ch, (p_ch = *++p) != ']');
-			if (matched == negated || t_ch == '/')
+			if (matched == negated ||
+			    ((flags & WM_PATHNAME) && t_ch == '/'))
 				return WM_NOMATCH;
 			continue;
 		}
diff --git a/wildmatch.h b/wildmatch.h
index 1c814fd..4090c8f 100644
--- a/wildmatch.h
+++ b/wildmatch.h
@@ -2,6 +2,7 @@
 #define WILDMATCH_H
 
 #define WM_CASEFOLD 1
+#define WM_PATHNAME 2
 
 #define WM_ABORT_MALFORMED 2
 #define WM_NOMATCH 1
-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply related

* [PATCH v2 4/9] wildmatch: make dowild() take arbitrary flags
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1356667854-8686-1-git-send-email-pclouds@gmail.com>


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 wildmatch.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/wildmatch.c b/wildmatch.c
index f9b6451..68e4213 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -52,7 +52,7 @@ typedef unsigned char uchar;
 #define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
 
 /* Match pattern "p" against "text" */
-static int dowild(const uchar *p, const uchar *text, int force_lower_case)
+static int dowild(const uchar *p, const uchar *text, unsigned int flags)
 {
 	uchar p_ch;
 
@@ -61,9 +61,9 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 		uchar t_ch, prev_ch;
 		if ((t_ch = *text) == '\0' && p_ch != '*')
 			return WM_ABORT_ALL;
-		if (force_lower_case && ISUPPER(t_ch))
+		if ((flags & WM_CASEFOLD) && ISUPPER(t_ch))
 			t_ch = tolower(t_ch);
-		if (force_lower_case && ISUPPER(p_ch))
+		if ((flags & WM_CASEFOLD) && ISUPPER(p_ch))
 			p_ch = tolower(p_ch);
 		switch (p_ch) {
 		case '\\':
@@ -97,7 +97,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 					 * both foo/bar and foo/a/bar.
 					 */
 					if (p[0] == '/' &&
-					    dowild(p + 1, text, force_lower_case) == WM_MATCH)
+					    dowild(p + 1, text, flags) == WM_MATCH)
 						return WM_MATCH;
 					match_slash = 1;
 				} else
@@ -116,7 +116,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 			while (1) {
 				if (t_ch == '\0')
 					break;
-				if ((matched = dowild(p, text,  force_lower_case)) != WM_NOMATCH) {
+				if ((matched = dowild(p, text, flags)) != WM_NOMATCH) {
 					if (!match_slash || matched != WM_ABORT_TO_STARSTAR)
 						return matched;
 				} else if (!match_slash && t_ch == '/')
@@ -227,6 +227,5 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 int wildmatch(const char *pattern, const char *text,
 	      unsigned int flags, struct wildopts *wo)
 {
-	return dowild((const uchar*)pattern, (const uchar*)text,
-		      flags & WM_CASEFOLD ? 1 :0);
+	return dowild((const uchar*)pattern, (const uchar*)text, flags);
 }
-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply related

* [PATCH v2 3/9] wildmatch: rename constants and update prototype
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1356667854-8686-1-git-send-email-pclouds@gmail.com>

- All exported constants now have a prefix WM_
- Do not rely on FNM_* constants, use the WM_ counterparts
- Remove TRUE and FALSE to follow Git's coding style
- While at it, turn flags type from int to unsigned int
- Add an (unused yet) argument to carry extra information
  so that we don't have to change the prototype again later
  when we need to pass other stuff to wildmatch

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 dir.c            |  3 +-
 test-wildmatch.c |  4 +--
 wildmatch.c      | 88 +++++++++++++++++++++++++++-----------------------------
 wildmatch.h      | 22 +++++++++-----
 4 files changed, 62 insertions(+), 55 deletions(-)

diff --git a/dir.c b/dir.c
index cb7328b..175a182 100644
--- a/dir.c
+++ b/dir.c
@@ -595,7 +595,8 @@ int match_pathname(const char *pathname, int pathlen,
 	}
 
 	return wildmatch(pattern, name,
-			 ignore_case ? FNM_CASEFOLD : 0) == 0;
+			 ignore_case ? WM_CASEFOLD : 0,
+			 NULL) == 0;
 }
 
 /* Scan the list and let the last match determine the fate.
diff --git a/test-wildmatch.c b/test-wildmatch.c
index e384c8e..4bb23b4 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -12,9 +12,9 @@ int main(int argc, char **argv)
 			argv[i] += 3;
 	}
 	if (!strcmp(argv[1], "wildmatch"))
-		return !!wildmatch(argv[3], argv[2], 0);
+		return !!wildmatch(argv[3], argv[2], 0, NULL);
 	else if (!strcmp(argv[1], "iwildmatch"))
-		return !!wildmatch(argv[3], argv[2], FNM_CASEFOLD);
+		return !!wildmatch(argv[3], argv[2], WM_CASEFOLD, NULL);
 	else if (!strcmp(argv[1], "fnmatch"))
 		return !!fnmatch(argv[3], argv[2], FNM_PATHNAME);
 	else
diff --git a/wildmatch.c b/wildmatch.c
index 8a58ad4..f9b6451 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -18,9 +18,6 @@ typedef unsigned char uchar;
 #define NEGATE_CLASS	'!'
 #define NEGATE_CLASS2	'^'
 
-#define FALSE 0
-#define TRUE 1
-
 #define CC_EQ(class, len, litmatch) ((len) == sizeof (litmatch)-1 \
 				    && *(class) == *(litmatch) \
 				    && strncmp((char*)class, litmatch, len) == 0)
@@ -63,7 +60,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 		int matched, match_slash, negated;
 		uchar t_ch, prev_ch;
 		if ((t_ch = *text) == '\0' && p_ch != '*')
-			return ABORT_ALL;
+			return WM_ABORT_ALL;
 		if (force_lower_case && ISUPPER(t_ch))
 			t_ch = tolower(t_ch);
 		if (force_lower_case && ISUPPER(p_ch))
@@ -76,12 +73,12 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 			/* FALLTHROUGH */
 		default:
 			if (t_ch != p_ch)
-				return NOMATCH;
+				return WM_NOMATCH;
 			continue;
 		case '?':
 			/* Match anything but '/'. */
 			if (t_ch == '/')
-				return NOMATCH;
+				return WM_NOMATCH;
 			continue;
 		case '*':
 			if (*++p == '*') {
@@ -100,135 +97,136 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 					 * both foo/bar and foo/a/bar.
 					 */
 					if (p[0] == '/' &&
-					    dowild(p + 1, text, force_lower_case) == MATCH)
-						return MATCH;
-					match_slash = TRUE;
+					    dowild(p + 1, text, force_lower_case) == WM_MATCH)
+						return WM_MATCH;
+					match_slash = 1;
 				} else
-					return ABORT_MALFORMED;
+					return WM_ABORT_MALFORMED;
 			} else
-				match_slash = FALSE;
+				match_slash = 0;
 			if (*p == '\0') {
 				/* Trailing "**" matches everything.  Trailing "*" matches
 				 * only if there are no more slash characters. */
 				if (!match_slash) {
 					if (strchr((char*)text, '/') != NULL)
-						return NOMATCH;
+						return WM_NOMATCH;
 				}
-				return MATCH;
+				return WM_MATCH;
 			}
 			while (1) {
 				if (t_ch == '\0')
 					break;
-				if ((matched = dowild(p, text,  force_lower_case)) != NOMATCH) {
-					if (!match_slash || matched != ABORT_TO_STARSTAR)
+				if ((matched = dowild(p, text,  force_lower_case)) != WM_NOMATCH) {
+					if (!match_slash || matched != WM_ABORT_TO_STARSTAR)
 						return matched;
 				} else if (!match_slash && t_ch == '/')
-					return ABORT_TO_STARSTAR;
+					return WM_ABORT_TO_STARSTAR;
 				t_ch = *++text;
 			}
-			return ABORT_ALL;
+			return WM_ABORT_ALL;
 		case '[':
 			p_ch = *++p;
 #ifdef NEGATE_CLASS2
 			if (p_ch == NEGATE_CLASS2)
 				p_ch = NEGATE_CLASS;
 #endif
-			/* Assign literal TRUE/FALSE because of "matched" comparison. */
-			negated = p_ch == NEGATE_CLASS? TRUE : FALSE;
+			/* Assign literal 1/0 because of "matched" comparison. */
+			negated = p_ch == NEGATE_CLASS ? 1 : 0;
 			if (negated) {
 				/* Inverted character class. */
 				p_ch = *++p;
 			}
 			prev_ch = 0;
-			matched = FALSE;
+			matched = 0;
 			do {
 				if (!p_ch)
-					return ABORT_ALL;
+					return WM_ABORT_ALL;
 				if (p_ch == '\\') {
 					p_ch = *++p;
 					if (!p_ch)
-						return ABORT_ALL;
+						return WM_ABORT_ALL;
 					if (t_ch == p_ch)
-						matched = TRUE;
+						matched = 1;
 				} else if (p_ch == '-' && prev_ch && p[1] && p[1] != ']') {
 					p_ch = *++p;
 					if (p_ch == '\\') {
 						p_ch = *++p;
 						if (!p_ch)
-							return ABORT_ALL;
+							return WM_ABORT_ALL;
 					}
 					if (t_ch <= p_ch && t_ch >= prev_ch)
-						matched = TRUE;
+						matched = 1;
 					p_ch = 0; /* This makes "prev_ch" get set to 0. */
 				} else if (p_ch == '[' && p[1] == ':') {
 					const uchar *s;
 					int i;
 					for (s = p += 2; (p_ch = *p) && p_ch != ']'; p++) {} /*SHARED ITERATOR*/
 					if (!p_ch)
-						return ABORT_ALL;
+						return WM_ABORT_ALL;
 					i = p - s - 1;
 					if (i < 0 || p[-1] != ':') {
 						/* Didn't find ":]", so treat like a normal set. */
 						p = s - 2;
 						p_ch = '[';
 						if (t_ch == p_ch)
-							matched = TRUE;
+							matched = 1;
 						continue;
 					}
 					if (CC_EQ(s,i, "alnum")) {
 						if (ISALNUM(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "alpha")) {
 						if (ISALPHA(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "blank")) {
 						if (ISBLANK(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "cntrl")) {
 						if (ISCNTRL(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "digit")) {
 						if (ISDIGIT(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "graph")) {
 						if (ISGRAPH(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "lower")) {
 						if (ISLOWER(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "print")) {
 						if (ISPRINT(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "punct")) {
 						if (ISPUNCT(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "space")) {
 						if (ISSPACE(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "upper")) {
 						if (ISUPPER(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else if (CC_EQ(s,i, "xdigit")) {
 						if (ISXDIGIT(t_ch))
-							matched = TRUE;
+							matched = 1;
 					} else /* malformed [:class:] string */
-						return ABORT_ALL;
+						return WM_ABORT_ALL;
 					p_ch = 0; /* This makes "prev_ch" get set to 0. */
 				} else if (t_ch == p_ch)
-					matched = TRUE;
+					matched = 1;
 			} while (prev_ch = p_ch, (p_ch = *++p) != ']');
 			if (matched == negated || t_ch == '/')
-				return NOMATCH;
+				return WM_NOMATCH;
 			continue;
 		}
 	}
 
-	return *text ? NOMATCH : MATCH;
+	return *text ? WM_NOMATCH : WM_MATCH;
 }
 
 /* Match the "pattern" against the "text" string. */
-int wildmatch(const char *pattern, const char *text, int flags)
+int wildmatch(const char *pattern, const char *text,
+	      unsigned int flags, struct wildopts *wo)
 {
 	return dowild((const uchar*)pattern, (const uchar*)text,
-		      flags & FNM_CASEFOLD ? 1 :0);
+		      flags & WM_CASEFOLD ? 1 :0);
 }
diff --git a/wildmatch.h b/wildmatch.h
index 984a38c..1c814fd 100644
--- a/wildmatch.h
+++ b/wildmatch.h
@@ -1,9 +1,17 @@
-/* wildmatch.h */
+#ifndef WILDMATCH_H
+#define WILDMATCH_H
 
-#define ABORT_MALFORMED 2
-#define NOMATCH 1
-#define MATCH 0
-#define ABORT_ALL -1
-#define ABORT_TO_STARSTAR -2
+#define WM_CASEFOLD 1
 
-int wildmatch(const char *pattern, const char *text, int flags);
+#define WM_ABORT_MALFORMED 2
+#define WM_NOMATCH 1
+#define WM_MATCH 0
+#define WM_ABORT_ALL -1
+#define WM_ABORT_TO_STARSTAR -2
+
+struct wildopts;
+
+int wildmatch(const char *pattern, const char *text,
+	      unsigned int flags,
+	      struct wildopts *wo);
+#endif
-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply related

* [PATCH v2 2/9] wildmatch: replace variable 'special' with better named ones
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1356667854-8686-1-git-send-email-pclouds@gmail.com>

'special' is too generic and is used for two different purposes.
Replace it with 'match_slash' to indicate "**" pattern and 'negated'
for "[!...]" and "[^...]".

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 wildmatch.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/wildmatch.c b/wildmatch.c
index 3972e26..8a58ad4 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -60,7 +60,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 	uchar p_ch;
 
 	for ( ; (p_ch = *p) != '\0'; text++, p++) {
-		int matched, special;
+		int matched, match_slash, negated;
 		uchar t_ch, prev_ch;
 		if ((t_ch = *text) == '\0' && p_ch != '*')
 			return ABORT_ALL;
@@ -102,15 +102,15 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 					if (p[0] == '/' &&
 					    dowild(p + 1, text, force_lower_case) == MATCH)
 						return MATCH;
-					special = TRUE;
+					match_slash = TRUE;
 				} else
 					return ABORT_MALFORMED;
 			} else
-				special = FALSE;
+				match_slash = FALSE;
 			if (*p == '\0') {
 				/* Trailing "**" matches everything.  Trailing "*" matches
 				 * only if there are no more slash characters. */
-				if (!special) {
+				if (!match_slash) {
 					if (strchr((char*)text, '/') != NULL)
 						return NOMATCH;
 				}
@@ -120,9 +120,9 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 				if (t_ch == '\0')
 					break;
 				if ((matched = dowild(p, text,  force_lower_case)) != NOMATCH) {
-					if (!special || matched != ABORT_TO_STARSTAR)
+					if (!match_slash || matched != ABORT_TO_STARSTAR)
 						return matched;
-				} else if (!special && t_ch == '/')
+				} else if (!match_slash && t_ch == '/')
 					return ABORT_TO_STARSTAR;
 				t_ch = *++text;
 			}
@@ -134,8 +134,8 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 				p_ch = NEGATE_CLASS;
 #endif
 			/* Assign literal TRUE/FALSE because of "matched" comparison. */
-			special = p_ch == NEGATE_CLASS? TRUE : FALSE;
-			if (special) {
+			negated = p_ch == NEGATE_CLASS? TRUE : FALSE;
+			if (negated) {
 				/* Inverted character class. */
 				p_ch = *++p;
 			}
@@ -217,7 +217,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 				} else if (t_ch == p_ch)
 					matched = TRUE;
 			} while (prev_ch = p_ch, (p_ch = *++p) != ']');
-			if (matched == special || t_ch == '/')
+			if (matched == negated || t_ch == '/')
 				return NOMATCH;
 			continue;
 		}
-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply related

* [PATCH v2 1/9] compat/fnmatch: respect NO_FNMATCH* even on glibc
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1356667854-8686-1-git-send-email-pclouds@gmail.com>


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 compat/fnmatch/fnmatch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compat/fnmatch/fnmatch.c b/compat/fnmatch/fnmatch.c
index 9473aed..6f7387d 100644
--- a/compat/fnmatch/fnmatch.c
+++ b/compat/fnmatch/fnmatch.c
@@ -55,7 +55,8 @@
    program understand `configure --with-gnu-libc' and omit the object files,
    it is simpler to just do this in the source for each such file.  */
 
-#if defined _LIBC || !defined __GNU_LIBRARY__
+#if defined NO_FNMATCH || defined NO_FNMATCH_CASEFOLD || \
+    defined _LIBC || !defined __GNU_LIBRARY__
 
 
 # if defined STDC_HEADERS || !defined isascii
-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply related

* [PATCH v2 0/9] fnmatch replacement step 1
From: Nguyễn Thái Ngọc Duy @ 2012-12-28  4:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy

v2 has no big changes:

 - 'special' variable in dowild() is removed in favor of two
   new, better named ones
 - fix TRUE/FALSE in comments as well as code in the rename patch
 - some tests for "*/" and "*<literal>" optimizations
 - USE_WILDMATCH patch is moved to the end of the series

Nguyễn Thái Ngọc Duy (9):
  compat/fnmatch: respect NO_FNMATCH* even on glibc
  wildmatch: replace variable 'special' with better named ones
  wildmatch: rename constants and update prototype
  wildmatch: make dowild() take arbitrary flags
  wildmatch: support "no FNM_PATHNAME" mode
  test-wildmatch: add "perf" command to compare wildmatch and fnmatch
  wildmatch: make a special case for "*/" with FNM_PATHNAME
  wildmatch: advance faster in <asterisk> + <literal> patterns
  Makefile: add USE_WILDMATCH to use wildmatch as fnmatch

 Makefile                 |   6 ++
 compat/fnmatch/fnmatch.c |   3 +-
 dir.c                    |   3 +-
 git-compat-util.h        |  13 +++++
 t/t3070-wildmatch.sh     |  41 +++++++++++++
 test-wildmatch.c         |  82 +++++++++++++++++++++++++-
 wildmatch.c              | 147 +++++++++++++++++++++++++++++------------------
 wildmatch.h              |  23 +++++---
 8 files changed, 251 insertions(+), 67 deletions(-)

-- 
1.8.0.rc2.23.g1fb49df

^ permalink raw reply

* Re: [PATCH] video: drm: exynos: mie bypass enable for fimd
From: Leela Krishna Amudala @ 2012-12-28  4:09 UTC (permalink / raw)
  To: Inki Dae; +Cc: kgene.kim, linux-samsung-soc, dri-devel
In-Reply-To: <CAAQKjZOPQtCPE6BHnyJ7mqfi04VWbg3VWeVf9fcjxZC3jjUYdQ@mail.gmail.com>

Hello Inki Dae,

On Thu, Dec 27, 2012 at 11:47 AM, Inki Dae <inki.dae@samsung.com> wrote:
>
> Hi,
>
> DISP1BLK_CFG register is related to GScaler, HDCP and MIXER as well. So
> it's not good that this register is controlled in fimd module. And I think
> the function to control the register should be placed in SoC common file .
> In other words, other drivers should be able to control the register through
> common thing also.
>

Thanks for reviewing the patch.
You mean to say that this functionality should be implemented at arch side
and called by drivers using call back functions ?

If so, then if we moved the driver to full DT version, all the call
backs will be removed.
Then how to make a call to this function?

So I thought other drivers (apart from Fimd) also parses the
appropriate nodes and
program the register as per the need.

Please correct me if my understanding is wrong.

Best Wishes,
Leela Krishna Amudala.


> Thanks,
> Inki Dae
>
> 2012/12/26 Leela Krishna Amudala <l.krishna@samsung.com>
>>
>> Bypasses the mie for fimd by parsing the register and bit offset values
>> from "mie-bypass" node, if "mie-bypass" node is present in the dts file.
>>
>> Signed-off-by: Leela Krishna Amudala <l.krishna@samsung.com>
>> ---
>>  drivers/gpu/drm/exynos/exynos_drm_fimd.c | 55
>> ++++++++++++++++++++++++++++++++
>>  1 file changed, 55 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> index bf0d9ba..f8ad259 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> @@ -118,6 +118,12 @@ static const struct of_device_id
>> fimd_driver_dt_match[] = {
>>  MODULE_DEVICE_TABLE(of, fimd_driver_dt_match);
>>  #endif
>>
>> +struct mie_bypass {
>> +       u32                             enable_bypass;
>> +       void __iomem                    *bypass_reg;
>> +       u32                             bypass_bit_offset;
>> +};
>> +
>>  static inline struct fimd_driver_data *drm_fimd_get_driver_data(
>>         struct platform_device *pdev)
>>  {
>> @@ -133,6 +139,41 @@ static inline struct fimd_driver_data
>> *drm_fimd_get_driver_data(
>>                 platform_get_device_id(pdev)->driver_data;
>>  }
>>
>> +static struct mie_bypass *parse_mie_bypass_for_fimd(struct device *dev,
>> +                                       struct device_node
>> *mie_bypass_node)
>> +{
>> +       struct mie_bypass *bypass_data;
>> +       u32 phy_address;
>> +
>> +       bypass_data = devm_kzalloc(dev, sizeof(*bypass_data),
>> GFP_KERNEL);
>> +       if (!bypass_data) {
>> +               dev_err(dev, "memory allocation for bypass data
>> failed\n");
>> +               return ERR_PTR(-ENOMEM);
>> +       }
>> +       of_property_read_u32(mie_bypass_node,
>> "samsung,mie-bypass-enable",
>> +                       &bypass_data->enable_bypass);
>> +       of_property_read_u32(mie_bypass_node, "samsung,disp1blk-cfg-reg",
>> +                       &phy_address);
>> +       of_property_read_u32(mie_bypass_node,
>> "samsung,bypass-bit-offset",
>> +                       &bypass_data->bypass_bit_offset);
>> +
>> +       bypass_data->bypass_reg = ioremap(phy_address, SZ_4);
>>
>> +       if (!bypass_data->bypass_reg) {
>> +               dev_err(dev, "failed to ioremap phy_address\n");
>> +               return ERR_PTR(-ENOMEM);
>> +       }
>> +       return bypass_data;
>> +}
>>
>> +
>> +static void mie_bypass_for_fimd(struct mie_bypass *bypass_data)
>> +{
>> +       u32 reg;
>> +
>> +       reg = __raw_readl(bypass_data->bypass_reg);
>> +       reg |= (1 << bypass_data->bypass_bit_offset);
>> +       __raw_writel(reg, bypass_data->bypass_reg);
>> +}
>> +
>>  static bool fimd_display_is_connected(struct device *dev)
>>  {
>>         DRM_DEBUG_KMS("%s\n", __FILE__);
>> @@ -906,12 +947,26 @@ static int __devinit fimd_probe(struct
>> platform_device *pdev)
>>         struct exynos_drm_fimd_pdata *pdata;
>>         struct exynos_drm_panel_info *panel;
>>         struct resource *res;
>> +       struct device_node *mie_bypass_node;
>> +       struct mie_bypass *bypass_data = NULL;
>>         int win;
>>         int ret = -EINVAL;
>>
>>         DRM_DEBUG_KMS("%s\n", __FILE__);
>>
>>         pdata = pdev->dev.platform_data;
>> +       if (pdev->dev.of_node) {
>> +               mie_bypass_node = of_find_node_by_name(pdev->dev.of_node,
>> +                                                       "mie-bypass");
>> +               if (mie_bypass_node) {
>> +                       bypass_data =
>> parse_mie_bypass_for_fimd(&pdev->dev,
>> +                                                       mie_bypass_node);
>>
>> +                       if (IS_ERR(bypass_data))
>> +                               return PTR_ERR(bypass_data);
>> +                       if (bypass_data->enable_bypass)
>> +                               mie_bypass_for_fimd(bypass_data);
>> +               }
>> +       }
>>         if (!pdata) {
>>                 dev_err(dev, "no platform data specified\n");
>>                 return -EINVAL;
>> --
>> 1.8.0
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>

^ permalink raw reply


This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.