RE: [alsa-devel] [RFC][PATCH] ASoC: simple-card: Add asoc_simple_card_data for the simple card driver data

2014-01-13 Thread li.xi...@freescale.com

> > Whether the dt is used or not, almost all the simple card information
> > for the DAI link and sound card are initialized in the simple card driver.
> >
> > And for the platform caller, the snd_link and snd_card are of no use, so
> > move them from struct asoc_simple_card_info to struct asoc_simple_card_data.
> >
> > And now only one DAI link is supported for simple card.
> >
> > Suggested-by: Jean-Francois Moine 
> > Signed-off-by: Xiubo Li 
> > ---
> 
> This patch seems have many this kind of lines
>   -   info->xxx
>   +   sdata->info->xxx
> 
> But, how about add this line to each function ?
> 
>  struct asoc_simple_card_info *info = &sdata->info;
> 
> Patch will be more readable
>

Yes, that's looks perfect.

See the next version please.

Thanks,

--
Best Regards,
Xiubo


--
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 net-next 03/10] eql: use __dev_get_by_name instead of dev_get_by_name to find interface

2014-01-13 Thread Ying Xue
The following call chain indicates that eql_ioctl(), eql_enslave(),
eql_emancipate(), eql_g_slave_cfg() and eql_s_slave_cfg() are
protected under rtnl_lock. So if we use __dev_get_by_name() instead
of dev_get_by_name() to find interface handlers in them, this would
help us avoid to change interface reference counters.

dev_ioctl()
  rtnl_lock()
dev_ifsioc()
  eql_ioctl()
eql_enslave()
eql_emancipate()
eql_g_slave_cfg()
eql_s_slave_cfg()
  rtnl_unlock()

Additionally we also change their return values from -EINVAL to
-ENODEV in case that interfaces are no found.

Signed-off-by: Ying Xue 
---
 drivers/net/eql.c |   95 +++--
 1 file changed, 42 insertions(+), 53 deletions(-)

diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index f219d38..7a79b60 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -395,6 +395,7 @@ static int __eql_insert_slave(slave_queue_t *queue, slave_t 
*slave)
if (duplicate_slave)
eql_kill_one_slave(queue, duplicate_slave);
 
+   dev_hold(slave->dev);
list_add(&slave->list, &queue->all_slaves);
queue->num_slaves++;
slave->dev->flags |= IFF_SLAVE;
@@ -413,39 +414,35 @@ static int eql_enslave(struct net_device *master_dev, 
slaving_request_t __user *
if (copy_from_user(&srq, srqp, sizeof (slaving_request_t)))
return -EFAULT;
 
-   slave_dev  = dev_get_by_name(&init_net, srq.slave_name);
-   if (slave_dev) {
-   if ((master_dev->flags & IFF_UP) == IFF_UP) {
-   /* slave is not a master & not already a slave: */
-   if (!eql_is_master(slave_dev) &&
-   !eql_is_slave(slave_dev)) {
-   slave_t *s = kmalloc(sizeof(*s), GFP_KERNEL);
-   equalizer_t *eql = netdev_priv(master_dev);
-   int ret;
-
-   if (!s) {
-   dev_put(slave_dev);
-   return -ENOMEM;
-   }
-
-   memset(s, 0, sizeof(*s));
-   s->dev = slave_dev;
-   s->priority = srq.priority;
-   s->priority_bps = srq.priority;
-   s->priority_Bps = srq.priority / 8;
-
-   spin_lock_bh(&eql->queue.lock);
-   ret = __eql_insert_slave(&eql->queue, s);
-   if (ret) {
-   dev_put(slave_dev);
-   kfree(s);
-   }
-   spin_unlock_bh(&eql->queue.lock);
-
-   return ret;
-   }
+   slave_dev = __dev_get_by_name(&init_net, srq.slave_name);
+   if (!slave_dev)
+   return -ENODEV;
+
+   if ((master_dev->flags & IFF_UP) == IFF_UP) {
+   /* slave is not a master & not already a slave: */
+   if (!eql_is_master(slave_dev) && !eql_is_slave(slave_dev)) {
+   slave_t *s = kmalloc(sizeof(*s), GFP_KERNEL);
+   equalizer_t *eql = netdev_priv(master_dev);
+   int ret;
+
+   if (!s)
+   return -ENOMEM;
+
+   memset(s, 0, sizeof(*s));
+   s->dev = slave_dev;
+   s->priority = srq.priority;
+   s->priority_bps = srq.priority;
+   s->priority_Bps = srq.priority / 8;
+
+   spin_lock_bh(&eql->queue.lock);
+   ret = __eql_insert_slave(&eql->queue, s);
+   if (ret)
+   kfree(s);
+
+   spin_unlock_bh(&eql->queue.lock);
+
+   return ret;
}
-   dev_put(slave_dev);
}
 
return -EINVAL;
@@ -461,24 +458,20 @@ static int eql_emancipate(struct net_device *master_dev, 
slaving_request_t __use
if (copy_from_user(&srq, srqp, sizeof (slaving_request_t)))
return -EFAULT;
 
-   slave_dev = dev_get_by_name(&init_net, srq.slave_name);
-   ret = -EINVAL;
-   if (slave_dev) {
-   spin_lock_bh(&eql->queue.lock);
-
-   if (eql_is_slave(slave_dev)) {
-   slave_t *slave = __eql_find_slave_dev(&eql->queue,
- slave_dev);
+   slave_dev = __dev_get_by_name(&init_net, srq.slave_name);
+   if (!slave_dev)
+   return -ENODEV;
 
-   if (slave) {
-   eql_kill_one_slave(&eql->queue, sl

[PATCH v2 0/3] Add modules for realtek USB card reader

2014-01-13 Thread rogerable
From: Roger Tseng 

This patchset adds modules to support Realtek USB vendor specific class flash
card reader: one base module in MFD subsystem and two host modules in both mmc
and memstick subsystems. The architecture is similar to rtsx_pci.

This work is done primarily to replace the staging driver: staging/rts5139,
which doesn't utilize mmc nor memstick subsystems. Once the patchset or its
revision is applied, we may need Greg's help to remove the staging one.

v2:
1. Fix potential buffer overflow in rtsx_usb_seq_write_register()
2. Remove unnecessary casting and messages
2. Revise coding style and white spaces

Roger Tseng (3):
  mfd: Add realtek USB card reader driver
  mmc: Add realtek USB sdmmc host driver
  memstick: Add realtek USB memstick host driver

 drivers/memstick/host/Kconfig   |   10 +
 drivers/memstick/host/Makefile  |1 +
 drivers/memstick/host/rtsx_usb_ms.c |  855 
 drivers/mfd/Kconfig |   10 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/rtsx_usb.c  |  788 ++
 drivers/mmc/host/Kconfig|7 +
 drivers/mmc/host/Makefile   |1 +
 drivers/mmc/host/rtsx_usb_sdmmc.c   | 1509 +++
 include/linux/mfd/rtsx_usb.h|  619 ++
 10 files changed, 3801 insertions(+)
 create mode 100644 drivers/memstick/host/rtsx_usb_ms.c
 create mode 100644 drivers/mfd/rtsx_usb.c
 create mode 100644 drivers/mmc/host/rtsx_usb_sdmmc.c
 create mode 100644 include/linux/mfd/rtsx_usb.h

-- 
1.8.2

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


[PATCH 1/3] mfd: Add realtek USB card reader driver

2014-01-13 Thread rogerable
From: Roger Tseng 

Realtek USB card reader provides a channel to transfer command or data to flash
memory cards. This driver exports host instances for mmc and memstick subsystems
and handles basic works.

Signed-off-by: Roger Tseng 
---
 drivers/mfd/Kconfig  |  10 +
 drivers/mfd/Makefile |   1 +
 drivers/mfd/rtsx_usb.c   | 788 +++
 include/linux/mfd/rtsx_usb.h | 619 +
 4 files changed, 1418 insertions(+)
 create mode 100644 drivers/mfd/rtsx_usb.c
 create mode 100644 include/linux/mfd/rtsx_usb.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..4c99ebd 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -507,6 +507,16 @@ config MFD_RTSX_PCI
  types of memory cards, such as Memory Stick, Memory Stick Pro,
  Secure Digital and MultiMediaCard.
 
+config MFD_RTSX_USB
+   tristate "Realtek USB card reader"
+   depends on USB
+   select MFD_CORE
+   help
+   Select this option to get support for Realtek USB 2.0 card readers
+   including RTS5129, RTS5139, RTS5179 and RTS5170.
+   Realtek card reader supports access to many types of memory cards,
+   such as Memory Stick Pro, Secure Digital and MultiMediaCard.
+
 config MFD_RC5T583
bool "Ricoh RC5T583 Power Management system device"
depends on I2C=y
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..33b8de6 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o
 
 rtsx_pci-objs  := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o 
rts5227.o rts5249.o
 obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o
+obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o
 
 obj-$(CONFIG_HTC_EGPIO)+= htc-egpio.o
 obj-$(CONFIG_HTC_PASIC3)   += htc-pasic3.o
diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c
new file mode 100644
index 000..905ec8d
--- /dev/null
+++ b/drivers/mfd/rtsx_usb.c
@@ -0,0 +1,788 @@
+/* Driver for Realtek USB card reader
+ *
+ * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ *
+ * Author:
+ *   Roger Tseng 
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int polling_pipe = 1;
+module_param(polling_pipe, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(polling_pipe, "polling pipe (0: ctl, 1: bulk)");
+static struct mfd_cell rtsx_usb_cells[] = {
+   [RTSX_USB_SD_CARD] = {
+   .name = DRV_NAME_RTSX_USB_SDMMC,
+   },
+   [RTSX_USB_MS_CARD] = {
+   .name = DRV_NAME_RTSX_USB_MS,
+   },
+};
+
+static void rtsx_usb_sg_timed_out(unsigned long data)
+{
+   struct rtsx_ucr *ucr = (struct rtsx_ucr *)data;
+
+   dev_dbg(&ucr->pusb_intf->dev, "%s: sg transfer timed out", __func__);
+   usb_sg_cancel(&ucr->current_sg);
+
+   /* we know the cancellation is caused by time-out */
+   ucr->current_sg.status = -ETIMEDOUT;
+}
+
+static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr,
+   unsigned int pipe, struct scatterlist *sg, int num_sg,
+   unsigned int length, unsigned int *act_len, int timeout)
+{
+   int ret;
+
+   dev_dbg(&ucr->pusb_intf->dev, "%s: xfer %u bytes, %d entries\n",
+   __func__, length, num_sg);
+   ret = usb_sg_init(&ucr->current_sg, ucr->pusb_dev, pipe, 0,
+   sg, num_sg, length, GFP_NOIO);
+   if (ret)
+   return ret;
+
+   ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout);
+   add_timer(&ucr->sg_timer);
+   usb_sg_wait(&ucr->current_sg);
+   del_timer(&ucr->sg_timer);
+
+   if (act_len)
+   *act_len = ucr->current_sg.bytes;
+
+   return ucr->current_sg.status;
+}
+
+int rtsx_usb_transfer_data(struct rtsx_ucr *ucr, unsigned int pipe,
+ void *buf, unsigned int len, int num_sg,
+ unsigned int *act_len, int timeout)
+{
+   if (timeout < 600)
+   timeout = 600;
+
+   if (num_sg)
+   return rtsx_usb_bulk_transfer_sglist(ucr, pipe,
+   (struct scatterlist *)buf, num_sg, len, act_len,
+   timeout);
+   els

[RESEND][PATCH] APIC: Read Error Status Register correctly

2014-01-13 Thread Richard Weinberger
Currently we do a read, a dummy write and a final read to fetch the error code.
The value from the final read is taken.
This is not the recommended way and leads to corrupted/lost ESR values.

Intel(c) 64 and IA-32 Architectures Software Developer's Manual,
Combined Volumes 1, 2ABC, 3ABC, Section 10.5.3 states:
>>Before attempt to read from the ESR, software should first write to it.
(The value written does not affect the values read subsequently;
only zero may be written in x2APIC mode.) This write clears
any previously logged errors and updates the ESR with any errors
detected since the last write to the ESR.
This write also rearms the APIC error interrupt triggering mechanism.<<

This patch removes the first read such that we are conform with the manual.

On my (very old) Pentium MMX SMP system this patch fixes the issue that
APIC errors a) are not always reported and b) are reported with false
error numbers.

Signed-off-by: Richard Weinberger 
---
 arch/x86/kernel/apic/apic.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index d278736..4ec1dd6 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1968,7 +1968,7 @@ __visible void smp_trace_spurious_interrupt(struct 
pt_regs *regs)
  */
 static inline void __smp_error_interrupt(struct pt_regs *regs)
 {
-   u32 v0, v1;
+   u32 v;
u32 i = 0;
static const char * const error_interrupt_reason[] = {
"Send CS error",/* APIC Error Bit 0 */
@@ -1982,21 +1982,20 @@ static inline void __smp_error_interrupt(struct pt_regs 
*regs)
};
 
/* First tickle the hardware, only then report what went on. -- REW */
-   v0 = apic_read(APIC_ESR);
apic_write(APIC_ESR, 0);
-   v1 = apic_read(APIC_ESR);
+   v = apic_read(APIC_ESR);
ack_APIC_irq();
atomic_inc(&irq_err_count);
 
-   apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
-   smp_processor_id(), v0 , v1);
+   apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x",
+   smp_processor_id(), v);
 
-   v1 = v1 & 0xff;
-   while (v1) {
-   if (v1 & 0x1)
+   v &= 0xff;
+   while (v) {
+   if (v & 0x1)
apic_printk(APIC_DEBUG, KERN_CONT " : %s", 
error_interrupt_reason[i]);
i++;
-   v1 >>= 1;
+   v >>= 1;
}
 
apic_printk(APIC_DEBUG, KERN_CONT "\n");
-- 
1.8.4.2

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


[PATCH 3/3] memstick: Add realtek USB memstick host driver

2014-01-13 Thread rogerable
From: Roger Tseng 

Realtek USB memstick host driver provides memstick host support based on the
Realtek USB card reader MFD driver.

Signed-off-by: Roger Tseng 
---
 drivers/memstick/host/Kconfig   |  10 +
 drivers/memstick/host/Makefile  |   1 +
 drivers/memstick/host/rtsx_usb_ms.c | 855 
 3 files changed, 866 insertions(+)
 create mode 100644 drivers/memstick/host/rtsx_usb_ms.c

diff --git a/drivers/memstick/host/Kconfig b/drivers/memstick/host/Kconfig
index 1b37cf8..7310e32 100644
--- a/drivers/memstick/host/Kconfig
+++ b/drivers/memstick/host/Kconfig
@@ -52,3 +52,13 @@ config MEMSTICK_REALTEK_PCI
 
  To compile this driver as a module, choose M here: the module will
  be called rtsx_pci_ms.
+
+config MEMSTICK_REALTEK_USB
+   tristate "Realtek USB Memstick Card Interface Driver"
+   depends on MFD_RTSX_USB
+   help
+ Say Y here to include driver code to support Memstick card interface
+ of Realtek RTS5129/39 series USB card reader
+
+ To compile this driver as a module, choose M here: the module will
+ be called rts5139_ms.
diff --git a/drivers/memstick/host/Makefile b/drivers/memstick/host/Makefile
index af3459d..491c955 100644
--- a/drivers/memstick/host/Makefile
+++ b/drivers/memstick/host/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_MEMSTICK_TIFM_MS)  += tifm_ms.o
 obj-$(CONFIG_MEMSTICK_JMICRON_38X) += jmb38x_ms.o
 obj-$(CONFIG_MEMSTICK_R592)+= r592.o
 obj-$(CONFIG_MEMSTICK_REALTEK_PCI) += rtsx_pci_ms.o
+obj-$(CONFIG_MEMSTICK_REALTEK_USB) += rtsx_usb_ms.o
diff --git a/drivers/memstick/host/rtsx_usb_ms.c 
b/drivers/memstick/host/rtsx_usb_ms.c
new file mode 100644
index 000..71d865f
--- /dev/null
+++ b/drivers/memstick/host/rtsx_usb_ms.c
@@ -0,0 +1,855 @@
+/* Realtek USB Memstick Card Interface driver
+ *
+ * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ *
+ * Author:
+ *   Roger Tseng 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct rtsx_usb_ms {
+   struct platform_device  *pdev;
+   struct rtsx_ucr *ucr;
+   struct memstick_host*msh;
+   struct memstick_request *req;
+
+   struct mutexhost_mutex;
+   struct work_struct  handle_req;
+
+   struct task_struct  *detect_ms;
+   struct completion   detect_ms_exit;
+
+   u8  ssc_depth;
+   unsigned intclock;
+   int power_mode;
+   unsigned char   ifmode;
+   booleject;
+};
+
+static inline struct device *ms_dev(struct rtsx_usb_ms *host)
+{
+   return &(host->pdev->dev);
+}
+
+static inline void ms_clear_error(struct rtsx_usb_ms *host)
+{
+   struct rtsx_ucr *ucr = host->ucr;
+   rtsx_usb_ep0_write_register(ucr, CARD_STOP,
+ MS_STOP | MS_CLR_ERR,
+ MS_STOP | MS_CLR_ERR);
+
+   rtsx_usb_clear_dma_err(ucr);
+   rtsx_usb_clear_fsm_err(ucr);
+}
+
+#ifdef DEBUG
+
+static void ms_print_debug_regs(struct rtsx_usb_ms *host)
+{
+   struct rtsx_ucr *ucr = host->ucr;
+   u16 i;
+   u8 *ptr;
+
+   /* Print MS host internal registers */
+   rtsx_usb_init_cmd(ucr);
+
+   /* MS_CFG to MS_INT_REG */
+   for (i = 0xFD40; i <= 0xFD44; i++)
+   rtsx_usb_add_cmd(ucr, READ_REG_CMD, i, 0, 0);
+
+   /* CARD_SHARE_MODE to CARD_GPIO */
+   for (i = 0xFD51; i <= 0xFD56; i++)
+   rtsx_usb_add_cmd(ucr, READ_REG_CMD, i, 0, 0);
+
+   /* CARD_PULL_CTLx */
+   for (i = 0xFD60; i <= 0xFD65; i++)
+   rtsx_usb_add_cmd(ucr, READ_REG_CMD, i, 0, 0);
+
+   /* CARD_DATA_SOURCE, CARD_SELECT, CARD_CLK_EN, CARD_PWR_CTL */
+   rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_DATA_SOURCE, 0, 0);
+   rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_SELECT, 0, 0);
+   rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_CLK_EN, 0, 0);
+   rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_PWR_CTL, 0, 0);
+
+   rtsx_usb_send_cmd(ucr, MODE_CR, 100);
+   rtsx_usb_get_rsp(ucr, 21, 100);
+
+   ptr = ucr->rsp_buf;
+   for (i = 0xFD40; i <= 0xFD44; i++)
+   dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++))

[PATCH 2/3] mmc: Add realtek USB sdmmc host driver

2014-01-13 Thread rogerable
From: Roger Tseng 

Realtek USB SD/MMC host driver provides mmc host support based on the Realtek
USB card reader MFD driver.

Signed-off-by: Roger Tseng 
---
 drivers/mmc/host/Kconfig  |7 +
 drivers/mmc/host/Makefile |1 +
 drivers/mmc/host/rtsx_usb_sdmmc.c | 1509 +
 3 files changed, 1517 insertions(+)
 create mode 100644 drivers/mmc/host/rtsx_usb_sdmmc.c

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 7fc5099..16f9a23 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -665,3 +665,10 @@ config MMC_REALTEK_PCI
help
  Say Y here to include driver code to support SD/MMC card interface
  of Realtek PCI-E card reader
+
+config MMC_REALTEK_USB
+   tristate "Realtek USB SD/MMC Card Interface Driver"
+   depends on MFD_RTSX_USB
+   help
+ Say Y here to include driver code to support SD/MMC card interface
+ of Realtek RTS5129/39 series card reader
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index c41d0c3..9d8d765 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_MMC_USHC)+= ushc.o
 obj-$(CONFIG_MMC_WMT)  += wmt-sdmmc.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)  += rtsx_pci_sdmmc.o
+obj-$(CONFIG_MMC_REALTEK_USB)  += rtsx_usb_sdmmc.o
 
 obj-$(CONFIG_MMC_SDHCI_PLTFM)  += sdhci-pltfm.o
 obj-$(CONFIG_MMC_SDHCI_CNS3XXX)+= sdhci-cns3xxx.o
diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c 
b/drivers/mmc/host/rtsx_usb_sdmmc.c
new file mode 100644
index 000..b1c489f
--- /dev/null
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -0,0 +1,1509 @@
+/* Realtek USB SD/MMC Card Interface driver
+ *
+ * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ *
+ * Author:
+ *   Roger Tseng 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
+#include 
+#include 
+#define RTSX_USB_USE_LEDS_CLASS
+#endif
+
+struct rtsx_usb_sdmmc {
+   struct platform_device  *pdev;
+   struct rtsx_ucr *ucr;
+   struct mmc_host *mmc;
+   struct mmc_request  *mrq;
+
+   struct mutexhost_mutex;
+
+   u8  ssc_depth;
+   unsigned intclock;
+   boolvpclk;
+   booldouble_clk;
+   boolhost_removal;
+   boolcard_exist;
+   boolinitial_mode;
+   boolddr_mode;
+
+   unsigned char   power_mode;
+
+#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
+   struct led_classdev led;
+   charled_name[32];
+   struct work_struct  led_work;
+#endif
+};
+
+static inline struct device *sdmmc_dev(struct rtsx_usb_sdmmc *host)
+{
+   return &(host->pdev->dev);
+}
+
+static inline void sd_clear_error(struct rtsx_usb_sdmmc *host)
+{
+   struct rtsx_ucr *ucr = host->ucr;
+   rtsx_usb_ep0_write_register(ucr, CARD_STOP,
+ SD_STOP | SD_CLR_ERR,
+ SD_STOP | SD_CLR_ERR);
+
+   rtsx_usb_clear_dma_err(ucr);
+   rtsx_usb_clear_fsm_err(ucr);
+}
+
+#ifdef DEBUG
+static void sd_print_debug_regs(struct rtsx_usb_sdmmc *host)
+{
+   struct rtsx_ucr *ucr = host->ucr;
+   u8 val = 0;
+
+   rtsx_usb_ep0_read_register(ucr, SD_STAT1, &val);
+   dev_dbg(sdmmc_dev(host), "SD_STAT1: 0x%x\n", val);
+   rtsx_usb_ep0_read_register(ucr, SD_STAT2, &val);
+   dev_dbg(sdmmc_dev(host), "SD_STAT2: 0x%x\n", val);
+   rtsx_usb_ep0_read_register(ucr, SD_BUS_STAT, &val);
+   dev_dbg(sdmmc_dev(host), "SD_BUS_STAT: 0x%x\n", val);
+}
+#else
+#define sd_print_debug_regs(host)
+#endif /* DEBUG */
+
+static int sd_read_data(struct rtsx_usb_sdmmc *host, struct mmc_command *cmd,
+  u16 byte_cnt, u8 *buf, int buf_len, int timeout)
+{
+   struct rtsx_ucr *ucr = host->ucr;
+   int err;
+   u8 trans_mode;
+
+   if (!buf)
+   buf_len = 0;
+
+   rtsx_usb_init_cmd(ucr);
+   if (cmd != N

Re: [PATCH 02/14] target: Add DIF CHECK_CONDITION ASC/ASCQ exception cases

2014-01-13 Thread Sagi Grimberg

On 1/10/2014 8:53 AM, Nicholas A. Bellinger wrote:

On Thu, 2014-01-09 at 12:43 +0200, Sagi Grimberg wrote:

On 1/8/2014 10:36 PM, Nicholas A. Bellinger wrote:

From: Nicholas Bellinger 

This patch adds support for DIF related CHECK_CONDITION ASC/ASCQ
exception cases into transport_send_check_condition_and_sense().

This includes:

LOGICAL BLOCK GUARD CHECK FAILED
LOGICAL BLOCK APPLICATION TAG CHECK FAILED
LOGICAL BLOCK REFERENCE TAG CHECK FAILED

that used by DIF TYPE1 and TYPE3 failure cases.

Cc: Martin K. Petersen 
Cc: Christoph Hellwig 
Cc: Hannes Reinecke 
Cc: Sagi Grimberg 
Cc: Or Gerlitz 
Signed-off-by: Nicholas Bellinger 
---
   drivers/target/target_core_transport.c |   30 ++
   include/target/target_core_base.h  |3 +++
   2 files changed, 33 insertions(+)

diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index 91953da..707ee17 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2648,6 +2648,36 @@ transport_send_check_condition_and_sense(struct se_cmd 
*cmd,
buffer[SPC_ASC_KEY_OFFSET] = 0x1d;
buffer[SPC_ASCQ_KEY_OFFSET] = 0x00;
break;
+   case TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED:
+   /* CURRENT ERROR */
+   buffer[0] = 0x70;
+   buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10;
+   /* ILLEGAL REQUEST */
+   buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
+   /* LOGICAL BLOCK GUARD CHECK FAILED */
+   buffer[SPC_ASC_KEY_OFFSET] = 0x10;
+   buffer[SPC_ASCQ_KEY_OFFSET] = 0x01;




Hey Nic,

In my iSER patches I constructed the same sense buffer (call 
isert_pi_err_sense_buffer) and called isert_put_rsponse. So I should 
call this routine instead correct?

--
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 net-next 04/10] dcb: use __dev_get_by_name instead of dev_get_by_name to find interface

2014-01-13 Thread Ying Xue
The following call chain indicates that dcb_doit() is protected
under rtnl_lock. So if we use __dev_get_by_name() instead of
dev_get_by_name() to find interface handlers in it, this would
help us avoid to change interface reference counter.

rtnetlink_rcv()
  rtnl_lock()
  netlink_rcv_skb()
dcb_doit()
  rtnl_unlock()

Cc: John Fastabend 
Signed-off-by: Ying Xue 
---
 net/dcb/dcbnl.c |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 66fbe19..5536444 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1688,21 +1688,17 @@ static int dcb_doit(struct sk_buff *skb, struct 
nlmsghdr *nlh)
if (!tb[DCB_ATTR_IFNAME])
return -EINVAL;
 
-   netdev = dev_get_by_name(net, nla_data(tb[DCB_ATTR_IFNAME]));
+   netdev = __dev_get_by_name(net, nla_data(tb[DCB_ATTR_IFNAME]));
if (!netdev)
return -ENODEV;
 
-   if (!netdev->dcbnl_ops) {
-   ret = -EOPNOTSUPP;
-   goto out;
-   }
+   if (!netdev->dcbnl_ops)
+   return -EOPNOTSUPP;
 
reply_skb = dcbnl_newmsg(fn->type, dcb->cmd, portid, nlh->nlmsg_seq,
 nlh->nlmsg_flags, &reply_nlh);
-   if (!reply_skb) {
-   ret = -ENOBUFS;
-   goto out;
-   }
+   if (!reply_skb)
+   return -ENOBUFS;
 
ret = fn->cb(netdev, nlh, nlh->nlmsg_seq, tb, reply_skb);
if (ret < 0) {
@@ -1714,7 +1710,6 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr 
*nlh)
 
ret = rtnl_unicast(reply_skb, net, portid);
 out:
-   dev_put(netdev);
return ret;
 }
 
-- 
1.7.9.5

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


[PATCH net-next 07/10] batman-adv: use __dev_get_by_index instead of dev_get_by_index to find interface

2014-01-13 Thread Ying Xue
The following call chains indicate that batadv_is_on_batman_iface()
is always under rtnl_lock protection as call_netdevice_notifier()
is protected by rtnl_lock. So if __dev_get_by_index() rather than
dev_get_by_index() is used to find interface handler in it, this
would help us avoid to change interface reference counter.

call_netdevice_notifier()
  batadv_hard_if_event()
batadv_hardif_add_interface()
  batadv_is_valid_iface()
batadv_is_on_batman_iface()

Cc: Antonio Quartulli 
Signed-off-by: Ying Xue 
---
 net/batman-adv/hard-interface.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index bebd46c..115d14e 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -86,15 +86,13 @@ static bool batadv_is_on_batman_iface(const struct 
net_device *net_dev)
return false;
 
/* recurse over the parent device */
-   parent_dev = dev_get_by_index(&init_net, net_dev->iflink);
+   parent_dev = __dev_get_by_index(&init_net, net_dev->iflink);
/* if we got a NULL parent_dev there is something broken.. */
if (WARN(!parent_dev, "Cannot find parent device"))
return false;
 
ret = batadv_is_on_batman_iface(parent_dev);
 
-   if (parent_dev)
-   dev_put(parent_dev);
return ret;
 }
 
-- 
1.7.9.5

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


[PATCH net-next 05/10] decnet: use __dev_get_by_index instead of dev_get_by_index to find interface

2014-01-13 Thread Ying Xue
The following call chain we can identify that dn_cache_getroute() is
protected under rtnl_lock. So if we use __dev_get_by_index() instead
of dev_get_by_index() to find interface handlers in it, this would help
us avoid to change interface reference counter.

rtnetlink_rcv()
  rtnl_lock()
netlink_rcv_skb()
  dn_cache_getroute()
  rtnl_unlock()

Signed-off-by: Ying Xue 
---
 net/decnet/dn_route.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index ad2efa5..22390e4 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1666,12 +1666,12 @@ static int dn_cache_getroute(struct sk_buff *in_skb, 
struct nlmsghdr *nlh)
 
if (fld.flowidn_iif) {
struct net_device *dev;
-   if ((dev = dev_get_by_index(&init_net, fld.flowidn_iif)) == 
NULL) {
+   dev = __dev_get_by_index(&init_net, fld.flowidn_iif);
+   if (!dev) {
kfree_skb(skb);
return -ENODEV;
}
if (!dev->dn_ptr) {
-   dev_put(dev);
kfree_skb(skb);
return -ENODEV;
}
@@ -1693,8 +1693,6 @@ static int dn_cache_getroute(struct sk_buff *in_skb, 
struct nlmsghdr *nlh)
err = dn_route_output_key((struct dst_entry **)&rt, &fld, 0);
}
 
-   if (skb->dev)
-   dev_put(skb->dev);
skb->dev = NULL;
if (err)
goto out_free;
-- 
1.7.9.5

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


[PATCH net-next 06/10] vxlan: use __dev_get_by_index instead of dev_get_by_index to find interface

2014-01-13 Thread Ying Xue
The following call chains indicate that vxlan_fdb_parse() is
under rtnl_lock protection. So if we use __dev_get_by_index()
instead of dev_get_by_index() to find interface handler in it,
this would help us avoid to change interface reference counter.

rtnetlink_rcv()
  rtnl_lock()
  netlink_rcv_skb()
rtnl_fdb_add()
  vxlan_fdb_add()
vxlan_fdb_parse()
  rtnl_unlock()

rtnetlink_rcv()
  rtnl_lock()
  netlink_rcv_skb()
rtnl_fdb_del()
  vxlan_fdb_del()
vxlan_fdb_parse()
  rtnl_unlock()

Cc: Stephen Hemminger 
Signed-off-by: Ying Xue 
---
 drivers/net/vxlan.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 481f85d..8c40802 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -741,10 +741,9 @@ static int vxlan_fdb_parse(struct nlattr *tb[], struct 
vxlan_dev *vxlan,
if (nla_len(tb[NDA_IFINDEX]) != sizeof(u32))
return -EINVAL;
*ifindex = nla_get_u32(tb[NDA_IFINDEX]);
-   tdev = dev_get_by_index(net, *ifindex);
+   tdev = __dev_get_by_index(net, *ifindex);
if (!tdev)
return -EADDRNOTAVAIL;
-   dev_put(tdev);
} else {
*ifindex = 0;
}
-- 
1.7.9.5

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


[PATCH net-next 08/10] caif: __dev_get_by_index instead of dev_get_by_index to find interface

2014-01-13 Thread Ying Xue
The following call chains indicate that chnl_net_open() is under
rtnl_lock protection as __dev_open() is protected by rtnl_lock.
So if __dev_get_by_index() instead of dev_get_by_index() is used
to find interface handler in it, this would help us avoid to change
interface reference counter.

__dev_open()
  chnl_net_open()

Cc: Dmitry Tarnyagin 
Signed-off-by: Ying Xue 
---
 net/caif/chnl_net.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
index 7344a8f..4589ff67 100644
--- a/net/caif/chnl_net.c
+++ b/net/caif/chnl_net.c
@@ -285,7 +285,7 @@ static int chnl_net_open(struct net_device *dev)
goto error;
}
 
-   lldev = dev_get_by_index(dev_net(dev), llifindex);
+   lldev = __dev_get_by_index(dev_net(dev), llifindex);
 
if (lldev == NULL) {
pr_debug("no interface?\n");
@@ -307,7 +307,6 @@ static int chnl_net_open(struct net_device *dev)
mtu = min_t(int, dev->mtu, lldev->mtu - (headroom + tailroom));
mtu = min_t(int, GPRS_PDP_MTU, mtu);
dev_set_mtu(dev, mtu);
-   dev_put(lldev);
 
if (mtu < 100) {
pr_warn("CAIF Interface MTU too small (%d)\n", mtu);
-- 
1.7.9.5

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


[PATCH net-next 09/10] can: use __dev_get_by_index instead of dev_get_by_index to find interface

2014-01-13 Thread Ying Xue
As cgw_create_job() is always under rtnl_lock protection,
__dev_get_by_index() instead of dev_get_by_index() should be used to
find interface handler in it having us avoid to change interface
reference counter.

Cc: Oliver Hartkopp 
Signed-off-by: Ying Xue 
---
 net/can/gw.c |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/net/can/gw.c b/net/can/gw.c
index 88c8a39..ac31891 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -839,21 +839,21 @@ static int cgw_create_job(struct sk_buff *skb,  struct 
nlmsghdr *nlh)
if (!gwj->ccgw.src_idx || !gwj->ccgw.dst_idx)
goto out;
 
-   gwj->src.dev = dev_get_by_index(&init_net, gwj->ccgw.src_idx);
+   gwj->src.dev = __dev_get_by_index(&init_net, gwj->ccgw.src_idx);
 
if (!gwj->src.dev)
goto out;
 
if (gwj->src.dev->type != ARPHRD_CAN)
-   goto put_src_out;
+   goto out;
 
-   gwj->dst.dev = dev_get_by_index(&init_net, gwj->ccgw.dst_idx);
+   gwj->dst.dev = __dev_get_by_index(&init_net, gwj->ccgw.dst_idx);
 
if (!gwj->dst.dev)
-   goto put_src_out;
+   goto out;
 
if (gwj->dst.dev->type != ARPHRD_CAN)
-   goto put_src_dst_out;
+   goto out;
 
gwj->limit_hops = limhops;
 
@@ -862,11 +862,6 @@ static int cgw_create_job(struct sk_buff *skb,  struct 
nlmsghdr *nlh)
err = cgw_register_filter(gwj);
if (!err)
hlist_add_head_rcu(&gwj->list, &cgw_list);
-
-put_src_dst_out:
-   dev_put(gwj->dst.dev);
-put_src_out:
-   dev_put(gwj->src.dev);
 out:
if (err)
kmem_cache_free(cgw_cache, gwj);
-- 
1.7.9.5

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


[PATCH net-next 10/10] net: nl80211: __dev_get_by_index instead of dev_get_by_index to find interface

2014-01-13 Thread Ying Xue
As __cfg80211_rdev_from_attrs(), nl80211_dump_wiphy_parse() and
nl80211_set_wiphy() are all under rtnl_lock protection,
__dev_get_by_index() instead of dev_get_by_index() should be used
to find interface handler in them allowing us to avoid to change
interface reference counter.

Cc: Johannes Berg 
Signed-off-by: Ying Xue 
---
 net/wireless/nl80211.c |  100 +---
 1 file changed, 36 insertions(+), 64 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index b4f40fe..0d4d7fd 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -165,7 +165,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr 
**attrs)
 
if (attrs[NL80211_ATTR_IFINDEX]) {
int ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]);
-   netdev = dev_get_by_index(netns, ifindex);
+   netdev = __dev_get_by_index(netns, ifindex);
if (netdev) {
if (netdev->ieee80211_ptr)
tmp = wiphy_to_dev(
@@ -173,8 +173,6 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr 
**attrs)
else
tmp = NULL;
 
-   dev_put(netdev);
-
/* not wireless device -- return error */
if (!tmp)
return ERR_PTR(-EINVAL);
@@ -1656,7 +1654,7 @@ static int nl80211_dump_wiphy_parse(struct sk_buff *skb,
struct cfg80211_registered_device *rdev;
int ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]);
 
-   netdev = dev_get_by_index(sock_net(skb->sk), ifidx);
+   netdev = __dev_get_by_index(sock_net(skb->sk), ifidx);
if (!netdev)
return -ENODEV;
if (netdev->ieee80211_ptr) {
@@ -1664,7 +1662,6 @@ static int nl80211_dump_wiphy_parse(struct sk_buff *skb,
netdev->ieee80211_ptr->wiphy);
state->filter_wiphy = rdev->wiphy_idx;
}
-   dev_put(netdev);
}
 
return 0;
@@ -1987,7 +1984,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
if (info->attrs[NL80211_ATTR_IFINDEX]) {
int ifindex = nla_get_u32(info->attrs[NL80211_ATTR_IFINDEX]);
 
-   netdev = dev_get_by_index(genl_info_net(info), ifindex);
+   netdev = __dev_get_by_index(genl_info_net(info), ifindex);
if (netdev && netdev->ieee80211_ptr)
rdev = wiphy_to_dev(netdev->ieee80211_ptr->wiphy);
else
@@ -2015,32 +2012,24 @@ static int nl80211_set_wiphy(struct sk_buff *skb, 
struct genl_info *info)
rdev, nla_data(info->attrs[NL80211_ATTR_WIPHY_NAME]));
 
if (result)
-   goto bad_res;
+   return result;
 
if (info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS]) {
struct ieee80211_txq_params txq_params;
struct nlattr *tb[NL80211_TXQ_ATTR_MAX + 1];
 
-   if (!rdev->ops->set_txq_params) {
-   result = -EOPNOTSUPP;
-   goto bad_res;
-   }
+   if (!rdev->ops->set_txq_params)
+   return -EOPNOTSUPP;
 
-   if (!netdev) {
-   result = -EINVAL;
-   goto bad_res;
-   }
+   if (!netdev)
+   return -EINVAL;
 
if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
-   netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) {
-   result = -EINVAL;
-   goto bad_res;
-   }
+   netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
+   return -EINVAL;
 
-   if (!netif_running(netdev)) {
-   result = -ENETDOWN;
-   goto bad_res;
-   }
+   if (!netif_running(netdev))
+   return -ENETDOWN;
 
nla_for_each_nested(nl_txq_params,
info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
@@ -2051,12 +2040,12 @@ static int nl80211_set_wiphy(struct sk_buff *skb, 
struct genl_info *info)
  txq_params_policy);
result = parse_txq_params(tb, &txq_params);
if (result)
-   goto bad_res;
+   return result;
 
result = rdev_set_txq_params(rdev, netdev,
 &txq_params);
if (result)
-   goto bad_res;
+   return result;
}
}
 
@@ -2065,7 +2054,7 @@ static int

[PATCH net-next 02/10] bonding: use __dev_get_by_name instead of dev_get_by_name to find interface

2014-01-13 Thread Ying Xue
The following call chain indicates that bond_do_ioctl() is protected
under rtnl_lock. If we use __dev_get_by_name() instead of
dev_get_by_name() to find interface handler in it, this would
help us avoid to change reference counter of interface once.

dev_ioctl()
  rtnl_lock()
  dev_ifsioc()
bond_do_ioctl()
  rtnl_unlock()

Additionally we also change the coding style in bond_do_ioctl(),
letting it more readable for us.

Cc: Jay Vosburgh 
Cc: Veaceslav Falico 
Signed-off-by: Ying Xue 
---
 drivers/net/bonding/bond_main.c |   49 ++-
 1 file changed, 23 insertions(+), 26 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index e06c445..a69afbf 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3213,37 +3213,34 @@ static int bond_do_ioctl(struct net_device *bond_dev, 
struct ifreq *ifr, int cmd
if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
return -EPERM;
 
-   slave_dev = dev_get_by_name(net, ifr->ifr_slave);
+   slave_dev = __dev_get_by_name(net, ifr->ifr_slave);
 
pr_debug("slave_dev=%p:\n", slave_dev);
 
if (!slave_dev)
-   res = -ENODEV;
-   else {
-   pr_debug("slave_dev->name=%s:\n", slave_dev->name);
-   switch (cmd) {
-   case BOND_ENSLAVE_OLD:
-   case SIOCBONDENSLAVE:
-   res = bond_enslave(bond_dev, slave_dev);
-   break;
-   case BOND_RELEASE_OLD:
-   case SIOCBONDRELEASE:
-   res = bond_release(bond_dev, slave_dev);
-   break;
-   case BOND_SETHWADDR_OLD:
-   case SIOCBONDSETHWADDR:
-   bond_set_dev_addr(bond_dev, slave_dev);
-   res = 0;
-   break;
-   case BOND_CHANGE_ACTIVE_OLD:
-   case SIOCBONDCHANGEACTIVE:
-   res = bond_option_active_slave_set(bond, slave_dev);
-   break;
-   default:
-   res = -EOPNOTSUPP;
-   }
+   return -ENODEV;
 
-   dev_put(slave_dev);
+   pr_debug("slave_dev->name=%s:\n", slave_dev->name);
+   switch (cmd) {
+   case BOND_ENSLAVE_OLD:
+   case SIOCBONDENSLAVE:
+   res = bond_enslave(bond_dev, slave_dev);
+   break;
+   case BOND_RELEASE_OLD:
+   case SIOCBONDRELEASE:
+   res = bond_release(bond_dev, slave_dev);
+   break;
+   case BOND_SETHWADDR_OLD:
+   case SIOCBONDSETHWADDR:
+   bond_set_dev_addr(bond_dev, slave_dev);
+   res = 0;
+   break;
+   case BOND_CHANGE_ACTIVE_OLD:
+   case SIOCBONDCHANGEACTIVE:
+   res = bond_option_active_slave_set(bond, slave_dev);
+   break;
+   default:
+   res = -EOPNOTSUPP;
}
 
return res;
-- 
1.7.9.5

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


[PATCH net-next 00/10] use appropriate APIs to get interfaces

2014-01-13 Thread Ying Xue
Under rtnl_lock protection, we should use __dev_get_name/index()
rather than dev_get_name()/index() to find interface handlers
because the former interfaces can help us avoid to change interface
reference counter.

Ying Xue (10):
  Drivers: Staging: cxt1e1: use __dev_get_name instead of dev_get_name
to find interfaces
  bonding: use __dev_get_by_name instead of dev_get_by_name to find
interface
  eql: use __dev_get_by_name instead of dev_get_by_name to find
interface
  dcb: use __dev_get_by_name instead of dev_get_by_name to find
interface
  decnet: use __dev_get_by_index instead of dev_get_by_index to find
interface
  vxlan: use __dev_get_by_index instead of dev_get_by_index to find
interface
  batman-adv: use __dev_get_by_index instead of dev_get_by_index to
find interface
  caif: __dev_get_by_index instead of dev_get_by_index to find
interface
  can: use __dev_get_by_index instead of dev_get_by_index to find
interface
  net: nl80211: __dev_get_by_index instead of dev_get_by_index to find
interface

 drivers/net/bonding/bond_main.c |   49 +--
 drivers/net/eql.c   |   95 -
 drivers/net/vxlan.c |3 +-
 drivers/staging/cxt1e1/linux.c  |   15 +++---
 net/batman-adv/hard-interface.c |4 +-
 net/caif/chnl_net.c |3 +-
 net/can/gw.c|   15 ++
 net/dcb/dcbnl.c |   15 ++
 net/decnet/dn_route.c   |6 +--
 net/wireless/nl80211.c  |  100 ++-
 10 files changed, 123 insertions(+), 182 deletions(-)

-- 
1.7.9.5

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


[PATCH net-next 01/10] Drivers: Staging: cxt1e1: use __dev_get_name instead of dev_get_name to find interfaces

2014-01-13 Thread Ying Xue
The following call chain denotes that both do_reset() and do_del_chan()
are protected under rtnl_lock. If we use __dev_get_by_name() instead of
dev_get_by_name() to find interface handlers in them, this would help
us avoid to change interface reference counter.

dev_ioctl()
  rtnl_lock()
  dev_ifsioc()
c4_ioctl()
  do_reset()
  do_del_chan()

Signed-off-by: Ying Xue 
---
 drivers/staging/cxt1e1/linux.c |   15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 9b48373..4a08e16 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -770,9 +770,9 @@ do_del_chan (struct net_device *musycc_dev, void *data)
 if (cp.channum > 999)
 return -EINVAL;
 snprintf (buf, sizeof(buf), CHANNAME "%d", cp.channum);
-if (!(dev = dev_get_by_name (&init_net, buf)))
-return -ENOENT;
-dev_put (dev);
+   dev = __dev_get_by_name(&init_net, buf);
+   if (!dev)
+   return -ENODEV;
 ret = do_deluser (dev, 1);
 if (ret)
 return ret;
@@ -792,19 +792,18 @@ do_reset (struct net_device *musycc_dev, void *data)
 charbuf[sizeof (CHANNAME) + 3];
 
 sprintf (buf, CHANNAME "%d", i);
-if (!(ndev = dev_get_by_name(&init_net, buf)))
-continue;
+   ndev = __dev_get_by_name(&init_net, buf);
+   if (!ndev)
+   continue;
 priv = dev_to_hdlc (ndev)->priv;
 
 if ((unsigned long) (priv->ci) ==
 (unsigned long) (netdev_priv(musycc_dev)))
 {
 ndev->flags &= ~IFF_UP;
-dev_put (ndev);
 netif_stop_queue (ndev);
 do_deluser (ndev, 1);
-} else
-dev_put (ndev);
+   }
 }
 return 0;
 }
-- 
1.7.9.5

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


Re: [PATCH] cpuidle/menu: Fail cpuidle_idle_call() if no idle state is acceptable

2014-01-13 Thread Srivatsa S. Bhat
On 01/14/2014 12:30 PM, Srivatsa S. Bhat wrote:
> On 01/14/2014 11:35 AM, Preeti U Murthy wrote:
>> On PowerPC, in a particular test scenario, all the cpu idle states were 
>> disabled.
>> Inspite of this it was observed that the idle state count of the shallowest
>> idle state, snooze, was increasing.
>>
>> This is because the governor returns the idle state index as 0 even in
>> scenarios when no idle state can be chosen. These scenarios could be when the
>> latency requirement is 0 or as mentioned above when the user wants to disable
>> certain cpu idle states at runtime. In the latter case, its possible that no
>> cpu idle state is valid because the suitable states were disabled
>> and the rest did not match the menu governor criteria to be chosen as the
>> next idle state.
>>
>> This patch adds the code to indicate that a valid cpu idle state could not be
>> chosen by the menu governor and reports back to arch so that it can take some
>> default action.
>>
> 
> That sounds fair enough. However, the "default" action of pseries idle loop
> (pseries_lpar_idle()) surprises me. It enters Cede, which is _deeper_ than 
> doing
> a snooze! IOW, a user might "disable" cpuidle or set the 
> PM_QOS_CPU_DMA_LATENCY
> to 0 hoping to prevent the CPUs from going to deep idle states, but then the
> machine would still end up going to Cede, even though that wont get reflected
> in the idle state counts. IMHO that scenario needs some thought as well...
> 

I checked the git history and found that the default idle was changed (on 
purpose)
to cede the processor, in order to speed up booting.. Hmm..

commit 363edbe2614aa90df706c0f19ccfa2a6c06af0be
Author: Vaidyanathan Srinivasan 
Date:   Fri Sep 6 00:25:06 2013 +0530

powerpc: Default arch idle could cede processor on pseries


Regards,
Srivatsa S. Bhat

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


[RFC PATCH] audit: Use hex_byte_pack_upper

2014-01-13 Thread Joe Perches
Using the generic kernel function causes the
object size to increase with gcc 4.8.1.

$ size kernel/audit.o*
   textdata bss dec hex filename
  1857760798436   330928144 kernel/audit.o.new
  1857960158420   3301480f6 kernel/audit.o.old

Unsigned...
---
Generally, it makes sense to use generic functions
but when it increases object size?  blech.

 kernel/audit.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 2dc7573..af8ad29 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1455,7 +1455,6 @@ void audit_log_n_hex(struct audit_buffer *ab, const 
unsigned char *buf,
int i, avail, new_len;
unsigned char *ptr;
struct sk_buff *skb;
-   static const unsigned char *hex = "0123456789ABCDEF";
 
if (!ab)
return;
@@ -1473,10 +1472,8 @@ void audit_log_n_hex(struct audit_buffer *ab, const 
unsigned char *buf,
}
 
ptr = skb_tail_pointer(skb);
-   for (i=0; i>4]; /* Upper nibble */
-   *ptr++ = hex[buf[i] & 0x0F];  /* Lower nibble */
-   }
+   for (i = 0; i < len; i++)
+   ptr = hex_byte_pack_upper(ptr, buf[i]);
*ptr = 0;
skb_put(skb, len << 1); /* new string is twice the old string */
 }


--
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: Idle power fix regresses ebizzy performance (was 3.12-stable backport of NUMA balancing patches)

2014-01-13 Thread Len Brown
> This is a false alarm.

Thanks for the follow-up, Mel.

Agreed, it makes no sense for ebizzy measure 'throughput', when a
library debug bottleneck
prevents it from scaling past 3% CPU utilization.

Still, the broken configuration did find a difference due to the
addition of CLFLUSH on this box.
It makes me wonder if we will find issues on workloads that may depend
on the latency
of idle entry/exit, or perhaps sensitivity to the state of the cache
line containing thread_info->flags.

If somebody runs into such a workload, please try changing this 1 line
of intel_idle.c to limit
the CLFLUSH to C-states deeper than C1E, and let me know what you see.

- if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR))
+ if ((eax > 1) && this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR))
  clflush((void *)¤t_thread_info()->flags);

thanks,
Len Brown, Intel Open Source Technology Center
--
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] mm/zswap: Check all pool pages instead of one pool pages

2014-01-13 Thread Cai Liu
Hello, Kim

2014/1/14 Minchan Kim :
> Hello Bob,
>
> On Tue, Jan 14, 2014 at 09:19:23AM +0800, Bob Liu wrote:
>>
>> On 01/14/2014 07:35 AM, Minchan Kim wrote:
>> > Hello,
>> >
>> > On Sat, Jan 11, 2014 at 03:43:07PM +0800, Cai Liu wrote:
>> >> zswap can support multiple swapfiles. So we need to check
>> >> all zbud pool pages in zswap.
>> >
>> > True but this patch is rather costly that we should iterate
>> > zswap_tree[MAX_SWAPFILES] to check it. SIGH.
>> >
>> > How about defining zswap_tress as linked list instead of static
>> > array? Then, we could reduce unnecessary iteration too much.
>> >
>>
>> But if use linked list, it might not easy to access the tree like this:
>> struct zswap_tree *tree = zswap_trees[type];
>
> struct zswap_tree {
> ..
> ..
> struct list_head list;
> }
>
> zswap_frontswap_init()
> {
> ..
> ..
> zswap_trees[type] = tree;
> list_add(&tree->list, &zswap_list);
> }
>
> get_zswap_pool_pages(void)
> {
> struct zswap_tree *cur;
> list_for_each_entry(cur, &zswap_list, list) {
> pool_pages += zbud_get_pool_size(cur->pool);
> }
> return pool_pages;
> }
>
>
>>
>> BTW: I'm still prefer to use dynamic pool size, instead of use
>> zswap_is_full(). AFAIR, Seth has a plan to replace the rbtree with radix
>> which will be more flexible to support this feature and page migration
>> as well.
>>
>> > Other question:
>> > Why do we need to update zswap_pool_pages too frequently?
>> > As I read the code, I think it's okay to update it only when user
>> > want to see it by debugfs and zswap_is_full is called.
>> > So could we optimize it out?
>> >
>> >>
>> >> Signed-off-by: Cai Liu 
>>
>> Reviewed-by: Bob Liu 
>
> Hmm, I really suprised you are okay in this code piece where we have
> unnecessary cost most of case(ie, most system has a swap device) in
> *mm* part.
>
> Anyway, I don't want to merge this patchset.
> If Andrew merge it and anybody doesn't do right work, I will send a patch.
> Cai, Could you redo a patch?

Yes, Unnecessary iteration is not good design.
I will redo this patch.

Thanks!

> I don't want to intercept your credit.
>
> Even, we could optimize to reduce the the number of call as I said in
> previous reply.
>
> Thanks.
>
>>
>> >> ---
>> >>  mm/zswap.c |   18 +++---
>> >>  1 file changed, 15 insertions(+), 3 deletions(-)
>> >>
>> >> diff --git a/mm/zswap.c b/mm/zswap.c
>> >> index d93afa6..2438344 100644
>> >> --- a/mm/zswap.c
>> >> +++ b/mm/zswap.c
>> >> @@ -291,7 +291,6 @@ static void zswap_free_entry(struct zswap_tree *tree,
>> >>zbud_free(tree->pool, entry->handle);
>> >>zswap_entry_cache_free(entry);
>> >>atomic_dec(&zswap_stored_pages);
>> >> -  zswap_pool_pages = zbud_get_pool_size(tree->pool);
>> >>  }
>> >>
>> >>  /* caller must hold the tree lock */
>> >> @@ -405,10 +404,24 @@ cleanup:
>> >>  /*
>> >>  * helpers
>> >>  **/
>> >> +static u64 get_zswap_pool_pages(void)
>> >> +{
>> >> +  int i;
>> >> +  u64 pool_pages = 0;
>> >> +
>> >> +  for (i = 0; i < MAX_SWAPFILES; i++) {
>> >> +  if (zswap_trees[i])
>> >> +  pool_pages += zbud_get_pool_size(zswap_trees[i]->pool);
>> >> +  }
>> >> +  zswap_pool_pages = pool_pages;
>> >> +
>> >> +  return pool_pages;
>> >> +}
>> >> +
>> >>  static bool zswap_is_full(void)
>> >>  {
>> >>return (totalram_pages * zswap_max_pool_percent / 100 <
>> >> -  zswap_pool_pages);
>> >> +  get_zswap_pool_pages());
>> >>  }
>> >>
>> >>  /*
>> >> @@ -716,7 +729,6 @@ static int zswap_frontswap_store(unsigned type, 
>> >> pgoff_t offset,
>> >>
>> >>/* update stats */
>> >>atomic_inc(&zswap_stored_pages);
>> >> -  zswap_pool_pages = zbud_get_pool_size(tree->pool);
>> >>
>> >>return 0;
>> >>
>> >> --
>> >> 1.7.10.4
>> --
>> Regards,
>> -Bob
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to majord...@kvack.org.  For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: mailto:"d...@kvack.org";> em...@kvack.org 
>
> --
> Kind regards,
> Minchan Kim
--
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/5] mm: vmscan: shrink all slab objects if tight on memory

2014-01-13 Thread Vladimir Davydov
On 01/14/2014 03:05 AM, Andrew Morton wrote:
> On Sat, 11 Jan 2014 16:36:31 +0400 Vladimir Davydov  
> wrote:
>
>> When reclaiming kmem, we currently don't scan slabs that have less than
>> batch_size objects (see shrink_slab_node()):
>>
>> while (total_scan >= batch_size) {
>> shrinkctl->nr_to_scan = batch_size;
>> shrinker->scan_objects(shrinker, shrinkctl);
>> total_scan -= batch_size;
>> }
>>
>> If there are only a few shrinkers available, such a behavior won't cause
>> any problems, because the batch_size is usually small, but if we have a
>> lot of slab shrinkers, which is perfectly possible since FS shrinkers
>> are now per-superblock, we can end up with hundreds of megabytes of
>> practically unreclaimable kmem objects. For instance, mounting a
>> thousand of ext2 FS images with a hundred of files in each and iterating
>> over all the files using du(1) will result in about 200 Mb of FS caches
>> that cannot be dropped even with the aid of the vm.drop_caches sysctl!
> True.  I suspect this was an accidental consequence of the chosen
> implementation.  As you mentioned, I was thinking that the caches would
> all be large, and the remaining 1 ..  SHRINK_BATCH-1 objects just
> didn't matter.
>
>> This problem was initially pointed out by Glauber Costa [*]. Glauber
>> proposed to fix it by making the shrink_slab() always take at least one
>> pass, to put it simply, turning the scan loop above to a do{}while()
>> loop. However, this proposal was rejected, because it could result in
>> more aggressive and frequent slab shrinking even under low memory
>> pressure when total_scan is naturally very small.
> Well, it wasn't "rejected" - Mel pointed out that Glauber's change
> could potentially trigger problems which already exist in shrinkers.
>
> The potential issues seem pretty unlikely to me, and they're things we
> can fix up if they eventuate.

When preparing this patch, I considered not the problems that
potentially exist in some shrinkers, but the issues that unconditional
scan of < batch_size objects might trigger for any shrinker:

1) We would call shrinkers more frequently, which could possibly
increase contention on shrinker-internal locks. The point is that under
very light memory pressure when we can fulfill the allocation request
after a few low-prio scans, we would not call slab shrinkers at all,
instead we would only add the delta to nr_deferred in order to keep
slab-vs-pagecache reclaim balanced. Original Glauber's patch changes
this behavior - it makes shrink_slab() always call the shrinker at least
once, even if the current delta is negligible. I'm afraid, this might
affect performance. Note, this is irrespective of how much objects the
shrinker has to reclaim (< or > batch_size).

2) As Mel Gorman pointed out
(http://thread.gmane.org/gmane.linux.kernel.mm/99059):

> It's possible for caches to shrink to zero where before the last
> SHRINK_SLAB objects would often be protected for any slab. If this is
> an inode or dentry cache and there are very few objects then it's
> possible that objects will be reclaimed before they can be used by the
> process allocating them.


> So I'm thinking we should at least try Glauber's approach - it's a bit
> weird that we should treat the final 0 ..  batch_size-1 objects in a
> different manner from all the others.

It's not exactly that we treat the final 0 .. batch_size-1 objects
differently from others. We rather try to accumulate at least batch_size
objects before calling ->scan().

> That being said, I think I'll schedule this patch as-is for 3.14.  Can
> you please take a look at implementing the simpler approach, send me
> something for 3.15-rc1?

IMHO the simpler approach (Glauber's patch) is not suitable as is,
because it, in fact, neglects the notion of batch_size when doing low
prio scans, because it calls ->scan() for < batch_size objects even if
the slab has >= batch_size objects while AFAIU it should accumulate a
sufficient number of objects to scan in nr_deferred instead.

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: [PATCH] Staging: comedi: move trailing statement to next line in ni_mio_common.c

2014-01-13 Thread Dan Carpenter
On Mon, Jan 13, 2014 at 07:16:14PM -0800, Joe Perches wrote:
> On Mon, 2014-01-13 at 21:13 -0600, Chase Southwood wrote:
> > This patch for ni_mio_common.c silences a checkpatch error due to a
> > trailing statement.
> []
> > diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
> > b/drivers/staging/comedi/drivers/ni_mio_common.c
> []
> > @@ -692,7 +692,8 @@ static void ni_clear_ai_fifo(struct comedi_device *dev)
> > /*  Flush the 6143 data FIFO */
> > ni_writel(0x10, AIFIFO_Control_6143);   /*  Flush fifo */
> > ni_writel(0x00, AIFIFO_Control_6143);   /*  Flush fifo */
> > -   while (ni_readl(AIFIFO_Status_6143) & 0x10) ;   /*  Wait for 
> > complete */
> > +   while (ni_readl(AIFIFO_Status_6143) & 0x10)
> > +   ;   /*  Wait for complete */
> 
> It's generally better to use timeouts too.

Just to clarify what Joe is saying do:

/*  Wait for complete */
while (timemout < TIMEOUT) {
if (ni_readl(AIFIFO_Status_6143) & 0x10)
break;
udelay(1);
}

I added in a delay...  The problem is that you'd probably have to look
at the hardware spec to know what timeout to use or if the delay is
needed.

regards,
dan carpenter

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


[PATCHv2] driver core/platform: don't leak memory allocated for dma_mask

2014-01-13 Thread Yann Droneaud
Since commit 01dcc60a7cb8, platform_device_register_full() is
available to allocate and register a platform device.

If a dma_mask is provided as part of platform_device_info,
platform_device_register_full() allocate memory for a u64
using kmalloc().

A comment in the code state that "[t]his memory isn't freed
when the device is put".

It's never a good thing to leak memory, but there's only very
few users of platform_device_info's dma_mask, and those are mostly
"static" devices that are not going to be plugged/unplugged.

So memory leak is not really an issue, but allocating 8 bytes
through kmalloc() seems overkill, so this patch moves dma_mask
after the platform_device struct, dynamically allocated along
the name buffer.

With dma_mask part of the memory allocated for the platform_device
struct, like name buffer, it will be released with it:
no memory leak, no small allocation.

The drawback is the additional code needed to handle
dma_mask allocation:

Before (on next-20140113 with gcc-4.8):
   textdata bss dec hex filename
   5600 472  32610417d8 obj-arm/drivers/base/platform.o
   5927 532  326491195b obj-i386/drivers/base/platform.o
   7036 960  4880441f6c obj-x86_64/drivers/base/platform.o

After:
   textdata bss dec hex filename
   5668 472  326172181c obj-arm/drivers/base/platform.o
   6007 532  32657119ab obj-i386/drivers/base/platform.o
   7132 960  4881401fcc obj-x86_64/drivers/base/platform.o

Changes from v1 [1]:
- remove unneeded kfree() from error path
- add reference to author/commit adding allocation of dmamask

Changes from v0 [2]:
- small rewrite to squeeze the patch to a bare minimal

[1] 
http://lkml.kernel.org/r/1389649085-7365-1-git-send-email-ydrone...@opteya.com
https://patchwork.kernel.org/patch/3480961/

[2] 
http://lkml.kernel.org/r/1386886207-2735-1-git-send-email-ydrone...@opteya.com

Cc: Uwe Kleine-König 
Cc: Dmitry Torokhov 
Cc: Greg Kroah-Hartman 
Signed-off-by: Yann Droneaud 
---

Hi Greg,

> Why haven't you cc:ed the author of that comment?  He would be best to
> evaluate if this patch is good enough or not.
>

I must admit I was a bit lazy: I've tried ./script/get_maintainer.pl --git / 
--git-blame
but the results scare me, so I've send the patch to the maintainer only. (And 
somehow
I've thought you wrote that comment).

> And is leaking that memory really an issue?  As you point out, these
> aren't devices that are going to go away (I'd argue that no platform
> device should ever be a removable device, but that's a longer
> argument...)
>

I've seen some removable platform driver ... and, in fact, wrote some:
when writing/testing it, being able to remove the devices/driver is a must.

> Please resend and cc: all of the needed developers.
> 

Thanks for the advice.

Regards.

 drivers/base/platform.c | 83 -
 1 file changed, 62 insertions(+), 21 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 3a94b799f166..6e3e639fb886 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -157,7 +157,7 @@ EXPORT_SYMBOL_GPL(platform_add_devices);
 
 struct platform_object {
struct platform_device pdev;
-   char name[1];
+   char payload[0];
 };
 
 /**
@@ -186,6 +186,25 @@ static void platform_device_release(struct device *dev)
kfree(pa);
 }
 
+static struct platform_object *platform_object_alloc(size_t payload)
+{
+   struct platform_object *pa;
+
+   pa = kzalloc(sizeof(*pa) + payload, GFP_KERNEL);
+
+   return pa;
+}
+
+static void platform_object_init(struct platform_object *pa,
+const char *name, int id)
+{
+   pa->pdev.name = name;
+   pa->pdev.id = id;
+   device_initialize(&pa->pdev.dev);
+   pa->pdev.dev.release = platform_device_release;
+   arch_setup_pdev_archdata(&pa->pdev);
+}
+
 /**
  * platform_device_alloc - create a platform device
  * @name: base name of the device we're adding
@@ -198,14 +217,10 @@ struct platform_device *platform_device_alloc(const char 
*name, int id)
 {
struct platform_object *pa;
 
-   pa = kzalloc(sizeof(struct platform_object) + strlen(name), GFP_KERNEL);
+   pa = platform_object_alloc(strlen(name) + 1);
if (pa) {
-   strcpy(pa->name, name);
-   pa->pdev.name = pa->name;
-   pa->pdev.id = id;
-   device_initialize(&pa->pdev.dev);
-   pa->pdev.dev.release = platform_device_release;
-   arch_setup_pdev_archdata(&pa->pdev);
+   strcpy(pa->payload, name);
+   platform_object_init(pa, pa->payload, id);
}
 

Re: [PATCH 1/7] zram: fix race between reset and flushing pending work

2014-01-13 Thread Sergey Senozhatsky
On (01/13/14 15:55), Andrew Morton wrote:
[..]
> >
> > --- a/drivers/block/zram/zram_drv.c
> > +++ b/drivers/block/zram/zram_drv.c
> > @@ -553,14 +553,14 @@ static void zram_reset_device(struct zram *zram, bool 
> > reset_capacity)
> > size_t index;
> > struct zram_meta *meta;
> >  
> > -   flush_work(&zram->free_work);
> > -
> > down_write(&zram->init_lock);
> > if (!zram->init_done) {
> > up_write(&zram->init_lock);
> > return;
> > }
> >  
> > +   flush_work(&zram->free_work);
> > +
> > meta = zram->meta;
> > zram->init_done = 0;
> 
> This makes zram.lock nest inside zram.init_lock, which afaict is new
> behaviour.
> 
> That all seems OK and logical - has it been well tested with lockdep?
> 

Patches 1-7
Tested-by: Sergey Senozhatsky 

-ss
--
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: comedi: remove unnecessary braces in pcl711.c

2014-01-13 Thread Dan Carpenter
On Mon, Jan 13, 2014 at 09:13:16PM -0600, Chase Southwood wrote:
> This patch for pcl711.c removes braces causing a checkpatch.pl warning.
> It also removes an empty else arm of an if-else statement.
> 
> Signed-off-by: Chase Southwood 
> ---
> 
> I removed the "else" arm of this statement because it was empty, save
> for the "ignore" comment.  If it is instead preferred kernel style for
> this empty else to remain in, let me know and I will correct this
> patch accordingly.
> 

Nope, it's perfect.  Don't doubt yourself.  Always feel free to change
the code.

regards,
dan carpenter

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


[PATCH] PM: Enable asynchronous noirq resume threads to save the resuming time

2014-01-13 Thread Chuansheng Liu

Currently, the dpm_resume_noirq() is done synchronously, and for PCI devices
pci_pm_resume_noirq():

pci_pm_resume_noirq()
 pci_pm_default_resume_early()
  pci_power_up()
   pci_raw_set_power_state()
Which set the device from D3hot to D0 mostly, for every device, there will
be one 10ms(pci_pm_d3_delay) to wait.

Hence normally dpm_resume_noirq() will cost > 100ms, which is bigger for mobile
platform.

Here implementing it with asynchronous way which will reduce much.

For example below, The 80% time is saved.
With synchronous way:
[ 1411.272218] PM: noirq resume of devices complete after 92.223 msecs
With asynchronous way:
[  110.616735] PM: noirq resume of devices complete after 10.544 msecs

Signed-off-by: Liu, Chuansheng 
---
 drivers/base/power/main.c |   42 +-
 1 file changed, 33 insertions(+), 9 deletions(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 1b41fca..1b9d774 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -505,6 +505,19 @@ static int device_resume_noirq(struct device *dev, 
pm_message_t state)
return error;
 }
 
+static bool is_async(struct device *dev);
+
+static void async_resume_noirq(void *data, async_cookie_t cookie)
+{
+   struct device *dev = (struct device *)data;
+   int error;
+
+   error = device_resume_noirq(dev, pm_transition);
+   if (error)
+   pm_dev_err(dev, pm_transition, " noirq", error);
+   put_device(dev);
+}
+
 /**
  * dpm_resume_noirq - Execute "noirq resume" callbacks for all devices.
  * @state: PM transition of the system being carried out.
@@ -514,29 +527,40 @@ static int device_resume_noirq(struct device *dev, 
pm_message_t state)
  */
 static void dpm_resume_noirq(pm_message_t state)
 {
+   struct device *dev;
ktime_t starttime = ktime_get();
+   pm_transition = state;
+
+   list_for_each_entry(dev, &dpm_noirq_list, power.entry) {
+   if (is_async(dev)) {
+   get_device(dev);
+   async_schedule(async_resume_noirq, dev);
+   }
+   }
 
mutex_lock(&dpm_list_mtx);
while (!list_empty(&dpm_noirq_list)) {
-   struct device *dev = to_device(dpm_noirq_list.next);
-   int error;
+   dev = to_device(dpm_noirq_list.next);
 
get_device(dev);
list_move_tail(&dev->power.entry, &dpm_late_early_list);
mutex_unlock(&dpm_list_mtx);
 
-   error = device_resume_noirq(dev, state);
-   if (error) {
-   suspend_stats.failed_resume_noirq++;
-   dpm_save_failed_step(SUSPEND_RESUME_NOIRQ);
-   dpm_save_failed_dev(dev_name(dev));
-   pm_dev_err(dev, state, " noirq", error);
+   if (!is_async(dev)) {
+   int error;
+   error = device_resume_noirq(dev, state);
+   if (error) {
+   suspend_stats.failed_resume_noirq++;
+   dpm_save_failed_step(SUSPEND_RESUME_NOIRQ);
+   dpm_save_failed_dev(dev_name(dev));
+   pm_dev_err(dev, state, " noirq", error);
+   }
}
-
mutex_lock(&dpm_list_mtx);
put_device(dev);
}
mutex_unlock(&dpm_list_mtx);
+   async_synchronize_full();
dpm_show_time(starttime, state, "noirq");
resume_device_irqs();
cpuidle_resume();
-- 
1.7.9.5



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


Re: [PATCH 6/7] zram: remove workqueue for freeing removed pending slot

2014-01-13 Thread Sergey Senozhatsky
Hello Minchan,

On (01/14/14 08:38), Minchan Kim wrote:
> Hello Sergey,
> 
> On Mon, Jan 13, 2014 at 10:42:56PM +0300, Sergey Senozhatsky wrote:
> > On (01/13/14 20:19), Minchan Kim wrote:
> > 
> > Hello Minchan,
> > I think we need to down_write init_lock in zram_slot_free_notify(),
> > and thus can avoid locking meta->tb_lock. otherwise, I think,
> 
> zram_slot_free_notify is atomic path so we couldn't hold mutex.
> 
> > there is a chance that zram_slot_free_notify() can race with
> > device reset, e.g.
> > 
> > zram_slot_free_notify() zram_reset_device()
> > down_write(&zram->init_lock);
> > meta = zram->meta
> > zram_meta_free(zram->meta);
> > zram->meta = NULL;
> > write_lock(&meta->tb_lock);
> > [...]
> > write_unlock(&meta->tb_lock);
> > [..]
> > up_write(&zram->init_lock);
> > 
> 
> Nope. We couldn't reset active device by bdev->bd_holders check
> logic in reset_store.
> 

true. sorry for the noise.

-ss
--
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] mm/zswap: Check all pool pages instead of one pool pages

2014-01-13 Thread Cai Liu
2014/1/14 Bob Liu :
>
> On 01/14/2014 01:05 PM, Minchan Kim wrote:
>> On Tue, Jan 14, 2014 at 01:50:22PM +0900, Minchan Kim wrote:
>>> Hello Bob,
>>>
>>> On Tue, Jan 14, 2014 at 09:19:23AM +0800, Bob Liu wrote:

 On 01/14/2014 07:35 AM, Minchan Kim wrote:
> Hello,
>
> On Sat, Jan 11, 2014 at 03:43:07PM +0800, Cai Liu wrote:
>> zswap can support multiple swapfiles. So we need to check
>> all zbud pool pages in zswap.
>
> True but this patch is rather costly that we should iterate
> zswap_tree[MAX_SWAPFILES] to check it. SIGH.
>
> How about defining zswap_tress as linked list instead of static
> array? Then, we could reduce unnecessary iteration too much.
>

 But if use linked list, it might not easy to access the tree like this:
 struct zswap_tree *tree = zswap_trees[type];
>>>
>>> struct zswap_tree {
>>> ..
>>> ..
>>> struct list_head list;
>>> }
>>>
>>> zswap_frontswap_init()
>>> {
>>> ..
>>> ..
>>> zswap_trees[type] = tree;
>>> list_add(&tree->list, &zswap_list);
>>> }
>>>
>>> get_zswap_pool_pages(void)
>>> {
>>> struct zswap_tree *cur;
>>> list_for_each_entry(cur, &zswap_list, list) {
>>> pool_pages += zbud_get_pool_size(cur->pool);
>>> }
>>> return pool_pages;
>>> }
>
> Okay, I see your point. Yes, it's much better.
> Cai, Please make an new patch.
>

Thanks for your review.
I will re-send a patch.

Also, as weijie metioned in anonther mail. Should we add "all pool
pages" count in zbud
file. Then we can keep zswap module unchanged. I think this is
reasonable, as in
zswap we only just need to know total pages, not individual pool pages.

Thanks

> Thanks,
> -Bob
>
>>>
>>>

 BTW: I'm still prefer to use dynamic pool size, instead of use
 zswap_is_full(). AFAIR, Seth has a plan to replace the rbtree with radix
 which will be more flexible to support this feature and page migration
 as well.

> Other question:
> Why do we need to update zswap_pool_pages too frequently?
> As I read the code, I think it's okay to update it only when user
> want to see it by debugfs and zswap_is_full is called.
> So could we optimize it out?
>
>>
>> Signed-off-by: Cai Liu 

 Reviewed-by: Bob Liu 
>>>
>>> Hmm, I really suprised you are okay in this code piece where we have
>>> unnecessary cost most of case(ie, most system has a swap device) in
>>> *mm* part.
>>>
>>> Anyway, I don't want to merge this patchset.
>>> If Andrew merge it and anybody doesn't do right work, I will send a patch.
>>> Cai, Could you redo a patch?
>>> I don't want to intercept your credit.
>>>
>>> Even, we could optimize to reduce the the number of call as I said in
>>> previous reply.
>>
>> You did it already. Please write it out in description.
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] BCM2835: Add I2S driver to device tree

2014-01-13 Thread Florian Meier
On 14.01.2014 03:57, Stephen Warren wrote:
> On 01/13/2014 04:16 AM, Florian Meier wrote:
>> This adds the definitions for the BCM2835 I2S driver
>> to the device tree. Some GPIO settings are needed for
>> the correct pin functions.
>
> Patch 1/1 and the .dtsi portion of patch 2/2 look fine; I can apply
> those after 3.14's merge window closes.
>
> However, I don't think I can apply the change to bcm2835-rpi-b.dts in
> this patch; those pins are used for the board ID strapping on rev 1
> boards,

Yes, but I thought the board ID is never utilized. However, I have not
tested that.

> and even on rev 2 boards, they're simply routed to a generic
> header, rather than being dedicated for I2S usage. That part of the
> patch would be better kept locally in your own kernel tree. Perhaps if
> DT overlays ever take off, we can publish it as part of an I2S-specific
> overlay.

You are right. That might be a problem. Someone might want to use the
pins for another functionality. I personally think the I2S
functionality will be the most used functionality for those pins, but
I accept it when you say that they better should be set as second I2C
channel and generic GPIO pins (as it is by default).

However, for an end user it doesn't seem to be a convenient solution
to have a kernel tree for each possible combination of pin
assignments.
The "old way" would be to set the pin functionality while loading the
i2s driver, but I assume that is not the right way to go, right?
--
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] [RFC] timekeeping: Rework frequency adjustments to work better w/ nohz

2014-01-13 Thread Richard Cochran
On Mon, Jan 13, 2014 at 10:15:18AM -0800, John Stultz wrote:
> That's great to hear! Thanks so much, I really appreciate the testing!
> And this is with HZ=?

HZ=1000
 
> If you do get a chance to look again, I'd also be interested if running
> with nohz=off w/ the fix doesn't show any regression compared to the
> unmodified nohz=off case.

Okay, will do.
 
Thanks,
Richard
--
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] cpuidle/menu: Fail cpuidle_idle_call() if no idle state is acceptable

2014-01-13 Thread Srivatsa S. Bhat
On 01/14/2014 11:35 AM, Preeti U Murthy wrote:
> On PowerPC, in a particular test scenario, all the cpu idle states were 
> disabled.
> Inspite of this it was observed that the idle state count of the shallowest
> idle state, snooze, was increasing.
> 
> This is because the governor returns the idle state index as 0 even in
> scenarios when no idle state can be chosen. These scenarios could be when the
> latency requirement is 0 or as mentioned above when the user wants to disable
> certain cpu idle states at runtime. In the latter case, its possible that no
> cpu idle state is valid because the suitable states were disabled
> and the rest did not match the menu governor criteria to be chosen as the
> next idle state.
> 
> This patch adds the code to indicate that a valid cpu idle state could not be
> chosen by the menu governor and reports back to arch so that it can take some
> default action.
> 

That sounds fair enough. However, the "default" action of pseries idle loop
(pseries_lpar_idle()) surprises me. It enters Cede, which is _deeper_ than doing
a snooze! IOW, a user might "disable" cpuidle or set the PM_QOS_CPU_DMA_LATENCY
to 0 hoping to prevent the CPUs from going to deep idle states, but then the
machine would still end up going to Cede, even though that wont get reflected
in the idle state counts. IMHO that scenario needs some thought as well...

> Signed-off-by: Preeti U Murthy 
> ---
> 
>  drivers/cpuidle/cpuidle.c|6 +-
>  drivers/cpuidle/governors/menu.c |7 ---
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index a55e68f..5bf06bb 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -131,8 +131,9 @@ int cpuidle_idle_call(void)
> 
>   /* ask the governor for the next state */
>   next_state = cpuidle_curr_governor->select(drv, dev);
> +
> + dev->last_residency = 0;
>   if (need_resched()) {
> - dev->last_residency = 0;
>   /* give the governor an opportunity to reflect on the outcome */
>   if (cpuidle_curr_governor->reflect)
>   cpuidle_curr_governor->reflect(dev, next_state);

The comments on top of the .reflect() routines of the governors say that the
second parameter is the index of the actual state entered. But after this patch,
next_state can be negative, indicating an invalid index. So those comments need
to be updated accordingly.

> @@ -140,6 +141,9 @@ int cpuidle_idle_call(void)
>   return 0;
>   }
> 
> + if (next_state < 0)
> + return -EINVAL;

The exit path above (due to need_resched) returns with irqs enabled, but the new
one you are adding (next_state < 0) returns with irqs disabled. This is correct,
because in the latter case, "idle" is still in progress and the arch will choose
a default handler to execute (unlike the former case where "idle" is over and
hence its time to enable interrupts).

IMHO it would be good to add comments around this code to explain this subtle
difference. We can never be too careful with these things... ;-)

> +
>   trace_cpu_idle_rcuidle(next_state, dev->cpu);
> 
>   broadcast = !!(drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP);
> diff --git a/drivers/cpuidle/governors/menu.c 
> b/drivers/cpuidle/governors/menu.c
> index cf7f2f0..6921543 100644
> --- a/drivers/cpuidle/governors/menu.c
> +++ b/drivers/cpuidle/governors/menu.c
> @@ -283,6 +283,7 @@ again:
>   * menu_select - selects the next idle state to enter
>   * @drv: cpuidle driver containing state data
>   * @dev: the CPU
> + * Returns -1 when no idle state is suitable
>   */
>  static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device 
> *dev)
>  {
> @@ -292,17 +293,17 @@ static int menu_select(struct cpuidle_driver *drv, 
> struct cpuidle_device *dev)
>   int multiplier;
>   struct timespec t;
> 
> - if (data->needs_update) {
> + if (data->last_state_idx >= 0 && data->needs_update) {
   ^
Doesn't hurt, but actually unnecessary, since ->needs_update is set to 1
only when index >= 0.

>   menu_update(drv, dev);
>   data->needs_update = 0;
>   }
> 
> - data->last_state_idx = 0;
> + data->last_state_idx = -1;
>   data->exit_us = 0;
> 
>   /* Special case when user has set very strict latency requirement */
>   if (unlikely(latency_req == 0))
> - return 0;
> + return data->last_state_idx;
> 
>   /* determine the expected residency time, round up */
>   t = ktime_to_timespec(tick_nohz_get_sleep_length());
> 

What about the ladder governor? I know its not used that much in practice,
but I think it would be good to update that as well, just to keep it
consistent.

Regards,
Srivatsa S. Bhat

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordo

Re: [alsa-devel] [RFC][PATCH] ASoC: simple-card: Add asoc_simple_card_data for the simple card driver data

2014-01-13 Thread Kuninori Morimoto

Hi Xiubo

Thank you for your patch

> Whether the dt is used or not, almost all the simple card information
> for the DAI link and sound card are initialized in the simple card driver.
> 
> And for the platform caller, the snd_link and snd_card are of no use, so
> move them from struct asoc_simple_card_info to struct asoc_simple_card_data.
> 
> And now only one DAI link is supported for simple card.
> 
> Suggested-by: Jean-Francois Moine 
> Signed-off-by: Xiubo Li 
> ---

This patch seems have many this kind of lines
  - info->xxx
  + sdata->info->xxx

But, how about add this line to each function ?

 struct asoc_simple_card_info *info = &sdata->info;

Patch will be more readable

Best regards
---
Kuninori Morimoto
--
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 0/4] misc: xgene: Add support for APM X-Gene SoC Queue Manager/Traffic Manager

2014-01-13 Thread Arnd Bergmann
On Monday 13 January 2014, Ravi Patel wrote:
> > For inbound messages, the QMTM serves a similar purpose as an MSI
> > controller, ensuring that inbound DMA data has arrived in RAM
> > before an interrupt is delivered to the CPU and thereby avoiding
> > the need for an expensive MMIO read to serialize the DMA.
> 
> For inbound messages, slave device generates message on a completion
> of a inbound DMA operation or any relevant operation targeted to the
> CPU. The QMTM's role is to just trigger an interrupt to CPU when there
> is a new message arrived from a slave device. QMTM doesn't know what
> the message was for. It is upto the upper layer drivers to decide how
> to process this message.

That doesn't seem to contradict what I wrote above. The DMA ordering
would be an implicit side-effect of the message generated by the
slave device if the QMTM is on the same bus as the external memory
controller and the message has the "strict ordering" bit set on the
bus transaction.

Arnd
--
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/5] mm: vmscan: respect NUMA policy mask when shrinking slab on direct reclaim

2014-01-13 Thread Vladimir Davydov
On 01/14/2014 03:11 AM, Andrew Morton wrote:
> On Sat, 11 Jan 2014 16:36:33 +0400 Vladimir Davydov  
> wrote:
>
>> When direct reclaim is executed by a process bound to a set of NUMA
>> nodes, we should scan only those nodes when possible, but currently we
>> will scan kmem from all online nodes even if the kmem shrinker is NUMA
>> aware. That said, binding a process to a particular NUMA node won't
>> prevent it from shrinking inode/dentry caches from other nodes, which is
>> not good. Fix this.
> Seems right.  I worry that reducing the amount of shrinking which
> node-bound processes perform might affect workloads in unexpected ways.

Theoretically, it might, especially for NUMA unaware shrinkers. But
that's how it works for cpusets right now - we do not count pages from
nodes that are not allowed for the current process. Besides, when
counting lru pages for kswapd_shrink_zones(), we also consider only the
node this kswapd runs on so that NUMA unaware shrinkers will be scanned
more aggressively on NUMA enabled setups than NUMA aware ones. So, in
fact, this patch makes policy masks handling consistent with the rest of
the vmscan code.

> I think I'll save this one for 3.15-rc1, OK?

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


[PATCH net-next] tun/macvtap: limit the packets queued through rcvbuf

2014-01-13 Thread Jason Wang
We used to limit the number of packets queued through tx_queue_length. This
has several issues:

- tx_queue_length is the control of qdisc queue length, simply reusing it
  to control the packets queued by device may cause confusion.
- After commit 6acf54f1cf0a6747bac9fea26f34cfc5a9029523 ("macvtap: Add
  support of packet capture on macvtap device."), an unexpected qdisc
  caused by non-zero tx_queue_length will lead qdisc lock contention for
  multiqueue deivce.
- What we really want is to limit the total amount of memory occupied not
  the number of packets.

So this patch tries to solve the above issues by using socket rcvbuf to
limit the packets could be queued for tun/macvtap. This was done by using
sock_queue_rcv_skb() instead of a direct call to skb_queue_tail(). Also two
new ioctl() were introduced for userspace to change the rcvbuf like what we
have done for sndbuf.

With this fix, we can safely change the tx_queue_len of macvtap to
zero. This will make multiqueue works without extra lock contention.

Cc: Vlad Yasevich 
Cc: Michael S. Tsirkin 
Cc: John Fastabend 
Cc: Stephen Hemminger 
Cc: Herbert Xu 
Signed-off-by: Jason Wang 
---
 drivers/net/macvtap.c   | 31 -
 drivers/net/tun.c   | 48 +
 include/uapi/linux/if_tun.h |  3 +++
 3 files changed, 60 insertions(+), 22 deletions(-)

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index a2c3a89..c429c56 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -292,9 +292,6 @@ static rx_handler_result_t macvtap_handle_frame(struct 
sk_buff **pskb)
if (!q)
return RX_HANDLER_PASS;
 
-   if (skb_queue_len(&q->sk.sk_receive_queue) >= dev->tx_queue_len)
-   goto drop;
-
skb_push(skb, ETH_HLEN);
 
/* Apply the forward feature mask so that we perform segmentation
@@ -310,8 +307,10 @@ static rx_handler_result_t macvtap_handle_frame(struct 
sk_buff **pskb)
goto drop;
 
if (!segs) {
-   skb_queue_tail(&q->sk.sk_receive_queue, skb);
-   goto wake_up;
+   if (sock_queue_rcv_skb(&q->sk, skb))
+   goto drop;
+   else
+   goto wake_up;
}
 
kfree_skb(skb);
@@ -319,11 +318,17 @@ static rx_handler_result_t macvtap_handle_frame(struct 
sk_buff **pskb)
struct sk_buff *nskb = segs->next;
 
segs->next = NULL;
-   skb_queue_tail(&q->sk.sk_receive_queue, segs);
+   if (sock_queue_rcv_skb(&q->sk, segs)) {
+   skb = segs;
+   skb->next = nskb;
+   goto drop;
+   }
+
segs = nskb;
}
} else {
-   skb_queue_tail(&q->sk.sk_receive_queue, skb);
+   if (sock_queue_rcv_skb(&q->sk, skb))
+   goto drop;
}
 
 wake_up:
@@ -333,7 +338,7 @@ wake_up:
 drop:
/* Count errors/drops only here, thus don't care about args. */
macvlan_count_rx(vlan, 0, 0, 0);
-   kfree_skb(skb);
+   kfree_skb_list(skb);
return RX_HANDLER_CONSUMED;
 }
 
@@ -414,7 +419,7 @@ static void macvtap_dellink(struct net_device *dev,
 static void macvtap_setup(struct net_device *dev)
 {
macvlan_common_setup(dev);
-   dev->tx_queue_len = TUN_READQ_SIZE;
+   dev->tx_queue_len = 0;
 }
 
 static struct rtnl_link_ops macvtap_link_ops __read_mostly = {
@@ -469,6 +474,7 @@ static int macvtap_open(struct inode *inode, struct file 
*file)
sock_init_data(&q->sock, &q->sk);
q->sk.sk_write_space = macvtap_sock_write_space;
q->sk.sk_destruct = macvtap_sock_destruct;
+   q->sk.sk_rcvbuf = TUN_RCVBUF;
q->flags = IFF_VNET_HDR | IFF_NO_PI | IFF_TAP;
q->vnet_hdr_sz = sizeof(struct virtio_net_hdr);
 
@@ -1040,6 +1046,13 @@ static long macvtap_ioctl(struct file *file, unsigned 
int cmd,
q->sk.sk_sndbuf = u;
return 0;
 
+   case TUNSETRCVBUF:
+   if (get_user(u, up))
+   return -EFAULT;
+
+   q->sk.sk_rcvbuf = u;
+   return 0;
+
case TUNGETVNETHDRSZ:
s = q->vnet_hdr_sz;
if (put_user(s, sp))
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 09f6662..7a08fa3 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -177,6 +177,7 @@ struct tun_struct {
 
int vnet_hdr_sz;
int sndbuf;
+   int rcvbuf;
struct tap_filter   txflt;
struct sock_fprog   fprog;
/* protected by rtnl lock */
@@ -771,17 +772,6 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, 
struct net_d

Re: [PATCH 4/5] mm: vmscan: move call to shrink_slab() to shrink_zones()

2014-01-13 Thread Vladimir Davydov
On 01/14/2014 03:13 AM, Andrew Morton wrote:
> On Sat, 11 Jan 2014 16:36:34 +0400 Vladimir Davydov  
> wrote:
>
>> This reduces the indentation level of do_try_to_free_pages() and removes
>> extra loop over all eligible zones counting the number of on-LRU pages.
> So this should cause no functional change, yes?

Yes. This patch merely moves a piece of code from one function to another.

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: [PATCH v4 4/5] arm: Add [U]EFI runtime services support

2014-01-13 Thread Arnd Bergmann
On Monday 13 January 2014, Leif Lindholm wrote:
> On Mon, Jan 13, 2014 at 07:43:09PM +0100, Arnd Bergmann wrote:
> > > This patch implements basic support for UEFI runtime services in the
> > > ARM architecture - a requirement for using efibootmgr to read and update
> > > the system boot configuration.
> > > 
> > > It uses the generic configuration table scanning to populate ACPI and
> > > SMBIOS pointers.
> > 
> > As far as I'm concerned there are no plans to have ACPI support on ARM32,
> > so I wonder what the code to populate the ACPI tables is about. Can
> > you clarify this?
> 
> Are you suggesting that I should #ifndef ARM in common code, or that I
> should neglect to document what the common code will do with data it is
> given by UEFI?

It would probably be good to document the fact that it won't work,
possibly even having a BUG_ON statement in the code for this case.

> > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > > index 78a79a6a..1ab24cc 100644
> > > --- a/arch/arm/Kconfig
> > > +++ b/arch/arm/Kconfig
> > > @@ -1853,6 +1853,20 @@ config EARLY_IOREMAP
> > > the same virtual memory range as kmap so all early mappings must
> > > be unapped before paging_init() is called.
> > >  
> > > +config EFI
> > > + bool "UEFI runtime service support"
> > > + depends on OF && !CPU_BIG_ENDIAN
> > 
> > What is the dependency on !CPU_BIG_ENDIAN?
> 
> Mainly on code not being implemented to byte-reverse UCS strings.

Why would you byte-reverse /strings/? They normally just come in
order of the characters, and UTF-16 strings are already defined
as being big-endian or marked by the BOM character.

> > We try hard to have
> > all kernel code support both big-endian and little-endian, and
> > I'm guessing there is a significant overlap between the people
> > that want UEFI support and those that want big-endian kernels.
> 
> Not really. There might be some. Also, it is not necessarily the case
> that those people want to run the big-endian kernel at EL2.
> 
> If a need is seen, this support can be added at a later date.

Ok.

> > > +struct efi_memory_map memmap;
> > 
> > "memmap" is not a good name for a global identifier, particularly because
> > it's easily confused with the well-known "mem_map" array. This
> > wants namespace prefix like you other variable, or a "static" tag,
> > preferably both.
> 
> It is defined by include/linux/efi.h.

This seems to be a mistake: there is no user of this variable outside
of arch/x86/platform/efi/efi.c and arch/x86/platform/efi/efi_64.c.
I think it should just be moved into an x86 specific header file,
or preferably be renamed in the process. There is also efi->memmap,
which seems to be the same pointer.

Note that a number of drivers have local memmap variables.

Arnd
--
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] net/mlx4_core: clean up cq_res_start_move_to()

2014-01-13 Thread Jack Morgenstein
This time, replying to the list as well.

-Jack
P.S. sorry for the delay, I was swamped.

On Tue, 07 Jan 2014 14:01:18 +0100
Paul Bolle  wrote:

> + } else {
> + /* state == RES_CQ_HW */
> + if (r->com.state != RES_CQ_ALLOCATED)

if (state != RES_CQ_HW || r->com.state != RES_CQ_ALLOCATED)
to protect against any bad calls to this function
(although I know that currently there are none).

This also preserves the behavior of the switch statement.

>   err = -EINVAL;
> - }
> + else
> + err = 0;
> + }
>  
> - if (!err) {
> - r->com.from_state = r->com.state;
> - r->com.to_state = state;
> - r->com.state = RES_CQ_BUSY;
> - if (cq)
> - *cq = r;
> - }
> + if (!err) {
> + r->com.from_state = r->com.state;
> + r->com.to_state = state;
> + r->com.state = RES_CQ_BUSY;

Please keep the "if" here.  Protects against (future) bad calls.

> + *cq = r;
>   }

--
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 0/3] Deferrable timers support for timerfd API

2014-01-13 Thread Alexey Perevalov

On 01/13/2014 09:36 PM, Andi Kleen wrote:

Alexey Perevalov  writes:


Hello all,

one remark - timerfd is not documented in linux Documentation
directory at all.
I think it's better to have such description.

The documentation is the manpage in man-pages.

Ideally you change would come with the changed manpage
too.

-Andi


Hello Andi,
 thank you,

I found ./man2/timerfd_create.2 from 
http://git.kernel.org/pub/scm/docs/man-pages/man-pages is outdated.

TFD_TIMER_CANCEL_ON_SET isn't described, just mention "since linux 3.0"
Clockids CLOCK_REALTIME_ALARM, CLOCK_BOOTTIME_ALARM isn't mentioned at all.

I'm not technical writer, but I'll try to describe _ALARM clockids and 
flags introduced by Anton's patchset.



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


[RFC][PATCH] ASoC: simple-card: Add asoc_simple_card_data for the simple card driver data

2014-01-13 Thread Xiubo Li
Whether the dt is used or not, almost all the simple card information
for the DAI link and sound card are initialized in the simple card driver.

And for the platform caller, the snd_link and snd_card are of no use, so
move them from struct asoc_simple_card_info to struct asoc_simple_card_data.

And now only one DAI link is supported for simple card.

Suggested-by: Jean-Francois Moine 
Signed-off-by: Xiubo Li 
---
 include/sound/simple_card.h |   4 --
 sound/soc/generic/simple-card.c | 115 +---
 2 files changed, 60 insertions(+), 59 deletions(-)

diff --git a/include/sound/simple_card.h b/include/sound/simple_card.h
index 6c74527..e1ac996 100644
--- a/include/sound/simple_card.h
+++ b/include/sound/simple_card.h
@@ -29,10 +29,6 @@ struct asoc_simple_card_info {
unsigned int daifmt;
struct asoc_simple_dai cpu_dai;
struct asoc_simple_dai codec_dai;
-
-   /* used in simple-card.c */
-   struct snd_soc_dai_link snd_link;
-   struct snd_soc_card snd_card;
 };
 
 #endif /* __SIMPLE_CARD_H */
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 2a1b1b5..eab8f92 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -15,6 +15,12 @@
 #include 
 #include 
 
+struct asoc_simple_card_data {
+   struct asoc_simple_card_info info;
+   struct snd_soc_dai_link snd_link;
+   struct snd_soc_card snd_card;
+};
+
 static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
   struct asoc_simple_dai *set,
   unsigned int daifmt)
@@ -39,18 +45,18 @@ static int __asoc_simple_card_dai_init(struct snd_soc_dai 
*dai,
 
 static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 {
-   struct asoc_simple_card_info *info =
+   struct asoc_simple_card_data *sdata =
snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *codec = rtd->codec_dai;
struct snd_soc_dai *cpu = rtd->cpu_dai;
-   unsigned int daifmt = info->daifmt;
+   unsigned int daifmt = sdata->info.daifmt;
int ret;
 
-   ret = __asoc_simple_card_dai_init(codec, &info->codec_dai, daifmt);
+   ret = __asoc_simple_card_dai_init(codec, &sdata->info.codec_dai, 
daifmt);
if (ret < 0)
return ret;
 
-   ret = __asoc_simple_card_dai_init(cpu, &info->cpu_dai, daifmt);
+   ret = __asoc_simple_card_dai_init(cpu, &sdata->info.cpu_dai, daifmt);
if (ret < 0)
return ret;
 
@@ -118,23 +124,23 @@ parse_error:
 }
 
 static int asoc_simple_card_parse_of(struct device_node *node,
-struct asoc_simple_card_info *info,
-struct device *dev,
+struct asoc_simple_card_data *sdata,
 struct device_node **of_cpu,
 struct device_node **of_codec,
 struct device_node **of_platform)
 {
+   struct device *dev = sdata->snd_card.dev;
struct device_node *np;
char *name;
int ret;
 
/* get CPU/CODEC common format via simple-audio-card,format */
-   info->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") &
-   (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK);
+   sdata->info.daifmt = snd_soc_of_parse_daifmt(node,
+   "simple-audio-card,") & SND_SOC_DAIFMT_FORMAT_MASK;
 
/* DAPM routes */
if (of_property_read_bool(node, "simple-audio-card,routing")) {
-   ret = snd_soc_of_parse_audio_routing(&info->snd_card,
+   ret = snd_soc_of_parse_audio_routing(&sdata->snd_card,
"simple-audio-card,routing");
if (ret)
return ret;
@@ -145,7 +151,7 @@ static int asoc_simple_card_parse_of(struct device_node 
*node,
np = of_get_child_by_name(node, "simple-audio-card,cpu");
if (np)
ret = asoc_simple_card_sub_parse_of(np,
- &info->cpu_dai,
+ &sdata->info.cpu_dai,
  of_cpu);
if (ret < 0)
return ret;
@@ -155,60 +161,60 @@ static int asoc_simple_card_parse_of(struct device_node 
*node,
np = of_get_child_by_name(node, "simple-audio-card,codec");
if (np)
ret = asoc_simple_card_sub_parse_of(np,
- &info->codec_dai,
+ &sdata->info.codec_dai,
  of_codec);
if (ret < 0)
return ret;
 
-   if (!info->cpu_dai.name || !info->codec_dai.name)
+   if (!sdata->info.

Re: [PATCH 2/2] net/mlx4_core: clean up srq_res_start_move_to()

2014-01-13 Thread Jack Morgenstein
On Tue, 07 Jan 2014 14:02:14 +0100
Paul Bolle  wrote:

> diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
> b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index
> a41f01e..8ace450 100644 ---
> a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++
> b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c @@ -1372,7
> +1372,7 @@ static int cq_res_start_move_to(struct mlx4_dev *dev, int
> slave, int cqn, } 
>  static int srq_res_start_move_to(struct mlx4_dev *dev, int slave,
> int index,
> -  enum res_cq_states state, struct res_srq **srq)
> +  enum res_srq_states state, struct res_srq 
> **srq) {

ACK


> + /* state == RES_SRQ_HW */
> + if (r->com.state != RES_SRQ_ALLOCATED)

if (state != RES_SRQ_HW || r->com.state != RES_SRQ_ALLOCATED)

>   err = -EINVAL;
> - }
> + }
>  
> - if (!err) {
> - r->com.from_state = r->com.state;
> - r->com.to_state = state;
> - r->com.state = RES_SRQ_BUSY;
> - if (srq)
> - *srq = r;
> - }
> + if (!err) {
> + r->com.from_state = r->com.state;
> + r->com.to_state = state;
> + r->com.state = RES_SRQ_BUSY;
please leave in the if (srq). Not currently needed, but if this
changes in the future, we will get an Oops.
> + *srq = r;
>   }
>  
>   spin_unlock_irq(mlx4_tlock(dev));

--
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] cpuidle/menu: Fail cpuidle_idle_call() if no idle state is acceptable

2014-01-13 Thread Deepthi Dharwar
On 01/14/2014 11:35 AM, Preeti U Murthy wrote:
> On PowerPC, in a particular test scenario, all the cpu idle states were 
> disabled.
> Inspite of this it was observed that the idle state count of the shallowest
> idle state, snooze, was increasing.
> 
> This is because the governor returns the idle state index as 0 even in
> scenarios when no idle state can be chosen. These scenarios could be when the
> latency requirement is 0 or as mentioned above when the user wants to disable
> certain cpu idle states at runtime. In the latter case, its possible that no
> cpu idle state is valid because the suitable states were disabled
> and the rest did not match the menu governor criteria to be chosen as the
> next idle state.
> 
> This patch adds the code to indicate that a valid cpu idle state could not be
> chosen by the menu governor and reports back to arch so that it can take some
> default action.
> 
> Signed-off-by: Preeti U Murthy 
> ---

Acked-by: Deepthi Dharwar 

> 
>  drivers/cpuidle/cpuidle.c|6 +-
>  drivers/cpuidle/governors/menu.c |7 ---
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index a55e68f..5bf06bb 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -131,8 +131,9 @@ int cpuidle_idle_call(void)
> 
>   /* ask the governor for the next state */
>   next_state = cpuidle_curr_governor->select(drv, dev);
> +
> + dev->last_residency = 0;
>   if (need_resched()) {
> - dev->last_residency = 0;
>   /* give the governor an opportunity to reflect on the outcome */
>   if (cpuidle_curr_governor->reflect)
>   cpuidle_curr_governor->reflect(dev, next_state);
> @@ -140,6 +141,9 @@ int cpuidle_idle_call(void)
>   return 0;
>   }
> 
> + if (next_state < 0)
> + return -EINVAL;
> +
>   trace_cpu_idle_rcuidle(next_state, dev->cpu);
> 
>   broadcast = !!(drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP);
> diff --git a/drivers/cpuidle/governors/menu.c 
> b/drivers/cpuidle/governors/menu.c
> index cf7f2f0..6921543 100644
> --- a/drivers/cpuidle/governors/menu.c
> +++ b/drivers/cpuidle/governors/menu.c
> @@ -283,6 +283,7 @@ again:
>   * menu_select - selects the next idle state to enter
>   * @drv: cpuidle driver containing state data
>   * @dev: the CPU
> + * Returns -1 when no idle state is suitable
>   */
>  static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device 
> *dev)
>  {
> @@ -292,17 +293,17 @@ static int menu_select(struct cpuidle_driver *drv, 
> struct cpuidle_device *dev)
>   int multiplier;
>   struct timespec t;
> 
> - if (data->needs_update) {
> + if (data->last_state_idx >= 0 && data->needs_update) {
>   menu_update(drv, dev);
>   data->needs_update = 0;
>   }
> 
> - data->last_state_idx = 0;
> + data->last_state_idx = -1;
>   data->exit_us = 0;
> 
>   /* Special case when user has set very strict latency requirement */
>   if (unlikely(latency_req == 0))
> - return 0;
> + return data->last_state_idx;
> 
>   /* determine the expected residency time, round up */
>   t = ktime_to_timespec(tick_nohz_get_sleep_length());
> 

--
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/8 v3] crypto:s5p-sss: Add support for SSS module on Exynos

2014-01-13 Thread Naveen Krishna Ch
Hell Vladimir, Tomasz,

On 14 January 2014 02:36, Vladimir Zapolskiy  wrote:
> Hi Naveen and Tomasz,
>
>
> On 01/10/14 17:44, Tomasz Figa wrote:
>>
>> Hi Naveen,
>>
>> Please see my comments inline.
>>
>> On 10.01.2014 12:42, Naveen Krishna Chatradhi wrote:
>>>
>>> This patch adds new compatible and variant struct to support the SSS
>>> module on Exynos4 (Exynos4210), Exynos5 (Exynos5420 and Exynos5250)
>>> for which
>>> 1. AES register are at an offset of 0x200 and
>>> 2. hash interrupt is not available
>>>
>>> Signed-off-by: Naveen Krishna Ch 
>>> CC: Herbert Xu 
>>> CC: David S. Miller 
>>> CC: Vladimir Zapolskiy 
>>> TO: 
>>> CC: 
>>> ---
>>> Changes since v2:
>>> 1. Added variant struct to handle the differences in SSS modules
>>> 2. Changed the compatible strings to exynos4210-secss
>>> 3. Other changes suggested by Tomasz
>>>
>>> .../devicetree/bindings/crypto/samsung-sss.txt | 20 
>>> drivers/crypto/s5p-sss.c | 110 +++-
>>> 2 files changed, 106 insertions(+), 24 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/crypto/samsung-sss.txt
>>> b/Documentation/devicetree/bindings/crypto/samsung-sss.txt
>>> index 2f9d7e4..fdc7d8b 100644
>>> --- a/Documentation/devicetree/bindings/crypto/samsung-sss.txt
>>> +++ b/Documentation/devicetree/bindings/crypto/samsung-sss.txt
>>> @@ -8,13 +8,33 @@ The SSS module in S5PV210 SoC supports the following:
>>> -- SHA-1/SHA-256/MD5/HMAC (SHA-1/SHA-256/MD5)/PRNG
>>> -- PRNG: Pseudo Random Number Generator
>>>
>>> +The SSS module in Exynos4 (Exynos4210) and
>>> +Exynos5 (Exynos5420 and Exynos5250) SoCs
>>> +supports the following also:
>>> +-- ARCFOUR (ARC4)
>>> +-- True Random Number Generator (TRNG)
>>> +-- Secure Key Manager
>>> +
>>> Required properties:
>>>
>>> - compatible : Should contain entries for this and backward compatible
>>> SSS versions:
>>> - "samsung,s5pv210-secss" for S5PV210 SoC.
>>> + - "samsung,exynos4210-secss" for Exynos4210, Exynos5250 and
>>> Exynos5420 SoCs.
>>
>>
>> You can also add Exynos4212/4412 to the list.
>>
>>> - reg : Offset and length of the register set for the module
>>> - interrupts : the interrupt-specifier for the SSS module.
>>> Two interrupts "feed control and hash" in case of S5PV210
>>> + One interrupts "feed control" in case of Exynos4210,
>>> + Exynos5250 and Exynos5420 SoCs.
>>
>>
>> You can refer to compatible string here instead of listing all the SoCs.
>>
>>> - clocks : the required gating clock for the SSS module.
>>> - clock-names : the gating clock name to be requested in the SSS driver.
>>
>>
>> Again, please specify name of the clock in property description. The
>> proper description for both clock properties should be:
>>
>> - clock-names : list of device clock input names; should contain one
>> entry - "secss".
>> - clocks : list of clock phandle and specifier pairs for all clocks
>> listed in clock-names property.
>>
>>> +
>>> +Example:
>>> + /* SSS_VER_5 */
>>> + sss@1083 {
>>> + compatible = "samsung,exynos4210-secss";
>>> + reg = <0x1083 0x1>;
>>> + interrupts = <0 112 0>;
>>> + clocks = <&clock 471>;
>>> + clock-names = "secss";
>>> + };
>>> diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
>>> index 2da5617..f274f5f 100644
>>> --- a/drivers/crypto/s5p-sss.c
>>> +++ b/drivers/crypto/s5p-sss.c
>>> @@ -106,7 +106,7 @@
>>> #define SSS_REG_FCPKDMAO 0x005C
>>>
>>> /* AES registers */
>>> -#define SSS_REG_AES_CONTROL 0x4000
>>> +#define SSS_REG_AES_CONTROL 0x00
>>> #define SSS_AES_BYTESWAP_DI _BIT(11)
>>> #define SSS_AES_BYTESWAP_DO _BIT(10)
>>> #define SSS_AES_BYTESWAP_IV _BIT(9)
>>> @@ -122,21 +122,26 @@
>>> #define SSS_AES_CHAIN_MODE_CTR _SBF(1, 0x02)
>>> #define SSS_AES_MODE_DECRYPT _BIT(0)
>>>
>>> -#define SSS_REG_AES_STATUS 0x4004
>>> +#define SSS_REG_AES_STATUS 0x04
>>> #define SSS_AES_BUSY _BIT(2)
>>> #define SSS_AES_INPUT_READY _BIT(1)
>>> #define SSS_AES_OUTPUT_READY _BIT(0)
>>>
>>> -#define SSS_REG_AES_IN_DATA(s) (0x4010 + (s << 2))
>>> -#define SSS_REG_AES_OUT_DATA(s) (0x4020 + (s << 2))
>>> -#define SSS_REG_AES_IV_DATA(s) (0x4030 + (s << 2))
>>> -#define SSS_REG_AES_CNT_DATA(s) (0x4040 + (s << 2))
>>> -#define SSS_REG_AES_KEY_DATA(s) (0x4080 + (s << 2))
>>> +#define SSS_REG_AES_IN_DATA(off, s) ((off + 0x10) + (s << 2))
>>> +#define SSS_REG_AES_OUT_DATA(off, s) ((off + 0x20) + (s << 2))
>>> +#define SSS_REG_AES_IV_DATA(off, s) ((off + 0x30) + (s << 2))
>>> +#define SSS_REG_AES_CNT_DATA(off, s) ((off + 0x40) + (s << 2))
>>> +#define SSS_REG_AES_KEY_DATA(off, s) ((off + 0x80) + (s << 2))
>>
>>
>> I still somehow don't like this. Such macros are only hiding operations
>> performed by the driver. See my comment below, in the code that
>> references them, to see my proposal.
>>
>>>
>>> #define SSS_REG(dev, reg) ((dev)->ioaddr + (SSS_REG_##reg))
>>> #define SSS_READ(dev, reg) __raw_readl(SSS_REG(dev, reg))
>>> #define SSS_WRITE(dev, reg, val) __raw_writel((val), SSS_REG(dev, reg))
>>>
>>> +#define SSS_AES_REG(dev, reg) ((dev)->ioaddr + SSS_REG_##

Re: [PATCH] mm/zswap: Check all pool pages instead of one pool pages

2014-01-13 Thread Weijie Yang
On Tue, Jan 14, 2014 at 1:42 PM, Bob Liu  wrote:
>
> On 01/14/2014 01:05 PM, Minchan Kim wrote:
>> On Tue, Jan 14, 2014 at 01:50:22PM +0900, Minchan Kim wrote:
>>> Hello Bob,
>>>
>>> On Tue, Jan 14, 2014 at 09:19:23AM +0800, Bob Liu wrote:

 On 01/14/2014 07:35 AM, Minchan Kim wrote:
> Hello,
>
> On Sat, Jan 11, 2014 at 03:43:07PM +0800, Cai Liu wrote:
>> zswap can support multiple swapfiles. So we need to check
>> all zbud pool pages in zswap.
>
> True but this patch is rather costly that we should iterate
> zswap_tree[MAX_SWAPFILES] to check it. SIGH.
>
> How about defining zswap_tress as linked list instead of static
> array? Then, we could reduce unnecessary iteration too much.
>

 But if use linked list, it might not easy to access the tree like this:
 struct zswap_tree *tree = zswap_trees[type];
>>>
>>> struct zswap_tree {
>>> ..
>>> ..
>>> struct list_head list;
>>> }
>>>
>>> zswap_frontswap_init()
>>> {
>>> ..
>>> ..
>>> zswap_trees[type] = tree;
>>> list_add(&tree->list, &zswap_list);
>>> }
>>>
>>> get_zswap_pool_pages(void)
>>> {
>>> struct zswap_tree *cur;
>>> list_for_each_entry(cur, &zswap_list, list) {
>>> pool_pages += zbud_get_pool_size(cur->pool);
>>> }
>>> return pool_pages;
>>> }
>
> Okay, I see your point. Yes, it's much better.
> Cai, Please make an new patch.

This improved patch could reduce unnecessary iteration too much.

But I still have a question: why do we need so many zbud pools?
How about use only one global zbud pool for all zswap_tree?
I do not test it, but I think it can improve the strore density.

Just for your reference, Thanks!

> Thanks,
> -Bob
>
>>>
>>>

 BTW: I'm still prefer to use dynamic pool size, instead of use
 zswap_is_full(). AFAIR, Seth has a plan to replace the rbtree with radix
 which will be more flexible to support this feature and page migration
 as well.

> Other question:
> Why do we need to update zswap_pool_pages too frequently?
> As I read the code, I think it's okay to update it only when user
> want to see it by debugfs and zswap_is_full is called.
> So could we optimize it out?
>
>>
>> Signed-off-by: Cai Liu 

 Reviewed-by: Bob Liu 
>>>
>>> Hmm, I really suprised you are okay in this code piece where we have
>>> unnecessary cost most of case(ie, most system has a swap device) in
>>> *mm* part.
>>>
>>> Anyway, I don't want to merge this patchset.
>>> If Andrew merge it and anybody doesn't do right work, I will send a patch.
>>> Cai, Could you redo a patch?
>>> I don't want to intercept your credit.
>>>
>>> Even, we could optimize to reduce the the number of call as I said in
>>> previous reply.
>>
>> You did it already. Please write it out in description.
>>
> --
> 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: linux-next: manual merge of the tip tree with the net-next tree

2014-01-13 Thread Stephen Rothwell
Hi Dave,

On Mon, 13 Jan 2014 21:48:41 -0800 (PST) David Miller  
wrote:
>
> Net patch applied, thanks Stephen.

Thanks.

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


pgpLeAmu5C984.pgp
Description: PGP signature


[PATCH] cpuidle/menu: Fail cpuidle_idle_call() if no idle state is acceptable

2014-01-13 Thread Preeti U Murthy
On PowerPC, in a particular test scenario, all the cpu idle states were 
disabled.
Inspite of this it was observed that the idle state count of the shallowest
idle state, snooze, was increasing.

This is because the governor returns the idle state index as 0 even in
scenarios when no idle state can be chosen. These scenarios could be when the
latency requirement is 0 or as mentioned above when the user wants to disable
certain cpu idle states at runtime. In the latter case, its possible that no
cpu idle state is valid because the suitable states were disabled
and the rest did not match the menu governor criteria to be chosen as the
next idle state.

This patch adds the code to indicate that a valid cpu idle state could not be
chosen by the menu governor and reports back to arch so that it can take some
default action.

Signed-off-by: Preeti U Murthy 
---

 drivers/cpuidle/cpuidle.c|6 +-
 drivers/cpuidle/governors/menu.c |7 ---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index a55e68f..5bf06bb 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -131,8 +131,9 @@ int cpuidle_idle_call(void)
 
/* ask the governor for the next state */
next_state = cpuidle_curr_governor->select(drv, dev);
+
+   dev->last_residency = 0;
if (need_resched()) {
-   dev->last_residency = 0;
/* give the governor an opportunity to reflect on the outcome */
if (cpuidle_curr_governor->reflect)
cpuidle_curr_governor->reflect(dev, next_state);
@@ -140,6 +141,9 @@ int cpuidle_idle_call(void)
return 0;
}
 
+   if (next_state < 0)
+   return -EINVAL;
+
trace_cpu_idle_rcuidle(next_state, dev->cpu);
 
broadcast = !!(drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP);
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index cf7f2f0..6921543 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -283,6 +283,7 @@ again:
  * menu_select - selects the next idle state to enter
  * @drv: cpuidle driver containing state data
  * @dev: the CPU
+ * Returns -1 when no idle state is suitable
  */
 static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 {
@@ -292,17 +293,17 @@ static int menu_select(struct cpuidle_driver *drv, struct 
cpuidle_device *dev)
int multiplier;
struct timespec t;
 
-   if (data->needs_update) {
+   if (data->last_state_idx >= 0 && data->needs_update) {
menu_update(drv, dev);
data->needs_update = 0;
}
 
-   data->last_state_idx = 0;
+   data->last_state_idx = -1;
data->exit_us = 0;
 
/* Special case when user has set very strict latency requirement */
if (unlikely(latency_req == 0))
-   return 0;
+   return data->last_state_idx;
 
/* determine the expected residency time, round up */
t = ktime_to_timespec(tick_nohz_get_sleep_length());

--
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 1/6] Documentation: add dts binding for X-Gene reboot dts node.

2014-01-13 Thread Arnd Bergmann
On Tuesday 14 January 2014, Feng Kan wrote:
> 
> >
> > Is this related to the standard ARM SCU that manages multiprocessor
> > systems, or a different unit that uses the same name?
> 
> FKAN: You mean the snoop control unit in ARM. This is different from
> that, the main function of this unit is clk control.

Hmm, if it's *mainly* used for clocks, you may actually just want to
have a driver in drivers/clk for it that also performs a few of the
other things on the side.

Arnd
--
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 2/4] net_dma: revert 'copied_early'

2014-01-13 Thread Dan Williams
On Mon, Jan 13, 2014 at 9:16 PM, David Miller  wrote:
> From: Dan Williams 
> Date: Mon, 13 Jan 2014 16:47:14 -0800
>
>> Now that tcp_dma_try_early_copy() is gone nothing ever sets
>> copied_early.
>>
>> Also reverts "53240c208776 tcp: Fix possible double-ack w/ user dma"
>> since it is no longer necessary.
>>
>> Cc: Ali Saidi 
>> Cc: James Morris 
>> Cc: Patrick McHardy 
>> Cc: Eric Dumazet 
>> Cc: David S. Miller 
>> Cc: Alexey Kuznetsov 
>> Cc: Hideaki YOSHIFUJI 
>> Cc: Neal Cardwell 
>> Reported-by: Dave Jones 
>> Signed-off-by: Dan Williams 
>
> Acked-by: David S. Miller 

Thank you sir.
--
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] arch: Re-sort some Kbuild files to hopefully help avoid some conflicts

2014-01-13 Thread tip-bot for Stephen Rothwell
Commit-ID:  f549ed1abc7e4f0292ce08c4143c64a610c8b2cb
Gitweb: http://git.kernel.org/tip/f549ed1abc7e4f0292ce08c4143c64a610c8b2cb
Author: Stephen Rothwell 
AuthorDate: Tue, 14 Jan 2014 16:36:10 +1100
Committer:  H. Peter Anvin 
CommitDate: Mon, 13 Jan 2014 21:56:54 -0800

arch: Re-sort some Kbuild files to hopefully help avoid some conflicts

Checkin:

93ea02bb8435 arch: Clean up asm/barrier.h implementations using 
asm-generic/barrier.h

... unfortunately left some Kbuild files out of order, which caused
unnecessary merge conflicts, in particular with checkin:

e3fec2f74f7f lib: Add missing arch generic-y entries for asm-generic/hash.h

Put them back in order to make the upcoming merges cleaner.

Signed-off-by: Stephen Rothwell 
Link: 
http://lkml.kernel.org/r/20140114164420.d296fbcc4be3a5f126c86...@canb.auug.org.au
Signed-off-by: H. Peter Anvin 
Cc: Geert Uytterhoeven 
Cc: "Paul E. McKenney" 
Cc: Mathieu Desnoyers 
Cc: Peter Zijlstra 
Cc: David Miller 
---
 arch/arc/include/asm/Kbuild| 2 +-
 arch/cris/include/asm/Kbuild   | 2 +-
 arch/hexagon/include/asm/Kbuild| 2 +-
 arch/microblaze/include/asm/Kbuild | 2 +-
 arch/mn10300/include/asm/Kbuild| 2 +-
 arch/parisc/include/asm/Kbuild | 2 +-
 arch/score/include/asm/Kbuild  | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index e07c786..9ae21c1 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -1,4 +1,5 @@
 generic-y += auxvec.h
+generic-y += barrier.h
 generic-y += bugs.h
 generic-y += bitsperlong.h
 generic-y += clkdev.h
@@ -47,4 +48,3 @@ generic-y += user.h
 generic-y += vga.h
 generic-y += xor.h
 generic-y += preempt.h
-generic-y += barrier.h
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild
index 35ec2e5..199b1a9 100644
--- a/arch/cris/include/asm/Kbuild
+++ b/arch/cris/include/asm/Kbuild
@@ -3,6 +3,7 @@ header-y += arch-v10/
 header-y += arch-v32/
 
 
+generic-y += barrier.h
 generic-y += clkdev.h
 generic-y += exec.h
 generic-y += kvm_para.h
@@ -12,4 +13,3 @@ generic-y += trace_clock.h
 generic-y += vga.h
 generic-y += xor.h
 generic-y += preempt.h
-generic-y += barrier.h
diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild
index a614ec9..ada843c 100644
--- a/arch/hexagon/include/asm/Kbuild
+++ b/arch/hexagon/include/asm/Kbuild
@@ -2,6 +2,7 @@
 header-y += ucontext.h
 
 generic-y += auxvec.h
+generic-y += barrier.h
 generic-y += bug.h
 generic-y += bugs.h
 generic-y += clkdev.h
@@ -54,4 +55,3 @@ generic-y += ucontext.h
 generic-y += unaligned.h
 generic-y += xor.h
 generic-y += preempt.h
-generic-y += barrier.h
diff --git a/arch/microblaze/include/asm/Kbuild 
b/arch/microblaze/include/asm/Kbuild
index f77fb66..a824265 100644
--- a/arch/microblaze/include/asm/Kbuild
+++ b/arch/microblaze/include/asm/Kbuild
@@ -1,7 +1,7 @@
 
+generic-y += barrier.h
 generic-y += clkdev.h
 generic-y += exec.h
 generic-y += trace_clock.h
 generic-y += syscalls.h
 generic-y += preempt.h
-generic-y += barrier.h
diff --git a/arch/mn10300/include/asm/Kbuild b/arch/mn10300/include/asm/Kbuild
index 367ef39..032143e 100644
--- a/arch/mn10300/include/asm/Kbuild
+++ b/arch/mn10300/include/asm/Kbuild
@@ -1,6 +1,6 @@
 
+generic-y += barrier.h
 generic-y += clkdev.h
 generic-y += exec.h
 generic-y += trace_clock.h
 generic-y += preempt.h
-generic-y += barrier.h
diff --git a/arch/parisc/include/asm/Kbuild b/arch/parisc/include/asm/Kbuild
index 8df06d0..34b0be4 100644
--- a/arch/parisc/include/asm/Kbuild
+++ b/arch/parisc/include/asm/Kbuild
@@ -1,8 +1,8 @@
 
+generic-y += barrier.h
 generic-y += word-at-a-time.h auxvec.h user.h cputime.h emergency-restart.h \
  segment.h topology.h vga.h device.h percpu.h hw_irq.h mutex.h \
  div64.h irq_regs.h kdebug.h kvm_para.h local64.h local.h param.h \
  poll.h xor.h clkdev.h exec.h
 generic-y += trace_clock.h
 generic-y += preempt.h
-generic-y += barrier.h
diff --git a/arch/score/include/asm/Kbuild b/arch/score/include/asm/Kbuild
index ee2993b..fe7471e 100644
--- a/arch/score/include/asm/Kbuild
+++ b/arch/score/include/asm/Kbuild
@@ -1,8 +1,8 @@
 
 header-y +=
 
+generic-y += barrier.h
 generic-y += clkdev.h
 generic-y += trace_clock.h
 generic-y += xor.h
 generic-y += preempt.h
-generic-y += barrier.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/


linux-next: Tree for Jan 14

2014-01-13 Thread Stephen Rothwell
Hi all,

This tree fails (more than usual) the powerpc allyesconfig build.

Changes since 20140113:

Dropped tree: sh (complex merge conflicts against very old commits)

The powerpc tree still had its build failure.

The v4l-dvb tree gained a conflict against Linus' tree.

The tip tree gained a build failure for which I reverted a commit from
the pm tree.

The kvm tree still had its build failure so I used the version from
next-20140109.

The akpm-current tree gained conflicts against the char-misc and tip trees.

Non-merge commits (relative to Linus' tree): 8567
 7924 files changed, 409038 insertions(+), 213932 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" as mentioned in the FAQ on the wiki
(see below).

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log files
in the Next directory.  Between each merge, the tree was built with
a ppc64_defconfig for powerpc and an allmodconfig for x86_64 and a
multi_v7_defconfig for arm. After the final fixups (if any), it is also
built with powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig and
allyesconfig (minus CONFIG_PROFILE_ALL_BRANCHES - this fails its final
link) and i386, sparc, sparc64 and arm defconfig. These builds also have
CONFIG_ENABLE_WARN_DEPRECATED, CONFIG_ENABLE_MUST_CHECK and
CONFIG_DEBUG_INFO disabled when necessary.

Below is a summary of the state of the merge.

I am currently merging 209 trees (counting Linus' and 29 trees of patches
pending for Linus' tree).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

There is a wiki covering stuff to do with linux-next at
http://linux.f-seidel.de/linux-next/pmwiki/ .  Thanks to Frank Seidel.

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

$ git checkout master
$ git reset --hard stable
Merging origin/master (a6da83f98267 Merge branch 'merge' of 
git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc)
Merging fixes/master (b0031f227e47 Merge tag 's2mps11-build' of 
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator)
Merging kbuild-current/rc-fixes (19514fc665ff arm, kbuild: make "make install" 
not depend on vmlinux)
Merging arc-current/for-curr (1e01c7eb7c43 ARC: Allow conditional multiple 
inclusion of uapi/asm/unistd.h)
Merging arm-current/fixes (b25f3e1c3584 ARM: 7938/1: OMAP4/highbank: Flush L2 
cache before disabling)
Merging m68k-current/for-linus (77a42796786c m68k: Remove deprecated 
IRQF_DISABLED)
Merging metag-fixes/fixes (3b2f64d00c46 Linux 3.11-rc2)
Merging powerpc-merge/merge (10348f597683 powerpc: Check return value of 
instance-to-package OF call)
Merging sparc/master (ef350bb7c5e0 Merge tag 'ext4_for_linus_stable' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4)
Merging net/master (9ef9730ba84d cxgb4: silence shift wrapping static checker 
warning)
Merging ipsec/master (965cdea82569 dccp: catch failed request_module call in 
dccp_probe init)
Merging sound-current/for-linus (150116bcfbd9 ALSA: hiface: Fix typo in 352800 
rate definition)
Merging pci-current/for-linus (f0b75693cbb2 MAINTAINERS: Add DesignWare, i.MX6, 
Armada, R-Car PCI host maintainers)
Merging wireless/master (2eff7c791a18 Merge tag 'nfc-fixes-3.13-1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/sameo/nfc-fixes)
Merging driver-core.current/driver-core-linus (413541dd66d5 Linux 3.13-rc5)
Merging tty.current/tty-linus (413541dd66d5 Linux 3.13-rc5)
Merging usb.current/usb-linus (413541dd66d5 Linux 3.13-rc5)
Merging staging.current/staging-linus (413541dd66d5 Linux 3.13-rc5)
Merging char-misc.current/char-misc-linus (802eee95bde7 Linux 3.13-rc6)
Merging input-current/for-linus (8e2f2325b73f Input: xpad - add new USB IDs for 
Logitech F310 and F710)
Merging md-current/for-linus (d47648fcf061 raid5: avoid finding "discard" 
stripe)
Merging crypto-current/master (efb753b8e013 crypto: ixp4xx - Fix kernel compile 
error)
Merging ide/master (c2f7d1e103ef ide: pmac: remove unnecessary 
pci_set_drvdata())
Merging dwmw2/master (5950f0803ca9 pcmcia: remove RPX board stuff)
Merging sh-current/sh-fixes-for-linus (44033109e99c SH: Convert out

Re: linux-next: manual merge of the tip tree with the net-next tree

2014-01-13 Thread David Miller
From: Stephen Rothwell 
Date: Tue, 14 Jan 2014 16:44:20 +1100

> On Mon, 13 Jan 2014 21:19:46 -0800 (PST) David Miller  
> wrote:
>>
>> From: "H. Peter Anvin" 
>> Date: Mon, 13 Jan 2014 20:51:43 -0800
>> 
>> > Is there a sensible way we can fix this in either net-next or tip?
>> 
>> I think if I sort the files in net-next the problem will go away,
>> if someone can confirm this I'll do it.
> 
> I have attached 2 patches: one for net-next and one for tip/auto-latest
> (but should be applicable in the appropriate topic branch).  If both are
> applied to their respect trees, then I get no conflict when merging the
> two trees.

Net patch applied, thanks Stephen.
--
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: linux-next: manual merge of the tip tree with the net-next tree

2014-01-13 Thread Stephen Rothwell
On Mon, 13 Jan 2014 21:19:46 -0800 (PST) David Miller  
wrote:
>
> From: "H. Peter Anvin" 
> Date: Mon, 13 Jan 2014 20:51:43 -0800
> 
> > Is there a sensible way we can fix this in either net-next or tip?
> 
> I think if I sort the files in net-next the problem will go away,
> if someone can confirm this I'll do it.

I have attached 2 patches: one for net-next and one for tip/auto-latest
(but should be applicable in the appropriate topic branch).  If both are
applied to their respect trees, then I get no conflict when merging the
two trees.

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au
>From da6b3ed2f43d1a0c5e946d11902c167eb6188cca Mon Sep 17 00:00:00 2001
From: Stephen Rothwell 
Date: Tue, 14 Jan 2014 16:37:45 +1100
Subject: [PATCH] net: resort some Kbuild files to hopefully help avoid some
 conflicts

Signed-off-by: Stephen Rothwell 
---
 arch/arc/include/asm/Kbuild| 2 +-
 arch/cris/include/asm/Kbuild   | 2 +-
 arch/hexagon/include/asm/Kbuild| 2 +-
 arch/microblaze/include/asm/Kbuild | 2 +-
 arch/mn10300/include/asm/Kbuild| 2 +-
 arch/score/include/asm/Kbuild  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index 93e6ca919620..cf29d84fd9c2 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -11,6 +11,7 @@ generic-y += fcntl.h
 generic-y += fb.h
 generic-y += ftrace.h
 generic-y += hardirq.h
+generic-y += hash.h
 generic-y += hw_irq.h
 generic-y += ioctl.h
 generic-y += ioctls.h
@@ -47,4 +48,3 @@ generic-y += user.h
 generic-y += vga.h
 generic-y += xor.h
 generic-y += preempt.h
-generic-y += hash.h
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild
index c5963b3e4624..406cbd3ebd58 100644
--- a/arch/cris/include/asm/Kbuild
+++ b/arch/cris/include/asm/Kbuild
@@ -5,6 +5,7 @@ header-y += arch-v32/
 
 generic-y += clkdev.h
 generic-y += exec.h
+generic-y += hash.h
 generic-y += kvm_para.h
 generic-y += linkage.h
 generic-y += module.h
@@ -12,4 +13,3 @@ generic-y += trace_clock.h
 generic-y += vga.h
 generic-y += xor.h
 generic-y += preempt.h
-generic-y += hash.h
diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild
index 469d223950ff..ae45d75a3187 100644
--- a/arch/hexagon/include/asm/Kbuild
+++ b/arch/hexagon/include/asm/Kbuild
@@ -15,6 +15,7 @@ generic-y += fb.h
 generic-y += fcntl.h
 generic-y += ftrace.h
 generic-y += hardirq.h
+generic-y += hash.h
 generic-y += hw_irq.h
 generic-y += ioctl.h
 generic-y += ioctls.h
@@ -54,4 +55,3 @@ generic-y += ucontext.h
 generic-y += unaligned.h
 generic-y += xor.h
 generic-y += preempt.h
-generic-y += hash.h
diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild
index 43eec338ff50..ca60945ddf30 100644
--- a/arch/microblaze/include/asm/Kbuild
+++ b/arch/microblaze/include/asm/Kbuild
@@ -1,7 +1,7 @@
 
 generic-y += clkdev.h
 generic-y += exec.h
+generic-y += hash.h
 generic-y += trace_clock.h
 generic-y += syscalls.h
 generic-y += preempt.h
-generic-y += hash.h
diff --git a/arch/mn10300/include/asm/Kbuild b/arch/mn10300/include/asm/Kbuild
index bc42f14c9c2e..199345207d82 100644
--- a/arch/mn10300/include/asm/Kbuild
+++ b/arch/mn10300/include/asm/Kbuild
@@ -1,6 +1,6 @@
 
 generic-y += clkdev.h
 generic-y += exec.h
+generic-y += hash.h
 generic-y += trace_clock.h
 generic-y += preempt.h
-generic-y += hash.h
diff --git a/arch/score/include/asm/Kbuild b/arch/score/include/asm/Kbuild
index 099e7ba40599..1d35e33ccf86 100644
--- a/arch/score/include/asm/Kbuild
+++ b/arch/score/include/asm/Kbuild
@@ -2,8 +2,8 @@
 header-y +=
 
 generic-y += clkdev.h
+generic-y += hash.h
 generic-y += trace_clock.h
 generic-y += xor.h
 generic-y += preempt.h
-generic-y += hash.h
 
-- 
1.8.5.2

>From 6d0a3746f35cb879189228093728251b7ce04135 Mon Sep 17 00:00:00 2001
From: Stephen Rothwell 
Date: Tue, 14 Jan 2014 16:36:10 +1100
Subject: [PATCH] tip: resort some Kbuild files to hopefully help avoid some
 conflicts

Signed-off-by: Stephen Rothwell 
---
 arch/arc/include/asm/Kbuild| 2 +-
 arch/cris/include/asm/Kbuild   | 2 +-
 arch/hexagon/include/asm/Kbuild| 2 +-
 arch/microblaze/include/asm/Kbuild | 2 +-
 arch/mn10300/include/asm/Kbuild| 2 +-
 arch/parisc/include/asm/Kbuild | 2 +-
 arch/score/include/asm/Kbuild  | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index e07c786011af..9ae21c198007 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -1,4 +1,5 @@
 generic-y += auxvec.h
+generic-y += barrier.h
 generic-y += bugs.h
 generic-y += bitsperlong.h
 generic-y += clkdev.h
@@ -47,4 +48,3 @@ generic-y += user.h
 generic-y += vga.h
 generic-y += xor.h
 generic-y += preempt.h
-generic-y += barrier.h
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild
index 35ec2e5ca832..199b1a9dab89 100644
--- a/arch/cris/include/asm/Kbui

Re: [PATCH] mm/zswap: Check all pool pages instead of one pool pages

2014-01-13 Thread Bob Liu

On 01/14/2014 01:05 PM, Minchan Kim wrote:
> On Tue, Jan 14, 2014 at 01:50:22PM +0900, Minchan Kim wrote:
>> Hello Bob,
>>
>> On Tue, Jan 14, 2014 at 09:19:23AM +0800, Bob Liu wrote:
>>>
>>> On 01/14/2014 07:35 AM, Minchan Kim wrote:
 Hello,

 On Sat, Jan 11, 2014 at 03:43:07PM +0800, Cai Liu wrote:
> zswap can support multiple swapfiles. So we need to check
> all zbud pool pages in zswap.

 True but this patch is rather costly that we should iterate
 zswap_tree[MAX_SWAPFILES] to check it. SIGH.

 How about defining zswap_tress as linked list instead of static
 array? Then, we could reduce unnecessary iteration too much.

>>>
>>> But if use linked list, it might not easy to access the tree like this:
>>> struct zswap_tree *tree = zswap_trees[type];
>>
>> struct zswap_tree {
>> ..
>> ..
>> struct list_head list;
>> }
>>
>> zswap_frontswap_init()
>> {
>> ..
>> ..
>> zswap_trees[type] = tree;
>> list_add(&tree->list, &zswap_list);
>> }
>>
>> get_zswap_pool_pages(void)
>> {
>> struct zswap_tree *cur;
>> list_for_each_entry(cur, &zswap_list, list) {
>> pool_pages += zbud_get_pool_size(cur->pool);
>> }
>> return pool_pages;
>> }

Okay, I see your point. Yes, it's much better.
Cai, Please make an new patch.

Thanks,
-Bob

>>
>>
>>>
>>> BTW: I'm still prefer to use dynamic pool size, instead of use
>>> zswap_is_full(). AFAIR, Seth has a plan to replace the rbtree with radix
>>> which will be more flexible to support this feature and page migration
>>> as well.
>>>
 Other question:
 Why do we need to update zswap_pool_pages too frequently?
 As I read the code, I think it's okay to update it only when user
 want to see it by debugfs and zswap_is_full is called.
 So could we optimize it out?

>
> Signed-off-by: Cai Liu 
>>>
>>> Reviewed-by: Bob Liu 
>>
>> Hmm, I really suprised you are okay in this code piece where we have
>> unnecessary cost most of case(ie, most system has a swap device) in
>> *mm* part.
>>
>> Anyway, I don't want to merge this patchset.
>> If Andrew merge it and anybody doesn't do right work, I will send a patch.
>> Cai, Could you redo a patch?
>> I don't want to intercept your credit.
>>
>> Even, we could optimize to reduce the the number of call as I said in
>> previous reply.
> 
> You did it already. Please write it out in description.
> 
--
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/9] mm: keep page cache radix tree nodes in check

2014-01-13 Thread Minchan Kim
On Mon, Jan 13, 2014 at 04:39:47PM +0900, Minchan Kim wrote:
> On Fri, Jan 10, 2014 at 01:10:43PM -0500, Johannes Weiner wrote:
> > Previously, page cache radix tree nodes were freed after reclaim
> > emptied out their page pointers.  But now reclaim stores shadow
> > entries in their place, which are only reclaimed when the inodes
> > themselves are reclaimed.  This is problematic for bigger files that
> > are still in use after they have a significant amount of their cache
> > reclaimed, without any of those pages actually refaulting.  The shadow
> > entries will just sit there and waste memory.  In the worst case, the
> > shadow entries will accumulate until the machine runs out of memory.
> > 
> > To get this under control, the VM will track radix tree nodes
> > exclusively containing shadow entries on a per-NUMA node list.
> > Per-NUMA rather than global because we expect the radix tree nodes
> > themselves to be allocated node-locally and we want to reduce
> > cross-node references of otherwise independent cache workloads.  A
> > simple shrinker will then reclaim these nodes on memory pressure.
> > 
> > A few things need to be stored in the radix tree node to implement the
> > shadow node LRU and allow tree deletions coming from the list:
> > 
> > 1. There is no index available that would describe the reverse path
> >from the node up to the tree root, which is needed to perform a
> >deletion.  To solve this, encode in each node its offset inside the
> >parent.  This can be stored in the unused upper bits of the same
> >member that stores the node's height at no extra space cost.
> > 
> > 2. The number of shadow entries needs to be counted in addition to the
> >regular entries, to quickly detect when the node is ready to go to
> >the shadow node LRU list.  The current entry count is an unsigned
> >int but the maximum number of entries is 64, so a shadow counter
> >can easily be stored in the unused upper bits.
> > 
> > 3. Tree modification needs tree lock and tree root, which are located
> >in the address space, so store an address_space backpointer in the
> >node.  The parent pointer of the node is in a union with the 2-word
> >rcu_head, so the backpointer comes at no extra cost as well.
> > 
> > 4. The node needs to be linked to an LRU list, which requires a list
> >head inside the node.  This does increase the size of the node, but
> >it does not change the number of objects that fit into a slab page.
> > 
> > Signed-off-by: Johannes Weiner 
> > ---
> >  include/linux/list_lru.h   |   2 +
> >  include/linux/mmzone.h |   1 +
> >  include/linux/radix-tree.h |  32 +---
> >  include/linux/swap.h   |   1 +
> >  lib/radix-tree.c   |  36 --
> >  mm/filemap.c   |  77 +++--
> >  mm/list_lru.c  |   8 +++
> >  mm/truncate.c  |  20 +++-
> >  mm/vmstat.c|   1 +
> >  mm/workingset.c| 121 
> > +
> >  10 files changed, 259 insertions(+), 40 deletions(-)
> > 
> > diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
> > index 3ce541753c88..b02fc233eadd 100644
> > --- a/include/linux/list_lru.h
> > +++ b/include/linux/list_lru.h
> > @@ -13,6 +13,8 @@
> >  /* list_lru_walk_cb has to always return one of those */
> >  enum lru_status {
> > LRU_REMOVED,/* item removed from list */
> > +   LRU_REMOVED_RETRY,  /* item removed, but lock has been
> > +  dropped and reacquired */
> > LRU_ROTATE, /* item referenced, give another pass */
> > LRU_SKIP,   /* item cannot be locked, skip */
> > LRU_RETRY,  /* item not freeable. May drop the lock
> > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> > index 118ba9f51e86..8cac5a7ef7a7 100644
> > --- a/include/linux/mmzone.h
> > +++ b/include/linux/mmzone.h
> > @@ -144,6 +144,7 @@ enum zone_stat_item {
> >  #endif
> > WORKINGSET_REFAULT,
> > WORKINGSET_ACTIVATE,
> > +   WORKINGSET_NODERECLAIM,
> > NR_ANON_TRANSPARENT_HUGEPAGES,
> > NR_FREE_CMA_PAGES,
> > NR_VM_ZONE_STAT_ITEMS };
> > diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
> > index 13636c40bc42..33170dbd9db4 100644
> > --- a/include/linux/radix-tree.h
> > +++ b/include/linux/radix-tree.h
> > @@ -72,21 +72,37 @@ static inline int radix_tree_is_indirect_ptr(void *ptr)
> >  #define RADIX_TREE_TAG_LONGS   \
> > ((RADIX_TREE_MAP_SIZE + BITS_PER_LONG - 1) / BITS_PER_LONG)
> >  
> > +#define RADIX_TREE_INDEX_BITS  (8 /* CHAR_BIT */ * sizeof(unsigned long))
> > +#define RADIX_TREE_MAX_PATH (DIV_ROUND_UP(RADIX_TREE_INDEX_BITS, \
> > + RADIX_TREE_MAP_SHIFT))
> > +
> > +/* Height component in node->path */
> > +#define RADIX_TREE_HEIGHT_SHIFT(RADIX_TREE_MAX_PATH + 1)
> > +#define RADIX_TREE_HEIGHT_MASK ((1U

[PATCH resend] ASoC: simple-card: fix one bug to writing to the platform data

2014-01-13 Thread Xiubo Li
It's a bug that writing to the platform data directly, for it should
be constant. So just copy it before writing.

Signed-off-by: Xiubo Li 
---

Resend this patch.


 sound/soc/generic/simple-card.c | 40 +---
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 5528dd6..53395f5 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -9,9 +9,10 @@
  * published by the Free Software Foundation.
  */
 #include 
+#include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
@@ -190,36 +191,37 @@ static int asoc_simple_card_probe(struct platform_device 
*pdev)
struct device_node *np = pdev->dev.of_node;
struct device_node *of_cpu, *of_codec, *of_platform;
struct device *dev = &pdev->dev;
+   int ret;
 
cinfo   = NULL;
of_cpu  = NULL;
of_codec= NULL;
of_platform = NULL;
+
+   cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
+   if (!cinfo)
+   return -ENOMEM;
+
if (np && of_device_is_available(np)) {
-   cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
-   if (cinfo) {
-   int ret;
-   cinfo->snd_card.dev = &pdev->dev;
-   ret = asoc_simple_card_parse_of(np, cinfo, dev,
-   &of_cpu,
-   &of_codec,
-   &of_platform);
-   if (ret < 0) {
-   if (ret != -EPROBE_DEFER)
-   dev_err(dev, "parse error %d\n", ret);
-   return ret;
-   }
-   } else {
-   return -ENOMEM;
+   cinfo->snd_card.dev = dev;
+
+   ret = asoc_simple_card_parse_of(np, cinfo, dev,
+   &of_cpu,
+   &of_codec,
+   &of_platform);
+   if (ret < 0) {
+   if (ret != -EPROBE_DEFER)
+   dev_err(dev, "parse error %d\n", ret);
+   return ret;
}
} else {
-   cinfo = pdev->dev.platform_data;
-   if (!cinfo) {
+   if (!dev->platform_data) {
dev_err(dev, "no info for asoc-simple-card\n");
return -EINVAL;
}
 
-   cinfo->snd_card.dev = &pdev->dev;
+   memcpy(cinfo, dev->platform_data, sizeof(*cinfo));
+   cinfo->snd_card.dev = dev;
}
 
if (!cinfo->name||
-- 
1.8.4


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


[PATCH 08/24] perf tools: Update cpumode for each cumulative entry

2014-01-13 Thread Namhyung Kim
The cpumode and level in struct addr_localtion was set for a sample
and but updated as cumulative callchains were added.  This led to have
non-matching symbol and cpumode in the output.

Update it accordingly based on the fact whether the map is a part of
the kernel or not.  This is a reverse of what thread__find_addr_map()
does.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/callchain.c | 42 ++
 tools/perf/util/callchain.h |  2 ++
 tools/perf/util/hist.c  | 13 ++---
 3 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 9eb4f57f8663..357513dd7011 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -554,3 +554,45 @@ int hist_entry__append_callchain(struct hist_entry *he, 
struct perf_sample *samp
return 0;
return callchain_append(he->callchain, &callchain_cursor, 
sample->period);
 }
+
+int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node 
*node,
+   bool hide_unresolved)
+{
+   al->map = node->map;
+   al->sym = node->sym;
+   if (node->map)
+   al->addr = node->map->map_ip(node->map, node->ip);
+   else
+   al->addr = node->ip;
+
+   if (al->sym == NULL) {
+   if (hide_unresolved)
+   return 0;
+   if (al->map == NULL)
+   goto out;
+   }
+
+   if (al->map->groups == &al->machine->kmaps) {
+   if (machine__is_host(al->machine)) {
+   al->cpumode = PERF_RECORD_MISC_KERNEL;
+   al->level = 'k';
+   } else {
+   al->cpumode = PERF_RECORD_MISC_GUEST_KERNEL;
+   al->level = 'g';
+   }
+   } else {
+   if (machine__is_host(al->machine)) {
+   al->cpumode = PERF_RECORD_MISC_USER;
+   al->level = '.';
+   } else if (perf_guest) {
+   al->cpumode = PERF_RECORD_MISC_GUEST_USER;
+   al->level = 'u';
+   } else {
+   al->cpumode = PERF_RECORD_MISC_HYPERVISOR;
+   al->level = 'H';
+   }
+   }
+
+out:
+   return 1;
+}
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 8ad97e9b119f..66faae21370d 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -155,6 +155,8 @@ int sample__resolve_callchain(struct perf_sample *sample, 
struct symbol **parent
  struct perf_evsel *evsel, struct addr_location 
*al,
  int max_stack);
 int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample 
*sample);
+int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node 
*node,
+   bool hide_unresolved);
 
 extern const char record_callchain_help[];
 #endif /* __PERF_CALLCHAIN_H */
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 46402fbf4c0e..beb9f96e4e4f 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -739,18 +739,9 @@ iter_next_cumulative_entry(struct hist_entry_iter *iter,
if (node == NULL)
return 0;
 
-   al->map = node->map;
-   al->sym = node->sym;
-   if (node->map)
-   al->addr = node->map->map_ip(node->map, node->ip);
-   else
-   al->addr = node->ip;
-
-   if (iter->hide_unresolved && al->sym == NULL)
-   return 0;
-
callchain_cursor_advance(&callchain_cursor);
-   return 1;
+
+   return fill_callchain_info(al, node, iter->hide_unresolved);
 }
 
 static int
-- 
1.7.11.7

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


[PATCH 01/24] perf tools: Remove symbol_conf.use_callchain check

2014-01-13 Thread Namhyung Kim
The machine__resolve_callchain() is called only if symbol_conf.
use_callchain is set so no need to check it again.

Signed-off-by: Namhyung Kim 
---
 tools/perf/util/machine.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 0130279aac51..ded74590b92f 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1314,8 +1314,6 @@ static int machine__resolve_callchain_sample(struct 
machine *machine,
*root_al = al;
callchain_cursor_reset(&callchain_cursor);
}
-   if (!symbol_conf.use_callchain)
-   break;
}
 
err = callchain_cursor_append(&callchain_cursor,
-- 
1.7.11.7

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


[PATCH 05/24] perf hists: Add support for accumulated stat of hist entry

2014-01-13 Thread Namhyung Kim
Maintain accumulated stat information in hist_entry->stat_acc if
symbol_conf.cumulate_callchain is set.  Fields in ->stat_acc have same
vaules initially, and will be updated as callchain is processed later.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/hist.c   | 28 ++--
 tools/perf/util/sort.h   |  1 +
 tools/perf/util/symbol.h |  1 +
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index d60ea8da342c..45a962f40cea 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -231,6 +231,8 @@ static bool hists__decay_entry(struct hists *hists, struct 
hist_entry *he)
return true;
 
he_stat__decay(&he->stat);
+   if (symbol_conf.cumulate_callchain)
+   he_stat__decay(he->stat_acc);
 
if (!he->filtered)
hists->stats.total_period -= prev_period - he->stat.period;
@@ -272,12 +274,26 @@ void hists__decay_entries(struct hists *hists, bool 
zap_user, bool zap_kernel)
 
 static struct hist_entry *hist_entry__new(struct hist_entry *template)
 {
-   size_t callchain_size = symbol_conf.use_callchain ? sizeof(struct 
callchain_root) : 0;
-   struct hist_entry *he = zalloc(sizeof(*he) + callchain_size);
+   size_t callchain_size = 0;
+   struct hist_entry *he;
+
+   if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain)
+   callchain_size = sizeof(struct callchain_root);
+
+   he = zalloc(sizeof(*he) + callchain_size);
 
if (he != NULL) {
*he = *template;
 
+   if (symbol_conf.cumulate_callchain) {
+   he->stat_acc = malloc(sizeof(he->stat));
+   if (he->stat_acc == NULL) {
+   free(he);
+   return NULL;
+   }
+   memcpy(he->stat_acc, &he->stat, sizeof(he->stat));
+   }
+
if (he->ms.map)
he->ms.map->referenced = true;
 
@@ -289,6 +305,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry 
*template)
 */
he->branch_info = malloc(sizeof(*he->branch_info));
if (he->branch_info == NULL) {
+   free(he->stat_acc);
free(he);
return NULL;
}
@@ -362,6 +379,8 @@ static struct hist_entry *add_hist_entry(struct hists 
*hists,
 
if (!cmp) {
he_stat__add_period(&he->stat, period, weight);
+   if (symbol_conf.cumulate_callchain)
+   he_stat__add_period(he->stat_acc, period, 
weight);
 
/*
 * This mem info was allocated from machine__resolve_mem
@@ -398,6 +417,8 @@ static struct hist_entry *add_hist_entry(struct hists 
*hists,
rb_insert_color(&he->rb_node_in, hists->entries_in);
 out:
he_stat__add_cpumode_period(&he->stat, al->cpumode, period);
+   if (symbol_conf.cumulate_callchain)
+   he_stat__add_cpumode_period(he->stat_acc, al->cpumode, period);
return he;
 }
 
@@ -775,6 +796,7 @@ void hist_entry__free(struct hist_entry *he)
 {
zfree(&he->branch_info);
zfree(&he->mem_info);
+   zfree(&he->stat_acc);
free_srcline(he->srcline);
free(he);
 }
@@ -800,6 +822,8 @@ static bool hists__collapse_insert_entry(struct hists 
*hists __maybe_unused,
 
if (!cmp) {
he_stat__add_stat(&iter->stat, &he->stat);
+   if (symbol_conf.cumulate_callchain)
+   he_stat__add_stat(iter->stat_acc, he->stat_acc);
 
if (symbol_conf.use_callchain) {
callchain_cursor_reset(&callchain_cursor);
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 43e5ff42a609..309f2838a1b4 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -81,6 +81,7 @@ struct hist_entry {
struct list_head head;
} pairs;
struct he_stat  stat;
+   struct he_stat  *stat_acc;
struct map_symbol   ms;
struct thread   *thread;
struct comm *comm;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 4ccc5c4b3a65..c9221c2390af 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -92,6 +92,7 @@ struct symbol_conf {
show_nr_samples,
show_total_period,
use_callchain,
+   cumulate_callchain,
exclude_other,
show_cpu_utilization,
initialized,
-- 
1.7.11.7

--
To unsubscribe fr

[PATCH 12/24] perf hists: Sort hist entries by accumulated period

2014-01-13 Thread Namhyung Kim
When callchain accumulation is requested, we need to sort the entries
by accumulated period value.  When accumulated periods of two entries
are same (i.e. single path callchain) put the caller above since
accumulation tends to put callers on higher position for obvious
reason.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/hist.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 765ac5953201..da4fbec3d0d8 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1063,6 +1063,18 @@ static int hist_entry__sort_on_period(struct hist_entry 
*a,
struct hist_entry *pair;
u64 *periods_a, *periods_b;
 
+   if (symbol_conf.cumulate_callchain) {
+   /*
+* Put caller above callee when they have equal period.
+*/
+   if (a->stat_acc->period != b->stat_acc->period)
+   return a->stat_acc->period > b->stat_acc->period ? 1 : 
-1;
+
+   if (a->callchain->max_depth != b->callchain->max_depth)
+   return a->callchain->max_depth < 
b->callchain->max_depth ?
+   1 : -1;
+   }
+
ret = period_cmp(a->stat.period, b->stat.period);
if (ret || !symbol_conf.event_group)
return ret;
-- 
1.7.11.7

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


[PATCH 10/24] perf callchain: Add callchain_cursor_snapshot()

2014-01-13 Thread Namhyung Kim
The callchain_cursor_snapshot() is for saving current status of the
callchain.  It'll be used to accumulate callchain information for each node.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/callchain.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 66faae21370d..bbd63dfbe112 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -159,4 +159,13 @@ int fill_callchain_info(struct addr_location *al, struct 
callchain_cursor_node *
bool hide_unresolved);
 
 extern const char record_callchain_help[];
+
+static inline void callchain_cursor_snapshot(struct callchain_cursor *dest,
+struct callchain_cursor *src)
+{
+   *dest = *src;
+
+   dest->first = src->curr;
+   dest->nr -= src->pos;
+}
 #endif /* __PERF_CALLCHAIN_H */
-- 
1.7.11.7

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


[PATCH 03/24] perf tools: Introduce struct hist_entry_iter

2014-01-13 Thread Namhyung Kim
There're some duplicate code when adding hist entries.  They are
different in that some have branch info or mem info but generally do
same thing.  So introduce new struct hist_entry_iter and add callbacks
to customize each case in general way.

The new perf_evsel__add_entry() function will look like:

  iter->prepare_entry();
  iter->add_single_entry();

  while (iter->next_entry())
iter->add_next_entry();

  iter->finish_entry();

This will help further work like the cumulative callchain patchset.

Cc: Jiri Olsa 
Cc: David Ahern 
Cc: Stephane Eranian 
Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c | 172 +++--
 tools/perf/util/hist.c  | 304 
 tools/perf/util/hist.h  |  34 +
 3 files changed, 356 insertions(+), 154 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 7ddea46594ae..b6618ecb474a 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -85,144 +85,6 @@ static int report__config(const char *var, const char 
*value, void *cb)
return perf_default_config(var, value, cb);
 }
 
-static int report__add_mem_hist_entry(struct perf_tool *tool, struct 
addr_location *al,
- struct perf_sample *sample, struct 
perf_evsel *evsel,
- union perf_event *event)
-{
-   struct report *rep = container_of(tool, struct report, tool);
-   struct symbol *parent = NULL;
-   u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
-   struct hist_entry *he;
-   struct mem_info *mi, *mx;
-   uint64_t cost;
-   int err = sample__resolve_callchain(sample, &parent, evsel, al, 
rep->max_stack);
-
-   if (err)
-   return err;
-
-   mi = machine__resolve_mem(al->machine, al->thread, sample, cpumode);
-   if (!mi)
-   return -ENOMEM;
-
-   if (rep->hide_unresolved && !al->sym)
-   return 0;
-
-   cost = sample->weight;
-   if (!cost)
-   cost = 1;
-
-   /*
-* must pass period=weight in order to get the correct
-* sorting from hists__collapse_resort() which is solely
-* based on periods. We want sorting be done on nr_events * weight
-* and this is indirectly achieved by passing period=weight here
-* and the he_stat__add_period() function.
-*/
-   he = __hists__add_entry(&evsel->hists, al, parent, NULL, mi,
-   cost, cost, 0);
-   if (!he)
-   return -ENOMEM;
-
-   err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
-   if (err)
-   goto out;
-
-   mx = he->mem_info;
-   err = addr_map_symbol__inc_samples(&mx->daddr, evsel->idx);
-   if (err)
-   goto out;
-
-   evsel->hists.stats.total_period += cost;
-   hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
-   err = hist_entry__append_callchain(he, sample);
-out:
-   return err;
-}
-
-static int report__add_branch_hist_entry(struct perf_tool *tool, struct 
addr_location *al,
-struct perf_sample *sample, struct 
perf_evsel *evsel)
-{
-   struct report *rep = container_of(tool, struct report, tool);
-   struct symbol *parent = NULL;
-   unsigned i;
-   struct hist_entry *he;
-   struct branch_info *bi, *bx;
-   int err = sample__resolve_callchain(sample, &parent, evsel, al, 
rep->max_stack);
-
-   if (err)
-   return err;
-
-   bi = machine__resolve_bstack(al->machine, al->thread,
-sample->branch_stack);
-   if (!bi)
-   return -ENOMEM;
-
-   for (i = 0; i < sample->branch_stack->nr; i++) {
-   if (rep->hide_unresolved && !(bi[i].from.sym && bi[i].to.sym))
-   continue;
-
-   err = -ENOMEM;
-
-   /* overwrite the 'al' to branch-to info */
-   al->map = bi[i].to.map;
-   al->sym = bi[i].to.sym;
-   al->addr = bi[i].to.addr;
-   /*
-* The report shows the percentage of total branches captured
-* and not events sampled. Thus we use a pseudo period of 1.
-*/
-   he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL,
-   1, 1, 0);
-   if (he) {
-   bx = he->branch_info;
-   err = addr_map_symbol__inc_samples(&bx->from, 
evsel->idx);
-   if (err)
-   goto out;
-
-   err = addr_map_symbol__inc_samples(&bx->to, evsel->idx);
-   if (err)
-   goto out;
-
-   evsel->hists.stats.total_period += 1;
-   

[PATCHSET 00/24] perf tools: Add support to accumulate hist periods (v6)

2014-01-13 Thread Namhyung Kim
Hello,

This is a new attempt to implement cumulative hist period report.
This work begins from Arun's SORT_INCLUSIVE patch [1] but I completely
rewrote it from scratch.

This patchset is based on my previous patchset [2] but I think it's
almost independent so that it can be applied separately.

Please see the patch 03/24.  I refactored functions that add hist
entries with struct hist_entry_iter.  While I converted all functions
carefully, it'd be better anyone can test and confirm that I didn't
mess up something - especially for branch stack and mem stuff.

This patchset basically adds period in a sample to every node in the
callchain.  A hist_entry now has an additional fields to keep the
cumulative period if --children option is given on perf report.

I changed the option as a separate --children and added a new
"Children" column (and renamed the default "Overhead" column into
"Self").  The output will be sorted by children (cumulative) overhead
for now.  The reason I changed to the --children is that I still think
it's much different from other --call-graph options.  The --call-graph
option will take care of it even with --children option.

I know that the UI should be changed also to be more flexible as Ingo
requested, but I'd like to do this first and then move to work on the
next.  I also added a new config option to enable it by default.

 * changes in v6:
  - separate struct hist_iter_ops (Jiri)
  - check iter->he before calling ->add_entry_cb (Jiri)
  - fix locking issue on perf top (Jiri)

 * changes in v5:
  - support both of --children and --call-graph (Arun)
  - refactor hist_entry_iter to share with perf top (Jiri)
  - various cleanups and fixes (Jiri)
  - add ack's from Jiri

 * changes in v4:
  - change to --children option (Ingo)
  - rebased on new annotation change (Arnaldo)
  - support perf top also
  - enable --children option by default (Ingo)

 * changes in v3:
  - change to --cumulate option
  - fix a couple of bugs (Jiri, Rodrigo)
  - rename some help functions (Arnaldo)
  - cache previous hist entries rathen than just symbol and dso
  - add some preparatory cleanups
  - add report.cumulate config option


Let me show you an example:

  $ cat abc.c
  #define barrier() asm volatile("" ::: "memory")

  void a(void)
  {
int i;
for (i = 0; i < 100; i++)
barrier();
  }
  void b(void)
  {
a();
  }
  void c(void)
  {
b();
  }
  int main(void)
  {
c();
return 0;
  }

With this simple program I ran perf record and report:

  $ perf record -g -e cycles:u ./abc


Case 1.

  $ perf report --stdio --no-call-graph --no-children

  # Overhead  Command  Shared Object  Symbol
  #   ...  .  ..
  #
  91.50%  abc  abc[.] a 
   8.18%  abc  ld-2.17.so [.] strlen
   0.31%  abc  [kernel.kallsyms]  [k] page_fault
   0.01%  abc  ld-2.17.so [.] _start


Case 2. (current default behavior)

  $ perf report --stdio --call-graph --no-children

  # Overhead  Command  Shared Object  Symbol
  #   ...  .  ..
  #
  91.50%  abc  abc[.] a 
  |
  --- a
  b
  c
  main
  __libc_start_main

   8.18%  abc  ld-2.17.so [.] strlen
  |
  --- strlen
  _dl_sysdep_start

   0.31%  abc  [kernel.kallsyms]  [k] page_fault
  |
  --- page_fault
  _start

   0.01%  abc  ld-2.17.so [.] _start
  |
  --- _start


Case 3.

  $ perf report --no-call-graph --children --stdio

  # Self  Children  Command  Shared Object Symbol
  #     ...  .  .
  #
   0.00%91.50%  abc  libc-2.17.so   [.] __libc_start_main
   0.00%91.50%  abc  abc[.] main 
   0.00%91.50%  abc  abc[.] c
   0.00%91.50%  abc  abc[.] b
  91.50%91.50%  abc  abc[.] a
   0.00% 8.18%  abc  ld-2.17.so [.] _dl_sysdep_start 
   8.18% 8.18%  abc  ld-2.17.so [.] strlen   
   0.01% 0.33%  abc  ld-2.17.so [.] _start   
   0.31% 0.31%  abc  [kernel.kallsyms]  [k] page_fault   

As you can see __libc_start_main -> main -> c -> b -> a callchain show
up in the output.

Finally, it looks like below with both option enabled:

Case 4. (default behavior?)

  $ perf report --call-graph --children --stdio

  # Self  Children  Command  Shared Object Symbol
  

[PATCH 06/24] perf hists: Check if accumulated when adding a hist entry

2014-01-13 Thread Namhyung Kim
To support callchain accumulation, @entry should be recognized if it's
accumulated or not when add_hist_entry() called.  The period of an
accumulated entry should be added to ->stat_acc but not ->stat. Add
@sample_self arg for that.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-annotate.c |  3 ++-
 tools/perf/builtin-diff.c |  2 +-
 tools/perf/builtin-top.c  |  2 +-
 tools/perf/tests/hists_link.c |  4 ++--
 tools/perf/util/hist.c| 29 ++---
 tools/perf/util/hist.h|  3 ++-
 6 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 0da603b79b61..70b2d52c3b2e 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -65,7 +65,8 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return 0;
}
 
-   he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0);
+   he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0,
+   true);
if (he == NULL)
return -ENOMEM;
 
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index a77e31246c00..93912add75b5 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -308,7 +308,7 @@ static int hists__add_entry(struct hists *hists,
u64 weight, u64 transaction)
 {
if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight,
-  transaction) != NULL)
+  transaction, true) != NULL)
return 0;
return -ENOMEM;
 }
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 76cd510d34d0..c574c291383c 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -245,7 +245,7 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct 
perf_evsel *evsel,
pthread_mutex_lock(&evsel->hists.lock);
he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL,
sample->period, sample->weight,
-   sample->transaction);
+   sample->transaction, true);
pthread_mutex_unlock(&evsel->hists.lock);
if (he == NULL)
return NULL;
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 2b6519e0e36f..e4e931ec1dbb 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -223,7 +223,7 @@ static int add_hist_entries(struct perf_evlist *evlist, 
struct machine *machine)
goto out;
 
he = __hists__add_entry(&evsel->hists, &al, NULL,
-   NULL, NULL, 1, 1, 0);
+   NULL, NULL, 1, 1, 0, true);
if (he == NULL)
goto out;
 
@@ -246,7 +246,7 @@ static int add_hist_entries(struct perf_evlist *evlist, 
struct machine *machine)
goto out;
 
he = __hists__add_entry(&evsel->hists, &al, NULL,
-   NULL, NULL, 1, 1, 0);
+   NULL, NULL, 1, 1, 0, true);
if (he == NULL)
goto out;
 
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 45a962f40cea..2e9dd5d4ca1d 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -272,7 +272,8 @@ void hists__decay_entries(struct hists *hists, bool 
zap_user, bool zap_kernel)
  * histogram, sorted on item, collects periods
  */
 
-static struct hist_entry *hist_entry__new(struct hist_entry *template)
+static struct hist_entry *hist_entry__new(struct hist_entry *template,
+ bool sample_self)
 {
size_t callchain_size = 0;
struct hist_entry *he;
@@ -292,6 +293,8 @@ static struct hist_entry *hist_entry__new(struct hist_entry 
*template)
return NULL;
}
memcpy(he->stat_acc, &he->stat, sizeof(he->stat));
+   if (!sample_self)
+   memset(&he->stat, 0, sizeof(he->stat));
}
 
if (he->ms.map)
@@ -354,7 +357,8 @@ static u8 symbol__parent_filter(const struct symbol *parent)
 
 static struct hist_entry *add_hist_entry(struct hists *hists,
 struct hist_entry *entry,
-struct addr_location *al)
+struct addr_location *al,
+bool sample_self)
 {
struct rb_node **p;
struct rb_node *parent = NULL;
@@ -378,7 +382,8 @@ static struct hist_entry *add_hist_

[PATCH 11/24] perf tools: Save callchain info for each cumulative entry

2014-01-13 Thread Namhyung Kim
When accumulating callchain entry, also save current snapshot of the
chain so that it can show the rest of the chain.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/hist.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 1b477f8d2d17..765ac5953201 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -744,6 +744,14 @@ iter_add_single_cumulative_entry(struct hist_entry_iter 
*iter,
 
he_cache[iter->curr++] = he;
 
+   callchain_append(he->callchain, &callchain_cursor, sample->period);
+
+   /*
+* We need to re-initialize the cursor since callchain_append()
+* advanced the cursor to the end.
+*/
+   callchain_cursor_commit(&callchain_cursor);
+
return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
 }
 
@@ -757,8 +765,6 @@ iter_next_cumulative_entry(struct hist_entry_iter *iter,
if (node == NULL)
return 0;
 
-   callchain_cursor_advance(&callchain_cursor);
-
return fill_callchain_info(al, node, iter->hide_unresolved);
 }
 
@@ -782,6 +788,11 @@ iter_add_next_cumulative_entry(struct hist_entry_iter 
*iter,
.parent = iter->parent,
};
int i;
+   struct callchain_cursor cursor;
+
+   callchain_cursor_snapshot(&cursor, &callchain_cursor);
+
+   callchain_cursor_advance(&callchain_cursor);
 
/*
 * Check if there's duplicate entries in the callchain.
@@ -800,6 +811,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
 
he_cache[iter->curr++] = he;
 
+   callchain_append(he->callchain, &cursor, sample->period);
+
return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
 }
 
-- 
1.7.11.7

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


[PATCH 14/24] perf ui/browser: Add support to accumulated hist stat

2014-01-13 Thread Namhyung Kim
Print accumulated stat of a hist entry if requested.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/ui/browsers/hists.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index b720b92eba6e..c8e3a2e7b5c0 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -693,11 +693,26 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt 
__maybe_unused,\
return __hpp__color_fmt(hpp, he, __hpp_get_##_field, _cb);  \
 }
 
+#define __HPP_COLOR_ACC_PERCENT_FN(_type, _field, _cb) \
+static u64 __hpp_get_acc_##_field(struct hist_entry *he)   \
+{  \
+   return he->stat_acc->_field;\
+}  \
+   \
+static int \
+hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\
+   struct perf_hpp *hpp,   \
+   struct hist_entry *he)  \
+{  \
+   return __hpp__color_fmt(hpp, he, __hpp_get_acc_##_field, _cb);  \
+}
+
 __HPP_COLOR_PERCENT_FN(overhead, period, __hpp__color_callchain)
 __HPP_COLOR_PERCENT_FN(overhead_sys, period_sys, NULL)
 __HPP_COLOR_PERCENT_FN(overhead_us, period_us, NULL)
 __HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys, NULL)
 __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us, NULL)
+__HPP_COLOR_ACC_PERCENT_FN(overhead_acc, period, NULL)
 
 #undef __HPP_COLOR_PERCENT_FN
 
@@ -715,6 +730,8 @@ void hist_browser__init_hpp(void)
hist_browser__hpp_color_overhead_guest_sys;
perf_hpp__format[PERF_HPP__OVERHEAD_GUEST_US].color =
hist_browser__hpp_color_overhead_guest_us;
+   perf_hpp__format[PERF_HPP__OVERHEAD_ACC].color =
+   hist_browser__hpp_color_overhead_acc;
 }
 
 static int hist_browser__show_entry(struct hist_browser *browser,
-- 
1.7.11.7

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


[PATCH 13/24] perf ui/hist: Add support to accumulated hist stat

2014-01-13 Thread Namhyung Kim
Print accumulated stat of a hist entry if requested.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/ui/hist.c   | 45 +
 tools/perf/util/hist.h |  1 +
 2 files changed, 46 insertions(+)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 78f4c92e9b73..eb9c07bcdb01 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -129,6 +129,28 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt 
__maybe_unused,\
  scnprintf, true); 
\
 }
 
+#define __HPP_COLOR_ACC_PERCENT_FN(_type, _field)  
\
+static u64 he_get_acc_##_field(struct hist_entry *he)  
\
+{  
\
+   return he->stat_acc->_field;
\
+}  
\
+   
\
+static int hpp__color_acc_##_type(struct perf_hpp_fmt *fmt __maybe_unused, 
\
+ struct perf_hpp *hpp, struct hist_entry *he)  
\
+{  
\
+   return __hpp__fmt(hpp, he, he_get_acc_##_field, " %6.2f%%", 
\
+ (hpp_snprint_fn)percent_color_snprintf, true);
\
+}
+
+#define __HPP_ENTRY_ACC_PERCENT_FN(_type, _field)  
\
+static int hpp__entry_acc_##_type(struct perf_hpp_fmt *_fmt __maybe_unused,
\
+ struct perf_hpp *hpp, struct hist_entry *he)  
\
+{  
\
+   const char *fmt = symbol_conf.field_sep ? " %.2f" : " %6.2f%%"; 
\
+   return __hpp__fmt(hpp, he, he_get_acc_##_field, fmt,
\
+ scnprintf, true); 
\
+}
+
 #define __HPP_ENTRY_RAW_FN(_type, _field)  
\
 static u64 he_get_raw_##_field(struct hist_entry *he)  
\
 {  
\
@@ -148,17 +170,25 @@ __HPP_WIDTH_FN(_type, _min_width, _unit_width)
\
 __HPP_COLOR_PERCENT_FN(_type, _field)  \
 __HPP_ENTRY_PERCENT_FN(_type, _field)
 
+#define HPP_PERCENT_ACC_FNS(_type, _str, _field, _min_width, _unit_width)\
+__HPP_HEADER_FN(_type, _str, _min_width, _unit_width)  \
+__HPP_WIDTH_FN(_type, _min_width, _unit_width) \
+__HPP_COLOR_ACC_PERCENT_FN(_type, _field)  \
+__HPP_ENTRY_ACC_PERCENT_FN(_type, _field)
+
 #define HPP_RAW_FNS(_type, _str, _field, _min_width, _unit_width)  \
 __HPP_HEADER_FN(_type, _str, _min_width, _unit_width)  \
 __HPP_WIDTH_FN(_type, _min_width, _unit_width) \
 __HPP_ENTRY_RAW_FN(_type, _field)
 
+__HPP_HEADER_FN(overhead_self, "Self", 8, 8)
 
 HPP_PERCENT_FNS(overhead, "Overhead", period, 8, 8)
 HPP_PERCENT_FNS(overhead_sys, "sys", period_sys, 8, 8)
 HPP_PERCENT_FNS(overhead_us, "usr", period_us, 8, 8)
 HPP_PERCENT_FNS(overhead_guest_sys, "guest sys", period_guest_sys, 9, 8)
 HPP_PERCENT_FNS(overhead_guest_us, "guest usr", period_guest_us, 9, 8)
+HPP_PERCENT_ACC_FNS(overhead_acc, "Children", period, 8, 8)
 
 HPP_RAW_FNS(samples, "Samples", nr_events, 12, 12)
 HPP_RAW_FNS(period, "Period", period, 12, 12)
@@ -171,6 +201,14 @@ HPP_RAW_FNS(period, "Period", period, 12, 12)
.entry  = hpp__entry_ ## _name  \
}
 
+#define HPP__COLOR_ACC_PRINT_FNS(_name)\
+   {   \
+   .header = hpp__header_ ## _name,\
+   .width  = hpp__width_ ## _name, \
+   .color  = hpp__color_acc_ ## _name, \
+   .entry  = hpp__entry_acc_ ## _name  \
+   }
+
 #define HPP__PRINT_FNS(_name)  \
{   \
.header = hpp__header_ ## _name,\
@@ -184,6 +222,7 @@ struct perf_hpp_fmt perf_hpp__format[] = {
HPP__COLOR_PRINT_FNS(overhead_us),
HPP__COLOR_PRINT_FNS(overhead_guest_sys),
HPP__COLOR_PRINT_FNS(overhead_guest_us),
+   HPP__COLOR_ACC_PRINT_FNS(overhead_acc),
HPP__PRINT_FNS(samples),
HPP__PRINT_FNS(period)
 };
@@ -208,6 +247,12 @@ void perf_hpp__init(void)
 {
perf_hpp__column_enable(PERF_HPP__OVERHEAD);
 
+   if (symbol_conf.cumulate_callchain) {
+   perf_hpp__format[PERF_HPP__OVERHEAD].header =
+   hpp__header_overhead_self;
+ 

[PATCH 23/24] perf top: Add top.children config option

2014-01-13 Thread Namhyung Kim
Add top.children config option for setting default value of
callchain accumulation.  It affects the output only if one of
-g or --call-graph option is given as well.

A user can write .perfconfig file like below to enable accumulation
by default:

  $ cat ~/.perfconfig
  [top]
  children = true

And it can be disabled through command line:

  $ perf top --no-children

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-top.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 439e000b0f39..2e521d00c0a4 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -87,6 +87,16 @@ static void perf_top__sig_winch(int sig __maybe_unused,
perf_top__update_print_entries(top);
 }
 
+static int top__config(const char *var, const char *value, void *cb)
+{
+   if (!strcmp(var, "top.children")) {
+   symbol_conf.cumulate_callchain = perf_config_bool(var, value);
+   return 0;
+   }
+
+   return perf_default_config(var, value, cb);
+}
+
 static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
 {
struct symbol *sym;
@@ -1125,6 +1135,8 @@ int cmd_top(int argc, const char **argv, const char 
*prefix __maybe_unused)
if (top.evlist == NULL)
return -ENOMEM;
 
+   perf_config(top__config, &top);
+
argc = parse_options(argc, argv, options, top_usage, 0);
if (argc)
usage_with_options(top_usage, options);
-- 
1.7.11.7

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


[PATCH 22/24] perf top: Add --children option

2014-01-13 Thread Namhyung Kim
The --children option is for showing accumulated overhead (period)
value as well as self overhead.  It should be used with one of -g or
--call-graph option.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/Documentation/perf-top.txt | 6 ++
 tools/perf/builtin-top.c  | 7 +++
 2 files changed, 13 insertions(+)

diff --git a/tools/perf/Documentation/perf-top.txt 
b/tools/perf/Documentation/perf-top.txt
index cdd8d4946dba..01b6fd1a4428 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -149,6 +149,12 @@ Default is to monitor all CPUS.
Setup and enable call-graph (stack chain/backtrace) recording,
implies -g.
 
+--children::
+   Accumulate callchain of children to parent entry so that then can
+   show up in the output.  The output will have a new "Children" column
+   and will be sorted on the data.  It requires -g/--call-graph option
+   enabled.
+
 --max-stack::
Set the stack depth limit when parsing the callchain, anything
beyond the specified depth will be ignored. This is a trade-off
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 9de14f71c196..439e000b0f39 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1087,6 +1087,8 @@ int cmd_top(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_CALLBACK(0, "call-graph", &top.record_opts,
 "mode[,dump_size]", record_callchain_help,
 &parse_callchain_opt),
+   OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
+   "Accumulate callchains of children and show total overhead 
as well"),
OPT_INTEGER(0, "max-stack", &top.max_stack,
"Set the maximum stack depth when parsing the callchain. "
"Default: " __stringify(PERF_MAX_STACK_DEPTH)),
@@ -1186,6 +1188,11 @@ int cmd_top(int argc, const char **argv, const char 
*prefix __maybe_unused)
 
top.sym_evsel = perf_evlist__first(top.evlist);
 
+   if (!symbol_conf.use_callchain) {
+   symbol_conf.cumulate_callchain = false;
+   perf_hpp__cancel_cumulate();
+   }
+
symbol_conf.priv_size = sizeof(struct annotation);
 
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
-- 
1.7.11.7

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


[PATCH 19/24] perf report: Add report.children config option

2014-01-13 Thread Namhyung Kim
Add report.children config option for setting default value of
callchain accumulation.  It affects the report output only if
perf.data contains callchain info.

A user can write .perfconfig file like below to enable accumulation
by default:

  $ cat ~/.perfconfig
  [report]
  children = true

And it can be disabled through command line:

  $ perf report --no-children

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 56fe8c00b1be..b8541ec61a00 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -78,7 +78,9 @@ static int report__config(const char *var, const char *value, 
void *cb)
symbol_conf.filter_relative = false;
else
return -1;
-
+   }
+   if (!strcmp(var, "report.children")) {
+   symbol_conf.cumulate_callchain = perf_config_bool(var, value);
return 0;
}
 
-- 
1.7.11.7

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


[PATCH 18/24] perf report: Add --children option

2014-01-13 Thread Namhyung Kim
The --children option is for showing accumulated overhead (period)
value as well as self overhead.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/Documentation/perf-report.txt |  5 +
 tools/perf/builtin-report.c  | 10 ++
 2 files changed, 15 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index 9a67a42356d6..59e04df1b387 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -141,6 +141,11 @@ OPTIONS
 
Default: fractal,0.5,callee,function.
 
+--children::
+   Accumulate callchain of children to parent entry so that then can
+   show up in the output.  The output will have a new "Children" column
+   and will be sorted on the data.  It requires callchains are recorded.
+
 --max-stack::
Set the stack depth limit when parsing the callchain, anything
beyond the specified depth will be ignored. This is a trade-off
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3ed0669d7620..56fe8c00b1be 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -183,6 +183,14 @@ static int report__setup_sample_type(struct report *rep)
}
}
 
+   if (symbol_conf.cumulate_callchain) {
+   /* Silently ignore if callchain is missing */
+   if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) {
+   symbol_conf.cumulate_callchain = false;
+   perf_hpp__cancel_cumulate();
+   }
+   }
+
if (sort__mode == SORT_MODE__BRANCH) {
if (!is_pipe &&
!(sample_type & PERF_SAMPLE_BRANCH_STACK)) {
@@ -661,6 +669,8 @@ int cmd_report(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_CALLBACK_DEFAULT('g', "call-graph", &report, 
"output_type,min_percent[,print_limit],call_order",
 "Display callchains using output_type (graph, flat, 
fractal, or none) , min percent threshold, optional print limit, callchain 
order, key (function or address). "
 "Default: fractal,0.5,callee,function", 
&parse_callchain_opt, callchain_default_opt),
+   OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
+   "Accumulate callchains of children and show total overhead 
as well"),
OPT_INTEGER(0, "max-stack", &report.max_stack,
"Set the maximum stack depth when parsing the callchain, "
"anything beyond the specified depth will be ignored. "
-- 
1.7.11.7

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


[PATCH 21/24] perf top: Convert to hist_entry_iter

2014-01-13 Thread Namhyung Kim
Reuse hist_entry_iter__add() function to share the similar code with
perf report.  Note that it needs to be called with hists.lock so tweak
some internal functions not to deadlock or hold the lock too long.

Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-top.c | 78 ++--
 1 file changed, 43 insertions(+), 35 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index c574c291383c..9de14f71c196 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -194,6 +194,12 @@ static void perf_top__record_precise_ip(struct perf_top 
*top,
 
pthread_mutex_unlock(¬es->lock);
 
+   /*
+* This function is now called with he->hists->lock held.
+* Release it before going to sleep.
+*/
+   pthread_mutex_unlock(&he->hists->lock);
+
if (err == -ERANGE && !he->ms.map->erange_warned)
ui__warn_map_erange(he->ms.map, sym, ip);
else if (err == -ENOMEM) {
@@ -201,6 +207,8 @@ static void perf_top__record_precise_ip(struct perf_top 
*top,
   sym->name);
sleep(1);
}
+
+   pthread_mutex_lock(&he->hists->lock);
 }
 
 static void perf_top__show_details(struct perf_top *top)
@@ -236,24 +244,6 @@ out_unlock:
pthread_mutex_unlock(¬es->lock);
 }
 
-static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel,
-struct addr_location *al,
-struct perf_sample *sample)
-{
-   struct hist_entry *he;
-
-   pthread_mutex_lock(&evsel->hists.lock);
-   he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL,
-   sample->period, sample->weight,
-   sample->transaction, true);
-   pthread_mutex_unlock(&evsel->hists.lock);
-   if (he == NULL)
-   return NULL;
-
-   hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
-   return he;
-}
-
 static void perf_top__print_sym_table(struct perf_top *top)
 {
char bf[160];
@@ -657,6 +647,28 @@ static int symbol_filter(struct map *map __maybe_unused, 
struct symbol *sym)
return 0;
 }
 
+static int hist_iter_cb(struct hist_entry_iter *iter, struct addr_location *al,
+   bool single, void *arg)
+{
+   struct perf_top *top = arg;
+   struct hist_entry *he = iter->he;
+   struct perf_evsel *evsel = iter->evsel;
+
+   if (single)
+   hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
+
+   if (sort__has_sym) {
+   u64 ip = al->addr;
+
+   if (al->map)
+   ip = al->map->unmap_ip(al->map, ip);
+
+   perf_top__record_precise_ip(top, he, evsel->idx, ip);
+   }
+
+   return 0;
+}
+
 static void perf_event__process_sample(struct perf_tool *tool,
   const union perf_event *event,
   struct perf_evsel *evsel,
@@ -664,8 +676,6 @@ static void perf_event__process_sample(struct perf_tool 
*tool,
   struct machine *machine)
 {
struct perf_top *top = container_of(tool, struct perf_top, tool);
-   struct symbol *parent = NULL;
-   u64 ip = sample->ip;
struct addr_location al;
int err;
 
@@ -741,25 +751,23 @@ static void perf_event__process_sample(struct perf_tool 
*tool,
}
 
if (al.sym == NULL || !al.sym->ignore) {
-   struct hist_entry *he;
+   struct hist_entry_iter iter = {
+   .add_entry_cb = hist_iter_cb,
+   };
 
-   err = sample__resolve_callchain(sample, &parent, evsel, &al,
-   top->max_stack);
-   if (err)
-   return;
+   if (symbol_conf.cumulate_callchain)
+   iter.ops = &hist_iter_cumulative;
+   else
+   iter.ops = &hist_iter_normal;
 
-   he = perf_evsel__add_hist_entry(evsel, &al, sample);
-   if (he == NULL) {
-   pr_err("Problem incrementing symbol period, skipping 
event\n");
-   return;
-   }
+   pthread_mutex_lock(&evsel->hists.lock);
 
-   err = hist_entry__append_callchain(he, sample);
-   if (err)
-   return;
+   err = hist_entry_iter__add(&iter, &al, evsel, event, sample,
+  top->max_stack, top);
+   if (err < 0)
+   pr_err("Problem incrementing symbol period, skipping 
event\n");
 
-   if (sort__has_sym)
-   perf_top__record_precise_ip(top, he, evsel->idx, ip);
+   pthread_mutex_unlock(&evsel->hists.lock);
}
 
re

[PATCH 16/24] perf tools: Apply percent-limit to cumulative percentage

2014-01-13 Thread Namhyung Kim
If -g cumulative option is given, it needs to show entries which don't
have self overhead.  So apply percent-limit to accumulated overhead
percentage in this case.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/ui/browsers/hists.c | 33 +++--
 tools/perf/ui/gtk/hists.c  |  4 ++--
 tools/perf/ui/stdio/hist.c |  4 ++--
 tools/perf/util/hist.h |  1 +
 tools/perf/util/sort.h | 17 -
 5 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index c8e3a2e7b5c0..0a088535ebac 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -828,12 +828,12 @@ static unsigned int hist_browser__refresh(struct 
ui_browser *browser)
 
for (nd = browser->top; nd; nd = rb_next(nd)) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
-   float percent = h->stat.period * 100.0 /
-   hb->hists->stats.total_period;
+   float percent;
 
if (h->filtered)
continue;
 
+   percent = hist_entry__get_percent_limit(h);
if (percent < hb->min_pcnt)
continue;
 
@@ -846,18 +846,13 @@ static unsigned int hist_browser__refresh(struct 
ui_browser *browser)
 }
 
 static struct rb_node *hists__filter_entries(struct rb_node *nd,
-struct hists *hists,
 float min_pcnt)
 {
while (nd != NULL) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
-   float percent = h->stat.period * 100.0 /
-   hists->stats.total_period;
+   float percent = hist_entry__get_percent_limit(h);
 
-   if (percent < min_pcnt)
-   return NULL;
-
-   if (!h->filtered)
+   if (!h->filtered && percent >= min_pcnt)
return nd;
 
nd = rb_next(nd);
@@ -867,13 +862,11 @@ static struct rb_node *hists__filter_entries(struct 
rb_node *nd,
 }
 
 static struct rb_node *hists__filter_prev_entries(struct rb_node *nd,
- struct hists *hists,
  float min_pcnt)
 {
while (nd != NULL) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
-   float percent = h->stat.period * 100.0 /
-   hists->stats.total_period;
+   float percent = hist_entry__get_percent_limit(h);
 
if (!h->filtered && percent >= min_pcnt)
return nd;
@@ -902,14 +895,14 @@ static void ui_browser__hists_seek(struct ui_browser 
*browser,
switch (whence) {
case SEEK_SET:
nd = hists__filter_entries(rb_first(browser->entries),
-  hb->hists, hb->min_pcnt);
+  hb->min_pcnt);
break;
case SEEK_CUR:
nd = browser->top;
goto do_offset;
case SEEK_END:
nd = hists__filter_prev_entries(rb_last(browser->entries),
-   hb->hists, hb->min_pcnt);
+   hb->min_pcnt);
first = false;
break;
default:
@@ -952,8 +945,7 @@ do_offset:
break;
}
}
-   nd = hists__filter_entries(rb_next(nd), hb->hists,
-  hb->min_pcnt);
+   nd = hists__filter_entries(rb_next(nd), hb->min_pcnt);
if (nd == NULL)
break;
--offset;
@@ -986,7 +978,7 @@ do_offset:
}
}
 
-   nd = hists__filter_prev_entries(rb_prev(nd), hb->hists,
+   nd = hists__filter_prev_entries(rb_prev(nd),
hb->min_pcnt);
if (nd == NULL)
break;
@@ -1157,7 +1149,6 @@ static int hist_browser__fprintf_entry(struct 
hist_browser *browser,
 static int hist_browser__fprintf(struct hist_browser *browser, FILE *fp)
 {
struct rb_node *nd = hists__filter_entries(rb_first(browser->b.entries),
-  browser->hists,
   browser->min_pcnt);
int printed = 0;
 
@@ -1165,8 +1156,7 @@ static int hist_browser__fprintf(struct hist_browser 
*browser, FILE *fp)
   

[PATCH 24/24] perf tools: Enable --children option by default

2014-01-13 Thread Namhyung Kim
Now perf top and perf report will show children column by default if
it has callchain information.

Requested-by: Ingo Molnar 
Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/symbol.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 39ce9adbaaf0..186dca9df434 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -29,11 +29,12 @@ int vmlinux_path__nr_entries;
 char **vmlinux_path;
 
 struct symbol_conf symbol_conf = {
-   .use_modules  = true,
-   .try_vmlinux_path = true,
-   .annotate_src = true,
-   .demangle = true,
-   .symfs= "",
+   .use_modules= true,
+   .try_vmlinux_path   = true,
+   .annotate_src   = true,
+   .demangle   = true,
+   .cumulate_callchain = true,
+   .symfs  = "",
 };
 
 static enum dso_binary_type binary_type_symtab[] = {
-- 
1.7.11.7

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


[PATCH 17/24] perf tools: Add more hpp helper functions

2014-01-13 Thread Namhyung Kim
Sometimes it needs to disable some columns at runtime.  Add help
functions to support that.

Cc: Jiri Olsa 
Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/ui/hist.c   | 17 +
 tools/perf/util/hist.h |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index eb9c07bcdb01..1f9e25211da2 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -275,12 +275,29 @@ void perf_hpp__column_register(struct perf_hpp_fmt 
*format)
list_add_tail(&format->list, &perf_hpp__list);
 }
 
+void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
+{
+   list_del(&format->list);
+}
+
 void perf_hpp__column_enable(unsigned col)
 {
BUG_ON(col >= PERF_HPP__MAX_INDEX);
perf_hpp__column_register(&perf_hpp__format[col]);
 }
 
+void perf_hpp__column_disable(unsigned col)
+{
+   BUG_ON(col >= PERF_HPP__MAX_INDEX);
+   perf_hpp__column_unregister(&perf_hpp__format[col]);
+}
+
+void perf_hpp__cancel_cumulate(void)
+{
+   perf_hpp__column_disable(PERF_HPP__OVERHEAD_ACC);
+   perf_hpp__format[PERF_HPP__OVERHEAD].header = hpp__header_overhead;
+}
+
 int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size,
  struct hists *hists)
 {
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 421c2d809769..1a91d536e443 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -209,7 +209,10 @@ enum {
 
 void perf_hpp__init(void);
 void perf_hpp__column_register(struct perf_hpp_fmt *format);
+void perf_hpp__column_unregister(struct perf_hpp_fmt *format);
 void perf_hpp__column_enable(unsigned col);
+void perf_hpp__column_disable(unsigned col);
+void perf_hpp__cancel_cumulate(void);
 
 static inline size_t perf_hpp__use_color(void)
 {
-- 
1.7.11.7

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


[PATCH 04/24] perf hists: Convert hist entry functions to use struct he_stat

2014-01-13 Thread Namhyung Kim
hist_entry__add_cpumode_period() and hist_entry__decay() are dealing
with hist_entry's stat fields only.  So make them use the struct
directly.

Acked-by: Jiri Olsa 
Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/hist.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 81565b6bf828..d60ea8da342c 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -175,21 +175,21 @@ void hists__output_recalc_col_len(struct hists *hists, 
int max_rows)
}
 }
 
-static void hist_entry__add_cpumode_period(struct hist_entry *he,
-  unsigned int cpumode, u64 period)
+static void he_stat__add_cpumode_period(struct he_stat *he_stat,
+   unsigned int cpumode, u64 period)
 {
switch (cpumode) {
case PERF_RECORD_MISC_KERNEL:
-   he->stat.period_sys += period;
+   he_stat->period_sys += period;
break;
case PERF_RECORD_MISC_USER:
-   he->stat.period_us += period;
+   he_stat->period_us += period;
break;
case PERF_RECORD_MISC_GUEST_KERNEL:
-   he->stat.period_guest_sys += period;
+   he_stat->period_guest_sys += period;
break;
case PERF_RECORD_MISC_GUEST_USER:
-   he->stat.period_guest_us += period;
+   he_stat->period_guest_us += period;
break;
default:
break;
@@ -216,10 +216,10 @@ static void he_stat__add_stat(struct he_stat *dest, 
struct he_stat *src)
dest->weight+= src->weight;
 }
 
-static void hist_entry__decay(struct hist_entry *he)
+static void he_stat__decay(struct he_stat *he_stat)
 {
-   he->stat.period = (he->stat.period * 7) / 8;
-   he->stat.nr_events = (he->stat.nr_events * 7) / 8;
+   he_stat->period = (he_stat->period * 7) / 8;
+   he_stat->nr_events = (he_stat->nr_events * 7) / 8;
/* XXX need decay for weight too? */
 }
 
@@ -230,7 +230,7 @@ static bool hists__decay_entry(struct hists *hists, struct 
hist_entry *he)
if (prev_period == 0)
return true;
 
-   hist_entry__decay(he);
+   he_stat__decay(&he->stat);
 
if (!he->filtered)
hists->stats.total_period -= prev_period - he->stat.period;
@@ -397,7 +397,7 @@ static struct hist_entry *add_hist_entry(struct hists 
*hists,
rb_link_node(&he->rb_node_in, parent, p);
rb_insert_color(&he->rb_node_in, hists->entries_in);
 out:
-   hist_entry__add_cpumode_period(he, al->cpumode, period);
+   he_stat__add_cpumode_period(&he->stat, al->cpumode, period);
return he;
 }
 
-- 
1.7.11.7

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


[PATCH 09/24] perf report: Cache cumulative callchains

2014-01-13 Thread Namhyung Kim
It is possble that a callchain has cycles or recursive calls.  In that
case it'll end up having entries more than 100% overhead in the
output.  In order to prevent such entries, cache each callchain node
and skip if same entry already cumulated.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/hist.c | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index beb9f96e4e4f..1b477f8d2d17 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -708,7 +708,22 @@ static int
 iter_prepare_cumulative_entry(struct hist_entry_iter *iter __maybe_unused,
  struct addr_location *al __maybe_unused)
 {
+   struct hist_entry **he_cache;
+
callchain_cursor_commit(&callchain_cursor);
+
+   /*
+* This is for detecting cycles or recursions so that they're
+* cumulated only one time to prevent entries more than 100%
+* overhead.
+*/
+   he_cache = malloc(sizeof(*he_cache) * (PERF_MAX_STACK_DEPTH + 1));
+   if (he_cache == NULL)
+   return -ENOMEM;
+
+   iter->priv = he_cache;
+   iter->curr = 0;
+
return 0;
 }
 
@@ -718,6 +733,7 @@ iter_add_single_cumulative_entry(struct hist_entry_iter 
*iter,
 {
struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;
+   struct hist_entry **he_cache = iter->priv;
struct hist_entry *he;
 
he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL,
@@ -726,6 +742,8 @@ iter_add_single_cumulative_entry(struct hist_entry_iter 
*iter,
if (he == NULL)
return -ENOMEM;
 
+   he_cache[iter->curr++] = he;
+
return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
 }
 
@@ -750,7 +768,29 @@ iter_add_next_cumulative_entry(struct hist_entry_iter 
*iter,
 {
struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;
+   struct hist_entry **he_cache = iter->priv;
struct hist_entry *he;
+   struct hist_entry he_tmp = {
+   .cpu = al->cpu,
+   .thread = al->thread,
+   .comm = thread__comm(al->thread),
+   .ip = al->addr,
+   .ms = {
+   .map = al->map,
+   .sym = al->sym,
+   },
+   .parent = iter->parent,
+   };
+   int i;
+
+   /*
+* Check if there's duplicate entries in the callchain.
+* It's possible that it has cycles or recursive calls.
+*/
+   for (i = 0; i < iter->curr; i++) {
+   if (hist_entry__cmp(he_cache[i], &he_tmp) == 0)
+   return 0;
+   }
 
he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL,
sample->period, sample->weight,
@@ -758,6 +798,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
if (he == NULL)
return -ENOMEM;
 
+   he_cache[iter->curr++] = he;
+
return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
 }
 
@@ -771,6 +813,7 @@ iter_finish_cumulative_entry(struct hist_entry_iter *iter,
evsel->hists.stats.total_period += sample->period;
hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
 
+   zfree(&iter->priv);
return 0;
 }
 
-- 
1.7.11.7

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


[PATCH 07/24] perf hists: Accumulate hist entry stat based on the callchain

2014-01-13 Thread Namhyung Kim
Call __hists__add_entry() for each callchain node to get an
accumulated stat for an entry.  Introduce new cumulative_iter ops to
process them properly.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c |  2 ++
 tools/perf/util/hist.c  | 87 +
 tools/perf/util/hist.h  |  1 +
 3 files changed, 90 insertions(+)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b6618ecb474a..3ed0669d7620 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -114,6 +114,8 @@ static int process_sample_event(struct perf_tool *tool,
iter.ops = &hist_iter_branch;
else if (rep->mem_mode == 1)
iter.ops = &hist_iter_mem;
+   else if (symbol_conf.cumulate_callchain)
+   iter.ops = &hist_iter_cumulative;
else
iter.ops = &hist_iter_normal;
 
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 2e9dd5d4ca1d..46402fbf4c0e 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -704,6 +704,85 @@ iter_finish_normal_entry(struct hist_entry_iter *iter, 
struct addr_location *al)
 
return hist_entry__append_callchain(he, sample);
 }
+static int
+iter_prepare_cumulative_entry(struct hist_entry_iter *iter __maybe_unused,
+ struct addr_location *al __maybe_unused)
+{
+   callchain_cursor_commit(&callchain_cursor);
+   return 0;
+}
+
+static int
+iter_add_single_cumulative_entry(struct hist_entry_iter *iter,
+struct addr_location *al)
+{
+   struct perf_evsel *evsel = iter->evsel;
+   struct perf_sample *sample = iter->sample;
+   struct hist_entry *he;
+
+   he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL,
+   sample->period, sample->weight,
+   sample->transaction, true);
+   if (he == NULL)
+   return -ENOMEM;
+
+   return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
+}
+
+static int
+iter_next_cumulative_entry(struct hist_entry_iter *iter,
+  struct addr_location *al)
+{
+   struct callchain_cursor_node *node;
+
+   node = callchain_cursor_current(&callchain_cursor);
+   if (node == NULL)
+   return 0;
+
+   al->map = node->map;
+   al->sym = node->sym;
+   if (node->map)
+   al->addr = node->map->map_ip(node->map, node->ip);
+   else
+   al->addr = node->ip;
+
+   if (iter->hide_unresolved && al->sym == NULL)
+   return 0;
+
+   callchain_cursor_advance(&callchain_cursor);
+   return 1;
+}
+
+static int
+iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
+  struct addr_location *al)
+{
+   struct perf_evsel *evsel = iter->evsel;
+   struct perf_sample *sample = iter->sample;
+   struct hist_entry *he;
+
+   he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL,
+   sample->period, sample->weight,
+   sample->transaction, false);
+   if (he == NULL)
+   return -ENOMEM;
+
+   return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
+}
+
+static int
+iter_finish_cumulative_entry(struct hist_entry_iter *iter,
+struct addr_location *al __maybe_unused)
+{
+   struct perf_evsel *evsel = iter->evsel;
+   struct perf_sample *sample = iter->sample;
+
+   evsel->hists.stats.total_period += sample->period;
+   hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
+
+   return 0;
+}
+
 const struct hist_iter_ops hist_iter_mem = {
.prepare_entry  = iter_prepare_mem_entry,
.add_single_entry   = iter_add_single_mem_entry,
@@ -728,6 +807,14 @@ const struct hist_iter_ops hist_iter_normal = {
.finish_entry   = iter_finish_normal_entry,
 };
 
+const struct hist_iter_ops hist_iter_cumulative = {
+   .prepare_entry  = iter_prepare_cumulative_entry,
+   .add_single_entry   = iter_add_single_cumulative_entry,
+   .next_entry = iter_next_cumulative_entry,
+   .add_next_entry = iter_add_next_cumulative_entry,
+   .finish_entry   = iter_finish_cumulative_entry,
+};
+
 int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location 
*al,
 struct perf_evsel *evsel, const union perf_event 
*event,
 struct perf_sample *sample, int max_stack_depth)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index d482e673ecf5..091bf81df8c3 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -120,6 +120,7 @@ struct hist_entry_iter {
 extern const struct hist_iter_ops hist_iter_normal;
 extern const struct hist_iter_ops hist_iter_branch;

[PATCH 20/24] perf tools: Add callback function to hist_entry_iter

2014-01-13 Thread Namhyung Kim
The new ->add_entry_cb() will be called after an entry was added to
the histogram.  It's used for code sharing between perf report and
perf top.  Note that ops->add_*_entry() should set iter->he properly
in order to call the ->add_entry_cb.

Also pass @arg to the callback function.  It'll be used by perf top
later.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c | 30 +++---
 tools/perf/util/hist.c  | 45 +
 tools/perf/util/hist.h  |  6 +-
 3 files changed, 57 insertions(+), 24 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b8541ec61a00..3dbf2b83fc5e 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -87,6 +87,27 @@ static int report__config(const char *var, const char 
*value, void *cb)
return perf_default_config(var, value, cb);
 }
 
+static int hist_iter_cb(struct hist_entry_iter *iter,
+   struct addr_location *al, bool single,
+   void *arg __maybe_unused)
+{
+   int err;
+   struct hist_entry *he = iter->he;
+   struct perf_evsel *evsel = iter->evsel;
+   struct perf_sample *sample = iter->sample;
+
+   err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
+
+   if (!single)
+   goto out;
+
+   evsel->hists.stats.total_period += sample->period;
+   hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
+
+out:
+   return err;
+}
+
 static int process_sample_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
@@ -116,16 +137,19 @@ static int process_sample_event(struct perf_tool *tool,
iter.ops = &hist_iter_branch;
else if (rep->mem_mode == 1)
iter.ops = &hist_iter_mem;
-   else if (symbol_conf.cumulate_callchain)
+   else if (symbol_conf.cumulate_callchain) {
iter.ops = &hist_iter_cumulative;
-   else
+   iter.add_entry_cb = hist_iter_cb;
+   } else {
iter.ops = &hist_iter_normal;
+   iter.add_entry_cb = hist_iter_cb;
+   }
 
if (al.map != NULL)
al.map->dso->hit = 1;
 
ret = hist_entry_iter__add(&iter, &al, evsel, event, sample,
-  rep->max_stack);
+  rep->max_stack, NULL);
if (ret < 0)
pr_debug("problem adding hist entry, skipping event\n");
 
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index da4fbec3d0d8..b14fa143f7d7 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -683,11 +683,10 @@ iter_add_single_normal_entry(struct hist_entry_iter 
*iter, struct addr_location
 }
 
 static int
-iter_finish_normal_entry(struct hist_entry_iter *iter, struct addr_location 
*al)
+iter_finish_normal_entry(struct hist_entry_iter *iter,
+struct addr_location *al __maybe_unused)
 {
-   int err;
struct hist_entry *he = iter->he;
-   struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;
 
if (he == NULL)
@@ -695,13 +694,6 @@ iter_finish_normal_entry(struct hist_entry_iter *iter, 
struct addr_location *al)
 
iter->he = NULL;
 
-   err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
-   if (err)
-   return err;
-
-   evsel->hists.stats.total_period += sample->period;
-   hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
-
return hist_entry__append_callchain(he, sample);
 }
 static int
@@ -742,6 +734,7 @@ iter_add_single_cumulative_entry(struct hist_entry_iter 
*iter,
if (he == NULL)
return -ENOMEM;
 
+   iter->he = he;
he_cache[iter->curr++] = he;
 
callchain_append(he->callchain, &callchain_cursor, sample->period);
@@ -752,7 +745,7 @@ iter_add_single_cumulative_entry(struct hist_entry_iter 
*iter,
 */
callchain_cursor_commit(&callchain_cursor);
 
-   return hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
+   return 0;
 }
 
 static int
@@ -799,8 +792,11 @@ iter_add_next_cumulative_entry(struct hist_entry_iter 
*iter,
 * It's possible that it has cycles or recursive calls.
 */
for (i = 0; i < iter->curr; i++) {
-   if (hist_entry__cmp(he_cache[i], &he_tmp) == 0)
+   if (hist_entry__cmp(he_cache[i], &he_tmp) == 0) {
+   /* to avoid calling callback function */
+   iter->he = NULL;
return 0;
+   }
}
 
he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL,
@@ -809,24 +805,20 @@ iter_add_next_cumulative_entry(struct hist_entry_iter 
*iter,
if (he == NULL)
return -ENOMEM

[PATCH 15/24] perf ui/gtk: Add support to accumulated hist stat

2014-01-13 Thread Namhyung Kim
Print accumulated stat of a hist entry if requested.

Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/ui/gtk/hists.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 5b95c44f3435..49531c1c7121 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -98,11 +98,25 @@ static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt 
*fmt __maybe_unused,
return __hpp__color_fmt(hpp, he, he_get_##_field);  
\
 }
 
+#define __HPP_COLOR_ACC_PERCENT_FN(_type, _field)  
\
+static u64 he_get_acc_##_field(struct hist_entry *he)  
\
+{  
\
+   return he->stat_acc->_field;
\
+}  
\
+   
\
+static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt 
__maybe_unused,\
+  struct perf_hpp *hpp,
\
+  struct hist_entry *he)   
\
+{  
\
+   return __hpp__color_fmt(hpp, he, he_get_acc_##_field);  
\
+}
+
 __HPP_COLOR_PERCENT_FN(overhead, period)
 __HPP_COLOR_PERCENT_FN(overhead_sys, period_sys)
 __HPP_COLOR_PERCENT_FN(overhead_us, period_us)
 __HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys)
 __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us)
+__HPP_COLOR_ACC_PERCENT_FN(overhead_acc, period)
 
 #undef __HPP_COLOR_PERCENT_FN
 
@@ -121,6 +135,8 @@ void perf_gtk__init_hpp(void)
perf_gtk__hpp_color_overhead_guest_sys;
perf_hpp__format[PERF_HPP__OVERHEAD_GUEST_US].color =
perf_gtk__hpp_color_overhead_guest_us;
+   perf_hpp__format[PERF_HPP__OVERHEAD_ACC].color =
+   perf_gtk__hpp_color_overhead_acc;
 }
 
 static void callchain_list__sym_name(struct callchain_list *cl,
-- 
1.7.11.7

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


[PATCH 02/24] perf tools: Factor out sample__resolve_callchain()

2014-01-13 Thread Namhyung Kim
The report__resolve_callchain() can be shared with perf top code as it
doesn't really depend on the perf report code.  Factor it out as
sample__resolve_callchain().  The same goes to the hist_entry__append_
callchain() too.

Acked-by: Jiri Olsa 
Cc: Arun Sharma 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c | 24 +++-
 tools/perf/builtin-top.c| 22 +++---
 tools/perf/util/callchain.c | 23 +++
 tools/perf/util/callchain.h |  6 ++
 4 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1bb9e989c7bd..7ddea46594ae 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -85,24 +85,6 @@ static int report__config(const char *var, const char 
*value, void *cb)
return perf_default_config(var, value, cb);
 }
 
-static int report__resolve_callchain(struct report *rep, struct symbol 
**parent,
-struct perf_evsel *evsel, struct 
addr_location *al,
-struct perf_sample *sample)
-{
-   if ((sort__has_parent || symbol_conf.use_callchain) && 
sample->callchain) {
-   return machine__resolve_callchain(al->machine, evsel, 
al->thread, sample,
- parent, al, rep->max_stack);
-   }
-   return 0;
-}
-
-static int hist_entry__append_callchain(struct hist_entry *he, struct 
perf_sample *sample)
-{
-   if (!symbol_conf.use_callchain)
-   return 0;
-   return callchain_append(he->callchain, &callchain_cursor, 
sample->period);
-}
-
 static int report__add_mem_hist_entry(struct perf_tool *tool, struct 
addr_location *al,
  struct perf_sample *sample, struct 
perf_evsel *evsel,
  union perf_event *event)
@@ -113,7 +95,7 @@ static int report__add_mem_hist_entry(struct perf_tool 
*tool, struct addr_locati
struct hist_entry *he;
struct mem_info *mi, *mx;
uint64_t cost;
-   int err = report__resolve_callchain(rep, &parent, evsel, al, sample);
+   int err = sample__resolve_callchain(sample, &parent, evsel, al, 
rep->max_stack);
 
if (err)
return err;
@@ -165,7 +147,7 @@ static int report__add_branch_hist_entry(struct perf_tool 
*tool, struct addr_loc
unsigned i;
struct hist_entry *he;
struct branch_info *bi, *bx;
-   int err = report__resolve_callchain(rep, &parent, evsel, al, sample);
+   int err = sample__resolve_callchain(sample, &parent, evsel, al, 
rep->max_stack);
 
if (err)
return err;
@@ -218,7 +200,7 @@ static int report__add_hist_entry(struct perf_tool *tool, 
struct perf_evsel *evs
struct report *rep = container_of(tool, struct report, tool);
struct symbol *parent = NULL;
struct hist_entry *he;
-   int err = report__resolve_callchain(rep, &parent, evsel, al, sample);
+   int err = sample__resolve_callchain(sample, &parent, evsel, al, 
rep->max_stack);
 
if (err)
return err;
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 569dd87690ef..76cd510d34d0 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -743,15 +743,10 @@ static void perf_event__process_sample(struct perf_tool 
*tool,
if (al.sym == NULL || !al.sym->ignore) {
struct hist_entry *he;
 
-   if ((sort__has_parent || symbol_conf.use_callchain) &&
-   sample->callchain) {
-   err = machine__resolve_callchain(machine, evsel,
-al.thread, sample,
-&parent, &al,
-top->max_stack);
-   if (err)
-   return;
-   }
+   err = sample__resolve_callchain(sample, &parent, evsel, &al,
+   top->max_stack);
+   if (err)
+   return;
 
he = perf_evsel__add_hist_entry(evsel, &al, sample);
if (he == NULL) {
@@ -759,12 +754,9 @@ static void perf_event__process_sample(struct perf_tool 
*tool,
return;
}
 
-   if (symbol_conf.use_callchain) {
-   err = callchain_append(he->callchain, &callchain_cursor,
-  sample->period);
-   if (err)
-   return;
-   }
+   err = hist_entry__append_callchain(he, sample);
+   if (err)
+   return;
 
if (sort__has_sym)
perf_top__record_precise_ip(top, he, evsel-

Re: linux-next: manual merge of the tip tree with the net-next tree

2014-01-13 Thread David Miller
From: "H. Peter Anvin" 
Date: Mon, 13 Jan 2014 20:51:43 -0800

> Is there a sensible way we can fix this in either net-next or tip?

I think if I sort the files in net-next the problem will go away,
if someone can confirm this I'll do it.
--
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: linux-next: manual merge of the tip tree with the net-next tree

2014-01-13 Thread Stephen Rothwell
Hi,

On Mon, 13 Jan 2014 20:51:43 -0800 "H. Peter Anvin"  wrote:
>
> On 01/13/2014 07:02 PM, Stephen Rothwell wrote:
> > 
> > On Mon, 13 Jan 2014 14:20:59 +1100 Stephen Rothwell  
> > wrote:
> >> 
> >> On Mon, 13 Jan 2014 14:18:24 +1100 Stephen Rothwell 
> >>  wrote:
> >>> 
> >>> Today's linux-next merge of the tip tree got conflicts in 
> >>> arch/arc/include/asm/Kbuild, arch/cris/include/asm/Kbuild, 
> >>> arch/hexagon/include/asm/Kbuild,
> >>> arch/microblaze/include/asm/Kbuild, 
> >>> arch/parisc/include/asm/Kbuild and
> >>> arch/score/include/asm/Kbuild between commit e3fec2f74f7f
> >>> ("lib: Add missing arch generic-y entries for 
> >>> asm-generic/hash.h") from the net-next tree and commit
> >>> 93ea02bb8435 ("arch: Clean up asm/barrier.h implementations
> >>> using asm-generic/barrier.h") from the tip tree.
> >>> 
> >>> I fixed it up (see below) and can carry the fix as necessary
> >>> (no action is required).
> >>> 
> >>> BTW: thanks for not keeping the Kbuild files sorted :-(
> >> 
> >> I missed arch/mn10300/include/asm/Kbuild the first time round.
> > 
> > And ... git rerere does not work well here.  It stores resolutions
> > by a hash of the (sanitised) conflict and since most of these files
> > have exactly the same conflict, I am going to have to edit 5 of
> > them by hand every day.
> > 
> 
> Well, you probably can keep a diff from the conflict-merge tree to the
> fix, but still.
> 
> Is there a sensible way we can fix this in either net-next or tip?

Probably not now.  If the respective patches had kept those Kbuild files
sorted, then (most of the) conflicts would not have happened.

Maybe if there were follow up patches that put them back in order it may
help.  Or at least maybe make the conflicts different enough so that
git rerere would store them all.

I am just grumbling because I guessed this would happen when I saw the
patch go into the next-next tree (unfortunately, it was a report of mine
that caused that patch to be created :-().
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpTdpTuhsVtS.pgp
Description: PGP signature


Re: [PATCH v3 2/4] net_dma: revert 'copied_early'

2014-01-13 Thread David Miller
From: Dan Williams 
Date: Mon, 13 Jan 2014 16:47:14 -0800

> Now that tcp_dma_try_early_copy() is gone nothing ever sets
> copied_early.
> 
> Also reverts "53240c208776 tcp: Fix possible double-ack w/ user dma"
> since it is no longer necessary.
> 
> Cc: Ali Saidi 
> Cc: James Morris 
> Cc: Patrick McHardy 
> Cc: Eric Dumazet 
> Cc: David S. Miller 
> Cc: Alexey Kuznetsov 
> Cc: Hideaki YOSHIFUJI 
> Cc: Neal Cardwell 
> Reported-by: Dave Jones 
> Signed-off-by: Dan Williams 

Acked-by: David S. Miller 
--
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: ced1401: Fix dev_ messages

2014-01-13 Thread Joe Perches
Add a missing newline to each message.
Standardize style to "%s: ...", __func__.

Signed-off-by: Joe Perches 
---

There are a _lot_ of function tracing style
uses of dev_dbg that could/should be deleted.

This patch doesn't attempt to delete them.

 drivers/staging/ced1401/ced_ioc.c | 151 +++---
 drivers/staging/ced1401/usb1401.c | 188 +++---
 2 files changed, 171 insertions(+), 168 deletions(-)

diff --git a/drivers/staging/ced1401/ced_ioc.c 
b/drivers/staging/ced1401/ced_ioc.c
index bf532b1..573a283 100644
--- a/drivers/staging/ced1401/ced_ioc.c
+++ b/drivers/staging/ced1401/ced_ioc.c
@@ -38,8 +38,8 @@
 /
 static void FlushOutBuff(DEVICE_EXTENSION *pdx)
 {
-   dev_dbg(&pdx->interface->dev, "%s currentState=%d", __func__,
-   pdx->sCurrentState);
+   dev_dbg(&pdx->interface->dev, "%s: currentState=%d\n",
+   __func__, pdx->sCurrentState);
if (pdx->sCurrentState == U14ERR_TIME)  /* Do nothing if hardware in 
trouble */
return;
/* Kill off any pending I/O */
@@ -59,8 +59,8 @@ static void FlushOutBuff(DEVICE_EXTENSION *pdx)
 /
 static void FlushInBuff(DEVICE_EXTENSION *pdx)
 {
-   dev_dbg(&pdx->interface->dev, "%s currentState=%d", __func__,
-   pdx->sCurrentState);
+   dev_dbg(&pdx->interface->dev, "%s: currentState=%d\n",
+   __func__, pdx->sCurrentState);
if (pdx->sCurrentState == U14ERR_TIME)  /* Do nothing if hardware in 
trouble */
return;
/* Kill off any pending I/O */
@@ -118,8 +118,8 @@ int SendString(DEVICE_EXTENSION *pdx, const char __user 
*pData,
 
mutex_lock(&pdx->io_mutex); /*  Protect disconnect from new i/o */
if (n > 0) {/*  do nothing if nowt to do! */
-   dev_dbg(&pdx->interface->dev, "%s n=%d>%s<", __func__, n,
-   buffer);
+   dev_dbg(&pdx->interface->dev, "%s: n=%d>%s<\n",
+   __func__, n, buffer);
iReturn = PutChars(pdx, buffer, n);
}
 
@@ -139,7 +139,7 @@ int SendChar(DEVICE_EXTENSION *pdx, char c)
int iReturn;
mutex_lock(&pdx->io_mutex); /*  Protect disconnect from new i/o */
iReturn = PutChars(pdx, &c, 1);
-   dev_dbg(&pdx->interface->dev, "SendChar >%c< (0x%02x)", c, c);
+   dev_dbg(&pdx->interface->dev, "SendChar >%c< (0x%02x)\n", c, c);
Allowi(pdx);/*  Make sure char reads are running */
mutex_unlock(&pdx->io_mutex);
return iReturn;
@@ -174,7 +174,7 @@ int SendChar(DEVICE_EXTENSION *pdx, char c)
 int Get1401State(DEVICE_EXTENSION *pdx, __u32 *state, __u32 *error)
 {
int nGot;
-   dev_dbg(&pdx->interface->dev, "Get1401State() entry");
+   dev_dbg(&pdx->interface->dev, "%s: entry\n", __func__);
 
*state = 0x;/*  Start off with invalid state */
nGot = usb_control_msg(pdx->udev, usb_rcvctrlpipe(pdx->udev, 0),
@@ -182,15 +182,15 @@ int Get1401State(DEVICE_EXTENSION *pdx, __u32 *state, 
__u32 *error)
   pdx->statBuf, sizeof(pdx->statBuf), HZ);
if (nGot != sizeof(pdx->statBuf)) {
dev_err(&pdx->interface->dev,
-   "Get1401State() FAILED, return code %d", nGot);
+   "%s: FAILED, return code %d\n", __func__, nGot);
pdx->sCurrentState = U14ERR_TIME;   /*  Indicate that 
things are very wrong indeed */
*state = 0; /*  Force status values to a known state */
*error = 0;
} else {
int nDevice;
dev_dbg(&pdx->interface->dev,
-   "Get1401State() Success, state: 0x%x, 0x%x",
-   pdx->statBuf[0], pdx->statBuf[1]);
+   "%s: Success, state: 0x%x, 0x%x\n",
+   __func__, pdx->statBuf[0], pdx->statBuf[1]);
 
*state = pdx->statBuf[0];   /*  Return the state values to 
the calling code */
*error = pdx->statBuf[1];
@@ -220,8 +220,8 @@ int Get1401State(DEVICE_EXTENSION *pdx, __u32 *state, __u32 
*error)
 /
 int ReadWrite_Cancel(DEVICE_EXTENSION *pdx)
 {
-   dev_dbg(&pdx->interface->dev, "ReadWrite_Cancel entry %d",
-   pdx->bStagedUrbPending);
+   dev_dbg(&pdx->interface->dev, "%s: entry %d\n",
+   __func__, pdx->bStagedUrbPending);
 #ifdef NOT_WRITTEN_YET
int ntStatus = STATUS_SUCCESS;
bool bResult = false;
@@ -231,7 +231,7 @@ int ReadWrite_Cancel(DEVICE_EXTENSION *pdx)
 
if (pdx->bStagedUrbPending) {   /*  anything to be cancelled? May need 
more... */
dev_info(&pdx->interface - dev,
-   

Re: [PATCH] mm/zswap: Check all pool pages instead of one pool pages

2014-01-13 Thread Minchan Kim
On Tue, Jan 14, 2014 at 01:50:22PM +0900, Minchan Kim wrote:
> Hello Bob,
> 
> On Tue, Jan 14, 2014 at 09:19:23AM +0800, Bob Liu wrote:
> > 
> > On 01/14/2014 07:35 AM, Minchan Kim wrote:
> > > Hello,
> > > 
> > > On Sat, Jan 11, 2014 at 03:43:07PM +0800, Cai Liu wrote:
> > >> zswap can support multiple swapfiles. So we need to check
> > >> all zbud pool pages in zswap.
> > > 
> > > True but this patch is rather costly that we should iterate
> > > zswap_tree[MAX_SWAPFILES] to check it. SIGH.
> > > 
> > > How about defining zswap_tress as linked list instead of static
> > > array? Then, we could reduce unnecessary iteration too much.
> > > 
> > 
> > But if use linked list, it might not easy to access the tree like this:
> > struct zswap_tree *tree = zswap_trees[type];
> 
> struct zswap_tree {
> ..
> ..
> struct list_head list;
> }
> 
> zswap_frontswap_init()
> {
> ..
> ..
> zswap_trees[type] = tree;
> list_add(&tree->list, &zswap_list);
> }
> 
> get_zswap_pool_pages(void)
> {
> struct zswap_tree *cur;
> list_for_each_entry(cur, &zswap_list, list) {
> pool_pages += zbud_get_pool_size(cur->pool);
> }
> return pool_pages;
> }
> 
> 
> > 
> > BTW: I'm still prefer to use dynamic pool size, instead of use
> > zswap_is_full(). AFAIR, Seth has a plan to replace the rbtree with radix
> > which will be more flexible to support this feature and page migration
> > as well.
> > 
> > > Other question:
> > > Why do we need to update zswap_pool_pages too frequently?
> > > As I read the code, I think it's okay to update it only when user
> > > want to see it by debugfs and zswap_is_full is called.
> > > So could we optimize it out?
> > > 
> > >>
> > >> Signed-off-by: Cai Liu 
> > 
> > Reviewed-by: Bob Liu 
> 
> Hmm, I really suprised you are okay in this code piece where we have
> unnecessary cost most of case(ie, most system has a swap device) in
> *mm* part.
> 
> Anyway, I don't want to merge this patchset.
> If Andrew merge it and anybody doesn't do right work, I will send a patch.
> Cai, Could you redo a patch?
> I don't want to intercept your credit.
> 
> Even, we could optimize to reduce the the number of call as I said in
> previous reply.

You did it already. Please write it out in description.

> 
> Thanks.
-- 
Kind regards,
Minchan Kim
--
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: linux-next: manual merge of the akpm-current tree with the tip tree

2014-01-13 Thread Davidlohr Bueso
On Tue, 2014-01-14 at 15:53 +1100, Stephen Rothwell wrote:
> Hi Andrew,
> 
> Today's linux-next merge of the akpm-current tree got a conflict in
> kernel/futex.c between commit a52b89ebb6d4 ("futexes: Increase hash table
> size for better performance") from the tip tree and commit 61beee6c76e5
> ("futex: switch to USER_DS for futex test") from the akpm-current tree.
> 
> I fixed it up (see below) and can carry the fix as necessary (no action
> is required).

Thanks Stephen. At least for my bits the fix seems ok. In the future,
though, changes to this evil file should be routed only through one
tree.

Thanks,
Davidlohr

--
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/rfc] perf on raspberry-pi without overflow interrupt

2014-01-13 Thread Vince Weaver
On Fri, 10 Jan 2014, Peter Zijlstra wrote:

> On Thu, Jan 09, 2014 at 11:08:47PM -0500, Vince Weaver wrote:
> > On Thu, 9 Jan 2014, Will Deacon wrote:
> > 
> > > I'd rather see it in the generic code if at all possible. Maybe we could 
> > > add
> > > a flags field to perf_pmu_register?
> > 
> > I can look into adding the check in generic code.
> 
> Adding something like this to the generic code would mean adding a
> struct pmu capabilities field and visiting all existing PMU
> implementations to properly fill this out.

I don't see an existing pmu capabilities struct... or do you mean
coming up with one?

Would it only hold an "overflow_interrupt_available" flag, or are
there other generic capabilities it would be handy to know about?

> There's a number of hardware PMU implementations that do not have an
> interrupt and would need to set this flag.

Well that can be added gradually, right?  Things wouldn't get any worse if 
we add a generic check without auditing all code, things will just behave 
the same as before for those architectures.

There is some subtlety here though.  On ARM (or at least rasp-pi) the 
overflow hardware is there, just no interrupt is hooked up.  So things 
like counter overflow are handled as long as overflows aren't faster than 
context switch time.  It's just sampled events aren't possible.

On architectures without overflow support at all (I've had such hardware; 
some SPARC machines, the Playstation 3 hypervisor) then counter overflow 
isn't possible without a periodic timer (sort of like what is done with 
Intel uncore).  Is that something that should be in generic code too?

Vince
--
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 akpm-current tree with the tip tree

2014-01-13 Thread Stephen Rothwell
Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in
kernel/futex.c between commit a52b89ebb6d4 ("futexes: Increase hash table
size for better performance") from the tip tree and commit 61beee6c76e5
("futex: switch to USER_DS for futex test") from the akpm-current 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 kernel/futex.c
index 3666aa0017ed,66d23727c6ab..
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@@ -63,7 -63,7 +63,8 @@@
  #include 
  #include 
  #include 
 +#include 
+ #include 
  
  #include 
  
@@@ -2845,19 -2734,9 +2846,20 @@@ SYSCALL_DEFINE6(futex, u32 __user *, ua
  
  static int __init futex_init(void)
  {
+   mm_segment_t fs;
u32 curval;
 -  int i;
 +  unsigned long i;
 +
 +#if CONFIG_BASE_SMALL
 +  futex_hashsize = 16;
 +#else
 +  futex_hashsize = roundup_pow_of_two(256 * num_possible_cpus());
 +#endif
 +
 +  futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues),
 + futex_hashsize, 0,
 + futex_hashsize < 256 ? 
HASH_SMALL : 0,
 + NULL, NULL, futex_hashsize, 
futex_hashsize);
  
/*
 * This will fail and we want it. Some arch implementations do
@@@ -2869,10 -2748,13 +2871,13 @@@
 * implementation, the non-functional ones will return
 * -ENOSYS.
 */
+   fs = get_fs();
+   set_fs(USER_DS);
if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
futex_cmpxchg_enabled = 1;
+   set_fs(fs);
  
 -  for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
 +  for (i = 0; i < futex_hashsize; i++) {
plist_head_init(&futex_queues[i].chain);
spin_lock_init(&futex_queues[i].lock);
}


pgp9uV8fY94nU.pgp
Description: PGP signature


Re: linux-next: manual merge of the tip tree with the net-next tree

2014-01-13 Thread H. Peter Anvin
On 01/13/2014 07:02 PM, Stephen Rothwell wrote:
> Hi all,
> 
> On Mon, 13 Jan 2014 14:20:59 +1100 Stephen Rothwell
>  wrote:
>> 
>> On Mon, 13 Jan 2014 14:18:24 +1100 Stephen Rothwell
>>  wrote:
>>> 
>>> Today's linux-next merge of the tip tree got conflicts in 
>>> arch/arc/include/asm/Kbuild, arch/cris/include/asm/Kbuild, 
>>> arch/hexagon/include/asm/Kbuild,
>>> arch/microblaze/include/asm/Kbuild, 
>>> arch/parisc/include/asm/Kbuild and
>>> arch/score/include/asm/Kbuild between commit e3fec2f74f7f
>>> ("lib: Add missing arch generic-y entries for 
>>> asm-generic/hash.h") from the net-next tree and commit
>>> 93ea02bb8435 ("arch: Clean up asm/barrier.h implementations
>>> using asm-generic/barrier.h") from the tip tree.
>>> 
>>> I fixed it up (see below) and can carry the fix as necessary
>>> (no action is required).
>>> 
>>> BTW: thanks for not keeping the Kbuild files sorted :-(
>> 
>> I missed arch/mn10300/include/asm/Kbuild the first time round.
> 
> And ... git rerere does not work well here.  It stores resolutions
> by a hash of the (sanitised) conflict and since most of these files
> have exactly the same conflict, I am going to have to edit 5 of
> them by hand every day.
> 

Well, you probably can keep a diff from the conflict-merge tree to the
fix, but still.

Is there a sensible way we can fix this in either net-next or tip?

-hpa


--
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 akpm-current tree with the char-misc tree

2014-01-13 Thread Stephen Rothwell
Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in
drivers/misc/mei/init.c between commit 33ec08263147 ("mei: revamp mei
reset state machine") from the char-misc tree and commit dd045dab2999
("drivers/misc/mei: ratelimit several error messages") from the
akpm-current 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 drivers/misc/mei/init.c
index cdd31c2a2a2b,edd3bb6a5df9..
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@@ -43,119 -43,41 +43,119 @@@ const char *mei_dev_state_str(int state
  #undef MEI_DEV_STATE
  }
  
 -void mei_device_init(struct mei_device *dev)
 -{
 -  /* setup our list array */
 -  INIT_LIST_HEAD(&dev->file_list);
 -  INIT_LIST_HEAD(&dev->device_list);
 -  mutex_init(&dev->device_lock);
 -  init_waitqueue_head(&dev->wait_hw_ready);
 -  init_waitqueue_head(&dev->wait_recvd_msg);
 -  init_waitqueue_head(&dev->wait_stop_wd);
 -  dev->dev_state = MEI_DEV_INITIALIZING;
  
 -  mei_io_list_init(&dev->read_list);
 -  mei_io_list_init(&dev->write_list);
 -  mei_io_list_init(&dev->write_waiting_list);
 -  mei_io_list_init(&dev->ctrl_wr_list);
 -  mei_io_list_init(&dev->ctrl_rd_list);
 +/**
 + * mei_cancel_work. Cancel mei background jobs
 + *
 + * @dev: the device structure
 + *
 + * returns 0 on success or < 0 if the reset hasn't succeeded
 + */
 +void mei_cancel_work(struct mei_device *dev)
 +{
 +  cancel_work_sync(&dev->init_work);
 +  cancel_work_sync(&dev->reset_work);
  
 -  INIT_DELAYED_WORK(&dev->timer_work, mei_timer);
 -  INIT_WORK(&dev->init_work, mei_host_client_init);
 +  cancel_delayed_work(&dev->timer_work);
 +}
 +EXPORT_SYMBOL_GPL(mei_cancel_work);
  
 -  INIT_LIST_HEAD(&dev->wd_cl.link);
 -  INIT_LIST_HEAD(&dev->iamthif_cl.link);
 -  mei_io_list_init(&dev->amthif_cmd_list);
 -  mei_io_list_init(&dev->amthif_rd_complete_list);
 +/**
 + * mei_reset - resets host and fw.
 + *
 + * @dev: the device structure
 + */
 +int mei_reset(struct mei_device *dev)
 +{
 +  enum mei_dev_state state = dev->dev_state;
 +  bool interrupts_enabled;
 +  int ret;
  
 -  bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX);
 -  dev->open_handle_count = 0;
 +  if (state != MEI_DEV_INITIALIZING &&
 +  state != MEI_DEV_DISABLED &&
 +  state != MEI_DEV_POWER_DOWN &&
 +  state != MEI_DEV_POWER_UP)
-   dev_warn(&dev->pdev->dev, "unexpected reset: dev_state = %s\n",
++  dev_warn_ratelimited(&dev->pdev->dev, "unexpected reset: 
dev_state = %s\n",
 +   mei_dev_state_str(state));
  
 -  /*
 -   * Reserving the first client ID
 -   * 0: Reserved for MEI Bus Message communications
 +  /* we're already in reset, cancel the init timer
 +   * if the reset was called due the hbm protocol error
 +   * we need to call it before hw start
 +   * so the hbm watchdog won't kick in
 */
 -  bitmap_set(dev->host_clients_map, 0, 1);
 +  mei_hbm_idle(dev);
 +
 +  /* enter reset flow */
 +  interrupts_enabled = state != MEI_DEV_POWER_DOWN;
 +  dev->dev_state = MEI_DEV_RESETTING;
 +
 +  dev->reset_count++;
 +  if (dev->reset_count > MEI_MAX_CONSEC_RESET) {
 +  dev_err(&dev->pdev->dev, "reset: reached maximal consecutive 
resets: disabling the device\n");
 +  dev->dev_state = MEI_DEV_DISABLED;
 +  return -ENODEV;
 +  }
 +
 +  ret = mei_hw_reset(dev, interrupts_enabled);
 +  /* fall through and remove the sw state even if hw reset has failed */
 +
 +  /* no need to clean up software state in case of power up */
 +  if (state != MEI_DEV_INITIALIZING &&
 +  state != MEI_DEV_POWER_UP) {
 +
 +  /* remove all waiting requests */
 +  mei_cl_all_write_clear(dev);
 +
 +  mei_cl_all_disconnect(dev);
 +
 +  /* wake up all readers and writers so they can be interrupted */
 +  mei_cl_all_wakeup(dev);
 +
 +  /* remove entry if already in list */
 +  dev_dbg(&dev->pdev->dev, "remove iamthif and wd from the file 
list.\n");
 +  mei_cl_unlink(&dev->wd_cl);
 +  mei_cl_unlink(&dev->iamthif_cl);
 +  mei_amthif_reset_params(dev);
 +  memset(&dev->wr_ext_msg, 0, sizeof(dev->wr_ext_msg));
 +  }
 +
 +
 +  dev->me_clients_num = 0;
 +  dev->rd_msg_hdr = 0;
 +  dev->wd_pending = false;
 +
 +  if (ret) {
 +  dev_err(&dev->pdev->dev, "hw_reset failed ret = %d\n", ret);
 +  dev->dev_state = MEI_DEV_DISABLED;
 +  return ret;
 +  }
 +
 +  if (state == MEI_DEV_POWER_DOWN) {
 +  dev_dbg(&dev->pdev->dev, "powering down: end of reset\n");
 +  dev->dev_state = MEI_DEV_DISABLE

Re: [PATCH] mm/zswap: Check all pool pages instead of one pool pages

2014-01-13 Thread Minchan Kim
Hello Bob,

On Tue, Jan 14, 2014 at 09:19:23AM +0800, Bob Liu wrote:
> 
> On 01/14/2014 07:35 AM, Minchan Kim wrote:
> > Hello,
> > 
> > On Sat, Jan 11, 2014 at 03:43:07PM +0800, Cai Liu wrote:
> >> zswap can support multiple swapfiles. So we need to check
> >> all zbud pool pages in zswap.
> > 
> > True but this patch is rather costly that we should iterate
> > zswap_tree[MAX_SWAPFILES] to check it. SIGH.
> > 
> > How about defining zswap_tress as linked list instead of static
> > array? Then, we could reduce unnecessary iteration too much.
> > 
> 
> But if use linked list, it might not easy to access the tree like this:
> struct zswap_tree *tree = zswap_trees[type];

struct zswap_tree {
..
..
struct list_head list;
}

zswap_frontswap_init()
{
..
..
zswap_trees[type] = tree;
list_add(&tree->list, &zswap_list);
}

get_zswap_pool_pages(void)
{
struct zswap_tree *cur;
list_for_each_entry(cur, &zswap_list, list) {
pool_pages += zbud_get_pool_size(cur->pool);
}
return pool_pages;
}


> 
> BTW: I'm still prefer to use dynamic pool size, instead of use
> zswap_is_full(). AFAIR, Seth has a plan to replace the rbtree with radix
> which will be more flexible to support this feature and page migration
> as well.
> 
> > Other question:
> > Why do we need to update zswap_pool_pages too frequently?
> > As I read the code, I think it's okay to update it only when user
> > want to see it by debugfs and zswap_is_full is called.
> > So could we optimize it out?
> > 
> >>
> >> Signed-off-by: Cai Liu 
> 
> Reviewed-by: Bob Liu 

Hmm, I really suprised you are okay in this code piece where we have
unnecessary cost most of case(ie, most system has a swap device) in
*mm* part.

Anyway, I don't want to merge this patchset.
If Andrew merge it and anybody doesn't do right work, I will send a patch.
Cai, Could you redo a patch?
I don't want to intercept your credit.

Even, we could optimize to reduce the the number of call as I said in
previous reply.

Thanks.

> 
> >> ---
> >>  mm/zswap.c |   18 +++---
> >>  1 file changed, 15 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/mm/zswap.c b/mm/zswap.c
> >> index d93afa6..2438344 100644
> >> --- a/mm/zswap.c
> >> +++ b/mm/zswap.c
> >> @@ -291,7 +291,6 @@ static void zswap_free_entry(struct zswap_tree *tree,
> >>zbud_free(tree->pool, entry->handle);
> >>zswap_entry_cache_free(entry);
> >>atomic_dec(&zswap_stored_pages);
> >> -  zswap_pool_pages = zbud_get_pool_size(tree->pool);
> >>  }
> >>  
> >>  /* caller must hold the tree lock */
> >> @@ -405,10 +404,24 @@ cleanup:
> >>  /*
> >>  * helpers
> >>  **/
> >> +static u64 get_zswap_pool_pages(void)
> >> +{
> >> +  int i;
> >> +  u64 pool_pages = 0;
> >> +
> >> +  for (i = 0; i < MAX_SWAPFILES; i++) {
> >> +  if (zswap_trees[i])
> >> +  pool_pages += zbud_get_pool_size(zswap_trees[i]->pool);
> >> +  }
> >> +  zswap_pool_pages = pool_pages;
> >> +
> >> +  return pool_pages;
> >> +}
> >> +
> >>  static bool zswap_is_full(void)
> >>  {
> >>return (totalram_pages * zswap_max_pool_percent / 100 <
> >> -  zswap_pool_pages);
> >> +  get_zswap_pool_pages());
> >>  }
> >>  
> >>  /*
> >> @@ -716,7 +729,6 @@ static int zswap_frontswap_store(unsigned type, 
> >> pgoff_t offset,
> >>  
> >>/* update stats */
> >>atomic_inc(&zswap_stored_pages);
> >> -  zswap_pool_pages = zbud_get_pool_size(tree->pool);
> >>  
> >>return 0;
> >>  
> >> -- 
> >> 1.7.10.4
> -- 
> Regards,
> -Bob
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org";> em...@kvack.org 

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


Re: next bio iters break discard?

2014-01-13 Thread Kent Overstreet
On Mon, Jan 13, 2014 at 11:06:33PM -0500, Martin K. Petersen wrote:
> > "Kent" == Kent Overstreet  writes:
> 
> Kent,
> 
> Kent> I think for discards we can deal with this easily enough -
> Kent> __blk_recalc_rq_segments() will have to special case them - but
> Kent> there's a similar (but worse) issue with WRITE_SAME, and looking
> Kent> at the code it does attempt to merge WRITE_SAME requests too.
> 
> DISCARD bios have no payload going down the stack. They get a payload
> attached in the sd driver and will therefore have a single bvec at
> completion time.
> 
> WRITE_SAME bios have a single bvec payload throughout their lifetime.
> 
> For both these types of requests we never attempt to merge the actual
> payloads. But the block range worked on may shrink or grow as the bio is
> split or merged going down the stack.
> 
> IOW, DISCARD, WRITE SAME and the impending COPY requests do not have a
> 1:1 mapping between the block range worked on and the size of any bvecs
> attached. Your recent changes must have changed the way we handled that
> in the past.

Yeah - but with WRITE_SAME bios, wouldn't we at least have to check that they're
writing the same data to merge them?
--
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/5] perf report: Add --percentage option

2014-01-13 Thread Namhyung Kim
The --percentage option is for controlling overhead percentage
displayed.  It can only receive either of "relative" or "absolute".

"relative" means it's relative to filtered entries only so that the
sum of shown entries will be always 100%.  "absolute" means it retains
original value before and after the filter applied.

  $ perf report -s comm
  # Overhead   Command
  #   
  #
  74.19%   cc1
   7.61%   gcc
   6.11%as
   4.35%sh
   4.14%  make
   1.13%fixdep
  ...

  $ perf report -s comm -c cc1,gcc --percentage absolute
  # Overhead   Command
  #   
  #
  74.19%   cc1
   7.61%   gcc

  $ perf report -s comm -c cc1,gcc --percentage relative
  # Overhead   Command
  #   
  #
  90.69%   cc1
   9.31%   gcc

Note that it has zero effect if no filter was applied.

Suggested-by: Arnaldo Carvalho de Melo 
Signed-off-by: Namhyung Kim 
---
 tools/perf/Documentation/perf-report.txt |  6 ++
 tools/perf/builtin-report.c  | 16 
 2 files changed, 22 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index 8eab8a4bdeb8..9a67a42356d6 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -237,6 +237,12 @@ OPTIONS
Do not show entries which have an overhead under that percent.
(Default: 0).
 
+--percentage::
+   Determine how to display the overhead percentage of filtered entries.
+   "relative" means it's relative to filtered entries only so that the
+   sum of shown entries will be always 100%.  "absolute" means it retains
+   original value before and after the filter applied.
+
 --header::
Show header information in the perf.data file.  This includes
various information like hostname, OS and perf version, cpu/mem
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 664a3dcdf0e0..535bd6745355 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -717,6 +717,20 @@ parse_percent_limit(const struct option *opt, const char 
*str,
return 0;
 }
 
+static int
+parse_percentage(const struct option *opt __maybe_unused, const char *str,
+int unset __maybe_unused)
+{
+   if (!strcmp(str, "relative"))
+   symbol_conf.filter_relative = true;
+   else if (!strcmp(str, "absolute"))
+   symbol_conf.filter_relative = false;
+   else
+   return -1;
+
+   return 0;
+}
+
 int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 {
struct perf_session *session;
@@ -839,6 +853,8 @@ int cmd_report(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"),
OPT_CALLBACK(0, "percent-limit", &report, "percent",
 "Don't show entries under that percent", 
parse_percent_limit),
+   OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
+"how to display percentage of filtered entries", 
parse_percentage),
OPT_END()
};
struct perf_data_file file = {
-- 
1.7.11.7

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


[PATCH 5/5] perf tools: Show absolute percentage by default

2014-01-13 Thread Namhyung Kim
Now perf report will show absolute percentage on filter entries by
default.

Suggested-by: Jiri Olsa 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/symbol.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index ac3d9748993c..39ce9adbaaf0 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -33,7 +33,6 @@ struct symbol_conf symbol_conf = {
.try_vmlinux_path = true,
.annotate_src = true,
.demangle = true,
-   .filter_relative  = true,
.symfs= "",
 };
 
-- 
1.7.11.7

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


[PATCHSET 0/5] perf tools: Update on filtered entries' percentage output

2014-01-13 Thread Namhyung Kim
Hello,

I added --percentage option to perf report to control display of
percentage of filtered entries.

 usage: perf report []

--percentage 
  how to display percentage of filtered entries

"relative" means it's relative to filtered entries only so that the
sum of shown entries will be always 100%.  "absolute" means it retains
original value before and after the filter applied.  In patch 5, I
made the "absolute" as default since it makes more sense IMHO.

  $ perf report -s comm
  # Overhead   Command
  #   
  #
  74.19%   cc1
   7.61%   gcc
   6.11%as
   4.35%sh
   4.14%  make
   1.13%fixdep
  ...

  $ perf report -s comm -c cc1,gcc --percentage absolute
  # Overhead   Command
  #   
  #
  74.19%   cc1
   7.61%   gcc

  $ perf report -s comm -c cc1,gcc --percentage relative
  # Overhead   Command
  #   
  #
  90.69%   cc1
   9.31%   gcc

Note that it has zero effect if no filter was applied.

I only added the option to perf report for now.  If it looks good to
you I'll add it to perf top too.

Any comments are welcome, thanks
Namhyung


Namhyung Kim (5):
  perf tools: Count filtered entries to total period also
  perf ui/tui: Add support for showing relative percentage
  perf report: Add --percentage option
  perf report: Add report.percentage config option
  perf tools: Show absolute percentage by default

 tools/perf/Documentation/perf-report.txt |  6 ++
 tools/perf/builtin-report.c  | 28 +++-
 tools/perf/util/event.c  | 18 --
 tools/perf/util/hist.c   | 27 ++-
 tools/perf/util/hist.h   |  7 +++
 tools/perf/util/symbol.h |  5 +++--
 6 files changed, 65 insertions(+), 26 deletions(-)

-- 
1.7.11.7

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


[PATCH 2/5] perf ui/tui: Add support for showing relative percentage

2014-01-13 Thread Namhyung Kim
When filtering by thread, dso or symbol on TUI it also update total
period so that the output shows different result than no filter - the
percentage changed to relative to filtered entries only.  Sometimes
(always?)  this is not desired since users might expect same results
with filter.

So change this behavior depends on symbol_conf.filter_relative value.

Signed-off-by: Namhyung Kim 
---
 tools/perf/util/hist.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 2d81f3aefad0..58c799d9b689 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -696,10 +696,11 @@ static void hists__remove_entry_filter(struct hists 
*hists, struct hist_entry *h
return;
 
++hists->nr_entries;
+   if (symbol_conf.filter_relative)
+   hists->stats.total_period += h->stat.period;
if (h->ms.unfolded)
hists->nr_entries += h->nr_rows;
h->row_offset = 0;
-   hists->stats.total_period += h->stat.period;
hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->stat.nr_events;
 
hists__calc_col_len(hists, h);
@@ -722,7 +723,9 @@ void hists__filter_by_dso(struct hists *hists)
 {
struct rb_node *nd;
 
-   hists->nr_entries = hists->stats.total_period = 0;
+   hists->nr_entries = 0;
+   if (symbol_conf.filter_relative)
+   hists->stats.total_period = 0;
hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
hists__reset_col_len(hists);
 
@@ -755,7 +758,9 @@ void hists__filter_by_thread(struct hists *hists)
 {
struct rb_node *nd;
 
-   hists->nr_entries = hists->stats.total_period = 0;
+   hists->nr_entries = 0;
+   if (symbol_conf.filter_relative)
+   hists->stats.total_period = 0;
hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
hists__reset_col_len(hists);
 
@@ -786,7 +791,9 @@ void hists__filter_by_symbol(struct hists *hists)
 {
struct rb_node *nd;
 
-   hists->nr_entries = hists->stats.total_period = 0;
+   hists->nr_entries = 0;
+   if (symbol_conf.filter_relative)
+   hists->stats.total_period = 0;
hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
hists__reset_col_len(hists);
 
-- 
1.7.11.7

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


[PATCH 4/5] perf report: Add report.percentage config option

2014-01-13 Thread Namhyung Kim
Add report.percentage option for setting default value of the
symbol_conf.filter_relative.  It affects the report output only if a
filter applied.

An user can write .perfconfig file like below to show absolute
percentage of filtered entries by default:

  $ cat ~/.perfconfig
  [report]
  percentage = absolute

And it can be changed through command line:

  $ perf report --percentage relative

Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 535bd6745355..1bb9e989c7bd 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -71,6 +71,16 @@ static int report__config(const char *var, const char 
*value, void *cb)
rep->min_percent = strtof(value, NULL);
return 0;
}
+   if (!strcmp(var, "report.percentage")) {
+   if (!strcmp(value, "relative"))
+   symbol_conf.filter_relative = true;
+   else if (!strcmp(value, "absolute"))
+   symbol_conf.filter_relative = false;
+   else
+   return -1;
+
+   return 0;
+   }
 
return perf_default_config(var, value, cb);
 }
-- 
1.7.11.7

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


[PATCH 1/5] perf tools: Count filtered entries to total period also

2014-01-13 Thread Namhyung Kim
Currently if a sample was filtered by command line option, it just
dropped.  But this affects final output in that the percentage can be
different since the filtered entries were not included to the total.

But user might want to see the original percentages when filter
applied so change the behavior depends on a new symbol_conf.filter_
relative value in order to be controlled by user later.

Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c |  2 +-
 tools/perf/util/event.c | 18 --
 tools/perf/util/hist.c  | 12 +++-
 tools/perf/util/hist.h  |  7 +++
 tools/perf/util/symbol.c|  1 +
 tools/perf/util/symbol.h|  5 +++--
 6 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 46864dd7eb83..664a3dcdf0e0 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -247,7 +247,7 @@ static int process_sample_event(struct perf_tool *tool,
return -1;
}
 
-   if (al.filtered || (rep->hide_unresolved && al.sym == NULL))
+   if (rep->hide_unresolved && al.sym == NULL)
return 0;
 
if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap))
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 1fc1c2f04772..f5a0bcd6be64 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -3,6 +3,7 @@
 #include "debug.h"
 #include "machine.h"
 #include "sort.h"
+#include "hist.h"
 #include "string.h"
 #include "strlist.h"
 #include "thread.h"
@@ -663,7 +664,7 @@ void thread__find_addr_map(struct thread *thread,
al->thread = thread;
al->addr = addr;
al->cpumode = cpumode;
-   al->filtered = false;
+   al->filtered = 0;
 
if (machine == NULL) {
al->map = NULL;
@@ -750,9 +751,6 @@ int perf_event__preprocess_sample(const union perf_event 
*event,
if (thread == NULL)
return -1;
 
-   if (thread__is_filtered(thread))
-   goto out_filtered;
-
dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), 
thread->tid);
/*
 * Have we already created the kernel maps for this machine?
@@ -767,6 +765,10 @@ int perf_event__preprocess_sample(const union perf_event 
*event,
 
thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
  sample->ip, al);
+
+   if (thread__is_filtered(thread))
+   al->filtered |= (1 << HIST_FILTER__THREAD);
+
dump_printf(" .. dso: %s\n",
al->map ? al->map->dso->long_name :
al->level == 'H' ? "[hypervisor]" : "");
@@ -782,7 +784,7 @@ int perf_event__preprocess_sample(const union perf_event 
*event,
   (dso->short_name != dso->long_name &&
strlist__has_entry(symbol_conf.dso_list,
   dso->long_name)
-   goto out_filtered;
+   al->filtered |= (1 << HIST_FILTER__DSO);
 
al->sym = map__find_symbol(al->map, al->addr,
   machine->symbol_filter);
@@ -791,11 +793,7 @@ int perf_event__preprocess_sample(const union perf_event 
*event,
if (symbol_conf.sym_list &&
(!al->sym || !strlist__has_entry(symbol_conf.sym_list,
al->sym->name)))
-   goto out_filtered;
-
-   return 0;
+   al->filtered |= (1 << HIST_FILTER__SYMBOL);
 
-out_filtered:
-   al->filtered = true;
return 0;
 }
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 4ed3e883240d..2d81f3aefad0 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -13,13 +13,6 @@ static bool hists__filter_entry_by_thread(struct hists 
*hists,
 static bool hists__filter_entry_by_symbol(struct hists *hists,
  struct hist_entry *he);
 
-enum hist_filter {
-   HIST_FILTER__DSO,
-   HIST_FILTER__THREAD,
-   HIST_FILTER__PARENT,
-   HIST_FILTER__SYMBOL,
-};
-
 struct callchain_param callchain_param = {
.mode   = CHAIN_GRAPH_REL,
.min_percent = 0.5,
@@ -329,8 +322,9 @@ void hists__inc_nr_entries(struct hists *hists, struct 
hist_entry *h)
if (!h->filtered) {
hists__calc_col_len(hists, h);
++hists->nr_entries;
-   hists->stats.total_period += h->stat.period;
}
+   if (!h->filtered || !symbol_conf.filter_relative)
+   hists->stats.total_period += h->stat.period;
 }
 
 static u8 symbol__parent_filter(const struct symbol *parent)
@@ -429,7 +423,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
.weight = weight,
},
.parent = sym_parent,
-   .filtered = symbol__parent_filter(sy

  1   2   3   4   5   6   7   8   9   10   >