Re: [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc

2012-09-13 Thread Rene Buergel
> Also, why move it?  Are there other modules that need to use it?

Fullquote from Aug, 24:
> > > > - Although i removed the dependency from ezusb to usb_serial,
> > > >   ezusb.c still resides in drivers/usb/serial.
> > > >   Can you give me a hint, where to put it instead?
> > > >   I would like to do that with an additional patch.
> > > 
> > > Why do you want to move it?
> > 
> > because is has nothing to do with any serial stuff anymore...
> 
> Fair enough, how about drivers/usb/misc/ instead?
> 
> greg k-h
> 
--
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 v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc

2012-09-13 Thread Rene Buergel
> Git should show this as a move, not as a "add a file and remove a
> file"
> type patch.  Are you generating it properly?

Whats the proper way to do this? I did a git mv, git commit and than git diff 
on that commit hash.


> Also, why move it?  Are there other modules that need to use it?
> 
> thanks,
> 
> greg k-h
> 

we discussed this a while ago, i had some trouble getting the patches due to 
changing my workplace.
--
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] gcov: add a kfree() on error to new_node()

2012-09-13 Thread Dan Carpenter
We should free "node->loaded_info" on this error path.  We'd never care
in real life but it makes the static checkers happy.

Signed-off-by: Dan Carpenter 
---
v2: some style changes.

diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
index 9bd0934..7ba47f7 100644
--- a/kernel/gcov/fs.c
+++ b/kernel/gcov/fs.c
@@ -451,8 +451,7 @@ static struct gcov_node *new_node(struct gcov_node *parent,
node->dentry = debugfs_create_dir(node->name, parent->dentry);
if (!node->dentry) {
pr_warning("could not create file\n");
-   kfree(node);
-   return NULL;
+   goto err_info;
}
if (info)
add_links(node, parent->dentry);
@@ -461,6 +460,8 @@ static struct gcov_node *new_node(struct gcov_node *parent,
 
return node;
 
+err_info:
+   kfree(node->loaded_info);
 err_nomem:
kfree(node);
pr_warning("out of memory\n");
--
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/2] mm: refactor out __alloc_contig_migrate_alloc

2012-09-13 Thread Wen Congyang
At 09/12/2012 09:43 AM, Minchan Kim Wrote:
> __alloc_contig_migrate_alloc can be used by memory-hotplug so
> refactor out(move + rename as a common name) it into
> page_isolation.c.
> 
> Cc: Kamezawa Hiroyuki 
> Cc: Yasuaki Ishimatsu 
> Cc: Michal Nazarewicz 
> Cc: Marek Szyprowski 
> Cc: Wen Congyang 
> Signed-off-by: Minchan Kim 
> ---
> 
> This patch is intended for preparing next bug fix patch.
> 
>  include/linux/page-isolation.h |3 ++-
>  mm/page_alloc.c|   14 +-
>  mm/page_isolation.c|   11 +++
>  3 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
> index 105077a..1c82261 100644
> --- a/include/linux/page-isolation.h
> +++ b/include/linux/page-isolation.h
> @@ -37,6 +37,7 @@ int test_pages_isolated(unsigned long start_pfn, unsigned 
> long end_pfn);
>   */
>  int set_migratetype_isolate(struct page *page);
>  void unset_migratetype_isolate(struct page *page, unsigned migratetype);
> -
> +struct page *alloc_migrate_target(struct page *page, unsigned long private,
> + int **resultp);
>  
>  #endif
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index a4ff74e..6716023 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5648,18 +5648,6 @@ static unsigned long pfn_max_align_up(unsigned long 
> pfn)
>   pageblock_nr_pages));
>  }
>  
> -static struct page *
> -__alloc_contig_migrate_alloc(struct page *page, unsigned long private,
> -  int **resultp)
> -{
> - gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE;
> -
> - if (PageHighMem(page))
> - gfp_mask |= __GFP_HIGHMEM;
> -
> - return alloc_page(gfp_mask);
> -}
> -
>  /* [start, end) must belong to a single zone. */
>  static int __alloc_contig_migrate_range(unsigned long start, unsigned long 
> end)
>  {
> @@ -5700,7 +5688,7 @@ static int __alloc_contig_migrate_range(unsigned long 
> start, unsigned long end)
>   }
>  
>   ret = migrate_pages(&cc.migratepages,
> - __alloc_contig_migrate_alloc,
> + alloc_migrate_target,
>   0, false, MIGRATE_SYNC);
>   }
>  
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index 247d1f1..6936545 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -233,3 +233,14 @@ int test_pages_isolated(unsigned long start_pfn, 
> unsigned long end_pfn)
>   spin_unlock_irqrestore(&zone->lock, flags);
>   return ret ? 0 : -EBUSY;
>  }
> +
> +struct page *alloc_migrate_target(struct page *page, unsigned long private,
> + int **resultp)
> +{
> +gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE;
> +
> +if (PageHighMem(page))
> +gfp_mask |= __GFP_HIGHMEM;
> +
> +return alloc_page(gfp_mask);

alloc_page() will use current task's memory policy. If we offline memory like 
this:
numactl -m n echo offline >/sys/devices/system/memory/memoryX/state # n is 
page's nid

It may trigger OOM event.

Thanks
Wen Congyang

--
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/3] Add a core driver for SI476x MFD

2012-09-13 Thread Hans Verkuil
Hi Andrey!

Thanks for posting this driver. One request for the future: please split this
patch up in smaller pieces: one for each c source for example. That makes it
easier to review.

On Fri September 14 2012 00:40:11 Andrey Smirnov wrote:
> This patch adds a core driver for Silicon Laboratories Si476x series
> of AM/FM tuner chips. The driver as a whole is implemented as an MFD device
> and this patch adds a core portion of it that provides all the necessary
> functionality to the two other drivers that represent radio and audio
> codec subsystems of the chip.
> 
> Signed-off-by: Andrey Smirnov 
> ---
>  drivers/mfd/Kconfig |   14 +
>  drivers/mfd/Makefile|3 +
>  drivers/mfd/si476x-cmd.c| 1509 
> +++
>  drivers/mfd/si476x-i2c.c| 1033 +++
>  drivers/mfd/si476x-prop.c   |  477 +
>  include/linux/mfd/si476x-core.h |  522 ++
>  include/media/si476x.h  |  455 
>  7 files changed, 4013 insertions(+)
>  create mode 100644 drivers/mfd/si476x-cmd.c
>  create mode 100644 drivers/mfd/si476x-i2c.c
>  create mode 100644 drivers/mfd/si476x-prop.c
>  create mode 100644 include/linux/mfd/si476x-core.h
>  create mode 100644 include/media/si476x.h
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index b1a1462..3fab06d 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -895,6 +895,20 @@ config MFD_WL1273_CORE
> driver connects the radio-wl1273 V4L2 module and the wl1273
> audio codec.
>  
> +config MFD_SI476X_CORE
> + tristate "Support for Silicon Laboratories 4761/64/68 AM/FM radio."
> + depends on I2C
> + select MFD_CORE
> + default n
> + help
> +   This is the core driver for the SI476x series of AM/FM radio. This MFD
> +   driver connects the radio-si476x V4L2 module and the si476x
> +   audio codec.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called si476x-core.
> +
> +
>  config MFD_OMAP_USB_HOST
>   bool "Support OMAP USBHS core driver"
>   depends on USB_EHCI_HCD_OMAP || USB_OHCI_HCD_OMAP3
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 79dd22d..942257b 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -132,3 +132,6 @@ obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o
>  obj-$(CONFIG_MFD_SEC_CORE)   += sec-core.o sec-irq.o
>  obj-$(CONFIG_MFD_ANATOP) += anatop-mfd.o
>  obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o
> +
> +si476x-core-objs := si476x-cmd.o si476x-prop.o si476x-i2c.o
> +obj-$(CONFIG_MFD_SI476X_CORE)+= si476x-core.o
> diff --git a/drivers/mfd/si476x-cmd.c b/drivers/mfd/si476x-cmd.c
> new file mode 100644
> index 000..defe1f5
> --- /dev/null
> +++ b/drivers/mfd/si476x-cmd.c
> @@ -0,0 +1,1509 @@
> +/*
> + * include/media/si476x-cmd.c -- Subroutines implementing command
> + * protocol of si476x series of chips
> + *
> + * Copyright (C) 2012 Innovative Converged Devices(ICD)
> + *
> + * Author: Andrey Smirnov 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#define msb(x)  ((u8)((u16) x >> 8))
> +#define lsb(x)  ((u8)((u16) x &  0x00FF))
> +
> +
> +
> +#define CMD_POWER_UP 0x01
> +#define CMD_POWER_UP_A10_NRESP   1
> +#define CMD_POWER_UP_A10_NARGS   5
> +
> +#define CMD_POWER_UP_A20_NRESP   1
> +#define CMD_POWER_UP_A20_NARGS   5
> +
> +#define POWER_UP_DELAY_MS110
> +
> +#define CMD_POWER_DOWN   0x11
> +#define CMD_POWER_DOWN_A10_NRESP 1
> +
> +#define CMD_POWER_DOWN_A20_NRESP 1
> +#define CMD_POWER_DOWN_A20_NARGS 1
> +
> +#define CMD_FUNC_INFO0x12
> +#define CMD_FUNC_INFO_NRESP  7
> +
> +#define CMD_SET_PROPERTY 0x13
> +#define CMD_SET_PROPERTY_NARGS   5
> +#define CMD_SET_PROPERTY_NRESP   1
> +
> +#define CMD_GET_PROPERTY 0x14
> +#define CMD_GET_PROPERTY_NARGS   3
> +#define CMD_GET_PROPERTY_NRESP   4
> +
> +#define CMD_AGC_STATUS   0x17
> +#define CMD_AGC_STAT

linux-next: manual merge of the dma-mapping tree with the libata tree

2012-09-13 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the dma-mapping tree got a conflict in
arch/arm/boot/dts/highbank.dts between commit 8996b89d6bc9 ("ata: add
platform driver for Calxeda AHCI controller") from the libata tree and
commit 33e4628cc333 ("ARM: highbank: add coherent DMA setup") from the
dma-mapping tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc arch/arm/boot/dts/highbank.dts
index 5204cf7,7414577..000
--- a/arch/arm/boot/dts/highbank.dts
+++ b/arch/arm/boot/dts/highbank.dts
@@@ -121,9 -121,7 +121,10 @@@
compatible = "calxeda,hb-ahci";
reg = <0xffe08000 0x1>;
interrupts = <0 83 4>;
 +  calxeda,port-phys = <&combophy5 0 &combophy0 0
 +   &combophy0 1 &combophy0 2
 +   &combophy0 3>;
+   dma-coherent;
};
  
sdhci@ffe0e000 {


pgpc0vk1Ecfd2.pgp
Description: PGP signature


linux-next: manual merge of the dma-mapping tree with the libata tree

2012-09-13 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the dma-mapping tree got a conflict in
Documentation/devicetree/bindings/ata/ahci-platform.txt between commit
8996b89d6bc9 ("ata: add platform driver for Calxeda AHCI controller")
from the  tree and commit 33e4628cc333 ("ARM: highbank: add coherent DMA
setup") from the dma-mapping tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc Documentation/devicetree/bindings/ata/ahci-platform.txt
index 147c1f6,6c1ad01..000
--- a/Documentation/devicetree/bindings/ata/ahci-platform.txt
+++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt
@@@ -9,9 -9,7 +9,10 @@@ Required properties
  - reg   : 
  
  Optional properties:
 +- calxeda,port-phys: phandle-combophy and lane assignment, which maps each
 +  SATA port to a combophy and a lane within that
 +  combophy
+ - dma-coherent  : Present if dma operations are coherent
  
  Example:
  sata@ffe08000 {


pgpcgzHUEALUC.pgp
Description: PGP signature


Re: [PATCH 1/1] leds: Add new LED driver for lm3642 chips

2012-09-13 Thread Bryan Wu
On Wed, Sep 12, 2012 at 8:05 PM, G.Shark Jeong  wrote:
> From: "G.Shark Jeong" 
>
> This driver is a general version for LM642 led chip of TI.
>
> LM3642 :
> The LM3642 is a 4MHz fixed-frequency synchronous boost
> converter plus 1.5A constant current driver for a high-current
> white LED.
> The LM3642 is controlled via an I2C-compatible interface.
>

Thanks, this patch looks fine to me. Applied to my for-next branch.

-Bryan

> Signed-off-by: G.Shark Jeong 
> ---
>  drivers/leds/Kconfig  |   11 +
>  drivers/leds/Makefile |1 +
>  drivers/leds/leds-lm3642.c|  471 
> +
>  include/linux/platform_data/leds-lm3642.h |   38 +++
>  4 files changed, 521 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/leds/leds-lm3642.c
>  create mode 100644 include/linux/platform_data/leds-lm3642.h
>
> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index c96bbaa..bdc05cb 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -63,6 +63,17 @@ config LEDS_LM3533
>   hardware-accelerated blinking with maximum on and off periods of 9.8
>   and 77 seconds respectively.
>
> +config LEDS_LM3642
> +   tristate "LED support for LM3642 Chip"
> +   depends on LEDS_CLASS && I2C
> +   select REGMAP_I2C
> +   help
> + This option enables support for LEDs connected to LM3642.
> + The LM3642 is a 4MHz fixed-frequency synchronous boost
> + converter plus 1.5A constant current driver for a high-current
> + white LED.
> +
> +
>  config LEDS_LOCOMO
> tristate "LED Support for Locomo device"
> depends on LEDS_CLASS
> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> index a4429a9..9a0 100644
> --- a/drivers/leds/Makefile
> +++ b/drivers/leds/Makefile
> @@ -11,6 +11,7 @@ obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o
>  obj-$(CONFIG_LEDS_LOCOMO)  += leds-locomo.o
>  obj-$(CONFIG_LEDS_LM3530)  += leds-lm3530.o
>  obj-$(CONFIG_LEDS_LM3533)  += leds-lm3533.o
> +obj-$(CONFIG_LEDS_LM3642)  += leds-lm3642.o
>  obj-$(CONFIG_LEDS_MIKROTIK_RB532)  += leds-rb532.o
>  obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
>  obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
> diff --git a/drivers/leds/leds-lm3642.c b/drivers/leds/leds-lm3642.c
> new file mode 100644
> index 000..924853b
> --- /dev/null
> +++ b/drivers/leds/leds-lm3642.c
> @@ -0,0 +1,471 @@
> +/*
> +* Simple driver for Texas Instruments LM3642 LED Flash driver chip
> +* Copyright (C) 2012 Texas Instruments
> +*
> +* This program is free software; you can redistribute it and/or modify
> +* it under the terms of the GNU General Public License version 2 as
> +* published by the Free Software Foundation.
> +*
> +*/
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#defineREG_FILT_TIME   (0x0)
> +#defineREG_IVFM_MODE   (0x1)
> +#defineREG_TORCH_TIME  (0x6)
> +#defineREG_FLASH   (0x8)
> +#defineREG_I_CTRL  (0x9)
> +#defineREG_ENABLE  (0xA)
> +#defineREG_FLAG(0xB)
> +#defineREG_MAX (0xB)
> +
> +#defineUVLO_EN_SHIFT   (7)
> +#defineIVM_D_TH_SHIFT  (2)
> +#defineTORCH_RAMP_UP_TIME_SHIFT(3)
> +#defineTORCH_RAMP_DN_TIME_SHIFT(0)
> +#defineINDUCTOR_I_LIMIT_SHIFT  (6)
> +#defineFLASH_RAMP_TIME_SHIFT   (3)
> +#defineFLASH_TOUT_TIME_SHIFT   (0)
> +#defineTORCH_I_SHIFT   (4)
> +#defineFLASH_I_SHIFT   (0)
> +#defineIVFM_SHIFT  (7)
> +#defineTX_PIN_EN_SHIFT (6)
> +#defineSTROBE_PIN_EN_SHIFT (5)
> +#defineTORCH_PIN_EN_SHIFT  (4)
> +#defineMODE_BITS_SHIFT (0)
> +
> +#defineUVLO_EN_MASK(0x1)
> +#defineIVM_D_TH_MASK   (0x7)
> +#defineTORCH_RAMP_UP_TIME_MASK (0x7)
> +#defineTORCH_RAMP_DN_TIME_MASK (0x7)
> +#defineINDUCTOR_I_LIMIT_MASK   (0x1)
> +#defineFLASH_RAMP_TIME_MASK(0x7)
> +#defineFLASH_TOUT_TIME_MASK(0x7)
> +#defineTORCH_I_MASK(0x7)
> +#defineFLASH_I_MASK(0xF)
> +#defineIVFM_MASK   (0x1)
> +#defineTX_PIN_EN_MASK  (0x1)
> +#defineSTROBE_PIN_EN_MASK  (0x1)
> +#defineTORCH_PIN_EN_MASK   (0x1)
> +#defineMODE_BITS_MASK  (0x73)
> +#defi

Re: memory-hotplug : possible circular locking dependency detected

2012-09-13 Thread Yasuaki Ishimatsu
Hi Wen,

2012/09/14 15:02, Wen Congyang wrote:
> At 09/13/2012 02:19 PM, Yasuaki Ishimatsu Wrote:
>> When I offline a memory on linux-3.6-rc5, "possible circular
>> locking dependency detected" messages are shown.
>> Are the messages known problem?
> 
> It is a known problem, but it doesn't cause a deadlock.
> There is 3 locks: memory hotplug's lock, memory hotplug
> notifier's lock, and ksm_thread_mutex.
> 
> ksm_thread_mutex is locked when the memory is going offline
> and is unlocked when the memory is offlined or the offlining
> is cancelled. So we meet the warning messages. But it
> doesn't cause deadlock, because we lock mem_hotplug_mutex
> first.

Thank you for your clarification.
I understand it. So I ignore the messages.

Thanks,
Yasuaki Ishimatsu

> 
> Thanks
> Wen Congyang
> 
>>
>> [  201.596363] Offlined Pages 32768
>> [  201.596373] remove from free list 14 1024 148000
>> [  201.596493] remove from free list 140400 1024 148000
>> [  201.596612] remove from free list 140800 1024 148000
>> [  201.596730] remove from free list 140c00 1024 148000
>> [  201.596849] remove from free list 141000 1024 148000
>> [  201.596968] remove from free list 141400 1024 148000
>> [  201.597049] remove from free list 141800 1024 148000
>> [  201.597049] remove from free list 141c00 1024 148000
>> [  201.597049] remove from free list 142000 1024 148000
>> [  201.597049] remove from free list 142400 1024 148000
>> [  201.597049] remove from free list 142800 1024 148000
>> [  201.597049] remove from free list 142c00 1024 148000
>> [  201.597049] remove from free list 143000 1024 148000
>> [  201.597049] remove from free list 143400 1024 148000
>> [  201.597049] remove from free list 143800 1024 148000
>> [  201.597049] remove from free list 143c00 1024 148000
>> [  201.597049] remove from free list 144000 1024 148000
>> [  201.597049] remove from free list 144400 1024 148000
>> [  201.597049] remove from free list 144800 1024 148000
>> [  201.597049] remove from free list 144c00 1024 148000
>> [  201.597049] remove from free list 145000 1024 148000
>> [  201.597049] remove from free list 145400 1024 148000
>> [  201.597049] remove from free list 145800 1024 148000
>> [  201.597049] remove from free list 145c00 1024 148000
>> [  201.597049] remove from free list 146000 1024 148000
>> [  201.597049] remove from free list 146400 1024 148000
>> [  201.597049] remove from free list 146800 1024 148000
>> [  201.597049] remove from free list 146c00 1024 148000
>> [  201.597049] remove from free list 147000 1024 148000
>> [  201.597049] remove from free list 147400 1024 148000
>> [  201.597049] remove from free list 147800 1024 148000
>> [  201.597049] remove from free list 147c00 1024 148000
>> [  201.602143]
>> [  201.602150] ==
>> [  201.602153] [ INFO: possible circular locking dependency detected ]
>> [  201.602157] 3.6.0-rc5 #1 Not tainted
>> [  201.602159] ---
>> [  201.602162] bash/2789 is trying to acquire lock:
>> [  201.602164]  ((memory_chain).rwsem){.+.+.+}, at: [] 
>> __blocking_notifier_call_chain+0x66/0xd0
>> [  201.602180]
>> [  201.602180] but task is already holding lock:
>> [  201.602182]  (ksm_thread_mutex/1){+.+.+.}, at: [] 
>> ksm_memory_callback+0x3a/0xc0
>> [  201.602194]
>> [  201.602194] which lock already depends on the new lock.
>> [  201.602194]
>> [  201.602197]
>> [  201.602197] the existing dependency chain (in reverse order) is:
>> [  201.602200]
>> [  201.602200] -> #1 (ksm_thread_mutex/1){+.+.+.}:
>> [  201.602208][] validate_chain+0x6d9/0x7e0
>> [  201.602214][] __lock_acquire+0x2f6/0x4f0
>> [  201.602219][] lock_acquire+0x9d/0x190
>> [  201.602223][] __mutex_lock_common+0x5c/0x420
>> [  201.602229][] mutex_lock_nested+0x4a/0x60
>> [  201.602234][] ksm_memory_callback+0x3a/0xc0
>> [  201.602239][] notifier_call_chain+0x67/0x150
>> [  201.602244][] 
>> __blocking_notifier_call_chain+0x7b/0xd0
>> [  201.602250][] 
>> blocking_notifier_call_chain+0x16/0x20
>> [  201.602255][] memory_notify+0x1b/0x20
>> [  201.602261][] offline_pages+0x1b1/0x470
>> [  201.602267][] remove_memory+0x1e/0x20
>> [  201.602273][] memory_block_action+0xa1/0x190
>> [  201.602278][] 
>> memory_block_change_state+0x79/0xe0
>> [  201.602282][] store_mem_state+0xc2/0xd0
>> [  201.602287][] dev_attr_store+0x20/0x30
>> [  201.602293][] sysfs_write_file+0xa3/0x100
>> [  201.602299][] vfs_write+0xd0/0x1a0
>> [  201.602304][] sys_write+0x54/0xa0
>> [  201.602309][] system_call_fastpath+0x16/0x1b
>> [  201.602315]
>> [  201.602315] -> #0 ((memory_chain).rwsem){.+.+.+}:
>> [  201.602322][] check_prev_add+0x527/0x550
>> [  201.602326][] validate_chain+0x6d9/0x7e0
>> [  201.602331][] __lock_acquire+0x2f6/0x4f0
>> [  201.602335][] loc

[tip:core/locking] locking: Adjust spin lock inlining Kconfig options

2012-09-13 Thread tip-bot for Jan Beulich
Commit-ID:  4fe84fb8c6b5081f7364af63aee8e118a665b966
Gitweb: http://git.kernel.org/tip/4fe84fb8c6b5081f7364af63aee8e118a665b966
Author: Jan Beulich 
AuthorDate: Mon, 10 Sep 2012 13:01:16 +0100
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 17:56:13 +0200

locking: Adjust spin lock inlining Kconfig options

Break out the DEBUG_SPINLOCK dependency (requires moving up
UNINLINE_SPIN_UNLOCK, as this was the only one in that block not
depending on that option).

Avoid putting values not selected into the resulting .config -
they are not useful for anything, make the output less legible,
and just consume space: Use "depends on" rather than directly
setting the default from the combined dependency values.

Signed-off-by: Jan Beulich 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/504df2ac02780009a...@nat28.tlf.novell.com
Signed-off-by: Ingo Molnar 
---
 kernel/Kconfig.locks |  103 ++---
 1 files changed, 63 insertions(+), 40 deletions(-)

diff --git a/kernel/Kconfig.locks b/kernel/Kconfig.locks
index 2251882..44511d1 100644
--- a/kernel/Kconfig.locks
+++ b/kernel/Kconfig.locks
@@ -87,6 +87,9 @@ config ARCH_INLINE_WRITE_UNLOCK_IRQ
 config ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
bool
 
+config UNINLINE_SPIN_UNLOCK
+   bool
+
 #
 # lock_* functions are inlined when:
 #   - DEBUG_SPINLOCK=n and GENERIC_LOCKBREAK=n and ARCH_INLINE_*LOCK=y
@@ -103,100 +106,120 @@ config ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
 #   - DEBUG_SPINLOCK=n and ARCH_INLINE_*LOCK=y
 #
 
+if !DEBUG_SPINLOCK
+
 config INLINE_SPIN_TRYLOCK
-   def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_TRYLOCK
+   def_bool y
+   depends on ARCH_INLINE_SPIN_TRYLOCK
 
 config INLINE_SPIN_TRYLOCK_BH
-   def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_TRYLOCK_BH
+   def_bool y
+   depends on ARCH_INLINE_SPIN_TRYLOCK_BH
 
 config INLINE_SPIN_LOCK
-   def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK
+   def_bool y
+   depends on !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK
 
 config INLINE_SPIN_LOCK_BH
-   def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
-ARCH_INLINE_SPIN_LOCK_BH
+   def_bool y
+   depends on !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK_BH
 
 config INLINE_SPIN_LOCK_IRQ
-   def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
-ARCH_INLINE_SPIN_LOCK_IRQ
+   def_bool y
+   depends on !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK_IRQ
 
 config INLINE_SPIN_LOCK_IRQSAVE
-   def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
-ARCH_INLINE_SPIN_LOCK_IRQSAVE
-
-config UNINLINE_SPIN_UNLOCK
-   bool
+   def_bool y
+   depends on !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK_IRQSAVE
 
 config INLINE_SPIN_UNLOCK_BH
-   def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_UNLOCK_BH
+   def_bool y
+   depends on ARCH_INLINE_SPIN_UNLOCK_BH
 
 config INLINE_SPIN_UNLOCK_IRQ
-   def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_SPIN_UNLOCK_BH)
+   def_bool y
+   depends on !PREEMPT || ARCH_INLINE_SPIN_UNLOCK_BH
 
 config INLINE_SPIN_UNLOCK_IRQRESTORE
-   def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE
+   def_bool y
+   depends on ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE
 
 
 config INLINE_READ_TRYLOCK
-   def_bool !DEBUG_SPINLOCK && ARCH_INLINE_READ_TRYLOCK
+   def_bool y
+   depends on ARCH_INLINE_READ_TRYLOCK
 
 config INLINE_READ_LOCK
-   def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK
+   def_bool y
+   depends on !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK
 
 config INLINE_READ_LOCK_BH
-   def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
-ARCH_INLINE_READ_LOCK_BH
+   def_bool y
+   depends on !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK_BH
 
 config INLINE_READ_LOCK_IRQ
-   def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
-ARCH_INLINE_READ_LOCK_IRQ
+   def_bool y
+   depends on !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK_IRQ
 
 config INLINE_READ_LOCK_IRQSAVE
-   def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
-ARCH_INLINE_READ_LOCK_IRQSAVE
+   def_bool y
+   depends on !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK_IRQSAVE
 
 config INLINE_READ_UNLOCK
-   def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_READ_UNLOCK)
+   def_bool y
+   depends on !PREEMPT || ARCH_INLINE_READ_UNLOCK
 
 config INLINE_READ_UNLOCK_BH
-   def_bool !DEBUG_SPINLOCK && ARCH_INLINE_READ_UNLOCK_BH
+   def_bool y
+   depends on ARCH_INLINE_READ_UNLOCK_BH
 
 config INLINE_READ_UNLOCK_IRQ
-   def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_READ_UNLOCK_BH)
+   def_bool y
+   depends on !PREEMPT || ARCH_INLINE_READ_UNLOCK_BH
 
 config INLINE_READ_UNLOCK_IRQRESTORE
-   def_bool !DEBUG_SPINLOCK && ARCH_INLINE_READ_UNLOCK_IRQRESTORE
+   def_bool 

[tip:x86/build] x86/Kconfig: Clean up Kconfig defaults

2012-09-13 Thread tip-bot for Jan Beulich
Commit-ID:  3120e25efdc0834c88e1c0f8394e2087444f8c19
Gitweb: http://git.kernel.org/tip/3120e25efdc0834c88e1c0f8394e2087444f8c19
Author: Jan Beulich 
AuthorDate: Mon, 10 Sep 2012 12:41:45 +0100
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 17:45:33 +0200

x86/Kconfig: Clean up Kconfig defaults

The main goal here is to have the resulting .config no carry any
options that aren't enabled and can't be (i.e such where the
default is "no" and can't be changed), so that if any such
option later gets a user visible prompt, the user will actually
be prompted on a "make ...oldconfig" rather than keeping the
previously invisible option disabled.

There's a little bit of other trivial cleanup mixed in here.

Signed-off-by: Jan Beulich 
Cc: Linus Torvalds 
Link: http://lkml.kernel.org/r/504dee1902780009a...@nat28.tlf.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/Kconfig |   50 ++
 arch/x86/Kconfig.cpu |5 +++--
 2 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 8ec3a1a..3fb8719 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -7,11 +7,13 @@ config 64BIT
  Say no to build a 32-bit kernel - formerly known as i386
 
 config X86_32
-   def_bool !64BIT
+   def_bool y
+   depends on !64BIT
select CLKSRC_I8253
 
 config X86_64
-   def_bool 64BIT
+   def_bool y
+   depends on 64BIT
select X86_DEV_DMA_OPS
 
 ### Arch settings
@@ -99,7 +101,8 @@ config X86
select GENERIC_STRNLEN_USER
 
 config INSTRUCTION_DECODER
-   def_bool (KPROBES || PERF_EVENTS || UPROBES)
+   def_bool y
+   depends on KPROBES || PERF_EVENTS || UPROBES
 
 config OUTPUT_FORMAT
string
@@ -127,13 +130,15 @@ config SBUS
bool
 
 config NEED_DMA_MAP_STATE
-   def_bool (X86_64 || INTEL_IOMMU || DMA_API_DEBUG)
+   def_bool y
+   depends on X86_64 || INTEL_IOMMU || DMA_API_DEBUG
 
 config NEED_SG_DMA_LENGTH
def_bool y
 
 config GENERIC_ISA_DMA
-   def_bool ISA_DMA_API
+   def_bool y
+   depends on ISA_DMA_API
 
 config GENERIC_BUG
def_bool y
@@ -150,13 +155,16 @@ config GENERIC_GPIO
bool
 
 config ARCH_MAY_HAVE_PC_FDC
-   def_bool ISA_DMA_API
+   def_bool y
+   depends on ISA_DMA_API
 
 config RWSEM_GENERIC_SPINLOCK
-   def_bool !X86_XADD
+   def_bool y
+   depends on !X86_XADD
 
 config RWSEM_XCHGADD_ALGORITHM
-   def_bool X86_XADD
+   def_bool y
+   depends on X86_XADD
 
 config GENERIC_CALIBRATE_DELAY
def_bool y
@@ -752,7 +760,8 @@ config SWIOTLB
  3 GB of memory. If unsure, say Y.
 
 config IOMMU_HELPER
-   def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB || AMD_IOMMU)
+   def_bool y
+   depends on CALGARY_IOMMU || GART_IOMMU || SWIOTLB || AMD_IOMMU
 
 config MAXSMP
bool "Enable Maximum number of SMP Processors and NUMA Nodes"
@@ -1159,10 +1168,12 @@ config X86_PAE
  consumes more pagetable space per process.
 
 config ARCH_PHYS_ADDR_T_64BIT
-   def_bool X86_64 || X86_PAE
+   def_bool y
+   depends on X86_64 || X86_PAE
 
 config ARCH_DMA_ADDR_T_64BIT
-   def_bool X86_64 || HIGHMEM64G
+   def_bool y
+   depends on X86_64 || HIGHMEM64G
 
 config DIRECT_GBPAGES
bool "Enable 1GB pages for kernel pagetables" if EXPERT
@@ -1285,8 +1296,8 @@ config ARCH_SELECT_MEMORY_MODEL
depends on ARCH_SPARSEMEM_ENABLE
 
 config ARCH_MEMORY_PROBE
-   def_bool X86_64
-   depends on MEMORY_HOTPLUG
+   def_bool y
+   depends on X86_64 && MEMORY_HOTPLUG
 
 config ARCH_PROC_KCORE_TEXT
def_bool y
@@ -1975,7 +1986,6 @@ config PCI_MMCONFIG
 
 config PCI_CNB20LE_QUIRK
bool "Read CNB20LE Host Bridge Windows" if EXPERT
-   default n
depends on PCI && EXPERIMENTAL
help
  Read the PCI windows out of the CNB20LE host bridge. This allows
@@ -2186,18 +2196,18 @@ config COMPAT
depends on IA32_EMULATION || X86_X32
select ARCH_WANT_OLD_COMPAT_IPC
 
+if COMPAT
 config COMPAT_FOR_U64_ALIGNMENT
-   def_bool COMPAT
-   depends on X86_64
+   def_bool y
 
 config SYSVIPC_COMPAT
def_bool y
-   depends on COMPAT && SYSVIPC
+   depends on SYSVIPC
 
 config KEYS_COMPAT
-   bool
-   depends on COMPAT && KEYS
-   default y
+   def_bool y
+   depends on KEYS
+endif
 
 endmenu
 
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 706e12e..f3b86d0 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -306,7 +306,8 @@ config X86_INTERNODE_CACHE_SHIFT
default X86_L1_CACHE_SHIFT
 
 config X86_CMPXCHG
-   def_bool X86_64 || (X86_32 && !M386)
+   def_bool y
+   depends on X86_64 || (X86_32 && !M386)
 
 config X86_L1_CACHE_SHIFT
int
@@ -317,7 +318,7 @@ config X86_L1_CACHE_SHIFT
 
 config X86_XADD
def_bool y
-   depends on X86_64 || !M386
+   depe

[tip:x86/asm] x86: Prefer TZCNT over BFS

2012-09-13 Thread tip-bot for Jan Beulich
Commit-ID:  5870661c091e827973674cc3469b50c959008c2b
Gitweb: http://git.kernel.org/tip/5870661c091e827973674cc3469b50c959008c2b
Author: Jan Beulich 
AuthorDate: Mon, 10 Sep 2012 12:24:43 +0100
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 17:44:01 +0200

x86: Prefer TZCNT over BFS

Following a relatively recent compiler change, make use of the
fact that for non-zero input BSF and TZCNT produce the same
result, and that CPUs not knowing of TZCNT will treat the
instruction as BSF (i.e. ignore what looks like a REP prefix to
them). The assumption here is that TZCNT would never have worse
performance than BSF.

For the moment, only do this when the respective generic-CPU
option is selected (as there are no specific-CPU options
covering the CPUs supporting TZCNT), and don't do that when size
optimization was requested.

Signed-off-by: Jan Beulich 
Cc: Linus Torvalds 
Link: http://lkml.kernel.org/r/504dea1b02780009a...@nat28.tlf.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/bitops.h |   19 +--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index ebaee69..b2af664 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -347,6 +347,19 @@ static int test_bit(int nr, const volatile unsigned long 
*addr);
 ? constant_test_bit((nr), (addr))  \
 : variable_test_bit((nr), (addr)))
 
+#if (defined(CONFIG_X86_GENERIC) || defined(CONFIG_GENERIC_CPU)) \
+&& !defined(CONFIG_CC_OPTIMIZE_FOR_SIZE)
+/*
+ * Since BSF and TZCNT have sufficiently similar semantics for the purposes
+ * for which we use them here, BMI-capable hardware will decode the prefixed
+ * variant as 'tzcnt ...' and may execute that faster than 'bsf ...', while
+ * older hardware will ignore the REP prefix and decode it as 'bsf ...'.
+ */
+# define BSF_PREFIX "rep;"
+#else
+# define BSF_PREFIX
+#endif
+
 /**
  * __ffs - find first set bit in word
  * @word: The word to search
@@ -355,7 +368,7 @@ static int test_bit(int nr, const volatile unsigned long 
*addr);
  */
 static inline unsigned long __ffs(unsigned long word)
 {
-   asm("bsf %1,%0"
+   asm(BSF_PREFIX "bsf %1,%0"
: "=r" (word)
: "rm" (word));
return word;
@@ -369,12 +382,14 @@ static inline unsigned long __ffs(unsigned long word)
  */
 static inline unsigned long ffz(unsigned long word)
 {
-   asm("bsf %1,%0"
+   asm(BSF_PREFIX "bsf %1,%0"
: "=r" (word)
: "r" (~word));
return word;
 }
 
+#undef BSF_PREFIX
+
 /*
  * __fls: find last set bit in word
  * @word: The word to search
--
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:x86/asm] x86/64: Adjust types of temporaries used by ffs()/ fls()/fls64()

2012-09-13 Thread tip-bot for Jan Beulich
Commit-ID:  1edfbb4153bd29bcf8d2236676238d5237972be1
Gitweb: http://git.kernel.org/tip/1edfbb4153bd29bcf8d2236676238d5237972be1
Author: Jan Beulich 
AuthorDate: Mon, 10 Sep 2012 12:04:16 +0100
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 17:43:58 +0200

x86/64: Adjust types of temporaries used by ffs()/fls()/fls64()

The 64-bit special cases of the former two (the thrird one is
64-bit only anyway) don't need to use "long" temporaries, as the
result will always fit in a 32-bit variable, and the functions
return plain "int". This avoids a few REX prefixes, i.e.
minimally reduces code size.

Signed-off-by: Jan Beulich 
Cc: Linus Torvalds 
Link: http://lkml.kernel.org/r/504de55002780009a...@nat28.tlf.novell.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/bitops.h |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 72f5009..ebaee69 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -417,10 +417,9 @@ static inline int ffs(int x)
 * We cannot do this on 32 bits because at the very least some
 * 486 CPUs did not behave this way.
 */
-   long tmp = -1;
asm("bsfl %1,%0"
: "=r" (r)
-   : "rm" (x), "0" (tmp));
+   : "rm" (x), "0" (-1));
 #elif defined(CONFIG_X86_CMOV)
asm("bsfl %1,%0\n\t"
"cmovzl %2,%0"
@@ -459,10 +458,9 @@ static inline int fls(int x)
 * We cannot do this on 32 bits because at the very least some
 * 486 CPUs did not behave this way.
 */
-   long tmp = -1;
asm("bsrl %1,%0"
: "=r" (r)
-   : "rm" (x), "0" (tmp));
+   : "rm" (x), "0" (-1));
 #elif defined(CONFIG_X86_CMOV)
asm("bsrl %1,%0\n\t"
"cmovzl %2,%0"
@@ -490,13 +488,13 @@ static inline int fls(int x)
 #ifdef CONFIG_X86_64
 static __always_inline int fls64(__u64 x)
 {
-   long bitpos = -1;
+   int bitpos = -1;
/*
 * AMD64 says BSRQ won't clobber the dest reg if x==0; Intel64 says the
 * dest reg is undefined if x==0, but their CPU architect says its
 * value is written to set it to the same as before.
 */
-   asm("bsrq %1,%0"
+   asm("bsrq %1,%q0"
: "+r" (bitpos)
: "rm" (x));
return bitpos + 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/


[tip:timers/urgent] time: Fix timeekeping_get_ns overflow on 32bit systems

2012-09-13 Thread tip-bot for John Stultz
Commit-ID:  ec145babe754f9ea1079034a108104b6001e001c
Gitweb: http://git.kernel.org/tip/ec145babe754f9ea1079034a108104b6001e001c
Author: John Stultz 
AuthorDate: Tue, 11 Sep 2012 19:26:03 -0400
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 17:39:14 +0200

time: Fix timeekeping_get_ns overflow on 32bit systems

Daniel Lezcano reported seeing multi-second stalls from
keyboard input on his T61 laptop when NOHZ and CPU_IDLE
were enabled on a 32bit kernel.

He bisected the problem down to commit
1e75fa8be9fb6 ("time: Condense timekeeper.xtime into xtime_sec").

After reproducing this issue, I narrowed the problem down
to the fact that timekeeping_get_ns() returns a 64bit
nsec value that hasn't been accumulated. In some cases
this value was being then stored in timespec.tv_nsec
(which is a long).

On 32bit systems, with idle times larger then 4 seconds
(or less, depending on the value of xtime_nsec), the
returned nsec value would overflow 32bits. This limited
kept time from increasing, causing timers to not expire.

The fix is to make sure we don't directly store the
result of timekeeping_get_ns() into a tv_nsec field,
instead using a 64bit nsec value which can then be
added into the timespec via timespec_add_ns().

Reported-and-bisected-by: Daniel Lezcano 
Tested-by: Daniel Lezcano 
Signed-off-by: John Stultz 
Acked-by: Prarit Bhargava 
Cc: Richard Cochran 
Link: 
http://lkml.kernel.org/r/1347405963-35715-1-git-send-email-john.stu...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/time/timekeeping.c |   19 ---
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 34e5eac..d3b91e7 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -303,10 +303,11 @@ void getnstimeofday(struct timespec *ts)
seq = read_seqbegin(&tk->lock);
 
ts->tv_sec = tk->xtime_sec;
-   ts->tv_nsec = timekeeping_get_ns(tk);
+   nsecs = timekeeping_get_ns(tk);
 
} while (read_seqretry(&tk->lock, seq));
 
+   ts->tv_nsec = 0;
timespec_add_ns(ts, nsecs);
 }
 EXPORT_SYMBOL(getnstimeofday);
@@ -345,6 +346,7 @@ void ktime_get_ts(struct timespec *ts)
 {
struct timekeeper *tk = &timekeeper;
struct timespec tomono;
+   s64 nsec;
unsigned int seq;
 
WARN_ON(timekeeping_suspended);
@@ -352,13 +354,14 @@ void ktime_get_ts(struct timespec *ts)
do {
seq = read_seqbegin(&tk->lock);
ts->tv_sec = tk->xtime_sec;
-   ts->tv_nsec = timekeeping_get_ns(tk);
+   nsec = timekeeping_get_ns(tk);
tomono = tk->wall_to_monotonic;
 
} while (read_seqretry(&tk->lock, seq));
 
-   set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec,
-   ts->tv_nsec + tomono.tv_nsec);
+   ts->tv_sec += tomono.tv_sec;
+   ts->tv_nsec = 0;
+   timespec_add_ns(ts, nsec + tomono.tv_nsec);
 }
 EXPORT_SYMBOL_GPL(ktime_get_ts);
 
@@ -1244,6 +1247,7 @@ void get_monotonic_boottime(struct timespec *ts)
 {
struct timekeeper *tk = &timekeeper;
struct timespec tomono, sleep;
+   s64 nsec;
unsigned int seq;
 
WARN_ON(timekeeping_suspended);
@@ -1251,14 +1255,15 @@ void get_monotonic_boottime(struct timespec *ts)
do {
seq = read_seqbegin(&tk->lock);
ts->tv_sec = tk->xtime_sec;
-   ts->tv_nsec = timekeeping_get_ns(tk);
+   nsec = timekeeping_get_ns(tk);
tomono = tk->wall_to_monotonic;
sleep = tk->total_sleep_time;
 
} while (read_seqretry(&tk->lock, seq));
 
-   set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec,
-   ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec);
+   ts->tv_sec += tomono.tv_sec + sleep.tv_sec;
+   ts->tv_nsec = 0;
+   timespec_add_ns(ts, nsec + tomono.tv_nsec + sleep.tv_nsec);
 }
 EXPORT_SYMBOL_GPL(get_monotonic_boottime);
 
--
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:x86/urgent] x86/mm/init.c: Fix devmem_is_allowed() off by one

2012-09-13 Thread tip-bot for T Makphaibulchoke
Commit-ID:  73e8f3d7e2cb23614d5115703d76d8e54764b641
Gitweb: http://git.kernel.org/tip/73e8f3d7e2cb23614d5115703d76d8e54764b641
Author: T Makphaibulchoke 
AuthorDate: Tue, 28 Aug 2012 21:21:43 -0600
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 17:35:54 +0200

x86/mm/init.c: Fix devmem_is_allowed() off by one

Fixing an off-by-one error in devmem_is_allowed(), which allows
accesses to physical addresses 0x10-0x100fff, an extra page
past 1MB.

Signed-off-by: T Makphaibulchoke 
Acked-by: H. Peter Anvin 
Cc: ying...@kernel.org
Cc: ti...@suse.de
Cc: dhowe...@redhat.com
Link: http://lkml.kernel.org/r/1346210503-14276-1-git-send-email-t...@hp.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/init.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index e0e6990..ab1f6a9 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -319,7 +319,7 @@ unsigned long __init_refok init_memory_mapping(unsigned 
long start,
  */
 int devmem_is_allowed(unsigned long pagenr)
 {
-   if (pagenr <= 256)
+   if (pagenr < 256)
return 1;
if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
return 0;
--
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:x86/asm] x86: Drop unnecessary kernel_eflags variable on 64-bit

2012-09-13 Thread tip-bot for Ian Campbell
Commit-ID:  6eebdda35e6b18d0dddb2a44e34211bd94f0cad6
Gitweb: http://git.kernel.org/tip/6eebdda35e6b18d0dddb2a44e34211bd94f0cad6
Author: Ian Campbell 
AuthorDate: Fri, 24 Aug 2012 23:58:47 +0400
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 17:32:47 +0200

x86: Drop unnecessary kernel_eflags variable on 64-bit

On 64 bit x86 we save the current eflags in cpu_init for use in
ret_from_fork. Strictly speaking reserved bits in EFLAGS should
be read as written but in practise it is unlikely that EFLAGS
could ever be extended in this way and the kernel alread clears
any undefined flags early on.

The equivalent 32 bit code simply hard codes 0x0202 as the new
EFLAGS.

This change makes 64 bit use the same mechanism to setup the
initial EFLAGS on fork. Note that 64 bit resets EFLAGS before
calling schedule_tail() as opposed to 32 bit which calls
schedule_tail() first. Therefore the correct value for EFLAGS
has opposite IF bit.

Signed-off-by: Ian Campbell 
Signed-off-by: Cyrill Gorcunov 
Acked-by: Andi Kleen 
Acked-by: "H. Peter Anvin" 
Cc: Brian Gerst 
Cc: Peter Zijlstra 
Cc: Pekka Enberg 
Cc: Andi Kleen 
Link: http://lkml.kernel.org/r/20120824195847.GA31628@moon
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/processor.h |1 -
 arch/x86/kernel/cpu/common.c |4 
 arch/x86/kernel/entry_64.S   |2 +-
 3 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index d048cad..9738b39 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -423,7 +423,6 @@ DECLARE_INIT_PER_CPU(irq_stack_union);
 
 DECLARE_PER_CPU(char *, irq_stack_ptr);
 DECLARE_PER_CPU(unsigned int, irq_count);
-extern unsigned long kernel_eflags;
 extern asmlinkage void ignore_sysret(void);
 #else  /* X86_64 */
 #ifdef CONFIG_CC_STACKPROTECTOR
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index a5fbc3c..9961e2e 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1116,8 +1116,6 @@ void syscall_init(void)
   X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|X86_EFLAGS_IOPL);
 }
 
-unsigned long kernel_eflags;
-
 /*
  * Copies of the original ist values from the tss are only accessed during
  * debugging, no special alignment required.
@@ -1299,8 +1297,6 @@ void __cpuinit cpu_init(void)
fpu_init();
xsave_init();
 
-   raw_local_save_flags(kernel_eflags);
-
if (is_uv_system())
uv_cpu_init();
 }
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 69babd8..b1dac12 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -440,7 +440,7 @@ ENTRY(ret_from_fork)
 
LOCK ; btr $TIF_FORK,TI_flags(%r8)
 
-   pushq_cfi kernel_eflags(%rip)
+   pushq_cfi $0x0002
popfq_cfi   # reset kernel eflags
 
call schedule_tail  # rdi: 'prev' task parameter
--
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:core/locking] lockdep: Check if nested lock is actually held

2012-09-13 Thread tip-bot for Maarten Lankhorst
Commit-ID:  d094595078d00b63839d0c5ccb8b184ef242cb45
Gitweb: http://git.kernel.org/tip/d094595078d00b63839d0c5ccb8b184ef242cb45
Author: Maarten Lankhorst 
AuthorDate: Thu, 13 Sep 2012 11:39:51 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 17:00:44 +0200

lockdep: Check if nested lock is actually held

It is considered good form to lock the lock you claim to be nested in.

Signed-off-by: Maarten Lankhorst 

[ removed nest_lock arg to print_lock_nested_lock_not_held in favour
  of hlock->nest_lock, also renamed the lock arg to hlock since its
  a held_lock type ]
Signed-off-by: Peter Zijlstra 
Link: http://lkml.kernel.org/r/5051a9e7.5040...@canonical.com
Signed-off-by: Ingo Molnar 
---
 kernel/lockdep.c |   39 +++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index ea9ee45..7981e5b 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2998,6 +2998,42 @@ EXPORT_SYMBOL_GPL(lockdep_init_map);
 
 struct lock_class_key __lockdep_no_validate__;
 
+static int
+print_lock_nested_lock_not_held(struct task_struct *curr,
+   struct held_lock *hlock,
+   unsigned long ip)
+{
+   if (!debug_locks_off())
+   return 0;
+   if (debug_locks_silent)
+   return 0;
+
+   printk("\n");
+   printk("==\n");
+   printk("[ BUG: Nested lock was not taken ]\n");
+   print_kernel_ident();
+   printk("--\n");
+
+   printk("%s/%d is trying to lock:\n", curr->comm, task_pid_nr(curr));
+   print_lock(hlock);
+
+   printk("\nbut this task is not holding:\n");
+   printk("%s\n", hlock->nest_lock->name);
+
+   printk("\nstack backtrace:\n");
+   dump_stack();
+
+   printk("\nother info that might help us debug this:\n");
+   lockdep_print_held_locks(curr);
+
+   printk("\nstack backtrace:\n");
+   dump_stack();
+
+   return 0;
+}
+
+static int __lock_is_held(struct lockdep_map *lock);
+
 /*
  * This gets called for every mutex_lock*()/spin_lock*() operation.
  * We maintain the dependency maps and validate the locking attempt:
@@ -3139,6 +3175,9 @@ static int __lock_acquire(struct lockdep_map *lock, 
unsigned int subclass,
}
chain_key = iterate_chain_key(chain_key, id);
 
+   if (nest_lock && !__lock_is_held(nest_lock))
+   return print_lock_nested_lock_not_held(curr, hlock, ip);
+
if (!validate_chain(curr, lock, hlock, chain_head, chain_key))
return 0;
 
--
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/urgent] perf/x86: Export Sandy Bridge uncore clockticks event in sysfs

2012-09-13 Thread tip-bot for Stephane Eranian
Commit-ID:  35534b201c9f115c68962c095b5a9aad204d025f
Gitweb: http://git.kernel.org/tip/35534b201c9f115c68962c095b5a9aad204d025f
Author: Stephane Eranian 
AuthorDate: Wed, 29 Aug 2012 15:01:22 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 16:59:46 +0200

perf/x86: Export Sandy Bridge uncore clockticks event in sysfs

This patch exports the clockticks event and its encoding to user level.
The clockticks event was exported for Nehalem/Westmere but not for Sandy
Bridge (client). Given that it uses a special encoding, it needs to be
exported to user tools, so users can do:

  # perf stat -a -C 0 -e uncore_cbox_0/clockticks/ sleep 1

Signed-off-by: Stephane Eranian 
Acked-by: Yan, Zheng 
Signed-off-by: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20120829130122.GA32336@quad
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c 
b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 0a55710..38e4894 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -661,6 +661,11 @@ static void snb_uncore_msr_init_box(struct 
intel_uncore_box *box)
}
 }
 
+static struct uncore_event_desc snb_uncore_events[] = {
+   INTEL_UNCORE_EVENT_DESC(clockticks, "event=0xff,umask=0x00"),
+   { /* end: all zeroes */ },
+};
+
 static struct attribute *snb_uncore_formats_attr[] = {
&format_attr_event.attr,
&format_attr_umask.attr,
@@ -704,6 +709,7 @@ static struct intel_uncore_type snb_uncore_cbox = {
.constraints= snb_uncore_cbox_constraints,
.ops= &snb_uncore_msr_ops,
.format_group   = &snb_uncore_format_group,
+   .event_descs= snb_uncore_events,
 };
 
 static struct intel_uncore_type *snb_msr_uncores[] = {
--
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:sched/core] sched/nohz: Clean up select_nohz_load_balancer()

2012-09-13 Thread tip-bot for Alex Shi
Commit-ID:  c1cc017c59c44d9ede7003631c43adc0cfdce2f9
Gitweb: http://git.kernel.org/tip/c1cc017c59c44d9ede7003631c43adc0cfdce2f9
Author: Alex Shi 
AuthorDate: Mon, 10 Sep 2012 15:10:58 +0800
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 16:52:05 +0200

sched/nohz: Clean up select_nohz_load_balancer()

There is no load_balancer to be selected now. It just sets the
state of the nohz tick to stop.

So rename the function, pass the 'cpu' as a parameter and then
remove the useless call from tick_nohz_restart_sched_tick().

[ s/set_nohz_tick_stopped/nohz_balance_enter_idle/g
  s/clear_nohz_tick_stopped/nohz_balance_exit_idle/g ]
Signed-off-by: Alex Shi 
Acked-by: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Signed-off-by: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1347261059-24747-1-git-send-email-alex@intel.com
Signed-off-by: Ingo Molnar 
---
 include/linux/sched.h|4 ++--
 kernel/sched/fair.c  |   25 ++---
 kernel/time/tick-sched.c |3 +--
 3 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 60e5e38..8c38df0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -273,11 +273,11 @@ extern void init_idle_bootup_task(struct task_struct 
*idle);
 extern int runqueue_is_locked(int cpu);
 
 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
-extern void select_nohz_load_balancer(int stop_tick);
+extern void nohz_balance_enter_idle(int cpu);
 extern void set_cpu_sd_state_idle(void);
 extern int get_nohz_timer_target(void);
 #else
-static inline void select_nohz_load_balancer(int stop_tick) { }
+static inline void nohz_balance_enter_idle(int cpu) { }
 static inline void set_cpu_sd_state_idle(void) { }
 #endif
 
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9ae3a5b..de596a2 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4603,7 +4603,7 @@ static void nohz_balancer_kick(int cpu)
return;
 }
 
-static inline void clear_nohz_tick_stopped(int cpu)
+static inline void nohz_balance_exit_idle(int cpu)
 {
if (unlikely(test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu {
cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
@@ -4643,28 +4643,23 @@ void set_cpu_sd_state_idle(void)
 }
 
 /*
- * This routine will record that this cpu is going idle with tick stopped.
+ * This routine will record that the cpu is going idle with tick stopped.
  * This info will be used in performing idle load balancing in the future.
  */
-void select_nohz_load_balancer(int stop_tick)
+void nohz_balance_enter_idle(int cpu)
 {
-   int cpu = smp_processor_id();
-
/*
 * If this cpu is going down, then nothing needs to be done.
 */
if (!cpu_active(cpu))
return;
 
-   if (stop_tick) {
-   if (test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))
-   return;
+   if (test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))
+   return;
 
-   cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
-   atomic_inc(&nohz.nr_cpus);
-   set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
-   }
-   return;
+   cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
+   atomic_inc(&nohz.nr_cpus);
+   set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
 }
 
 static int __cpuinit sched_ilb_notifier(struct notifier_block *nfb,
@@ -4672,7 +4667,7 @@ static int __cpuinit sched_ilb_notifier(struct 
notifier_block *nfb,
 {
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_DYING:
-   clear_nohz_tick_stopped(smp_processor_id());
+   nohz_balance_exit_idle(smp_processor_id());
return NOTIFY_OK;
default:
return NOTIFY_DONE;
@@ -4833,7 +4828,7 @@ static inline int nohz_kick_needed(struct rq *rq, int cpu)
* busy tick after returning from idle, we will update the busy stats.
*/
set_cpu_sd_state_busy();
-   clear_nohz_tick_stopped(cpu);
+   nohz_balance_exit_idle(cpu);
 
/*
 * None are in tickless mode and hence no need for NOHZ idle load
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 3a9e5d5..1a5ee90 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -372,7 +372,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched 
*ts,
 * the scheduler tick in nohz_restart_sched_tick.
 */
if (!ts->tick_stopped) {
-   select_nohz_load_balancer(1);
+   nohz_balance_enter_idle(cpu);
calc_load_enter_idle();
 
ts->last_tick = hrtimer_get_expires(&ts->sched_timer);
@@ -569,7 +569,6 @@ static void tick_nohz_restart(struct tick_sched *ts, 
ktime_t now)
 static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now)
 {
/* Update jiffies first */
-   select_nohz_load_balancer(0);
tick_do_up

[tip:sched/core] sched: Fix load avg vs. cpu-hotplug

2012-09-13 Thread tip-bot for Peter Zijlstra
Commit-ID:  08bedae1d0acd8c9baf514fb69fa199d0c8345f6
Gitweb: http://git.kernel.org/tip/08bedae1d0acd8c9baf514fb69fa199d0c8345f6
Author: Peter Zijlstra 
AuthorDate: Thu, 6 Sep 2012 00:03:50 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 16:52:05 +0200

sched: Fix load avg vs. cpu-hotplug

Commit f319da0c68 ("sched: Fix load avg vs cpu-hotplug") was an
incomplete fix:

In particular, the problem is that at the point it calls
calc_load_migrate() nr_running := 1 (the stopper thread), so move the
call to CPU_DEAD where we're sure that nr_running := 0.

Also note that we can call calc_load_migrate() without serialization, we
know the state of rq is stable since its cpu is dead, and we modify the
global state using appropriate atomic ops.

Suggested-by: Paul E. McKenney 
Signed-off-by: Peter Zijlstra 
Link: http://lkml.kernel.org/r/1346882630.2600.59.camel@twins
Signed-off-by: Ingo Molnar 
---
 kernel/sched/core.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8b51b2d..ba144b1 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5048,7 +5048,9 @@ migration_call(struct notifier_block *nfb, unsigned long 
action, void *hcpu)
migrate_tasks(cpu);
BUG_ON(rq->nr_running != 1); /* the migration thread */
raw_spin_unlock_irqrestore(&rq->lock, flags);
+   break;
 
+   case CPU_DEAD:
calc_load_migrate(rq);
break;
 #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:sched/core] sched: Remove __ARCH_WANT_INTERRUPTS_ON_CTXSW

2012-09-13 Thread tip-bot for Peter Zijlstra
Commit-ID:  f3e947867478af9a12b9956bcd000ac7613a8a95
Gitweb: http://git.kernel.org/tip/f3e947867478af9a12b9956bcd000ac7613a8a95
Author: Peter Zijlstra 
AuthorDate: Wed, 12 Sep 2012 11:22:00 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 16:52:04 +0200

sched: Remove __ARCH_WANT_INTERRUPTS_ON_CTXSW

Now that the last architecture to use this has stopped doing so (ARM,
thanks Catalin!) we can remove this complexity from the scheduler
core.

Signed-off-by: Peter Zijlstra 
Cc: Oleg Nesterov 
Cc: Catalin Marinas 
Link: http://lkml.kernel.org/n/tip-g9p2a1w81xxbrze25v9zp...@git.kernel.org
Signed-off-by: Ingo Molnar 
---
 Documentation/scheduler/sched-arch.txt |   10 
 include/linux/sched.h  |5 
 kernel/fork.c  |4 ---
 kernel/sched/core.c|   40 +---
 kernel/sched/rt.c  |5 
 kernel/sched/sched.h   |6 
 6 files changed, 1 insertions(+), 69 deletions(-)

diff --git a/Documentation/scheduler/sched-arch.txt 
b/Documentation/scheduler/sched-arch.txt
index 28aa107..b1b8587 100644
--- a/Documentation/scheduler/sched-arch.txt
+++ b/Documentation/scheduler/sched-arch.txt
@@ -17,16 +17,6 @@ you must `#define __ARCH_WANT_UNLOCKED_CTXSW` in a header 
file
 Unlocked context switches introduce only a very minor performance
 penalty to the core scheduler implementation in the CONFIG_SMP case.
 
-2. Interrupt status
-By default, the switch_to arch function is called with interrupts
-disabled. Interrupts may be enabled over the call if it is likely to
-introduce a significant interrupt latency by adding the line
-`#define __ARCH_WANT_INTERRUPTS_ON_CTXSW` in the same place as for
-unlocked context switches. This define also implies
-`__ARCH_WANT_UNLOCKED_CTXSW`. See arch/arm/include/asm/system.h for an
-example.
-
-
 CPU idle
 
 Your cpu_idle routines need to obey the following rules:
diff --git a/include/linux/sched.h b/include/linux/sched.h
index f3eebc1..60e5e38 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -678,11 +678,6 @@ struct signal_struct {
 * (notably. ptrace) */
 };
 
-/* Context switch must be unlocked if interrupts are to be enabled */
-#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
-# define __ARCH_WANT_UNLOCKED_CTXSW
-#endif
-
 /*
  * Bits in flags field of signal_struct.
  */
diff --git a/kernel/fork.c b/kernel/fork.c
index 2c8857e..743d48f 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1280,11 +1280,7 @@ static struct task_struct *copy_process(unsigned long 
clone_flags,
 #endif
 #ifdef CONFIG_TRACE_IRQFLAGS
p->irq_events = 0;
-#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
-   p->hardirqs_enabled = 1;
-#else
p->hardirqs_enabled = 0;
-#endif
p->hardirq_enable_ip = 0;
p->hardirq_enable_event = 0;
p->hardirq_disable_ip = _THIS_IP_;
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c46a011..8b51b2d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1361,25 +1361,6 @@ static void ttwu_queue_remote(struct task_struct *p, int 
cpu)
smp_send_reschedule(cpu);
 }
 
-#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
-static int ttwu_activate_remote(struct task_struct *p, int wake_flags)
-{
-   struct rq *rq;
-   int ret = 0;
-
-   rq = __task_rq_lock(p);
-   if (p->on_cpu) {
-   ttwu_activate(rq, p, ENQUEUE_WAKEUP);
-   ttwu_do_wakeup(rq, p, wake_flags);
-   ret = 1;
-   }
-   __task_rq_unlock(rq);
-
-   return ret;
-
-}
-#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */
-
 bool cpus_share_cache(int this_cpu, int that_cpu)
 {
return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
@@ -1440,21 +1421,8 @@ try_to_wake_up(struct task_struct *p, unsigned int 
state, int wake_flags)
 * If the owning (remote) cpu is still in the middle of schedule() with
 * this task as prev, wait until its done referencing the task.
 */
-   while (p->on_cpu) {
-#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
-   /*
-* In case the architecture enables interrupts in
-* context_switch(), we cannot busy wait, since that
-* would lead to deadlocks when an interrupt hits and
-* tries to wake up @prev. So bail and do a complete
-* remote wakeup.
-*/
-   if (ttwu_activate_remote(p, wake_flags))
-   goto stat;
-#else
+   while (p->on_cpu)
cpu_relax();
-#endif
-   }
/*
 * Pairs with the smp_wmb() in finish_lock_switch().
 */
@@ -1798,13 +1766,7 @@ static void finish_task_switch(struct rq *rq, struct 
task_struct *prev)
prev_state = prev->state;
account_switch_vtime(prev);
finish_arch_switch(prev);
-#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
-   loca

[tip:sched/core] sched: Fix nohz_idle_balance()

2012-09-13 Thread tip-bot for Vincent Guittot
Commit-ID:  5ed4f1d96deee82ee92cd1ac1e0108c27e80e9b0
Gitweb: http://git.kernel.org/tip/5ed4f1d96deee82ee92cd1ac1e0108c27e80e9b0
Author: Vincent Guittot 
AuthorDate: Thu, 13 Sep 2012 06:11:26 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 16:52:03 +0200

sched: Fix nohz_idle_balance()

On tickless systems, one CPU runs load balance for all idle CPUs.

The cpu_load of this CPU is updated before starting the load balance
of each other idle CPUs. We should instead update the cpu_load of
the balance_cpu.

Signed-off-by: Vincent Guittot 
Signed-off-by: Peter Zijlstra 
Cc: Venkatesh Pallipadi 
Cc: Suresh Siddha 
Link: 
http://lkml.kernel.org/r/1347509486-8688-1-git-send-email-vincent.guit...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1ca4fe4..9ae3a5b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4794,14 +4794,15 @@ static void nohz_idle_balance(int this_cpu, enum 
cpu_idle_type idle)
if (need_resched())
break;
 
-   raw_spin_lock_irq(&this_rq->lock);
-   update_rq_clock(this_rq);
-   update_idle_cpu_load(this_rq);
-   raw_spin_unlock_irq(&this_rq->lock);
+   rq = cpu_rq(balance_cpu);
+
+   raw_spin_lock_irq(&rq->lock);
+   update_rq_clock(rq);
+   update_idle_cpu_load(rq);
+   raw_spin_unlock_irq(&rq->lock);
 
rebalance_domains(balance_cpu, CPU_IDLE);
 
-   rq = cpu_rq(balance_cpu);
if (time_after(this_rq->next_balance, rq->next_balance))
this_rq->next_balance = rq->next_balance;
}
--
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 v3 4/5] IIO : ADC: tiadc: Add support of TI's ADC driver

2012-09-13 Thread Patil, Rachna
On Thu, Sep 13, 2012 at 18:21:19, Lars-Peter Clausen wrote:
> On 09/13/2012 12:40 PM, Patil, Rachna wrote:
> > This patch adds support for TI's ADC driver.
> > This is a multifunctional device.
> > Analog input lines are provided on which voltage measurements can be 
> > carried out.
> > You can have upto 8 input lines.
> > 
> 
> Hi,
> 
> couple of minor issues inline.

Hi,

Please find my comments inline.

> 
> > Signed-off-by: Patil, Rachna 
> > ---
> > Changes in v2:
> > Addressed review comments from Matthias Kaehlcke
> > 
> > Changes in v3:
> > Addressed review comments from Jonathan Cameron.
> > Added comments, new line appropriately.
> > 
> >  drivers/iio/adc/Kconfig  |7 +
> >  drivers/iio/adc/Makefile |1 +
> >  drivers/iio/adc/ti_adc.c |  223 
> > ++
> >  drivers/mfd/ti_tscadc.c  |   18 +++-
> >  include/linux/mfd/ti_tscadc.h|9 ++-
> >  include/linux/platform_data/ti_adc.h |   14 ++
> >  6 files changed, 270 insertions(+), 2 deletions(-)  create mode 
> > 100644 drivers/iio/adc/ti_adc.c  create mode 100644 
> > include/linux/platform_data/ti_adc.h
> > 
> [...]
> > +
> > +struct adc_device {
> 
> Not really an issue, but I'd use a consistent function/struct prefix.
> Currently you use both "adc" and "tiadc"

Ok. I will update this.

> 
> > +   struct ti_tscadc_dev *mfd_tscadc;
> > +   struct iio_dev *idev;
> 
> idev is used only once in the remove callback. But you can get a pointer to 
> it easily using platform_get_drvdata. So I'd remove it from the adc_device 
> struct.

Ok. I will remove this.

> 
> > +   int channels;
> > +};
> > +
> > +static unsigned int adc_readl(struct adc_device *adc, unsigned int 
> > +reg) {
> > +   return readl(adc->mfd_tscadc->tscadc_base + reg); }
> > +
> > +static void adc_writel(struct adc_device *adc, unsigned int reg,
> > +   unsigned int val)
> > +{
> > +   writel(val, adc->mfd_tscadc->tscadc_base + reg); }
> > +
> > +static void adc_step_config(struct adc_device *adc_dev) {
> > +   unsigned intstepconfig;
> 
> extra whitespace

Ok. I will remove this.

> 
> > +   int i, channels = 0, steps;
> > +
> > +   /*
> > +* There are 16 configurable steps and 8 analog input
> > +* lines available which are shared between Touchscreen and ADC.
> > +*
> > +* Steps backwards i.e. from 16 towards 0 are used by ADC
> > +* depending on number of input lines needed.
> > +* Channel would represent which analog input
> > +* needs to be given to ADC to digitalize data.
> > +*/
> > +
> > +   steps = TOTAL_STEPS - adc_dev->channels;
> > +   channels = TOTAL_CHANNELS - adc_dev->channels;
> > +
> > +   stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1;
> > +
> > +   for (i = (steps + 1); i <= TOTAL_STEPS; i++) {
> > +   adc_writel(adc_dev, REG_STEPCONFIG(i),
> > +   stepconfig | STEPCONFIG_INP(channels));
> > +   adc_writel(adc_dev, REG_STEPDELAY(i),
> > +   STEPCONFIG_OPENDLY);
> > +   channels++;
> > +   }
> > +   adc_writel(adc_dev, REG_SE, STPENB_STEPENB); }
> > +
> > [...]
> > +
> > +static const struct iio_info tiadc_info = {
> > +   .read_raw = &tiadc_read_raw,
> 
> .driver_module = THIS_MODULE,
> 
> > +};
> > +
> > +static int __devinit tiadc_probe(struct platform_device *pdev) {
> > +   struct iio_dev  *idev;
> 
> For consistency with other drivers please rename idev to indio_dev throughout 
> the driver.

Ok. I will rename this.

> 
> > +   int err;
> > +   struct adc_device   *adc_dev;
> > +   struct ti_tscadc_dev*tscadc_dev = pdev->dev.platform_data;
> > +   struct mfd_tscadc_board *pdata;
> > +
> > +   pdata = (struct mfd_tscadc_board *)tscadc_dev->dev->platform_data;
> 
> The cast should not be necessary.

True,
I will correct this.

> 
> > +   if (!pdata || !pdata->adc_init) {
> > +   dev_err(tscadc_dev->dev, "Could not find platform data\n");
> 
> I'd still use pdev->dev for the device parameter here. Seeing a message 
> printed by this driver for another device might be confusing.

Yes, I will correct this.

> 
> > +   return -EINVAL;
> > +   }
> > +
> > +   idev = iio_device_alloc(sizeof(struct adc_device));
> > +   if (idev == NULL) {
> > +   dev_err(&pdev->dev, "failed to allocate iio device.\n");
> > +   err = -ENOMEM;
> > +   goto err_ret;
> > +   }
> > +   adc_dev = iio_priv(idev);
> > +
> > +   tscadc_dev->adc = adc_dev;
> 
> This there any reason why you need to store a pointer to the adc struct in 
> the mfd struct? Is it going to be used outside of the adc driver? Currently 
> it is, as far as I can see, only used in the remove callback and 
> suspend/resume handlers. But there you can use iio_priv just as easily to get 
> the pointer to the adc device struct and it certainly will be also be cleaner 
> to do it that way.

Yes, current

[tip:core/urgent] task_work: Simplify the usage in ptrace_notify() and get_signal_to_deliver()

2012-09-13 Thread tip-bot for Oleg Nesterov
Commit-ID:  f784e8a7989c0da3062d04bfea3db90f41e8f738
Gitweb: http://git.kernel.org/tip/f784e8a7989c0da3062d04bfea3db90f41e8f738
Author: Oleg Nesterov 
AuthorDate: Sun, 26 Aug 2012 21:12:17 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 16:47:37 +0200

task_work: Simplify the usage in ptrace_notify() and get_signal_to_deliver()

ptrace_notify() and get_signal_to_deliver() do unnecessary things
before task_work_run():

1. smp_mb__after_clear_bit() is not needed, test_and_clear_bit()
   implies mb().

2. And we do not need the barrier at all, in this case we only
   care about the "synchronous" works added by the task itself.

3. No need to clear TIF_NOTIFY_RESUME, and we should not assume
   task_works is the only user of this flag.

Signed-off-by: Oleg Nesterov 
Signed-off-by: Peter Zijlstra 
Cc: Al Viro 
Cc: Linus Torvalds 
Cc: Andrew Morton 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20120826191217.ga4...@redhat.com
Signed-off-by: Ingo Molnar 
---
 kernel/signal.c |   18 --
 1 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index be4f856..2c681f1 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1971,13 +1971,8 @@ static void ptrace_do_notify(int signr, int exit_code, 
int why)
 void ptrace_notify(int exit_code)
 {
BUG_ON((exit_code & (0x7f | ~0x)) != SIGTRAP);
-   if (unlikely(current->task_works)) {
-   if (test_and_clear_ti_thread_flag(current_thread_info(),
-  TIF_NOTIFY_RESUME)) {
-   smp_mb__after_clear_bit();
-   task_work_run();
-   }
-   }
+   if (unlikely(current->task_works))
+   task_work_run();
 
spin_lock_irq(¤t->sighand->siglock);
ptrace_do_notify(SIGTRAP, exit_code, CLD_TRAPPED);
@@ -2198,13 +2193,8 @@ int get_signal_to_deliver(siginfo_t *info, struct 
k_sigaction *return_ka,
struct signal_struct *signal = current->signal;
int signr;
 
-   if (unlikely(current->task_works)) {
-   if (test_and_clear_ti_thread_flag(current_thread_info(),
-  TIF_NOTIFY_RESUME)) {
-   smp_mb__after_clear_bit();
-   task_work_run();
-   }
-   }
+   if (unlikely(current->task_works))
+   task_work_run();
 
if (unlikely(uprobe_deny_signal()))
return 0;
--
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:core/urgent] task_work: Revert " hold task_lock around checks in keyctl"

2012-09-13 Thread tip-bot for Oleg Nesterov
Commit-ID:  b3f68f16dbcde6fcdf0fd27695391ff7e9d41233
Gitweb: http://git.kernel.org/tip/b3f68f16dbcde6fcdf0fd27695391ff7e9d41233
Author: Oleg Nesterov 
AuthorDate: Sun, 26 Aug 2012 21:12:14 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 16:47:36 +0200

task_work: Revert "hold task_lock around checks in keyctl"

This reverts commit d35abdb28824cf74f0a106a0f9c6f3ff700a35bf.

task_lock() was added to ensure exit_mm() and thus exit_task_work() is
not possible before task_work_add().

This is wrong, task_lock() must not be nested with write_lock(tasklist).
And this is no longer needed, task_work_add() now fails if it is called
after exit_task_work().

Reported-by: Dave Jones 
Signed-off-by: Oleg Nesterov 
Signed-off-by: Peter Zijlstra 
Cc: Al Viro 
Cc: Linus Torvalds 
Cc: Andrew Morton 
Link: http://lkml.kernel.org/r/20120826191214.ga4...@redhat.com
Signed-off-by: Ingo Molnar 
---
 security/keys/keyctl.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 3364fbf..6cfc647 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -1486,7 +1486,6 @@ long keyctl_session_to_parent(void)
oldwork = NULL;
parent = me->real_parent;
 
-   task_lock(parent);
/* the parent mustn't be init and mustn't be a kernel thread */
if (parent->pid <= 1 || !parent->mm)
goto unlock;
@@ -1530,7 +1529,6 @@ long keyctl_session_to_parent(void)
if (!ret)
newwork = NULL;
 unlock:
-   task_unlock(parent);
write_unlock_irq(&tasklist_lock);
rcu_read_unlock();
if (oldwork)
--
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:core/urgent] task_work: task_work_add() should not succeed after exit_task_work()

2012-09-13 Thread tip-bot for Oleg Nesterov
Commit-ID:  9da33de62431c7839f98156720862262272a8380
Gitweb: http://git.kernel.org/tip/9da33de62431c7839f98156720862262272a8380
Author: Oleg Nesterov 
AuthorDate: Sun, 26 Aug 2012 21:12:11 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 16:47:34 +0200

task_work: task_work_add() should not succeed after exit_task_work()

ed3e694d "move exit_task_work() past exit_files() et.al" destroyed
the add/exit synchronization we had, the caller itself should ensure
task_work_add() can't race with the exiting task.

However, this is not convenient/simple, and the only user which tries
to do this is buggy (see the next patch). Unless the task is current,
there is simply no way to do this in general.

Change exit_task_work()->task_work_run() to use the dummy "work_exited"
entry to let task_work_add() know it should fail.

Signed-off-by: Oleg Nesterov 
Signed-off-by: Peter Zijlstra 
Cc: Al Viro 
Cc: Linus Torvalds 
Cc: Andrew Morton 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20120826191211.ga4...@redhat.com
Signed-off-by: Ingo Molnar 
---
 include/linux/task_work.h |3 +--
 kernel/task_work.c|   22 --
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/include/linux/task_work.h b/include/linux/task_work.h
index fb46b03..ca5a1cf 100644
--- a/include/linux/task_work.h
+++ b/include/linux/task_work.h
@@ -18,8 +18,7 @@ void task_work_run(void);
 
 static inline void exit_task_work(struct task_struct *task)
 {
-   if (unlikely(task->task_works))
-   task_work_run();
+   task_work_run();
 }
 
 #endif /* _LINUX_TASK_WORK_H */
diff --git a/kernel/task_work.c b/kernel/task_work.c
index f13ec0b..65bd3c9 100644
--- a/kernel/task_work.c
+++ b/kernel/task_work.c
@@ -2,16 +2,17 @@
 #include 
 #include 
 
+static struct callback_head work_exited; /* all we need is ->next == NULL */
+
 int
 task_work_add(struct task_struct *task, struct callback_head *work, bool 
notify)
 {
struct callback_head *head;
-   /*
-* Not inserting the new work if the task has already passed
-* exit_task_work() is the responisbility of callers.
-*/
+
do {
head = ACCESS_ONCE(task->task_works);
+   if (unlikely(head == &work_exited))
+   return -ESRCH;
work->next = head;
} while (cmpxchg(&task->task_works, head, work) != head);
 
@@ -30,7 +31,7 @@ task_work_cancel(struct task_struct *task, task_work_func_t 
func)
 * If cmpxchg() fails we continue without updating pprev.
 * Either we raced with task_work_add() which added the
 * new entry before this work, we will find it again. Or
-* we raced with task_work_run(), *pprev == NULL.
+* we raced with task_work_run(), *pprev == NULL/exited.
 */
raw_spin_lock_irqsave(&task->pi_lock, flags);
while ((work = ACCESS_ONCE(*pprev))) {
@@ -51,7 +52,16 @@ void task_work_run(void)
struct callback_head *work, *head, *next;
 
for (;;) {
-   work = xchg(&task->task_works, NULL);
+   /*
+* work->func() can do task_work_add(), do not set
+* work_exited unless the list is empty.
+*/
+   do {
+   work = ACCESS_ONCE(task->task_works);
+   head = !work && (task->flags & PF_EXITING) ?
+   &work_exited : NULL;
+   } while (cmpxchg(&task->task_works, work, head) != work);
+
if (!work)
break;
/*
--
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:core/urgent] task_work: Make task_work_add() lockless

2012-09-13 Thread tip-bot for Oleg Nesterov
Commit-ID:  ac3d0da8f3290b3d394cdb7f50604424a7cd6092
Gitweb: http://git.kernel.org/tip/ac3d0da8f3290b3d394cdb7f50604424a7cd6092
Author: Oleg Nesterov 
AuthorDate: Sun, 26 Aug 2012 21:12:09 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Sep 2012 16:47:33 +0200

task_work: Make task_work_add() lockless

Change task_work's to use llist-like code to avoid pi_lock
in task_work_add(), this makes it useable under rq->lock.

task_work_cancel() and task_work_run() still use pi_lock
to synchronize with each other.

(This is in preparation for a deadlock fix.)

Suggested-by: Peter Zijlstra 
Signed-off-by: Oleg Nesterov 
Signed-off-by: Peter Zijlstra 
Cc: Al Viro 
Cc: Linus Torvalds 
Cc: Andrew Morton 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20120826191209.ga4...@redhat.com
Signed-off-by: Ingo Molnar 
---
 kernel/task_work.c |   95 ++-
 1 files changed, 48 insertions(+), 47 deletions(-)

diff --git a/kernel/task_work.c b/kernel/task_work.c
index d320d44..f13ec0b 100644
--- a/kernel/task_work.c
+++ b/kernel/task_work.c
@@ -3,25 +3,18 @@
 #include 
 
 int
-task_work_add(struct task_struct *task, struct callback_head *twork, bool 
notify)
+task_work_add(struct task_struct *task, struct callback_head *work, bool 
notify)
 {
-   struct callback_head *last, *first;
-   unsigned long flags;
-
+   struct callback_head *head;
/*
 * Not inserting the new work if the task has already passed
 * exit_task_work() is the responisbility of callers.
 */
-   raw_spin_lock_irqsave(&task->pi_lock, flags);
-   last = task->task_works;
-   first = last ? last->next : twork;
-   twork->next = first;
-   if (last)
-   last->next = twork;
-   task->task_works = twork;
-   raw_spin_unlock_irqrestore(&task->pi_lock, flags);
+   do {
+   head = ACCESS_ONCE(task->task_works);
+   work->next = head;
+   } while (cmpxchg(&task->task_works, head, work) != head);
 
-   /* test_and_set_bit() implies mb(), see tracehook_notify_resume(). */
if (notify)
set_notify_resume(task);
return 0;
@@ -30,52 +23,60 @@ task_work_add(struct task_struct *task, struct 
callback_head *twork, bool notify
 struct callback_head *
 task_work_cancel(struct task_struct *task, task_work_func_t func)
 {
+   struct callback_head **pprev = &task->task_works;
+   struct callback_head *work = NULL;
unsigned long flags;
-   struct callback_head *last, *res = NULL;
-
+   /*
+* If cmpxchg() fails we continue without updating pprev.
+* Either we raced with task_work_add() which added the
+* new entry before this work, we will find it again. Or
+* we raced with task_work_run(), *pprev == NULL.
+*/
raw_spin_lock_irqsave(&task->pi_lock, flags);
-   last = task->task_works;
-   if (last) {
-   struct callback_head *q = last, *p = q->next;
-   while (1) {
-   if (p->func == func) {
-   q->next = p->next;
-   if (p == last)
-   task->task_works = q == p ? NULL : q;
-   res = p;
-   break;
-   }
-   if (p == last)
-   break;
-   q = p;
-   p = q->next;
-   }
+   while ((work = ACCESS_ONCE(*pprev))) {
+   read_barrier_depends();
+   if (work->func != func)
+   pprev = &work->next;
+   else if (cmpxchg(pprev, work, work->next) == work)
+   break;
}
raw_spin_unlock_irqrestore(&task->pi_lock, flags);
-   return res;
+
+   return work;
 }
 
 void task_work_run(void)
 {
struct task_struct *task = current;
-   struct callback_head *p, *q;
+   struct callback_head *work, *head, *next;
 
-   while (1) {
-   raw_spin_lock_irq(&task->pi_lock);
-   p = task->task_works;
-   task->task_works = NULL;
-   raw_spin_unlock_irq(&task->pi_lock);
+   for (;;) {
+   work = xchg(&task->task_works, NULL);
+   if (!work)
+   break;
+   /*
+* Synchronize with task_work_cancel(). It can't remove
+* the first entry == work, cmpxchg(task_works) should
+* fail, but it can play with *work and other entries.
+*/
+   raw_spin_unlock_wait(&task->pi_lock);
+   smp_mb();
 
-   if (unlikely(!p))
-   return;
+   /* Reverse the list to run the works in fifo order */
+   head = NULL;
+   do {
+   next = work->next;
+  

[tip:core/rcu] trace: Don' t declare trace_*_rcuidle functions in modules

2012-09-13 Thread tip-bot for Josh Triplett
Commit-ID:  7ece55a4a3a04abe37118b1d4fb0b702eeb1de4c
Gitweb: http://git.kernel.org/tip/7ece55a4a3a04abe37118b1d4fb0b702eeb1de4c
Author: Josh Triplett 
AuthorDate: Tue, 4 Sep 2012 23:23:06 -0700
Committer:  Steven Rostedt 
CommitDate: Wed, 12 Sep 2012 10:20:14 -0400

trace: Don't declare trace_*_rcuidle functions in modules

Tracepoints declare a static inline trace_*_rcuidle variant of the trace
function, to support safely generating trace events from the idle loop.
Module code never actually uses that variant of trace functions, because
modules don't run code that needs tracing with RCU idled.  However, the
declaration of those otherwise unused functions causes the module to
reference rcu_idle_exit and rcu_idle_enter, which RCU does not export to
modules.

To avoid this, don't generate trace_*_rcuidle functions for tracepoints
declared in module code.

Link: http://lkml.kernel.org/r/20120905062306.GA14756@leaf

Reported-by: Steven Rostedt 
Acked-by: Mathieu Desnoyers 
Acked-by: Paul E. McKenney 
Signed-off-by: Josh Triplett 
Signed-off-by: Steven Rostedt 
---
 include/linux/tracepoint.h |   28 ++--
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 802de56..2f322c3 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -136,6 +136,22 @@ static inline void tracepoint_synchronize_unregister(void)
postrcu;\
} while (0)
 
+#ifndef MODULE
+#define __DECLARE_TRACE_RCU(name, proto, args, cond, data_proto, data_args)
\
+   static inline void trace_##name##_rcuidle(proto)\
+   {   \
+   if (static_key_false(&__tracepoint_##name.key)) \
+   __DO_TRACE(&__tracepoint_##name,\
+   TP_PROTO(data_proto),   \
+   TP_ARGS(data_args), \
+   TP_CONDITION(cond), \
+   rcu_idle_exit(),\
+   rcu_idle_enter());  \
+   }
+#else
+#define __DECLARE_TRACE_RCU(name, proto, args, cond, data_proto, data_args)
+#endif
+
 /*
  * Make sure the alignment of the structure in the __tracepoints section will
  * not add unwanted padding between the beginning of the section and the
@@ -151,16 +167,8 @@ static inline void tracepoint_synchronize_unregister(void)
TP_ARGS(data_args), \
TP_CONDITION(cond),,);  \
}   \
-   static inline void trace_##name##_rcuidle(proto)\
-   {   \
-   if (static_key_false(&__tracepoint_##name.key)) \
-   __DO_TRACE(&__tracepoint_##name,\
-   TP_PROTO(data_proto),   \
-   TP_ARGS(data_args), \
-   TP_CONDITION(cond), \
-   rcu_idle_exit(),\
-   rcu_idle_enter());  \
-   }   \
+   __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args),  \
+   PARAMS(cond), PARAMS(data_proto), PARAMS(data_args))\
static inline int   \
register_trace_##name(void (*probe)(data_proto), void *data)\
{   \
--
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 sched: Don' t read all tracepoint variables in advance

2012-09-13 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  9ec3f4e437ede2f3b5087d412abe16a0219b3b99
Gitweb: http://git.kernel.org/tip/9ec3f4e437ede2f3b5087d412abe16a0219b3b99
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 11 Sep 2012 19:29:17 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 20:39:19 -0300

perf sched: Don't read all tracepoint variables in advance

Do it just at the actual consumer of these fields, that way we avoid
needless lookups:

  [root@sandy ~]# perf sched record sleep 30s
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 8.585 MB perf.data (~375063 samples) ]

Before:

  [root@sandy ~]# perf stat -r 10 perf sched lat > /dev/null

   Performance counter stats for 'perf sched lat' (10 runs):

  103.592215 task-clock#0.993 CPUs utilized 
   ( +-  0.33% )
  12 context-switches  #0.114 K/sec 
   ( +-  3.29% )
   0 cpu-migrations#0.000 K/sec
   7,605 page-faults   #0.073 M/sec 
   ( +-  0.00% )
 345,796,112 cycles#3.338 GHz   
   ( +-  0.07% ) [82.90%]
 106,876,796 stalled-cycles-frontend   #   30.91% frontend cycles idle  
   ( +-  0.38% ) [83.23%]
  62,060,877 stalled-cycles-backend#   17.95% backend  cycles idle  
   ( +-  0.80% ) [67.14%]
 628,246,586 instructions  #1.82  insns per cycle
   #0.17  stalled cycles per 
insn  ( +-  0.04% ) [83.64%]
 134,962,057 branches  # 1302.820 M/sec 
   ( +-  0.10% ) [83.64%]
   1,233,037 branch-misses #0.91% of all branches   
   ( +-  0.29% ) [83.41%]

 0.104333272 seconds time elapsed   
   ( +-  0.33% )

  [root@sandy ~]# perf stat -r 10 perf sched lat > /dev/null

   Performance counter stats for 'perf sched lat' (10 runs):

 98.848272 task-clock#0.993 CPUs utilized   
 ( +-  0.48% )
11 context-switches  #0.112 K/sec   
 ( +-  2.83% )
 0 cpu-migrations#0.003 K/sec   
 ( +- 50.92% )
 7,604 page-faults   #0.077 M/sec   
 ( +-  0.00% )
   332,216,085 cycles#3.361 GHz 
 ( +-  0.14% ) [82.87%]
   100,623,710 stalled-cycles-frontend   #   30.29% frontend cycles idle
 ( +-  0.53% ) [82.95%]
58,788,692 stalled-cycles-backend#   17.70% backend  cycles idle
 ( +-  0.59% ) [67.15%]
   609,402,433 instructions  #1.83  insns per cycle
 #0.17  stalled cycles per insn 
 ( +-  0.04% ) [83.76%]
   131,277,138 branches  # 1328.067 M/sec   
 ( +-  0.06% ) [83.77%]
 1,117,871 branch-misses #0.85% of all branches 
 ( +-  0.32% ) [83.51%]

   0.099580430 seconds time elapsed 
 ( +-  0.48% )

  [root@sandy ~]#

Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/n/tip-kracdpw8wqlr0xjh75uk8...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c |  277 +++
 1 files changed, 97 insertions(+), 180 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0df5e7a..af305f5 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -97,73 +97,25 @@ struct work_atoms {
 
 typedef int (*sort_fn_t)(struct work_atoms *, struct work_atoms *);
 
-struct trace_switch_event {
-   char *prev_comm;
-   u32  prev_pid;
-   u32  prev_prio;
-   u64  prev_state;
-   char *next_comm;
-   u32  next_pid;
-   u32  next_prio;
-};
-
-struct trace_runtime_event {
-   char *comm;
-   u32  pid;
-   u64  runtime;
-   u64  vruntime;
-};
+struct perf_sched;
 
-struct trace_wakeup_event {
-   char *comm;
-   u32  pid;
-   u32  prio;
-   u32  success;
-   u32  cpu;
-};
+struct trace_sched_handler {
+   int (*switch_event)(struct perf_sched *sched, struct perf_evsel *evsel,
+   struct perf_sample *sample, struct machine 
*machine);
 
-struct trace_fork_event {
-   char *parent_comm;
-   u32  parent_pid;
-   char *child_comm;
-   u32   child_pid;
-};
+   int (*runtime_event)(struct perf_sched *sched, struct perf_evsel *evsel,
+struct perf_sample *sample, struct machine 
*machine);
 
-struct trace_migrate_task_event {
-   char *comm;
-   u32  pid;
-   u32  prio;

[tip:perf/core] perf sched: Use perf_evsel__{int,str}val

2012-09-13 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  2b7fcbc5a9c719a306af1c4986a9f5c2cbfcec65
Gitweb: http://git.kernel.org/tip/2b7fcbc5a9c719a306af1c4986a9f5c2cbfcec65
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 11 Sep 2012 19:29:17 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 19:33:51 -0300

perf sched: Use perf_evsel__{int,str}val

This patch also stops reading the common fields, as they were not being used 
except
for one ->common_pid case that was replaced by sample->tid, i.e. the info is 
already
in the perf_sample struct.

Also it only fills the _event structures when there is a handler.

  [root@sandy ~]# perf sched record sleep 30s
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 8.585 MB perf.data (~375063 samples) ]

Before:

  [root@sandy ~]# perf stat -r 10 perf sched lat > /dev/null

   Performance counter stats for 'perf sched lat' (10 runs):

  129.117838 task-clock#0.994 CPUs utilized 
   ( +-  0.28% )
  14 context-switches  #0.111 K/sec 
   ( +-  2.10% )
   0 cpu-migrations#0.002 K/sec 
   ( +- 66.67% )
   7,654 page-faults   #0.059 M/sec 
   ( +-  0.67% )
 438,121,661 cycles#3.393 GHz   
   ( +-  0.06% ) [83.06%]
 150,808,605 stalled-cycles-frontend   #   34.42% frontend cycles idle  
   ( +-  0.14% ) [83.10%]
  80,748,941 stalled-cycles-backend#   18.43% backend  cycles idle  
   ( +-  0.64% ) [66.73%]
 758,605,879 instructions  #1.73  insns per cycle
   #0.20  stalled cycles per 
insn  ( +-  0.08% ) [83.54%]
 162,164,321 branches  # 1255.940 M/sec 
   ( +-  0.10% ) [83.70%]
   1,609,903 branch-misses #0.99% of all branches   
   ( +-  0.08% ) [83.62%]

 0.129949153 seconds time elapsed   
   ( +-  0.28% )

After:

  [root@sandy ~]# perf stat -r 10 perf sched lat > /dev/null

   Performance counter stats for 'perf sched lat' (10 runs):

  103.592215 task-clock#0.993 CPUs utilized 
   ( +-  0.33% )
  12 context-switches  #0.114 K/sec 
   ( +-  3.29% )
   0 cpu-migrations#0.000 K/sec
   7,605 page-faults   #0.073 M/sec 
   ( +-  0.00% )
 345,796,112 cycles#3.338 GHz   
   ( +-  0.07% ) [82.90%]
 106,876,796 stalled-cycles-frontend   #   30.91% frontend cycles idle  
   ( +-  0.38% ) [83.23%]
  62,060,877 stalled-cycles-backend#   17.95% backend  cycles idle  
   ( +-  0.80% ) [67.14%]
 628,246,586 instructions  #1.82  insns per cycle
   #0.17  stalled cycles per 
insn  ( +-  0.04% ) [83.64%]
 134,962,057 branches  # 1302.820 M/sec 
   ( +-  0.10% ) [83.64%]
   1,233,037 branch-misses #0.91% of all branches   
   ( +-  0.29% ) [83.41%]

 0.104333272 seconds time elapsed   
   ( +-  0.33% )

  [root@sandy ~]#

Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/n/tip-weu9t63zkrfrazkn0gxj4...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c |  249 
 1 files changed, 90 insertions(+), 159 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 79f88fa..0df5e7a 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -98,82 +98,40 @@ struct work_atoms {
 typedef int (*sort_fn_t)(struct work_atoms *, struct work_atoms *);
 
 struct trace_switch_event {
-   u32  size;
-
-   u16  common_type;
-   u8   common_flags;
-   u8   common_preempt_count;
-   u32  common_pid;
-   u32  common_tgid;
-
-   char prev_comm[16];
+   char *prev_comm;
u32  prev_pid;
u32  prev_prio;
u64  prev_state;
-   char next_comm[16];
+   char *next_comm;
u32  next_pid;
u32  next_prio;
 };
 
 struct trace_runtime_event {
-   u32  size;
-
-   u16  common_type;
-   u8   common_flags;
-   u8   common_preempt_count;
-   u32  common_pid;
-   u32  common_tgid;
-
-   char comm[16];
+   char *comm;
u32  pid;
u64  runtime;
u64  vruntime;
 };
 
 struct trace_wakeup_event {
-   u32  size;
-
-   u16  common_type;
-   u8   common_flags;
-   u8   common_preempt_count;
-

[tip:perf/core] perf evsel: Introduce perf_evsel__{str, int}val methods

2012-09-13 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  ded44698ed82ffa3d8742ec2994f695127bc
Gitweb: http://git.kernel.org/tip/ded44698ed82ffa3d8742ec2994f695127bc
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 11 Sep 2012 19:24:23 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 19:24:23 -0300

perf evsel: Introduce perf_evsel__{str,int}val methods

Wrappers to the libtraceevent routines, so that we can further reduce
the surface contact perf builtins have with it.

Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/n/tip-rtmgzptvrifzjxqwb9vs6...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evsel.c |   35 +++
 tools/perf/util/evsel.h |7 +++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 06f7644..1506ba0 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include "asm/bug.h"
+#include "event-parse.h"
 #include "evsel.h"
 #include "evlist.h"
 #include "util.h"
@@ -1000,3 +1001,37 @@ int perf_event__synthesize_sample(union perf_event 
*event, u64 type,
 
return 0;
 }
+
+char *perf_evsel__strval(struct perf_evsel *evsel, struct perf_sample *sample,
+const char *name)
+{
+   struct format_field *field = pevent_find_field(evsel->tp_format, name);
+   int offset;
+
+if (!field)
+return NULL;
+
+   offset = field->offset;
+
+   if (field->flags & FIELD_IS_DYNAMIC) {
+   offset = *(int *)(sample->raw_data + field->offset);
+   offset &= 0x;
+   }
+
+   return sample->raw_data + offset;
+}
+
+u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
+  const char *name)
+{
+   struct format_field *field = pevent_find_field(evsel->tp_format, name);
+   u64 val;
+
+if (!field)
+return 0;
+
+   val = pevent_read_number(evsel->tp_format->pevent,
+sample->raw_data + field->offset, field->size);
+   return val;
+
+}
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 390690e..dc40fe3 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -120,6 +120,13 @@ int perf_evsel__open(struct perf_evsel *evsel, struct 
cpu_map *cpus,
 struct thread_map *threads);
 void perf_evsel__close(struct perf_evsel *evsel, int ncpus, int nthreads);
 
+struct perf_sample;
+
+char *perf_evsel__strval(struct perf_evsel *evsel, struct perf_sample *sample,
+const char *name);
+u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
+  const char *name);
+
 #define perf_evsel__match(evsel, t, c) \
(evsel->attr.type == PERF_TYPE_##t &&   \
 evsel->attr.config == PERF_COUNT_##c)
--
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 sched: Remove unused thread parameter

2012-09-13 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  4218e6734197f3842fc9b6362f12973918d913aa
Gitweb: http://git.kernel.org/tip/4218e6734197f3842fc9b6362f12973918d913aa
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 11 Sep 2012 13:18:47 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 13:18:47 -0300

perf sched: Remove unused thread parameter

>From the tracepoint handling routines.

Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/n/tip-mcqd9mv34z6he0wqiz4a3...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c |   23 ---
 1 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 82e8ec2..af11b1a 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1372,8 +1372,7 @@ static struct trace_sched_handler *trace_handler;
 static int process_sched_wakeup_event(struct perf_tool *tool __maybe_unused,
  struct event_format *event,
  struct perf_sample *sample,
- struct machine *machine,
- struct thread *thread __maybe_unused)
+ struct machine *machine)
 {
void *data = sample->raw_data;
struct trace_wakeup_event wakeup_event;
@@ -1489,8 +1488,7 @@ map_switch_event(struct trace_switch_event *switch_event,
 static int process_sched_switch_event(struct perf_tool *tool __maybe_unused,
  struct event_format *event,
  struct perf_sample *sample,
- struct machine *machine,
- struct thread *thread __maybe_unused)
+ struct machine *machine)
 {
int this_cpu = sample->cpu, err = 0;
void *data = sample->raw_data;
@@ -1524,8 +1522,7 @@ static int process_sched_switch_event(struct perf_tool 
*tool __maybe_unused,
 static int process_sched_runtime_event(struct perf_tool *tool __maybe_unused,
   struct event_format *event,
   struct perf_sample *sample,
-  struct machine *machine,
-  struct thread *thread __maybe_unused)
+  struct machine *machine)
 {
void *data = sample->raw_data;
struct trace_runtime_event runtime_event;
@@ -1545,8 +1542,7 @@ static int process_sched_runtime_event(struct perf_tool 
*tool __maybe_unused,
 static int process_sched_fork_event(struct perf_tool *tool __maybe_unused,
struct event_format *event,
struct perf_sample *sample,
-   struct machine *machine __maybe_unused,
-   struct thread *thread __maybe_unused)
+   struct machine *machine __maybe_unused)
 {
void *data = sample->raw_data;
struct trace_fork_event fork_event;
@@ -1568,8 +1564,7 @@ static int process_sched_fork_event(struct perf_tool 
*tool __maybe_unused,
 static int process_sched_exit_event(struct perf_tool *tool __maybe_unused,
struct event_format *event,
struct perf_sample *sample __maybe_unused,
-   struct machine *machine __maybe_unused,
-   struct thread *thread __maybe_unused)
+   struct machine *machine __maybe_unused)
 {
if (verbose)
printf("sched_exit event %p\n", event);
@@ -1580,8 +1575,7 @@ static int process_sched_exit_event(struct perf_tool 
*tool __maybe_unused,
 static int process_sched_migrate_task_event(struct perf_tool *tool 
__maybe_unused,
struct event_format *event,
struct perf_sample *sample,
-   struct machine *machine,
-   struct thread *thread 
__maybe_unused)
+   struct machine *machine)
 {
void *data = sample->raw_data;
struct trace_migrate_task_event migrate_task_event;
@@ -1603,8 +1597,7 @@ static int process_sched_migrate_task_event(struct 
perf_tool *tool __maybe_unuse
 typedef int (*tracepoint_handler)(struct perf_tool *tool,
  struct event_format *tp_format,
  struct perf_sample *sample,
- struct machine *machine,
- struct thread *thread);
+  

[tip:perf/core] perf tools: Back [vdso] DSO with real data

2012-09-13 Thread tip-bot for Jiri Olsa
Commit-ID:  7dbf4dcfe2987c35c2c4675cd7ae1b6006979176
Gitweb: http://git.kernel.org/tip/7dbf4dcfe2987c35c2c4675cd7ae1b6006979176
Author: Jiri Olsa 
AuthorDate: Mon, 10 Sep 2012 18:50:19 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 12:08:30 -0300

perf tools: Back [vdso] DSO with real data

Storing data for VDSO shared object, because we need it for the post
unwind processing.

The VDSO shared object is same for all process on a running system, so
it makes no difference when we store it inside the tracer - perf.

When [vdso] map memory is hit, we retrieve [vdso] DSO image and store it
into temporary file.

During the build-id processing phase, the [vdso] DSO image is stored in
build-id db, and build-id reference is made inside perf.data. The
build-id vdso file object is called '[vdso]'. We don't use temporary
file name which gets removed when record is finished.

During report phase the vdso build-id object is treated as any other
build-id DSO object.

Adding following API for vdso object:

  bool is_vdso_map(const char *filename)
- returns true if the filename matches vdso map name

  struct dso *vdso__dso_findnew(struct list_head *head)
- find/create proper vdso DSO object

  vdso__exit(void)
- removes temporary VDSO image if there's any

This change makes backtrace dwarf post unwind possible from [vdso] maps.

Following output is current report of [vdso] sample dwarf backtrace:

  # Overhead  Command  Shared Object Symbol
  #   ...  .  .
  #
  99.52%   ex  [vdso] [.] 0x7fff3ace89af
   |
   --- 0x7fff3ace89af

Following output is new report of [vdso] sample dwarf backtrace:

  # Overhead  Command  Shared Object Symbol
  #   ...  .  .
  #
  99.52%   ex  [vdso] [.] 0x09af
   |
   --- 0x7fff3ace89af
   main
   __libc_start_main
   _start

Signed-off-by: Jiri Olsa 
Acked-by: Peter Zijlstra 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1347295819-23177-5-git-send-email-jo...@redhat.com
[ committer note: s/ALIGN/PERF_ALIGN/g to cope with the android build changes ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile|2 +
 tools/perf/builtin-buildid-cache.c |3 +-
 tools/perf/util/header.c   |   70 ---
 tools/perf/util/header.h   |2 +-
 tools/perf/util/map.c  |   12 +++-
 tools/perf/util/session.c  |2 +
 tools/perf/util/vdso.c |  111 
 tools/perf/util/vdso.h |   18 ++
 8 files changed, 194 insertions(+), 26 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 1d2723c..209774b 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -337,6 +337,7 @@ LIB_H += util/intlist.h
 LIB_H += util/perf_regs.h
 LIB_H += util/unwind.h
 LIB_H += ui/helpline.h
+LIB_H += util/vdso.h
 
 LIB_OBJS += $(OUTPUT)util/abspath.o
 LIB_OBJS += $(OUTPUT)util/alias.o
@@ -404,6 +405,7 @@ LIB_OBJS += $(OUTPUT)util/cgroup.o
 LIB_OBJS += $(OUTPUT)util/target.o
 LIB_OBJS += $(OUTPUT)util/rblist.o
 LIB_OBJS += $(OUTPUT)util/intlist.o
+LIB_OBJS += $(OUTPUT)util/vdso.o
 
 LIB_OBJS += $(OUTPUT)ui/helpline.o
 LIB_OBJS += $(OUTPUT)ui/hist.o
diff --git a/tools/perf/builtin-buildid-cache.c 
b/tools/perf/builtin-buildid-cache.c
index 29ad20e..995368e 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -43,7 +43,8 @@ static int build_id_cache__add_file(const char *filename, 
const char *debugdir)
}
 
build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
-   err = build_id_cache__add_s(sbuild_id, debugdir, filename, false);
+   err = build_id_cache__add_s(sbuild_id, debugdir, filename,
+   false, false);
if (verbose)
pr_info("Adding %s %s: %s\n", sbuild_id, filename,
err ? "FAIL" : "Ok");
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 974e758..87996ca 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -21,6 +21,7 @@
 #include "debug.h"
 #include "cpumap.h"
 #include "pmu.h"
+#include "vdso.h"
 
 static bool no_buildid_cache = false;
 
@@ -207,6 +208,29 @@ perf_header__set_cmdline(int argc, const char **argv)
continue;   \
else
 
+static int write_buildid(char *name, size_t name_len, u8 *build_id,
+pid_t pid, u16 misc, int fd)
+{
+   int err;
+   struct build_id_event b;
+   size_t len;
+
+   len = name_len + 1;
+   len = PERF_ALI

RE: [PATCH v3 4/5] IIO : ADC: tiadc: Add support of TI's ADC driver

2012-09-13 Thread Patil, Rachna
On Thu, Sep 13, 2012 at 17:43:30, Jonathan Cameron wrote:
> On 13/09/12 11:40, Patil, Rachna wrote:
> > This patch adds support for TI's ADC driver.
> > This is a multifunctional device.
> > Analog input lines are provided on which voltage measurements can be 
> > carried out.
> > You can have upto 8 input lines.
> >
> > Signed-off-by: Patil, Rachna 
> 
> There's a little fuzz in applying this due to other drivers that have gone in 
> recently.
> 
> Actually this is going to be 'interesting' to merge. Dmitry, Samuel thoughts 
> on who takes this one and how?  Maybe this is a case for a 'special' branch 
> pulled into more than one tree?
> 
> 
> One minor thing inline.  I have an aversion to dynamic allocation of
> things that are then constant.
> 
> Also the module name is simply ti_adc. Does seem a little 'vague'
> given the range of ADC's TI makes :)  Perhaps keep the reference
> to the tsc in there?  Personally I'd have preferred the whole thing
> being named after a particular part number (any one it support would
> do) to avoid a clash in future with a new touch screen adc from TI.
> Bit late for that though I guess ;)

Yes, true.
TI definitely might come up with more IP's of this type.
This IP(TSC / ADC) is present on AM335x. If necessary we can rename the driver 
to ti_am335x_XXX.

> 
> Jonathan
> > ---
> > Changes in v2:
> > Addressed review comments from Matthias Kaehlcke
> >
> > Changes in v3:
> > Addressed review comments from Jonathan Cameron.
> > Added comments, new line appropriately.
> >
> >   drivers/iio/adc/Kconfig  |7 +
> >   drivers/iio/adc/Makefile |1 +
> >   drivers/iio/adc/ti_adc.c |  223 
> > ++
> >   drivers/mfd/ti_tscadc.c  |   18 +++-
> >   include/linux/mfd/ti_tscadc.h|9 ++-
> >   include/linux/platform_data/ti_adc.h |   14 ++
> >   6 files changed, 270 insertions(+), 2 deletions(-)
> >   create mode 100644 drivers/iio/adc/ti_adc.c
> >   create mode 100644 include/linux/platform_data/ti_adc.h
> >
> > diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> > index 8a78b4f..ad32df8 100644
> > --- a/drivers/iio/adc/Kconfig
> > +++ b/drivers/iio/adc/Kconfig
> > @@ -22,4 +22,11 @@ config AT91_ADC
> > help
> >   Say yes here to build support for Atmel AT91 ADC.
> >
> > +config TI_ADC
> > +   tristate "TI's ADC driver"
> > +   depends on ARCH_OMAP2PLUS
> > +   help
> > + Say yes here to build support for Texas Instruments ADC
> > + driver which is also a MFD client.
> > +
> >   endmenu
> > diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> > index 52eec25..a930cee 100644
> > --- a/drivers/iio/adc/Makefile
> > +++ b/drivers/iio/adc/Makefile
> > @@ -4,3 +4,4 @@
> >
> >   obj-$(CONFIG_AD7266) += ad7266.o
> >   obj-$(CONFIG_AT91_ADC) += at91_adc.o
> > +obj-$(CONFIG_TI_ADC) += ti_adc.o
> > diff --git a/drivers/iio/adc/ti_adc.c b/drivers/iio/adc/ti_adc.c
> > new file mode 100644
> > index 000..56f8af2
> > --- /dev/null
> > +++ b/drivers/iio/adc/ti_adc.c
> > @@ -0,0 +1,223 @@
> > +/*
> > + * TI ADC MFD driver
> > + *
> > + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation version 2.
> > + *
> > + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> > + * kind, whether express or implied; without even the implied warranty
> > + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +struct adc_device {
> > +   struct ti_tscadc_dev *mfd_tscadc;
> > +   struct iio_dev *idev;
> > +   int channels;
> > +};
> > +
> > +static unsigned int adc_readl(struct adc_device *adc, unsigned int reg)
> > +{
> > +   return readl(adc->mfd_tscadc->tscadc_base + reg);
> > +}
> > +
> > +static void adc_writel(struct adc_device *adc, unsigned int reg,
> > +   unsigned int val)
> > +{
> > +   writel(val, adc->mfd_tscadc->tscadc_base + reg);
> > +}
> > +
> > +static void adc_step_config(struct adc_device *adc_dev)
> > +{
> > +   unsigned intstepconfig;
> > +   int i, channels = 0, steps;
> > +
> > +   /*
> > +* There are 16 configurable steps and 8 analog input
> > +* lines available which are shared between Touchscreen and ADC.
> > +*
> > +* Steps backwards i.e. from 16 towards 0 are used by ADC
> > +* depending on number of input lines needed.
> > +* Channel would represent which analog input
> > +* needs to be given to ADC to digitalize data.
> > +*/
> > +
> > +   steps = TOTAL_STEPS - adc_dev->channels;
> 

[tip:perf/core] perf symbols: Make dsos__find function globally available

2012-09-13 Thread tip-bot for Jiri Olsa
Commit-ID:  1c4be9ff5933e5c0f033ea98169cd89e22c90900
Gitweb: http://git.kernel.org/tip/1c4be9ff5933e5c0f033ea98169cd89e22c90900
Author: Jiri Olsa 
AuthorDate: Mon, 10 Sep 2012 18:50:18 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 12:05:16 -0300

perf symbols: Make dsos__find function globally available

Changing dsos__find function from static to be globally available.

Signed-off-by: Jiri Olsa 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1347295819-23177-4-git-send-email-jo...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/symbol.c |2 +-
 tools/perf/util/symbol.h |1 +
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index ba85d4f..bbb24e9 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1596,7 +1596,7 @@ void dsos__add(struct list_head *head, struct dso *dso)
list_add_tail(&dso->node, head);
 }
 
-static struct dso *dsos__find(struct list_head *head, const char *name)
+struct dso *dsos__find(struct list_head *head, const char *name)
 {
struct dso *pos;
 
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 41a15da..dde8a26 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -294,6 +294,7 @@ static inline void dso__set_loaded(struct dso *dso, enum 
map_type type)
 void dso__sort_by_name(struct dso *dso, enum map_type type);
 
 void dsos__add(struct list_head *head, struct dso *dso);
+struct dso *dsos__find(struct list_head *head, const char *name);
 struct dso *__dsos__findnew(struct list_head *head, const char *name);
 
 int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter);
--
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 v2] KVM: trace the events of mmu_notifier

2012-09-13 Thread Xiao Guangrong
On 09/10/2012 05:26 PM, Xiao Guangrong wrote:
> On 09/10/2012 05:09 PM, Avi Kivity wrote:
>> On 09/07/2012 09:16 AM, Xiao Guangrong wrote:
>>> mmu_notifier is the interface to broadcast the mm events to KVM, the
>>> tracepoints introduced in this patch can trace all these events, it is
>>> very helpful for us to notice and fix the bug caused by mm
>>
>> There is nothing kvm specific here.  Perhaps this can be made generic
>> (with a mm parameter so we can filter by process).
> 
> Hmm, i would like to put these tracepoints in the mmu-lock then we can clearly
> know the sequence between mm and kvm mmu. It is useful for us to detect the
> issue/race between them.
> 

Ping...?

--
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 memdup function

2012-09-13 Thread tip-bot for Jiri Olsa
Commit-ID:  b232e0732b1d763834c3d5b098d25d59337ba075
Gitweb: http://git.kernel.org/tip/b232e0732b1d763834c3d5b098d25d59337ba075
Author: Jiri Olsa 
AuthorDate: Mon, 10 Sep 2012 18:50:17 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 12:04:41 -0300

perf tools: Add memdup function

Adding memdup function to duplicate region of memory.

  void *memdup(const void *src, size_t len)

Signed-off-by: Jiri Olsa 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1347295819-23177-3-git-send-email-jo...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/include/linux/string.h |2 ++
 tools/perf/util/string.c   |   18 +-
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/include/linux/string.h 
b/tools/perf/util/include/linux/string.h
index 3b2f590..6f19c54 100644
--- a/tools/perf/util/include/linux/string.h
+++ b/tools/perf/util/include/linux/string.h
@@ -1 +1,3 @@
 #include 
+
+void *memdup(const void *src, size_t len);
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index 199bc4d..3217059 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -1,5 +1,5 @@
 #include "util.h"
-#include "string.h"
+#include "linux/string.h"
 
 #define K 1024LL
 /*
@@ -335,3 +335,19 @@ char *rtrim(char *s)
 
return s;
 }
+
+/**
+ * memdup - duplicate region of memory
+ * @src: memory region to duplicate
+ * @len: memory region length
+ */
+void *memdup(const void *src, size_t len)
+{
+   void *p;
+
+   p = malloc(len);
+   if (p)
+   memcpy(p, src, len);
+
+   return p;
+}
--
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: Do backtrace post unwind only if we regs and stack were captured

2012-09-13 Thread tip-bot for Jiri Olsa
Commit-ID:  bdde37163e1fd474509aab90f5eaacee46100107
Gitweb: http://git.kernel.org/tip/bdde37163e1fd474509aab90f5eaacee46100107
Author: Jiri Olsa 
AuthorDate: Mon, 10 Sep 2012 18:50:16 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 12:01:15 -0300

perf tools: Do backtrace post unwind only if we regs and stack were captured

Bail out without error if we want to do backtrace post unwind, but were
not able to capture user registers or user stack during the record
phase, which is possible and valid case.

Signed-off-by: Jiri Olsa 
Cc: Frederic Weisbecker 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1347295819-23177-2-git-send-email-jo...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/session.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 3806ea4..0ecd62b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -388,6 +388,11 @@ int machine__resolve_callchain(struct machine *machine,
  (evsel->attr.sample_type & PERF_SAMPLE_STACK_USER)))
return 0;
 
+   /* Bail out if nothing was captured. */
+   if ((!sample->user_regs.regs) ||
+   (!sample->user_stack.size))
+   return 0;
+
return unwind__get_entries(unwind_entry, &callchain_cursor, machine,
   thread, evsel->attr.sample_regs_user,
   sample);
--
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: fix ALIGN redefinition in system headers

2012-09-13 Thread tip-bot for Irina Tirdea
Commit-ID:  9ac3e487f0eeef0fa058d72da7681398cc052ee9
Gitweb: http://git.kernel.org/tip/9ac3e487f0eeef0fa058d72da7681398cc052ee9
Author: Irina Tirdea 
AuthorDate: Tue, 11 Sep 2012 01:15:01 +0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 11:48:30 -0300

perf tools: fix ALIGN redefinition in system headers

On some systems (e.g. Android), ALIGN is defined in system headers as
ALIGN(p).  The definition of ALIGN used in perf takes 2 parameters:
ALIGN(x,a).  This leads to redefinition conflicts.

Redefinition error on Android:
In file included from util/include/linux/list.h:1:0,
from util/callchain.h:5,
from util/hist.h:6,
from util/session.h:4,
from util/build-id.h:4,
from util/annotate.c:11:
util/include/linux/kernel.h:11:0: error: "ALIGN" redefined [-Werror]
bionic/libc/include/sys/param.h:38:0: note: this is the location of
the previous definition

Conflics with system defined ALIGN in Android:
util/event.c: In function 'perf_event__synthesize_comm':
util/event.c:115:32: error: macro "ALIGN" passed 2 arguments, but takes just 1
util/event.c:115:9: error: 'ALIGN' undeclared (first use in this function)
util/event.c:115:9: note: each undeclared identifier is reported only once for
each function it appears in

In order to avoid this redefinition, ALIGN is renamed to PERF_ALIGN.

Signed-off-by: Irina Tirdea 
Acked-by: Pekka Enberg 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Irina Tirdea 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Link: 
http://lkml.kernel.org/r/1347315303-29906-5-git-send-email-irina.tir...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/event.c|   10 +-
 tools/perf/util/event.h|2 +-
 tools/perf/util/header.c   |   16 
 tools/perf/util/include/linux/kernel.h |4 ++--
 tools/perf/util/session.c  |4 ++--
 tools/perf/util/symbol.c   |2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 84ff6f16..f7f4805 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -112,7 +112,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool 
*tool,
event->comm.header.type = PERF_RECORD_COMM;
 
size = strlen(event->comm.comm) + 1;
-   size = ALIGN(size, sizeof(u64));
+   size = PERF_ALIGN(size, sizeof(u64));
memset(event->comm.comm + size, 0, machine->id_hdr_size);
event->comm.header.size = (sizeof(event->comm) -
(sizeof(event->comm.comm) - size) +
@@ -145,7 +145,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool 
*tool,
 sizeof(event->comm.comm));
 
size = strlen(event->comm.comm) + 1;
-   size = ALIGN(size, sizeof(u64));
+   size = PERF_ALIGN(size, sizeof(u64));
memset(event->comm.comm + size, 0, machine->id_hdr_size);
event->comm.header.size = (sizeof(event->comm) -
  (sizeof(event->comm.comm) - size) +
@@ -228,7 +228,7 @@ static int perf_event__synthesize_mmap_events(struct 
perf_tool *tool,
size = strlen(execname);
execname[size - 1] = '\0'; /* Remove \n */
memcpy(event->mmap.filename, execname, size);
-   size = ALIGN(size, sizeof(u64));
+   size = PERF_ALIGN(size, sizeof(u64));
event->mmap.len -= event->mmap.start;
event->mmap.header.size = (sizeof(event->mmap) -
(sizeof(event->mmap.filename) - 
size));
@@ -282,7 +282,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool,
if (pos->dso->kernel)
continue;
 
-   size = ALIGN(pos->dso->long_name_len + 1, sizeof(u64));
+   size = PERF_ALIGN(pos->dso->long_name_len + 1, sizeof(u64));
event->mmap.header.type = PERF_RECORD_MMAP;
event->mmap.header.size = (sizeof(event->mmap) -
(sizeof(event->mmap.filename) - size));
@@ -494,7 +494,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool 
*tool,
map = machine->vmlinux_maps[MAP__FUNCTION];
size = snprintf(event->mmap.filename, sizeof(event->mmap.filename),
"%s%s", mmap_name, symbol_name) + 1;
-   size = ALIGN(size, sizeof(u64));
+   size = PERF_ALIGN(size, sizeof(u64));
event->mmap.header.type = PERF_RECORD_MMAP;
event->mmap.header.size = (sizeof(event->mmap) -
(sizeof(event->mmap.filename) - size) + 
machine->id_hdr_size);
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 0e088d0..21b99e7 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/

Re: [3.5.0 BUG] vmx_handle_exit: unexpected, valid vectoring info (0x80000b0e)

2012-09-13 Thread Xiao Guangrong
On 09/12/2012 04:15 PM, Avi Kivity wrote:
> On 09/12/2012 07:40 AM, Fengguang Wu wrote:
>> Hi,
>>
>> 3 of my test boxes running v3.5 kernel become unaccessible and I find
>> two of them kept emitting this dmesg:
>>
>> vmx_handle_exit: unexpected, valid vectoring info (0x8b0e) and exit 
>> reason is 0x31
>>
>> The other one has froze and the above lines are the last dmesg.
>> Any ideas?
> 
> First, that printk should be rate-limited.
> 
> Second, we should add EXIT_REASON_EPT_MISCONFIG (0x31) to 
> 
>   if ((vectoring_info & VECTORING_INFO_VALID_MASK) &&
>   (exit_reason != EXIT_REASON_EXCEPTION_NMI &&
>   exit_reason != EXIT_REASON_EPT_VIOLATION &&
>   exit_reason != EXIT_REASON_TASK_SWITCH))
>   printk(KERN_WARNING "%s: unexpected, valid vectoring info "
>  "(0x%x) and exit reason is 0x%x\n",
>  __func__, vectoring_info, exit_reason);
> 
> since it's easily caused by the guest.

Yes, i will do these.

> 
> Third, it's really unexpected.  It seems the guest was attempting to deliver 
> a page fault exception (0x0e) but encountered an mmio page during delivery 
> (in the IDT, TSS, stack, or page tables).  Is this reproducible?  If so it's 
> easy to patch kvm to halt in that case and allow examining the guest via qemu.
> 

Have no idea yet why the box was frozen under this case, will try to write a 
test case,
hope it can help me to find the reason out.

> Maybe we should do so regardless (return a KVM_EXIT_INTERNAL_ERROR).

I think this is reasonable.

Thanks!


--
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: memory-hotplug : possible circular locking dependency detected

2012-09-13 Thread Wen Congyang
At 09/13/2012 02:19 PM, Yasuaki Ishimatsu Wrote:
> When I offline a memory on linux-3.6-rc5, "possible circular
> locking dependency detected" messages are shown.
> Are the messages known problem?

It is a known problem, but it doesn't cause a deadlock.
There is 3 locks: memory hotplug's lock, memory hotplug
notifier's lock, and ksm_thread_mutex.

ksm_thread_mutex is locked when the memory is going offline
and is unlocked when the memory is offlined or the offlining
is cancelled. So we meet the warning messages. But it
doesn't cause deadlock, because we lock mem_hotplug_mutex
first.

Thanks
Wen Congyang

> 
> [  201.596363] Offlined Pages 32768
> [  201.596373] remove from free list 14 1024 148000
> [  201.596493] remove from free list 140400 1024 148000
> [  201.596612] remove from free list 140800 1024 148000
> [  201.596730] remove from free list 140c00 1024 148000
> [  201.596849] remove from free list 141000 1024 148000
> [  201.596968] remove from free list 141400 1024 148000
> [  201.597049] remove from free list 141800 1024 148000
> [  201.597049] remove from free list 141c00 1024 148000
> [  201.597049] remove from free list 142000 1024 148000
> [  201.597049] remove from free list 142400 1024 148000
> [  201.597049] remove from free list 142800 1024 148000
> [  201.597049] remove from free list 142c00 1024 148000
> [  201.597049] remove from free list 143000 1024 148000
> [  201.597049] remove from free list 143400 1024 148000
> [  201.597049] remove from free list 143800 1024 148000
> [  201.597049] remove from free list 143c00 1024 148000
> [  201.597049] remove from free list 144000 1024 148000
> [  201.597049] remove from free list 144400 1024 148000
> [  201.597049] remove from free list 144800 1024 148000
> [  201.597049] remove from free list 144c00 1024 148000
> [  201.597049] remove from free list 145000 1024 148000
> [  201.597049] remove from free list 145400 1024 148000
> [  201.597049] remove from free list 145800 1024 148000
> [  201.597049] remove from free list 145c00 1024 148000
> [  201.597049] remove from free list 146000 1024 148000
> [  201.597049] remove from free list 146400 1024 148000
> [  201.597049] remove from free list 146800 1024 148000
> [  201.597049] remove from free list 146c00 1024 148000
> [  201.597049] remove from free list 147000 1024 148000
> [  201.597049] remove from free list 147400 1024 148000
> [  201.597049] remove from free list 147800 1024 148000
> [  201.597049] remove from free list 147c00 1024 148000
> [  201.602143] 
> [  201.602150] ==
> [  201.602153] [ INFO: possible circular locking dependency detected ]
> [  201.602157] 3.6.0-rc5 #1 Not tainted
> [  201.602159] ---
> [  201.602162] bash/2789 is trying to acquire lock:
> [  201.602164]  ((memory_chain).rwsem){.+.+.+}, at: [] 
> __blocking_notifier_call_chain+0x66/0xd0
> [  201.602180] 
> [  201.602180] but task is already holding lock:
> [  201.602182]  (ksm_thread_mutex/1){+.+.+.}, at: [] 
> ksm_memory_callback+0x3a/0xc0
> [  201.602194] 
> [  201.602194] which lock already depends on the new lock.
> [  201.602194] 
> [  201.602197] 
> [  201.602197] the existing dependency chain (in reverse order) is:
> [  201.602200] 
> [  201.602200] -> #1 (ksm_thread_mutex/1){+.+.+.}:
> [  201.602208][] validate_chain+0x6d9/0x7e0
> [  201.602214][] __lock_acquire+0x2f6/0x4f0
> [  201.602219][] lock_acquire+0x9d/0x190
> [  201.602223][] __mutex_lock_common+0x5c/0x420
> [  201.602229][] mutex_lock_nested+0x4a/0x60
> [  201.602234][] ksm_memory_callback+0x3a/0xc0
> [  201.602239][] notifier_call_chain+0x67/0x150
> [  201.602244][] 
> __blocking_notifier_call_chain+0x7b/0xd0
> [  201.602250][] 
> blocking_notifier_call_chain+0x16/0x20
> [  201.602255][] memory_notify+0x1b/0x20
> [  201.602261][] offline_pages+0x1b1/0x470
> [  201.602267][] remove_memory+0x1e/0x20
> [  201.602273][] memory_block_action+0xa1/0x190
> [  201.602278][] memory_block_change_state+0x79/0xe0
> [  201.602282][] store_mem_state+0xc2/0xd0
> [  201.602287][] dev_attr_store+0x20/0x30
> [  201.602293][] sysfs_write_file+0xa3/0x100
> [  201.602299][] vfs_write+0xd0/0x1a0
> [  201.602304][] sys_write+0x54/0xa0
> [  201.602309][] system_call_fastpath+0x16/0x1b
> [  201.602315] 
> [  201.602315] -> #0 ((memory_chain).rwsem){.+.+.+}:
> [  201.602322][] check_prev_add+0x527/0x550
> [  201.602326][] validate_chain+0x6d9/0x7e0
> [  201.602331][] __lock_acquire+0x2f6/0x4f0
> [  201.602335][] lock_acquire+0x9d/0x190
> [  201.602340][] down_read+0x51/0xa0
> [  201.602345][] 
> __blocking_notifier_call_chain+0x66/0xd0
> [  201.602350][] 
> blocking_notifier_call_chain+0x16/0x20
> [  201.602355][] memory_notify+0x1b/0x20
> [ 

Re: [alex....@intel.com: Re: [PATCH] UV: fix incorrect tlb flush all issue]

2012-09-13 Thread Ingo Molnar

* Cliff Wickman  wrote:

> On Thu, Sep 13, 2012 at 05:53:10PM +0200, Ingo Molnar wrote:
> > 
> > Ack?
> > 
> > Thanks,
> > 
> > Ingo
> 
> Ack.
> But with the adjustment below.  The 'end' argument was not declared long.

Ok, great - mind sending the updated patch properly under a new 
title (the old one doesn't seem ideal), with an expanded 
changelog and with a Signed-off-by: Cliff Wickman, instead of 
the Acked-by?

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/


[tip:perf/core] perf tools: include __WORDSIZE definition

2012-09-13 Thread tip-bot for Irina Tirdea
Commit-ID:  3f34f6c0233ae055b592e8f8da23d873b82070bb
Gitweb: http://git.kernel.org/tip/3f34f6c0233ae055b592e8f8da23d873b82070bb
Author: Irina Tirdea 
AuthorDate: Tue, 11 Sep 2012 01:15:00 +0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 11:47:45 -0300

perf tools: include __WORDSIZE definition

__WORDSIZE is GLibC-specific and is not defined on all systems or glibc
versions (e.g. Android's bionic does not define it).

In file included from util/include/linux/bitmap.h:5:0,
 from util/header.h:10,
 from util/session.h:6,
 from util/build-id.h:4,
 from util/annotate.c:11:
util/include/linux/bitops.h: In function 'set_bit':
util/include/linux/bitops.h:25:12: error:
'__WORDSIZE' undeclared (first use in this function)
util/include/linux/bitops.h:25:12: note:
each undeclared identifier is reported only once for each function it appears in
util/include/linux/bitops.h:23:51: error:
parameter 'addr' set but not used [-Werror=unused-but-set-parameter]
util/include/linux/bitops.h: In function 'clear_bit':
util/include/linux/bitops.h:30:12: error:
'__WORDSIZE' undeclared (first use in this function)
util/include/linux/bitops.h:28:53: error:
parameter 'addr' set but not used [-Werror=unused-but-set-parameter]
In file included from util/header.h:10:0,
 from util/session.h:6,
 from util/build-id.h:4,
 from util/annotate.c:11:
util/include/linux/bitmap.h: In function 'bitmap_zero':
util/include/linux/bitmap.h:22:6: error:
'__WORDSIZE' undeclared (first use in this function)

Defining __WORDSIZE in perf's headers if it is not already defined.

Suggested-by: Peter Zijlstra 
Suggested-by: Pekka Enberg 
Signed-off-by: Irina Tirdea 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Irina Tirdea 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Link: 
http://lkml.kernel.org/r/1347315303-29906-4-git-send-email-irina.tir...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/include/linux/bitops.h |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/include/linux/bitops.h 
b/tools/perf/util/include/linux/bitops.h
index 587a230..a55d8cf 100644
--- a/tools/perf/util/include/linux/bitops.h
+++ b/tools/perf/util/include/linux/bitops.h
@@ -5,6 +5,10 @@
 #include 
 #include 
 
+#ifndef __WORDSIZE
+#define __WORDSIZE (__SIZEOF_LONG__ * 8)
+#endif
+
 #define BITS_PER_LONG __WORDSIZE
 #define BITS_PER_BYTE   8
 #define BITS_TO_LONGS(nr)   DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
--
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: Update types definitions for Android

2012-09-13 Thread tip-bot for Irina Tirdea
Commit-ID:  86d5a70c1eeb3d35bcadc94753fd9651df8835a8
Gitweb: http://git.kernel.org/tip/86d5a70c1eeb3d35bcadc94753fd9651df8835a8
Author: Irina Tirdea 
AuthorDate: Tue, 11 Sep 2012 01:14:59 +0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 11:46:09 -0300

perf tools: Update types definitions for Android

Some type definitions are missing from Android or are already defined in
bionic and lead to redefinition errors.

Android defines in types.h __le32. Since perf is wrapping  with a
local version, we need to define this constant in the local version too.
Error in Android:
In file included from bionic/libc/include/unistd.h:36:0,
 from external/perf/tools/perf/util/util.h:46,
 from external/perf/tools/perf/util/cache.h:5,
 from external/perf/tools/perf/util/abspath.c:1:
bionic/libc/kernel/common/linux/capability.h:60:2:
error: unknown type name '__le32'

roundup() definition is missing:
util/symbol.c: In function 'symbols__fixup_end':
util/symbol.c:106: warning: implicit declaration of function 'roundup'
util/symbol.c:106: warning: nested extern declaration of 'roundup'

__force macro defined in perf is also defined in libc which leads to
redefinition errors. In order to avoid these, we guard these definition
with

Signed-off-by: Irina Tirdea 
Acked-by: Pekka Enberg 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Irina Tirdea 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Link: 
http://lkml.kernel.org/r/1347315303-29906-3-git-send-email-irina.tir...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/include/linux/compiler.h |4 
 tools/perf/util/include/linux/kernel.h   |9 +
 tools/perf/util/include/linux/types.h|8 
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/include/linux/compiler.h 
b/tools/perf/util/include/linux/compiler.h
index 2dc8671..ce2367b 100644
--- a/tools/perf/util/include/linux/compiler.h
+++ b/tools/perf/util/include/linux/compiler.h
@@ -12,4 +12,8 @@
 #define __used __attribute__((__unused__))
 #define __packed   __attribute__((__packed__))
 
+#ifndef __force
+#define __force
+#endif
+
 #endif
diff --git a/tools/perf/util/include/linux/kernel.h 
b/tools/perf/util/include/linux/kernel.h
index 4af9a10..a978f26 100644
--- a/tools/perf/util/include/linux/kernel.h
+++ b/tools/perf/util/include/linux/kernel.h
@@ -46,6 +46,15 @@
_min1 < _min2 ? _min1 : _min2; })
 #endif
 
+#ifndef roundup
+#define roundup(x, y) (\
+{  \
+   const typeof(y) __y = y;   \
+   (((x) + (__y - 1)) / __y) * __y;   \
+}  \
+)
+#endif
+
 #ifndef BUG_ON
 #ifdef NDEBUG
 #define BUG_ON(cond) do { if (cond) {} } while (0)
diff --git a/tools/perf/util/include/linux/types.h 
b/tools/perf/util/include/linux/types.h
index 12de3b8..eb46478 100644
--- a/tools/perf/util/include/linux/types.h
+++ b/tools/perf/util/include/linux/types.h
@@ -3,6 +3,14 @@
 
 #include 
 
+#ifndef __bitwise
+#define __bitwise
+#endif
+
+#ifndef __le32
+typedef __u32 __bitwise __le32;
+#endif
+
 #define DECLARE_BITMAP(name,bits) \
unsigned long name[BITS_TO_LONGS(bits)]
 
--
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 perf_regs. h file to MANIFEST

2012-09-13 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  fe392c535644b8ee370a219ca63557611e0b0365
Gitweb: http://git.kernel.org/tip/fe392c535644b8ee370a219ca63557611e0b0365
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 11 Sep 2012 11:42:41 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 11 Sep 2012 11:42:41 -0300

perf tools: Add missing perf_regs.h file to MANIFEST

The 2bcd355 broke the perf-tar*-src-pkg generated tarballs builds, fix
it.

Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/n/tip-2ndz2o636rn4q175fwn18...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/MANIFEST |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index b4b572e..0518079 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -10,6 +10,7 @@ include/linux/stringify.h
 lib/rbtree.c
 include/linux/swab.h
 arch/*/include/asm/unistd*.h
+arch/*/include/asm/perf_regs.h
 arch/*/lib/memcpy*.S
 arch/*/lib/memset*.S
 include/linux/poison.h
--
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 v4 0/8] Avoid cache trashing on clearing huge/gigantic page

2012-09-13 Thread Ingo Molnar

* Andrew Morton  wrote:

> On Mon, 20 Aug 2012 16:52:29 +0300
> "Kirill A. Shutemov"  wrote:
> 
> > Clearing a 2MB huge page will typically blow away several levels of CPU
> > caches.  To avoid this only cache clear the 4K area around the fault
> > address and use a cache avoiding clears for the rest of the 2MB area.
> > 
> > This patchset implements cache avoiding version of clear_page only for
> > x86. If an architecture wants to provide cache avoiding version of
> > clear_page it should to define ARCH_HAS_USER_NOCACHE to 1 and implement
> > clear_page_nocache() and clear_user_highpage_nocache().
> 
> Patchset looks nice to me, but the changelogs are terribly 
> short of performance measurements.  For this sort of change I 
> do think it is important that pretty exhaustive testing be 
> performed, and that the results (or a readable summary of 
> them) be shown.  And that testing should be designed to probe 
> for slowdowns, not just the speedups!

That is my general impression as well.

Firstly, doing before/after "perf stat --repeat 3 ..." runs 
showing a statistically significant effect on a workload that is 
expected to win from this, and on a workload expected to be 
hurting from this would go a long way towards convincing me.

Secondly, if you can find some user-space simulation of the 
intended positive (and negative) effects then a 'perf bench' 
testcase designed to show weakness of any such approach, running 
the very kernel assembly code in user-space would also be rather 
useful.

See:

comet:~/tip> git grep x86 tools/perf/bench/ | grep inclu
tools/perf/bench/mem-memcpy-arch.h:#include "mem-memcpy-x86-64-asm-def.h"
tools/perf/bench/mem-memcpy-x86-64-asm.S:#include 
"../../../arch/x86/lib/memcpy_64.S"
tools/perf/bench/mem-memcpy.c:#include "mem-memcpy-x86-64-asm-def.h"
tools/perf/bench/mem-memset-arch.h:#include "mem-memset-x86-64-asm-def.h"
tools/perf/bench/mem-memset-x86-64-asm.S:#include 
"../../../arch/x86/lib/memset_64.S"
tools/perf/bench/mem-memset.c:#include "mem-memset-x86-64-asm-def.h"

that code uses the kernel-side assembly code and runs it in 
user-space.

Although obviously clearing pages on page faults needs some care 
to properly simulate in user-space.

Without repeatable hard numbers such code just gets into the 
kernel and bitrots there as new CPU generations come in - a few 
years down the line the original decisions often degrade to pure 
noise. We've been there, we've done that, we don't want to 
repeat it.

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/


[tip:perf/core] perf kmem: Remove die() calls

2012-09-13 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  2814eb05720baa54ffe0950714fd55a5bcc8a565
Gitweb: http://git.kernel.org/tip/2814eb05720baa54ffe0950714fd55a5bcc8a565
Author: Arnaldo Carvalho de Melo 
AuthorDate: Sat, 8 Sep 2012 22:53:06 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Sun, 9 Sep 2012 11:39:02 -0300

perf kmem: Remove die() calls

Just use pr_err() + return -1 and perf_session__process_events to abort
when some event would call die(), then let the perf's main() exit doing
whatever it needs.

Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/n/tip-i7rhuqfwshjiwc9gr9m1v...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kmem.c |  108 -
 1 files changed, 67 insertions(+), 41 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index fc6607b..ad9f520 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -58,41 +58,52 @@ static unsigned long nr_allocs, nr_cross_allocs;
 
 #define PATH_SYS_NODE  "/sys/devices/system/node"
 
-static void init_cpunode_map(void)
+static int init_cpunode_map(void)
 {
FILE *fp;
-   int i;
+   int i, err = -1;
 
fp = fopen("/sys/devices/system/cpu/kernel_max", "r");
if (!fp) {
max_cpu_num = 4096;
-   return;
+   return 0;
+   }
+
+   if (fscanf(fp, "%d", &max_cpu_num) < 1) {
+   pr_err("Failed to read 'kernel_max' from sysfs");
+   goto out_close;
}
 
-   if (fscanf(fp, "%d", &max_cpu_num) < 1)
-   die("Failed to read 'kernel_max' from sysfs");
max_cpu_num++;
 
cpunode_map = calloc(max_cpu_num, sizeof(int));
-   if (!cpunode_map)
-   die("calloc");
+   if (!cpunode_map) {
+   pr_err("%s: calloc failed\n", __func__);
+   goto out_close;
+   }
+
for (i = 0; i < max_cpu_num; i++)
cpunode_map[i] = -1;
+
+   err = 0;
+out_close:
fclose(fp);
+   return err;
 }
 
-static void setup_cpunode_map(void)
+static int setup_cpunode_map(void)
 {
struct dirent *dent1, *dent2;
DIR *dir1, *dir2;
unsigned int cpu, mem;
char buf[PATH_MAX];
 
-   init_cpunode_map();
+   if (init_cpunode_map())
+   return -1;
 
dir1 = opendir(PATH_SYS_NODE);
if (!dir1)
-   return;
+   return -1;
 
while ((dent1 = readdir(dir1)) != NULL) {
if (dent1->d_type != DT_DIR ||
@@ -112,10 +123,11 @@ static void setup_cpunode_map(void)
closedir(dir2);
}
closedir(dir1);
+   return 0;
 }
 
-static void insert_alloc_stat(unsigned long call_site, unsigned long ptr,
- int bytes_req, int bytes_alloc, int cpu)
+static int insert_alloc_stat(unsigned long call_site, unsigned long ptr,
+int bytes_req, int bytes_alloc, int cpu)
 {
struct rb_node **node = &root_alloc_stat.rb_node;
struct rb_node *parent = NULL;
@@ -139,8 +151,10 @@ static void insert_alloc_stat(unsigned long call_site, 
unsigned long ptr,
data->bytes_alloc += bytes_alloc;
} else {
data = malloc(sizeof(*data));
-   if (!data)
-   die("malloc");
+   if (!data) {
+   pr_err("%s: malloc failed\n", __func__);
+   return -1;
+   }
data->ptr = ptr;
data->pingpong = 0;
data->hit = 1;
@@ -152,9 +166,10 @@ static void insert_alloc_stat(unsigned long call_site, 
unsigned long ptr,
}
data->call_site = call_site;
data->alloc_cpu = cpu;
+   return 0;
 }
 
-static void insert_caller_stat(unsigned long call_site,
+static int insert_caller_stat(unsigned long call_site,
  int bytes_req, int bytes_alloc)
 {
struct rb_node **node = &root_caller_stat.rb_node;
@@ -179,8 +194,10 @@ static void insert_caller_stat(unsigned long call_site,
data->bytes_alloc += bytes_alloc;
} else {
data = malloc(sizeof(*data));
-   if (!data)
-   die("malloc");
+   if (!data) {
+   pr_err("%s: malloc failed\n", __func__);
+   return -1;
+   }
data->call_site = call_site;
data->pingpong = 0;
data->hit = 1;
@@ -190,11 +207,12 @@ static void insert_caller_stat(unsigned long call_site,
rb_link_node(&data->node, parent, node);
rb_insert_color(&data->node, &root_caller_stat);
}
+
+   return 0;
 }
 
-static void perf_evsel__process_alloc_event(struct perf_evsel *ev

[tip:perf/core] perf sched: Remove die() calls

2012-09-13 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  a116e05dcf61c8d758e0f0aed40325534aee2c13
Gitweb: http://git.kernel.org/tip/a116e05dcf61c8d758e0f0aed40325534aee2c13
Author: Arnaldo Carvalho de Melo 
AuthorDate: Sat, 8 Sep 2012 22:53:06 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Sun, 9 Sep 2012 11:39:02 -0300

perf sched: Remove die() calls

Just use pr_err() + return -1 and perf_session__process_events to abort
when some event would call die(), then let the perf's main() exit doing
whatever it needs.

Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/n/tip-88cwdogxqomsy9tfr8r0a...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c |  281 
 1 files changed, 179 insertions(+), 102 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index a25a023..782f66d 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -423,8 +423,8 @@ static int self_open_counters(void)
fd = sys_perf_event_open(&attr, 0, -1, -1, 0);
 
if (fd < 0)
-   die("Error: sys_perf_event_open() syscall returned"
-   "with %d (%s)\n", fd, strerror(errno));
+   pr_debug("Error: sys_perf_event_open() syscall returned"
+"with %d (%s)\n", fd, strerror(errno));
return fd;
 }
 
@@ -450,7 +450,8 @@ static void *thread_func(void *ctx)
sprintf(comm2, ":%s", this_task->comm);
prctl(PR_SET_NAME, comm2);
fd = self_open_counters();
-
+   if (fd < 0)
+   return NULL;
 again:
ret = sem_post(&this_task->ready_for_work);
BUG_ON(ret);
@@ -726,30 +727,30 @@ struct trace_migrate_task_event {
 };
 
 struct trace_sched_handler {
-   void (*switch_event)(struct trace_switch_event *,
-struct machine *,
-struct event_format *,
-struct perf_sample *sample);
-
-   void (*runtime_event)(struct trace_runtime_event *,
- struct machine *,
- struct perf_sample *sample);
+   int (*switch_event)(struct trace_switch_event *event,
+   struct machine *machine,
+   struct event_format *tp_format,
+   struct perf_sample *sample);
 
-   void (*wakeup_event)(struct trace_wakeup_event *,
-struct machine *,
-struct event_format *,
+   int (*runtime_event)(struct trace_runtime_event *event,
+struct machine *machine,
 struct perf_sample *sample);
 
-   void (*fork_event)(struct trace_fork_event *,
-  struct event_format *event);
+   int (*wakeup_event)(struct trace_wakeup_event *event,
+   struct machine *machine,
+   struct event_format *tp_format,
+   struct perf_sample *sample);
 
-   void (*migrate_task_event)(struct trace_migrate_task_event *,
-  struct machine *machine,
-  struct perf_sample *sample);
+   int (*fork_event)(struct trace_fork_event *event,
+ struct event_format *tp_format);
+
+   int (*migrate_task_event)(struct trace_migrate_task_event *event,
+ struct machine *machine,
+ struct perf_sample *sample);
 };
 
 
-static void
+static int
 replay_wakeup_event(struct trace_wakeup_event *wakeup_event,
struct machine *machine __used,
struct event_format *event, struct perf_sample *sample)
@@ -769,11 +770,12 @@ replay_wakeup_event(struct trace_wakeup_event 
*wakeup_event,
wakee = register_pid(wakeup_event->pid, wakeup_event->comm);
 
add_sched_event_wakeup(waker, sample->time, wakee);
+   return 0;
 }
 
 static u64 cpu_last_switched[MAX_CPUS];
 
-static void
+static int
 replay_switch_event(struct trace_switch_event *switch_event,
struct machine *machine __used,
struct event_format *event,
@@ -788,7 +790,7 @@ replay_switch_event(struct trace_switch_event *switch_event,
printf("sched_switch event %p\n", event);
 
if (cpu >= MAX_CPUS || cpu < 0)
-   return;
+   return 0;
 
timestamp0 = cpu_last_switched[cpu];
if (timestamp0)
@@ -796,8 +798,10 @@ replay_switch_event(struct trace_switch_event 
*switch_event,
else
delta = 0;
 
-   if (delta < 0)
-   die("hm, delta: %" PRIu64 " < 0 ?\n", delta);
+   if (delta < 0) {
+   pr_debug("hm, delta: %" PRIu64 " < 0 ?\n", delta);
+

[tip:perf/core] perf test: Remove die() calls

2012-09-13 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  32c7f7383a096a4fc878fdda686c7725945e8a8f
Gitweb: http://git.kernel.org/tip/32c7f7383a096a4fc878fdda686c7725945e8a8f
Author: Arnaldo Carvalho de Melo 
AuthorDate: Sat, 8 Sep 2012 22:53:06 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Sun, 9 Sep 2012 11:39:02 -0300

perf test: Remove die() calls

Just use pr_err() + return -1 and let the other tests run as well and
then the perf's main() exit doing whatever it needs.

Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/n/tip-n5ahw26e94klmde9cz6rx...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-test.c |   14 --
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index cf33e50..6ae102e 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -1023,14 +1023,16 @@ static int __test__rdpmc(void)
 
fd = sys_perf_event_open(&attr, 0, -1, -1, 0);
if (fd < 0) {
-   die("Error: sys_perf_event_open() syscall returned "
-   "with %d (%s)\n", fd, strerror(errno));
+   pr_debug("Error: sys_perf_event_open() syscall returned "
+"with %d (%s)\n", fd, strerror(errno));
+   return -1;
}
 
addr = mmap(NULL, page_size, PROT_READ, MAP_SHARED, fd, 0);
if (addr == (void *)(-1)) {
-   die("Error: mmap() syscall returned "
-   "with (%s)\n", strerror(errno));
+   pr_debug("Error: mmap() syscall returned with (%s)\n",
+strerror(errno));
+   goto out_close;
}
 
for (n = 0; n < 6; n++) {
@@ -1051,9 +1053,9 @@ static int __test__rdpmc(void)
}
 
munmap(addr, page_size);
-   close(fd);
-
pr_debug("   ");
+out_close:
+   close(fd);
 
if (!delta_sum)
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 v2 2/3] sched:nohz rename clear_nohz_tick_stopped as nohz_balance_exit_idle

2012-09-13 Thread Alex Shi
This patch just rename the function clear_nohz_tick_stopped() to
nohz_balance_exit_idle(), that align with nohz_balance_enter_idle.

no function changes.

Signed-off-by: Alex Shi 
---
 kernel/sched/fair.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b681941..60d5505 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4634,7 +4634,7 @@ static void nohz_balancer_kick(int cpu)
return;
 }
 
-static inline void clear_nohz_tick_stopped(int cpu)
+static inline void nohz_balance_exit_idle(int cpu)
 {
if (unlikely(test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu {
cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
@@ -4698,7 +4698,7 @@ static int __cpuinit sched_ilb_notifier(struct 
notifier_block *nfb,
 {
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_DYING:
-   clear_nohz_tick_stopped(smp_processor_id());
+   nohz_balance_exit_idle(smp_processor_id());
return NOTIFY_OK;
default:
return NOTIFY_DONE;
@@ -4858,7 +4858,7 @@ static inline int nohz_kick_needed(struct rq *rq, int cpu)
* busy tick after returning from idle, we will update the busy stats.
*/
set_cpu_sd_state_busy();
-   clear_nohz_tick_stopped(cpu);
+   nohz_balance_exit_idle(cpu);
 
/*
 * None are in tickless mode and hence no need for NOHZ idle load
-- 
1.7.12

--
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] few functions clean up

2012-09-13 Thread Alex Shi
Changed according to Peter and Suresh suggestion.

Thanks
[PATCH v2 1/3] nohz: clean up select_nohz_load_balancer()
[PATCH v2 2/3] sched:nohz rename clear_nohz_tick_stopped as
[PATCH v2 3/3] sched/balance: remove on_null_domain() in
--
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/3] sched/balance: remove on_null_domain() in trigger_load_balance

2012-09-13 Thread Alex Shi
According to Suresh's inverstigation, the first on_null_domain in
trigger_load_balance is for avoiding unnecessary loadbalances(from
softirq) when a SMP kernel running on UP machine.
The second on_null_domain is not needed, since nohz_kick_needed()
will return 0 in this scenario.

So, remove the 2nd on_null_domain calling.

Signed-off-by: Alex Shi 
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 60d5505..1ae2c66 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4938,7 +4938,7 @@ void trigger_load_balance(struct rq *rq, int cpu)
likely(!on_null_domain(cpu)))
raise_softirq(SCHED_SOFTIRQ);
 #ifdef CONFIG_NO_HZ
-   if (nohz_kick_needed(rq, cpu) && likely(!on_null_domain(cpu)))
+   if (nohz_kick_needed(rq, cpu))
nohz_balancer_kick(cpu);
 #endif
 }
-- 
1.7.12

--
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 1/3] nohz: clean up select_nohz_load_balancer()

2012-09-13 Thread Alex Shi
There is no load_balancer to be selected now. It just set state of
nohz tick stopping.

So rename the function as nohz_balance_enter_idle according to Peter's
suggestion, pass the 'cpu' from parameter and then
remove the useless calling from tick_nohz_restart_sched_tick().

Signed-off-by: Alex Shi 
---
 include/linux/sched.h|  4 ++--
 kernel/sched/fair.c  | 19 +++
 kernel/time/tick-sched.c |  3 +--
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index b8c8664..e723a4b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -273,11 +273,11 @@ extern void init_idle_bootup_task(struct task_struct 
*idle);
 extern int runqueue_is_locked(int cpu);
 
 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
-extern void select_nohz_load_balancer(int stop_tick);
+extern void nohz_balance_enter_idle(int cpu);
 extern void set_cpu_sd_state_idle(void);
 extern int get_nohz_timer_target(void);
 #else
-static inline void select_nohz_load_balancer(int stop_tick) { }
+static inline void nohz_balance_enter_idle(int cpu) { }
 static inline void set_cpu_sd_state_idle(void) { }
 #endif
 
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c219bf8..b681941 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4674,28 +4674,23 @@ void set_cpu_sd_state_idle(void)
 }
 
 /*
- * This routine will record that this cpu is going idle with tick stopped.
+ * This routine will record that the cpu is going idle with tick stopped.
  * This info will be used in performing idle load balancing in the future.
  */
-void select_nohz_load_balancer(int stop_tick)
+void nohz_balance_enter_idle(int cpu)
 {
-   int cpu = smp_processor_id();
-
/*
 * If this cpu is going down, then nothing needs to be done.
 */
if (!cpu_active(cpu))
return;
 
-   if (stop_tick) {
-   if (test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))
-   return;
+   if (test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))
+   return;
 
-   cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
-   atomic_inc(&nohz.nr_cpus);
-   set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
-   }
-   return;
+   cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
+   atomic_inc(&nohz.nr_cpus);
+   set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
 }
 
 static int __cpuinit sched_ilb_notifier(struct notifier_block *nfb,
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 024540f..0e6a945 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -372,7 +372,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched 
*ts,
 * the scheduler tick in nohz_restart_sched_tick.
 */
if (!ts->tick_stopped) {
-   select_nohz_load_balancer(1);
+   nohz_balance_enter_idle(cpu);
calc_load_enter_idle();
 
ts->last_tick = hrtimer_get_expires(&ts->sched_timer);
@@ -569,7 +569,6 @@ static void tick_nohz_restart(struct tick_sched *ts, 
ktime_t now)
 static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now)
 {
/* Update jiffies first */
-   select_nohz_load_balancer(0);
tick_do_update_jiffies64(now);
update_cpu_load_nohz();
 
-- 
1.7.12

--
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 3/3 v2] perf tool: give user better message if precise is not supported

2012-09-13 Thread Ingo Molnar

* David Ahern  wrote:

> Platforms (e.g., VM's) without support for precise mode get a confusing
> error message. e.g.,
> $ perf record -e cycles:p -a -- sleep 1
> 
>   Error: sys_perf_event_open() syscall returned with 95 (Operation not
>   supported).  /bin/dmesg may provide additional information.
> 
>   No hardware sampling interrupt available. No APIC? If so then you can
>   boot the kernel with the "lapic" boot parameter to force-enable it.
>   sleep: Terminated
> 
> which is not clear that precise mode might be the root problem. With this
> patch:
> 
> $ perf record -e cycles:p -fo /tmp/perf.data -- sleep 1
>   Error:
>   'precise' request may not be supported. Try removing 'p' modifier
>   sleep: Terminated
> 
> v2: softened message to 'may not be' supported per Robert's suggestion

Well, either it's supported on this machine or it's not - why 
does the text have to be so unsure about it?

We use computers to increase determinism, not to insert extra 
uncertainty! ;-)

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 2/4] perf stat: add compile-time option to disable --big-num

2012-09-13 Thread Ingo Molnar

* Irina Tirdea  wrote:

> From: Irina Tirdea 
> 
> In printf's format, ' is used to group the output with thousands' grouping
> characters for decimal conversion. Bionic does not support ' for printf.

Please try to solve compatibility without affecting the default 
output and big num is the default perf stat output.

Could the big num output be implemented within perf, without 
relying on glibc's printf implementation?

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/


linux-next: manual merge of the workqueues tree with the net tree

2012-09-13 Thread Stephen Rothwell
Hi Tejun,

Today's linux-next merge of the workqueues tree got a conflict in
drivers/isdn/mISDN/hwchannel.c between commit 4b921eda5336 ("mISDN: Fix
wrong usage of flush_work_sync while holding locks") from the  tree and
commit 43829731dd37 ("workqueue: deprecate flush[_delayed]_work_sync()")
from the workqueues tree.

The former supercedes the latter (I think) so I used that and can carry
the fix as necessary (no action is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpYpc2jorsFX.pgp
Description: PGP signature


Re: [PATCH] power: battery: Generic battery driver using IIO

2012-09-13 Thread anish singh
On Fri, Sep 14, 2012 at 5:16 AM, Anton Vorontsov  wrote:
> On Thu, Sep 13, 2012 at 09:46:32PM +0530, anish kumar wrote:
>> From: anish kumar 
>>
>> In this version:
>> Addressed concerns raised by lars:
>> a. made the adc_bat per device.
>> b. get the IIO channel using hardcoded channel names.
>> c. Minor issues related to gpio_is_valid and some code
>>refactoring.
>>
>> Signed-off-by: anish kumar 
>> ---
>
> Anish, much thanks for your work! This is much appreciated.
I can't thank you enough for your excellent review.I wonder how
you even spotted the indentation errors which even checkpatch
couldn't check.
>
> There are a few comments below, they don't require any design
> changes, just some technical issues, which wouldn't hard to fix,
> I guess.
>
> And again, thanks for your efforts!
>
>>  drivers/power/generic-adc-battery.c   |  460 
>> +
>>  include/linux/power/generic-adc-battery.h |   33 ++
>>  2 files changed, 493 insertions(+), 0 deletions(-)
>>  create mode 100644 drivers/power/generic-adc-battery.c
>>  create mode 100644 include/linux/power/generic-adc-battery.h
>>
>> diff --git a/drivers/power/generic-adc-battery.c 
>> b/drivers/power/generic-adc-battery.c
>> new file mode 100644
>> index 000..003e0e1
>> --- /dev/null
>> +++ b/drivers/power/generic-adc-battery.c
>> @@ -0,0 +1,460 @@
>> +/*
>> + * Generic battery driver code using IIO
>> + * Copyright (C) 2012, Anish Kumar 
>> + * based on jz4740-battery.c
>> + * based on s3c_adc_battery.c
>> + *
>> + * This file is subject to the terms and conditions of the GNU General 
>> Public
>> + * License.  See the file COPYING in the main directory of this archive for
>> + * more details.
>> + *
>
> No need for this empty comment line.
>
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>
> No need for this empty line.
>
>> +#include 
>> +
>> +#define to_generic_bat(ptr)  \
>> + container_of(ptr, struct generic_adc_bat, ptr)
>
> This will fit on one line.
>
> Plus, it look strange that you use 'struct generic_adc_bat' before
> actually declaring it. :-) Surely it works because it's a macro.
>
> Also, while this is a simple one-liner, I'd really suggest making
> it a function. That way you also won't have a risk to evaluate
> 'ptr' expression twice, plus the function is type-safe (unlike
> the macro).
>
>> +
>> +enum chan_type {
>> + VOLTAGE = 0,
>> + CURRENT,
>> + POWER,
>> + MAX_CHAN_TYPE
>
> The enum is in the global namespace. Please prefix items with
> GEN_ADC_BAT (or GENERIC_ADC_BAT, but that would be too long).
>
> Personally, I like making acronyms. I.e., while file name already
> makes it pretty clear that it is generic_adc_battery, in the file
> itself you can use short gab_ and GAB_ everywhere.
>
> Anyways, it's up to you. generic_adc_bat_ prefix is also fine. But
> be consistent.
>
> The same with chan_type, please prefix it with something.
>
>> +};
>> +
>> +#define CHAN_MAX_NAME 30
>> +/*
>> + * channel_name suggests the standard channel names for commonly used
>> + * channel types.
>> + */
>> +char channel_name[][CHAN_MAX_NAME + 1] = {
>
> Ditto. gab_channel_name.
>
> Plus, you can make it char *gab_channel_name[] = {
> [VOLTAGE] = "voltage",
> [...] = ...,
> };
>
> Thus no need for MAX_NAME.
>
>> + [VOLTAGE]   = "voltage",
>> + [CURRENT]   = "current",
>> + [POWER] = "power",
>> +};
>> +
>> +struct generic_adc_bat {
>> + struct power_supply psy;
>> + struct iio_channel  **channel;
>> + struct iio_battery_platform_data*pdata;
>> + struct delayed_work bat_work;
>> + int was_plugged;
>> + int volt_value;
>> + int cur_value;
>> + int level;
>> + int status;
>> + int cable_plugged:1;
>> +};
>> +
>> +static void generic_adc_bat_ext_power_changed(struct power_supply *psy)
>> +{
>> + struct generic_adc_bat *adc_bat;
>> + adc_bat = to_generic_bat(psy);
>
> This would fit into one line.
>
>> +
>> + schedule_delayed_work(&adc_bat->bat_work,
>> + msecs_to_jiffies(adc_bat->pdata->jitter_delay));
>> +}
>> +
>> +static enum power_supply_property bat_props[] = {
>
> While it's static, it still looks awkward that you don't prefix it.
>
>> + POWER_SUPPLY_PROP_STATUS,
>> + POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
>> + POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN,
>> + POWER_SUPPLY_PROP_CHARGE_NOW,
>> + POWER_SUPPLY_PROP_VOLTAGE_NOW,
>> + POWER_SUPPLY_PROP_CURRENT_NOW,
>> + POWER_SUPPLY_PROP_TECHNOLOGY,
>> + POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
>> + POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
>> + POWER_SUPPLY_PROP_MODEL_NAME,
>> +};
>> +
>> +/*
>> + * This properties are set based on the received platform data and this
>> + * s

Re: [PATCH] pinctrl: use kasprintf() in pinmux_request_gpio()

2012-09-13 Thread Joe Perches
On Thu, 2012-09-13 at 21:49 +0200, Thomas Petazzoni wrote:
> Instead of using a temporary buffer, snprintf() and kstrdup(), just
> use kasprintf() that does the same thing in just oneline.
> 
> Signed-off-by: Thomas Petazzoni 
> ---
>  drivers/pinctrl/pinmux.c |5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
> index 3d5ac73..9301a7a 100644
> --- a/drivers/pinctrl/pinmux.c
> +++ b/drivers/pinctrl/pinmux.c
> @@ -232,14 +232,11 @@ int pinmux_request_gpio(struct pinctrl_dev *pctldev,
>   struct pinctrl_gpio_range *range,
>   unsigned pin, unsigned gpio)
>  {
> - char gpiostr[16];
>   const char *owner;
>   int ret;
>  
>   /* Conjure some name stating what chip and pin this is taken by */
> - snprintf(gpiostr, 15, "%s:%d", range->name, gpio);
> -
> - owner = kstrdup(gpiostr, GFP_KERNEL);
> + owner = kasprintf(GFP_KERNEL, "%s:%d", range->name, gpio);
>   if (!owner)
>   return -EINVAL;
>  

No not really.  It's a bit different because the first
snprintf is length limited but the kasprintf is not.


--
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 v3 5/5] MFD: ti_tscadc: add suspend/resume functionality

2012-09-13 Thread Patil, Rachna
On Fri, Sep 14, 2012 at 10:39:20, Venu Byravarasu wrote:
> > -Original Message-
> > From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel- 
> > ow...@vger.kernel.org] On Behalf Of Patil, Rachna
> > Sent: Friday, September 14, 2012 10:29 AM
> > To: Lars-Peter Clausen
> > Cc: linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; linux- 
> > i...@vger.kernel.org; Samuel Ortiz; Dmitry Torokhov; Dmitry Torokhov; 
> > Jonathan Cameron
> > Subject: RE: [PATCH v3 5/5] MFD: ti_tscadc: add suspend/resume 
> > functionality
> > 
> > On Thu, Sep 13, 2012 at 18:31:35, Lars-Peter Clausen wrote:
> > > On 09/13/2012 12:40 PM, Patil, Rachna wrote:
> > > > This patch adds support for suspend/resume of TSC/ADC MFDevice.
> > > >
> > > > Signed-off-by: Patil, Rachna 
> > > > ---
> > > > Changes in v2:
> > > > Added this patch newly in this patch series.
> > > >
> > > > Changes in v3:
> > > > No changes.
> > > >
> > > >  drivers/iio/adc/ti_adc.c   |   32
> > 
> > > >  drivers/input/touchscreen/ti_tsc.c |   33
> > +
> > > >  drivers/mfd/ti_tscadc.c|   33
> > -
> > > >  include/linux/mfd/ti_tscadc.h  |3 +++
> > > >  4 files changed, 100 insertions(+), 1 deletions(-)
> > > >
> > > > diff --git a/drivers/iio/adc/ti_adc.c b/drivers/iio/adc/ti_adc.c 
> > > > index 56f8af2..69f19f0 100644
> > > > --- a/drivers/iio/adc/ti_adc.c
> > > > +++ b/drivers/iio/adc/ti_adc.c
> > > > @@ -207,6 +207,36 @@ static int __devexit tiadc_remove(struct
> > platform_device *pdev)
> > > > return 0;
> > > >  }
> > > >
> > > [...]
> > > >  static struct platform_driver tiadc_driver = {
> > > > .driver = {
> > > > .name   = "tiadc",
> > > > @@ -214,6 +244,8 @@ static struct platform_driver tiadc_driver = {
> > > > },
> > > > .probe  = tiadc_probe,
> > > > .remove = __devexit_p(tiadc_remove),
> > > > +   .suspend = adc_suspend,
> > > > +   .resume = adc_resume,
> > > >  };
> > > >
> > >
> > >
> > > Using the suspend/resume callbacks is deprecated, please use
> > dev_pm_ops.
> > > Same comment applies to the other two drivers.
> > 
> > Ok. I will make changes in all the 3 driver to use dev_pm_ops instead 
> > of suspend/resume callbacks.
> 
> Probably you might need to protect suspend/resumes with CONFIG_PM. 

Yes, I will add that as well.

Regards,
Rachna

--
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 v3 5/5] MFD: ti_tscadc: add suspend/resume functionality

2012-09-13 Thread Venu Byravarasu
> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
> ow...@vger.kernel.org] On Behalf Of Patil, Rachna
> Sent: Friday, September 14, 2012 10:29 AM
> To: Lars-Peter Clausen
> Cc: linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; linux-
> i...@vger.kernel.org; Samuel Ortiz; Dmitry Torokhov; Dmitry Torokhov;
> Jonathan Cameron
> Subject: RE: [PATCH v3 5/5] MFD: ti_tscadc: add suspend/resume
> functionality
> 
> On Thu, Sep 13, 2012 at 18:31:35, Lars-Peter Clausen wrote:
> > On 09/13/2012 12:40 PM, Patil, Rachna wrote:
> > > This patch adds support for suspend/resume of TSC/ADC MFDevice.
> > >
> > > Signed-off-by: Patil, Rachna 
> > > ---
> > > Changes in v2:
> > >   Added this patch newly in this patch series.
> > >
> > > Changes in v3:
> > >   No changes.
> > >
> > >  drivers/iio/adc/ti_adc.c   |   32
> 
> > >  drivers/input/touchscreen/ti_tsc.c |   33
> +
> > >  drivers/mfd/ti_tscadc.c|   33
> -
> > >  include/linux/mfd/ti_tscadc.h  |3 +++
> > >  4 files changed, 100 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/drivers/iio/adc/ti_adc.c b/drivers/iio/adc/ti_adc.c index
> > > 56f8af2..69f19f0 100644
> > > --- a/drivers/iio/adc/ti_adc.c
> > > +++ b/drivers/iio/adc/ti_adc.c
> > > @@ -207,6 +207,36 @@ static int __devexit tiadc_remove(struct
> platform_device *pdev)
> > >   return 0;
> > >  }
> > >
> > [...]
> > >  static struct platform_driver tiadc_driver = {
> > >   .driver = {
> > >   .name   = "tiadc",
> > > @@ -214,6 +244,8 @@ static struct platform_driver tiadc_driver = {
> > >   },
> > >   .probe  = tiadc_probe,
> > >   .remove = __devexit_p(tiadc_remove),
> > > + .suspend = adc_suspend,
> > > + .resume = adc_resume,
> > >  };
> > >
> >
> >
> > Using the suspend/resume callbacks is deprecated, please use
> dev_pm_ops.
> > Same comment applies to the other two drivers.
> 
> Ok. I will make changes in all the 3 driver to use dev_pm_ops instead of
> suspend/resume callbacks.

Probably you might need to protect suspend/resumes with CONFIG_PM. 

> 
> Regards,
> Rachna
> 
> >
> >
> >
> 
> --
> 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/
--
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 v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc

2012-09-13 Thread Greg KH
On Thu, Sep 13, 2012 at 10:19:11PM +0200, Rene Buergel wrote:
> This patch moves drivers/usb/serial/ezusb.c to drivers/usb/misc/and
> adapts Makefiles and Kconfigs
> 
> Signed-off-by: René Bürgel 
> --
> diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
> index 1bfcd02..1c63b54 100644
> --- a/drivers/usb/misc/Kconfig
> +++ b/drivers/usb/misc/Kconfig
> @@ -244,3 +244,7 @@ config USB_YUREX
> To compile this driver as a module, choose M here: the
> module will be called yurex.
>  
> +config USB_EZUSB
> + bool "Functions for loading firmware on EZUSB chips"
> + help
> + Say Y here if you need EZUSB device support.
> diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
> index 796ce7e..f1f7815 100644
> --- a/drivers/usb/misc/Makefile
> +++ b/drivers/usb/misc/Makefile
> @@ -11,6 +11,7 @@ obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o
>  obj-$(CONFIG_USB_CYTHERM)+= cytherm.o
>  obj-$(CONFIG_USB_EMI26)  += emi26.o
>  obj-$(CONFIG_USB_EMI62)  += emi62.o
> +obj-$(CONFIG_USB_EZUSB)  += ezusb.o
>  obj-$(CONFIG_USB_FTDI_ELAN)  += ftdi-elan.o
>  obj-$(CONFIG_USB_IDMOUSE)+= idmouse.o
>  obj-$(CONFIG_USB_IOWARRIOR)  += iowarrior.o
> diff --git a/drivers/usb/misc/ezusb.c b/drivers/usb/misc/ezusb.c
> new file mode 100644
> index 000..867a3e1
> --- /dev/null
> +++ b/drivers/usb/misc/ezusb.c

Git should show this as a move, not as a "add a file and remove a file"
type patch.  Are you generating it properly?

Also, why move it?  Are there other modules that need to use it?

thanks,

greg k-h
--
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 v2 2/4]: add support for Cypress FX2LP

2012-09-13 Thread Greg KH
On Thu, Sep 13, 2012 at 10:15:47PM +0200, Rene Buergel wrote:
> This Patch adds support for the newer Cypress FX2LP. It also adapts 
> three drivers currently using ezusb to the interface change. (whiteheat 
> and keyspan[_pda])
> 
> Signed-off-by: René Bürgel 
> --

Shouldn't this be 3 '-' characters?

Also, you forgot to put your email address in here :(

Care to resend this, and the two after it?  I took the first one.

thanks,

greg k-h
--
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 v3 5/5] MFD: ti_tscadc: add suspend/resume functionality

2012-09-13 Thread Patil, Rachna
On Thu, Sep 13, 2012 at 18:31:35, Lars-Peter Clausen wrote:
> On 09/13/2012 12:40 PM, Patil, Rachna wrote:
> > This patch adds support for suspend/resume of TSC/ADC MFDevice.
> > 
> > Signed-off-by: Patil, Rachna 
> > ---
> > Changes in v2:
> > Added this patch newly in this patch series.
> > 
> > Changes in v3:
> > No changes.
> > 
> >  drivers/iio/adc/ti_adc.c   |   32 
> >  drivers/input/touchscreen/ti_tsc.c |   33 +
> >  drivers/mfd/ti_tscadc.c|   33 -
> >  include/linux/mfd/ti_tscadc.h  |3 +++
> >  4 files changed, 100 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/ti_adc.c b/drivers/iio/adc/ti_adc.c index 
> > 56f8af2..69f19f0 100644
> > --- a/drivers/iio/adc/ti_adc.c
> > +++ b/drivers/iio/adc/ti_adc.c
> > @@ -207,6 +207,36 @@ static int __devexit tiadc_remove(struct 
> > platform_device *pdev)
> > return 0;
> >  }
> >  
> [...]
> >  static struct platform_driver tiadc_driver = {
> > .driver = {
> > .name   = "tiadc",
> > @@ -214,6 +244,8 @@ static struct platform_driver tiadc_driver = {
> > },
> > .probe  = tiadc_probe,
> > .remove = __devexit_p(tiadc_remove),
> > +   .suspend = adc_suspend,
> > +   .resume = adc_resume,
> >  };
> >  
> 
> 
> Using the suspend/resume callbacks is deprecated, please use dev_pm_ops.
> Same comment applies to the other two drivers.

Ok. I will make changes in all the 3 driver to use dev_pm_ops instead of 
suspend/resume callbacks.

Regards,
Rachna

> 
> 
> 

--
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: nvec: adjust for mfd_add_devices() API change

2012-09-13 Thread Greg Kroah-Hartman
On Wed, Sep 12, 2012 at 10:26:00AM -0600, Stephen Warren wrote:
> From: Stephen Warren 
> 
> Commit 6607bad "mfd: core: Push irqdomain mapping out into devices"
> added a new parameter to mfd_add_devices(), but missed updating the
> nvec driver in staging.
> 
> Cc: Mark Brown 
> Cc: Marc Dietrich 
> Signed-off-by: Stephen Warren 
> --
> Samuel, I wonder if this patch should be squashed into the commit mentioned
> above in the MFD tree?

Looks good to me:

Acked-by: Greg Kroah-Hartman 
--
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 v2] efi: Add support for a UEFI variable filesystem

2012-09-13 Thread H. Peter Anvin

On 09/13/2012 08:45 PM, joeyli wrote:

Hi Peter,

於 四,2012-09-13 於 09:52 -0400,Peter Jones 提到:

On Thu, 2012-09-13 at 16:10 +0800, joeyli wrote:


Do we have plan to create a new kobject add to /sys/firmware/efi for
provide a fixed mount point to efivars fs?
e.g. /sys/firmware/efi/efivars

Or we just direct reuse current /sys/firmeware/efi/vars? But, that means
we need think for the backward compatibility if choice reuse vars
folder.


I'm not sure that's a terribly large concern - if you haven't updated
your tools to use the new efivars, don't mount the new efivars.



Thanks for your comment!



I think it is wrong.  The new API should have a different path.

-hpa


--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

--
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] Staging: bcm: Fix udelay related compilation error

2012-09-13 Thread Tushar Behera
commit 6788d7dab6a5 ("Staging: bcm: Use udelay instead of msleep for
delays in nvm.c") replaces msleep with udelay values. udelay values
of more than 1000 should be replaced by mdelay instead.

This fixes following build error.
ERROR: "__bad_udelay" [drivers/staging/bcm/bcm_wimax.ko] undefined!
make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2

Cc: Kevin McKinney 
Cc: Greg Kroah-Hartman 
Signed-off-by: Tushar Behera 
---
 drivers/staging/bcm/nvm.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c
index b179dba..921e25e 100644
--- a/drivers/staging/bcm/nvm.c
+++ b/drivers/staging/bcm/nvm.c
@@ -577,7 +577,7 @@ static int FlashSectorErase(struct bcm_mini_adapter 
*Adapter,
 * the sector erase cycle is 500 ms to 4 msec. 
hence sleeping 10 ms
 * won't hamper performance in any case.
 */
-   udelay(1);
+   mdelay(10);
} while ((uiStatus & 0x1) && (iRetries < 400));
 
if (uiStatus & 0x1) {
-- 
1.7.4.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 v9 05/13] ARM: SoC: convert Exynos4 to SoC descriptor

2012-09-13 Thread Kukjin Kim
Arnd Bergmann wrote:
> 
> From: Marc Zyngier 
> 
> Convert Exynos4 to use the SoC descriptor to provide its SMP
> and CPU hotplug operations.
> 
> Cc: Kukjin Kim 

Acked-by: Kukjin Kim 

Thanks.

Best regards,
Kgene.
--
Kukjin Kim , Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

> Tested-by: Kyungmin Park 
> Signed-off-by: Marc Zyngier 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/arm/mach-exynos/common.h  |5 +
>  arch/arm/mach-exynos/hotplug.c |   18 +++---
>  arch/arm/mach-exynos/mach-armlex4210.c |1 +
>  arch/arm/mach-exynos/mach-exynos5-dt.c |1 +
>  arch/arm/mach-exynos/mach-nuri.c   |1 +
>  arch/arm/mach-exynos/mach-origen.c |1 +
>  arch/arm/mach-exynos/mach-smdk4x12.c   |2 ++
>  arch/arm/mach-exynos/mach-smdkv310.c   |2 ++
>  arch/arm/mach-exynos/mach-universal_c210.c |1 +
>  arch/arm/mach-exynos/platsmp.c |   20 
>  10 files changed, 33 insertions(+), 19 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: WARNING: at kernel/rcutree.c:1558 rcu_do_batch+0x386/0x3a0(), during CPU hotplug

2012-09-13 Thread Michael Wang
On 09/13/2012 08:47 PM, Srivatsa S. Bhat wrote:
> On 09/13/2012 12:00 PM, Michael Wang wrote:
>> On 09/12/2012 11:31 PM, Paul E. McKenney wrote:
>>> On Wed, Sep 12, 2012 at 06:06:20PM +0530, Srivatsa S. Bhat wrote:
 On 07/19/2012 10:45 PM, Paul E. McKenney wrote:
> On Thu, Jul 19, 2012 at 05:39:30PM +0530, Srivatsa S. Bhat wrote:
>> Hi Paul,
>>
>> While running a CPU hotplug stress test on v3.5-rc7+
>> (mainline commit 8a7298b7805ab) I hit this warning.
>> I haven't tried to debug this yet...
>>
>> Line number 1550 maps to:
>>
>> WARN_ON_ONCE(cpu_is_offline(smp_processor_id()));
>>
>> inside rcu_do_batch().
>
> Hello, Srivatsa,
>
> I believe that you need commit a16b7a69 (Prevent __call_rcu() from
> invoking RCU core on offline CPUs), which is currently in -tip, queued
> for 3.6.  Please see below for the patch.
>
> Does this help?
>

 Hi Paul,

 I am hitting the cpu_is_offline() warning in rcu_do_batch() (see 2 of the
 examples below) occasionally while testing CPU hotplug on Thomas' 
 smp/hotplug
 branch in -tip. It does contain the commit that you had mentioned above.

 The stack trace suggests that we are not hitting this from the __call_rcu()
 path. So I guess this needs a different fix?
>>>
>>> So there was an interrupt from stop_machine_stop().  Because RCU complained
>>> about offline, I presume that this was on exit from stop_machine_stop().
>>> (Otherwise, on entry to stop_machine_stop(), the CPU has not yet marked
>>> itself offline, right?)
>>>
> 
> Yes, that's my understanding too.
> 
>>> So my question is:  Why didn't the CPU shut off all interrupts before
>>> coming out of stop_machine_stop()?
>>>
>>> Or am I confused about what is really happening here?
>>
>> I think Srivatsa may need patch a3716d2e too:
>>
> 
> The changelog of this patch doesn't seem to suggest that it was written to
> address the problem I am facing. Please see my thoughts below..
> 
>> commit a3716d2e5a50a9ed5268ae3d3c2f093968ff236a
>> Author: Paul E. McKenney 
>> Date:   Thu Jun 21 09:54:10 2012 -0700
>>
>> rcu: Prevent offline CPUs from executing RCU core code
>> 
>> Earlier versions of RCU invoked the RCU core from the CPU_DYING notifier
>> in order to note a quiescent state for the outgoing CPU.  Because the
>> CPU is marked "offline" during the execution of the CPU_DYING notifiers,
>> the RCU core had to tolerate being invoked from an offline CPU.  However,
>> commit b1420f1c (Make rcu_barrier() less disruptive) left only tracing
>> code in the CPU_DYING notifier, so the RCU core need no longer execute
>> on offline CPUs.  This commit therefore enforces this restriction.
>> 
>> Signed-off-by: Paul E. McKenney 
>> Signed-off-by: Paul E. McKenney 
>>
>> diff --git a/kernel/rcutree.c b/kernel/rcutree.c
>> index 300aba6..84a6f55 100644
>> --- a/kernel/rcutree.c
>> +++ b/kernel/rcutree.c
>> @@ -1892,6 +1892,8 @@ static void rcu_process_callbacks(struct 
>> softirq_action *unused)
>>  {
>> struct rcu_state *rsp;
>>
>> +   if (cpu_is_offline(smp_processor_id()))
>> +   return;
>> trace_rcu_utilization("Start RCU core");
>> for_each_rcu_flavor(rsp)
>> __rcu_process_callbacks(rsp);
>>
>> With out it, the RCU_SOFTIRQ raised before offline won't
>> have a chance to return.
>>
> 
> I'm sure this would help to get rid of the warning, but IMHO, like Paul 
> pointed out,
> its rather surprising that the CPU going offline got interrupts *after* 
> coming out of
> the stop_machine thing, iow, *after* it was marked offline.. So we need to 
> examine
> *this* issue right?

This may be a clue:

 [   53.917769] do_IRQ: 8.211 No irq handler for vector (irq -1)

I'm not familiar with APIC, but that's not something we expected, correct?

Regards,
Michael Wang

> 
> Regards,
> Srivatsa S. Bhat
> 

 [   53.882344] smpboot: CPU 7 is now offline
 [   53.891072] CPU 12 MCA banks CMCI:6 CMCI:8
 [   53.895621] CPU 15 MCA banks CMCI:2 CMCI:3 CMCI:5
 [   53.914738] Broke affinity for irq 81
 [   53.917769] do_IRQ: 8.211 No irq handler for vector (irq -1) 
 [   53.917769] [ cut here ]
 [   53.917769] WARNING: at kernel/rcutree.c:1558 rcu_do_batch+0x386/0x3a0()
 [   53.917769] Hardware name: IBM System x -[7870C4Q]-
 [   53.917769] Modules linked in: ipv6 cpufreq_conservative 
 cpufreq_userspace cpufreq_powersave acpi_cpufreq mperf fuse loop dm_mod 
 iTCO_wdt iTCO_vendor_support coretemp kvm_intel kvm cdc_ether usbnet 
 ioatdma lpc_ich mfd_core crc32c_intel microcode mii pcspkr i2c_i801 shpchp 
 i2c_core serio_raw bnx2 tpm_tis dca tpm pci_hotplug i7core_edac tpm_bios 
 edac_core sg rtc_cmos button uhci_hcd ehci_hcd usbcore usb_common sd_mod 
 crc_t10dif edd ext3 mbcache jbd fan processor mptsas mptscsih mptbase 
 scsi_transport

[GIT PULL] hwmon fixes for 3.6-rc6

2012-09-13 Thread Guenter Roeck
Hi Linus,

Please pull hwmon fixes for Linux 3.6-rc6 from signed tag:

git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git 
hwmon-for-linus

Thanks,
Guenter
--

The following changes since commit 55d512e245bc7699a8800e23df1a24195dd08217:

  Linux 3.6-rc5 (2012-09-08 16:43:45 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git 
tags/hwmon-for-linus

for you to fetch changes up to 080b98e9ab30734bda2f1b8b33cd55a4c4ef406a:

  hwmon: (ina2xx) Fix word size register read and write operations (2012-09-12 
06:42:11 -0700)


Fix word size register read and write operations in ina2xx driver, and
initialize uninitialized structure elements in twl4030-madc-hwmon driver.


Guenter Roeck (2):
  hwmon: (twl4030-madc-hwmon) Initialize uninitialized structure elements
  hwmon: (ina2xx) Fix word size register read and write operations

 drivers/hwmon/ina2xx.c |   30 +-
 drivers/hwmon/twl4030-madc-hwmon.c |9 +
 2 files changed, 14 insertions(+), 25 deletions(-)


signature.asc
Description: Digital signature


Re: linux-next: build failure after merge of the final tree (akpm tree related)

2012-09-13 Thread David Fries
On Thu, Sep 13, 2012 at 11:34:29PM +1000, Stephen Rothwell wrote:
> Hi David,
> 
> On Thu, 13 Sep 2012 08:24:08 -0500 David Fries  wrote:
> >
> > On Thu, Sep 13, 2012 at 06:11:27PM +1000, Stephen Rothwell wrote:
> > > Hi all,
> > > 
> > > After merging the final tree, today's linux-next build (sparc64 defconfig)
> > > failed like this:
> > > 
> > > drivers/built-in.o: In function `rtc_hctosys':
> > > hctosys.c:(.init.text+0x4a98): undefined reference to `rtc_hctosys_ret'
> > > hctosys.c:(.init.text+0x4b54): undefined reference to `rtc_hctosys_ret'
> > > hctosys.c:(.init.text+0x4b58): undefined reference to `rtc_hctosys_ret'
> > 
> > Can you post your .config?  `grep RTC .config`
> > It would seem to me that drivers/rtc/hctosys.c is being compiled
> > without drivers/rtc/class.c which now holds the global variable, but
> > Kconfig says that RTC_HCTOSYS 'depends on RTC_CLASS = y'.
> 
> Did you read the bit you quoted below?

Oops, sorry, I had just got out of bed and was trying to hurry to
work.  The following version defines rtc_hctosys_ret in
CONFIG_RTC_HCTOSYS_DEVICE and CONFIG_PM is checked later.

> CONFIG_PM is not set, so that the
> part of class.c that contains the definition of rtc_hctosys_ret is not
> compiled ...
> 
> > > Caused by commit "rtc_sysfs_show_hctosys(): display 0 if resume failed"
> > > from the akpm tree.  rtc_hctosys_ret was moved into class.c but protected
> > > by defined(CONFIG_PM) && defined(CONFIG_RTC_HCTOSYS_DEVICE) and this
> > > build does not have CONFIG_PM set.



>From 7c5aac626f9f64b9a4cc8c1cca1e4cb7cfefb819 Mon Sep 17 00:00:00 2001
From: David Fries 
Date: Sat, 25 Aug 2012 13:48:08 -0500
Subject: [PATCH] rtc_sysfs_show_hctosys(): display 0 if resume failed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Without this patch /sys/class/rtc/$CONFIG_RTC_HCTOSYS_DEVICE/hctosys
contains a 1 (meaning "This rtc was used to initialize the system
clock") even if setting the time by do_settimeofday() at bootup failed.
The RTC can also be used to set the clock on resume, if it did 1,
otherwise 0.  Previously there was no indication if the RTC was used
to set the clock in resume.

This uses only CONFIG_RTC_HCTOSYS_DEVICE for conditional compilation
instead of it and CONFIG_RTC_HCTOSYS to be more consistent.
rtc_hctosys_ret was moved to class.c so class.c no longer depends on
hctosys.c.

Signed-off-by: David Fries 
Cc: Matthew Garrett 
Cc: Alessandro Zummo 
Cc: Uwe Kleine-König 
Cc: Andrew Morton 
---
 drivers/rtc/class.c |8 +++-
 drivers/rtc/hctosys.c   |4 +---
 drivers/rtc/rtc-sysfs.c |6 ++
 include/linux/rtc.h |2 +-
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index dc4c274..a022b1c 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -31,8 +31,11 @@ static void rtc_device_release(struct device *dev)
kfree(rtc);
 }
 
-#if defined(CONFIG_PM) && defined(CONFIG_RTC_HCTOSYS_DEVICE)
+#ifdef CONFIG_RTC_HCTOSYS_DEVICE
+/* Result of the last RTC to system clock attempt. */
+int rtc_hctosys_ret = -ENODEV;
 
+#ifdef CONFIG_PM
 /*
  * On suspend(), measure the delta between one RTC and the
  * system's wall clock; restore it on resume().
@@ -84,6 +87,7 @@ static int rtc_resume(struct device *dev)
struct timespec new_system, new_rtc;
struct timespec sleep_time;
 
+   rtc_hctosys_ret = -ENODEV;
if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0)
return 0;
 
@@ -117,6 +121,7 @@ static int rtc_resume(struct device *dev)
 
if (sleep_time.tv_sec >= 0)
timekeeping_inject_sleeptime(&sleep_time);
+   rtc_hctosys_ret = 0;
return 0;
 }
 
@@ -124,6 +129,7 @@ static int rtc_resume(struct device *dev)
 #define rtc_suspendNULL
 #define rtc_resume NULL
 #endif
+#endif
 
 
 /**
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index bc90b09..4aa60d7 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -22,8 +22,6 @@
  * the best guess is to add 0.5s.
  */
 
-int rtc_hctosys_ret = -ENODEV;
-
 static int __init rtc_hctosys(void)
 {
int err = -ENODEV;
@@ -56,7 +54,7 @@ static int __init rtc_hctosys(void)
 
rtc_tm_to_time(&tm, &tv.tv_sec);
 
-   do_settimeofday(&tv);
+   err = do_settimeofday(&tv);
 
dev_info(rtc->dev.parent,
"setting system clock to "
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 380083c..b70e2bb 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -102,6 +102,12 @@ rtc_sysfs_set_max_user_freq(struct device *dev, struct 
device_attribute *attr,
return n;
 }
 
+/**
+ * rtc_sysfs_show_hctosys - indicate if the given RTC set the system time
+ *
+ * Returns 1 if the system clock was set by this RTC at the last
+ * boot or resume event.
+ */
 static ssize_t
 rtc_sysfs_show_hctosys(struct device *dev, struct device_attri

Re: PROBLEM: ACPI 0x0000000000000b00-0x0000000000000b07 SystemIO conflicts with Region \_SB_.PCI0.SBRG.ASOC.SMRG 1 (20120320/utaddress-251)

2012-09-13 Thread Bjorn Helgaas
On Thu, Sep 13, 2012 at 12:11 PM, Peter Simons  wrote:
> Hi guys,
>
> I've recently updated my machine to Linux kernel 3.5. Ever since then, I
> experience frequent kernel panics in the I/O system. The output from
> dmesg shows the following warning, which earlier version of the kernel
> did not show:
>
>   ACPI 0x0b00-0x0b07 SystemIO conflicts with Region 
> \_SB_.PCI0.SBRG.ASOC.SMRG 1 (20120320/utaddress-251)

The panic is the real problem, not the warning message.  It's possible
that they're related, but certainly not obvious.  Can you capture any
information about the panic with a serial console, netconsole, or even
a digital photo or movie?

It sounds like this is a regression, so it will be useful to know the
newest kernel that works correctly and the oldest one that fails.

Bjorn
--
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 9/15] arch/arm/mach-s3c24xx/mach-h1940.c: removes unnecessary semicolon

2012-09-13 Thread kgene
Peter Senna Tschudin wrote:
> 
> From: Peter Senna Tschudin 
> 
> removes unnecessary semicolon
> 
> Found by Coccinelle: http://coccinelle.lip6.fr/
> 
> Signed-off-by: Peter Senna Tschudin 
> 
> ---
>  arch/arm/mach-s3c24xx/mach-h1940.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-
> s3c24xx/mach-h1940.c
> index bb8d008..02ef7d5 100644
> --- a/arch/arm/mach-s3c24xx/mach-h1940.c
> +++ b/arch/arm/mach-s3c24xx/mach-h1940.c
> @@ -460,7 +460,7 @@ static void h1940_set_mmc_power(unsigned char
> power_mode, unsigned short vdd)
>   break;
>   default:
>   break;
> - };
> + }
>  }
> 
>  static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = {

Applied, thanks.

K-Gene 

--
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] arch/arm/mach-s3c24xx/mach-h1940.c: delete double assignment

2012-09-13 Thread kgene
Julia Lawall wrote:
> 
> From: Julia Lawall 
> 
> Delete successive assignments to the same location.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // 
> @@
> expression i;
> @@
> 
> *i = ...;
>  i = ...;
> // 
> 
> Signed-off-by: Julia Lawall 
> 
> ---
> Not compiled, and this may change the behavior of the code.  Without this
> change, check_gpio2 could possibly be used uninitialized later.
> 
>  arch/arm/mach-s3c24xx/mach-h1940.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-
> s3c24xx/mach-h1940.c
> index bb8d008..48c 100644
> --- a/arch/arm/mach-s3c24xx/mach-h1940.c
> +++ b/arch/arm/mach-s3c24xx/mach-h1940.c
> @@ -380,7 +380,7 @@ int h1940_led_blink_set(unsigned gpio, int state,
>   default:
>   blink_gpio = S3C2410_GPA(3);
>   check_gpio1 = S3C2410_GPA(1);
> - check_gpio1 = S3C2410_GPA(7);
> + check_gpio2 = S3C2410_GPA(7);
>   break;
>   }
> 
Applied, thanks.

K-Gene 

--
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 v2] efi: Add support for a UEFI variable filesystem

2012-09-13 Thread joeyli
Hi Peter, 

於 四,2012-09-13 於 09:52 -0400,Peter Jones 提到:
> On Thu, 2012-09-13 at 16:10 +0800, joeyli wrote:
> 
> > Do we have plan to create a new kobject add to /sys/firmware/efi for
> > provide a fixed mount point to efivars fs?
> > e.g. /sys/firmware/efi/efivars
> > 
> > Or we just direct reuse current /sys/firmeware/efi/vars? But, that means
> > we need think for the backward compatibility if choice reuse vars
> > folder.
> 
> I'm not sure that's a terribly large concern - if you haven't updated
> your tools to use the new efivars, don't mount the new efivars.
> 

Thanks for your comment!

Joey Lee

--
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] ACPI: Enable SCI_EMULATE to manually simulate physical hotplug testing.

2012-09-13 Thread Yinghai Lu
On Thu, Sep 13, 2012 at 5:22 PM, Toshi Kani  wrote:
>> > >> +
>> > >> + /*
>> > >> +  * Check for internal object and make sure there is a handler
>> > >> +  * registered for this object
>> > >> +  */
>> > >> + obj_desc = acpi_ns_get_attached_object(node);
>> > >> + if (obj_desc) {
>> > >> + if (obj_desc->common_notify.notify_list[0]) {
>> > >
>> > > Is the above check necessary?  acpi_ev_queue_notify_request() sets up to
>> > > call the global handler, acpi_gbl_global_notify[0], even if the object
>> > > does not have a local handler registered.
>> >
>> > Not sure.
>> >
>> > maybe Len or other acpi guyes could answer your questions.
>>
>> I think this check should be removed, but would like someone to
>> verify...
>
>
> Hi Yinghai,
>
> Attached is my suggested update to your patch. It allows a SCI to be
> sent to any object, and therefore can be used for testing the global
> notify handler. Some drivers such as dock.c only register their handler
> to the global notify handler. I also made a few minor changes. I have
> been testing with this update and it is working fine. I like this
> feature, so I hope we can make progress with this update.

len, can you check them?

Thanks

Yinghai
--
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 RESEND] memory hotplug: fix a double register section info bug

2012-09-13 Thread qiuxishi
There may be a bug when registering section info. For example, on
my Itanium platform, the pfn range of node0 includes the other nodes,
so other nodes' section info will be double registered, and memmap's
page count will equal to 3.

node0: start_pfn=0x100,spanned_pfn=0x20fb00, present_pfn=0x7f8a3, => 
0x000100-0x20fc00
node1: start_pfn=0x8,  spanned_pfn=0x8,  present_pfn=0x8, => 
0x08-0x10
node2: start_pfn=0x10, spanned_pfn=0x8,  present_pfn=0x8, => 
0x10-0x18
node3: start_pfn=0x18, spanned_pfn=0x8,  present_pfn=0x8, => 
0x18-0x20

free_all_bootmem_node()
register_page_bootmem_info_node()
register_page_bootmem_info_section()

When hot remove memory, we can't free the memmap's page because
page_count() is 2 after put_page_bootmem().

sparse_remove_one_section()
free_section_usemap()
free_map_bootmem()
put_page_bootmem()

Signed-off-by: Xishi Qiu 
Signed-off-by: Jiang Liu 
---
 mm/memory_hotplug.c |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 2adbcac..cf493c7 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -126,9 +126,6 @@ static void register_page_bootmem_info_section(unsigned 
long start_pfn)
struct mem_section *ms;
struct page *page, *memmap;

-   if (!pfn_valid(start_pfn))
-   return;
-
section_nr = pfn_to_section_nr(start_pfn);
ms = __nr_to_section(section_nr);

@@ -187,9 +184,10 @@ void register_page_bootmem_info_node(struct pglist_data 
*pgdat)
end_pfn = pfn + pgdat->node_spanned_pages;

/* register_section info */
-   for (; pfn < end_pfn; pfn += PAGES_PER_SECTION)
-   register_page_bootmem_info_section(pfn);
-
+   for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
+   if (pfn_valid(pfn) && (pfn_to_nid(pfn) == node))
+   register_page_bootmem_info_section(pfn);
+   }
 }
 #endif /* !CONFIG_SPARSEMEM_VMEMMAP */

-- 
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 v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()

2012-09-13 Thread Vinod Koul
On Thu, 2012-09-13 at 16:38 +0100, Russell King - ARM Linux wrote:
> On Thu, Sep 13, 2012 at 05:27:09PM +0200, Lars-Peter Clausen wrote:
> > Hm... Do you think it would work as well if we implement this by setting the
> > callback for the descriptor to NULL? If the callback is NULL there is
> > nothing to at the end of a transfer/period and the dma engine driver may
> > choose to disable interrupts. This would also benefit non cyclic transfers
> > where the callback is NULL and we do not need add the new parameter to
> > dmaengine_prep_dma_cyclic.
> 
> Actually, there's a way to do that already.  DMA_PREP_INTERRUPT.
> Unfortunately, most DMA engine slave API users don't set it when they
> setup their transfer:
> 
>  * @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion of
>  *  this transaction
Looks like I have repeated the correct action!
> 
> if we fixed that, then we could use the lack of it to avoid the interrupt.
> 
> However, cyclic transfers don't have the flags parameter used to pass this
> bit.  Yet another bit of yucky inconsistent design in DMA engine land...
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel



--
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 v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()

2012-09-13 Thread Vinod Koul
On Thu, 2012-09-13 at 17:27 +0200, Lars-Peter Clausen wrote:
> Hi,
> 
> Hm... Do you think it would work as well if we implement this by
> setting the
> callback for the descriptor to NULL? If the callback is NULL there is
> nothing to at the end of a transfer/period and the dma engine driver
> may
> choose to disable interrupts. This would also benefit non cyclic
> transfers
> where the callback is NULL and we do not need add the new parameter to
> dmaengine_prep_dma_cyclic.
That will work too BUT the idea of no_wake mode in ALSA is that we
should not have any interrupts, so anything which is going to cause
interrupts to AP in undesired. The interrupts still happen and it just
that dmaengine driver is not notifying client.


-- 
~Vinod

--
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 v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback

2012-09-13 Thread Vinod Koul
On Thu, 2012-09-13 at 16:37 +0300, Peter Ujfalusi wrote:
> Change the parameter list of device_prep_dma_cyclic() so the DMA drivers
> can receive the no_wakeup request coming from client drivers.
> This feature can be used during audio operation to disable all audio
> related interrupts.
We already have a flag to indicate this, see 
* @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion  of
*  this transaction

Unfortunately, the addition of cyclic API missed having this flag. So
right way would be to add flag argument in the API.

-- 
~Vinod

--
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] ARM: mmp: using for_each_set_bit to simplify the code

2012-09-13 Thread Eric Miao
On Fri, Sep 14, 2012 at 10:30 AM, Wei Yongjun  wrote:
> From: Wei Yongjun 
>
> Using for_each_set_bit() to simplify the code.
>
> spatch with a semantic match is used to found this.
> (http://coccinelle.lip6.fr/)
>
> Signed-off-by: Wei Yongjun 

Great API, this is good. Acked-by: Eric Miao 

> ---
>  arch/arm/mach-mmp/irq.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-mmp/irq.c b/arch/arm/mach-mmp/irq.c
> index e60c7d9..3c71246 100644
> --- a/arch/arm/mach-mmp/irq.c
> +++ b/arch/arm/mach-mmp/irq.c
> @@ -153,10 +153,8 @@ static void icu_mux_irq_demux(unsigned int irq, struct 
> irq_desc *desc)
> status = readl_relaxed(data->reg_status) & ~mask;
> if (status == 0)
> break;
> -   n = find_first_bit(&status, BITS_PER_LONG);
> -   while (n < BITS_PER_LONG) {
> +   for_each_set_bit(n, &status, BITS_PER_LONG) {
> generic_handle_irq(icu_data[i].virq_base + n);
> -   n = find_next_bit(&status, BITS_PER_LONG, n + 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 01/16] ARM: at91: move platform_data definitions

2012-09-13 Thread Vinod Koul
On Tue, 2012-09-11 at 14:59 +0200, Arnd Bergmann wrote:
> Platform data for device drivers should be defined in
> include/linux/platform_data/*.h, not in the architecture
> and platform specific directories.
> 
> This moves such data out of the at91 include directories
> 
> Signed-off-by: Arnd Bergmann 
> Cc: Nicolas Ferre 
> Cc: Jean-Christophe Plagniol-Villard 
> Cc: Vinod Koul 
> Cc: Dan Williams 

Acked-by: Vinod Koul 

-- 
~Vinod

--
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 03/16] ARM: ep93xx: move platform_data definitions

2012-09-13 Thread Vinod Koul
On Tue, 2012-09-11 at 14:59 +0200, Arnd Bergmann wrote:
> Platform data for device drivers should be defined in
> include/linux/platform_data/*.h, not in the architecture
> and platform specific directories.
> 
> This moves such data out of the ep93xx include directories
> 

>  drivers/dma/ep93xx_dma.c |2 +-
Acked-by: Vinod Koul 




-- 
~Vinod

--
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 04/16] ARM: imx: move platform_data definitions

2012-09-13 Thread Vinod Koul
On Tue, 2012-09-11 at 14:59 +0200, Arnd Bergmann wrote:
> Platform data for device drivers should be defined in
> include/linux/platform_data/*.h, not in the architecture
> and platform specific directories.
> 
> This moves such data out of the imx include directories

For these:
>  drivers/dma/imx-dma.c  |2 +-
>  drivers/dma/imx-sdma.c |4 +--
Acked-by: Vinod Koul 

-- 
~Vinod

--
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/2] DMA: PL330: Clock and runtime cleanup

2012-09-13 Thread Vinod Koul
On Fri, 2012-09-07 at 12:14 +0530, Inderpal Singh wrote:
> The controller clock is being managed at AMBA bus level probe/remove and
> pm_runtime/suspend functions. The existing driver does the clock 
> enable/disable
> again in the same code paths, which unneccessarily increments the usage count 
> of
> the clock for the same device. 
> 
> The following patches remove the redundant clock enable/disable from the 
> driver.
Looks good, any tested by before I apply this.. Kukjin?
> 
> Inderpal Singh (2):
>   DMA: PL330: Remove controller clock enable/disable
>   DMA: PL330: Remove redundant runtime_suspend/resume functions
> 
>  drivers/dma/pl330.c |   73 
> ---
>  1 file changed, 5 insertions(+), 68 deletions(-)
> 


-- 
~Vinod

--
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/


linux-next: build failure after merge of the cgroup tree

2012-09-13 Thread Stephen Rothwell
Hi Tejun,

After merging the cgroup tree, today's linux-next build (powerpc
ppc64_defconfig) failed like this:

drivers/net/tun.c: In function 'tun_alloc_skb':
drivers/net/tun.c:589:2: error: implicit declaration of function 
'sock_update_classid' [-Werror=implicit-function-declaration]

Caused by commit 1f66c0a8833c ("cgroup: net_cls: Move sock_update_classid()
declaration to cls_cgroup.h").  Grep is your friend ...

I have used the cgroup tree from next-20120913 for today.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpsqvNNIYupE.pgp
Description: PGP signature


RE: [PATCH 0/2] ARM: EXYNOS: Set the capability of pdm0 and pdm1 as DMA_PRIVATE

2012-09-13 Thread Vinod Koul
On Fri, 2012-09-07 at 14:30 +0900, Kukjin Kim wrote:
> Vinod Koul wrote:
> > 
> > On Wed, 2012-08-29 at 10:16 +0530, Tushar Behera wrote:
> > > DMA clients pdma0 and pdma1 are internal to the SoC and are used only
> > > by dedicated peripherals. Since they cannot be used for generic
> > > purpose, their capability should be set as DMA_PRIVATE.
> > >
> > > The patches are rebased on top of v3.6-rc3.
> > Kukjin, if you ack them I can take thru my tree, other way round is fine
> > with me too.
> 
> Hi Vinod,
> 
> Looks good to me, please pick them into your tree with my ack.
> 
> Acked-by: Kukjin Kim 
Okay applied both.


-- 
~Vinod

--
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] lib: spinlock_debug: Avoid livelock in do_raw_spin_lock

2012-09-13 Thread Vikram Mulukutla
The logic in do_raw_spin_lock attempts to acquire a spinlock
by invoking arch_spin_trylock in a loop with a delay between
each attempt. Now consider the following situation in a 2
CPU system:

1. CPU-0 continually acquires and releases a spinlock in a
   tight loop; it stays in this loop until some condition X
   is satisfied. X can only be satisfied by another CPU.

2. CPU-1 tries to acquire the same spinlock, in an attempt
   to satisfy the aforementioned condition X. However, it
   never sees the unlocked value of the lock because the
   debug spinlock code uses trylock instead of just lock;
   it checks at all the wrong moments - whenever CPU-0 has
   locked the lock.

Now in the absence of debug spinlocks, the architecture specific
spinlock code can correctly allow CPU-1 to wait in a "queue"
(e.g., ticket spinlocks), ensuring that it acquires the lock at
some point. However, with the debug spinlock code, livelock
can easily occur due to the use of try_lock, which obviously
cannot put the CPU in that "queue". This queueing mechanism is
implemented in both x86 and ARM spinlock code.

Note that the situation mentioned above is not hypothetical.
A real problem was encountered where CPU-0 was running
hrtimer_cancel with interrupts disabled, and CPU-1 was attempting
to run the hrtimer that CPU-0 was trying to cancel.

Address this by actually attempting arch_spin_lock once it is
suspected that there is a spinlock lockup. If we're in a
situation that is described above, the arch_spin_lock should
succeed; otherwise other timeout mechanisms (e.g., watchdog)
should alert the system of a lockup. Therefore, if there is
a genuine system problem and the spinlock can't be acquired,
the end result (irrespective of this change being present)
is the same. If there is a livelock caused by the debug code,
this change will allow the lock to be acquired, depending on
the implementation of the lower level arch specific spinlock
code.

Signed-off-by: Vikram Mulukutla 
---
 lib/spinlock_debug.c |   32 ++--
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c
index eb10578..94624e1 100644
--- a/lib/spinlock_debug.c
+++ b/lib/spinlock_debug.c
@@ -107,23 +107,27 @@ static void __spin_lock_debug(raw_spinlock_t *lock)
 {
u64 i;
u64 loops = loops_per_jiffy * HZ;
-   int print_once = 1;
 
-   for (;;) {
-   for (i = 0; i < loops; i++) {
-   if (arch_spin_trylock(&lock->raw_lock))
-   return;
-   __delay(1);
-   }
-   /* lockup suspected: */
-   if (print_once) {
-   print_once = 0;
-   spin_dump(lock, "lockup suspected");
+   for (i = 0; i < loops; i++) {
+   if (arch_spin_trylock(&lock->raw_lock))
+   return;
+   __delay(1);
+   }
+   /* lockup suspected: */
+   spin_dump(lock, "lockup suspected");
 #ifdef CONFIG_SMP
-   trigger_all_cpu_backtrace();
+   trigger_all_cpu_backtrace();
 #endif
-   }
-   }
+
+   /*
+* In case the trylock above was causing a livelock, give the lower
+* level arch specific lock code a chance to acquire the lock. We have
+* already printed a warning/backtrace at this point. The non-debug arch
+* specific code might actually succeed in acquiring the lock. If it is
+* not successful, the end-result is the same - there is no forward
+* progress.
+*/
+   arch_spin_lock(&lock->raw_lock);
 }
 
 void do_raw_spin_lock(raw_spinlock_t *lock)
-- 
1.7.8.3

The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

--
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 v3] memory leak fix while calling system_path

2012-09-13 Thread liang xie
memory leak fix while calling system_path

Since v1: Remove an unnecessary null pointer check per Felipe's comments
Since v2: Make system_path&perf_exec_path always return dynamically
allocated string

Signed-off-by: xieliang 
---
 tools/perf/builtin-help.c   |   12 +---
 tools/perf/builtin-script.c |   13 ++---
 tools/perf/perf.c   |8 ++--
 tools/perf/util/config.c|   16 +---
 tools/perf/util/exec_cmd.c  |   26 +++---
 tools/perf/util/exec_cmd.h  |4 ++--
 tools/perf/util/help.c  |6 --
 7 files changed, 51 insertions(+), 34 deletions(-)

diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 6d5a8a7..180a5bd 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -321,12 +321,13 @@ static void setup_man_path(void)
 {
struct strbuf new_path = STRBUF_INIT;
const char *old_path = getenv("MANPATH");
+   char *man_path = system_path(PERF_MAN_PATH);

/* We should always put ':' after our path. If there is no
 * old_path, the ':' at the end will let 'man' to try
 * system-wide paths after ours to find the manual page. If
 * there is old_path, we need ':' as delimiter. */
-   strbuf_addstr(&new_path, system_path(PERF_MAN_PATH));
+   strbuf_addstr(&new_path, man_path);
strbuf_addch(&new_path, ':');
if (old_path)
strbuf_addstr(&new_path, old_path);
@@ -334,6 +335,7 @@ static void setup_man_path(void)
setenv("MANPATH", new_path.buf, 1);

strbuf_release(&new_path);
+   free(man_path);
 }

 static void exec_viewer(const char *name, const char *page)
@@ -371,14 +373,16 @@ static void show_man_page(const char *perf_cmd)
 static void show_info_page(const char *perf_cmd)
 {
const char *page = cmd_to_page(perf_cmd);
-   setenv("INFOPATH", system_path(PERF_INFO_PATH), 1);
+   char *info_path = system_path(PERF_INFO_PATH);
+   setenv("INFOPATH", info_path, 1);
execlp("info", "info", "perfman", page, NULL);
+   free(info_path);
 }

 static void get_html_page_path(struct strbuf *page_path, const char *page)
 {
struct stat st;
-   const char *html_path = system_path(PERF_HTML_PATH);
+   char *html_path = system_path(PERF_HTML_PATH);

/* Check that we have a perf documentation directory. */
if (stat(mkpath("%s/perf.html", html_path), &st)
@@ -387,6 +391,7 @@ static void get_html_page_path(struct strbuf
*page_path, const char *page)

strbuf_init(page_path, 0);
strbuf_addf(page_path, "%s/%s.html", html_path, page);
+   free(html_path);
 }

 /*
@@ -409,6 +414,7 @@ static void show_html_page(const char *perf_cmd)
get_html_page_path(&page_path, page);

open_html(page_path.buf);
+   strbuf_release(&page_path);
 }

 int cmd_help(int argc, const char **argv, const char *prefix __used)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 1e60ab7..528b786 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1021,8 +1021,10 @@ static int list_available_scripts(const struct
option *opt __used,
struct script_desc *desc;
char first_half[BUFSIZ];
char *script_root;
+   char *exec_path = perf_exec_path();

-   snprintf(scripts_path, MAXPATHLEN, "%s/scripts", perf_exec_path());
+   snprintf(scripts_path, MAXPATHLEN, "%s/scripts", exec_path);
+   free(exec_path);

scripts_dir = opendir(scripts_path);
if (!scripts_dir)
@@ -1066,8 +1068,10 @@ static char *get_script_path(const char
*script_root, const char *suffix)
DIR *scripts_dir, *lang_dir;
char lang_path[MAXPATHLEN];
char *__script_root;
+   char *exec_path = perf_exec_path();

-   snprintf(scripts_path, MAXPATHLEN, "%s/scripts", perf_exec_path());
+   snprintf(scripts_path, MAXPATHLEN, "%s/scripts", exec_path);
+   free(exec_path);

scripts_dir = opendir(scripts_path);
if (!scripts_dir)
@@ -1199,6 +1203,7 @@ int cmd_script(int argc, const char **argv,
const char *prefix __used)
 {
char *rec_script_path = NULL;
char *rep_script_path = NULL;
+   char *exec_path = NULL;
struct perf_session *session;
char *script_path = NULL;
const char **__argv;
@@ -1226,7 +1231,9 @@ int cmd_script(int argc, const char **argv,
const char *prefix __used)
}

/* make sure PERF_EXEC_PATH is set for scripts */
-   perf_set_argv_exec_path(perf_exec_path());
+   exec_path = perf_exec_path();
+   perf_set_argv_exec_path(exec_path);
+   free(exec_path);

if (argc && !script_name && !rec_script_path && !rep_script_path) {
int live_pipe[2];
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 2b2e225..2198725 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -104,11 +104,15 @@ static int handle_options(const char ***argv,
int 

Re: [PATCH] dma: ipu: Drop unused spinlock

2012-09-13 Thread Vinod Koul
On Thu, 2012-09-06 at 09:19 +0200, Jean Delvare wrote:
> I was checking why this spinlock was never initialized, but it turns
> out it's not used anywhere, so we can drop it.
> 
> Signed-off-by: Jean Delvare 
> Cc: Vinod Koul 
> Cc: Dan Williams 
> ---
> I can't even build-test this.
> 
>  drivers/dma/ipu/ipu_irq.c |1 -
>  1 file changed, 1 deletion(-)
> 
> --- linux-3.6-rc4.orig/drivers/dma/ipu/ipu_irq.c  2012-08-04 
> 21:49:26.0 +0200
> +++ linux-3.6-rc4/drivers/dma/ipu/ipu_irq.c   2012-09-06 09:13:31.034228670 
> +0200
> @@ -45,7 +45,6 @@ static void ipu_write_reg(struct ipu *ip
>  struct ipu_irq_bank {
>   unsigned intcontrol;
>   unsigned intstatus;
> - spinlock_t  lock;
>   struct ipu  *ipu;
>  };
>  
Dan, you okay with this?



-- 
~Vinod

--
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] dma: tegra: use list_move_tail instead of list_del/list_add_tail

2012-09-13 Thread Vinod Koul
On Wed, 2012-09-05 at 15:08 +0800, Wei Yongjun wrote:
> From: Wei Yongjun 
> 
> Using list_move_tail() instead of list_del() + list_add_tail().
> 
> spatch with a semantic match is used to found this problem.
> (http://coccinelle.lip6.fr/)
> 
> Signed-off-by: Wei Yongjun 
Applied thanks
> ---
>  drivers/dma/tegra20-apb-dma.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
> index 24acd71..6ed3f43 100644
> --- a/drivers/dma/tegra20-apb-dma.c
> +++ b/drivers/dma/tegra20-apb-dma.c
> @@ -475,8 +475,7 @@ static void tegra_dma_abort_all(struct tegra_dma_channel 
> *tdc)
>   while (!list_empty(&tdc->pending_sg_req)) {
>   sgreq = list_first_entry(&tdc->pending_sg_req,
>   typeof(*sgreq), node);
> - list_del(&sgreq->node);
> - list_add_tail(&sgreq->node, &tdc->free_sg_req);
> + list_move_tail(&sgreq->node, &tdc->free_sg_req);
>   if (sgreq->last_sg) {
>   dma_desc = sgreq->dma_desc;
>   dma_desc->dma_status = DMA_ERROR;
> @@ -570,8 +569,7 @@ static void handle_cont_sngl_cycle_dma_done(struct 
> tegra_dma_channel *tdc,
>  
>   /* If not last req then put at end of pending list */
>   if (!list_is_last(&sgreq->node, &tdc->pending_sg_req)) {
> - list_del(&sgreq->node);
> - list_add_tail(&sgreq->node, &tdc->pending_sg_req);
> + list_move_tail(&sgreq->node, &tdc->pending_sg_req);
>   sgreq->configured = false;
>   st = handle_continuous_head_request(tdc, sgreq, to_terminate);
>   if (!st)
> 
> 
> --
> 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/


-- 
~Vinod

--
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 v2] kprobes/x86: Fix to support jprobes on ftrace-based kprobe

2012-09-13 Thread Steven Rostedt
From: Masami Hiramatsu 

Fix kprobes/x86 to support jprobes on ftrace-based kprobes.
Because of -mfentry support of ftrace, ftrace is now put
on the beginning of function where jprobes are put.

Originally ftrace-based kprobes doesn't support jprobe
because it will change regs->ip and ftrace doesn't support
changing IP and ftrace itself doesn't conflict jprobe.
However, ftrace -mfentry support moves mcount call on the
top of functions where jprobes are put. This means that
jprobe always conflicts with ftrace-based kprobe and fails.

This patch allows ftrace-based kprobes to support jprobes
by allowing to modify regs->ip and kprobes breakpoint
handler also allows to skip singlestepping because there
is a ftrace call (not an original instruction).

Link: 
http://lkml.kernel.org/r/20120905143125.10329.90836.stgit@localhost.localdomain

Reported-by: Fengguang Wu 
Cc: Peter Zijlstra 
Cc: Frederic Weisbecker 
Cc: Thomas Gleixner 
Cc: "H. Peter Anvin" 
Signed-off-by: Masami Hiramatsu 
Signed-off-by: Steven Rostedt 
---
 arch/x86/kernel/kprobes.c |   42 +-
 kernel/kprobes.c  |3 ---
 2 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index f49f60c..b7c2a85 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -541,6 +541,8 @@ reenter_kprobe(struct kprobe *p, struct pt_regs *regs, 
struct kprobe_ctlblk *kcb
return 1;
 }
 
+static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
+ struct kprobe_ctlblk *kcb);
 /*
  * Interrupts are disabled on entry as trap3 is an interrupt gate and they
  * remain disabled throughout this function.
@@ -599,6 +601,12 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
} else if (kprobe_running()) {
p = __this_cpu_read(current_kprobe);
if (p->break_handler && p->break_handler(p, regs)) {
+#ifdef KPROBES_CAN_USE_FTRACE
+   if (kprobe_ftrace(p)) {
+   skip_singlestep(p, regs, kcb);
+   return 1;
+   }
+#endif
setup_singlestep(p, regs, kcb, 0);
return 1;
}
@@ -1053,6 +1061,21 @@ int __kprobes longjmp_break_handler(struct kprobe *p, 
struct pt_regs *regs)
 }
 
 #ifdef KPROBES_CAN_USE_FTRACE
+static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
+ struct kprobe_ctlblk *kcb)
+{
+   /*
+* Emulate singlestep (and also recover regs->ip)
+* as if there is a 5byte nop
+*/
+   regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE;
+   if (unlikely(p->post_handler)) {
+   kcb->kprobe_status = KPROBE_HIT_SSDONE;
+   p->post_handler(p, regs, 0);
+   }
+   __this_cpu_write(current_kprobe, NULL);
+}
+
 /* Ftrace callback handler for kprobes */
 void __kprobes kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 struct ftrace_ops *ops, struct pt_regs 
*regs)
@@ -1077,19 +1100,12 @@ void __kprobes kprobe_ftrace_handler(unsigned long ip, 
unsigned long parent_ip,
 
__this_cpu_write(current_kprobe, p);
kcb->kprobe_status = KPROBE_HIT_ACTIVE;
-   if (p->pre_handler)
-   p->pre_handler(p, regs);
-
-   if (unlikely(p->post_handler)) {
-   /*
-* Emulate singlestep (and also recover regs->ip)
-* as if there is a 5byte nop
-*/
-   regs->ip = ip + MCOUNT_INSN_SIZE;
-   kcb->kprobe_status = KPROBE_HIT_SSDONE;
-   p->post_handler(p, regs, 0);
-   }
-   __this_cpu_write(current_kprobe, NULL);
+   if (!p->pre_handler || !p->pre_handler(p, regs))
+   skip_singlestep(p, regs, kcb);
+   /*
+* If pre_handler returns !0, it sets regs->ip and
+* resets current kprobe.
+*/
}
 end:
local_irq_restore(flags);
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 35b4315..098f396 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1418,9 +1418,6 @@ static __kprobes int check_kprobe_address_safe(struct 
kprobe *p,
/* Given address is not on the instruction boundary */
if ((unsigned long)p->addr != ftrace_addr)
return -EILSEQ;
-   /* break_handler (jprobe) can not work with ftrace */
-   if (p->break_handler)
-   return -EINVAL;
p->flags |= KPROBE_FLAG_FTRACE;
 #else  /* !KPROBES_CAN_USE_FTRACE */
return -EINVAL;
-- 
1.7.10.4




signature.asc
Description: This 

[PATCH 1/6 v2] tracing: Skip printing "OK" if failed to disable event

2012-09-13 Thread Steven Rostedt
From: Yuanhan Liu 

No acutal case found. But logically, we should skip "OK" in case any
error met.

Link: 
http://lkml.kernel.org/r/1346051625-25231-1-git-send-email-yuanhan@linux.intel.com

Signed-off-by: Yuanhan Liu 
Signed-off-by: Steven Rostedt 
---
 kernel/trace/trace_events.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 6825d83..bbb0e63 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1646,9 +1646,11 @@ static __init void event_trace_self_tests(void)
event_test_stuff();
 
ret = __ftrace_set_clr_event(NULL, system->name, NULL, 0);
-   if (WARN_ON_ONCE(ret))
+   if (WARN_ON_ONCE(ret)) {
pr_warning("error disabling system %s\n",
   system->name);
+   continue;
+   }
 
pr_cont("OK\n");
}
-- 
1.7.10.4




signature.asc
Description: This is a digitally signed message part


Re: [PATCH] dw_dmac: utilize slave_id to pass request line

2012-09-13 Thread Vinod Koul
On Mon, 2012-09-03 at 13:46 +0300, Andy Shevchenko wrote:
> There is slave_id field in the generic slave config structure that is 
> dedicated
> for the uniq slave number. In our case we have the request lines wired to the
> certain hardware. Therefore the number of the request line is uniq and could 
> be
> used as slave_id. It allows us in some cases to drop out the usage of the
> custom slave config structure.
> 
> Signed-off-by: Andy Shevchenko 
Applied thanks
> ---
>  drivers/dma/dw_dmac.c |5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
> index f0c9403..7a67673 100644
> --- a/drivers/dma/dw_dmac.c
> +++ b/drivers/dma/dw_dmac.c
> @@ -187,6 +187,11 @@ static void dwc_initialize(struct dw_dma_chan *dwc)
>  
>   cfghi = dws->cfg_hi;
>   cfglo |= dws->cfg_lo & ~DWC_CFGL_CH_PRIOR_MASK;
> + } else {
> + if (dwc->dma_sconfig.direction == DMA_MEM_TO_DEV)
> + cfghi = DWC_CFGH_DST_PER(dwc->dma_sconfig.slave_id);
> + else if (dwc->dma_sconfig.direction == DMA_DEV_TO_MEM)
> + cfghi = DWC_CFGH_SRC_PER(dwc->dma_sconfig.slave_id);
>   }
>  
>   channel_writel(dwc, CFG_LO, cfglo);


-- 
~Vinod

--
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/6 v2] kprobes/x86: Fix kprobes to collectly handle IP on ftrace

2012-09-13 Thread Steven Rostedt
From: Masami Hiramatsu 

Current kprobe_ftrace_handler expects regs->ip == ip, but it is
incorrect (originally on x86-64). Actually, ftrace handler sets
regs->ip = ip + MCOUNT_INSN_SIZE.
kprobe_ftrace_handler must take care for that.

Link: 
http://lkml.kernel.org/r/20120905143112.10329.72069.stgit@localhost.localdomain

Cc: Peter Zijlstra 
Cc: Frederic Weisbecker 
Cc: Thomas Gleixner 
Cc: "H. Peter Anvin" 
Signed-off-by: Masami Hiramatsu 
Signed-off-by: Steven Rostedt 
---
 arch/x86/kernel/kprobes.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 47ae102..f49f60c 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -1072,7 +1072,8 @@ void __kprobes kprobe_ftrace_handler(unsigned long ip, 
unsigned long parent_ip,
if (kprobe_running()) {
kprobes_inc_nmissed_count(p);
} else {
-   regs->ip += sizeof(kprobe_opcode_t);
+   /* Kprobe handler expects regs->ip = ip + 1 as breakpoint hit */
+   regs->ip = ip + sizeof(kprobe_opcode_t);
 
__this_cpu_write(current_kprobe, p);
kcb->kprobe_status = KPROBE_HIT_ACTIVE;
@@ -1080,13 +1081,15 @@ void __kprobes kprobe_ftrace_handler(unsigned long ip, 
unsigned long parent_ip,
p->pre_handler(p, regs);
 
if (unlikely(p->post_handler)) {
-   /* Emulate singlestep as if there is a 5byte nop */
+   /*
+* Emulate singlestep (and also recover regs->ip)
+* as if there is a 5byte nop
+*/
regs->ip = ip + MCOUNT_INSN_SIZE;
kcb->kprobe_status = KPROBE_HIT_SSDONE;
p->post_handler(p, regs, 0);
}
__this_cpu_write(current_kprobe, NULL);
-   regs->ip = ip;  /* Recover for next callback */
}
 end:
local_irq_restore(flags);
-- 
1.7.10.4




signature.asc
Description: This is a digitally signed message part


[PATCH 2/6 v2] trace: Stop compiling in trace_clock unconditionally

2012-09-13 Thread Steven Rostedt
From: Josh Triplett 

Commit 56449f437 "tracing: make the trace clocks available generally",
in April 2009, made trace_clock available unconditionally, since
CONFIG_X86_DS used it too.

Commit faa4602e47 "x86, perf, bts, mm: Delete the never used BTS-ptrace code",
in March 2010, removed CONFIG_X86_DS, and now only CONFIG_RING_BUFFER (split
out from CONFIG_TRACING for general use) has a dependency on trace_clock. So,
only compile in trace_clock with CONFIG_RING_BUFFER or CONFIG_TRACING
enabled.

Link: http://lkml.kernel.org/r/20120903024513.GA19583@leaf

Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Peter Zijlstra 
Cc: Andrew Morton 
Cc: "Eric W. Biederman" 
Cc: Al Viro 
Signed-off-by: Josh Triplett 
Signed-off-by: Steven Rostedt 
---
 kernel/Makefile   |2 +-
 kernel/trace/Kconfig  |5 +
 kernel/trace/Makefile |6 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/Makefile b/kernel/Makefile
index c0cc67a..29d993b 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -98,7 +98,7 @@ obj-$(CONFIG_COMPAT_BINFMT_ELF) += elfcore.o
 obj-$(CONFIG_BINFMT_ELF_FDPIC) += elfcore.o
 obj-$(CONFIG_FUNCTION_TRACER) += trace/
 obj-$(CONFIG_TRACING) += trace/
-obj-$(CONFIG_X86_DS) += trace/
+obj-$(CONFIG_TRACE_CLOCK) += trace/
 obj-$(CONFIG_RING_BUFFER) += trace/
 obj-$(CONFIG_TRACEPOINTS) += trace/
 obj-$(CONFIG_IRQ_WORK) += irq_work.o
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 9301a0e..4cea4f4 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -62,8 +62,12 @@ config HAVE_C_RECORDMCOUNT
 config TRACER_MAX_TRACE
bool
 
+config TRACE_CLOCK
+   bool
+
 config RING_BUFFER
bool
+   select TRACE_CLOCK
 
 config FTRACE_NMI_ENTER
bool
@@ -114,6 +118,7 @@ config TRACING
select NOP_TRACER
select BINARY_PRINTF
select EVENT_TRACING
+   select TRACE_CLOCK
 
 config GENERIC_TRACER
bool
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index 8370908..d7e2068 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -19,11 +19,7 @@ endif
 
 CFLAGS_trace_events_filter.o := -I$(src)
 
-#
-# Make the trace clocks available generally: it's infrastructure
-# relied on by ptrace for example:
-#
-obj-y += trace_clock.o
+obj-$(CONFIG_TRACE_CLOCK) += trace_clock.o
 
 obj-$(CONFIG_FUNCTION_TRACER) += libftrace.o
 obj-$(CONFIG_RING_BUFFER) += ring_buffer.o
-- 
1.7.10.4




signature.asc
Description: This is a digitally signed message part


Re: [PATCH] sched: unify the check on atomic sleeping in __might_sleep() and schedule_bug()

2012-09-13 Thread Michael Wang
On 09/13/2012 06:04 PM, Peter Zijlstra wrote:
> On Wed, 2012-08-22 at 10:40 +0800, Michael Wang wrote:
>> From: Michael Wang 
>>
>> Fengguang Wu  has reported the bug:
>>
>> [0.043953] BUG: scheduling while atomic: swapper/0/1/0x1002
>> [0.044017] no locks held by swapper/0/1.
>> [0.044692] Pid: 1, comm: swapper/0 Not tainted 3.6.0-rc1-00420-gb7aebb9 
>> #34
>> [0.045861] Call Trace:
>> [0.048071]  [] __schedule_bug+0x5e/0x70
>> [0.048890]  [] __schedule+0x91/0xb10
>> [0.049660]  [] ? vsnprintf+0x33a/0x450
>> [0.050444]  [] ? lg_local_lock+0x6/0x70
>> [0.051256]  [] ? wait_for_xmitr+0x31/0x90
>> [0.052019]  [] ? do_raw_spin_unlock+0xa5/0xf0
>> [0.052903]  [] ? _raw_spin_unlock+0x22/0x30
>> [0.053759]  [] ? up+0x1b/0x70
>> [0.054421]  [] __cond_resched+0x1b/0x30
>> [0.055228]  [] _cond_resched+0x45/0x50
>> [0.056020]  [] mutex_lock_nested+0x28/0x370
>> [0.056884]  [] ? console_unlock+0x3a2/0x4e0
>> [0.057741]  [] __irq_alloc_descs+0x39/0x1c0
>> [0.058589]  [] io_apic_setup_irq_pin+0x2c/0x310
>> [0.060042]  [] setup_IO_APIC+0x101/0x744
>> [0.060878]  [] ? clear_IO_APIC+0x31/0x50
>> [0.061695]  [] native_smp_prepare_cpus+0x538/0x680
>> [0.062644]  [] ? do_one_initcall+0x12c/0x12c
>> [0.063517]  [] ? do_one_initcall+0x12c/0x12c
>> [0.064016]  [] kernel_init+0x4b/0x17f
>> [0.064790]  [] ? do_one_initcall+0x12c/0x12c
>> [0.065660]  [] kernel_thread_helper+0x6/0x10
>>
>> It was caused by that:
>>
>>  native_smp_prepare_cpus()
>>  preempt_disable()   //preempt_count++
>>  mutex_lock()//in __irq_alloc_descs
>>  __might_sleep() //system is booting, avoid check
>>  might_resched()
>>  __schedule()
>>  preempt_disable()   //preempt_count++
>>  schedule_bug()  //preempt_count > 1, report bug
>>
>> The __might_sleep() avoid check on atomic sleeping until the system booted
>> while the schedule_bug() doesn't, it's the reason for the bug.
>>
>> This patch will add one additional check in schedule_bug() to avoid check
>> until the system booted, so the check on atomic sleeping will be unified.
>>
>> Signed-off-by: Michael Wang 
>> Tested-by: Fengguang Wu 
>> ---
>>  kernel/sched/core.c |3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 4376c9f..3396c33 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -3321,7 +3321,8 @@ static inline void schedule_debug(struct task_struct 
>> *prev)
>>   * schedule() atomically, we ignore that path for now.
>>   * Otherwise, whine if we are scheduling when we should not be.
>>   */
>> -if (unlikely(in_atomic_preempt_off() && !prev->exit_state))
>> +if (unlikely(in_atomic_preempt_off() && !prev->exit_state
>> +&& system_state == SYSTEM_RUNNING))
>>  __schedule_bug(prev);
>>  rcu_sleep_check();
>>  
> 
> 
> No this is very very wrong.. we avoid the might_sleep bug on !
> SYSTEM_RUNNING because while we _might_ sleep, we should _never_
> actually sleep under those conditions.
> 
> So hitting a schedule() here is an actual bug.

I see, so the rule is that we never allowed invoke schedule() with
preempt disabled.

The actual reason trigger this bug is that:
we invoke irq_alloc_descs() which will use mutex_lock() while
!SYSTEM_RUNNING.
And mutex_lock() invoke the might_sleep(), which do the schedule()
without any warning.

So if we want to follow the rule, should_resched() should never return
true if preempt disabled.

I think we could do changes like:



index c46a011..36fe510 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4209,7 +4209,7 @@ SYSCALL_DEFINE0(sched_yield)
 
 static inline int should_resched(void)
 {
-   return need_resched() && !(preempt_count() & PREEMPT_ACTIVE);
+   return need_resched() && !preempt_count();
 }
 
 static void __cond_resched(void)



Then the should_resched() will return false when the preempt disabled or
PREEMPT_ACTIVE bit is on.

Could we use this solution?

Regards,
Michael Wang

> --
> 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/
> 

--
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/6 v2] ftrace/x86: Adjust x86 regs.ip as like as x86-64

2012-09-13 Thread Steven Rostedt
From: Masami Hiramatsu 

Adjust x86 regs.ip to ip + MCOUNT_INSN_SIZE as like as
on x86-64. This helps us to consolidate codes which use
regs->ip on both of x86/x86-64.

Link: 
http://lkml.kernel.org/r/20120905143100.10329.60109.stgit@localhost.localdomain

Cc: Peter Zijlstra 
Cc: Frederic Weisbecker 
Cc: Thomas Gleixner 
Cc: "H. Peter Anvin" 
Signed-off-by: Masami Hiramatsu 
Signed-off-by: Steven Rostedt 
---
 arch/x86/kernel/entry_32.S |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 061ac17..f438a44 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1148,7 +1148,6 @@ ENTRY(ftrace_regs_caller)
 * ip location, and move flags into the return ip location.
 */
pushl 4(%esp)   /* save return ip into ip slot */
-   subl $MCOUNT_INSN_SIZE, (%esp)  /* Adjust ip */
 
pushl $0/* Load 0 into orig_ax */
pushl %gs
@@ -1169,6 +1168,7 @@ ENTRY(ftrace_regs_caller)
movl $__KERNEL_CS,13*4(%esp)
 
movl 12*4(%esp), %eax   /* Load ip (1st parameter) */
+   subl $MCOUNT_INSN_SIZE, %eax/* Adjust ip */
movl 0x4(%ebp), %edx/* Load parent ip (2nd parameter) */
leal function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
pushl %esp  /* Save pt_regs as 4th parameter */
@@ -1180,7 +1180,6 @@ GLOBAL(ftrace_regs_call)
movl 14*4(%esp), %eax   /* Move flags back into cs */
movl %eax, 13*4(%esp)   /* Needed to keep addl from modifying flags */
movl 12*4(%esp), %eax   /* Get return ip from regs->ip */
-   addl $MCOUNT_INSN_SIZE, %eax
movl %eax, 14*4(%esp)   /* Put return ip back for ret */
 
popl %ebx
-- 
1.7.10.4




signature.asc
Description: This is a digitally signed message part


[PATCH 5/6 v2] ftrace/x86-64: Allow to change RIP in handlers

2012-09-13 Thread Steven Rostedt
From: Steven Rostedt 

Allow ftrace handlers to change RIP register (regs->ip)
in handlers. This will allow handlers to call another
function instead of original function.

Link: 
http://lkml.kernel.org/r/20120905143118.10329.5078.stgit@localhost.localdomain

Cc: Peter Zijlstra 
Cc: Frederic Weisbecker 
Cc: Thomas Gleixner 
Cc: "H. Peter Anvin" 
Signed-off-by: Masami Hiramatsu 
Signed-off-by: Steven Rostedt 
---
 arch/x86/kernel/entry_64.S |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index ed767b7..e9cc2b3 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -165,6 +165,10 @@ GLOBAL(ftrace_regs_call)
movq EFLAGS(%rsp), %rax
movq %rax, SS(%rsp)
 
+   /* Handlers can change the RIP */
+   movq RIP(%rsp), %rax
+   movq %rax, SS+8(%rsp)
+
/* restore the rest of pt_regs */
movq R15(%rsp), %r15
movq R14(%rsp), %r14
-- 
1.7.10.4




signature.asc
Description: This is a digitally signed message part


[PATCH 0/6 v2] [GIT PULL][3.7] tracing: cleanups and fixes

2012-09-13 Thread Steven Rostedt

Ingo,

As I believe the -pg removal from perf was holding up the patch
set, although Frederic and I are working that out, I rebased my
patch set to remove that change, for a later time.

The rest holds fixes to bugs that are in your queue for 3.7.

Please pull the latest tip/perf/core tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
tip/perf/core

Head SHA1: c6aaf4d0bb86e2154ea31a33804cec300611255f


Josh Triplett (1):
  trace: Stop compiling in trace_clock unconditionally

Masami Hiramatsu (3):
  ftrace/x86: Adjust x86 regs.ip as like as x86-64
  kprobes/x86: Fix kprobes to collectly handle IP on ftrace
  kprobes/x86: Fix to support jprobes on ftrace-based kprobe

Steven Rostedt (1):
  ftrace/x86-64: Allow to change RIP in handlers

Yuanhan Liu (1):
  tracing: Skip printing "OK" if failed to disable event


 arch/x86/kernel/entry_32.S  |3 +--
 arch/x86/kernel/entry_64.S  |4 
 arch/x86/kernel/kprobes.c   |   43 +++
 kernel/Makefile |2 +-
 kernel/kprobes.c|3 ---
 kernel/trace/Kconfig|5 +
 kernel/trace/Makefile   |6 +-
 kernel/trace/trace_events.c |4 +++-
 8 files changed, 46 insertions(+), 24 deletions(-)


signature.asc
Description: This is a digitally signed message part


Re: [PATCH 1/2] dmaengine: at_hdmac: fix comment in atc_prep_slave_sg()

2012-09-13 Thread Vinod Koul
On Tue, 2012-09-11 at 17:21 +0200, Nicolas Ferre wrote:
> s/dma_memcpy/slave_sg/ and it is sg length that we are
> talking about.
> 
> Signed-off-by: Nicolas Ferre 
> Cc: Stable  [2.6.31+]
> ---
>  drivers/dma/at_hdmac.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index 3934fcc..6c09e18 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
> @@ -661,7 +661,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct 
> scatterlist *sgl,
>   flags);
>  
>   if (unlikely(!atslave || !sg_len)) {
> - dev_dbg(chan2dev(chan), "prep_dma_memcpy: length is zero!\n");
> + dev_dbg(chan2dev(chan), "prep_slave_sg: sg length is zero!\n");
>   return NULL;
>   }
Applied both, Thanks.

I will send this to Linus in couple of days


-- 
~Vinod

--
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   5   6   7   >