Re: [PATCH v2 2/2] perf tools: add attr-mmap2 support

2013-08-31 Thread Ingo Molnar

* Stephane Eranian eran...@google.com wrote:

 False alarm, the changes in builtin-inject.c are in V2. Nothing more to 
 do. Sorry about the confusion.

ok, I'll pick up the -v2 patches from Peter.

Thanks,

Ingo
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] btrfs: use list_for_each_entry_safe() when delete items

2013-08-31 Thread Azat Khuzhin
On Tue, Jul 30, 2013 at 7:40 AM, Miao Xie mi...@cn.fujitsu.com wrote:
 On mon, 29 Jul 2013 11:48:32 +0400, Azat Khuzhin wrote:
 On Sat, Jul 27, 2013 at 2:12 PM, Azat Khuzhin a3at.m...@gmail.com wrote:
 Replace list_for_each_entry() by list_for_each_entry_safe() in
 __btrfs_close_devices()

 There is another place that delete items lock_stripe_add(), but there we
 don't need safe version, because after deleting we exit from loop.

 Signed-off-by: Azat Khuzhin a3at.m...@gmail.com
 ---
  fs/btrfs/volumes.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
 index 78b8717..1d1b595 100644
 --- a/fs/btrfs/volumes.c
 +++ b/fs/btrfs/volumes.c
 @@ -616,13 +616,13 @@ static void free_device(struct rcu_head *head)

  static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
  {
 -   struct btrfs_device *device;
 +   struct btrfs_device *device, *next;

 if (--fs_devices-opened  0)
 return 0;

 mutex_lock(fs_devices-device_list_mutex);
 -   list_for_each_entry(device, fs_devices-devices, dev_list) {
 +   list_for_each_entry_safe(device, next, fs_devices-devices, 
 dev_list) {
 struct btrfs_device *new_device;
 struct rcu_string *name;

 There is kfree(device); at the end of loop, maybe there must goto
 again; after it?
 (instead of this patch)

Ugh. I was looking into another function!


 Your fix is right, we needn't search from the head once again.

 The other fix way is:
 call_rcu(device-rcu, free_device);
 +   device = new_device;
  }
 but from the viewpoint of the readability, this way is not so good.

 Reviewed-by: Miao Xie mi...@cn.fujitsu.com

Thanks!
Miao, should I resend patch with you reviewed-by?




 --
 1.7.10.4








-- 
Respectfully
Azat Khuzhin
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH linux-next] Prevent a coredump with a large vm_map_count from Oopsing

2013-08-31 Thread Dan Aloni
A high setting of max_map_count, and a process core-dumping with
a large enough vm_map_count could result in an NT_FILE note not
being written, and the kernel crashing immediately later because
it has assumed otherwise.

Reproduction of the bug described here:

https://lkml.org/lkml/2013/8/30/50

Issue originating in 2aa362c49 (from Oct 4, 2012).

This patch make that section optional in that case.
fill_files_note() should signify the error, and also let the info
struct in elf_core_dump() be zero-initialized so that we can check
for the optionally written note.

Cc'ed original signers.

Cc'ed Al Viro because it is trivially relies on his linux-next
tree changes.

Signed-off-by: Dan Aloni alo...@stratoscale.com
Cc: Al Viro v...@zeniv.linux.org.uk
Cc: Denys Vlasenko vda.li...@googlemail.com
Cc: Andrew Morton a...@linux-foundation.org
Cc: Linus Torvalds torva...@linux-foundation.org
---
 fs/binfmt_elf.c | 33 +
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index dc82279..e1a323a 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1429,7 +1429,7 @@ static void fill_siginfo_note(struct memelfnote *note, 
user_siginfo_t *csigdata,
  *   long file_ofs
  * followed by COUNT filenames in ASCII: FILE1 NUL FILE2 NUL...
  */
-static void fill_files_note(struct memelfnote *note)
+static int fill_files_note(struct memelfnote *note)
 {
struct vm_area_struct *vma;
unsigned count, size, names_ofs, remaining, n;
@@ -1444,11 +1444,11 @@ static void fill_files_note(struct memelfnote *note)
names_ofs = (2 + 3 * count) * sizeof(data[0]);
  alloc:
if (size = MAX_FILE_NOTE_SIZE) /* paranoia check */
-   goto err;
+   return -E2BIG;
size = round_up(size, PAGE_SIZE);
data = vmalloc(size);
if (!data)
-   goto err;
+   return -ENOMEM;
 
start_end_ofs = data + 2;
name_base = name_curpos = ((char *)data) + names_ofs;
@@ -1501,7 +1501,7 @@ static void fill_files_note(struct memelfnote *note)
 
size = name_curpos - (char *)data;
fill_note(note, CORE, NT_FILE, size, data);
- err: ;
+   return 0;
 }
 
 #ifdef CORE_DUMP_USE_REGSET
@@ -1623,6 +1623,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
struct elf_prpsinfo *psinfo;
struct core_thread *ct;
unsigned int i;
+   int ret;
 
info-size = 0;
info-thread = NULL;
@@ -1702,8 +1703,9 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
fill_auxv_note(info-auxv, current-mm);
info-size += notesize(info-auxv);
 
-   fill_files_note(info-files);
-   info-size += notesize(info-files);
+   ret = fill_files_note(info-files);
+   if (!ret)
+   info-size += notesize(info-files);
 
return 1;
 }
@@ -1735,7 +1737,7 @@ static int write_note_info(struct elf_note_info *info,
return 0;
if (first  !writenote(info-auxv, cprm))
return 0;
-   if (first  !writenote(info-files, cprm))
+   if (first  info-files.data  !writenote(info-files, cprm))
return 0;
 
for (i = 1; i  info-thread_notes; ++i)
@@ -1822,6 +1824,7 @@ static int elf_dump_thread_status(long signr, struct 
elf_thread_status *t)
 
 struct elf_note_info {
struct memelfnote *notes;
+   struct memelfnote *notes_files;
struct elf_prstatus *prstatus;  /* NT_PRSTATUS */
struct elf_prpsinfo *psinfo;/* NT_PRPSINFO */
struct list_head thread_list;
@@ -1865,6 +1868,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
  siginfo_t *siginfo, struct pt_regs *regs)
 {
struct list_head *t;
+   int ret;
 
if (!elf_note_info_init(info))
return 0;
@@ -1912,9 +1916,13 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
 
fill_siginfo_note(info-notes + 2, info-csigdata, siginfo);
fill_auxv_note(info-notes + 3, current-mm);
-   fill_files_note(info-notes + 4);
+   info-numnote = 4;
 
-   info-numnote = 5;
+   ret = fill_files_note(info-notes + info-numnote);
+   if (!ret) {
+   info-notes_files = info-notes + info-numnote;
+   info-numnote++;
+   }
 
/* Try to dump the FPU. */
info-prstatus-pr_fpvalid = elf_core_copy_task_fpregs(current, regs,
@@ -1976,8 +1984,9 @@ static void free_note_info(struct elf_note_info *info)
kfree(list_entry(tmp, struct elf_thread_status, list));
}
 
-   /* Free data allocated by fill_files_note(): */
-   vfree(info-notes[4].data);
+   /* Free data possibly allocated by fill_files_note(): */
+   if (info-notes_files)
+   vfree(info-notes_files-data);
 
kfree(info-prstatus);
kfree(info-psinfo);
@@ -2059,7 +2068,7 @@ 

Re: linux-next: build warning after merge of the tip tree

2013-08-31 Thread Ingo Molnar

* Andi Kleen a...@linux.intel.com wrote:

   I've seen this pattern of deficient changelogs a dozen 
   times in your patches this year alone ...
  
  Ping?
 
 I've re-sent the patch already last week.

hpa was on vacation, if he doesn't pick it up I'll apply it.

 Some perf patches are also pending, there just seems to be a long 
 backlog.
 
 http://permalink.gmane.org/gmane.linux.kernel/1548787 
 http://permalink.gmane.org/gmane.linux.kernel/1548788 
 http://permalink.gmane.org/gmane.linux.kernel/1548790 
 http://permalink.gmane.org/gmane.linux.kernel/1548791

There's no perf patches backlog. The ones you link to here were delayed 
because you (again) ignored maintainer review feedback:

  https://lkml.org/lkml/2013/8/30/370

Not sure you noticed, but kernel subsystem maintainers are not your 
repeat-everything-a-thousand-times patch submission QA machinery.

I have no problems explaining kernel contribution basics to newbies, but 
as a long-time kernel contributor you are expected to submit patch series 
whose quality is proportional to the amount of time you have already spent 
submitting patches. I.e. the longer the time you actively spent sending 
patches, the higher quality your patch series should become.

Instead what I see from you are the same problems over and over again: 
sloppy patches, ignored review feedback.

So to protect other people's higher quality patch flows maintainers that 
deal with you frequently often have to put your faulty submissions to the 
tail of their TODO list, until you show more reliable patterns of 
behavior. I will eventually have to stop taking patches from you 
permanently, if your abuse of review feedback continues.

Instead of complaining and blaming the maintainer you should increase the 
quality of your patch submissions instead.

Thanks,

Ingo
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: ipv4: warnings on sk_wmem_queued

2013-08-31 Thread Eric Wong
Eric Wong normalper...@yhbt.net wrote:
 I noticed these warnings on stock 3.10.9 running stress tests on
 cmogstored.git (git://bogomips.org/cmogstored.git) doing standard
 HTTP server stuff between lo and tmpfs:

I'm still running the same test (in-place upgraded cmogstored a few
times to fix some bugs), and haven't hit these warnings again
(constantly pushing around 20GB/s total).

I forget to mention cmogstored is multithreaded and idle clients
automatically migrate between threads when becoming active (using
EPOLLONESHOT), so maybe this tickles some rare race condition
somewhere...

 Aug 30 06:03:54 localhost kernel: WARNING: at net/core/stream.c:200 
 sk_stream_kill_queues+0x131/0x140()
snip
 Aug 30 06:03:54 localhost kernel: WARNING: at net/ipv4/af_inet.c:155 
 inet_sock_destruct+0x191/0x1e0()

I probably won't be in a good position to reboot/test patches until
Tuesday, though.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] driver: input: fix missing of_node_put

2013-08-31 Thread Libo Chen

decrease np device_node refcount after task completion

Libo Chen (3):
  driver: input: 88pm860x-ts: fix missing of_node_put
  driver: input: twl4030-vibra: fix missing of_node_put
  driver: input: twl6040-vibra: fix missing of_node_put

 drivers/input/misc/twl4030-vibra.c  |4 +++-
 drivers/input/misc/twl6040-vibra.c  |3 +++
 drivers/input/touchscreen/88pm860x-ts.c |   22 +++---
 3 files changed, 21 insertions(+), 8 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/7] Drop support for Renesys H8/300 architecture

2013-08-31 Thread Geert Uytterhoeven
On Fri, Aug 30, 2013 at 9:37 PM, Guenter Roeck li...@roeck-us.net wrote:
 On Fri, Aug 30, 2013 at 12:14:20PM -0700, Linus Torvalds wrote:
 On Fri, Aug 30, 2013 at 12:11 PM, Guenter Roeck li...@roeck-us.net wrote:
 
  I would not mind if Linus would agree to pull it right away for 3.12,
  but that seems to be a bit on the fast side.

 I'm ok with code deletion patches, I don't think that would be a
 problem. I didn't check them, but I assume this is all literally just
 removing code that is conditional on h8/300 config options?

 Yes.

 I found a couple more since I sent the series, but nothing significant.

 What is your preference - keep it until 3.13, or prepare it now and send you
 a pull request for 3.12 ?

It would be nice to check with Sato-san, who wanted to attend Kernel
Summit as a hobbyist architecture maintainer, and see what are his plans
and opinions.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] driver: input: 88pm860x-ts: fix missing of_node_put

2013-08-31 Thread Libo Chen

decrease np device_node refcount after task completion

Signed-off-by: Libo Chen libo.c...@huawei.com
---
 drivers/input/touchscreen/88pm860x-ts.c |   22 +++---
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/88pm860x-ts.c 
b/drivers/input/touchscreen/88pm860x-ts.c
index f7de14a..4a2fd46 100644
--- a/drivers/input/touchscreen/88pm860x-ts.c
+++ b/drivers/input/touchscreen/88pm860x-ts.c
@@ -142,14 +142,18 @@ static int pm860x_touch_dt_init(struct platform_device 
*pdev,
data |= (n  7)  PM8607_GPADC_SW_CAL_MASK;
if (data) {
ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data);
-   if (ret  0)
-   return -EINVAL;
+   if (ret  0) {
+   ret = -EINVAL;
+   goto err;
+   }
}
/* set tsi prebias time */
if (!of_property_read_u32(np, marvell,88pm860x-tsi-prebias, data)) {
ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data);
-   if (ret  0)
-   return -EINVAL;
+   if (ret  0) {
+   ret = -EINVAL;
+   goto err;
+   }
}
/* set prebias  prechg time of pen detect */
data = 0;
@@ -159,11 +163,15 @@ static int pm860x_touch_dt_init(struct platform_device 
*pdev,
data |= n  PM8607_PD_PRECHG_MASK;
if (data) {
ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data);
-   if (ret  0)
-   return -EINVAL;
+   if (ret  0) {
+   ret = -EINVAL;
+   goto err;
+   }
}
of_property_read_u32(np, marvell,88pm860x-resistor-X, res_x);
-   return 0;
+err:
+   of_node_put(np);
+   return ret;
 }
 #else
 #define pm860x_touch_dt_init(x, y, z)  (-1)
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] driver: input: twl6040-vibra: fix missing of_node_put

2013-08-31 Thread Libo Chen

decrease twl6040_core_node device_node refcount after task completion

There are two ways to implement the function of_node_put through
the marco CONFIG_OF_DYNAMIC, so it is save to call directly.

Signed-off-by: Libo Chen libo.c...@huawei.com
---
 drivers/input/misc/twl6040-vibra.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/input/misc/twl6040-vibra.c 
b/drivers/input/misc/twl6040-vibra.c
index 0c2dfc8..f16193a 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -271,12 +271,14 @@ static int twl6040_vibra_probe(struct platform_device 
*pdev)
 #endif

if (!pdata  !twl6040_core_node) {
+   of_node_put(twl6040_core_node);
dev_err(pdev-dev, platform_data not available\n);
return -EINVAL;
}

info = devm_kzalloc(pdev-dev, sizeof(*info), GFP_KERNEL);
if (!info) {
+   of_node_put(twl6040_core_node);
dev_err(pdev-dev, couldn't allocate memory\n);
return -ENOMEM;
}
@@ -304,6 +306,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
 vddvibl_uV);
of_property_read_u32(twl6040_core_node, ti,vddvibr-uV,
 vddvibr_uV);
+   of_node_put(twl6040_core_node);
}

if ((!info-vibldrv_res  !info-viblmotor_res) ||
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] driver: input: twl4030-vibra: fix missing of_node_put

2013-08-31 Thread Libo Chen

decrease node device_node refcount after task completion

Signed-off-by: Libo Chen libo.c...@huawei.com
---
 drivers/input/misc/twl4030-vibra.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/input/misc/twl4030-vibra.c 
b/drivers/input/misc/twl4030-vibra.c
index 68a5f33..b8d1526 100644
--- a/drivers/input/misc/twl4030-vibra.c
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -185,8 +185,10 @@ static bool twl4030_vibra_check_coexist(struct 
twl4030_vibra_data *pdata,
if (pdata  pdata-coexist)
return true;

-   if (of_find_node_by_name(node, codec))
+   if (of_find_node_by_name(node, codec)) {
+   of_node_put(node);
return true;
+   }

return false;
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Fix the race between the fget() and close()

2013-08-31 Thread Al Viro
On Sat, Aug 31, 2013 at 05:53:11AM +, Liu, Chuansheng wrote:

 I think I found one of possible race here(two processes P1 and P2):
 P1 has the the files_struct pointer FILES1, P2 has the files_struct pointer 
 FILES2,
 
 When P1 open file, the new struct file pointer SHARE_FILE will be installed 
 into FILES1,
 and file refcount is 1;
 
 And in P1, we can get P2's files_struct FILES2, and thru _fd_install(), we 
 can add SHARE_FILE
 into P2's FILES2.
 
 Then the same file pointer SHARE_FILE stayed in both P1 and P2's 
 files_struct, and the panic case
 will happen:
 P1P2
 Open the SHARE_FILE
 Installed SHARE_FILE into P2's file_struct FILES2

... without bumping refcount on SHARE_FILE?  Then you really have a big
problem.  task_fd_install() call is preceded by grabbing a reference
to the file we are installing, though...  BTW, /* TODO: fput? */ after
that call is really bogus - the code doesn't call fput() there and it's
quite correct as is, since at that point the reference had gone into
descriptor table we'd been installing into and doesn't need to be dropped.

 Ioctl(SHARE_FILE)When P2 
 exiting,
  fget_light()
due to FILES1-refcount is 1, 
 put_files_struct will be called,
there will be no RCU and SHARE_FILE refcount increasing
 will close all files including SHARE_FILE
 
 But at this time, P1 is still operate SHARE_FILE without the refcount safety.
 
 Then the panic will happen at vfs_ioctl() due to the SHARE_FILE has been 
 freed.
 
 Is it allowable that installing one file pointer into another FILES_STRUCT? 
 Seems binder is doing the similar things.
 In fact, if in ioctl function, we can call fget() instead of fget_light(), 
 this panic can be avoided.
 
 Is it making sense?

No, it doesn't.  For one thing, any reference in any files_struct should
contribute 1 to refcount of struct file.  For another, you can modify
files_struct *ONLY* if you hold a reference to it.  binder, a misdesigned
piece of shit it is, does that only via proc-files, which is set in
binder_mmap() by grabbing a new reference to current-files of mmap(2)
caller.  It is safe to do (nobody can switch task's -files to another
files_struct under it) and once that's done, there's a pinned reference
to that files_struct.  If, at the time of task_fd_install(), it happens
to be task-files_struct of some process, its refcount is going to be
at least 2, fdget() done by that other process will see that descriptor
table is shared and will bump the refcount of file being accessed.

The subtle part here is that mmap() does *NOT* use fdget() - the property
we are aiming for is that if at the time of fdget() descriptor table
hadn't been shared, no new references that could be used to modify it
will be acquired until the matching fdput().  So binder_mmap() can
legitimately grab a reference to the descriptor table of calling process.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] Fix the race between the fget() and close()

2013-08-31 Thread Liu, Chuansheng


 -Original Message-
 From: Al Viro [mailto:v...@ftp.linux.org.uk] On Behalf Of Al Viro
 Sent: Saturday, August 31, 2013 2:48 PM
 To: Liu, Chuansheng
 Cc: Eric Dumazet; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org
 Subject: Re: [PATCH] Fix the race between the fget() and close()
 
 On Sat, Aug 31, 2013 at 05:53:11AM +, Liu, Chuansheng wrote:
 
  I think I found one of possible race here(two processes P1 and P2):
  P1 has the the files_struct pointer FILES1, P2 has the files_struct pointer
 FILES2,
 
  When P1 open file, the new struct file pointer SHARE_FILE will be installed
 into FILES1,
  and file refcount is 1;
 
  And in P1, we can get P2's files_struct FILES2, and thru _fd_install(), we 
  can
 add SHARE_FILE
  into P2's FILES2.
 
  Then the same file pointer SHARE_FILE stayed in both P1 and P2's 
  files_struct,
 and the panic case
  will happen:
  P1
 P2
  Open the SHARE_FILE
  Installed SHARE_FILE into P2's file_struct FILES2
 
 ... without bumping refcount on SHARE_FILE?  Then you really have a big
 problem.  task_fd_install() call is preceded by grabbing a reference
 to the file we are installing, though...  BTW, /* TODO: fput? */ after
 that call is really bogus - the code doesn't call fput() there and it's
 quite correct as is, since at that point the reference had gone into
 descriptor table we'd been installing into and doesn't need to be dropped.
 
  Ioctl(SHARE_FILE)
 When P2 exiting,
   fget_light()
 due to FILES1-refcount is 1,
 put_files_struct will be called,
 there will be no RCU and SHARE_FILE refcount increasing
 will close all files including SHARE_FILE
 
  But at this time, P1 is still operate SHARE_FILE without the refcount 
  safety.
 
  Then the panic will happen at vfs_ioctl() due to the SHARE_FILE has been
 freed.
 
  Is it allowable that installing one file pointer into another FILES_STRUCT?
 Seems binder is doing the similar things.
  In fact, if in ioctl function, we can call fget() instead of fget_light(), 
  this panic
 can be avoided.
 
  Is it making sense?
 
 No, it doesn't.  For one thing, any reference in any files_struct should
 contribute 1 to refcount of struct file.  For another, you can modify
 files_struct *ONLY* if you hold a reference to it.  binder, a misdesigned
My scenario is:
P1 files_struct refcount is 1, P2's is 1 also.
P1 get_files_struct(P2)
P1 install one file into P2's files_struct
P1 put_files_struct(P2)

Then P1 and P2's files_struct refcount are 1, then when P1 is doing ioctl() and 
P2 is exiting
with put_files_struct(P2), the race will occur, my understanding is wrong?

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Fix the race between the fget() and close()

2013-08-31 Thread Al Viro
On Sat, Aug 31, 2013 at 07:01:33AM +, Liu, Chuansheng wrote:

 My scenario is:
 P1 files_struct refcount is 1, P2's is 1 also.
 P1 get_files_struct(P2)
 P1 install one file into P2's files_struct
 P1 put_files_struct(P2)
 
 Then P1 and P2's files_struct refcount are 1, then when P1 is doing ioctl() 
 and P2 is exiting
 with put_files_struct(P2), the race will occur, my understanding is wrong?

First of all, this wouldn't have been a problem (so you get a new reference
to file inserted in P2's files_struct; file refcount had been bumped, so
destruction of P2's files_struct will undo that increment of file refcount
and we are still fine).  _Removal_ in a similar scenario would have been
a problem, with P2 doing fdget() while its table isn't shared, then P1
removing a reference from it and dropping a file - the last one, at that,
since fdget() assumed that the reference would've stayed in P2's descriptor
table.  HOWEVER, P1 does not do get_files_struct(P2) at all - it's only
done by P2 in binder_mmap().

Again, the invariant to look for is this:
* if current-files had not been shared at fdget() time, it won't
be shared at matching fdput() and no entries will have been removed in
between.

task_fd_install()/task_close_fd() are done on proc-files, which contributes
to descriptor table refcount.  All other modifications are done to
current-files, which also contributes to refcount.  If at fdget() time
current-files had refcount 1, we had no other processes with task-files
pointing to this descriptor table *and* no binder_proc had their -files
pointint to it.  No new ones may appear, since new process could get
such a reference only from do_fork() called by us and new binder_proc could
get such a reference only from binder_mmap() called by us.  Neither is
called between fdget() and fdput().  So in that case the only reference
to this descriptor table will remain current-files and all removals
would have to be done by ourselves (and not via task_close_fd(), at that).

And AFAICS, binder_lock() prevents proc-files being dropped under
task_close_fd() and task_fd_install().  Hell knows...

How reproducible it is?  Do you have any more instances, or had that
been a one-off panic?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] Fix the race between the fget() and close()

2013-08-31 Thread Liu, Chuansheng


 -Original Message-
 From: Al Viro [mailto:v...@ftp.linux.org.uk] On Behalf Of Al Viro
 Sent: Saturday, August 31, 2013 3:36 PM
 To: Liu, Chuansheng
 Cc: Eric Dumazet; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org
 Subject: Re: [PATCH] Fix the race between the fget() and close()
 
 On Sat, Aug 31, 2013 at 07:01:33AM +, Liu, Chuansheng wrote:
 
  My scenario is:
  P1 files_struct refcount is 1, P2's is 1 also.
  P1 get_files_struct(P2)
  P1 install one file into P2's files_struct
  P1 put_files_struct(P2)
 
  Then P1 and P2's files_struct refcount are 1, then when P1 is doing ioctl() 
  and
 P2 is exiting
  with put_files_struct(P2), the race will occur, my understanding is wrong?
 
 First of all, this wouldn't have been a problem (so you get a new reference
 to file inserted in P2's files_struct; file refcount had been bumped, so
 destruction of P2's files_struct will undo that increment of file refcount
 and we are still fine).  _Removal_ in a similar scenario would have been
 a problem, with P2 doing fdget() while its table isn't shared, then P1
 removing a reference from it and dropping a file - the last one, at that,
 since fdget() assumed that the reference would've stayed in P2's descriptor
 table.  HOWEVER, P1 does not do get_files_struct(P2) at all - it's only
 done by P2 in binder_mmap().
Got it, thanks. In other process, the fget() + _fd_install() should be the same
as the process call open() directly, and the file reference count will be at 
least 2.

 
 Again, the invariant to look for is this:
   * if current-files had not been shared at fdget() time, it won't
 be shared at matching fdput() and no entries will have been removed in
 between.
 
 task_fd_install()/task_close_fd() are done on proc-files, which contributes
 to descriptor table refcount.  All other modifications are done to
 current-files, which also contributes to refcount.  If at fdget() time
 current-files had refcount 1, we had no other processes with task-files
 pointing to this descriptor table *and* no binder_proc had their -files
 pointint to it.  No new ones may appear, since new process could get
 such a reference only from do_fork() called by us and new binder_proc could
 get such a reference only from binder_mmap() called by us.  Neither is
 called between fdget() and fdput().  So in that case the only reference
 to this descriptor table will remain current-files and all removals
 would have to be done by ourselves (and not via task_close_fd(), at that).
 
 And AFAICS, binder_lock() prevents proc-files being dropped under
 task_close_fd() and task_fd_install().  Hell knows...
 
 How reproducible it is?  Do you have any more instances, or had that
 been a one-off panic?
Just meet once yet.


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[REGRESSION 3.11-rc1+] wm8775 9-001b: I2C: cannot write ??? to register R??

2013-08-31 Thread Knut Petersen

Hi Linus!

It would be nice to have head cx88fix of git.linuxtv.org/hverkuil/media_tree.git
(git.linuxtv.org/hverkuil/media_tree.git/commit/5dce3635bf803cfe9dde84e00f5f9594439e6c02)
in 3.11 as it is a trivial and tested fix for a regression introduced between 
3.10 and 3.11-rc1.

see http://www.gossamer-threads.com/lists/linux/kernel/1771751?#1771751

cu,
 Knut
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL 00/15] perf/core improvements and fixes

2013-08-31 Thread Ingo Molnar

* Arnaldo Carvalho de Melo a...@infradead.org wrote:

 From: Arnaldo Carvalho de Melo a...@ghostprotocols.net
 
 Hi Ingo,
 
   Please consider pulling,
 
 - Arnaldo
 
 The following changes since commit 00e4cb1ced1b17c35465defafe86d156cbd7544e:
 
   Merge tag 'perf-core-for-mingo' of 
 git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core 
 (2013-08-29 12:02:34 +0200)
 
 are available in the git repository at:
 
 
   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux 
 tags/perf-core-for-mingo
 
 for you to fetch changes up to f2935f3e585226b8203ec3861907e1cb16ad3d6a:
 
   perf trace: Handle missing HUGEPAGE defines (2013-08-30 15:43:28 -0300)
 
 
 perf/core improvements and fixes:
 
 . Tidy up sample parsing validation, from Adrian Hunter.
 
 . Make events stream always parsable by adding a new sample_type bit:
   PERF_SAMPLE_IDENTIFIER, that when requested will be always aat a fixed
   position in all PERF_RECORD_ records, from Adrian Hunter.
 
 . Add a sample parsing test, from Adrian Hunter.
 
 . Add option to 'perf trace' to analyze events in a file versus live,
   so that one can do:
 
  [root@zoo ~]# perf record -a -e raw_syscalls:* sleep 1
  [ perf record: Woken up 0 times to write data ]
  [ perf record: Captured and wrote 25.150 MB perf.data (~1098836 samples) ]
  [root@zoo ~]# perf trace -i perf.data -e futex --duration 1
 17.799 ( 1.020 ms): 7127 futex(uaddr: 0x7fff3f6c6674, op: 393, val: 1, 
 utime: 0x7fff3f6c6470, ua
113.344 (95.429 ms): 7127 futex(uaddr: 0x7fff3f6c6674, op: 393, val: 1, 
 utime: 0x7fff3f6c6470, uaddr2: 0x7fff3f6c6648, val3: 4294967
133.778 ( 1.042 ms): 18004 futex(uaddr: 0x7fff3f6c6674, op: 393, val: 1, 
 utime: 0x7fff3f6c6470, uaddr2: 0x7fff3f6c6648, val3: 429496
  [root@zoo ~]#
 
  From David Ahern.
 
 . Honor target pid / tid options in 'perf trace' when analyzing a file,
   from David Ahern.
 
 . Handle missing HUGEPAGE defines in the mmap beautifier in 'perf trace',
   from David Ahern.
 
 Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
 
 
 Adrian Hunter (11):
   perf tools: change machine__findnew_thread() to set thread pid
   perf evsel: Tidy up sample parsing overflow checking
   perf callchain: Remove unnecessary validation
   perf tools: Remove references to struct ip_event
   perf: make events stream always parsable
   perf evlist: Move perf_evlist__config() to a new source file
   perf tools: Add support for PERF_SAMPLE_IDENTIFIER
   perf tools: Add missing 'abi' member to 'struct regs_dump'
   perf tools: Expand perf_event__synthesize_sample()
   perf tools: Add a function to calculate sample event size
   perf tests: Add a sample parsing test
 
 David Ahern (4):
   perf evlist: Add tracepoint lookup by name
   perf trace: Add option to analyze events in a file versus live
   perf trace: Honor target pid / tid options when analyzing a file
   perf trace: Handle missing HUGEPAGE defines
 
  include/uapi/linux/perf_event.h |  27 ++-
  kernel/events/core.c|  11 +-
  tools/perf/Documentation/perf-trace.txt |   4 +
  tools/perf/Makefile |   2 +
  tools/perf/builtin-inject.c |   8 +-
  tools/perf/builtin-kmem.c   |   3 +-
  tools/perf/builtin-kvm.c|   2 +-
  tools/perf/builtin-lock.c   |   3 +-
  tools/perf/builtin-mem.c|   2 +-
  tools/perf/builtin-report.c |   2 +-
  tools/perf/builtin-sched.c  |  20 +-
  tools/perf/builtin-script.c |   3 +-
  tools/perf/builtin-top.c|  11 +-
  tools/perf/builtin-trace.c  | 157 -
  tools/perf/tests/builtin-test.c |   4 +
  tools/perf/tests/code-reading.c |   4 +-
  tools/perf/tests/hists_link.c   |  23 +-
  tools/perf/tests/mmap-basic.c   |   2 +-
  tools/perf/tests/sample-parsing.c   | 316 +
  tools/perf/tests/tests.h|   1 +
  tools/perf/util/build-id.c  |  11 +-
  tools/perf/util/callchain.c |   8 -
  tools/perf/util/callchain.h |   5 -
  tools/perf/util/event.c |   5 +-
  tools/perf/util/event.h |  18 +-
  tools/perf/util/evlist.c| 140 +--
  tools/perf/util/evlist.h|  12 +-
  tools/perf/util/evsel.c | 405 
 
  tools/perf/util/evsel.h |  14 +-
  tools/perf/util/machine.c   |  22 +-
  tools/perf/util/machine.h   |   3 +-
  tools/perf/util/record.c| 108 +
  tools/perf/util/session.c   |  32 +--
  33 files changed, 1193 insertions(+), 195 deletions(-)
  create mode 100644 tools/perf/tests/sample-parsing.c
  

Re: kernel deadlock

2013-08-31 Thread Gerlando Falauto

Hi Stephen,


Just curious. Do you have this patch from 3.11 applied to your 3.10
kernel tree?


Nope, I didn't. But I applied it, and it doesn't seem to make a 
difference, unfortunately. :-(


Thanks for your help anyway!
Gerlando



commit 971ee28cbd1ccd87b3164facd9359a534c1d2892
Author: Peter Zijlstra pet...@infradead.org
Date:   Fri Jun 28 11:18:53 2013 +0200

 sched: Fix HRTICK

 David reported that the HRTICK sched feature was borken; which was
enough
 motivation for me to finally fix it ;-)

 We should not allow hrtimer code to do softirq wakeups while holding
schedul
er
 locks. The hrtimer code only needs this when we accidentally try to
program
an
 expired time. We don't much care about those anyway since we have
the regula
r
 tick to fall back to.

 Reported-by: David Ahern dsah...@gmail.com
 Tested-by: David Ahern dsah...@gmail.com
 Signed-off-by: Peter Zijlstra pet...@infradead.org
 Link:
http://lkml.kernel.org/r/20130628091853.GE29209@dyad.programming.kicks
-ass.net
 Signed-off-by: Ingo Molnar mi...@kernel.org



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Add support for PERF_SAMPLE_IDENTIFIER

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  75562573bab35b129cfd342fc2bcf89da84a6644
Gitweb: http://git.kernel.org/tip/75562573bab35b129cfd342fc2bcf89da84a6644
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:09 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 16:09:31 -0300

perf tools: Add support for PERF_SAMPLE_IDENTIFIER

Enable parsing of samples with sample format bit PERF_SAMPLE_IDENTIFIER.
In addition, if the kernel supports it, prefer it to selecting
PERF_SAMPLE_ID thereby allowing non-matching sample types.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-8-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/builtin-report.c   |   2 +-
 tools/perf/tests/mmap-basic.c |   2 +-
 tools/perf/util/event.h   |   3 +-
 tools/perf/util/evlist.c  | 111 +++---
 tools/perf/util/evlist.h  |   8 ++-
 tools/perf/util/evsel.c   | 101 --
 tools/perf/util/evsel.h   |  14 +-
 tools/perf/util/record.c  |  89 +++--
 tools/perf/util/session.c |   2 +-
 9 files changed, 310 insertions(+), 22 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 958a56a..9725aa3 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -365,7 +365,7 @@ static int process_read_event(struct perf_tool *tool,
 static int perf_report__setup_sample_type(struct perf_report *rep)
 {
struct perf_session *self = rep-session;
-   u64 sample_type = perf_evlist__sample_type(self-evlist);
+   u64 sample_type = perf_evlist__combined_sample_type(self-evlist);
 
if (!self-fd_pipe  !(sample_type  PERF_SAMPLE_CALLCHAIN)) {
if (sort__has_parent) {
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index 5b1b5ab..c4185b9 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -72,7 +72,7 @@ int test__basic_mmap(void)
}
 
evsels[i]-attr.wakeup_events = 1;
-   perf_evsel__set_sample_id(evsels[i]);
+   perf_evsel__set_sample_id(evsels[i], false);
 
perf_evlist__add(evlist, evsels[i]);
 
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 19d911c..4913339 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -53,7 +53,8 @@ struct read_event {
(PERF_SAMPLE_IP | PERF_SAMPLE_TID | \
 PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR |  \
PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID |\
-PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
+PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \
+PERF_SAMPLE_IDENTIFIER)
 
 struct sample_event {
struct perf_event_headerheader;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 9d682e5..6a629af 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -49,6 +49,21 @@ struct perf_evlist *perf_evlist__new(void)
return evlist;
 }
 
+/**
+ * perf_evlist__set_id_pos - set the positions of event ids.
+ * @evlist: selected event list
+ *
+ * Events with compatible sample types all have the same id_pos
+ * and is_pos.  For convenience, put a copy on evlist.
+ */
+void perf_evlist__set_id_pos(struct perf_evlist *evlist)
+{
+   struct perf_evsel *first = perf_evlist__first(evlist);
+
+   evlist-id_pos = first-id_pos;
+   evlist-is_pos = first-is_pos;
+}
+
 static void perf_evlist__purge(struct perf_evlist *evlist)
 {
struct perf_evsel *pos, *n;
@@ -79,15 +94,20 @@ void perf_evlist__delete(struct perf_evlist *evlist)
 void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry)
 {
list_add_tail(entry-node, evlist-entries);
-   ++evlist-nr_entries;
+   if (!evlist-nr_entries++)
+   perf_evlist__set_id_pos(evlist);
 }
 
 void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
   struct list_head *list,
   int nr_entries)
 {
+   bool set_id_pos = !evlist-nr_entries;
+
list_splice_tail(list, evlist-entries);
evlist-nr_entries += nr_entries;
+   if (set_id_pos)
+   perf_evlist__set_id_pos(evlist);
 }
 
 void __perf_evlist__set_leader(struct list_head *list)
@@ -349,6 +369,55 @@ struct perf_evsel *perf_evlist__id2evsel(struct 
perf_evlist *evlist, u64 id)
return NULL;
 }
 
+static int perf_evlist__event2id(struct 

[tip:perf/core] perf tools: Expand perf_event__synthesize_sample( )

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  d03f2170546d2f0c236a42706d211e15ffb64184
Gitweb: http://git.kernel.org/tip/d03f2170546d2f0c236a42706d211e15ffb64184
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:11 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 16:14:20 -0300

perf tools: Expand perf_event__synthesize_sample()

Expand perf_event__synthesize_sample() to handle all sample format bits.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-10-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/builtin-inject.c |  4 +-
 tools/perf/util/event.h |  1 +
 tools/perf/util/evsel.c | 95 -
 3 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index ffacd46..9b336fd 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -301,7 +301,9 @@ found:
sample_sw.period = sample-period;
sample_sw.time   = sample-time;
perf_event__synthesize_sample(event_sw, evsel-attr.sample_type,
- sample_sw, false);
+ evsel-attr.sample_regs_user,
+ evsel-attr.read_format, sample_sw,
+ false);
build_id__mark_dso_hit(tool, event_sw, sample_sw, evsel, machine);
return perf_event__repipe(tool, event_sw, sample_sw, machine);
 }
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index f959801..1c80e13 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -230,6 +230,7 @@ int perf_event__preprocess_sample(const union perf_event 
*self,
 const char *perf_event__name(unsigned int id);
 
 int perf_event__synthesize_sample(union perf_event *event, u64 type,
+ u64 sample_regs_user, u64 read_format,
  const struct perf_sample *sample,
  bool swapped);
 
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 1184188..7d62373 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1416,7 +1416,6 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, 
union perf_event *event,
}
 
if (type  PERF_SAMPLE_REGS_USER) {
-   /* First u64 tells us if we have any regs in sample. */
OVERFLOW_CHECK_u64(array);
data-user_regs.abi = *array;
array++;
@@ -1467,11 +1466,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, 
union perf_event *event,
 }
 
 int perf_event__synthesize_sample(union perf_event *event, u64 type,
+ u64 sample_regs_user, u64 read_format,
  const struct perf_sample *sample,
  bool swapped)
 {
u64 *array;
-
+   size_t sz;
/*
 * used for cross-endian analysis. See git commit 65014ab3
 * for why this goofiness is needed.
@@ -1544,6 +1544,97 @@ int perf_event__synthesize_sample(union perf_event 
*event, u64 type,
array++;
}
 
+   if (type  PERF_SAMPLE_READ) {
+   if (read_format  PERF_FORMAT_GROUP)
+   *array = sample-read.group.nr;
+   else
+   *array = sample-read.one.value;
+   array++;
+
+   if (read_format  PERF_FORMAT_TOTAL_TIME_ENABLED) {
+   *array = sample-read.time_enabled;
+   array++;
+   }
+
+   if (read_format  PERF_FORMAT_TOTAL_TIME_RUNNING) {
+   *array = sample-read.time_running;
+   array++;
+   }
+
+   /* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */
+   if (read_format  PERF_FORMAT_GROUP) {
+   sz = sample-read.group.nr *
+sizeof(struct sample_read_value);
+   memcpy(array, sample-read.group.values, sz);
+   array = (void *)array + sz;
+   } else {
+   *array = sample-read.one.id;
+   array++;
+   }
+   }
+
+   if (type  PERF_SAMPLE_CALLCHAIN) {
+   sz = (sample-callchain-nr + 1) * sizeof(u64);
+   memcpy(array, sample-callchain, sz);
+   array = (void *)array + sz;
+   }
+
+   if (type  PERF_SAMPLE_RAW) {
+  

[tip:perf/core] perf: make events stream always parsable

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  ff3d527cebc1fa3707c617bfe9e74f53fcfb0955
Gitweb: http://git.kernel.org/tip/ff3d527cebc1fa3707c617bfe9e74f53fcfb0955
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:07 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 15:40:03 -0300

perf: make events stream always parsable

The event stream is not always parsable because the format of a sample
is dependent on the sample_type of the selected event.  When there is
more than one selected event and the sample_types are not the same then
parsing becomes problematic.  A sample can be matched to its selected
event using the ID that is allocated when the event is opened.
Unfortunately, to get the ID from the sample means first parsing it.

This patch adds a new sample format bit PERF_SAMPLE_IDENTIFER that puts
the ID at a fixed position so that the ID can be retrieved without
parsing the sample.  For sample events, that is the first position
immediately after the header.  For non-sample events, that is the last
position.

In this respect parsing samples requires that the sample_type and ID
values are recorded.  For example, perf tools records struct
perf_event_attr and the IDs within the perf.data file.  Those must be
read first before it is possible to parse samples found later in the
perf.data file.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Tested-by: Stephane Eranian eran...@google.com
Acked-by: Peter Zijlstra pet...@infradead.org
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-6-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 include/uapi/linux/perf_event.h | 27 ---
 kernel/events/core.c| 11 ++-
 2 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 62c25a2..42cb7b6 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -134,8 +134,9 @@ enum perf_event_sample_format {
PERF_SAMPLE_STACK_USER  = 1U  13,
PERF_SAMPLE_WEIGHT  = 1U  14,
PERF_SAMPLE_DATA_SRC= 1U  15,
+   PERF_SAMPLE_IDENTIFIER  = 1U  16,
 
-   PERF_SAMPLE_MAX = 1U  16, /* non-ABI */
+   PERF_SAMPLE_MAX = 1U  17, /* non-ABI */
 };
 
 /*
@@ -492,12 +493,12 @@ enum perf_event_type {
/*
 * If perf_event_attr.sample_id_all is set then all event types will
 * have the sample_type selected fields related to where/when
-* (identity) an event took place (TID, TIME, ID, CPU, STREAM_ID)
-* described in PERF_RECORD_SAMPLE below, it will be stashed just after
-* the perf_event_header and the fields already present for the existing
-* fields, i.e. at the end of the payload. That way a newer perf.data
-* file will be supported by older perf tools, with these new optional
-* fields being ignored.
+* (identity) an event took place (TID, TIME, ID, STREAM_ID, CPU,
+* IDENTIFIER) described in PERF_RECORD_SAMPLE below, it will be stashed
+* just after the perf_event_header and the fields already present for
+* the existing fields, i.e. at the end of the payload. That way a newer
+* perf.data file will be supported by older perf tools, with these new
+* optional fields being ignored.
 *
 * struct sample_id {
 *  { u32   pid, tid; }  PERF_SAMPLE_TID
@@ -505,7 +506,12 @@ enum perf_event_type {
 *  { u64   id;   }  PERF_SAMPLE_ID
 *  { u64   stream_id;}  PERF_SAMPLE_STREAM_ID
 *  { u32   cpu, res; }  PERF_SAMPLE_CPU
+*  { u64   id;   }  PERF_SAMPLE_IDENTIFIER
 * }  perf_event_attr::sample_id_all
+*
+* Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID.  The
+* advantage of PERF_SAMPLE_IDENTIFIER is that its position is fixed
+* relative to header.size.
 */
 
/*
@@ -594,6 +600,13 @@ enum perf_event_type {
 * struct {
 *  struct perf_event_headerheader;
 *
+*  #
+*  # Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID.
+*  # The advantage of PERF_SAMPLE_IDENTIFIER is that its position
+*  # is fixed relative to header.
+*  #
+*
+*  { u64   id;   }  PERF_SAMPLE_IDENTIFIER
 *  

[tip:perf/core] perf evlist: Add tracepoint lookup by name

2013-08-31 Thread tip-bot for David Ahern
Commit-ID:  a2f2804a7142b043dafd39f21b86777840e1a78c
Gitweb: http://git.kernel.org/tip/a2f2804a7142b043dafd39f21b86777840e1a78c
Author: David Ahern dsah...@gmail.com
AuthorDate: Wed, 28 Aug 2013 22:29:51 -0600
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 17:41:02 -0300

perf evlist: Add tracepoint lookup by name

Will be used by upcoming perf-trace replay option.

Signed-off-by: David Ahern dsah...@gmail.com
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377750593-48046-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/util/evlist.c | 15 +++
 tools/perf/util/evlist.h |  4 
 2 files changed, 19 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 6a629af..5df4ca9 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -208,6 +208,21 @@ perf_evlist__find_tracepoint_by_id(struct perf_evlist 
*evlist, int id)
return NULL;
 }
 
+struct perf_evsel *
+perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,
+const char *name)
+{
+   struct perf_evsel *evsel;
+
+   list_for_each_entry(evsel, evlist-entries, node) {
+   if ((evsel-attr.type == PERF_TYPE_TRACEPOINT) 
+   (strcmp(evsel-name, name) == 0))
+   return evsel;
+   }
+
+   return NULL;
+}
+
 int perf_evlist__add_newtp(struct perf_evlist *evlist,
   const char *sys, const char *name, void *handler)
 {
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index ab95d72..841a394 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -74,6 +74,10 @@ int perf_evlist__set_filter(struct perf_evlist *evlist, 
const char *filter);
 struct perf_evsel *
 perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id);
 
+struct perf_evsel *
+perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,
+const char *name);
+
 void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
 int cpu, int thread, u64 id);
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Add a function to calculate sample event size

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  b1cf6f65aa7096984836addab7cec6b5b6d4393a
Gitweb: http://git.kernel.org/tip/b1cf6f65aa7096984836addab7cec6b5b6d4393a
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:12 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 16:44:26 -0300

perf tools: Add a function to calculate sample event size

Add perf_event__sample_event_size() which can be used when synthesizing
sample events to determine how big the resulting event will be, and
therefore how much memory to allocate.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-11-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/util/event.h |  2 ++
 tools/perf/util/evsel.c | 92 +
 2 files changed, 94 insertions(+)

diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 1c80e13..93130d8 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -229,6 +229,8 @@ int perf_event__preprocess_sample(const union perf_event 
*self,
 
 const char *perf_event__name(unsigned int id);
 
+size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 
type,
+u64 sample_regs_user, u64 read_format);
 int perf_event__synthesize_sample(union perf_event *event, u64 type,
  u64 sample_regs_user, u64 read_format,
  const struct perf_sample *sample,
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 7d62373..e8745fb 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1465,6 +1465,98 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, 
union perf_event *event,
return 0;
 }
 
+size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 
type,
+u64 sample_regs_user, u64 read_format)
+{
+   size_t sz, result = sizeof(struct sample_event);
+
+   if (type  PERF_SAMPLE_IDENTIFIER)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_IP)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_TID)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_TIME)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_ADDR)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_ID)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_STREAM_ID)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_CPU)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_PERIOD)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_READ) {
+   result += sizeof(u64);
+   if (read_format  PERF_FORMAT_TOTAL_TIME_ENABLED)
+   result += sizeof(u64);
+   if (read_format  PERF_FORMAT_TOTAL_TIME_RUNNING)
+   result += sizeof(u64);
+   /* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */
+   if (read_format  PERF_FORMAT_GROUP) {
+   sz = sample-read.group.nr *
+sizeof(struct sample_read_value);
+   result += sz;
+   } else {
+   result += sizeof(u64);
+   }
+   }
+
+   if (type  PERF_SAMPLE_CALLCHAIN) {
+   sz = (sample-callchain-nr + 1) * sizeof(u64);
+   result += sz;
+   }
+
+   if (type  PERF_SAMPLE_RAW) {
+   result += sizeof(u32);
+   result += sample-raw_size;
+   }
+
+   if (type  PERF_SAMPLE_BRANCH_STACK) {
+   sz = sample-branch_stack-nr * sizeof(struct branch_entry);
+   sz += sizeof(u64);
+   result += sz;
+   }
+
+   if (type  PERF_SAMPLE_REGS_USER) {
+   if (sample-user_regs.abi) {
+   result += sizeof(u64);
+   sz = hweight_long(sample_regs_user) * sizeof(u64);
+   result += sz;
+   } else {
+   result += sizeof(u64);
+   }
+   }
+
+   if (type  PERF_SAMPLE_STACK_USER) {
+   sz = sample-user_stack.size;
+   result += sizeof(u64);
+   if (sz) {
+   result += sz;
+   result += sizeof(u64);
+   }
+   }
+
+   if (type  PERF_SAMPLE_WEIGHT)
+   result += sizeof(u64);
+
+   if (type  PERF_SAMPLE_DATA_SRC)
+   

[tip:perf/core] perf tests: Add a sample parsing test

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  045f8cd8542d2fcd424a32fa10fcd3dd29c6d374
Gitweb: http://git.kernel.org/tip/045f8cd8542d2fcd424a32fa10fcd3dd29c6d374
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:13 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 16:46:58 -0300

perf tests: Add a sample parsing test

Add a test that checks that sample parsing is correctly implemented.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-12-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/Makefile   |   1 +
 tools/perf/tests/builtin-test.c   |   4 +
 tools/perf/tests/sample-parsing.c | 316 ++
 tools/perf/tests/tests.h  |   1 +
 4 files changed, 322 insertions(+)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 845cc76..ecebfd0 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -439,6 +439,7 @@ PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT)
 ifneq ($(OUTPUT),)
   CFLAGS += -I$(OUTPUT)
 endif
+LIB_OBJS += $(OUTPUT)tests/sample-parsing.o
 
 ifdef NO_LIBELF
 EXTLIBS := $(filter-out -lelf,$(EXTLIBS))
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index f5af192..8ad9415 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -104,6 +104,10 @@ static struct test {
.func = test__code_reading,
},
{
+   .desc = Test sample parsing,
+   .func = test__sample_parsing,
+   },
+   {
.func = NULL,
},
 };
diff --git a/tools/perf/tests/sample-parsing.c 
b/tools/perf/tests/sample-parsing.c
new file mode 100644
index 000..77f598d
--- /dev/null
+++ b/tools/perf/tests/sample-parsing.c
@@ -0,0 +1,316 @@
+#include stdbool.h
+#include inttypes.h
+
+#include util.h
+#include event.h
+#include evsel.h
+
+#include tests.h
+
+#define COMP(m) do {   \
+   if (s1-m != s2-m) {   \
+   pr_debug(Samples differ at '#m'\n); \
+   return false;   \
+   }   \
+} while (0)
+
+#define MCOMP(m) do {  \
+   if (memcmp(s1-m, s2-m, sizeof(s1-m))) {\
+   pr_debug(Samples differ at '#m'\n); \
+   return false;   \
+   }   \
+} while (0)
+
+static bool samples_same(const struct perf_sample *s1,
+const struct perf_sample *s2, u64 type, u64 regs_user,
+u64 read_format)
+{
+   size_t i;
+
+   if (type  PERF_SAMPLE_IDENTIFIER)
+   COMP(id);
+
+   if (type  PERF_SAMPLE_IP)
+   COMP(ip);
+
+   if (type  PERF_SAMPLE_TID) {
+   COMP(pid);
+   COMP(tid);
+   }
+
+   if (type  PERF_SAMPLE_TIME)
+   COMP(time);
+
+   if (type  PERF_SAMPLE_ADDR)
+   COMP(addr);
+
+   if (type  PERF_SAMPLE_ID)
+   COMP(id);
+
+   if (type  PERF_SAMPLE_STREAM_ID)
+   COMP(stream_id);
+
+   if (type  PERF_SAMPLE_CPU)
+   COMP(cpu);
+
+   if (type  PERF_SAMPLE_PERIOD)
+   COMP(period);
+
+   if (type  PERF_SAMPLE_READ) {
+   if (read_format  PERF_FORMAT_GROUP)
+   COMP(read.group.nr);
+   else
+   COMP(read.one.value);
+   if (read_format  PERF_FORMAT_TOTAL_TIME_ENABLED)
+   COMP(read.time_enabled);
+   if (read_format  PERF_FORMAT_TOTAL_TIME_RUNNING)
+   COMP(read.time_running);
+   /* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */
+   if (read_format  PERF_FORMAT_GROUP) {
+   for (i = 0; i  s1-read.group.nr; i++)
+   MCOMP(read.group.values[i]);
+   } else {
+   COMP(read.one.id);
+   }
+   }
+
+   if (type  PERF_SAMPLE_CALLCHAIN) {
+   COMP(callchain-nr);
+   for (i = 0; i  s1-callchain-nr; i++)
+   COMP(callchain-ips[i]);
+   }
+
+   if (type  PERF_SAMPLE_RAW) {
+   COMP(raw_size);
+   if (memcmp(s1-raw_data, s2-raw_data, s1-raw_size)) {
+   pr_debug(Samples differ at 'raw_data'\n);
+   return false;
+   

[tip:perf/core] perf trace: Handle missing HUGEPAGE defines

2013-08-31 Thread tip-bot for David Ahern
Commit-ID:  f2935f3e585226b8203ec3861907e1cb16ad3d6a
Gitweb: http://git.kernel.org/tip/f2935f3e585226b8203ec3861907e1cb16ad3d6a
Author: David Ahern dsah...@gmail.com
AuthorDate: Tue, 27 Aug 2013 10:50:40 -0600
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Fri, 30 Aug 2013 15:43:28 -0300

perf trace: Handle missing HUGEPAGE defines

Needed for compile on Fedora 12 which goes back to the 2.6.32 kernel.
Might be needed for RHEL6. I use F12 to compile static binaries for
Wind River Linux 4.3.

Signed-off-by: David Ahern dsah...@gmail.com
Link: http://lkml.kernel.org/n/tip-nd0d7rbajgm8k6tah3xv3...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/builtin-trace.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 845facc..69a065e 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -71,7 +71,9 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, 
size_t size, unsigned
P_MMAP_FLAG(FILE);
P_MMAP_FLAG(FIXED);
P_MMAP_FLAG(GROWSDOWN);
+#ifdef MAP_HUGETLB
P_MMAP_FLAG(HUGETLB);
+#endif
P_MMAP_FLAG(LOCKED);
P_MMAP_FLAG(NONBLOCK);
P_MMAP_FLAG(NORESERVE);
@@ -110,8 +112,12 @@ static size_t syscall_arg__scnprintf_madvise_behavior(char 
*bf, size_t size, uns
 #endif
P_MADV_BHV(MERGEABLE);
P_MADV_BHV(UNMERGEABLE);
+#ifdef MADV_HUGEPAGE
P_MADV_BHV(HUGEPAGE);
+#endif
+#ifdef MADV_NOHUGEPAGE
P_MADV_BHV(NOHUGEPAGE);
+#endif
 #ifdef MADV_DONTDUMP
P_MADV_BHV(DONTDUMP);
 #endif
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Add option to analyze events in a file versus live

2013-08-31 Thread tip-bot for David Ahern
Commit-ID:  6810fc915f7a89d8134edb3996dbbf8eac386c26
Gitweb: http://git.kernel.org/tip/6810fc915f7a89d8134edb3996dbbf8eac386c26
Author: David Ahern dsah...@gmail.com
AuthorDate: Wed, 28 Aug 2013 22:29:52 -0600
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 17:42:34 -0300

perf trace: Add option to analyze events in a file versus live

Allows capture of raw_syscall:* events and analyzed at a later time.

v2: change -i option from inherit to input name for consistency with
other perf commands

Signed-off-by: David Ahern dsah...@gmail.com
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377750593-48046-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/Documentation/perf-trace.txt |  4 ++
 tools/perf/builtin-trace.c  | 98 -
 2 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-trace.txt 
b/tools/perf/Documentation/perf-trace.txt
index fe19811..daccd2c 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -74,6 +74,10 @@ the thread executes on the designated CPUs. Default is to 
monitor all CPUs.
 --sched:
Accrue thread runtime and provide a summary at the end of the session.
 
+-i
+--input
+   Process events from a given perf data file.
+
 SEE ALSO
 
 linkperf:perf-record[1], linkperf:perf-script[1]
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 88387c5..2a6ebe1 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -4,6 +4,7 @@
 #include util/debug.h
 #include util/evlist.h
 #include util/machine.h
+#include util/session.h
 #include util/thread.h
 #include util/parse-options.h
 #include util/strlist.h
@@ -652,6 +653,36 @@ out_dump:
return 0;
 }
 
+static int trace__process_sample(struct perf_tool *tool,
+union perf_event *event __maybe_unused,
+struct perf_sample *sample,
+struct perf_evsel *evsel,
+struct machine *machine __maybe_unused)
+{
+   struct trace *trace = container_of(tool, struct trace, tool);
+   int err = 0;
+
+   tracepoint_handler handler = evsel-handler.func;
+
+   if (trace-base_time == 0)
+   trace-base_time = sample-time;
+
+   if (handler)
+   handler(trace, evsel, sample);
+
+   return err;
+}
+
+static bool
+perf_session__has_tp(struct perf_session *session, const char *name)
+{
+   struct perf_evsel *evsel;
+
+   evsel = perf_evlist__find_tracepoint_by_name(session-evlist, name);
+
+   return evsel != NULL;
+}
+
 static int trace__run(struct trace *trace, int argc, const char **argv)
 {
struct perf_evlist *evlist = perf_evlist__new();
@@ -791,6 +822,65 @@ out:
return err;
 }
 
+static int trace__replay(struct trace *trace)
+{
+   const struct perf_evsel_str_handler handlers[] = {
+   { raw_syscalls:sys_enter,  trace__sys_enter, },
+   { raw_syscalls:sys_exit,   trace__sys_exit, },
+   };
+
+   struct perf_session *session;
+   int err = -1;
+
+   trace-tool.sample= trace__process_sample;
+   trace-tool.mmap  = perf_event__process_mmap;
+   trace-tool.comm  = perf_event__process_comm;
+   trace-tool.exit  = perf_event__process_exit;
+   trace-tool.fork  = perf_event__process_fork;
+   trace-tool.attr  = perf_event__process_attr;
+   trace-tool.tracing_data = perf_event__process_tracing_data;
+   trace-tool.build_id  = perf_event__process_build_id;
+
+   trace-tool.ordered_samples = true;
+   trace-tool.ordering_requires_timestamps = true;
+
+   /* add tid to output */
+   trace-multiple_threads = true;
+
+   if (symbol__init()  0)
+   return -1;
+
+   session = perf_session__new(input_name, O_RDONLY, 0, false,
+   trace-tool);
+   if (session == NULL)
+   return -ENOMEM;
+
+   err = perf_session__set_tracepoints_handlers(session, handlers);
+   if (err)
+   goto out;
+
+   if (!perf_session__has_tp(session, raw_syscalls:sys_enter)) {
+   pr_err(Data file does not have raw_syscalls:sys_enter 
events\n);
+   goto out;
+   }
+
+   if (!perf_session__has_tp(session, raw_syscalls:sys_exit)) {
+   pr_err(Data file does not have raw_syscalls:sys_exit 
events\n);
+   goto out;
+   }
+
+   setup_pager();
+
+   err = perf_session__process_events(session, trace-tool);
+   if 

[tip:perf/core] perf trace: Honor target pid / tid options when analyzing a file

2013-08-31 Thread tip-bot for David Ahern
Commit-ID:  bdc896617b4fcaa9c89da9a9c5b72660f6741d46
Gitweb: http://git.kernel.org/tip/bdc896617b4fcaa9c89da9a9c5b72660f6741d46
Author: David Ahern dsah...@gmail.com
AuthorDate: Wed, 28 Aug 2013 22:29:53 -0600
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 17:45:39 -0300

perf trace: Honor target pid / tid options when analyzing a file

Allows capture of raw_syscall events for all processes or threads in a
task and then analyzing specific ones.

Signed-off-by: David Ahern dsah...@gmail.com
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377750593-48046-4-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/builtin-trace.c | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 2a6ebe1..845facc 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -8,6 +8,7 @@
 #include util/thread.h
 #include util/parse-options.h
 #include util/strlist.h
+#include util/intlist.h
 #include util/thread_map.h
 
 #include libaudit.h
@@ -259,6 +260,8 @@ struct trace {
unsigned long   nr_events;
struct strlist  *ev_qualifier;
boolnot_ev_qualifier;
+   struct intlist  *tid_list;
+   struct intlist  *pid_list;
boolsched;
boolmultiple_threads;
double  duration_filter;
@@ -653,6 +656,18 @@ out_dump:
return 0;
 }
 
+static bool skip_sample(struct trace *trace, struct perf_sample *sample)
+{
+   if ((trace-pid_list  intlist__find(trace-pid_list, sample-pid)) ||
+   (trace-tid_list  intlist__find(trace-tid_list, sample-tid)))
+   return false;
+
+   if (trace-pid_list || trace-tid_list)
+   return true;
+
+   return false;
+}
+
 static int trace__process_sample(struct perf_tool *tool,
 union perf_event *event __maybe_unused,
 struct perf_sample *sample,
@@ -664,6 +679,9 @@ static int trace__process_sample(struct perf_tool *tool,
 
tracepoint_handler handler = evsel-handler.func;
 
+   if (skip_sample(trace, sample))
+   return 0;
+
if (trace-base_time == 0)
trace-base_time = sample-time;
 
@@ -683,6 +701,27 @@ perf_session__has_tp(struct perf_session *session, const 
char *name)
return evsel != NULL;
 }
 
+static int parse_target_str(struct trace *trace)
+{
+   if (trace-opts.target.pid) {
+   trace-pid_list = intlist__new(trace-opts.target.pid);
+   if (trace-pid_list == NULL) {
+   pr_err(Error parsing process id string\n);
+   return -EINVAL;
+   }
+   }
+
+   if (trace-opts.target.tid) {
+   trace-tid_list = intlist__new(trace-opts.target.tid);
+   if (trace-tid_list == NULL) {
+   pr_err(Error parsing thread id string\n);
+   return -EINVAL;
+   }
+   }
+
+   return 0;
+}
+
 static int trace__run(struct trace *trace, int argc, const char **argv)
 {
struct perf_evlist *evlist = perf_evlist__new();
@@ -869,6 +908,10 @@ static int trace__replay(struct trace *trace)
goto out;
}
 
+   err = parse_target_str(trace);
+   if (err != 0)
+   goto out;
+
setup_pager();
 
err = perf_session__process_events(session, trace-tool);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf evlist: Move perf_evlist__config() to a new source file

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  faf967068e8c4d8df52f01f9361241101b3065a0
Gitweb: http://git.kernel.org/tip/faf967068e8c4d8df52f01f9361241101b3065a0
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:08 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 15:49:10 -0300

perf evlist: Move perf_evlist__config() to a new source file

perf_evlist__config() must be moved to a separate source file to avoid
Python link errors when adding support for PERF_SAMPLE_IDENTIFIER.

It is appropriate to do this because perf_evlist__config() is a helper
function for event recording.  It is used by tools to apply recording
options to perf_evlist.  It is not used by the Python API.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Acked-by: Namhyung Kim namhy...@kernel.org
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-7-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/Makefile  |  1 +
 tools/perf/util/evlist.c | 22 --
 tools/perf/util/record.c | 25 +
 3 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 7d30a7d..845cc76 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -360,6 +360,7 @@ LIB_OBJS += $(OUTPUT)util/rblist.o
 LIB_OBJS += $(OUTPUT)util/intlist.o
 LIB_OBJS += $(OUTPUT)util/vdso.o
 LIB_OBJS += $(OUTPUT)util/stat.o
+LIB_OBJS += $(OUTPUT)util/record.o
 
 LIB_OBJS += $(OUTPUT)ui/setup.o
 LIB_OBJS += $(OUTPUT)ui/helpline.o
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 1f5105a..9d682e5 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -49,28 +49,6 @@ struct perf_evlist *perf_evlist__new(void)
return evlist;
 }
 
-void perf_evlist__config(struct perf_evlist *evlist,
-   struct perf_record_opts *opts)
-{
-   struct perf_evsel *evsel;
-   /*
-* Set the evsel leader links before we configure attributes,
-* since some might depend on this info.
-*/
-   if (opts-group)
-   perf_evlist__set_leader(evlist);
-
-   if (evlist-cpus-map[0]  0)
-   opts-no_inherit = true;
-
-   list_for_each_entry(evsel, evlist-entries, node) {
-   perf_evsel__config(evsel, opts);
-
-   if (evlist-nr_entries  1)
-   perf_evsel__set_sample_id(evsel);
-   }
-}
-
 static void perf_evlist__purge(struct perf_evlist *evlist)
 {
struct perf_evsel *pos, *n;
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c
new file mode 100644
index 000..9b5ef79
--- /dev/null
+++ b/tools/perf/util/record.c
@@ -0,0 +1,25 @@
+#include evlist.h
+#include evsel.h
+#include cpumap.h
+
+void perf_evlist__config(struct perf_evlist *evlist,
+   struct perf_record_opts *opts)
+{
+   struct perf_evsel *evsel;
+   /*
+* Set the evsel leader links before we configure attributes,
+* since some might depend on this info.
+*/
+   if (opts-group)
+   perf_evlist__set_leader(evlist);
+
+   if (evlist-cpus-map[0]  0)
+   opts-no_inherit = true;
+
+   list_for_each_entry(evsel, evlist-entries, node) {
+   perf_evsel__config(evsel, opts);
+
+   if (evlist-nr_entries  1)
+   perf_evsel__set_sample_id(evsel);
+   }
+}
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Add missing 'abi' member to ' struct regs_dump'

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  5b95a4a3b52a1de84022dfaf580df4b5251f4a15
Gitweb: http://git.kernel.org/tip/5b95a4a3b52a1de84022dfaf580df4b5251f4a15
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:10 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 16:10:58 -0300

perf tools: Add missing 'abi' member to 'struct regs_dump'

And store the parsed value there.  Note that the 'abi' is 0 (no
registers), 1 (32-bit registers) or 2 (64-bit registers), but the
registers are anyway copied one-by-one as 64-bit values onto the event
i.e. see 'perf_output_sample_regs()'

Acked-by: Jiri Olsa jo...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-9-git-send-email-adrian.hun...@intel.com
Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/util/event.h | 1 +
 tools/perf/util/evsel.c | 7 +++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 4913339..f959801 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -62,6 +62,7 @@ struct sample_event {
 };
 
 struct regs_dump {
+   u64 abi;
u64 *regs;
 };
 
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index db4e431..1184188 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1416,13 +1416,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, 
union perf_event *event,
}
 
if (type  PERF_SAMPLE_REGS_USER) {
-   u64 avail;
-
/* First u64 tells us if we have any regs in sample. */
OVERFLOW_CHECK_u64(array);
-   avail = *array++;
+   data-user_regs.abi = *array;
+   array++;
 
-   if (avail) {
+   if (data-user_regs.abi) {
u64 regs_user = evsel-attr.sample_regs_user;
 
sz = hweight_long(regs_user) * sizeof(u64);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Remove references to struct ip_event

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  ef89325f773bc9f2f4e6019bd7f3d968ba85df9a
Gitweb: http://git.kernel.org/tip/ef89325f773bc9f2f4e6019bd7f3d968ba85df9a
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:06 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 15:29:28 -0300

perf tools: Remove references to struct ip_event

The ip_event struct assumes fixed positions for ip, pid and tid.  That
is no longer true with the addition of PERF_SAMPLE_IDENTIFIER.  The
information is anyway in struct sample, so use that instead.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Acked-by: Namhyung Kim namhy...@kernel.org
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-5-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/builtin-inject.c   |  4 ++--
 tools/perf/builtin-kmem.c |  4 ++--
 tools/perf/builtin-mem.c  |  2 +-
 tools/perf/builtin-script.c   |  4 ++--
 tools/perf/builtin-top.c  | 11 ++-
 tools/perf/tests/hists_link.c | 20 
 tools/perf/util/build-id.c|  8 
 tools/perf/util/event.c   |  6 +++---
 tools/perf/util/event.h   | 11 ---
 tools/perf/util/evsel.c   |  4 ++--
 tools/perf/util/session.c |  8 +---
 11 files changed, 35 insertions(+), 47 deletions(-)

diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 0d4ae1d..ffacd46 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -198,7 +198,7 @@ static int perf_event__inject_buildid(struct perf_tool 
*tool,
 
cpumode = event-header.misc  PERF_RECORD_MISC_CPUMODE_MASK;
 
-   thread = machine__findnew_thread(machine, event-ip.pid, event-ip.pid);
+   thread = machine__findnew_thread(machine, sample-pid, sample-pid);
if (thread == NULL) {
pr_err(problem processing %d event, skipping it.\n,
   event-header.type);
@@ -206,7 +206,7 @@ static int perf_event__inject_buildid(struct perf_tool 
*tool,
}
 
thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
- event-ip.ip, al);
+ sample-ip, al);
 
if (al.map != NULL) {
if (!al.map-dso-hit) {
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index c324778..c2dff9c 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -305,8 +305,8 @@ static int process_sample_event(struct perf_tool *tool 
__maybe_unused,
struct perf_evsel *evsel,
struct machine *machine)
 {
-   struct thread *thread = machine__findnew_thread(machine, event-ip.pid,
-   event-ip.pid);
+   struct thread *thread = machine__findnew_thread(machine, sample-pid,
+   sample-pid);
 
if (thread == NULL) {
pr_debug(problem processing %d event, skipping it.\n,
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 706a1fa..791b432 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -94,7 +94,7 @@ dump_raw_samples(struct perf_tool *tool,
symbol_conf.field_sep,
sample-tid,
symbol_conf.field_sep,
-   event-ip.ip,
+   sample-ip,
symbol_conf.field_sep,
sample-addr,
symbol_conf.field_sep,
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index d82712f..93a34ce 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -501,8 +501,8 @@ static int process_sample_event(struct perf_tool *tool 
__maybe_unused,
struct machine *machine)
 {
struct addr_location al;
-   struct thread *thread = machine__findnew_thread(machine, event-ip.pid,
-   event-ip.tid);
+   struct thread *thread = machine__findnew_thread(machine, sample-pid,
+   sample-tid);
 
if (thread == NULL) {
pr_debug(problem processing %d event, skipping it.\n,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index e37521f..2122141 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -689,7 +689,7 @@ static void perf_event__process_sample(struct perf_tool 
*tool,
 {
struct perf_top *top = container_of(tool, struct perf_top, tool);
struct symbol *parent = 

[tip:perf/core] perf callchain: Remove unnecessary validation

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  07940293ba7a43070cdebda952b0e6025d80a383
Gitweb: http://git.kernel.org/tip/07940293ba7a43070cdebda952b0e6025d80a383
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:05 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 15:11:29 -0300

perf callchain: Remove unnecessary validation

Now that the sample parsing correctly checks data sizes there is no
reason for it to be done again for callchains.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Acked-by: Namhyung Kim namhy...@kernel.org
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-4-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/util/callchain.c |  8 
 tools/perf/util/callchain.h |  5 -
 tools/perf/util/session.c   | 20 
 3 files changed, 33 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 4fee33b..482f680 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -21,14 +21,6 @@
 
 __thread struct callchain_cursor callchain_cursor;
 
-bool ip_callchain__valid(struct ip_callchain *chain,
-const union perf_event *event)
-{
-   unsigned int chain_size = event-header.size;
-   chain_size -= (unsigned long)event-ip.__more_data - (unsigned 
long)event;
-   return chain-nr * sizeof(u64) = chain_size;
-}
-
 #define chain_for_each_child(child, parent)\
list_for_each_entry(child, parent-children, siblings)
 
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 812d5a0..2b585bc 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -109,11 +109,6 @@ int callchain_append(struct callchain_root *root,
 int callchain_merge(struct callchain_cursor *cursor,
struct callchain_root *dst, struct callchain_root *src);
 
-struct ip_callchain;
-union perf_event;
-
-bool ip_callchain__valid(struct ip_callchain *chain,
-const union perf_event *event);
 /*
  * Initialize a cursor before adding entries inside, but keep
  * the previously allocated entries as a cache.
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 57b6f38..07590c3 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -997,22 +997,6 @@ static int perf_session_deliver_event(struct perf_session 
*session,
}
 }
 
-static int perf_session__preprocess_sample(struct perf_session *session,
-  union perf_event *event, struct 
perf_sample *sample)
-{
-   if (event-header.type != PERF_RECORD_SAMPLE ||
-   !(perf_evlist__sample_type(session-evlist)  
PERF_SAMPLE_CALLCHAIN))
-   return 0;
-
-   if (!ip_callchain__valid(sample-callchain, event)) {
-   pr_debug(call-chain problem with event, skipping it.\n);
-   ++session-stats.nr_invalid_chains;
-   session-stats.total_invalid_chains += sample-period;
-   return -EINVAL;
-   }
-   return 0;
-}
-
 static int perf_session__process_user_event(struct perf_session *session, 
union perf_event *event,
struct perf_tool *tool, u64 
file_offset)
 {
@@ -1075,10 +1059,6 @@ static int perf_session__process_event(struct 
perf_session *session,
if (ret)
return ret;
 
-   /* Preprocess sample records - precheck callchains */
-   if (perf_session__preprocess_sample(session, event, sample))
-   return 0;
-
if (tool-ordered_samples) {
ret = perf_session_queue_event(session, event, sample,
   file_offset);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf evsel: Tidy up sample parsing overflow checking

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  03b6ea9b91e0914caa847a1ade759af549555298
Gitweb: http://git.kernel.org/tip/03b6ea9b91e0914caa847a1ade759af549555298
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:04 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 15:10:02 -0300

perf evsel: Tidy up sample parsing overflow checking

The size of data retrieved from a sample event must be validated to
ensure it does not go past the end of the event.  That was being done
sporadically and without considering integer overflows.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Acked-by: Jiri Olsa jo...@redhat.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-3-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/util/evsel.c | 112 ++--
 1 file changed, 71 insertions(+), 41 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 47cbe1e..9a5fb23 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1131,24 +1131,30 @@ static int perf_evsel__parse_id_sample(const struct 
perf_evsel *evsel,
return 0;
 }
 
-static bool sample_overlap(const union perf_event *event,
-  const void *offset, u64 size)
+static inline bool overflow(const void *endp, u16 max_size, const void *offset,
+   u64 size)
 {
-   const void *base = event;
+   return size  max_size || offset + size  endp;
+}
 
-   if (offset + size  base + event-header.size)
-   return true;
+#define OVERFLOW_CHECK(offset, size, max_size) \
+   do {\
+   if (overflow(endp, (max_size), (offset), (size)))   \
+   return -EFAULT; \
+   } while (0)
 
-   return false;
-}
+#define OVERFLOW_CHECK_u64(offset) \
+   OVERFLOW_CHECK(offset, sizeof(u64), sizeof(u64))
 
 int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
 struct perf_sample *data)
 {
u64 type = evsel-attr.sample_type;
-   u64 regs_user = evsel-attr.sample_regs_user;
bool swapped = evsel-needs_swap;
const u64 *array;
+   u16 max_size = event-header.size;
+   const void *endp = (void *)event + max_size;
+   u64 sz;
 
/*
 * used for cross-endian analysis. See git commit 65014ab3
@@ -1170,6 +1176,11 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, 
union perf_event *event,
 
array = event-sample.array;
 
+   /*
+* The evsel's sample_size is based on PERF_SAMPLE_MASK which includes
+* up to PERF_SAMPLE_PERIOD.  After that overflow() must be used to
+* check the format does not go past the end of the event.
+*/
if (evsel-sample_size + sizeof(event-header)  event-header.size)
return -EFAULT;
 
@@ -1235,6 +1246,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, 
union perf_event *event,
if (type  PERF_SAMPLE_READ) {
u64 read_format = evsel-attr.read_format;
 
+   OVERFLOW_CHECK_u64(array);
if (read_format  PERF_FORMAT_GROUP)
data-read.group.nr = *array;
else
@@ -1243,41 +1255,51 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, 
union perf_event *event,
array++;
 
if (read_format  PERF_FORMAT_TOTAL_TIME_ENABLED) {
+   OVERFLOW_CHECK_u64(array);
data-read.time_enabled = *array;
array++;
}
 
if (read_format  PERF_FORMAT_TOTAL_TIME_RUNNING) {
+   OVERFLOW_CHECK_u64(array);
data-read.time_running = *array;
array++;
}
 
/* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */
if (read_format  PERF_FORMAT_GROUP) {
-   data-read.group.values = (struct sample_read_value *) 
array;
-   array = (void *) array + data-read.group.nr *
-   sizeof(struct sample_read_value);
+   const u64 max_group_nr = UINT64_MAX /
+   sizeof(struct sample_read_value);
+
+   if (data-read.group.nr  max_group_nr)
+   return -EFAULT;
+   sz = data-read.group.nr *
+ 

[tip:perf/core] perf tools: change machine__findnew_thread() to set thread pid

2013-08-31 Thread tip-bot for Adrian Hunter
Commit-ID:  314add6b1f045b59ca39683bd0cbc5310cd203f2
Gitweb: http://git.kernel.org/tip/314add6b1f045b59ca39683bd0cbc5310cd203f2
Author: Adrian Hunter adrian.hun...@intel.com
AuthorDate: Tue, 27 Aug 2013 11:23:03 +0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 29 Aug 2013 11:51:31 -0300

perf tools: change machine__findnew_thread() to set thread pid

Add a new parameter for 'pid' to machine__findnew_thread().
Change callers to pass 'pid' when it is known.

Note that callers sometimes want to find the main thread
which has the memory maps.  The main thread has tid == pid
so the usage in that case is:

machine__findnew_thread(machine, pid, pid)

whereas the usage to find the specific thread is:

machine__findnew_thread(machine, pid, tid)

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
Acked-by: David Ahern dsah...@gmail.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: 
http://lkml.kernel.org/r/1377591794-30553-2-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/builtin-inject.c |  2 +-
 tools/perf/builtin-kmem.c   |  3 ++-
 tools/perf/builtin-kvm.c|  2 +-
 tools/perf/builtin-lock.c   |  3 ++-
 tools/perf/builtin-sched.c  | 20 +++-
 tools/perf/builtin-script.c |  3 ++-
 tools/perf/builtin-trace.c  | 10 +++---
 tools/perf/tests/code-reading.c |  4 ++--
 tools/perf/tests/hists_link.c   |  3 ++-
 tools/perf/util/build-id.c  |  7 +--
 tools/perf/util/event.c |  3 ++-
 tools/perf/util/machine.c   | 22 +++---
 tools/perf/util/machine.h   |  3 ++-
 tools/perf/util/session.c   |  2 +-
 14 files changed, 55 insertions(+), 32 deletions(-)

diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 1d8de2e..0d4ae1d 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -198,7 +198,7 @@ static int perf_event__inject_buildid(struct perf_tool 
*tool,
 
cpumode = event-header.misc  PERF_RECORD_MISC_CPUMODE_MASK;
 
-   thread = machine__findnew_thread(machine, event-ip.pid);
+   thread = machine__findnew_thread(machine, event-ip.pid, event-ip.pid);
if (thread == NULL) {
pr_err(problem processing %d event, skipping it.\n,
   event-header.type);
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index b49f5c5..c324778 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -305,7 +305,8 @@ static int process_sample_event(struct perf_tool *tool 
__maybe_unused,
struct perf_evsel *evsel,
struct machine *machine)
 {
-   struct thread *thread = machine__findnew_thread(machine, event-ip.pid);
+   struct thread *thread = machine__findnew_thread(machine, event-ip.pid,
+   event-ip.pid);
 
if (thread == NULL) {
pr_debug(problem processing %d event, skipping it.\n,
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 6cd4de5..47b3540 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -815,7 +815,7 @@ static int process_sample_event(struct perf_tool *tool,
if (skip_sample(kvm, sample))
return 0;
 
-   thread = machine__findnew_thread(machine, sample-tid);
+   thread = machine__findnew_thread(machine, sample-pid, sample-tid);
if (thread == NULL) {
pr_debug(problem processing %d event, skipping it.\n,
event-header.type);
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 76543a4..ee33ba2 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -805,7 +805,8 @@ static int process_sample_event(struct perf_tool *tool 
__maybe_unused,
struct perf_evsel *evsel,
struct machine *machine)
 {
-   struct thread *thread = machine__findnew_thread(machine, sample-tid);
+   struct thread *thread = machine__findnew_thread(machine, sample-pid,
+   sample-tid);
 
if (thread == NULL) {
pr_debug(problem processing %d event, skipping it.\n,
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index f809cc7..d8c51b2 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -724,8 +724,10 @@ static int replay_fork_event(struct perf_sched *sched,
 {
struct thread *child, *parent;
 
-   child = machine__findnew_thread(machine, event-fork.tid);
-   

Re: [PATCH] Avoid useless inodes and dentries reclamation

2013-08-31 Thread Dave Chinner
On Fri, Aug 30, 2013 at 09:21:34AM -0700, Tim Chen wrote:
 On Fri, 2013-08-30 at 11:40 +1000, Dave Chinner wrote:
 
  
  The new shrinker infrastructure has a -count_objects() callout to
  specifically return the number of objects in the cache.
  shrink_slab_node() can check that return value against the minimum
  call count and determine whether it needs to call -scan_objects()
  at all.
  
  Actually, the shrinker already behaves like this with the batch_size
  variable - the shrinker has to be asking for more items to be
  scanned than the batch size. That means the problem is that counting
  callouts are causing the problem, not the scanning callouts.
  
  With the new code in the mmotm tree, for counting purposes we
  probably don't need to grab a passive superblock reference at all -
  the superblock and LRUs are guaranteed to be valid if the shrinker
  is currently running, but we don't really care if the superblock is
  being shutdown and the values that come back are invalid because the
  -scan_objects() callout will fail to grab the superblock to do
  anything with the calculated values.
 
 If that's the case, then we should remove grab_super_passive
 from the super_cache_count code.  That should remove the bottleneck
 in reclamation.
 
 Thanks for your detailed explanation.
 
 Tim
 
 Signed-off-by: Tim Chen tim.c.c...@linux.intel.com
 ---
 diff --git a/fs/super.c b/fs/super.c
 index 73d0952..4df1fab 100644
 --- a/fs/super.c
 +++ b/fs/super.c
 @@ -112,9 +112,6 @@ static unsigned long super_cache_count(struct shrinker 
 *shrink,
  
   sb = container_of(shrink, struct super_block, s_shrink);
  
 - if (!grab_super_passive(sb))
 - return 0;
 -

I think the function needs a comment explaining why we aren't
grabbing the sb here, otherwise people are going to read the code
and ask why it's different to the scanning callout.

   if (sb-s_op  sb-s_op-nr_cached_objects)
   total_objects = sb-s_op-nr_cached_objects(sb,
sc-nid);

But seeing this triggered further thought on my part. Being called
during unmount means that -nr_cached_objects implementations need
to be robust against unmount tearing down private filesystem
structures.  Right now, grab_super_passive() protects us from that
because it won't be able to get the sb-s_umount lock while
generic_shutdown_super() is doing it's work.

IOWs, the superblock based shrinker operations are safe because the
structures don't get torn down until after the shrinker is
unregistered. That's not true for the structures that
-nr_cached_objects() use: -put_super() tears them down before the
shrinker is unregistered and only grab_super_passive() protects us
from thay.

Let me have a bit more of a think about this - the solution may
simply be unregistering the shrinker before we call -kill_sb() so
the shrinker can't get called while we are tearing down the fs.
First, though, I need to go back and remind myself of why I put that
after -kill_sb() in the first place.  If we unregister the shrinker
before -kill_sb is called, then we can probably get rid of
grab_super_passive() in both shrinker callouts because they will no
longer need to handle running concurrently with -kill_sb()

Cheers,

Dave.
-- 
Dave Chinner
da...@fromorbit.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 1/1] powerpc/85xx: Wakeup kexec smp slave cpus in second kernel

2013-08-31 Thread Yu Chen
From 1ccf579b871dfd5938ce958f729361a203485c74 Mon Sep 17 00:00:00 2001
From: Yu Chen chenyu...@gmail.com
Date: Sat, 31 Aug 2013 23:52:31 +0800
Subject: [PATCH]  powerpc/85xx: Wakeup kexec smp slave cpus in second kernel

In current 85xx smp kexec implementation,master cpu reset slave cpus
by mpic_reset_core,
before jump to second kernel.In order to wake slave cpus up in second
kernel,we debug
this patch on p2041rdb.

The main principle of this patch,is to get slave cpus polling for flag
to change,
thus waiting for master cpu to set it with non-zero cpu number(see misc_32.S).
This flag is placed in kexec control page,so it would not be
overlapped when copying kimage.
The master cpu put flag's physical address in r28 as a parameter
passed to second kernel,
so the latter knows how to wake slave cpus up in smp_85xx_kick_cpu.
The pseudo-code may be like:
void slave_cpu_spin(void)
{
int cpu = smp_processor_id();
while (*kexec_poll != cpu)
;
/*slave wakeup and jump*/
jump(*(kexec_poll+1));
}

void master_cpu_wakeup(unsigned long *kexec_poll, int cpu)
{
*(kexec_poll+1) = __early_start;
mb();
*kexec_poll = cpu;
}

However,after applied this patch,we got some kernel exception during
booting second kernel,
I'm not sure if it's caused by improper treament of cache,or tlb,or
other.So I put this
patch here hoping someone can check and review it.

Signed-off-by: Yu Chen chenyu...@gmail.com
---
 arch/powerpc/kernel/head_fsl_booke.S |7 ++
 arch/powerpc/kernel/misc_32.S|   66 +-
 arch/powerpc/platforms/85xx/smp.c|  166 ++
 3 files changed, 222 insertions(+), 17 deletions(-)
 mode change 100644 = 100755 arch/powerpc/kernel/head_fsl_booke.S
 mode change 100644 = 100755 arch/powerpc/kernel/misc_32.S
 mode change 100644 = 100755 arch/powerpc/platforms/85xx/smp.c

diff --git a/arch/powerpc/kernel/head_fsl_booke.S
b/arch/powerpc/kernel/head_fsl_booke.S
old mode 100644
new mode 100755
index d10a7ca..63c8392
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -178,6 +178,13 @@ _ENTRY(__early_start)
  * This is where the main kernel code starts.
  */

+#if defined(CONFIG_KEXEC)  defined(CONFIG_SMP)
+/* r28 contain position where slave cpus spin*/
+lisr1,kexec_poll_phy@h
+orir1,r1,kexec_poll_phy@l
+stwr28,0(r1)
+#endif
+
 /* ptr to current */
 lisr2,init_task@h
 orir2,r2,init_task@l
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
old mode 100644
new mode 100755
index e469f30..d9eefc2
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -120,7 +120,7 @@ _GLOBAL(reloc_got2)
 addir4,r4,1b@l
 subfr0,r4,r0
 addr7,r0,r7
-2:lwzr0,0(r7)
+2:lwzr0,0(r7)
 addr0,r0,r3
 stwr0,0(r7)
 addir7,r7,4
@@ -692,6 +692,7 @@ _GLOBAL(__main)
 blr

 #ifdef CONFIG_KEXEC
+#define KEXEC_MAGIC 0xdeadbeef
 /*
  * Must be relocatable PIC code callable as a C function.
  */
@@ -707,6 +708,16 @@ relocate_new_kernel:
 mrr30, r4
 mrr31, r5

+#ifdef CONFIG_SMP
+bl1f
+1:mflrr8
+addir8,r8,kexec_flag-1b
+lis r7,PAGE_OFFSET@h
+ori r7,r7,PAGE_OFFSET@l
+/*r28 contain slave cpu spin physical address */
+subfr28, r7, r8
+#endif
+
 #define ENTRY_MAPPING_KEXEC_SETUP
 #include fsl_booke_entry_mapping.S
 #undef ENTRY_MAPPING_KEXEC_SETUP
@@ -1172,4 +1183,57 @@ relocate_new_kernel_end:
 .globl relocate_new_kernel_size
 relocate_new_kernel_size:
 .long relocate_new_kernel_end - relocate_new_kernel
+#ifdef CONFIG_FSL_BOOKE
+/**
+* Slave cpus wait for kexec_flag to change
+*/
+.globl relocate_smp_cpu_offset
+relocate_smp_cpu_offset:
+.long relocate_smp_cpu_wait-relocate_new_kernel
+
+.globl relocate_smp_cpu_wait
+relocate_smp_cpu_wait:
+
+bl1f
+1:mflrr5
+addir5,r5,kexec_flag-1b
+/*see if anyone calls me?*/
+mfspr   r24,SPRN_PIR
+99:lwzr4,4(r5)
+cmpwr4,r24
+msync
+bne99b
+
+msync
+/*r4 contains jump address*/
+lwzr4,8(r5)
+msync
+lisr5,MSR_KERNEL@h
+orir5,r5,MSR_KERNEL@l
+msync
+isync
+mtsprSPRN_SRR1, r5
+mtsprSPRN_SRR0, r4
+msync
+isync
+rfi
+isync
+1:b1b
+
+/**
+* kexec_flag indicates a kexec magic
+* kexec_flag+4 bytes supposed to be set with cpu number
+* kexec_flag+8 countain addr for slave cpu to jump into
+*/
+.globl kexec_flag
+kexec_flag:
+.long   KEXEC_MAGIC
+.long0
+.long0
+relocate_smp_cpu_wait_end:
+.globl relocate_smp_cpu_size
+relocate_smp_cpu_size:
+.long relocate_smp_cpu_wait_end-relocate_smp_cpu_wait
+#endif
+
 #endif
diff --git a/arch/powerpc/platforms/85xx/smp.c
b/arch/powerpc/platforms/85xx/smp.c
old mode 100644
new mode 

3.11-rc2: unpriviledged user crashes kernel using bluetooth

2013-08-31 Thread Pavel Machek
Hi!

While trying to set up serial bluetooth connection between two
machines, the server machine died rather hard.

This is what I got on ssh:

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW (2.19 )
 03/31/2011

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:task: e6d6a670 ti: e8fd8000 task.ti: e8fd8000

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:Stack:

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:Call Trace:

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:Code: 66 ff ff ff eb b9 ba 79 c9 b6 c0 89 d8 e8 58 ff ff ff eb
 a0 8d b6 00 00 00 00 55 89 e5 83 ec 10 89 5d f4 89 c3 89 75 f8 89 7d
 fc 81 78 04 ad 4e ad de 0f 85 11 01 00 00 64 a1 4c 87 d2 c0 39 43

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:EIP: [c04621f1] do_raw_spin_lock+0x11/0x140 SS:ESP
 0068:e8fd9e0c

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:CPU: 0 PID: 3822 Comm: modem-manager Tainted: G  D W
 3.11.0-rc2+ #306

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW (2.19 )
 03/31/2011

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:task: e6d9a670 ti: e6d4e000 task.ti: e6d4e000

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:Stack:

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:Call Trace:

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:Code: 66 ff ff ff eb b9 ba 79 c9 b6 c0 89 d8 e8 58 ff ff ff eb
 a0 8d b6 00 00 00 00 55 89 e5 83 ec 10 89 5d f4 89 c3 89 75 f8 89 7d
 fc 81 78 04 ad 4e ad de 0f 85 11 01 00 00 64 a1 4c 87 d2 c0 39 43

Message from syslogd@duo at Aug 31 11:50:07 ...
 kernel:EIP: [c04621f1] do_raw_spin_lock+0x11/0x140 SS:ESP
 0068:e6d4fe0c

. Python sources for client/server are at 

http://tui.cvs.sourceforge.net/viewvc/tui/tui/liveview/

. My kernels like to warn about

Aug 31 11:46:37 duo kernel: WARNING: CPU: 1 PID: 1 at
net/wireless/reg.c:423 regulatory_init+0x92/0xff()
Aug 31 11:46:37 duo kernel: db.txt is empty, you should update it...

. 3.10 does not seem to be affected.

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: perf_event: rdpmc self-monitoring overhead issue

2013-08-31 Thread Mikael Pettersson
Vince Weaver writes:
  On Fri, 30 Aug 2013, Stephane Eranian wrote:
   
   You mean that the high cost in your first example comes from the fact
   that you are averaging over all the iterations and not n-1 (where 1 is
   the first). I don't see a flag in mmap() to fault it in immediately. But
   why not document, that programs should touch the page once before
   starting any timing measurements.
  
  I was just curious why perfctr didn't need to do this, but possibly
  I'm just missing the mmap page being touched.  Though the code is pretty
  small and I'm not seeing any such access.

perfctr's -mmap() actively inserts the counters page into the calling
process' mm, so it's available immediately.  The other model is to wait
for the first page fault on that page before inserting it; apparently
the other performance counter frameworks do that instead.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: 3.11-rc2: unpriviledged user crashes kernel using bluetooth

2013-08-31 Thread Pavel Machek
Hi!

 . Python sources for client/server are at 
 
 http://tui.cvs.sourceforge.net/viewvc/tui/tui/liveview/
 
 . My kernels like to warn about
 
 Aug 31 11:46:37 duo kernel: WARNING: CPU: 1 PID: 1 at
 net/wireless/reg.c:423 regulatory_init+0x92/0xff()
 Aug 31 11:46:37 duo kernel: db.txt is empty, you should update it...
 
 . 3.10 does not seem to be affected.

When I said 3.10 was not affected, I was wrong. 3.10 survived the
test, but when I attempted to reboot the box, I got 

WARNING: at lib/list_debug.c:59 __list_del_entry+0xac/0xe0()
list_del_corruption. prev-next should be f44fffd4, but was f44c402c
...
...Comm: bluetoothd
Call trace:
...
__list_del_entry
cd_forget
evict
iput

System is debian stable with gnome2.
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


3.10: unpriviledged user crashes kernel using bluetooth

2013-08-31 Thread Pavel Machek
On Sat 2013-08-31 12:09:33, Pavel Machek wrote:
 Hi!
 
  . Python sources for client/server are at 
  
  http://tui.cvs.sourceforge.net/viewvc/tui/tui/liveview/
  
  . My kernels like to warn about
  
  Aug 31 11:46:37 duo kernel: WARNING: CPU: 1 PID: 1 at
  net/wireless/reg.c:423 regulatory_init+0x92/0xff()
  Aug 31 11:46:37 duo kernel: db.txt is empty, you should update it...
  
  . 3.10 does not seem to be affected.
 
 When I said 3.10 was not affected, I was wrong. 3.10 survived the
 test, but when I attempted to reboot the box, I got 
 
 WARNING: at lib/list_debug.c:59 __list_del_entry+0xac/0xe0()
 list_del_corruption. prev-next should be f44fffd4, but was f44c402c
 ...
 ...Comm: bluetoothd
 Call trace:
 ...
 __list_del_entry
 cd_forget
 evict
 iput

Aha, I have even better dump in the logs:

6cfg80211: Calling CRDA to update world regulatory domain
6wlan0: authenticate with 00:11:95:05:30:d7
6wlan0: send auth to 00:11:95:05:30:d7 (try 1/3)
6iwl3945 :03:00.0 wlan0: disabling HT as WMM/QoS is not
supported by the AP
6iwl3945 :03:00.0 wlan0: disabling VHT as WMM/QoS is not
supported by the AP
6wlan0: RX AssocResp from 00:11:95:05:30:d7 (capab=0x401 status=0
aid=2)
6wlan0: associated
4the code is fine but needs lockdep annotation.
4turning off the locking correctness validator.
4 edd4cc30 f3187db0 c095a48c f3187df0 c027c43e c0b27dcc f5f71670

4  f3187df4 0246 edd4cc30 c10253b0  
c10253b0
4 [c095a48c] dump_stack+0x16/0x18
4 [c027c43e] __lock_acquire+0x71e/0xcf0
4 [c027ca74] lock_acquire+0x64/0x80
4 [c04e59ec] ? tty_buffer_flush+0x1c/0xd0
4 [c095d52b] _raw_spin_lock_irqsave+0x3b/0x50
4 [c04e59ec] ? tty_buffer_flush+0x1c/0xd0
4 [c04e59ec] tty_buffer_flush+0x1c/0xd0
4 [c04df38f] tty_ioctl+0x5bf/0xa80
4 [c027c0a6] ? __lock_acquire+0x386/0xcf0
4 [c02e4899] do_vfs_ioctl+0x89/0x5b0
4 [c0455873] ? debug_check_no_obj_freed+0xe3/0x190
4 [c02e2ac8] ? final_putname+0x18/0x40
4 [c095e4b8] sysenter_do_call+0x12/0x31
6wlan0: deauthenticated from 00:11:95:05:30:d7 (Reason: 3)
6cfg80211: Calling CRDA to update world regulatory domain
6wlan0: authenticate with 00:11:95:05:30:d7
6wlan0: send auth to 00:11:95:05:30:d7 (try 1/3)
6wlan0: authenticated
6iwl3945 :03:00.0 wlan0: disabling HT as WMM/QoS is not
supported by the AP
6iwl3945 :03:00.0 wlan0: disabling VHT as WMM/QoS is not
supported by the AP
6wlan0: associate with 00:11:95:05:30:d7 (try 1/3)
6wlan0: RX AssocResp from 00:11:95:05:30:d7 (capab=0x401 status=0
aid=2)
6wlan0: associated
6wlan0: deauthenticated from 00:11:95:05:30:d7 (Reason: 3)
6cfg80211: Calling CRDA to update world regulatory domain
6wlan0: authenticated
6iwl3945 :03:00.0 wlan0: disabling HT as WMM/QoS is not
supported by the AP
6iwl3945 :03:00.0 wlan0: disabling VHT as WMM/QoS is not
supported by the AP

Broadcast message from root@duo (console) (Sat Aug 31 12:05:57 2013):

The system is going down for reboot NOW!
7uhci_hcd :00:1d.3: release dev 2 ep81-INT, period 1, phase 0,
23 us
4WARNING: at lib/list_debug.c:59 __list_del_entry+0xac/0xe0()
4list_del corruption. prev-next should be f44fffd4, but was
f44c402c
4Modules linked in:
4CPU: 0 PID: 2801 Comm: bluetoothd Tainted: GW3.10.0+
#293
4Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW (2.19 )
03/31/2011
4 003b f0933e14 c095a48c f0933e3c c022c96f c0b47bcc f0933e68
003b
4 c0454ddc c0454ddc f44c402c f44fffd4 f44c4000 f0933e54 c022ca0e
0009
4 f0933e4c c0b47bcc f0933e68 f0933e74 c0454ddc c0b474dd 003b
c0b47bcc
4Call Trace:
4 [c095a48c] dump_stack+0x16/0x18
4 [c022c96f] warn_slowpath_common+0x5f/0x80
4 [c0454ddc] ? __list_del_entry+0xac/0xe0
4 [c0454ddc] ? __list_del_entry+0xac/0xe0
4 [c0454ddc] __list_del_entry+0xac/0xe0
4 [c02d9276] cd_forget+0x26/0x60
4 [c02ebc69] evict+0x119/0x170
4 [c02ebda6] iput+0xe6/0x170
4 [c02e950f] d_kill+0xaf/0x100
4 [c02e9bf6] dput+0xc6/0x170
4 [c02d6d84] __fput+0x154/0x200
4 [c02d6e98] fput+0x8/0x10
4 [c0247a61] task_work_run+0x81/0xb0
1BUG: unable to handle kernel paging request at fffc
1IP: [c02d3943] filp_close+0x13/0x80
4*pde = 00d14067 *pte =  
4Oops:  [#2] SMP DEBUG_PAGEALLOC
4Modules linked in:
0CPU: 1 PID: 3735 Comm: python Tainted: G  D W3.10.0+ #293
0Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW (2.19 )
03/31/2011
0task: f29c6670 ti: edf28000 task.ti: edf28000
4EIP: 0060:[c02d3943] EFLAGS: 00210282 CPU: 1
4EIP is at filp_close+0x13/0x80
4EAX: ffc0 EBX: ffc0 ECX:  EDX: ee297f00
4ESI: ee297f00 EDI: f4779be0 EBP: edf29de0 ESP: edf29dd0
4 DS: 007b ES: 007b FS: 00d8 GS:  SS: 0068
4CR0: 8005003b CR2: fffc CR3: 00d13000 CR4: 0710
4DR0:  DR1:  DR2:  DR3: 
4DR6: 0ff0 DR7: 0400
0Stack:
4 00200246  001f f4779be0 edf29e0c c02ee2a5 0002
0001
4  c02ee21a  ee297f00 f29c6670 ee297f00 f29c6a54
edf29e20
4 c02ee372 edfdadc0 f29c6670 f29c6a54 edf29e74 c0231e25 c02eff30

0Call Trace:
4 

Re: 3.11-rc2: unpriviledged user crashes kernel using bluetooth

2013-08-31 Thread Pavel Machek
On Sat 2013-08-31 12:09:33, Pavel Machek wrote:
 Hi!
 
  . Python sources for client/server are at 
  
  http://tui.cvs.sourceforge.net/viewvc/tui/tui/liveview/
  
  . My kernels like to warn about
 System is debian stable with gnome2.

And no, it is not fixed in 3.11-rc7.

Pavel

pavel@duo:~$ uname -a
Linux duo 3.11.0-rc7+ #309 SMP Sat Aug 31 11:49:01 CEST 2013 i686
GNU/Linux
pavel@duo:~$ sudo cat /proc/kmsg 
[sudo] password for pavel: 
4 [c04f4c6c] ? tty_buffer_flush+0x1c/0xd0
4 [c0463593] ? debug_check_no_obj_freed+0xe3/0x190
4 [c02ee478] ? final_putname+0x18/0x40
4 [c02ee478] ? final_putname+0x18/0x40
4 [c02df45c] ? do_sys_open+0x19c/0x220
4 [c02f0775] SyS_ioctl+0x45/0x70
4 [c0986638] sysenter_do_call+0x12/0x31
0Code: 24 04 fb 0b 00 00 c7 04 24 65 76 b5 c0 e8 57 f3 fa ff 31 c0
eb ad 8d 76 00 8b 44 9e 04 85 c0 89 45 f0 0f 84 b2 fe ff ff 8b 4d f0
f0 ff 81 04 01 00 00 8b 0d 64 8e d5 c0 8b 9f 3c 04 00 00 85 c9
4CR2: c02e0e52
4 0a67 c0b533ab 009f c0238d28 c0238d28 f2ec6e38 f2ec6f6c
f2ec6d10
4 f549fb5c c0234ecd 0009  f549fb64 c0238d28 f549fb70
c09857c5
4 [c0234e8a] warn_slowpath_common+0x7a/0xa0
4 [c0238d28] ? local_bh_enable_ip+0x58/0x80
4 [c09857c5] _raw_write_unlock_bh+0x25/0x30
4 [c08c8643] unix_release_sock+0x73/0x230
4 [c02daf4e] ? kfree_debugcheck+0xe/0x30
4 [c08c8814] unix_release+0x14/0x20
4 [c081dd4b] sock_release+0x1b/0x80
4 [c081e0ab] sock_close+0xb/0x10
4 [c02e2688] __fput+0x88/0x1f0
4 [c02e2888] fput+0x8/0x10
4 [c024d0d1] task_work_run+0x81/0xb0
4 [c0236e8e] do_exit+0x22e/0x860
4 [c0204c7b] oops_end+0x8b/0xd0
4 [c09863da] error_code+0x5a/0x60
4 [c02e0d4e] ? do_sync_read+0x6e/0xa0
4 [c02e0d4e] ? do_sync_read+0x6e/0xa0
4 [c022d810] ? __do_page_fault+0x400/0x400
4 [c0285bc2] ? __lock_acquire+0x192/0xcf0
4 [c02fbb39] ? mntput_no_expire+0x19/0xf0
4 [c02e0d4e] ? do_sync_read+0x6e/0xa0
4 [c04f4c6c] ? tty_buffer_flush+0x1c/0xd0
4 [c04f4c6c] tty_buffer_flush+0x1c/0xd0
4 [c04ee5cf] tty_ioctl+0x5bf/0xa80
4 [c0285db6] ? __lock_acquire+0x386/0xcf0
4 [c022ea21] ? kernel_map_pages+0x71/0xf0
4 [c04ee010] ? tty_check_change+0xe0/0xe0
4 [c02f0209] do_vfs_ioctl+0x89/0x5b0
4 [c0463593] ? debug_check_no_obj_freed+0xe3/0x190
4 [c02ee478] ? final_putname+0x18/0x40
4 [c02f0775] SyS_ioctl+0x45/0x70
4---[ end trace f66d593cc2b02657 ]---
Message from syslogd@duo at Aug 31 12:13:17 ...
 kernel:CPU: 0 PID: 2663 Comm: modem-manager Tainted: GW
 3.11.0-rc7+ #309

Message from syslogd@duo at Aug 31 12:13:17 ...
 kernel:Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW (2.19 )
 03/31/2011

Message from syslogd@duo at Aug 31 12:13:17 ...
 kernel:task: f5f16670 ti: f549e000 task.ti: f549e000

Message from syslogd@duo at Aug 31 12:13:17 ...
 kernel:Stack:

Message from syslogd@duo at Aug 31 12:13:17 ...
 kernel:Call Trace:

Message from syslogd@duo at Aug 31 12:13:17 ...
 kernel:EIP: [c0285bc2] __lock_acquire+0x192/0xcf0 SS:ESP
 0068:f549fdb8
1BUG: unable to handle kernel paging request at eb823c24
1IP: [c0462691] do_raw_spin_lock+0x11/0x140
4*pde = 3733f067 *pte = 2b823060 
4Oops:  [#2] SMP DEBUG_PAGEALLOC
4Modules linked in:
0CPU: 1 PID: 3804 Comm: modem-manager Tainted: G  D W
 3.11.0-rc7+ #309
0Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW (2.19 )
 03/31/2011
0task: eae37670 ti: eba0a000 task.ti: eba0a000
4EIP: 0060:[c0462691] EFLAGS: 00010086 CPU: 1
4EIP is at do_raw_spin_lock+0x11/0x140
4EAX: eb823c20 EBX: eb823c20 ECX:  EDX: 
4ESI: 0286 EDI: eb823c20 EBP: eba0be1c ESP: eba0be0c
4 DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
4CR0: 80050033 CR2: eb823c24 CR3: 2acb4000 CR4: 0710
0Stack:
4  eb823c20 0286 eb823c20 eba0be3c c09856c2 
 0001
4  c04f4c6c eba09f00 eb823c00 eba0be6c c04f4c6c 023b
 ebf1ac00
4 0f44 0c4b  01c5 0003463b eba09f00 ebf1ac00
 0017
0Call Trace:
4 [c09856c2] _raw_spin_lock_irqsave+0x42/0x50
4 [c04f4c6c] ? tty_buffer_flush+0x1c/0xd0
4 [c04f4c6c] tty_buffer_flush+0x1c/0xd0
4 [c04ee5cf] tty_ioctl+0x5bf/0xa80
4 [c022ea21] ? kernel_map_pages+0x71/0xf0
4 [c04ee010] ? tty_check_change+0xe0/0xe0
4 [c02f0209] do_vfs_ioctl+0x89/0x5b0
4 [c0463593] ? debug_check_no_obj_freed+0xe3/0x190
4 [c02f90a0] ? __fd_install+0x20/0x50
4 [c02ee478] ? final_putname+0x18/0x40
4 [c02ee478] ? final_putname+0x18/0x40
4 [c02df45c] ? do_sys_open+0x19c/0x220
4 [c02f0775] SyS_ioctl+0x45/0x70
4 [c0986638] sysenter_do_call+0x12/0x31
0Code: 66 ff ff ff eb b9 ba 39 b7 b7 c0 89 d8 e8 58 ff ff ff eb a0
 8d b6 00 00 00 00 55 89 e5 83 ec 10 89 5d f4 89 c3 89 75 f8 89 7d fc
 81 78 04 ad 4e ad de 0f 85 11 01 00 00 64 a1 4c 87 d3 c0 39 43
0EIP: [c0462691] do_raw_spin_lock+0x11/0x140 SS:ESP 0068:eba0be0c
4CR2: eb823c24
4---[ end trace f66d593cc2b02658 ]---



-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line 

[PATCH 1/6] ACPI / processor: Introduce apic_id in struct processor to save parsed APIC id

2013-08-31 Thread Hanjun Guo
From: Jiang Liu jiang@huawei.com

For cpu hot add, we evaluate _MAT or parse MADT twice to get APIC id,
here is the code logic:
acpi_processor_add()
acpi_processor_get_info()
acpi_get_cpuid() will evaluate _MAT or parse MADT;
acpi_processor_hotadd_init()
acpi_map_lsapic() will evaluate _MAT again;

This can be done more effectively, this patch introduces apic_id in struct
processor to save parsed APIC id, and then we can use it and remove the
duplicated _MAT evaluation.

Signed-off-by: Jiang Liu jiang@huawei.com
Signed-off-by: Hanjun Guo hanjun@linaro.org
---
 drivers/acpi/acpi_processor.c |3 ++-
 drivers/acpi/processor_core.c |   26 +-
 include/acpi/processor.h  |3 +++
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index f29e06e..d5a6c81 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -270,7 +270,8 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
device_declaration = 1;
pr-acpi_id = value;
}
-   cpu_index = acpi_get_cpuid(pr-handle, device_declaration, pr-acpi_id);
+   pr-apic_id = acpi_get_apicid(pr-handle, device_declaration, 
pr-acpi_id);
+   cpu_index = acpi_map_cpuid(pr-apic_id, pr-acpi_id);
 
/* Handle UP system running SMP kernel, with no LAPIC in MADT */
if (!cpu0_initialized  (cpu_index == -1) 
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index cf34d90..b3171f3 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -162,16 +162,23 @@ exit:
return apic_id;
 }
 
-int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
+int acpi_get_apicid(acpi_handle handle, int type, u32 acpi_id)
 {
-#ifdef CONFIG_SMP
-   int i;
-#endif
-   int apic_id = -1;
+   int apic_id;
 
apic_id = map_mat_entry(handle, type, acpi_id);
if (apic_id == -1)
apic_id = map_madt_entry(type, acpi_id);
+
+   return apic_id;
+}
+
+int acpi_map_cpuid(int apic_id, u32 acpi_id)
+{
+#ifdef CONFIG_SMP
+   int i;
+#endif
+
if (apic_id == -1) {
/*
 * On UP processor, there is no _MAT or MADT table.
@@ -211,6 +218,15 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 
acpi_id)
 #endif
return -1;
 }
+
+int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
+{
+   int apic_id;
+
+   apic_id = acpi_get_apicid(handle, type, acpi_id);
+
+   return acpi_map_cpuid(apic_id, acpi_id);
+}
 EXPORT_SYMBOL_GPL(acpi_get_cpuid);
 
 static bool __init processor_physically_present(acpi_handle handle)
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 66096d0..7816e45 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -199,6 +199,7 @@ struct acpi_processor_flags {
 struct acpi_processor {
acpi_handle handle;
u32 acpi_id;
+   u32 apic_id;
u32 id;
u32 pblk;
int performance_platform_limit;
@@ -314,6 +315,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, 
unsigned int *limit)
 
 /* in processor_core.c */
 void acpi_processor_set_pdc(acpi_handle handle);
+int acpi_get_apicid(acpi_handle, int type, u32 acpi_id);
+int acpi_map_cpuid(int apic_id, u32 acpi_id);
 int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
 
 /* in processor_throttling.c */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] ACPI / processor: use apic_id and remove duplicated _MAT evaluation

2013-08-31 Thread Hanjun Guo
From: Jiang Liu jiang@huawei.com

Since APIC id is saved in processor struct, just use it and
remove the duplicated _MAT evaluation.

Signed-off-by: Jiang Liu jiang@huawei.com
Signed-off-by: Hanjun Guo hanjun@linaro.org
---
 arch/ia64/kernel/acpi.c   |   38 --
 arch/x86/kernel/acpi/boot.c   |   38 +++---
 drivers/acpi/acpi_processor.c |2 +-
 include/linux/acpi.h  |2 +-
 4 files changed, 9 insertions(+), 71 deletions(-)

diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 5eb71d2..59d52e3 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -882,40 +882,10 @@ __init void prefill_possible_map(void)
set_cpu_possible(i, true);
 }
 
-static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
+static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
 {
-   struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-   union acpi_object *obj;
-   struct acpi_madt_local_sapic *lsapic;
cpumask_t tmp_map;
-   int cpu, physid;
-
-   if (ACPI_FAILURE(acpi_evaluate_object(handle, _MAT, NULL, buffer)))
-   return -EINVAL;
-
-   if (!buffer.length || !buffer.pointer)
-   return -EINVAL;
-
-   obj = buffer.pointer;
-   if (obj-type != ACPI_TYPE_BUFFER)
-   {
-   kfree(buffer.pointer);
-   return -EINVAL;
-   }
-
-   lsapic = (struct acpi_madt_local_sapic *)obj-buffer.pointer;
-
-   if ((lsapic-header.type != ACPI_MADT_TYPE_LOCAL_SAPIC) ||
-   (!(lsapic-lapic_flags  ACPI_MADT_ENABLED))) {
-   kfree(buffer.pointer);
-   return -EINVAL;
-   }
-
-   physid = ((lsapic-id  8) | (lsapic-eid));
-
-   kfree(buffer.pointer);
-   buffer.length = ACPI_ALLOCATE_BUFFER;
-   buffer.pointer = NULL;
+   int cpu;
 
cpumask_complement(tmp_map, cpu_present_mask);
cpu = cpumask_first(tmp_map);
@@ -934,9 +904,9 @@ static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
 }
 
 /* wrapper to silence section mismatch warning */
-int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
+int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
 {
-   return _acpi_map_lsapic(handle, pcpu);
+   return _acpi_map_lsapic(handle, physid, pcpu);
 }
 EXPORT_SYMBOL(acpi_map_lsapic);
 
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 2627a81..3e186d1 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -620,44 +620,12 @@ static void acpi_map_cpu2node(acpi_handle handle, int 
cpu, int physid)
 #endif
 }
 
-static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
+static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
 {
-   struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-   union acpi_object *obj;
-   struct acpi_madt_local_apic *lapic;
cpumask_var_t tmp_map, new_map;
-   u8 physid;
int cpu;
int retval = -ENOMEM;
 
-   if (ACPI_FAILURE(acpi_evaluate_object(handle, _MAT, NULL, buffer)))
-   return -EINVAL;
-
-   if (!buffer.length || !buffer.pointer)
-   return -EINVAL;
-
-   obj = buffer.pointer;
-   if (obj-type != ACPI_TYPE_BUFFER ||
-   obj-buffer.length  sizeof(*lapic)) {
-   kfree(buffer.pointer);
-   return -EINVAL;
-   }
-
-   lapic = (struct acpi_madt_local_apic *)obj-buffer.pointer;
-
-   if (lapic-header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
-   !(lapic-lapic_flags  ACPI_MADT_ENABLED)) {
-   kfree(buffer.pointer);
-   return -EINVAL;
-   }
-
-   physid = lapic-id;
-
-   kfree(buffer.pointer);
-   buffer.length = ACPI_ALLOCATE_BUFFER;
-   buffer.pointer = NULL;
-   lapic = NULL;
-
if (!alloc_cpumask_var(tmp_map, GFP_KERNEL))
goto out;
 
@@ -695,9 +663,9 @@ out:
 }
 
 /* wrapper to silence section mismatch warning */
-int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
+int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
 {
-   return _acpi_map_lsapic(handle, pcpu);
+   return _acpi_map_lsapic(handle, physid, pcpu);
 }
 EXPORT_SYMBOL(acpi_map_lsapic);
 
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index d5a6c81..488e5d8 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -181,7 +181,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor 
*pr)
cpu_maps_update_begin();
cpu_hotplug_begin();
 
-   ret = acpi_map_lsapic(pr-handle, pr-id);
+   ret = acpi_map_lsapic(pr-handle, pr-apic_id, pr-id);
if (ret)
goto out;
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index a5db4ae..3bc7414 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -116,7 +116,7 @@ 

[PATCH 3/6] x86: simplify _acpi_map_lsapic()

2013-08-31 Thread Hanjun Guo
From: Jiang Liu jiang@huawei.com

In acpi_register_lapic(), it will generates a new logical cpu
number and maps to the local APIC id, this logical cpu number
can be returned to simplify _acpi_map_lsapic() implementation.

Signed-off-by: Jiang Liu jiang@huawei.com
Signed-off-by: Hanjun Guo hanjun@linaro.org
---
 arch/x86/include/asm/mpspec.h |2 +-
 arch/x86/kernel/acpi/boot.c   |   48 +
 arch/x86/kernel/apic/apic.c   |8 ---
 3 files changed, 21 insertions(+), 37 deletions(-)

diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h
index 626cf70..3142a94 100644
--- a/arch/x86/include/asm/mpspec.h
+++ b/arch/x86/include/asm/mpspec.h
@@ -94,7 +94,7 @@ static inline void early_reserve_e820_mpc_new(void) { }
 #define default_get_smp_config x86_init_uint_noop
 #endif
 
-void generic_processor_info(int apicid, int version);
+int generic_processor_info(int apicid, int version);
 #ifdef CONFIG_ACPI
 extern void mp_register_ioapic(int id, u32 address, u32 gsi_base);
 extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 3e186d1..ca73370 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -195,24 +195,31 @@ static int __init acpi_parse_madt(struct 
acpi_table_header *table)
return 0;
 }
 
-static void acpi_register_lapic(int id, u8 enabled)
+/**
+ * acpi_register_lapic - register a local apic and generates a logic cpu number
+ * @id: local apic id to register
+ * @enabled: this cpu is enabled or not
+ *
+ * Returns the logic cpu number which maps to the local apic
+ */
+static int acpi_register_lapic(int id, u8 enabled)
 {
unsigned int ver = 0;
 
if (id = (MAX_LOCAL_APIC-1)) {
printk(KERN_INFO PREFIX skipped apicid that is too big\n);
-   return;
+   return -1;
}
 
if (!enabled) {
++disabled_cpus;
-   return;
+   return -1;
}
 
if (boot_cpu_physical_apicid != -1U)
ver = apic_version[boot_cpu_physical_apicid];
 
-   generic_processor_info(id, ver);
+   return generic_processor_info(id, ver);
 }
 
 static int __init
@@ -622,44 +629,19 @@ static void acpi_map_cpu2node(acpi_handle handle, int 
cpu, int physid)
 
 static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
 {
-   cpumask_var_t tmp_map, new_map;
int cpu;
-   int retval = -ENOMEM;
-
-   if (!alloc_cpumask_var(tmp_map, GFP_KERNEL))
-   goto out;
 
-   if (!alloc_cpumask_var(new_map, GFP_KERNEL))
-   goto free_tmp_map;
-
-   cpumask_copy(tmp_map, cpu_present_mask);
-   acpi_register_lapic(physid, ACPI_MADT_ENABLED);
-
-   /*
-* If acpi_register_lapic successfully generates a new logical cpu
-* number, then the following will get us exactly what was mapped
-*/
-   cpumask_andnot(new_map, cpu_present_mask, tmp_map);
-   if (cpumask_empty(new_map)) {
+   cpu = acpi_register_lapic(physid, ACPI_MADT_ENABLED);
+   if (cpu == -1) {
printk (Unable to map lapic to logical cpu number\n);
-   retval = -EINVAL;
-   goto free_new_map;
+   return -EINVAL;
}
 
acpi_processor_set_pdc(handle);
-
-   cpu = cpumask_first(new_map);
acpi_map_cpu2node(handle, cpu, physid);
 
*pcpu = cpu;
-   retval = 0;
-
-free_new_map:
-   free_cpumask_var(new_map);
-free_tmp_map:
-   free_cpumask_var(tmp_map);
-out:
-   return retval;
+   return 0;
 }
 
 /* wrapper to silence section mismatch warning */
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index eca89c5..87128778 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2107,7 +2107,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)
apic_write(APIC_LVT1, value);
 }
 
-void generic_processor_info(int apicid, int version)
+int generic_processor_info(int apicid, int version)
 {
int cpu, max = nr_cpu_ids;
bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid,
@@ -2127,7 +2127,7 @@ void generic_processor_info(int apicid, int version)
  Processor %d/0x%x ignored.\n, max, thiscpu, apicid);
 
disabled_cpus++;
-   return;
+   return -1;
}
 
if (num_processors = nr_cpu_ids) {
@@ -2138,7 +2138,7 @@ void generic_processor_info(int apicid, int version)
  Processor %d/0x%x ignored.\n, max, thiscpu, apicid);
 
disabled_cpus++;
-   return;
+   return -1;
}
 
num_processors++;
@@ -2183,6 +2183,8 @@ void generic_processor_info(int apicid, int version)
 #endif
set_cpu_possible(cpu, true);
set_cpu_present(cpu, true);
+
+   return 

[PATCH 4/6] ACPI / processor: remove some dead code in acpi_processor_get_info()

2013-08-31 Thread Hanjun Guo
From: Jiang Liu jiang@huawei.com

errata.smp is used by anywhere, so variable assignment is meanless,
remove it.

Signed-off-by: Jiang Liu jiang@huawei.com
Signed-off-by: Hanjun Guo hanjun@linaro.org
---
 drivers/acpi/acpi_processor.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 488e5d8..a2a71d0 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -220,9 +220,6 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
acpi_status status = AE_OK;
static int cpu0_initialized;
 
-   if (num_online_cpus()  1)
-   errata.smp = TRUE;
-
acpi_processor_errata(pr);
 
/*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] ACPI / processor: remove unnecessary if (!pr) check

2013-08-31 Thread Hanjun Guo
acpi_processor_errata() is only called in acpi_processor_get_info(),
and the argument 'pr' passed to acpi_processor_errata() will be never
NULL, so the if (!pr) check is unnecessary.

Since the 'pr' argument is not used by acpi_processor_errata() any more,
so change the argument into void.

Signed-off-by: Hanjun Guo hanjun@linaro.org
---
 drivers/acpi/acpi_processor.c |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index a2a71d0..d1cabe5 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -140,15 +140,11 @@ static int acpi_processor_errata_piix4(struct pci_dev 
*dev)
return 0;
 }
 
-static int acpi_processor_errata(struct acpi_processor *pr)
+static int acpi_processor_errata(void)
 {
int result = 0;
struct pci_dev *dev = NULL;
 
-
-   if (!pr)
-   return -EINVAL;
-
/*
 * PIIX4
 */
@@ -220,7 +216,7 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
acpi_status status = AE_OK;
static int cpu0_initialized;
 
-   acpi_processor_errata(pr);
+   acpi_processor_errata();
 
/*
 * Check to see if we have bus mastering arbitration control.  This
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] ACPI / processor: Remove outdated comments

2013-08-31 Thread Hanjun Guo
acpi_get_processor_id() can be find nowhere, and the acpi id
is synchronized to APIC id when acpi_get_cpuid() is called, so
the comments can be removed.

Signed-off-by: Hanjun Guo hanjun@linaro.org
---
 drivers/acpi/acpi_processor.c |5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index d1cabe5..fa2412e 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -240,11 +240,6 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
return -ENODEV;
}
 
-   /*
-* TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
-*   'acpi_get_processor_id(acpi_id, id)' in
-*  arch/xxx/acpi.c
-*/
pr-acpi_id = object.processor.proc_id;
} else {
/*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: 3.11-rc7: unpriviledged user crashes kernel using bluetooth

2013-08-31 Thread Pavel Machek
On Sat 2013-08-31 12:14:51, Pavel Machek wrote:
 On Sat 2013-08-31 12:09:33, Pavel Machek wrote:
  Hi!
  
   . Python sources for client/server are at 
   
   http://tui.cvs.sourceforge.net/viewvc/tui/tui/liveview/
   
   . My kernels like to warn about
  System is debian stable with gnome2.
 
 And no, it is not fixed in 3.11-rc7.

2.6.32-5-686 from debian seems to work.

Notice that I probably have modemmanager fighting with my own
server, that is experiencing problem described in
http://ubuntuforums.org/showthread.php?t=2056285 . That still should
not allow me to crash the kernel.
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] ARM: Dove: Add the audio device to the Cubox DT

2013-08-31 Thread Jean-Francois Moine
On Wed, 28 Aug 2013 12:14:24 +0200
Sebastian Hesselbarth sebastian.hesselba...@gmail.com wrote:

  +i2s1 {
  +   status = okay;
  +   pinctrl-0 = pmx_audio1_i2s1_spdifo;
  +   pinctrl-names = default;
  +};  
 
 Please also add the external clock connected from si5351.

Hi Sebastian and Russell,

I tried it on my Cubox (si5351 2), and I have problems with HDMI
output and some audio streams like webradios with sample rates 32 or
22.05 kHz.

According to the Dove specification, the audio controller works with
the samples rates 44.1, 48 and 96 kHz, so, I don't see the usage of the
external clock, except when using the two audio controllers with
different sample rates.

But, BTW, as the kirkwood-i2 driver is written, this last case does not
work: for 44.1, 48 and 96 kHz, the external clock is never used and
there is only one DCO.

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] regulator: wm831x-isink: Use devm_request_threaded_irq()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

devm guarantees that resources are freed in the opposite order to that in
which they are allocated.

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/wm831x-isink.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index 4eb373d..841cb52 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -203,8 +203,10 @@ static int wm831x_isink_probe(struct platform_device *pdev)
}
 
irq = wm831x_irq(wm831x, platform_get_irq(pdev, 0));
-   ret = request_threaded_irq(irq, NULL, wm831x_isink_irq,
-  IRQF_TRIGGER_RISING, isink-name, isink);
+   ret = devm_request_threaded_irq(pdev-dev, irq, NULL,
+   wm831x_isink_irq,
+   IRQF_TRIGGER_RISING, isink-name,
+   isink);
if (ret != 0) {
dev_err(pdev-dev, Failed to request ISINK IRQ %d: %d\n,
irq, ret);
@@ -225,8 +227,6 @@ static int wm831x_isink_remove(struct platform_device *pdev)
 {
struct wm831x_isink *isink = platform_get_drvdata(pdev);
 
-   free_irq(wm831x_irq(isink-wm831x, platform_get_irq(pdev, 0)), isink);
-
regulator_unregister(isink-regulator);
 
return 0;
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] regulator: wm831x-dcdc: Convert to devm_request_threaded_irq()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

devm guarantees that resources are freed in the opposite order to that
in which they are registered.

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/wm831x-dcdc.c | 36 ++--
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index 8f62750..aca2fcb 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -532,8 +532,9 @@ static int wm831x_buckv_probe(struct platform_device *pdev)
}
 
irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, UV));
-   ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq,
-  IRQF_TRIGGER_RISING, dcdc-name, dcdc);
+   ret = devm_request_threaded_irq(pdev-dev, irq, NULL,
+   wm831x_dcdc_uv_irq,
+   IRQF_TRIGGER_RISING, dcdc-name, dcdc);
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
@@ -541,21 +542,19 @@ static int wm831x_buckv_probe(struct platform_device 
*pdev)
}
 
irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, HC));
-   ret = request_threaded_irq(irq, NULL, wm831x_dcdc_oc_irq,
-  IRQF_TRIGGER_RISING, dcdc-name, dcdc);
+   ret = devm_request_threaded_irq(pdev-dev, irq, NULL,
+   wm831x_dcdc_oc_irq,
+   IRQF_TRIGGER_RISING, dcdc-name, dcdc);
if (ret != 0) {
dev_err(pdev-dev, Failed to request HC IRQ %d: %d\n,
irq, ret);
-   goto err_uv;
+   goto err_regulator;
}
 
platform_set_drvdata(pdev, dcdc);
 
return 0;
 
-err_uv:
-   free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, UV)),
-dcdc);
 err_regulator:
regulator_unregister(dcdc-regulator);
 err:
@@ -565,12 +564,7 @@ err:
 static int wm831x_buckv_remove(struct platform_device *pdev)
 {
struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
-   struct wm831x *wm831x = dcdc-wm831x;
 
-   free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, HC)),
-   dcdc);
-   free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, UV)),
-   dcdc);
regulator_unregister(dcdc-regulator);
 
return 0;
@@ -688,8 +682,9 @@ static int wm831x_buckp_probe(struct platform_device *pdev)
}
 
irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, UV));
-   ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq,
-  IRQF_TRIGGER_RISING, dcdc-name, dcdc);
+   ret = devm_request_threaded_irq(pdev-dev, irq, NULL,
+   wm831x_dcdc_uv_irq,
+   IRQF_TRIGGER_RISING, dcdc-name, dcdc);
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
@@ -710,8 +705,6 @@ static int wm831x_buckp_remove(struct platform_device *pdev)
 {
struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
 
-   free_irq(wm831x_irq(dcdc-wm831x, platform_get_irq_byname(pdev, UV)),
-   dcdc);
regulator_unregister(dcdc-regulator);
 
return 0;
@@ -820,9 +813,10 @@ static int wm831x_boostp_probe(struct platform_device 
*pdev)
}
 
irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, UV));
-   ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq,
-  IRQF_TRIGGER_RISING, dcdc-name,
-  dcdc);
+   ret = devm_request_threaded_irq(pdev-dev, irq, NULL,
+   wm831x_dcdc_uv_irq,
+   IRQF_TRIGGER_RISING, dcdc-name,
+   dcdc);
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
@@ -843,8 +837,6 @@ static int wm831x_boostp_remove(struct platform_device 
*pdev)
 {
struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
 
-   free_irq(wm831x_irq(dcdc-wm831x, platform_get_irq_byname(pdev, UV)),
-dcdc);
regulator_unregister(dcdc-regulator);
 
return 0;
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Staging:BCM:DDRInit.c:Renaming __FUNCTION__

2013-08-31 Thread Dan Carpenter
On Fri, Aug 30, 2013 at 06:49:16PM +0100, Paul McQuade wrote:
 From c21d0da84c92d351f37b70c0d9c01a66fcb84e88 Mon Sep 17 00:00:00 2001
 From: Paul McQuade paulmcq...@gmail.com
 Date: Thu, 15 Aug 2013 20:00:50 +0100
 Subject: [PATCH] Staging:BCM:DDRInit.c:Renaming __FUNCTION__
 

Don't put these in the patch description.

 __Function__ gets renamed with __func__
 

__FUNCTION__

You have some other changes as well like white space changes to
surrounding lines.  Put those in a separate patch.


   retval = wrmalt(Adapter,(UINT)0x0f000830, 
 uiResetValue, sizeof(uiResetValue));
   if(retval  0) {
 - BCM_DEBUG_PRINT(Adapter,CMHOST, WRM, 
 DBG_LVL_ALL, %s:%d WRM failed\n, __FUNCTION__, __LINE__);
 + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, 
 DBG_LVL_ALL, %s:%d RDM failed\n, __func__, __LINE__);
   return retval;
   }

Here you changed the WRM to RDM.  That can fall under the trivial and
closely related change but it needs to be mentioned in the changelog.
Except in this case the original message was correct and the new message
is wrong.  W stands for write and R stands for read.

regards,
dan carpenter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] regulator: wm831x-ldo: Use devm_request_threaded_irq()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

devm guarantees that resources are freed in the oposite order to that in
which they are allocated.

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/wm831x-ldo.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index 1432b26..5570f3e 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -288,9 +288,10 @@ static int wm831x_gp_ldo_probe(struct platform_device 
*pdev)
}
 
irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, UV));
-   ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq,
-  IRQF_TRIGGER_RISING, ldo-name,
-  ldo);
+   ret = devm_request_threaded_irq(pdev-dev, irq, NULL,
+   wm831x_ldo_uv_irq,
+   IRQF_TRIGGER_RISING, ldo-name,
+   ldo);
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
@@ -311,8 +312,6 @@ static int wm831x_gp_ldo_remove(struct platform_device 
*pdev)
 {
struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
 
-   free_irq(wm831x_irq(ldo-wm831x,
-   platform_get_irq_byname(pdev, UV)), ldo);
regulator_unregister(ldo-regulator);
 
return 0;
@@ -514,8 +513,9 @@ static int wm831x_aldo_probe(struct platform_device *pdev)
}
 
irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, UV));
-   ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq,
-  IRQF_TRIGGER_RISING, ldo-name, ldo);
+   ret = devm_request_threaded_irq(pdev-dev, irq, NULL,
+   wm831x_ldo_uv_irq,
+   IRQF_TRIGGER_RISING, ldo-name, ldo);
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
@@ -536,8 +536,6 @@ static int wm831x_aldo_remove(struct platform_device *pdev)
 {
struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
 
-   free_irq(wm831x_irq(ldo-wm831x, platform_get_irq_byname(pdev, UV)),
-ldo);
regulator_unregister(ldo-regulator);
 
return 0;
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] regulator: wm831x-dcdc: Convert to devm_gpio_request_one()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Saves code in the unwind path.

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/wm831x-dcdc.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index 11861cb..8f62750 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -387,8 +387,9 @@ static struct regulator_ops wm831x_buckv_ops = {
  * Set up DVS control.  We just log errors since we can still run
  * (with reduced performance) if we fail.
  */
-static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc,
-   struct wm831x_buckv_pdata *pdata)
+static void wm831x_buckv_dvs_init(struct platform_device *pdev,
+ struct wm831x_dcdc *dcdc,
+ struct wm831x_buckv_pdata *pdata)
 {
struct wm831x *wm831x = dcdc-wm831x;
int ret;
@@ -402,9 +403,9 @@ static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc,
 */
dcdc-dvs_gpio_state = pdata-dvs_init_state;
 
-   ret = gpio_request_one(pdata-dvs_gpio,
-  dcdc-dvs_gpio_state ? GPIOF_INIT_HIGH : 0,
-  DCDC DVS);
+   ret = devm_gpio_request_one(pdev-dev, pdata-dvs_gpio,
+   dcdc-dvs_gpio_state ? GPIOF_INIT_HIGH : 0,
+   DCDC DVS);
if (ret  0) {
dev_err(wm831x-dev, Failed to get %s DVS GPIO: %d\n,
dcdc-name, ret);
@@ -513,7 +514,8 @@ static int wm831x_buckv_probe(struct platform_device *pdev)
dcdc-dvs_vsel = ret  WM831X_DC1_DVS_VSEL_MASK;
 
if (pdata  pdata-dcdc[id])
-   wm831x_buckv_dvs_init(dcdc, pdata-dcdc[id]-driver_data);
+   wm831x_buckv_dvs_init(pdev, dcdc,
+ pdata-dcdc[id]-driver_data);
 
config.dev = pdev-dev.parent;
if (pdata)
@@ -557,8 +559,6 @@ err_uv:
 err_regulator:
regulator_unregister(dcdc-regulator);
 err:
-   if (dcdc-dvs_gpio)
-   gpio_free(dcdc-dvs_gpio);
return ret;
 }
 
@@ -572,8 +572,6 @@ static int wm831x_buckv_remove(struct platform_device *pdev)
free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, UV)),
dcdc);
regulator_unregister(dcdc-regulator);
-   if (dcdc-dvs_gpio)
-   gpio_free(dcdc-dvs_gpio);
 
return 0;
 }
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [RFC][PATCH 17/18 v2] ftrace/cpuidle/x86: Mark functions that are RCU unsafe

2013-08-31 Thread Wysocki, Rafael J
Acked-by: Rafael J. Wysocki rafael.j.wyso...@intel.com




Sent from a tablet, I apologize for formatting issues.

Steven Rostedt rost...@goodmis.org wrote:
From: Steven Rostedt (Red Hat) rost...@goodmis.org

Some callbacks of the function tracer use rcu_read_lock(). This means that
there's places that can not be traced because RCU is not tracking the CPU
for various reasons (like NO_HZ_FULL and coming back from userspace).

Thes functions need to be marked so that callbacks that use RCU do not
trace them.

Cc: H. Peter Anvin h...@zytor.com
Cc: Rafael J. Wysocki rafael.j.wyso...@intel.com
Signed-off-by: Steven Rostedt rost...@goodmis.org
---
 arch/x86/kernel/process.c |2 ++
 drivers/cpuidle/cpuidle.c |2 ++
 kernel/cpu/idle.c |2 ++
 3 files changed, 6 insertions(+)

diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 83369e5..18739cd 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -17,6 +17,7 @@
 #include linux/stackprotector.h
 #include linux/tick.h
 #include linux/cpuidle.h
+#include linux/ftrace.h
 #include trace/events/power.h
 #include linux/hw_breakpoint.h
 #include asm/cpu.h
@@ -316,6 +317,7 @@ void default_idle(void)
 #ifdef CONFIG_APM_MODULE
 EXPORT_SYMBOL(default_idle);
 #endif
+FTRACE_UNSAFE_RCU(default_idle);

 #ifdef CONFIG_XEN
 bool xen_set_default_idle(void)
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index fdc432f..9515457 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -19,6 +19,7 @@
 #include linux/ktime.h
 #include linux/hrtimer.h
 #include linux/module.h
+#include linux/ftrace.h
 #include trace/events/power.h

 #include cpuidle.h
@@ -168,6 +169,7 @@ int cpuidle_idle_call(void)

 return 0;
 }
+FTRACE_UNSAFE_RCU(cpuidle_idle_call);

 /**
  * cpuidle_install_idle_handler - installs the cpuidle idle loop handler
diff --git a/kernel/cpu/idle.c b/kernel/cpu/idle.c
index e695c0a..d9d290f 100644
--- a/kernel/cpu/idle.c
+++ b/kernel/cpu/idle.c
@@ -5,6 +5,7 @@
 #include linux/cpu.h
 #include linux/tick.h
 #include linux/mm.h
+#include linux/ftrace.h
 #include linux/stackprotector.h

 #include asm/tlb.h
@@ -61,6 +62,7 @@ void __weak arch_cpu_idle(void)
 cpu_idle_force_poll = 1;
 local_irq_enable();
 }
+FTRACE_UNSAFE_RCU(arch_cpu_idle);

 /*
  * Generic idle loop implementation
--
1.7.10.4


-
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial 
Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | 
Kapital zakladowy 200.000 PLN.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i 
moze zawierac informacje poufne. W razie przypadkowego otrzymania tej 
wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; 
jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole 
use of the intended recipient(s). If you are not the intended recipient, please 
contact the sender and delete all copies; any review or distribution by others 
is strictly prohibited.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/11] regulator: core: Provide managed regulator registration

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Many regulator drivers have a remove function that consists solely of
calling regulator_unregister() so provide a devm_regulator_register()
in order to allow this repeated code to be removed and help eliminate
error handling code.

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/core.c | 66 
 include/linux/regulator/driver.h |  5 +++
 2 files changed, 71 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a01b8b3..5f995d2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3492,6 +3492,44 @@ clean:
 }
 EXPORT_SYMBOL_GPL(regulator_register);
 
+static void devm_rdev_release(struct device *dev, void *res)
+{
+   regulator_unregister(*(struct regulator_dev **)res);
+}
+
+/**
+ * devm_regulator_register - Resource managed regulator_register()
+ * @regulator_desc: regulator to register
+ * @config: runtime configuration for regulator
+ *
+ * Called by regulator drivers to register a regulator.  Returns a
+ * valid pointer to struct regulator_dev on success or an ERR_PTR() on
+ * error.  The regulator will automaticall be released when the device
+ * is unbound.
+ */
+struct regulator_dev *devm_regulator_register(struct device *dev,
+ const struct regulator_desc *regulator_desc,
+ const struct regulator_config *config)
+{
+   struct regulator_dev **ptr, *rdev;
+
+   ptr = devres_alloc(devm_rdev_release, sizeof(*ptr),
+  GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   rdev = regulator_register(regulator_desc, config);
+   if (!IS_ERR(rdev)) {
+   *ptr = rdev;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return rdev;
+}
+EXPORT_SYMBOL_GPL(devm_regulator_register);
+
 /**
  * regulator_unregister - unregister regulator
  * @rdev: regulator to unregister
@@ -3521,6 +3559,34 @@ void regulator_unregister(struct regulator_dev *rdev)
 }
 EXPORT_SYMBOL_GPL(regulator_unregister);
 
+static int devm_rdev_match(struct device *dev, void *res, void *data)
+{
+   struct regulator_dev **r = res;
+   if (!r || !*r) {
+   WARN_ON(!r || !*r);
+   return 0;
+   }
+   return *r == data;
+}
+
+/**
+ * devm_regulator_unregister - Resource managed regulator_unregister()
+ * @regulator: regulator to free
+ *
+ * Unregister a regulator registered with devm_regulator_register().
+ * Normally this function will not need to be called and the resource
+ * management code will ensure that the resource is freed.
+ */
+void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev)
+{
+   int rc;
+
+   rc = devres_release(dev, devm_rdev_release, devm_rdev_match, rdev);
+   if (rc != 0)
+   WARN_ON(rc);
+}
+EXPORT_SYMBOL_GPL(devm_regulator_unregister);
+
 /**
  * regulator_suspend_prepare - prepare regulators for system wide suspend
  * @state: system suspend state
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 67e13aa..8474c7f 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -334,7 +334,12 @@ struct regulator_dev {
 struct regulator_dev *
 regulator_register(const struct regulator_desc *regulator_desc,
   const struct regulator_config *config);
+struct regulator_dev *
+devm_regulator_register(struct device *dev,
+   const struct regulator_desc *regulator_desc,
+   const struct regulator_config *config);
 void regulator_unregister(struct regulator_dev *rdev);
+void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev);
 
 int regulator_notifier_call_chain(struct regulator_dev *rdev,
  unsigned long event, void *data);
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/11] regulator: wm831x-isink: Convert to devm_regulator_register()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/wm831x-isink.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index 841cb52..0339b88 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -194,7 +194,8 @@ static int wm831x_isink_probe(struct platform_device *pdev)
config.init_data = pdata-isink[id];
config.driver_data = isink;
 
-   isink-regulator = regulator_register(isink-desc, config);
+   isink-regulator = devm_regulator_register(pdev-dev, isink-desc,
+  config);
if (IS_ERR(isink-regulator)) {
ret = PTR_ERR(isink-regulator);
dev_err(wm831x-dev, Failed to register ISINK%d: %d\n,
@@ -210,31 +211,19 @@ static int wm831x_isink_probe(struct platform_device 
*pdev)
if (ret != 0) {
dev_err(pdev-dev, Failed to request ISINK IRQ %d: %d\n,
irq, ret);
-   goto err_regulator;
+   goto err;
}
 
platform_set_drvdata(pdev, isink);
 
return 0;
 
-err_regulator:
-   regulator_unregister(isink-regulator);
 err:
return ret;
 }
 
-static int wm831x_isink_remove(struct platform_device *pdev)
-{
-   struct wm831x_isink *isink = platform_get_drvdata(pdev);
-
-   regulator_unregister(isink-regulator);
-
-   return 0;
-}
-
 static struct platform_driver wm831x_isink_driver = {
.probe = wm831x_isink_probe,
-   .remove = wm831x_isink_remove,
.driver = {
.name   = wm831x-isink,
.owner  = THIS_MODULE,
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/11] regulator: s5m8767: Covert to devm_regulator_register()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/s5m8767.c | 24 +++-
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index c24448b..2297fdf 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -910,34 +910,17 @@ static int s5m8767_pmic_probe(struct platform_device 
*pdev)
config.regmap = iodev-regmap;
config.of_node = pdata-regulators[i].reg_node;
 
-   rdev[i] = regulator_register(regulators[id], config);
+   rdev[i] = devm_regulator_register(pdev-dev, regulators[id],
+ config);
if (IS_ERR(rdev[i])) {
ret = PTR_ERR(rdev[i]);
dev_err(s5m8767-dev, regulator init failed for %d\n,
id);
-   rdev[i] = NULL;
-   goto err;
+   return ret;
}
}
 
return 0;
-err:
-   for (i = 0; i  s5m8767-num_regulators; i++)
-   regulator_unregister(rdev[i]);
-
-   return ret;
-}
-
-static int s5m8767_pmic_remove(struct platform_device *pdev)
-{
-   struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev);
-   struct regulator_dev **rdev = s5m8767-rdev;
-   int i;
-
-   for (i = 0; i  s5m8767-num_regulators; i++)
-   regulator_unregister(rdev[i]);
-
-   return 0;
 }
 
 static const struct platform_device_id s5m8767_pmic_id[] = {
@@ -952,7 +935,6 @@ static struct platform_driver s5m8767_pmic_driver = {
.owner = THIS_MODULE,
},
.probe = s5m8767_pmic_probe,
-   .remove = s5m8767_pmic_remove,
.id_table = s5m8767_pmic_id,
 };
 
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/11] regulator: wm831x-dcdc: Convert to devm_regulator_register()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/wm831x-dcdc.c | 66 -
 1 file changed, 12 insertions(+), 54 deletions(-)

diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index aca2fcb..6823e6f 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -523,7 +523,8 @@ static int wm831x_buckv_probe(struct platform_device *pdev)
config.driver_data = dcdc;
config.regmap = wm831x-regmap;
 
-   dcdc-regulator = regulator_register(dcdc-desc, config);
+   dcdc-regulator = devm_regulator_register(pdev-dev, dcdc-desc,
+ config);
if (IS_ERR(dcdc-regulator)) {
ret = PTR_ERR(dcdc-regulator);
dev_err(wm831x-dev, Failed to register DCDC%d: %d\n,
@@ -538,7 +539,7 @@ static int wm831x_buckv_probe(struct platform_device *pdev)
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
-   goto err_regulator;
+   goto err;
}
 
irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, HC));
@@ -548,31 +549,19 @@ static int wm831x_buckv_probe(struct platform_device 
*pdev)
if (ret != 0) {
dev_err(pdev-dev, Failed to request HC IRQ %d: %d\n,
irq, ret);
-   goto err_regulator;
+   goto err;
}
 
platform_set_drvdata(pdev, dcdc);
 
return 0;
 
-err_regulator:
-   regulator_unregister(dcdc-regulator);
 err:
return ret;
 }
 
-static int wm831x_buckv_remove(struct platform_device *pdev)
-{
-   struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
-
-   regulator_unregister(dcdc-regulator);
-
-   return 0;
-}
-
 static struct platform_driver wm831x_buckv_driver = {
.probe = wm831x_buckv_probe,
-   .remove = wm831x_buckv_remove,
.driver = {
.name   = wm831x-buckv,
.owner  = THIS_MODULE,
@@ -673,7 +662,8 @@ static int wm831x_buckp_probe(struct platform_device *pdev)
config.driver_data = dcdc;
config.regmap = wm831x-regmap;
 
-   dcdc-regulator = regulator_register(dcdc-desc, config);
+   dcdc-regulator = devm_regulator_register(pdev-dev, dcdc-desc,
+ config);
if (IS_ERR(dcdc-regulator)) {
ret = PTR_ERR(dcdc-regulator);
dev_err(wm831x-dev, Failed to register DCDC%d: %d\n,
@@ -688,31 +678,19 @@ static int wm831x_buckp_probe(struct platform_device 
*pdev)
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
-   goto err_regulator;
+   goto err;
}
 
platform_set_drvdata(pdev, dcdc);
 
return 0;
 
-err_regulator:
-   regulator_unregister(dcdc-regulator);
 err:
return ret;
 }
 
-static int wm831x_buckp_remove(struct platform_device *pdev)
-{
-   struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
-
-   regulator_unregister(dcdc-regulator);
-
-   return 0;
-}
-
 static struct platform_driver wm831x_buckp_driver = {
.probe = wm831x_buckp_probe,
-   .remove = wm831x_buckp_remove,
.driver = {
.name   = wm831x-buckp,
.owner  = THIS_MODULE,
@@ -804,7 +782,8 @@ static int wm831x_boostp_probe(struct platform_device *pdev)
config.driver_data = dcdc;
config.regmap = wm831x-regmap;
 
-   dcdc-regulator = regulator_register(dcdc-desc, config);
+   dcdc-regulator = devm_regulator_register(pdev-dev, dcdc-desc,
+ config);
if (IS_ERR(dcdc-regulator)) {
ret = PTR_ERR(dcdc-regulator);
dev_err(wm831x-dev, Failed to register DCDC%d: %d\n,
@@ -820,31 +799,19 @@ static int wm831x_boostp_probe(struct platform_device 
*pdev)
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
-   goto err_regulator;
+   goto err;
}
 
platform_set_drvdata(pdev, dcdc);
 
return 0;
 
-err_regulator:
-   regulator_unregister(dcdc-regulator);
 err:
return ret;
 }
 
-static int wm831x_boostp_remove(struct platform_device *pdev)
-{
-   struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
-
-   regulator_unregister(dcdc-regulator);
-
-   return 0;
-}
-
 static struct platform_driver wm831x_boostp_driver = {
.probe = wm831x_boostp_probe,
-   .remove = wm831x_boostp_remove,
.driver = {
.name   = wm831x-boostp,
.owner  = THIS_MODULE,
@@ -904,7 +871,8 @@ static int wm831x_epe_probe(struct platform_device *pdev)

[PATCH 09/11] regulator: wm8350: Convert to devm_regulator_register()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/wm8350-regulator.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/wm8350-regulator.c 
b/drivers/regulator/wm8350-regulator.c
index 835b5f0..a438e93 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1206,7 +1206,8 @@ static int wm8350_regulator_probe(struct platform_device 
*pdev)
config.regmap = wm8350-regmap;
 
/* register regulator */
-   rdev = regulator_register(wm8350_reg[pdev-id], config);
+   rdev = devm_regulator_register(pdev-dev, wm8350_reg[pdev-id],
+  config);
if (IS_ERR(rdev)) {
dev_err(pdev-dev, failed to register %s\n,
wm8350_reg[pdev-id].name);
@@ -1217,7 +1218,6 @@ static int wm8350_regulator_probe(struct platform_device 
*pdev)
ret = wm8350_register_irq(wm8350, wm8350_reg[pdev-id].irq,
  pmic_uv_handler, 0, UV, rdev);
if (ret  0) {
-   regulator_unregister(rdev);
dev_err(pdev-dev, failed to register regulator %s IRQ\n,
wm8350_reg[pdev-id].name);
return ret;
@@ -1233,8 +1233,6 @@ static int wm8350_regulator_remove(struct platform_device 
*pdev)
 
wm8350_free_irq(wm8350, wm8350_reg[pdev-id].irq, rdev);
 
-   regulator_unregister(rdev);
-
return 0;
 }
 
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/11] regulator: arizona-ldo1: Convert to devm_regulator_register()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/arizona-ldo1.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 81d8681..4f6c205 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -226,7 +226,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
else
config.init_data = ldo1-init_data;
 
-   ldo1-regulator = regulator_register(desc, config);
+   ldo1-regulator = devm_regulator_register(pdev-dev, desc, config);
if (IS_ERR(ldo1-regulator)) {
ret = PTR_ERR(ldo1-regulator);
dev_err(arizona-dev, Failed to register LDO1 supply: %d\n,
@@ -239,18 +239,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
return 0;
 }
 
-static int arizona_ldo1_remove(struct platform_device *pdev)
-{
-   struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev);
-
-   regulator_unregister(ldo1-regulator);
-
-   return 0;
-}
-
 static struct platform_driver arizona_ldo1_driver = {
.probe = arizona_ldo1_probe,
-   .remove = arizona_ldo1_remove,
.driver = {
.name   = arizona-ldo1,
.owner  = THIS_MODULE,
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/11] regulator: arizona-micsupp: Convert to devm_regulator_register()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/arizona-micsupp.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/regulator/arizona-micsupp.c 
b/drivers/regulator/arizona-micsupp.c
index e87536b..724706a 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -225,7 +225,9 @@ static int arizona_micsupp_probe(struct platform_device 
*pdev)
regmap_update_bits(arizona-regmap, ARIZONA_MIC_CHARGE_PUMP_1,
   ARIZONA_CPMIC_BYPASS, 0);
 
-   micsupp-regulator = regulator_register(arizona_micsupp, config);
+   micsupp-regulator = devm_regulator_register(pdev-dev,
+arizona_micsupp,
+config);
if (IS_ERR(micsupp-regulator)) {
ret = PTR_ERR(micsupp-regulator);
dev_err(arizona-dev, Failed to register mic supply: %d\n,
@@ -238,18 +240,8 @@ static int arizona_micsupp_probe(struct platform_device 
*pdev)
return 0;
 }
 
-static int arizona_micsupp_remove(struct platform_device *pdev)
-{
-   struct arizona_micsupp *micsupp = platform_get_drvdata(pdev);
-
-   regulator_unregister(micsupp-regulator);
-
-   return 0;
-}
-
 static struct platform_driver arizona_micsupp_driver = {
.probe = arizona_micsupp_probe,
-   .remove = arizona_micsupp_remove,
.driver = {
.name   = arizona-micsupp,
.owner  = THIS_MODULE,
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/11] regulator: s2mps11: Convert to devm_regulator_register()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/s2mps11.c | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 5eba2ff..d7c241e 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -453,28 +453,11 @@ common_reg:
ret = PTR_ERR(s2mps11-rdev[i]);
dev_err(pdev-dev, regulator init failed for %d\n,
i);
-   s2mps11-rdev[i] = NULL;
-   goto err;
+   return ret;
}
}
 
return 0;
-err:
-   for (i = 0; i  S2MPS11_REGULATOR_MAX; i++)
-   regulator_unregister(s2mps11-rdev[i]);
-
-   return ret;
-}
-
-static int s2mps11_pmic_remove(struct platform_device *pdev)
-{
-   struct s2mps11_info *s2mps11 = platform_get_drvdata(pdev);
-   int i;
-
-   for (i = 0; i  S2MPS11_REGULATOR_MAX; i++)
-   regulator_unregister(s2mps11-rdev[i]);
-
-   return 0;
 }
 
 static const struct platform_device_id s2mps11_pmic_id[] = {
@@ -489,7 +472,6 @@ static struct platform_driver s2mps11_pmic_driver = {
.owner = THIS_MODULE,
},
.probe = s2mps11_pmic_probe,
-   .remove = s2mps11_pmic_remove,
.id_table = s2mps11_pmic_id,
 };
 
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/11] regulator: wm831x-ldo: Convert to devm_regulator_register()

2013-08-31 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/regulator/wm831x-ldo.c | 47 +++---
 1 file changed, 8 insertions(+), 39 deletions(-)

diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index 5570f3e..2be72fe 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -279,7 +279,8 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev)
config.driver_data = ldo;
config.regmap = wm831x-regmap;
 
-   ldo-regulator = regulator_register(ldo-desc, config);
+   ldo-regulator = devm_regulator_register(pdev-dev, ldo-desc,
+config);
if (IS_ERR(ldo-regulator)) {
ret = PTR_ERR(ldo-regulator);
dev_err(wm831x-dev, Failed to register LDO%d: %d\n,
@@ -295,31 +296,19 @@ static int wm831x_gp_ldo_probe(struct platform_device 
*pdev)
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
-   goto err_regulator;
+   goto err;
}
 
platform_set_drvdata(pdev, ldo);
 
return 0;
 
-err_regulator:
-   regulator_unregister(ldo-regulator);
 err:
return ret;
 }
 
-static int wm831x_gp_ldo_remove(struct platform_device *pdev)
-{
-   struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
-
-   regulator_unregister(ldo-regulator);
-
-   return 0;
-}
-
 static struct platform_driver wm831x_gp_ldo_driver = {
.probe = wm831x_gp_ldo_probe,
-   .remove = wm831x_gp_ldo_remove,
.driver = {
.name   = wm831x-ldo,
.owner  = THIS_MODULE,
@@ -504,7 +493,8 @@ static int wm831x_aldo_probe(struct platform_device *pdev)
config.driver_data = ldo;
config.regmap = wm831x-regmap;
 
-   ldo-regulator = regulator_register(ldo-desc, config);
+   ldo-regulator = devm_regulator_register(pdev-dev, ldo-desc,
+config);
if (IS_ERR(ldo-regulator)) {
ret = PTR_ERR(ldo-regulator);
dev_err(wm831x-dev, Failed to register LDO%d: %d\n,
@@ -519,31 +509,19 @@ static int wm831x_aldo_probe(struct platform_device *pdev)
if (ret != 0) {
dev_err(pdev-dev, Failed to request UV IRQ %d: %d\n,
irq, ret);
-   goto err_regulator;
+   goto err;
}
 
platform_set_drvdata(pdev, ldo);
 
return 0;
 
-err_regulator:
-   regulator_unregister(ldo-regulator);
 err:
return ret;
 }
 
-static int wm831x_aldo_remove(struct platform_device *pdev)
-{
-   struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
-
-   regulator_unregister(ldo-regulator);
-
-   return 0;
-}
-
 static struct platform_driver wm831x_aldo_driver = {
.probe = wm831x_aldo_probe,
-   .remove = wm831x_aldo_remove,
.driver = {
.name   = wm831x-aldo,
.owner  = THIS_MODULE,
@@ -661,7 +639,8 @@ static int wm831x_alive_ldo_probe(struct platform_device 
*pdev)
config.driver_data = ldo;
config.regmap = wm831x-regmap;
 
-   ldo-regulator = regulator_register(ldo-desc, config);
+   ldo-regulator = devm_regulator_register(pdev-dev, ldo-desc,
+config);
if (IS_ERR(ldo-regulator)) {
ret = PTR_ERR(ldo-regulator);
dev_err(wm831x-dev, Failed to register LDO%d: %d\n,
@@ -677,18 +656,8 @@ err:
return ret;
 }
 
-static int wm831x_alive_ldo_remove(struct platform_device *pdev)
-{
-   struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
-
-   regulator_unregister(ldo-regulator);
-
-   return 0;
-}
-
 static struct platform_driver wm831x_alive_ldo_driver = {
.probe = wm831x_alive_ldo_probe,
-   .remove = wm831x_alive_ldo_remove,
.driver = {
.name   = wm831x-alive-ldo,
.owner  = THIS_MODULE,
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] ARM: Dove: Add the audio device to the Cubox DT

2013-08-31 Thread Russell King - ARM Linux
On Sat, Aug 31, 2013 at 12:51:28PM +0200, Jean-Francois Moine wrote:
 Hi Sebastian and Russell,
 
 I tried it on my Cubox (si5351 2), and I have problems with HDMI
 output and some audio streams like webradios with sample rates 32 or
 22.05 kHz.

Some TVs will only accept certain sample rates - my (brand new) TV has
an audio block in the EDID containing this (starting at byte 0x92 -
note - I don't think it has to start at that offset):

23 09 07 01 

0x23 = audio block code (7:5 = 1, 4:0 = size)
0x09 = 7:3 format code = 1 (PCM), 2:0 number of channels = 2
0x07 = 48kHz, 44.1kHz and 32kHz supported
0x01 = 16-bit

There is no bit to indicate 22.05kHz support - 32kHz is the lowest which
the EDID block can report.

Also, this new TV seems to be more fussy than the old - it remains silent
with 48kHz playback, but works with 44.1kHz.  I've tried tweaking a fair
number of the registers both in the NXP and Dove, including the SPDIF
channel status, and nothing seems to make any difference.  Given that
the old TV just converted HDMI to analogue - yes, really - and this one
doesn't, I suspect it has stricter checking of the HDMI data.

However, even with the EDID reporting a restricted set of sample rates,
this does not mean that we should restrict ALSAs selection: remember,
the SPDIF is also routed out through the TOSlink output, which can
(undetectably, since it is output only) support more sample rates than
the HDMI connected device.

In the longer term, we probably want to eventually connect the NXP into
the ASoC DPCM code, so that it can be informed about the properties of
the audio being fed to it.  It can then compare the capabililties of the
connected device and disable HDMI audio output if they're not compatible.
That requires working DPCM first though.

 According to the Dove specification, the audio controller works with
 the samples rates 44.1, 48 and 96 kHz, so, I don't see the usage of the
 external clock, except when using the two audio controllers with
 different sample rates.

I don't see what the Dove specification has to do with that statement:
what the Dove spec says is that if you use just the internal DCO, then
only 44.1kHz, 48kHz and 96kHz are supported (with some trimming of that.)
However, the use of an external clock allows further rates to be supported.
If you have an external clock, there is no requirement to use the DCO for
those sample rates - you can if you wish, or you can use the external clock.

The mainline driver implements the use of the DCO for the standard 44.1,
48 and 96kHz rates, otherwise it uses the external clock if present.  This
is entirely conformant with the Dove spec.

If you attempt to use both audio controllers on the Cubox with different
sample rates which aren't supported by the DCO, then they will fight over
the input clock rate.  That's a limitation of the hardware, and there's
no real solution to that.  As the Cubox does not wire up the first audio
controller, it should not be enabled in DT.  If a board does use both, and
they both use the external clock input, then that's the time that this
needs to be solved.

We have more than enough problems to sort out without inventing new
problems.

 But, BTW, as the kirkwood-i2 driver is written, this last case does not
 work: for 44.1, 48 and 96 kHz, the external clock is never used and
 there is only one DCO.

This doesn't make sense.  this last case - what case are you referring
to?  there is only one DCO ?  Yes, there is only one DCO, what is its
relevance to the statement you're making?  And yes, in mainline we
currently use the DCO for the standard 44.1, 48 and 96kHz sample rates.
That's fine.  Confused.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 00/10] autofs4 - rename autofs4 to autofs

2013-08-31 Thread Ian Kent
The autofs4 kernel module provides function for autofs version 3, 4 and
5 and autofs module has long since been removed. Now we're left with a
misnamed module. Appart from the name another problem this presents is
that module autoload doesn't work because of the mismatch of the directory
name and the name of the file system provided by the module.

So autofs4 should be renamed to autofs but I've held back doing it because
of the potential disruption that could occur with a change like this.

The issues are somewhat reduced now because systemd needs the autofs
module at startup, and because of the autoload issue it's easier to just
compile the module into the kernel, which is what is often done.

Changes since the last posting of the series:
- removed the patches that updated the configs to use  CONFIG_AUTOFS_FS
  instead of CONFIG_AUTOFS4_FS, as recommended by Stephen Rothwell.
- Broke up large patches to meet list post size requirements.

By leaving a Kconfig and Makefile in fs/autofs4 (to build autofs4.ko)
with a deprication message sub-system maintainers and other users will
make any needed changes before these are removed after two kernel versions.
IMHO the presence of the warning is reason enough to leave a build stub
rather than do a straight out rename.

Any comments on the rename are welcome.

---

Ian Kent (10):
  autofs4 - coding style fixes
  autofs4 - fix string.h include in auto_dev-ioctl.h
  autofs4 - move linux/auto_dev-ioctl.h to uapi/linux
  autofs - merge auto_fs.h and auto_fs4.h
  autofs - use autofs instead of autofs4 everywhere
  autofs - copy autofs4 to autofs
  autofs - create autofs Kconfig and Makefile
  autofs - update fs/autofs4/Kconfig
  autofs - update fs/autofs4/Makefile
  autofs - delete fs/autofs4


 fs/Kconfig  |1 
 fs/Makefile |1 
 fs/autofs/Kconfig   |   19 +
 fs/autofs/Makefile  |7 
 fs/autofs/autofs_i.h|  341 +
 fs/autofs/dev-ioctl.c   |  759 ++
 fs/autofs/expire.c  |  561 ++
 fs/autofs/init.c|   49 ++
 fs/autofs/inode.c   |  368 ++
 fs/autofs/root.c|  898 +++
 fs/autofs/symlink.c |   21 +
 fs/autofs/waitq.c   |  570 ++
 fs/autofs4/Kconfig  |   30 +
 fs/autofs4/Makefile |4 
 fs/autofs4/autofs_i.h   |  341 -
 fs/autofs4/dev-ioctl.c  |  760 --
 fs/autofs4/expire.c |  562 --
 fs/autofs4/init.c   |   52 --
 fs/autofs4/inode.c  |  371 --
 fs/autofs4/root.c   |  898 ---
 fs/autofs4/symlink.c|   24 -
 fs/autofs4/waitq.c  |  572 --
 fs/compat_ioctl.c   |1 
 include/linux/auto_dev-ioctl.h  |  229 -
 include/linux/auto_fs.h |5 
 include/uapi/linux/auto_dev-ioctl.h |  224 +
 include/uapi/linux/auto_fs.h|  156 ++
 include/uapi/linux/auto_fs4.h   |  158 --
 28 files changed, 3991 insertions(+), 3991 deletions(-)
 create mode 100644 fs/autofs/Kconfig
 create mode 100644 fs/autofs/Makefile
 create mode 100644 fs/autofs/autofs_i.h
 create mode 100644 fs/autofs/dev-ioctl.c
 create mode 100644 fs/autofs/expire.c
 create mode 100644 fs/autofs/init.c
 create mode 100644 fs/autofs/inode.c
 create mode 100644 fs/autofs/root.c
 create mode 100644 fs/autofs/symlink.c
 create mode 100644 fs/autofs/waitq.c
 delete mode 100644 fs/autofs4/autofs_i.h
 delete mode 100644 fs/autofs4/dev-ioctl.c
 delete mode 100644 fs/autofs4/expire.c
 delete mode 100644 fs/autofs4/init.c
 delete mode 100644 fs/autofs4/inode.c
 delete mode 100644 fs/autofs4/root.c
 delete mode 100644 fs/autofs4/symlink.c
 delete mode 100644 fs/autofs4/waitq.c
 delete mode 100644 include/linux/auto_dev-ioctl.h
 create mode 100644 include/uapi/linux/auto_dev-ioctl.h

-- 
Ian
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/10] autofs4 - move linux/auto_dev-ioctl.h to uapi/linux

2013-08-31 Thread Ian Kent
Since linux/auto_dev-ioctl.h wasn't included in include/linux/Kbuild (although
I should have added it) it wasn't moved to uapi/linux as part of the uapi
series.

Signed-off-by: Ian Kent ra...@themaw.net
---
 include/linux/auto_dev-ioctl.h  |  224 ---
 include/uapi/linux/auto_dev-ioctl.h |  224 +++
 2 files changed, 224 insertions(+), 224 deletions(-)
 delete mode 100644 include/linux/auto_dev-ioctl.h
 create mode 100644 include/uapi/linux/auto_dev-ioctl.h

diff --git a/include/linux/auto_dev-ioctl.h b/include/linux/auto_dev-ioctl.h
deleted file mode 100644
index fe4f373..000
--- a/include/linux/auto_dev-ioctl.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright 2008 Red Hat, Inc. All rights reserved.
- * Copyright 2008 Ian Kent ra...@themaw.net
- *
- * This file is part of the Linux kernel and is made available under
- * the terms of the GNU General Public License, version 2, or at your
- * option, any later version, incorporated herein by reference.
- */
-
-#ifndef _LINUX_AUTO_DEV_IOCTL_H
-#define _LINUX_AUTO_DEV_IOCTL_H
-
-#include linux/auto_fs.h
-#include linux/string.h
-
-#define AUTOFS_DEVICE_NAME autofs
-
-#define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1
-#define AUTOFS_DEV_IOCTL_VERSION_MINOR 0
-
-#define AUTOFS_DEVID_LEN   16
-
-#define AUTOFS_DEV_IOCTL_SIZE  sizeof(struct autofs_dev_ioctl)
-
-/*
- * An ioctl interface for autofs mount point control.
- */
-
-struct args_protover {
-   __u32   version;
-};
-
-struct args_protosubver {
-   __u32   sub_version;
-};
-
-struct args_openmount {
-   __u32   devid;
-};
-
-struct args_ready {
-   __u32   token;
-};
-
-struct args_fail {
-   __u32   token;
-   __s32   status;
-};
-
-struct args_setpipefd {
-   __s32   pipefd;
-};
-
-struct args_timeout {
-   __u64   timeout;
-};
-
-struct args_requester {
-   __u32   uid;
-   __u32   gid;
-};
-
-struct args_expire {
-   __u32   how;
-};
-
-struct args_askumount {
-   __u32   may_umount;
-};
-
-struct args_ismountpoint {
-   union {
-   struct args_in {
-   __u32   type;
-   } in;
-   struct args_out {
-   __u32   devid;
-   __u32   magic;
-   } out;
-   };
-};
-
-/*
- * All the ioctls use this structure.
- * When sending a path size must account for the total length
- * of the chunk of memory otherwise is is the size of the
- * structure.
- */
-
-struct autofs_dev_ioctl {
-   __u32 ver_major;
-   __u32 ver_minor;
-   __u32 size; /* total size of data passed in
-* including this struct */
-   __s32 ioctlfd;  /* automount command fd */
-
-   /* Command parameters */
-
-   union {
-   struct args_protoverprotover;
-   struct args_protosubver protosubver;
-   struct args_openmount   openmount;
-   struct args_ready   ready;
-   struct args_failfail;
-   struct args_setpipefd   setpipefd;
-   struct args_timeout timeout;
-   struct args_requester   requester;
-   struct args_expire  expire;
-   struct args_askumount   askumount;
-   struct args_ismountpointismountpoint;
-   };
-
-   char path[0];
-};
-
-static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in)
-{
-   memset(in, 0, sizeof(struct autofs_dev_ioctl));
-   in-ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR;
-   in-ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR;
-   in-size = sizeof(struct autofs_dev_ioctl);
-   in-ioctlfd = -1;
-   return;
-}
-
-/*
- * If you change this make sure you make the corresponding change
- * to autofs-dev-ioctl.c:lookup_ioctl()
- */
-enum {
-   /* Get various version info */
-   AUTOFS_DEV_IOCTL_VERSION_CMD = 0x71,
-   AUTOFS_DEV_IOCTL_PROTOVER_CMD,
-   AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD,
-
-   /* Open mount ioctl fd */
-   AUTOFS_DEV_IOCTL_OPENMOUNT_CMD,
-
-   /* Close mount ioctl fd */
-   AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD,
-
-   /* Mount/expire status returns */
-   AUTOFS_DEV_IOCTL_READY_CMD,
-   AUTOFS_DEV_IOCTL_FAIL_CMD,
-
-   /* Activate/deactivate autofs mount */
-   AUTOFS_DEV_IOCTL_SETPIPEFD_CMD,
-   AUTOFS_DEV_IOCTL_CATATONIC_CMD,
-
-   /* Expiry timeout */
-   AUTOFS_DEV_IOCTL_TIMEOUT_CMD,
-
-   /* Get mount last requesting uid and gid */
-   AUTOFS_DEV_IOCTL_REQUESTER_CMD,
-
-   /* Check for eligible expire candidates */
-   AUTOFS_DEV_IOCTL_EXPIRE_CMD,
-
-   /* Request busy status */
-   AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD,
-
-   /* Check if path is a mountpoint */
-   AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD,
-};
-
-#define 

[PATCH 01/10] autofs4 - coding style fixes

2013-08-31 Thread Ian Kent
Try and make the coding style completely consistent throughtout the
autofs module and inline with kernel coding style recommendations.

Signed-off-by: Ian Kent ra...@themaw.net
---
 fs/autofs4/autofs_i.h   |   30 +++---
 fs/autofs4/expire.c |   38 +++---
 fs/autofs4/init.c   |5 +
 fs/autofs4/inode.c  |5 +
 fs/autofs4/root.c   |   22 +++---
 fs/autofs4/symlink.c|5 +
 fs/autofs4/waitq.c  |   14 ++
 include/linux/auto_fs.h |5 +
 8 files changed, 55 insertions(+), 69 deletions(-)

diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 16d3288..76b8097 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -1,7 +1,4 @@
-/* -*- c -*- - *
- *   
- * linux/fs/autofs/autofs_i.h
- *
+/*
  *   Copyright 1997-1998 Transmeta Corporation - All Rights Reserved
  *   Copyright 2005-2006 Ian Kent ra...@themaw.net
  *
@@ -51,12 +48,14 @@
printk(KERN_ERR pid %d: %s:  fmt \n,\
current-pid, __func__, ##__VA_ARGS__)
 
-/* Unified info structure.  This is pointed to by both the dentry and
-   inode structures.  Each file in the filesystem has an instance of this
-   structure.  It holds a reference to the dentry, so dentries are never
-   flushed while the file exists.  All name lookups are dealt with at the
-   dentry level, although the filesystem can interfere in the validation
-   process.  Readdir is implemented by traversing the dentry lists. */
+/*
+ * Unified info structure.  This is pointed to by both the dentry and
+ * inode structures.  Each file in the filesystem has an instance of this
+ * structure.  It holds a reference to the dentry, so dentries are never
+ * flushed while the file exists.  All name lookups are dealt with at the
+ * dentry level, although the filesystem can interfere in the validation
+ * process.  Readdir is implemented by traversing the dentry lists.
+ */
 struct autofs_info {
struct dentry   *dentry;
struct inode*inode;
@@ -78,7 +77,7 @@ struct autofs_info {
kgid_t gid;
 };
 
-#define AUTOFS_INF_EXPIRING(10) /* dentry is in the process of expiring 
*/
+#define AUTOFS_INF_EXPIRING(10) /* dentry in the process of expiring */
 #define AUTOFS_INF_PENDING (12) /* dentry pending mount */
 
 struct autofs_wait_queue {
@@ -138,7 +137,8 @@ static inline struct autofs_info *autofs4_dentry_ino(struct 
dentry *dentry)
processes which do manipulations for us in user space sees the raw
filesystem without magic.) */
 
-static inline int autofs4_oz_mode(struct autofs_sb_info *sbi) {
+static inline int autofs4_oz_mode(struct autofs_sb_info *sbi)
+{
return sbi-catatonic || task_pgrp(current) == sbi-oz_pgrp;
 }
 
@@ -163,12 +163,12 @@ void autofs4_free_ino(struct autofs_info *);
 int is_autofs4_dentry(struct dentry *);
 int autofs4_expire_wait(struct dentry *dentry);
 int autofs4_expire_run(struct super_block *, struct vfsmount *,
-   struct autofs_sb_info *,
-   struct autofs_packet_expire __user *);
+  struct autofs_sb_info *,
+  struct autofs_packet_expire __user *);
 int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
struct autofs_sb_info *sbi, int when);
 int autofs4_expire_multi(struct super_block *, struct vfsmount *,
-   struct autofs_sb_info *, int __user *);
+struct autofs_sb_info *, int __user *);
 struct dentry *autofs4_expire_direct(struct super_block *sb,
 struct vfsmount *mnt,
 struct autofs_sb_info *sbi, int how);
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 3d9d3f5..21d2ad8 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -1,7 +1,4 @@
-/* -*- c -*- --- *
- *
- * linux/fs/autofs/expire.c
- *
+/*
  *  Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
  *  Copyright 1999-2000 Jeremy Fitzhardinge jer...@goop.org
  *  Copyright 2001-2006 Ian Kent ra...@themaw.net
@@ -18,7 +15,7 @@ static unsigned long now;
 
 /* Check if a dentry can be expired */
 static inline int autofs4_can_expire(struct dentry *dentry,
-   unsigned long timeout, int do_now)
+unsigned long timeout, int do_now)
 {
struct autofs_info *ino = autofs4_dentry_ino(dentry);
 
@@ -81,7 +78,7 @@ done:
  * Calculate and dget next entry in the subdirs list under root.
  */
 static struct dentry *get_next_positive_subdir(struct dentry *prev,
-   struct dentry *root)
+  struct dentry *root)
 {
struct autofs_sb_info *sbi = 

[PATCH 00/10] autofs4 - rename autofs4 to autofs

2013-08-31 Thread Ian Kent
The autofs4 kernel module provides function for autofs version 3, 4 and
5 and autofs module has long since been removed. Now we're left with a
misnamed module. Appart from the name another problem this presents is
that module autoload doesn't work because of the mismatch of the directory
name and the name of the file system provided by the module.

So autofs4 should be renamed to autofs but I've held back doing it because
of the potential disruption that could occur with a change like this.

The issues are somewhat reduced now because systemd needs the autofs
module at startup, and because of the autoload issue it's easier to just
compile the module into the kernel, which is what is often done.

Changes since the last posting of the series:
- removed the patches that updated the configs to use  CONFIG_AUTOFS_FS
  instead of CONFIG_AUTOFS4_FS, as recommended by Stephen Rothwell.
- Broke up large patches to meet list post size requirements.

By leaving a Kconfig and Makefile in fs/autofs4 (to build autofs4.ko)
with a deprication message sub-system maintainers and other users will
make any needed changes before these are removed after two kernel versions.
IMHO the presence of the warning is reason enough to leave a build stub
rather than do a straight out rename.

Any comments on the rename are welcome.

---

Ian Kent (10):
  autofs4 - coding style fixes
  autofs4 - fix string.h include in auto_dev-ioctl.h
  autofs4 - move linux/auto_dev-ioctl.h to uapi/linux
  autofs - merge auto_fs.h and auto_fs4.h
  autofs - use autofs instead of autofs4 everywhere
  autofs - copy autofs4 to autofs
  autofs - create autofs Kconfig and Makefile
  autofs - update fs/autofs4/Kconfig
  autofs - update fs/autofs4/Makefile
  autofs - delete fs/autofs4


 fs/Kconfig  |1 
 fs/Makefile |1 
 fs/autofs/Kconfig   |   19 +
 fs/autofs/Makefile  |7 
 fs/autofs/autofs_i.h|  341 +
 fs/autofs/dev-ioctl.c   |  759 ++
 fs/autofs/expire.c  |  561 ++
 fs/autofs/init.c|   49 ++
 fs/autofs/inode.c   |  368 ++
 fs/autofs/root.c|  898 +++
 fs/autofs/symlink.c |   21 +
 fs/autofs/waitq.c   |  570 ++
 fs/autofs4/Kconfig  |   30 +
 fs/autofs4/Makefile |4 
 fs/autofs4/autofs_i.h   |  341 -
 fs/autofs4/dev-ioctl.c  |  760 --
 fs/autofs4/expire.c |  562 --
 fs/autofs4/init.c   |   52 --
 fs/autofs4/inode.c  |  371 --
 fs/autofs4/root.c   |  898 ---
 fs/autofs4/symlink.c|   24 -
 fs/autofs4/waitq.c  |  572 --
 fs/compat_ioctl.c   |1 
 include/linux/auto_dev-ioctl.h  |  229 -
 include/linux/auto_fs.h |5 
 include/uapi/linux/auto_dev-ioctl.h |  224 +
 include/uapi/linux/auto_fs.h|  156 ++
 include/uapi/linux/auto_fs4.h   |  158 --
 28 files changed, 3991 insertions(+), 3991 deletions(-)
 create mode 100644 fs/autofs/Kconfig
 create mode 100644 fs/autofs/Makefile
 create mode 100644 fs/autofs/autofs_i.h
 create mode 100644 fs/autofs/dev-ioctl.c
 create mode 100644 fs/autofs/expire.c
 create mode 100644 fs/autofs/init.c
 create mode 100644 fs/autofs/inode.c
 create mode 100644 fs/autofs/root.c
 create mode 100644 fs/autofs/symlink.c
 create mode 100644 fs/autofs/waitq.c
 delete mode 100644 fs/autofs4/autofs_i.h
 delete mode 100644 fs/autofs4/dev-ioctl.c
 delete mode 100644 fs/autofs4/expire.c
 delete mode 100644 fs/autofs4/init.c
 delete mode 100644 fs/autofs4/inode.c
 delete mode 100644 fs/autofs4/root.c
 delete mode 100644 fs/autofs4/symlink.c
 delete mode 100644 fs/autofs4/waitq.c
 delete mode 100644 include/linux/auto_dev-ioctl.h
 create mode 100644 include/uapi/linux/auto_dev-ioctl.h

-- 
Ian
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/10] autofs4 - fix string.h include in auto_dev-ioctl.h

2013-08-31 Thread Ian Kent
Since including linux/string.h will now do the right thing remove the
conditional check.

Signed-off-by: Ian Kent ra...@themaw.net
---
 include/linux/auto_dev-ioctl.h |5 -
 1 file changed, 5 deletions(-)

diff --git a/include/linux/auto_dev-ioctl.h b/include/linux/auto_dev-ioctl.h
index 850f39b..fe4f373 100644
--- a/include/linux/auto_dev-ioctl.h
+++ b/include/linux/auto_dev-ioctl.h
@@ -11,12 +11,7 @@
 #define _LINUX_AUTO_DEV_IOCTL_H
 
 #include linux/auto_fs.h
-
-#ifdef __KERNEL__
 #include linux/string.h
-#else
-#include string.h
-#endif /* __KERNEL__ */
 
 #define AUTOFS_DEVICE_NAME autofs
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/10] autofs - merge auto_fs.h and auto_fs4.h

2013-08-31 Thread Ian Kent
The autofs module has long since been removed so there's no need to have
two separate include files for autofs.

Signed-off-by: Ian Kent ra...@themaw.net
---
 fs/autofs4/autofs_i.h |2 -
 fs/compat_ioctl.c |1 
 include/uapi/linux/auto_fs.h  |  156 +---
 include/uapi/linux/auto_fs4.h |  158 +
 4 files changed, 149 insertions(+), 168 deletions(-)

diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 76b8097..1a79bc7 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -10,7 +10,7 @@
 
 /* Internal header file for autofs */
 
-#include linux/auto_fs4.h
+#include linux/auto_fs.h
 #include linux/auto_dev-ioctl.h
 #include linux/mutex.h
 #include linux/spinlock.h
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 5d19acf..43345ce 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -38,7 +38,6 @@
 #include linux/if_pppox.h
 #include linux/mtio.h
 #include linux/auto_fs.h
-#include linux/auto_fs4.h
 #include linux/tty.h
 #include linux/vt_kern.h
 #include linux/fb.h
diff --git a/include/uapi/linux/auto_fs.h b/include/uapi/linux/auto_fs.h
index bb991df..fe7518d 100644
--- a/include/uapi/linux/auto_fs.h
+++ b/include/uapi/linux/auto_fs.h
@@ -1,8 +1,7 @@
-/* -*- linux-c -*- --- *
- *   
- * linux/include/linux/auto_fs.h
- *
- *   Copyright 1997 Transmeta Corporation - All Rights Reserved
+/*
+ * Copyright 1997 Transmeta Corporation - All Rights Reserved
+ * Copyright 1999-2000 Jeremy Fitzhardinge jer...@goop.org
+ * Copyright 2005-2006,2013 Ian Kent ra...@themaw.net
  *
  * This file is part of the Linux kernel and is made available under
  * the terms of the GNU General Public License, version 2, or at your
@@ -10,7 +9,6 @@
  *
  * --- */
 
-
 #ifndef _UAPI_LINUX_AUTO_FS_H
 #define _UAPI_LINUX_AUTO_FS_H
 
@@ -19,13 +17,11 @@
 #include sys/ioctl.h
 #endif /* __KERNEL__ */
 
+#define AUTOFS_PROTO_VERSION   5
+#define AUTOFS_MIN_PROTO_VERSION   3
+#define AUTOFS_MAX_PROTO_VERSION   5
 
-/* This file describes autofs v3 */
-#define AUTOFS_PROTO_VERSION   3
-
-/* Range of protocol versions defined */
-#define AUTOFS_MAX_PROTO_VERSION   AUTOFS_PROTO_VERSION
-#define AUTOFS_MIN_PROTO_VERSION   AUTOFS_PROTO_VERSION
+#define AUTOFS_PROTO_SUBVERSION2
 
 /*
  * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed
@@ -71,4 +67,140 @@ struct autofs_packet_expire {
 #define AUTOFS_IOC_SETTIMEOUT _IOWR(0x93,0x64,unsigned long)
 #define AUTOFS_IOC_EXPIRE _IOR(0x93,0x65,struct autofs_packet_expire)
 
+/* autofs version 4 and later definitions */
+
+/* Mask for expire behaviour */
+#define AUTOFS_EXP_IMMEDIATE   1
+#define AUTOFS_EXP_LEAVES  2
+
+#define AUTOFS_TYPE_ANY0U
+#define AUTOFS_TYPE_INDIRECT   1U
+#define AUTOFS_TYPE_DIRECT 2U
+#define AUTOFS_TYPE_OFFSET 4U
+
+static inline void set_autofs_type_indirect(unsigned int *type)
+{
+   *type = AUTOFS_TYPE_INDIRECT;
+   return;
+}
+
+static inline unsigned int autofs_type_indirect(unsigned int type)
+{
+   return (type == AUTOFS_TYPE_INDIRECT);
+}
+
+static inline void set_autofs_type_direct(unsigned int *type)
+{
+   *type = AUTOFS_TYPE_DIRECT;
+   return;
+}
+
+static inline unsigned int autofs_type_direct(unsigned int type)
+{
+   return (type == AUTOFS_TYPE_DIRECT);
+}
+
+static inline void set_autofs_type_offset(unsigned int *type)
+{
+   *type = AUTOFS_TYPE_OFFSET;
+   return;
+}
+
+static inline unsigned int autofs_type_offset(unsigned int type)
+{
+   return (type == AUTOFS_TYPE_OFFSET);
+}
+
+static inline unsigned int autofs_type_trigger(unsigned int type)
+{
+   return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET);
+}
+
+/*
+ * This isn't really a type as we use it to say no type set to
+ * indicate we want to search for any mount in the
+ * autofs_dev_ioctl_ismountpoint() device ioctl function.
+ */
+static inline void set_autofs_type_any(unsigned int *type)
+{
+   *type = AUTOFS_TYPE_ANY;
+   return;
+}
+
+static inline unsigned int autofs_type_any(unsigned int type)
+{
+   return (type == AUTOFS_TYPE_ANY);
+}
+
+/* Daemon notification packet types */
+enum autofs_notify {
+   NFY_NONE,
+   NFY_MOUNT,
+   NFY_EXPIRE
+};
+
+/* Kernel protocol version 4 packet types */
+
+/* Expire entry (umount request) */
+#define autofs_ptype_expire_multi  2
+
+/* Kernel protocol version 5 packet types */
+
+/* Indirect mount missing and expire requests. */
+#define autofs_ptype_missing_indirect  3
+#define autofs_ptype_expire_indirect   4
+
+/* Direct mount missing and expire requests */
+#define autofs_ptype_missing_direct5
+#define autofs_ptype_expire_direct 6
+
+/* v4 multi expire (via pipe) */

[PATCH 09/10] autofs - update fs/autofs4/Makefile

2013-08-31 Thread Ian Kent
Update Makefile to build from source in fs/autofs instead of
fs/autofs4.

Signed-off-by: Ian Kent ra...@themaw.net
---
 fs/autofs4/Makefile |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/autofs4/Makefile b/fs/autofs4/Makefile
index a811c1f..417dd72 100644
--- a/fs/autofs4/Makefile
+++ b/fs/autofs4/Makefile
@@ -4,4 +4,6 @@
 
 obj-$(CONFIG_AUTOFS4_FS) += autofs4.o
 
-autofs4-objs := init.o inode.o root.o symlink.o waitq.o expire.o dev-ioctl.o
+autofs4-objs := ../autofs/init.o ../autofs/inode.o ../autofs/root.o \
+   ../autofs/symlink.o ../autofs/waitq.o ../autofs/expire.o \
+   ../autofs/dev-ioctl.o

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/10] autofs - update fs/autofs4/Kconfig

2013-08-31 Thread Ian Kent
Update Kconfig and add a depricated warning.

Signed-off-by: Ian Kent ra...@themaw.net
---
 fs/autofs4/Kconfig |   30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/fs/autofs4/Kconfig b/fs/autofs4/Kconfig
index 1204d63..f74d317 100644
--- a/fs/autofs4/Kconfig
+++ b/fs/autofs4/Kconfig
@@ -1,5 +1,5 @@
 config AUTOFS4_FS
-   tristate Kernel automounter version 4 support (also supports v3)
+   tristate Kernel automounter support (supports v3, v4 and v5)
help
  The automounter is a tool to automatically mount remote file systems
  on demand. This implementation is partially kernel-based to reduce
@@ -7,14 +7,24 @@ config AUTOFS4_FS
  automounter (amd), which is a pure user space daemon.
 
  To use the automounter you need the user-space tools from
- ftp://ftp.kernel.org/pub/linux/daemons/autofs/v4/; you also
- want to answer Y to NFS file system support, below.
+ ftp://ftp.kernel.org/pub/linux/daemons/autofs/; you also want
+ to answer Y to NFS file system support, below.
 
- To compile this support as a module, choose M here: the module will be
- called autofs4.  You will need to add alias autofs autofs4 to your
- modules configuration file.
+ This module is in the process of being renamed from autofs4 to autofs
+ since is now the only module that provides the autofs file system and
+ the module is not version 4 specific.
 
- If you are not a part of a fairly large, distributed network or
- don't have a laptop which needs to dynamically reconfigure to the
- local network, you probably do not need an automounter, and can say
- N here.
+ It is now built from the source located in fs/autofs and this 
directory
+ and the configuration entry will be removed two kernel version from 
the
+ inclusion of this change.
+
+ Changes that will need to be made should be limited to:
+ - source include statments should be changed from autofs_fs4.h to
+   autofs_fs.h since these two header file have been merged.
+ - user space scripts that manually load autofs4.ko should be changed
+   to load autofs.ko. Since the module directory name and the module
+   name itself are the same now there is no need to manually load
+   module.
+ - any alias autofs autofs4 will need to be removed.
+
+ Please configure AUTOFS_FS instead of AUTOFS4_FS from now on.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/10] autofs - create autofs Kconfig and Makefile

2013-08-31 Thread Ian Kent
Create Makefile and Kconfig for autofs module.

Signed-off-by: Ian Kent ra...@themaw.net
---
 fs/Kconfig |1 +
 fs/Makefile|1 +
 fs/autofs/Kconfig  |   19 +++
 fs/autofs/Makefile |7 +++
 4 files changed, 28 insertions(+)
 create mode 100644 fs/autofs/Kconfig
 create mode 100644 fs/autofs/Makefile

diff --git a/fs/Kconfig b/fs/Kconfig
index c229f82..5c071f3 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -65,6 +65,7 @@ source fs/notify/Kconfig
 
 source fs/quota/Kconfig
 
+source fs/autofs/Kconfig
 source fs/autofs4/Kconfig
 source fs/fuse/Kconfig
 
diff --git a/fs/Makefile b/fs/Makefile
index 1afa0e0..4bf173a 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -102,6 +102,7 @@ obj-$(CONFIG_AFFS_FS)   += affs/
 obj-$(CONFIG_ROMFS_FS) += romfs/
 obj-$(CONFIG_QNX4FS_FS)+= qnx4/
 obj-$(CONFIG_QNX6FS_FS)+= qnx6/
+obj-$(CONFIG_AUTOFS_FS)+= autofs/
 obj-$(CONFIG_AUTOFS4_FS)   += autofs4/
 obj-$(CONFIG_ADFS_FS)  += adfs/
 obj-$(CONFIG_FUSE_FS)  += fuse/
diff --git a/fs/autofs/Kconfig b/fs/autofs/Kconfig
new file mode 100644
index 000..17f77a6
--- /dev/null
+++ b/fs/autofs/Kconfig
@@ -0,0 +1,19 @@
+config AUTOFS_FS
+   tristate Kernel automounter support (supports v3, v4 and v5)
+   help
+  The automounter is a tool to automatically mount remote file systems
+  on demand. This implementation is partially kernel-based to reduce
+  overhead in the already-mounted case; this is unlike the BSD
+  automounter (amd), which is a pure user space daemon.
+
+  To use the automounter you need the user-space tools from
+  ftp://ftp.kernel.org/pub/linux/daemons/autofs/; you also want
+  to answer Y to NFS file system support, below.
+
+  To compile this support as a module, choose M here: the module will 
be
+  called autofs.
+
+  If you are not a part of a fairly large, distributed network or
+  don't have a laptop which needs to dynamically reconfigure to the
+  local network, you probably do not need an automounter, and can say
+  N here.
diff --git a/fs/autofs/Makefile b/fs/autofs/Makefile
new file mode 100644
index 000..43fedde
--- /dev/null
+++ b/fs/autofs/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the linux autofs-filesystem routines.
+#
+
+obj-$(CONFIG_AUTOFS_FS) += autofs.o
+
+autofs-objs := init.o inode.o root.o symlink.o waitq.o expire.o dev-ioctl.o

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] ARM: Dove: Add the audio device to the Cubox DT

2013-08-31 Thread Jean-Francois Moine
On Sat, 31 Aug 2013 12:24:31 +0100
Russell King - ARM Linux li...@arm.linux.org.uk wrote:

  According to the Dove specification, the audio controller works with
  the samples rates 44.1, 48 and 96 kHz, so, I don't see the usage of the
  external clock, except when using the two audio controllers with
  different sample rates.
[snip]
  But, BTW, as the kirkwood-i2 driver is written, this last case does not
  work: for 44.1, 48 and 96 kHz, the external clock is never used and
  there is only one DCO.  
 
 This doesn't make sense.  this last case - what case are you referring
 to?  there is only one DCO ?  Yes, there is only one DCO, what is its
 relevance to the statement you're making?  And yes, in mainline we
 currently use the DCO for the standard 44.1, 48 and 96kHz sample rates.
 That's fine.  Confused.

Sorry, it was clear in my head :)

The last case was when using the two audio controllers with different
sample rates (I should have added in the set [44.1, 48, 96 kHz]).
Then, with or without the availability of external clocks, both
controllers will set the unique DCO to two different rates.

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [-next] openvswitch BUILD_BUG_ON failed

2013-08-31 Thread Geert Uytterhoeven
On Fri, Aug 30, 2013 at 3:11 AM, Jesse Gross je...@nicira.com wrote:
 On Thu, Aug 29, 2013 at 3:10 PM, David Miller da...@davemloft.net wrote:
 From: Jesse Gross je...@nicira.com
 Date: Thu, 29 Aug 2013 14:42:22 -0700

 On Thu, Aug 29, 2013 at 2:21 PM, Geert Uytterhoeven
 ge...@linux-m68k.org wrote:
 However, I have some doubts about other alignment enforcements:

 __aligned(__alignof__(long)) makes the whole struct aligned to the
 alignment rule for long:
1. This is only 2 bytes on m68k, i.e. != sizeof(long).
2. This is 4 bytes on many 32-bit platforms, which may be less than the
   default alignment for __be64 (cfr. some members of struct
   ovs_key_ipv4_tunnel), so this may make those 64-bit members 
 unaligned.

 Do any of those 32-bit architectures actually care about alignment of
 64 bit values? On 32-bit x86, a long is 32 bits but the alignment
 requirement of __be64 is also 32 bit.

 All except x86-32 do, it is in fact the odd man out with respect to this
 issue.

 Thanks, good to know.

 Andy, do you want to modify your patch to just drop the alignment
 specification as Geert suggested (but definitely keep the new build
 assert that you added)? It's probably better to just send the patch to
 netdev (against net-next) as well since you'll likely get better
 comments there and we can fix this faster if you cut out the
 middleman.

Why do you want to keep the build asserts?
Is this in-memory structure also transfered as-is over the network?
If yes, you definitely want the padding.

Nevertheless, as the struct contains u32 and even __be64 members, the
size of the struct will always be a multiple of the alignment unit for
64-bit quantities (and thus also for long), as per the C standard.
Hence the check

BUILD_BUG_ON(sizeof(struct sw_flow_key) % __alignof__(long));

will only catch bad compiler bugs or people adding __packed to the struct.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] ARM: Dove: Add the audio device to the Cubox DT

2013-08-31 Thread Russell King - ARM Linux
On Sat, Aug 31, 2013 at 01:55:19PM +0200, Jean-Francois Moine wrote:
 The last case was when using the two audio controllers with different
 sample rates (I should have added in the set [44.1, 48, 96 kHz]).
 Then, with or without the availability of external clocks, both
 controllers will set the unique DCO to two different rates.

Ah, yes.  The documentation is rather confusing too.  In one part, it
does indeed say that there is only one DCO which is shared between the
two blocks.

However, each block has its own DCO register which allows it to be set
to a different frequency - maybe it accesses the same physical register.

In which case, it probably would be better that we use the external clock
for everything when it is available - Rabeeh's kernel already does that,
as does the kernel which I run on my Cubox.  I'll pull that patch over to
the series for mainline later today:

a402fa7 ASoC: kirkwood: prefer external clock over internal clock

(This is copy'n'pasted with gpm, so is white-space damaged).
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c 
b/sound/soc/kirkwood/kirkwood-i2s.c
index 1c8177b..92cd467 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -222,20 +222,20 @@ static void kirkwood_set_rate(struct snd_soc_dai *dai,
 {
uint32_t clks_ctrl;

-   if (rate == 44100 || rate == 48000 || rate == 96000) {
-   /* use internal dco for supported rates */
-   dev_dbg(dai-dev, %s: dco set rate = %lu\n,
-   __func__, rate);
-   kirkwood_set_dco(priv-io, rate);
-
-   clks_ctrl = KIRKWOOD_MCLK_SOURCE_DCO;
-   } else if (!IS_ERR(priv-extclk)) {
+   if (!IS_ERR(priv-extclk)) {
/* use optional external clk for other rates */
dev_dbg(dai-dev, %s: extclk set rate = %lu - %lu\n,
__func__, rate, 256 * rate);
clk_set_rate(priv-extclk, 256 * rate);

clks_ctrl = KIRKWOOD_MCLK_SOURCE_EXTCLK;
+   } else if (rate == 44100 || rate == 48000 || rate == 96000) {
+   /* use internal dco for supported rates */
+   dev_dbg(dai-dev, %s: dco set rate = %lu\n,
+   __func__, rate);
+   kirkwood_set_dco(priv-io, rate);
+
+   clks_ctrl = KIRKWOOD_MCLK_SOURCE_DCO;
}
writel(clks_ctrl, priv-io + KIRKWOOD_CLOCKS_CTRL);
 }

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5] Remove ASoC-level I/O functions from cq93vc

2013-08-31 Thread Mark Brown
This patch series removes the use of the ASoC-level read and write
functions from the cq93vc driver as part of a wider push to remove them
completely and just use regmap for all register I/O.  Since the driver
is essentially doing what regmap-mmio is doing this is done by adding a
MMIO regmap to the core device and using that.  This is compile tested
only, I don't have any hardware to run on.

Since I anticipate doing more cleanups over the CODEC drivers during the
next release cycle it'd be good to merge via ASoC, though there
shouldn't be any overlap with the first patch.

Mark Brown (5):
  mfd: davinci_voicecodec: Remove unused read and write functions
  mfd: davinci_voicecodec: Provide a regmap for register I/O
  ASoC: cq93vc: Use core I/O functions
  ASoC: cq93vc: Don't use control data for core driver data
  ASoC: cq93vc: Use regmap for I/O

 drivers/mfd/davinci_voicecodec.c   | 23 +++
 include/linux/mfd/davinci_voicecodec.h |  3 +++
 sound/soc/codecs/cq93vc.c  | 42 +++---
 3 files changed, 29 insertions(+), 39 deletions(-)



signature.asc
Description: Digital signature


Re: [PATCH] bcache: Fix a shrinker deadlock

2013-08-31 Thread Stefan Priebe

thanks applied to my local kernel git

Stefan

Am 30.08.2013 23:15, schrieb Kent Overstreet:

GFP_NOIO means we could be getting called recursively - mca_alloc() -
mca_data_alloc() - definitely can't use mutex_lock(bucket_lock) then.
Whoops.

Signed-off-by: Kent Overstreet k...@daterainc.com
---

On Thu, Aug 29, 2013 at 05:29:54PM -0700, kernel neophyte wrote:

We are evaluating to use bcache on our production systems where the
caching devices are insanely fast, in this scenario under a moderate load
of random 4k writes.. bcache fails miserably :-(

[ 3588.513638] bcache: bch_cached_dev_attach() Caching sda4 as bcache0
on set b082ce66-04c6-43d5-8207-ebf39840191d
[ 4442.163661] INFO: task kworker/0:0:4 blocked for more than 120 seconds.
[ 4442.163671] echo 0  /proc/sys/kernel/hung_task_timeout_secs
disables this message.
[ 4442.163678] kworker/0:0 D 81813d40 0 4  2 0x
[ 4442.163695] Workqueue: bcache bch_data_insert_keys
[ 4442.163699]  882fa6ac93c8 0046 882fa6ac93e8
0151
[ 4442.163705]  882fa6a84cb0 882fa6ac9fd8 882fa6ac9fd8
882fa6ac9fd8
[ 4442.163711]  882fa6ad6640 882fa6a84cb0 882fa6a84cb0
8822ca2c0d98
[ 4442.163716] Call Trace:
[ 4442.163729]  [816be299] schedule+0x29/0x70
[ 4442.163735]  [816be57e] schedule_preempt_disabled+0xe/0x10
[ 4442.163741]  [816bc862] __mutex_lock_slowpath+0x112/0x1b0
[ 4442.163746]  [816bc3da] mutex_lock+0x2a/0x50
[ 4442.163752]  [815112e5] bch_mca_shrink+0x1b5/0x2f0
[ 4442.163759]  [8117fc32] ? prune_super+0x162/0x1b0
[ 4442.163769]  [8112ebb4] shrink_slab+0x154/0x300
[ 4442.163776]  [81076828] ? resched_task+0x68/0x70
[ 4442.163782]  [81077165] ? check_preempt_curr+0x75/0xa0
[ 4442.163788]  [8113a379] ? fragmentation_index+0x19/0x70
[ 4442.163794]  [8113140f] do_try_to_free_pages+0x20f/0x4b0
[ 4442.163800]  [81131864] try_to_free_pages+0xe4/0x1a0
[ 4442.163810]  [81126e9c] __alloc_pages_nodemask+0x60c/0x9b0
[ 4442.163818]  [8116062a] alloc_pages_current+0xba/0x170
[ 4442.163824]  [8112240e] __get_free_pages+0xe/0x40
[ 4442.163829]  [8150ebb3] mca_data_alloc+0x73/0x1d0
[ 4442.163834]  [8150ee5a] mca_bucket_alloc+0x14a/0x1f0
[ 4442.163838]  [81511020] mca_alloc+0x360/0x470
[ 4442.163843]  [81511d1c] bch_btree_node_alloc+0x8c/0x1c0
[ 4442.163849]  [81513020] btree_split+0x110/0x5c0


Ohhh, that definitely isn't supposed to happen.

Wonder why I hadn't seen this before, looking at the backtrace it's
pretty obvious what's broken though - try this patch:

  drivers/md/bcache/btree.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 60908de..55e8666 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -617,7 +617,7 @@ static int bch_mca_shrink(struct shrinker *shrink, struct 
shrink_control *sc)
return mca_can_free(c) * c-btree_pages;

/* Return -1 if we can't do anything right now */
-   if (sc-gfp_mask  __GFP_WAIT)
+   if (sc-gfp_mask  __GFP_IO)
mutex_lock(c-bucket_lock);
else if (!mutex_trylock(c-bucket_lock))
return -1;


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] perf, x86: Report TSX transaction abort cost as weight v2

2013-08-31 Thread Andi Kleen
From: Andi Kleen a...@linux.intel.com

Use the existing weight reporting facility to report the transaction
abort cost, that is the number of cycles wasted in aborts.
Haswell reports this in the PEBS record.

This was in fact the original user for weight.

This is a very useful sort key to concentrate on the most
costly aborts and a good metric for TSX tuning.

v2: Add Peter's changes with minor modifications. More comments.
Signed-off-by: Andi Kleen a...@linux.intel.com
---
 arch/x86/kernel/cpu/perf_event_intel_ds.c | 55 +++
 1 file changed, 42 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c 
b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 3065c57..ede2e40 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -182,16 +182,29 @@ struct pebs_record_nhm {
  * Same as pebs_record_nhm, with two additional fields.
  */
 struct pebs_record_hsw {
-   struct pebs_record_nhm nhm;
-   /*
-* Real IP of the event. In the Intel documentation this
-* is called eventingrip.
-*/
-   u64 real_ip;
-   /*
-* TSX tuning information field: abort cycles and abort flags.
-*/
-   u64 tsx_tuning;
+   u64 flags, ip;
+   u64 ax, bx, cx, dx;
+   u64 si, di, bp, sp;
+   u64 r8,  r9,  r10, r11;
+   u64 r12, r13, r14, r15;
+   u64 status, dla, dse, lat;
+   u64 real_ip; /* the actual eventing ip */
+   u64 tsx_tuning; /* TSX abort cycles and flags */
+};
+
+union hsw_tsx_tuning {
+   struct {
+   u32 cycles_last_block : 32,
+   hle_abort : 1,
+   rtm_abort : 1,
+   instruction_abort : 1,
+   non_instruction_abort : 1,
+   retry : 1,
+   data_conflict : 1,
+   capacity_writes   : 1,
+   capacity_reads: 1;
+   };
+   u64 value;
 };
 
 void init_debug_store_on_cpu(int cpu)
@@ -759,16 +772,26 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs)
return 0;
 }
 
+static inline u64 intel_hsw_weight(struct pebs_record_hsw *pebs)
+{
+   if (pebs-tsx_tuning) {
+   union hsw_tsx_tuning tsx = { .value = pebs-tsx_tuning };
+   return tsx.cycles_last_block;
+   }
+   return 0;
+}
+
 static void __intel_pmu_pebs_event(struct perf_event *event,
   struct pt_regs *iregs, void *__pebs)
 {
/*
 * We cast to pebs_record_nhm to get the load latency data
 * if extra_reg MSR_PEBS_LD_LAT_THRESHOLD used
+* We cast to the biggest PEBS record are careful not
+* to access out-of-bounds members.
 */
struct cpu_hw_events *cpuc = __get_cpu_var(cpu_hw_events);
-   struct pebs_record_nhm *pebs = __pebs;
-   struct pebs_record_hsw *pebs_hsw = __pebs;
+   struct pebs_record_hsw *pebs= __pebs;
struct perf_sample_data data;
struct pt_regs regs;
u64 sample_type;
@@ -827,7 +850,7 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
regs.sp = pebs-sp;
 
if (event-attr.precise_ip  1  x86_pmu.intel_cap.pebs_format = 2) {
-   regs.ip = pebs_hsw-real_ip;
+   regs.ip = pebs-real_ip;
regs.flags |= PERF_EFLAGS_EXACT;
} else if (event-attr.precise_ip  1  intel_pmu_pebs_fixup_ip(regs))
regs.flags |= PERF_EFLAGS_EXACT;
@@ -838,6 +861,12 @@ static void __intel_pmu_pebs_event(struct perf_event 
*event,
x86_pmu.intel_cap.pebs_format = 1)
data.addr = pebs-dla;
 
+   /* Only set the TSX weight when no memory weight was requested. */
+   if ((event-attr.sample_type  PERF_SAMPLE_WEIGHT) 
+   !fll 
+   (x86_pmu.intel_cap.pebs_format = 2))
+   data.weight = intel_hsw_weight(pebs);
+
if (has_branch_stack(event))
data.br_stack = cpuc-lbr_stack;
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] perf, x86: Avoid checkpointed counters causing excessive TSX aborts v5

2013-08-31 Thread Andi Kleen
From: Andi Kleen a...@linux.intel.com

With checkpointed counters there can be a situation where the counter
is overflowing, aborts the transaction, is set back to a non overflowing
checkpoint, causes interupt. The interrupt doesn't see the overflow
because it has been checkpointed.  This is then a spurious PMI, typically with
a ugly NMI message.  It can also lead to excessive aborts.

Avoid this problem by:
- Using the full counter width for counting counters (earlier patch)
- Forbid sampling for checkpointed counters. It's not too useful anyways,
checkpointing is mainly for counting. The check is approximate
(to still handle KVM), but should catch the majority of cases.
- On a PMI always set back checkpointed counters to zero.

v2: Add unlikely. Add comment
v3: Allow large sampling periods with CP for KVM
v4: Use event_is_checkpointed. Use EOPNOTSUPP. (Stephane Eranian)
v5: Remove comment.
Signed-off-by: Andi Kleen a...@linux.intel.com
---
 arch/x86/kernel/cpu/perf_event_intel.c | 37 ++
 1 file changed, 37 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel.c 
b/arch/x86/kernel/cpu/perf_event_intel.c
index a45d8d4..91e3f8c 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1134,6 +1134,11 @@ static void intel_pmu_enable_event(struct perf_event 
*event)
__x86_pmu_enable_event(hwc, ARCH_PERFMON_EVENTSEL_ENABLE);
 }
 
+static inline bool event_is_checkpointed(struct perf_event *event)
+{
+   return (event-hw.config  HSW_IN_TX_CHECKPOINTED) != 0;
+}
+
 /*
  * Save and restart an expired event. Called by NMI contexts,
  * so it has to be careful about preempting normal event ops:
@@ -1141,6 +1146,17 @@ static void intel_pmu_enable_event(struct perf_event 
*event)
 int intel_pmu_save_and_restart(struct perf_event *event)
 {
x86_perf_event_update(event);
+   /*
+* For a checkpointed counter always reset back to 0.  This
+* avoids a situation where the counter overflows, aborts the
+* transaction and is then set back to shortly before the
+* overflow, and overflows and aborts again.
+*/
+   if (unlikely(event_is_checkpointed(event))) {
+   /* No race with NMIs because the counter should not be armed */
+   wrmsrl(event-hw.event_base, 0);
+   local64_set(event-hw.prev_count, 0);
+   }
return x86_perf_event_set_period(event);
 }
 
@@ -1224,6 +1240,13 @@ again:
x86_pmu.drain_pebs(regs);
}
 
+   /*
+* To avoid spurious interrupts with perf stat always reset checkpointed
+* counters.
+*/
+   if (cpuc-events[2]  event_is_checkpointed(cpuc-events[2]))
+   status |= (1ULL  2);
+
for_each_set_bit(bit, (unsigned long *)status, X86_PMC_IDX_MAX) {
struct perf_event *event = cpuc-events[bit];
 
@@ -1689,6 +1712,20 @@ static int hsw_hw_config(struct perf_event *event)
  event-attr.precise_ip  0))
return -EOPNOTSUPP;
 
+   if (event_is_checkpointed(event)) {
+   /*
+* Sampling of checkpointed events can cause situations where
+* the CPU constantly aborts because of a overflow, which is
+* then checkpointed back and ignored. Forbid checkpointing
+* for sampling.
+*
+* But still allow a long sampling period, so that perf stat
+* from KVM works.
+*/
+   if (event-attr.sample_period  0 
+   event-attr.sample_period  0x7fff)
+   return -EOPNOTSUPP;
+   }
return 0;
 }
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] perf, x86: Add Haswell TSX event aliases v6

2013-08-31 Thread Andi Kleen
From: Andi Kleen a...@linux.intel.com

Add TSX event aliases, and export them from the kernel to perf.

These are used by perf stat -T and to allow
more user friendly access to events. The events are designed to
be fairly generic and may also apply to other architectures
implementing HTM.  They all cover common situations that
happens during tuning of transactional code.

For Haswell we have to separate the HLE and RTM events,
as they are separate in the PMU.

This adds the following events.

tx-startCount start transaction (used by perf stat -T)
tx-commit   Count commit of transaction
tx-abortCount all aborts
tx-conflict Count aborts due to conflict with another CPU.
tx-capacity Count capacity aborts (transaction too large)

Then matching el-* events for HLE

cycles-tTransactional cycles (used by perf stat -T)
* also exists on POWER8
cycles-ct   Transactional cycles commited (used by perf stat -T)
* according to Michael Ellerman POWER8 has a cycles-transactional-committed,
* perf stat -T handles both cases

Note for useful abort profiling often precise has to be set,
as Haswell can only report the point inside the transaction
with precise=2.

(I had another patchkit to allow exporting precise too, but Vince
Weaver pointed out it violates the ABI, so dropped now)

For some classes of aborts, like conflicts, this is not needed,
as it makes more sense to look at the complete critical section.

This gives a clean set of generalized events to examine transaction
success and aborts. Haswell has additional events for TSX, but those are more
specialized for very specific situations.

v2: Move to new sysfs infrastructure
v3: Use own sysfs functions now
v4: Add tx/el-abort-return for better conflict sampling
v5: Different white space.
v6: Cut down events, rewrite description.
Signed-off-by: Andi Kleen a...@linux.intel.com
---
 arch/x86/kernel/cpu/perf_event_intel.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel.c 
b/arch/x86/kernel/cpu/perf_event_intel.c
index 91e3f8c..da58663 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -2074,7 +2074,34 @@ static __init void intel_nehalem_quirk(void)
 EVENT_ATTR_STR(mem-loads,  mem_ld_hsw, event=0xcd,umask=0x1,ldlat=3);
 EVENT_ATTR_STR(mem-stores, mem_st_hsw, event=0xd0,umask=0x82)
 
+/* Haswell special events */
+EVENT_ATTR_STR(tx-start,tx_start,   event=0xc9,umask=0x1);
+EVENT_ATTR_STR(tx-commit,   tx_commit,  event=0xc9,umask=0x2);
+EVENT_ATTR_STR(tx-abort,tx_abort,  event=0xc9,umask=0x4);
+EVENT_ATTR_STR(tx-capacity, tx_capacity,   event=0x54,umask=0x2);
+EVENT_ATTR_STR(tx-conflict, tx_conflict,   event=0x54,umask=0x1);
+EVENT_ATTR_STR(el-start,el_start,   event=0xc8,umask=0x1);
+EVENT_ATTR_STR(el-commit,   el_commit,  event=0xc8,umask=0x2);
+EVENT_ATTR_STR(el-abort,el_abort,  event=0xc8,umask=0x4);
+EVENT_ATTR_STR(el-capacity, el_capacity,event=0x54,umask=0x2);
+EVENT_ATTR_STR(el-conflict, el_conflict,event=0x54,umask=0x1);
+EVENT_ATTR_STR(cycles-t,cycles_t,   event=0x3c,in_tx=1);
+EVENT_ATTR_STR(cycles-ct,   cycles_ct,
+   event=0x3c,in_tx=1,in_tx_cp=1);
+
 static struct attribute *hsw_events_attrs[] = {
+   EVENT_PTR(tx_start),
+   EVENT_PTR(tx_commit),
+   EVENT_PTR(tx_abort),
+   EVENT_PTR(tx_capacity),
+   EVENT_PTR(tx_conflict),
+   EVENT_PTR(el_start),
+   EVENT_PTR(el_commit),
+   EVENT_PTR(el_abort),
+   EVENT_PTR(el_capacity),
+   EVENT_PTR(el_conflict),
+   EVENT_PTR(cycles_t),
+   EVENT_PTR(cycles_ct),
EVENT_PTR(mem_ld_hsw),
EVENT_PTR(mem_st_hsw),
NULL
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


perf, x86: Add parts of the remaining haswell PMU functionality v4

2013-08-31 Thread Andi Kleen
[v2: Added Peter's changes to the PEBS handler]
[v3: Addressed Arnaldo's feedback for the perf stat -T change
 and avoid conflict]
[v4: Remove XXX comment in checkpoint patch.
 Add Arnaldo's ack for tools patch]

Add some more TSX functionality to the basic Haswell PMU.

A lot of the infrastructure needed for these patches has
been merged earlier, so it is all quite straight forward
now.

- Add the checkpointed counter workaround.
(Parts of this have been already merged earlier)
- Add support for reporting PEBS transaction abort cost as weight.
This is useful to judge the cost of aborts and concentrate
on expensive ones first.
(Large parts of this have been already merged earlier,
this is just adding the final few lines to the PEBS handler)
- Add TSX event aliases, needed for perf stat -T and general
usability.
(Infrastructure also already in)
- Add perf stat -T support to give a user friendly highlevel
counting frontend for transaction..
This version should also be usable for POWER8 eventually.

Not included:

Support for transaction flags and TSX LBR flags.

-Andi
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] perf, tools: Add perf stat --transaction v5

2013-08-31 Thread Andi Kleen
From: Andi Kleen a...@linux.intel.com

Add support to perf stat to print the basic transactional execution statistics:
Total cycles, Cycles in Transaction, Cycles in aborted transsactions
using the in_tx and in_tx_checkpoint qualifiers.
Transaction Starts and Elision Starts, to compute the average transaction
length.

This is a reasonable overview over the success of the transactions.

Also support architectures that have a transaction aborted cycles
counter like POWER8. Since that is awkward to handle in the kernel
abstract handle both cases here.

Enable with a new --transaction / -T option.

This requires measuring these events in a group, since they depend on each
other.

This is implemented by using TM sysfs events exported by the kernel

v2: Only print the extended statistics when the option is enabled.
This avoids negative output when the user specifies the -T events
in separate groups.
v3: Port to latest tree
v4: Remove merge error. Avoid linear walks for comparisons. Check
transaction_run earlier. Minor fixes.
v5: Move option to avoid conflict. Improve description.
Acked-by: Arnaldo Carvalho de Melo a...@redhat.com
Signed-off-by: Andi Kleen a...@linux.intel.com
---
 tools/perf/Documentation/perf-stat.txt |   5 ++
 tools/perf/builtin-stat.c  | 144 -
 tools/perf/util/evsel.h|   6 ++
 tools/perf/util/pmu.c  |  16 
 tools/perf/util/pmu.h  |   1 +
 5 files changed, 171 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-stat.txt 
b/tools/perf/Documentation/perf-stat.txt
index 2fe87fb..40bc65a 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -132,6 +132,11 @@ is a useful mode to detect imbalance between physical 
cores.  To enable this mod
 use --per-core in addition to -a. (system-wide).  The output includes the
 core number and the number of online logical processors on that physical 
processor.
 
+-T::
+--transaction::
+
+Print statistics of transactional execution if supported.
+
 EXAMPLES
 
 
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 352fbd7..6bd90e4 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -46,6 +46,7 @@
 #include util/util.h
 #include util/parse-options.h
 #include util/parse-events.h
+#include util/pmu.h
 #include util/event.h
 #include util/evlist.h
 #include util/evsel.h
@@ -70,6 +71,41 @@ static void print_counter_aggr(struct perf_evsel *counter, 
char *prefix);
 static void print_counter(struct perf_evsel *counter, char *prefix);
 static void print_aggr(char *prefix);
 
+/* Default events used for perf stat -T */
+static const char * const transaction_attrs[] = {
+   task-clock,
+   {
+   instructions,
+   cycles,
+   cpu/cycles-t/,
+   cpu/tx-start/,
+   cpu/el-start/,
+   cpu/cycles-ct/
+   }
+};
+
+/* More limited version when the CPU does not have all events. */
+static const char * const transaction_limited_attrs[] = {
+   task-clock,
+   {
+   instructions,
+   cycles,
+   cpu/cycles-t/,
+   cpu/tx-start/
+   }
+};
+
+/* must match transaction_attrs and the beginning limited_attrs */
+enum {
+   T_TASK_CLOCK,
+   T_INSTRUCTIONS,
+   T_CYCLES,
+   T_CYCLES_IN_TX,
+   T_TRANSACTION_START,
+   T_ELISION_START,
+   T_CYCLES_IN_TX_CP,
+};
+
 static struct perf_evlist  *evsel_list;
 
 static struct perf_target  target = {
@@ -90,6 +126,7 @@ static enum aggr_modeaggr_mode   
= AGGR_GLOBAL;
 static volatile pid_t  child_pid   = -1;
 static boolnull_run=  false;
 static int detailed_run=  0;
+static booltransaction_run;
 static boolbig_num =  true;
 static int big_num_opt =  -1;
 static const char  *csv_sep= NULL;
@@ -213,7 +250,10 @@ static struct stats runtime_l1_icache_stats[MAX_NR_CPUS];
 static struct stats runtime_ll_cache_stats[MAX_NR_CPUS];
 static struct stats runtime_itlb_cache_stats[MAX_NR_CPUS];
 static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS];
+static struct stats runtime_cycles_in_tx_stats[MAX_NR_CPUS];
 static struct stats walltime_nsecs_stats;
+static struct stats runtime_transaction_stats[MAX_NR_CPUS];
+static struct stats runtime_elision_stats[MAX_NR_CPUS];
 
 static void perf_stat__reset_stats(struct perf_evlist *evlist)
 {
@@ -235,6 +275,11 @@ static void perf_stat__reset_stats(struct perf_evlist 
*evlist)
memset(runtime_ll_cache_stats, 0, sizeof(runtime_ll_cache_stats));
memset(runtime_itlb_cache_stats, 0, sizeof(runtime_itlb_cache_stats));
memset(runtime_dtlb_cache_stats, 0, sizeof(runtime_dtlb_cache_stats));
+   

Re: [PATCH linux-next] Prevent a coredump with a large vm_map_count from Oopsing

2013-08-31 Thread Martin MOKREJŠ
Hi Dan,
  thank you for your work on my issue. I would like to test it on 3.10.9 where
I faced the problem initially.

linux-3.10.9 # patch -p1  ../patches/vm_map_count.patch
patching file fs/binfmt_elf.c
Hunk #1 succeeded at 1415 (offset -14 lines).
Hunk #2 succeeded at 1430 (offset -14 lines).
Hunk #3 succeeded at 1487 (offset -14 lines).
Hunk #4 succeeded at 1609 (offset -14 lines).
Hunk #5 succeeded at 1689 (offset -14 lines).
Hunk #6 FAILED at 1737.
Hunk #7 succeeded at 1810 (offset -14 lines).
Hunk #8 succeeded at 1854 (offset -14 lines).
Hunk #9 succeeded at 1902 (offset -14 lines).
Hunk #10 succeeded at 1970 (offset -14 lines).
Hunk #11 FAILED at 2068.
2 out of 11 hunks FAILED -- saving rejects to file fs/binfmt_elf.c.rej
#


Thank you.

Dan Aloni wrote:
 A high setting of max_map_count, and a process core-dumping with
 a large enough vm_map_count could result in an NT_FILE note not
 being written, and the kernel crashing immediately later because
 it has assumed otherwise.
 
 Reproduction of the bug described here:
 
 https://lkml.org/lkml/2013/8/30/50
 
 Issue originating in 2aa362c49 (from Oct 4, 2012).
 
 This patch make that section optional in that case.
 fill_files_note() should signify the error, and also let the info
 struct in elf_core_dump() be zero-initialized so that we can check
 for the optionally written note.
 
 Cc'ed original signers.
 
 Cc'ed Al Viro because it is trivially relies on his linux-next
 tree changes.
 
 Signed-off-by: Dan Aloni alo...@stratoscale.com
 Cc: Al Viro v...@zeniv.linux.org.uk
 Cc: Denys Vlasenko vda.li...@googlemail.com
 Cc: Andrew Morton a...@linux-foundation.org
 Cc: Linus Torvalds torva...@linux-foundation.org
 ---
  fs/binfmt_elf.c | 33 +
  1 file changed, 21 insertions(+), 12 deletions(-)
 
 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
 index dc82279..e1a323a 100644
 --- a/fs/binfmt_elf.c
 +++ b/fs/binfmt_elf.c
 @@ -1429,7 +1429,7 @@ static void fill_siginfo_note(struct memelfnote *note, 
 user_siginfo_t *csigdata,
   *   long file_ofs
   * followed by COUNT filenames in ASCII: FILE1 NUL FILE2 NUL...
   */
 -static void fill_files_note(struct memelfnote *note)
 +static int fill_files_note(struct memelfnote *note)
  {
   struct vm_area_struct *vma;
   unsigned count, size, names_ofs, remaining, n;
 @@ -1444,11 +1444,11 @@ static void fill_files_note(struct memelfnote *note)
   names_ofs = (2 + 3 * count) * sizeof(data[0]);
   alloc:
   if (size = MAX_FILE_NOTE_SIZE) /* paranoia check */
 - goto err;
 + return -E2BIG;
   size = round_up(size, PAGE_SIZE);
   data = vmalloc(size);
   if (!data)
 - goto err;
 + return -ENOMEM;
  
   start_end_ofs = data + 2;
   name_base = name_curpos = ((char *)data) + names_ofs;
 @@ -1501,7 +1501,7 @@ static void fill_files_note(struct memelfnote *note)
  
   size = name_curpos - (char *)data;
   fill_note(note, CORE, NT_FILE, size, data);
 - err: ;
 + return 0;
  }
  
  #ifdef CORE_DUMP_USE_REGSET
 @@ -1623,6 +1623,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
   struct elf_prpsinfo *psinfo;
   struct core_thread *ct;
   unsigned int i;
 + int ret;
  
   info-size = 0;
   info-thread = NULL;
 @@ -1702,8 +1703,9 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
   fill_auxv_note(info-auxv, current-mm);
   info-size += notesize(info-auxv);
  
 - fill_files_note(info-files);
 - info-size += notesize(info-files);
 + ret = fill_files_note(info-files);
 + if (!ret)
 + info-size += notesize(info-files);
  
   return 1;
  }
 @@ -1735,7 +1737,7 @@ static int write_note_info(struct elf_note_info *info,
   return 0;
   if (first  !writenote(info-auxv, cprm))
   return 0;
 - if (first  !writenote(info-files, cprm))
 + if (first  info-files.data  !writenote(info-files, cprm))
   return 0;
  
   for (i = 1; i  info-thread_notes; ++i)
 @@ -1822,6 +1824,7 @@ static int elf_dump_thread_status(long signr, struct 
 elf_thread_status *t)
  
  struct elf_note_info {
   struct memelfnote *notes;
 + struct memelfnote *notes_files;
   struct elf_prstatus *prstatus;  /* NT_PRSTATUS */
   struct elf_prpsinfo *psinfo;/* NT_PRPSINFO */
   struct list_head thread_list;
 @@ -1865,6 +1868,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
 siginfo_t *siginfo, struct pt_regs *regs)
  {
   struct list_head *t;
 + int ret;
  
   if (!elf_note_info_init(info))
   return 0;
 @@ -1912,9 +1916,13 @@ static int fill_note_info(struct elfhdr *elf, int 
 phdrs,
  
   fill_siginfo_note(info-notes + 2, info-csigdata, siginfo);
   fill_auxv_note(info-notes + 3, current-mm);
 - fill_files_note(info-notes + 4);
 + info-numnote = 4;
  
 - 

Re: [PATCH linux-next] Prevent a coredump with a large vm_map_count from Oopsing

2013-08-31 Thread Dan Aloni
On Sat, Aug 31, 2013 at 03:38:33PM +0200, Martin MOKREJŠ wrote:
 Hi Dan,
   thank you for your work on my issue. I would like to test it on 3.10.9 where
 I faced the problem initially.

Sure, see the attached patch for 3.10.9.

-- 
Dan Aloni
From e323d3b4fdc1e61c3c39dfb3733d8b8c56f63b00 Mon Sep 17 00:00:00 2001
From: Dan Aloni alo...@stratoscale.com
Date: Sat, 31 Aug 2013 00:13:43 +0300
Subject: [PATCH 1/1] Prevent a coredump with a large max_map_count from
 Oopsing

A high setting of max_map_count, and a process core-dumping with
a large enough vm_map_count could result in a NT_FILE note not
being written, and the kernel crashing immediately later because
it has assumed otherwise.

Reproduction of the bug described here:

https://lkml.org/lkml/2013/8/30/50

This patch make that section optional in that case.
fill_files_note() should signify the error, and also let the info
struct in elf_core_dump() be zero-initialized so that we can check
for optionally written note.

Cc'ed original signers.

Signed-off-by: Dan Aloni alo...@stratoscale.com
Cc: Denys Vlasenko vda.li...@googlemail.com
Cc: Andrew Morton a...@linux-foundation.org
Cc: Linus Torvalds torva...@linux-foundation.org
---
 fs/binfmt_elf.c | 34 ++
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index f8a0b0e..1c4a425 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1415,7 +1415,7 @@ static void fill_siginfo_note(struct memelfnote *note, 
user_siginfo_t *csigdata,
  *   long file_ofs
  * followed by COUNT filenames in ASCII: FILE1 NUL FILE2 NUL...
  */
-static void fill_files_note(struct memelfnote *note)
+static int fill_files_note(struct memelfnote *note)
 {
struct vm_area_struct *vma;
unsigned count, size, names_ofs, remaining, n;
@@ -1430,11 +1430,11 @@ static void fill_files_note(struct memelfnote *note)
names_ofs = (2 + 3 * count) * sizeof(data[0]);
  alloc:
if (size = MAX_FILE_NOTE_SIZE) /* paranoia check */
-   goto err;
+   return -E2BIG;
size = round_up(size, PAGE_SIZE);
data = vmalloc(size);
if (!data)
-   goto err;
+   return -ENOMEM;
 
start_end_ofs = data + 2;
name_base = name_curpos = ((char *)data) + names_ofs;
@@ -1487,7 +1487,7 @@ static void fill_files_note(struct memelfnote *note)
 
size = name_curpos - (char *)data;
fill_note(note, CORE, NT_FILE, size, data);
- err: ;
+   return 0;
 }
 
 #ifdef CORE_DUMP_USE_REGSET
@@ -1609,6 +1609,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
struct elf_prpsinfo *psinfo;
struct core_thread *ct;
unsigned int i;
+   int ret;
 
info-size = 0;
info-thread = NULL;
@@ -1688,8 +1689,9 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
fill_auxv_note(info-auxv, current-mm);
info-size += notesize(info-auxv);
 
-   fill_files_note(info-files);
-   info-size += notesize(info-files);
+   ret = fill_files_note(info-files);
+   if (!ret)
+   info-size += notesize(info-files);
 
return 1;
 }
@@ -1721,7 +1723,8 @@ static int write_note_info(struct elf_note_info *info,
return 0;
if (first  !writenote(info-auxv, file, foffset))
return 0;
-   if (first  !writenote(info-files, file, foffset))
+   if (first  info-files.data  !writenote(info-files,
+   file, foffset))
return 0;
 
for (i = 1; i  info-thread_notes; ++i)
@@ -1808,6 +1811,7 @@ static int elf_dump_thread_status(long signr, struct 
elf_thread_status *t)
 
 struct elf_note_info {
struct memelfnote *notes;
+   struct memelfnote *notes_files;
struct elf_prstatus *prstatus;  /* NT_PRSTATUS */
struct elf_prpsinfo *psinfo;/* NT_PRPSINFO */
struct list_head thread_list;
@@ -1851,6 +1855,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
  siginfo_t *siginfo, struct pt_regs *regs)
 {
struct list_head *t;
+   int ret;
 
if (!elf_note_info_init(info))
return 0;
@@ -1898,9 +1903,13 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
 
fill_siginfo_note(info-notes + 2, info-csigdata, siginfo);
fill_auxv_note(info-notes + 3, current-mm);
-   fill_files_note(info-notes + 4);
+   info-numnote = 4;
 
-   info-numnote = 5;
+   ret = fill_files_note(info-notes + info-numnote);
+   if (!ret) {
+   info-notes_files = info-notes + info-numnote;
+   info-numnote++;
+   }
 
/* Try to dump the FPU. */
info-prstatus-pr_fpvalid = elf_core_copy_task_fpregs(current, regs,
@@ -1962,8 +1971,9 @@ static void free_note_info(struct elf_note_info *info)
  

[PATCH v2 2/9] cgroup: css iterations and css_from_dir() are safe under cgroup_mutex

2013-08-31 Thread Tejun Heo
Currently, all css iterations and css_from_dir() require RCU read lock
whether the caller is holding cgroup_mutex or not, which is
unnecessarily restrictive.  They are all safe to use under
cgroup_mutex without holding RCU read lock.

Factor out cgroup_assert_mutex_or_rcu_locked() from css_from_id() and
apply it to all css iteration functions and css_from_dir().

v2: cgroup_assert_mutex_or_rcu_locked() definition doesn't need to be
inside CONFIG_PROVE_RCU ifdef as rcu_lockdep_assert() is always
defined and conditionalized.  Move it outside of the ifdef block.

Signed-off-by: Tejun Heo t...@kernel.org
---
 kernel/cgroup.c |   56 ++--
 1 file changed, 30 insertions(+), 26 deletions(-)

--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -88,6 +88,11 @@ static DEFINE_MUTEX(cgroup_mutex);
 
 static DEFINE_MUTEX(cgroup_root_mutex);
 
+#define cgroup_assert_mutex_or_rcu_locked()\
+   rcu_lockdep_assert(rcu_read_lock_held() ||  \
+  lockdep_is_held(cgroup_mutex),  \
+  cgroup_mutex or RCU read lock required);
+
 /*
  * Generate an array of cgroup subsystem pointers. At boot time, this is
  * populated with the built in subsystems, and modular subsystems are
@@ -3036,9 +3041,9 @@ static void cgroup_enable_task_cg_lists(
  * @parent_css: css whose children to walk
  *
  * This function returns the next child of @parent_css and should be called
- * under RCU read lock.  The only requirement is that @parent_css and
- * @pos_css are accessible.  The next sibling is guaranteed to be returned
- * regardless of their states.
+ * under either cgroup_mutex or RCU read lock.  The only requirement is
+ * that @parent_css and @pos_css are accessible.  The next sibling is
+ * guaranteed to be returned regardless of their states.
  */
 struct cgroup_subsys_state *
 css_next_child(struct cgroup_subsys_state *pos_css,
@@ -3048,7 +3053,7 @@ css_next_child(struct cgroup_subsys_stat
struct cgroup *cgrp = parent_css-cgroup;
struct cgroup *next;
 
-   WARN_ON_ONCE(!rcu_read_lock_held());
+   cgroup_assert_mutex_or_rcu_locked();
 
/*
 * @pos could already have been removed.  Once a cgroup is removed,
@@ -3095,10 +3100,10 @@ EXPORT_SYMBOL_GPL(css_next_child);
  * to visit for pre-order traversal of @root's descendants.  @root is
  * included in the iteration and the first node to be visited.
  *
- * While this function requires RCU read locking, it doesn't require the
- * whole traversal to be contained in a single RCU critical section.  This
- * function will return the correct next descendant as long as both @pos
- * and @root are accessible and @pos is a descendant of @root.
+ * While this function requires cgroup_mutex or RCU read locking, it
+ * doesn't require the whole traversal to be contained in a single critical
+ * section.  This function will return the correct next descendant as long
+ * as both @pos and @root are accessible and @pos is a descendant of @root.
  */
 struct cgroup_subsys_state *
 css_next_descendant_pre(struct cgroup_subsys_state *pos,
@@ -3106,7 +3111,7 @@ css_next_descendant_pre(struct cgroup_su
 {
struct cgroup_subsys_state *next;
 
-   WARN_ON_ONCE(!rcu_read_lock_held());
+   cgroup_assert_mutex_or_rcu_locked();
 
/* if first iteration, visit @root */
if (!pos)
@@ -3137,17 +3142,17 @@ EXPORT_SYMBOL_GPL(css_next_descendant_pr
  * is returned.  This can be used during pre-order traversal to skip
  * subtree of @pos.
  *
- * While this function requires RCU read locking, it doesn't require the
- * whole traversal to be contained in a single RCU critical section.  This
- * function will return the correct rightmost descendant as long as @pos is
- * accessible.
+ * While this function requires cgroup_mutex or RCU read locking, it
+ * doesn't require the whole traversal to be contained in a single critical
+ * section.  This function will return the correct rightmost descendant as
+ * long as @pos is accessible.
  */
 struct cgroup_subsys_state *
 css_rightmost_descendant(struct cgroup_subsys_state *pos)
 {
struct cgroup_subsys_state *last, *tmp;
 
-   WARN_ON_ONCE(!rcu_read_lock_held());
+   cgroup_assert_mutex_or_rcu_locked();
 
do {
last = pos;
@@ -3183,10 +3188,11 @@ css_leftmost_descendant(struct cgroup_su
  * to visit for post-order traversal of @root's descendants.  @root is
  * included in the iteration and the last node to be visited.
  *
- * While this function requires RCU read locking, it doesn't require the
- * whole traversal to be contained in a single RCU critical section.  This
- * function will return the correct next descendant as long as both @pos
- * and @cgroup are accessible and @pos is a descendant of @cgroup.
+ * While this function requires cgroup_mutex or RCU read locking, it
+ * doesn't require the whole 

Re: [PATCH 0/7] Drop support for Renesys H8/300 architecture

2013-08-31 Thread Guenter Roeck

On 08/30/2013 11:44 PM, Geert Uytterhoeven wrote:

On Fri, Aug 30, 2013 at 9:37 PM, Guenter Roeck li...@roeck-us.net wrote:

On Fri, Aug 30, 2013 at 12:14:20PM -0700, Linus Torvalds wrote:

On Fri, Aug 30, 2013 at 12:11 PM, Guenter Roeck li...@roeck-us.net wrote:


I would not mind if Linus would agree to pull it right away for 3.12,
but that seems to be a bit on the fast side.


I'm ok with code deletion patches, I don't think that would be a
problem. I didn't check them, but I assume this is all literally just
removing code that is conditional on h8/300 config options?


Yes.

I found a couple more since I sent the series, but nothing significant.

What is your preference - keep it until 3.13, or prepare it now and send you
a pull request for 3.12 ?


It would be nice to check with Sato-san, who wanted to attend Kernel
Summit as a hobbyist architecture maintainer, and see what are his plans
and opinions.



Yes, of course. My bad that my send script dropped him of all people from the
original e-mail :(. I fixed that in version 2.

Guenter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 3/9] cgroup: make for_each_subsys() useable under cgroup_root_mutex

2013-08-31 Thread Tejun Heo
We want to use for_each_subsys() in cgroupfs_root handling where only
cgroup_root_mutex is held.  The only way cgroup_subsys[] can change is
through module load/unload, make cgroup_[un]load_subsys() grab
cgroup_root_mutex too and update the lockdep annotation in
for_each_subsys() to allow either cgroup_mutex or cgroup_root_mutex.

* Lockdep annotation is moved from inner 'if' condition to outer 'for'
  init caluse.  There's no reason to execute the assertion every loop.

* Loop index @i is renamed to @ssid.  Indices iterating through subsys
  will be [re]named to @ssid gradually.

v2: cgroup_assert_mutex_or_root_locked() caused build failure if
!CONFIG_LOCKEDP.  Conditionalize its definition.  The build failure
was reported by kbuild test bot.

Signed-off-by: Tejun Heo t...@kernel.org
Cc: kbuild test robot fengguang...@intel.com
---
 kernel/cgroup.c |   26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -93,6 +93,14 @@ static DEFINE_MUTEX(cgroup_root_mutex);
   lockdep_is_held(cgroup_mutex),  \
   cgroup_mutex or RCU read lock required);
 
+#ifdef CONFIG_LOCKDEP
+#define cgroup_assert_mutex_or_root_locked()   \
+   WARN_ON_ONCE(debug_locks  (!lockdep_is_held(cgroup_mutex)  \
+!lockdep_is_held(cgroup_root_mutex)))
+#else
+#define cgroup_assert_mutex_or_root_locked()   do { } while (0)
+#endif
+
 /*
  * Generate an array of cgroup subsystem pointers. At boot time, this is
  * populated with the built in subsystems, and modular subsystems are
@@ -291,14 +299,15 @@ static int notify_on_release(const struc
 /**
  * for_each_subsys - iterate all loaded cgroup subsystems
  * @ss: the iteration cursor
- * @i: the index of @ss, CGROUP_SUBSYS_COUNT after reaching the end
+ * @ssid: the index of @ss, CGROUP_SUBSYS_COUNT after reaching the end
  *
- * Should be called under cgroup_mutex.
+ * Iterates through all loaded subsystems.  Should be called under
+ * cgroup_mutex or cgroup_root_mutex.
  */
-#define for_each_subsys(ss, i) \
-   for ((i) = 0; (i)  CGROUP_SUBSYS_COUNT; (i)++) \
-   if (({ lockdep_assert_held(cgroup_mutex);  \
-  !((ss) = cgroup_subsys[i]); })) { }  \
+#define for_each_subsys(ss, ssid)  \
+   for (({ cgroup_assert_mutex_or_root_locked(); (ssid) = 0; });   \
+(ssid)  CGROUP_SUBSYS_COUNT; (ssid)++)\
+   if (!((ss) = cgroup_subsys[(ssid)])) { }\
else
 
 /**
@@ -4911,6 +4920,7 @@ int __init_or_module cgroup_load_subsys(
cgroup_init_cftsets(ss);
 
mutex_lock(cgroup_mutex);
+   mutex_lock(cgroup_root_mutex);
cgroup_subsys[ss-subsys_id] = ss;
 
/*
@@ -4966,10 +4976,12 @@ int __init_or_module cgroup_load_subsys(
goto err_unload;
 
/* success! */
+   mutex_unlock(cgroup_root_mutex);
mutex_unlock(cgroup_mutex);
return 0;
 
 err_unload:
+   mutex_unlock(cgroup_root_mutex);
mutex_unlock(cgroup_mutex);
/* @ss can't be mounted here as try_module_get() would fail */
cgroup_unload_subsys(ss);
@@ -4999,6 +5011,7 @@ void cgroup_unload_subsys(struct cgroup_
BUG_ON(ss-root != cgroup_dummy_root);
 
mutex_lock(cgroup_mutex);
+   mutex_lock(cgroup_root_mutex);
 
offline_css(cgroup_css(cgroup_dummy_top, ss));
 
@@ -5037,6 +5050,7 @@ void cgroup_unload_subsys(struct cgroup_
ss-css_free(cgroup_css(cgroup_dummy_top, ss));
RCU_INIT_POINTER(cgroup_dummy_top-subsys[ss-subsys_id], NULL);
 
+   mutex_unlock(cgroup_root_mutex);
mutex_unlock(cgroup_mutex);
 }
 EXPORT_SYMBOL_GPL(cgroup_unload_subsys);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [dm-devel] [RFC] dm-writeboost: plan to go to staging

2013-08-31 Thread Akira Hayakawa
Hi.

Progress report for staging dm-writeboost.

(1) Renaming to dm-writeboost
Thanks for comments on renaming.

By a simple democratic,
dm-lc will be renamed to dm-writeboost.
I am really happy with the new name.

(2) Idea for smelling limitation on the kind of backing store
Now I am tackling on the design issues.
As Alasdair pointed out
the statement below from my document really smells
and seems to be the first priority at this point.

  Be careful, you MUST create all the LVs as the destinations of
  the dirty blocks on the cache device before this operation.  Otherwise,
  the kernel may crash.

Aside from the two small requirements by Alasdair,
I may have to shoot out this problem before sending patch to staging tree.
 Two simple requirements before putting your proof-of-concept into staging
 if you want to work that way:
 
 1) Drop the major version number to 0.  Version 1 is reserved for
 supported modules.
 
 2) Agree a new and meaningful target name with us so you don't have to
 change it later.  lc means nothing, I'm afraid.

My investigation today revealed that this statement is too pessimistic.
The truth is only that
the backing store should not be some partition out of a disk,
say /dev/sdd1 out of /dev/sdd.

With the partition number,
my userland script works badly in attaching a device to a cache.
It failed to get the correct device name from sysfs.

I am thinking of addressing this problem by
adding new sysfs member to show device number(major:minor) of the backing store
which is likely to maintain backward-compatibility and
doing some modification on the Python scripts.

That's very easy.
I will do this before sending a patch for staging
aside said two requirements.

(3) Draft for TODO and MAINTAINERS files
These are the current drafts for TODO and MAINTAINERS files.
Please let me know if you find more to write or simple mistakes.

(3-1) TODO file
TODO:
- Get feedback from 3rd party users.
- Reviewed by Mike Snitzer.
- Audit userspace interfaces to make sure they are sane.
  Should use the same approach that is proven successful.
- Fix document.
  Should document the kernel interfaces
  rather than particular userspace tools.
- Add more comments inline
  to explain what it does and how it works.

Please send patches to Greg Kroah-Hartman gre...@linuxfoundation.org and Cc:
Akira Hayakawa ruby.w...@gmail.com

(3-2) part of MAINTAINERS file
M:  Greg Kroah-Hartman gre...@linuxfoundation.org
M:  Akira Hayakawa ruby.w...@gmail.com
S:  Maintained
L:  dm-de...@redhat.com
W:  https://github.com/akiradeveloper/dm-writeboost.git
F:  drivers/staging/dm-writeboost.git

(4) Next steps
- Fixed all source codes and documents as they are of
  dm-writeboost but not dm-lc.
- Github repo will be renamed.
- Complete the task said at (2).
- Generating a patch against linux-next
  and send it to Greg.

Thanks for your reading,
Akira
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] checkpatch: Add test for positional misuse of section specifiers like __initdata

2013-08-31 Thread Andi Kleen
 A similar patch was suggested by Andi Kleen
 https://lkml.org/lkml/2013/8/5/648

My patch checked for const - initdata / non const initconst  mistakes.

I don't think your patch does that?

-Andi
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [dm-devel] [RFC] dm-writeboost: plan to go to staging

2013-08-31 Thread Akira Hayakawa
Thanks, Alasdair.

I will reply to some of your comments
that is not answered up to now.

 The documentation file will eventually need rewriting to follow the same
 format as the other targets recently added to the kernel.  We document
 the kernel interface rather than any particular userspace tools, which
 just have the status of convenient examples.
dm-writeboost can be used by kicking kernel interfaces but
it is not recommended.
My userspace tools take care of all the
implications in using the kernel interfaces.
The fact dm-writeboost supports shared-caching and
write-back caching with auto-modulated migration
puts the interfaces and implementations under some constraints.
That's simply a tradeoff.

OK, I will document the kernel interfaces
and also mention the userspace tools.

 (Your code also needs many more comments inline to explain what it does
 and how it works.)
Comments are substantially noise is my philosophy.
I will add comments with given feedback clearly mentioning
what is clear and what is not clear about the source code.
Even in that case,
I'd better polish the code rather than write comments.

 Another little thing I noticed: look into using something like
 __dm_bless_for_disk() for your metadata and clearly segregate your
 on-disk structures and document the layout.
I couldn't understand what is __dm_bless_for_disk() for.
What does the word bless mean in this context?

By the way,
dm-cache and dm-writeboost are definitely different in a way that
dm-cache has an another disk for metadata while dm-writeboost doesn't.
dm-writeboost packs metadata and data within a log and
submit it to the cache device like log-structured filesystem.

So, the annotation checks can not be appropriated
to apply to dm-writeboost.

And what about moving these macros to
include/linux/device-mapper.h?

Akira

On 8/29/13 12:30 PM, Alasdair G Kergon wrote:
 On Wed, Aug 28, 2013 at 07:05:55PM -0700, Greg KH wrote:
 For staging drivers, I need a TODO file that lists
 what needs to be done to the code to get it into a mergable state for
 the real part of the kernel,
 
 Two simple requirements before putting your proof-of-concept into staging
 if you want to work that way:
 
 1) Drop the major version number to 0.  Version 1 is reserved for
 supported modules.
 
 2) Agree a new and meaningful target name with us so you don't have to
 change it later.  lc means nothing, I'm afraid.
 
 Then in general terms, you should continue to compare your device-mapper
 target with the existing targets and where there are differences, either
 change your target to be like something that already exists, or be ready
 to explain why that can't or shouldn't be done.
 
 In particular, the interface and architecture will need substantial
 changes and working these out should be your highest priority.
 
 For example, you write:
 
   Be careful, you MUST create all the LVs as the destinations of
   the dirty blocks on the cache device before this operation.  Otherwise,
   the kernel may crash.
 
 I read a statement like that as an indication of an interface or
 architectural problem.  The device-mapper approach is to 'design out'
 problems, rather than relying on users not doing bad things.
 Study the existing interfaces used by other targets to understand
 some approaches that proved successful, then decide which ones
 come closest to your needs.
 
 (Your code also needs many more comments inline to explain what it does
 and how it works.)
 
 The documentation file will eventually need rewriting to follow the same
 format as the other targets recently added to the kernel.  We document
 the kernel interface rather than any particular userspace tools, which
 just have the status of convenient examples.
 
 Another little thing I noticed: look into using something like
 __dm_bless_for_disk() for your metadata and clearly segregate your
 on-disk structures and document the layout.
 
 Alasdair
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Crashes on 3.0.11-rc7: nouveau?

2013-08-31 Thread ael

Aug 31 11:31:53 conquest2 kernel: [ cut here ]
Aug 31 11:31:53 conquest2 kernel: WARNING: CPU: 0 PID: 4566 at 
drivers/gpu/drm/nouveau/nouveau_bo.c:151 nouveau_bo_del_ttm+0x62/0x70 
[nouveau]()
Aug 31 11:31:53 conquest2 kernel: Modules linked in: snd_hrtimer 
cpufreq_userspace cpufreq_stats cpufreq_powersave lp hwmon_vid nfsd 
auth_rpcgss oid_registry exportfs nfs_acl nfs lockd sunrpc ipv6 analog 
joydev dm_crypt dm_mod nouveau snd_intel8x0 snd_ac97_codec ac97_bus 
video snd_pcm_oss snd_mixer_oss backlight snd_pcm mxm_wmi snd_page_alloc 
snd_seq_dummy snd_mpu401 snd_mpu401_uart snd_seq_oss wmi snd_seq_midi 
ttm snd_rawmidi snd_seq_midi_event snd_seq fbcon bitblit snd_seq_device 
softcursor font snd_timer drm_kms_helper snd drm sg k8temp forcedeth 
ns558 sr_mod cdrom hwmon psmouse serio_raw pcspkr gameport i2c_algo_bit 
evdev ohci_pci ohci_hcd ehci_pci ehci_hcd soundcore parport_pc parport 
i2c_nforce2 i2c_core floppy thermal processor button unix
Aug 31 11:31:53 conquest2 kernel: CPU: 0 PID: 4566 Comm: Xorg Not 
tainted 3.11.0-rc4_c2+ #99
Aug 31 11:31:53 conquest2 kernel: Hardware name: System manufacturer 
System name/A8N-SLI DELUXE, BIOS ASUS A8N-SLI DELUXE ACPI BIOS Revision 
1805 09/29/2006
Aug 31 11:31:53 conquest2 kernel: 0009 88007cad3c48 
81384a50 88007cad3c80
Aug 31 11:31:53 conquest2 kernel: 8105d2ab 880036c10c00 
a480 88007c908158
Aug 31 11:31:53 conquest2 kernel: 880036c10c00 880036c10c00 
88007cad3c90 8105d2f5

Aug 31 11:31:53 conquest2 kernel: Call Trace:
Aug 31 11:31:53 conquest2 kernel: [81384a50] dump_stack+0x19/0x1b
Aug 31 11:31:53 conquest2 kernel: [8105d2ab] 
warn_slowpath_common+0x7b/0xb0
Aug 31 11:31:53 conquest2 kernel: [8105d2f5] 
warn_slowpath_null+0x15/0x20
Aug 31 11:31:53 conquest2 kernel: [a03567d2] 
nouveau_bo_del_ttm+0x62/0x70 [nouveau]
Aug 31 11:31:53 conquest2 kernel: [a0238668] 
ttm_bo_release_list+0x98/0xe0 [ttm]
Aug 31 11:31:53 conquest2 kernel: [a023924d] 
ttm_bo_release+0x16d/0x200 [ttm]
Aug 31 11:31:53 conquest2 kernel: [a0239309] 
ttm_bo_unref+0x29/0x30 [ttm]
Aug 31 11:31:53 conquest2 kernel: [a03591e6] 
nouveau_gem_object_del+0x46/0x60 [nouveau]
Aug 31 11:31:53 conquest2 kernel: [a0133394] 
drm_gem_object_free+0x24/0x30 [drm]
Aug 31 11:31:53 conquest2 kernel: [a0133750] 
drm_gem_object_release_handle+0xb0/0xc0 [drm]
Aug 31 11:31:53 conquest2 kernel: [811e4c8f] 
idr_for_each+0xaf/0x100
Aug 31 11:31:53 conquest2 kernel: [a01336a0] ? 
drm_gem_handle_create+0xe0/0xe0 [drm]

Aug 31 11:31:53 conquest2 kernel: [81385f2d] ? mutex_lock+0xd/0x20
Aug 31 11:31:53 conquest2 kernel: [a0133c1b] 
drm_gem_release+0x1b/0x30 [drm]
Aug 31 11:31:53 conquest2 kernel: [a0132499] 
drm_release+0x589/0x600 [drm]

Aug 31 11:31:53 conquest2 kernel: [810eafcf] __fput+0xaf/0x230
Aug 31 11:31:53 conquest2 kernel: [810eb189] fput+0x9/0x10
Aug 31 11:31:53 conquest2 kernel: [810735c5] 
task_work_run+0x95/0xc0

Aug 31 11:31:53 conquest2 kernel: [8105ebbf] do_exit+0x5df/0x890
Aug 31 11:31:53 conquest2 kernel: [81069de3] ? 
restore_altstack+0x13/0x30
Aug 31 11:31:53 conquest2 kernel: [8105ef60] 
do_group_exit+0x30/0x70
Aug 31 11:31:53 conquest2 kernel: [8105efb2] 
SyS_exit_group+0x12/0x20
Aug 31 11:31:53 conquest2 kernel: [81388590] 
system_call_fastpath+0x16/0x1bAug 31 11:31:53 conquest2 kernel: ---[ end 
trace 76bc7ab59b9ea669 ]---


=


Aug 31 12:54:56 conquest2 kernel: general protection fault:  [#1]
Aug 31 12:54:56 conquest2 kernel: Modules linked in: rpcsec_gss_krb5 
nfsv4 snd_hrtimer cpufreq_userspace cpufreq_stats cpufreq_powersave lp 
hwmon_vid nfsd auth_
rpcgss oid_registry exportfs nfs_acl nfs lockd sunrpc ipv6 analog joydev 
dm_crypt dm_mod snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm_oss 
snd_mixer_oss snd_pcm
nouveau video backlight fbcon snd_page_alloc mxm_wmi snd_seq_dummy 
snd_mpu401 snd_mpu401_uart bitblit psmouse snd_seq_oss softcursor wmi 
snd_seq_midi ttm font s
nd_rawmidi drm_kms_helper snd_seq_midi_event sg snd_seq drm i2c_algo_bit 
sr_mod k8temp cdrom hwmon forcedeth serio_raw ohci_pci snd_seq_device 
pcspkr evdev ohci
_hcd snd_timer snd ns558 gameport ehci_pci ehci_hcd i2c_nforce2 i2c_core 
parport_pc parport floppy soundcore thermal processor button unix
Aug 31 12:54:56 conquest2 kernel: CPU: 0 PID:  Comm: ifconfig Not 
tainted 3.11.0-rc7_c2+ #100
Aug 31 12:54:56 conquest2 kernel: Hardware name: System manufacturer 
System name/A8N-SLI DELUXE, BIOS ASUS A8N-SLI DELUXE ACPI BIOS Revision 
1805 09/29/2006
Aug 31 12:54:56 conquest2 kernel: task: 88007d3f4150 ti: 
88000156e000 task.ti: 88000156e000
Aug 31 12:54:56 conquest2 kernel: RIP: 0010:[813846b3] 
[813846b3] 

Re: [PATCH] rwsem: add rwsem_is_contended

2013-08-31 Thread Peter Zijlstra
On Fri, Aug 30, 2013 at 10:14:01AM -0400, Josef Bacik wrote:
 Btrfs uses an rwsem to control access to its extent tree.  Threads will hold a
 read lock on this rwsem while they scan the extent tree, and if need_resched()
 they will drop the lock and schedule.  The transaction commit needs to take a
 write lock for this rwsem for a very short period to switch out the commit
 roots.  If there are a lot of threads doing this caching operation we can 
 starve
 out the committers which slows everybody out.  To address this we want to add
 this functionality to see if our rwsem has anybody waiting to take a write 
 lock
 so we can drop it and schedule for a bit to allow the commit to continue.


 +/*
 + * check to see if the rwsem we're holding has anybody waiting to acquire it.
 + */
 +int rwsem_is_contended(struct rw_semaphore *sem)
 +{
 + int ret = 0;
 + unsigned long flags;
 +
 + if (!raw_spin_trylock_irqsave(sem-wait_lock, flags))
 + return 1;
 + if (!list_empty(sem-wait_list))
 + ret = 1;
 + raw_spin_unlock_irqrestore(sem-wait_lock, flags);
 + return ret;
 +}
 +
 +EXPORT_SYMBOL(rwsem_is_contended);

Modeled after spin_is_contended(), so no problem with that. One thing I
was wondering about is if it wants to be called
rwsem_is_write_contended() or similar, since it explicitly only tests
for pending writers.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] perf, x86: Avoid checkpointed counters causing excessive TSX aborts v4

2013-08-31 Thread Peter Zijlstra
On Fri, Aug 30, 2013 at 01:44:45PM -0700, Andi Kleen wrote:
 On Fri, Aug 30, 2013 at 06:02:15PM +0200, Peter Zijlstra wrote:
  On Wed, Aug 21, 2013 at 04:47:23PM -0700, Andi Kleen wrote:
   @@ -1224,6 +1240,15 @@ again:
 x86_pmu.drain_pebs(regs);
 }

   + /*
   +  * To avoid spurious interrupts with perf stat always reset checkpointed
   +  * counters.
   +  *
   +  * XXX move somewhere else.
   +  */
   + if (cpuc-events[2]  event_is_checkpointed(cpuc-events[2]))
   + status |= (1ULL  2);
   +
 for_each_set_bit(bit, (unsigned long *)status, X86_PMC_IDX_MAX) {
 struct perf_event *event = cpuc-events[bit];


 So can just drop the XXX comment. Ok?

How about hiding the entire thing in a hsw function. I'm fairly sure
that eventually we'll need to check all counters for this nonsense.

Something like so perhaps?

---
 arch/x86/kernel/cpu/perf_event_intel.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel.c 
b/arch/x86/kernel/cpu/perf_event_intel.c
index a45d8d4..2a400b7 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1170,6 +1170,20 @@ static void intel_pmu_reset(void)
local_irq_restore(flags);
 }
 
+static void intel_pmu_hsw_tsx_status(struct cpu_hw_event *cpuc, u64 *status)
+{
+   const int idx = 2; /* only cnt2 supports TSX for now */
+   struct perf_event *event = cpuc-event[idx];
+
+   if (event_is_checkpoint(event)) {
+   /*
+* In order to avoid spurious interrupts always reset
+* checkpointed counters.
+*/
+   *status |= (1ULL  idx);
+   }
+}
+
 /*
  * This handler is triggered by the local APIC, so the APIC IRQ handling
  * rules apply:
@@ -1224,6 +1238,8 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
x86_pmu.drain_pebs(regs);
}
 
+   intel_pmu_hsw_tsx_status(cpuc, status);
+
for_each_set_bit(bit, (unsigned long *)status, X86_PMC_IDX_MAX) {
struct perf_event *event = cpuc-events[bit];
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] perf, x86: Avoid checkpointed counters causing excessive TSX aborts v4

2013-08-31 Thread Andi Kleen
  So can just drop the XXX comment. Ok?
 
 How about hiding the entire thing in a hsw function. I'm fairly sure
 that eventually we'll need to check all counters for this nonsense.

AFAIK there are no plans to do so.

 
 Something like so perhaps?

It's ok for me, except it's not for TSX (that's intx), but only for
intx_checkpointed.

Should I send a new patch?

-Andi
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Documentation/memory-barriers: fix a error that mistakes a CPU notion in Section Transitivity

2013-08-31 Thread Paul E. McKenney
On Sat, Aug 31, 2013 at 12:34:01PM +0800, Zhan Jianyu wrote:
 Hi, Rob,  thanks reviewing
 and I'm sorry for my careless writing.
 
 I resend the revised patch below:
 
 ---
 
 The memory-barriers document may has an error in Section TRANSITIVITY.
 
 For transitivity, see an example below, given that
 
 * CPU 2's load from X follows  CPU 1's store to X,
 * CPU 2's load from Y preceds CPU 3's store to Y.
 
 
  CPU 1   CPU 2   CPU 3
  =
 { X = 0, Y = 0 }
  STORE X=1 LOAD X  STORE Y=1
 read barrier  general barrier
 LOAD Y  LOAD X
 
 
 The read barrier in CPU 2 is inadquate, because it could _only_ guarantees
 that load operation _happen before_ load operation after the barrier, with
 respect to CPU 3, which constrained by a general barrier, but provide _NO_
 guarantee that CPU 1' store X will happen before the read barrier.
 
 Therefore, if this example runs on a system where CPUs 1 and 3 share a
 store buffer
 or a level of cache, CPU 3 might have early access to CPU 1's writes.
 
 The original text has mistaken CPU 2 for CPU 3, so this patch fixes
 this, and adds
 a paragraph to explain why a full barrier should guarantee this.
 
 Signed-off-by: Zhan Jianyu nasa4...@gmail.com
 ---
 Documentation/memory-barriers.txt |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)
 
 diff --git a/Documentation/memory-barriers.txt
 b/Documentation/memory-barriers.txt
 index fa5d8a9..590a5a9 100644
 --- a/Documentation/memory-barriers.txt
 +++ b/Documentation/memory-barriers.txt
 @@ -992,6 +992,13 @@ transitivity.  Therefore, in the above example,
 if CPU 2's load from X
  returns 1 and its load from Y returns 0, then CPU 3's load from X must
  also return 1.
 
 +The key point is that CPU 1's storing 1 to X precedes CPU 2's loading 1
 +from X, and CPU 2's loading 0 from Y precedes CPU 3's storing 1 to Y,
 +which implies an ordering that the general barrier in CPU 2 guarantees:
 +all store and load operations must happen before those after the barrier
 +with respect to CPU 3, which is constrained by a general barrier, too.
 +Thus, CPU 3's load from X must return 1.
 +

This one is a good addition, thank you!

  However, transitivity is -not- guaranteed for read or write barriers.
  For example, suppose that CPU 2's general barrier in the above example
  is changed to a read barrier as shown below:
 @@ -1009,8 +1016,8 @@ and CPU 3's load from X to return 0.
 
  The key point is that although CPU 2's read barrier orders its pair
  of loads, it does not guarantee to order CPU 1's store.  Therefore, if
 -this example runs on a system where CPUs 1 and 2 share a store buffer
 -or a level of cache, CPU 2 might have early access to CPU 1's writes.
 +this example runs on a system where CPUs 1 and 3 share a store buffer
 +or a level of cache, CPU 3 might have early access to CPU 1's writes.
  General barriers are therefore required to ensure that all CPUs agree
  on the combined order of CPU 1's and CPU 2's accesses.

However, this change does not make sense.  If CPUs 1 and 3 shared a store
buffer, then CPU 3 would be more likely to see x==1.  We need CPUs 1 and
2 to share a store buffer to make it more likely that CPU 3 will see x==0.

Thanx, Paul

 
 --
 
 Regards,
 Zhan Jianyu
 
 
 On Sat, Aug 31, 2013 at 12:16 PM, Rob Landley r...@landley.net wrote:
  On 08/27/2013 05:34:22 AM, larmbr wrote:
 
  The memory-barriers document may has a error in Section TRANSITIVITY.
 
  For transitivity, see a example below, given that
 
  * CPU 2's load from X follows CPU 1's store to X, and
CPU 2's load from Y preceds CPU 3's store to Y.
 
 
  I'd prefer somebody with a better understanding of this code review it
  before merging. I'm not a memory barrier semantics expert, I can't tell you
  if this _is_ a bug.
 
 
  +The key point is that CPU 1's storing 1 to X preceds CPU 2's loading 1
 
 
  precedes
 
 
  +from X, and CPU 2's loading 0 from Y preceds CPU 3's storing 1 to Y,
 
 
  precedes
 
 
  +which implies a ordering that the general barrier in CPU 2 guarantees:
 
 
  an ordering
 
 
  +all store and load operations must happen before those after the barrier
  +with respect to view of CPU 3, which constrained by a general barrier,
  too.
 
 
  the view of (or possibly from the point of view of, the current phrasing
  is awkward)
 
  which is constrained
 
  Rob
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 00/18 v2] ftrace/rcu: Handle unsafe RCU functions and ftrace callbacks

2013-08-31 Thread Steven Rostedt
On Sat, 31 Aug 2013 01:11:17 -0400
Steven Rostedt rost...@goodmis.org wrote:

 This is my final draft of the patches. I'm starting to run them
 through my formal tests now. They may change depending on the outcome
 of the tests.

Update: All my formal tests passed.

 
 I'm also a bit tired, and I added the change logs last. Thus I may
 need to go back and fix the change logs up too. But the code was done
 when I was rather spunky. But that doesn't mean I didn't break anything.

I still probably need to update the change logs.

But other than that, I'm waiting on Acks or comments.

Thanks!

-- Steve

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Crashes on 3.0.11-rc7: nouveau?

2013-08-31 Thread Ilia Mirkin
On Sat, Aug 31, 2013 at 10:43 AM, ael law_ence@ntlworld.com wrote:
 Aug 31 11:31:53 conquest2 kernel: [ cut here ]
 Aug 31 11:31:53 conquest2 kernel: WARNING: CPU: 0 PID: 4566 at
 drivers/gpu/drm/nouveau/nouveau_bo.c:151 nouveau_bo_del_ttm+0x62/0x70
 [nouveau]()
 Aug 31 11:31:53 conquest2 kernel: Modules linked in: snd_hrtimer
 cpufreq_userspace cpufreq_stats cpufreq_powersave lp hwmon_vid nfsd
 auth_rpcgss oid_registry exportfs nfs_acl nfs lockd sunrpc ipv6 analog
 joydev dm_crypt dm_mod nouveau snd_intel8x0 snd_ac97_codec ac97_bus video
 snd_pcm_oss snd_mixer_oss backlight snd_pcm mxm_wmi snd_page_alloc
 snd_seq_dummy snd_mpu401 snd_mpu401_uart snd_seq_oss wmi snd_seq_midi ttm
 snd_rawmidi snd_seq_midi_event snd_seq fbcon bitblit snd_seq_device
 softcursor font snd_timer drm_kms_helper snd drm sg k8temp forcedeth ns558
 sr_mod cdrom hwmon psmouse serio_raw pcspkr gameport i2c_algo_bit evdev
 ohci_pci ohci_hcd ehci_pci ehci_hcd soundcore parport_pc parport i2c_nforce2
 i2c_core floppy thermal processor button unix
 Aug 31 11:31:53 conquest2 kernel: CPU: 0 PID: 4566 Comm: Xorg Not tainted
 3.11.0-rc4_c2+ #99
 Aug 31 11:31:53 conquest2 kernel: Hardware name: System manufacturer System
 name/A8N-SLI DELUXE, BIOS ASUS A8N-SLI DELUXE ACPI BIOS Revision 1805
 09/29/2006
 Aug 31 11:31:53 conquest2 kernel: 0009 88007cad3c48
 81384a50 88007cad3c80
 Aug 31 11:31:53 conquest2 kernel: 8105d2ab 880036c10c00
 a480 88007c908158
 Aug 31 11:31:53 conquest2 kernel: 880036c10c00 880036c10c00
 88007cad3c90 8105d2f5
 Aug 31 11:31:53 conquest2 kernel: Call Trace:
 Aug 31 11:31:53 conquest2 kernel: [81384a50] dump_stack+0x19/0x1b
 Aug 31 11:31:53 conquest2 kernel: [8105d2ab]
 warn_slowpath_common+0x7b/0xb0
 Aug 31 11:31:53 conquest2 kernel: [8105d2f5]
 warn_slowpath_null+0x15/0x20
 Aug 31 11:31:53 conquest2 kernel: [a03567d2]
 nouveau_bo_del_ttm+0x62/0x70 [nouveau]
 Aug 31 11:31:53 conquest2 kernel: [a0238668]
 ttm_bo_release_list+0x98/0xe0 [ttm]
 Aug 31 11:31:53 conquest2 kernel: [a023924d]
 ttm_bo_release+0x16d/0x200 [ttm]
 Aug 31 11:31:53 conquest2 kernel: [a0239309]
 ttm_bo_unref+0x29/0x30 [ttm]
 Aug 31 11:31:53 conquest2 kernel: [a03591e6]
 nouveau_gem_object_del+0x46/0x60 [nouveau]
 Aug 31 11:31:53 conquest2 kernel: [a0133394]
 drm_gem_object_free+0x24/0x30 [drm]
 Aug 31 11:31:53 conquest2 kernel: [a0133750]
 drm_gem_object_release_handle+0xb0/0xc0 [drm]
 Aug 31 11:31:53 conquest2 kernel: [811e4c8f]
 idr_for_each+0xaf/0x100
 Aug 31 11:31:53 conquest2 kernel: [a01336a0] ?
 drm_gem_handle_create+0xe0/0xe0 [drm]
 Aug 31 11:31:53 conquest2 kernel: [81385f2d] ? mutex_lock+0xd/0x20
 Aug 31 11:31:53 conquest2 kernel: [a0133c1b]
 drm_gem_release+0x1b/0x30 [drm]
 Aug 31 11:31:53 conquest2 kernel: [a0132499]
 drm_release+0x589/0x600 [drm]
 Aug 31 11:31:53 conquest2 kernel: [810eafcf] __fput+0xaf/0x230
 Aug 31 11:31:53 conquest2 kernel: [810eb189] fput+0x9/0x10
 Aug 31 11:31:53 conquest2 kernel: [810735c5]
 task_work_run+0x95/0xc0
 Aug 31 11:31:53 conquest2 kernel: [8105ebbf] do_exit+0x5df/0x890
 Aug 31 11:31:53 conquest2 kernel: [81069de3] ?
 restore_altstack+0x13/0x30
 Aug 31 11:31:53 conquest2 kernel: [8105ef60]
 do_group_exit+0x30/0x70
 Aug 31 11:31:53 conquest2 kernel: [8105efb2]
 SyS_exit_group+0x12/0x20
 Aug 31 11:31:53 conquest2 kernel: [81388590]
 system_call_fastpath+0x16/0x1bAug 31 11:31:53 conquest2 kernel: ---[ end
 trace 76bc7ab59b9ea669 ]---

This is not a crash, but a warning. Also one that should have been
taken care of in 3.11-rc7 -- are you absolutely sure you're running
that kernel and not some 3.11-rc6+ one? This is the commit that should
have fixed it (and worked great for me):

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=78ae0ad403daf11cf63da86923d2b5dbeda3af8f

Based on what you pasted, you were actually running 3.11.0-rc4_c2+
which probably didn't contain the above commit.


 =


 Aug 31 12:54:56 conquest2 kernel: general protection fault:  [#1]
 Aug 31 12:54:56 conquest2 kernel: Modules linked in: rpcsec_gss_krb5 nfsv4
 snd_hrtimer cpufreq_userspace cpufreq_stats cpufreq_powersave lp hwmon_vid
 nfsd auth_
 rpcgss oid_registry exportfs nfs_acl nfs lockd sunrpc ipv6 analog joydev
 dm_crypt dm_mod snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm_oss
 snd_mixer_oss snd_pcm
 nouveau video backlight fbcon snd_page_alloc mxm_wmi snd_seq_dummy
 snd_mpu401 snd_mpu401_uart bitblit psmouse snd_seq_oss softcursor wmi
 snd_seq_midi ttm font s
 nd_rawmidi drm_kms_helper snd_seq_midi_event sg snd_seq drm i2c_algo_bit
 sr_mod k8temp cdrom hwmon forcedeth serio_raw ohci_pci snd_seq_device pcspkr
 evdev ohci
 _hcd snd_timer snd 

Re: [PATCH 1/2] w1: w1-gpio: use dev_get_platdata()

2013-08-31 Thread Evgeniy Polyakov
Hi

30.08.2013, 08:17, Jingoo Han jg1@samsung.com:
 Use the wrapper function for retrieving the platform data instead of
 accessing dev-platform_data directly. This is a cosmetic change
 to make the code simpler and enhance the readability.

Both patches look good, thank you

 Signed-off-by: Jingoo Han jg1@samsung.com

Acked-by: Evgeniy Polyakov z...@ioremap.net
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] checkpatch: Add test for positional misuse of section specifiers like __initdata

2013-08-31 Thread Joe Perches
On Sat, 2013-08-31 at 16:31 +0200, Andi Kleen wrote:
  A similar patch was suggested by Andi Kleen
  https://lkml.org/lkml/2013/8/5/648
 
 My patch checked for const - initdata / non const initconst  mistakes.
 
 I don't think your patch does that?

Hi Andi.

No it doesn't.

This patch is just warning when using
struct __initdata foo bar;
instead of
struct foo bar __initdata;

I'll get around to adding tests for your
cases soonish.

cheers, Joe

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] i2c: i2c-dev: Create 'name' attribute automatically

2013-08-31 Thread Guenter Roeck
The 'name' attribute is needed for all i2c-dev class devices, meaning
it can be created automatically by pointing to it in the class data
structure. This simplifies the code and reduces the probability for race
conditions.

Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/i2c/i2c-dev.c |   32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index c3ccdea..46eea02 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -111,7 +111,11 @@ static ssize_t show_adapter_name(struct device *dev,
return -ENODEV;
return sprintf(buf, %s\n, i2c_dev-adap-name);
 }
-static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
+
+static struct device_attribute i2c_dev_attributes[] = {
+   __ATTR(name, S_IRUGO, show_adapter_name, NULL),
+   { }
+};
 
 /* - */
 
@@ -538,7 +542,11 @@ static const struct file_operations i2cdev_fops = {
 
 /* - */
 
-static struct class *i2c_dev_class;
+static struct class i2c_dev_class = {
+   .owner = THIS_MODULE,
+   .name = i2c-dev,
+   .dev_attrs = i2c_dev_attributes,
+};
 
 static int i2cdev_attach_adapter(struct device *dev, void *dummy)
 {
@@ -555,22 +563,17 @@ static int i2cdev_attach_adapter(struct device *dev, void 
*dummy)
return PTR_ERR(i2c_dev);
 
/* register this i2c device with the driver core */
-   i2c_dev-dev = device_create(i2c_dev_class, adap-dev,
+   i2c_dev-dev = device_create(i2c_dev_class, adap-dev,
 MKDEV(I2C_MAJOR, adap-nr), NULL,
 i2c-%d, adap-nr);
if (IS_ERR(i2c_dev-dev)) {
res = PTR_ERR(i2c_dev-dev);
goto error;
}
-   res = device_create_file(i2c_dev-dev, dev_attr_name);
-   if (res)
-   goto error_destroy;
 
pr_debug(i2c-dev: adapter [%s] registered as minor %d\n,
 adap-name, adap-nr);
return 0;
-error_destroy:
-   device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap-nr));
 error:
return_i2c_dev(i2c_dev);
return res;
@@ -589,9 +592,8 @@ static int i2cdev_detach_adapter(struct device *dev, void 
*dummy)
if (!i2c_dev) /* attach_adapter must have failed */
return 0;
 
-   device_remove_file(i2c_dev-dev, dev_attr_name);
return_i2c_dev(i2c_dev);
-   device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap-nr));
+   device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap-nr));
 
pr_debug(i2c-dev: adapter [%s] unregistered\n, adap-name);
return 0;
@@ -632,11 +634,9 @@ static int __init i2c_dev_init(void)
if (res)
goto out;
 
-   i2c_dev_class = class_create(THIS_MODULE, i2c-dev);
-   if (IS_ERR(i2c_dev_class)) {
-   res = PTR_ERR(i2c_dev_class);
+   res = class_register(i2c_dev_class);
+   if (res)
goto out_unreg_chrdev;
-   }
 
/* Keep track of adapters which will be added or removed later */
res = bus_register_notifier(i2c_bus_type, i2cdev_notifier);
@@ -649,7 +649,7 @@ static int __init i2c_dev_init(void)
return 0;
 
 out_unreg_class:
-   class_destroy(i2c_dev_class);
+   class_unregister(i2c_dev_class);
 out_unreg_chrdev:
unregister_chrdev(I2C_MAJOR, i2c);
 out:
@@ -661,7 +661,7 @@ static void __exit i2c_dev_exit(void)
 {
bus_unregister_notifier(i2c_bus_type, i2cdev_notifier);
i2c_for_each_dev(NULL, i2cdev_detach_adapter);
-   class_destroy(i2c_dev_class);
+   class_unregister(i2c_dev_class);
unregister_chrdev(I2C_MAJOR, i2c);
 }
 
-- 
1.7.9.7

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   >