Re: [PATCH] ver_linux: libcpp.patch

2015-10-01 Thread Greg KH
On Thu, Oct 01, 2015 at 09:17:42PM +0300, Alexander Kapshuk wrote:
> Neither 'libg++.so', nor 'libstdc++.so' were found where the current
> implementation expects them to be found in the distros below.
> 
> 
> Gentoo Linux
> Debian 6.0.10
> Oracle Linux Server release 7.1
> 
> The proposed implementation relies on 'ldconfig' to locate the libraries
> in question.  'Sed' is used to do the text processing.
> 
> 
> 
> Signed-off-by: Alexander Kapshuk 

These are great, thanks for breaking them all up into individual,
reviewable patches.

Unfortunately I have no idea what order to apply them in :(

Can you resend them as a patch series, properly numbered (i.e.
[PATCH XX/YY]) so that I have a chance to apply them correctly?

thanks,

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


[PATCH 1/5] Staging: rtl8192u: quoted strings split across lines

2015-10-01 Thread mike dupuis
This is a patch to fix up instances where quoted strings are split
across multiple lines in several instances in ieee80211_crypt_ccmp.c

Signed-off-by: Mike Dupuis 
---
 .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c  | 27 +-
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
index a661416..71e8ad5 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
@@ -73,8 +73,7 @@ static void *ieee80211_ccmp_init(int key_idx)
 
priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tfm)) {
-   printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
-  "crypto API aes\n");
+   printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate 
crypto API aes\n");
priv->tfm = NULL;
goto fail;
}
@@ -284,23 +283,22 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, 
int hdr_len, void *priv)
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
if (net_ratelimit()) {
-   printk(KERN_DEBUG "CCMP: received packet without ExtIV"
-  " flag from %pM\n", hdr->addr2);
+   printk(KERN_DEBUG "CCMP: received packet without ExtIV 
flag from %pM\n",
+   hdr->addr2);
}
key->dot11RSNAStatsCCMPFormatErrors++;
return -2;
}
keyidx >>= 6;
if (key->key_idx != keyidx) {
-   printk(KERN_DEBUG "CCMP: RX tkey->key_idx=%d frame "
-  "keyidx=%d priv=%p\n", key->key_idx, keyidx, priv);
+   printk(KERN_DEBUG "CCMP: RX tkey->key_idx=%d frame keyidx=%d 
priv=%p\n",
+   key->key_idx, keyidx, priv);
return -6;
}
if (!key->key_set) {
if (net_ratelimit()) {
-   printk(KERN_DEBUG "CCMP: received packet from %pM"
-  " with keyid=%d that does not have a configured"
-  " key\n", hdr->addr2, keyidx);
+   printk(KERN_DEBUG "CCMP: received packet from %pM with 
keyid=%d that does not have a configured key\n",
+   hdr->addr2, keyidx);
}
return -3;
}
@@ -315,8 +313,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
 
if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
if (net_ratelimit()) {
-   printk(KERN_DEBUG "CCMP: replay detected: STA=%pM"
-  " previous PN %pm received PN %pm\n",
+   printk(KERN_DEBUG "CCMP: replay detected: STA=%pM 
previous PN %pm received PN %pm\n",
   hdr->addr2, key->rx_pn, pn);
}
key->dot11RSNAStatsCCMPReplays++;
@@ -353,8 +350,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
 
if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
if (net_ratelimit()) {
-   printk(KERN_DEBUG "CCMP: decrypt failed: STA="
-   "%pM\n", hdr->addr2);
+   printk(KERN_DEBUG "CCMP: decrypt failed: 
STA=%pM\n",
+   hdr->addr2);
}
key->dot11RSNAStatsCCMPDecryptErrors++;
return -5;
@@ -429,9 +426,7 @@ static int ieee80211_ccmp_get_key(void *key, int len, u8 
*seq, void *priv)
 static char *ieee80211_ccmp_print_stats(char *p, void *priv)
 {
struct ieee80211_ccmp_data *ccmp = priv;
-   p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
-"tx_pn=%pm rx_pn=%pm "
-"format_errors=%d replays=%d decrypt_errors=%d\n",
+   p += sprintf(p, "key[%d] alg=CCMP key_set=%d tx_pn=%pm rx_pn=%pm 
format_errors=%d replays=%d decrypt_errors=%d\n",
 ccmp->key_idx, ccmp->key_set,
 ccmp->tx_pn, ccmp->rx_pn,
 ccmp->dot11RSNAStatsCCMPFormatErrors,
-- 
2.1.4


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
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] Staging: rtl8192u: missing blank lines after declarations

2015-10-01 Thread mike dupuis
This is a patch to add missing lines after variable decalarations
in two functions in ieee80211_crypt_ccmp.c

Signed-off-by: Mike Dupuis 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
index 71e8ad5..0404654 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
@@ -104,6 +104,7 @@ static void ieee80211_ccmp_deinit(void *priv)
 static inline void xor_block(u8 *b, u8 *a, size_t len)
 {
int i;
+
for (i = 0; i < len; i++)
b[i] ^= a[i];
 }
@@ -426,6 +427,7 @@ static int ieee80211_ccmp_get_key(void *key, int len, u8 
*seq, void *priv)
 static char *ieee80211_ccmp_print_stats(char *p, void *priv)
 {
struct ieee80211_ccmp_data *ccmp = priv;
+
p += sprintf(p, "key[%d] alg=CCMP key_set=%d tx_pn=%pm rx_pn=%pm 
format_errors=%d replays=%d decrypt_errors=%d\n",
 ccmp->key_idx, ccmp->key_set,
 ccmp->tx_pn, ccmp->rx_pn,
-- 
2.1.4


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
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] Staging: rtl8192u: Fix block comment formatting

2015-10-01 Thread mike dupuis
This is a patch to correct block comment formatting in two
instances in ieee80211_crypt_ccmp.c

Signed-off-by: Mike Dupuis 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
index 0404654..ca5139a 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
@@ -125,10 +125,9 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
fc = le16_to_cpu(hdr->frame_ctl);
a4_included = ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
   (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS));
-   /*
-   qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
-  (WLAN_FC_GET_STYPE(fc) & 0x08));
-   */
+   /* qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
+* (WLAN_FC_GET_STYPE(fc) & 0x08));
+*/
/* fixed by David :2006.9.6 */
qc_included = (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
   (WLAN_FC_GET_STYPE(fc) & 0x80);
@@ -146,7 +145,8 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
 * Flag (Include authentication header, M=3 (8-octet MIC),
 *   L=1 (2-octet Dlen))
 * Nonce: 0x00 | A2 | PN
-* Dlen */
+* Dlen
+*/
b0[0] = 0x59;
b0[1] = qc;
memcpy(b0 + 2, hdr->addr2, ETH_ALEN);
-- 
2.1.4


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
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] Staging: rtl8192u: Remove spaces at the start of lines

2015-10-01 Thread mike dupuis
This is a patch to correct indentation in one instance in
ieee80211_crypt_ccmp.c

Signed-off-by: Mike Dupuis 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
index c8aaab3..27ce481 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
@@ -71,7 +71,7 @@ static void *ieee80211_ccmp_init(int key_idx)
goto fail;
priv->key_idx = key_idx;
 
-   priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
+   priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tfm)) {
printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate 
crypto API aes\n");
priv->tfm = NULL;
-- 
2.1.4


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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


[PATCH v3] mtd: nand: pass page number to ecc->write_xxx() methods

2015-10-01 Thread Boris Brezillon
The ->read_xxx() methods are all passed the page number the NAND controller
is supposed to read, but ->write_xxx() do not have such a parameter.

This is a problem if we want to properly implement data
scrambling/randomization in order to mitigate MLC sensibility to repeated
pattern: to prevent bitflips in adjacent pages in the same block we need
to avoid repeating the same pattern at the same offset in those pages,
hence the randomizer/scrambler engine need to be passed the page value
in order to adapt its seed accordingly.

Moreover, adding the page parameter to the ->write_xxx() methods add some
consistency to the current API.

Signed-off-by: Boris Brezillon 
CC: Josh Wu 
CC: Ezequiel Garcia 
CC: Maxime Ripard 
CC: Greg Kroah-Hartman 
CC: Huang Shijie 
CC: Stefan Agner 
CC: de...@driverdev.osuosl.org
CC: linux-arm-ker...@lists.infradead.org
CC: linux-kernel@vger.kernel.org
---
Changes since v2:
- fixed compilation error in the gpmi driver
- compile tested all impacted drivers except the bf5xx_nand,
  fsl_elbc_nand and fsl_ifc_nand ones

Changes since v1:
- rebased on l2-mtd/master
- fixed compilation error in the docg4 driver
---
 drivers/mtd/nand/atmel_nand.c |  6 --
 drivers/mtd/nand/bf5xx_nand.c |  3 ++-
 drivers/mtd/nand/brcmnand/brcmnand.c  |  4 ++--
 drivers/mtd/nand/cafe_nand.c  |  3 ++-
 drivers/mtd/nand/denali.c |  5 +++--
 drivers/mtd/nand/docg4.c  |  6 +++---
 drivers/mtd/nand/fsl_elbc_nand.c  |  4 ++--
 drivers/mtd/nand/fsl_ifc_nand.c   |  2 +-
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c|  8 +++
 drivers/mtd/nand/hisi504_nand.c   |  3 ++-
 drivers/mtd/nand/lpc32xx_mlc.c|  3 ++-
 drivers/mtd/nand/lpc32xx_slc.c|  5 +++--
 drivers/mtd/nand/nand_base.c  | 31 ++-
 drivers/mtd/nand/omap2.c  |  3 ++-
 drivers/mtd/nand/pxa3xx_nand.c|  3 ++-
 drivers/mtd/nand/sh_flctl.c   |  3 ++-
 drivers/mtd/nand/sunxi_nand.c |  5 +++--
 drivers/mtd/nand/vf610_nfc.c  |  2 +-
 drivers/staging/mt29f_spinand/mt29f_spinand.c |  3 ++-
 include/linux/mtd/nand.h  |  6 +++---
 20 files changed, 66 insertions(+), 42 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 46010bd..d0f50c9 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -954,7 +954,8 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,
 }
 
 static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
-   struct nand_chip *chip, const uint8_t *buf, int oob_required)
+   struct nand_chip *chip, const uint8_t *buf, int oob_required,
+   int page)
 {
struct atmel_nand_host *host = chip->priv;
uint32_t *eccpos = chip->ecc.layout->eccpos;
@@ -2005,7 +2006,8 @@ static int nfc_sram_write_page(struct mtd_info *mtd, 
struct nand_chip *chip,
 
if (likely(!raw))
/* Need to write ecc into oob */
-   status = chip->ecc.write_page(mtd, chip, buf, oob_required);
+   status = chip->ecc.write_page(mtd, chip, buf, oob_required,
+ page);
 
if (status < 0)
return status;
diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
index 4d8d4ba..17b3727 100644
--- a/drivers/mtd/nand/bf5xx_nand.c
+++ b/drivers/mtd/nand/bf5xx_nand.c
@@ -566,7 +566,8 @@ static int bf5xx_nand_read_page_raw(struct mtd_info *mtd, 
struct nand_chip *chip
 }
 
 static int bf5xx_nand_write_page_raw(struct mtd_info *mtd,
-   struct nand_chip *chip, const uint8_t *buf, int oob_required)
+   struct nand_chip *chip, const uint8_t *buf, int oob_required,
+   int page)
 {
bf5xx_nand_write_buf(mtd, buf, mtd->writesize);
bf5xx_nand_write_buf(mtd, chip->oob_poi, mtd->oobsize);
diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c 
b/drivers/mtd/nand/brcmnand/brcmnand.c
index 048e4e0..e577109 100644
--- a/drivers/mtd/nand/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/brcmnand/brcmnand.c
@@ -1606,7 +1606,7 @@ out:
 }
 
 static int brcmnand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-  const uint8_t *buf, int oob_required)
+  const uint8_t *buf, int oob_required, int page)
 {
struct brcmnand_host *host = chip->priv;
void *oob = oob_required ? chip->oob_poi : NULL;
@@ -1617,7 +1617,7 @@ static int brcmnand_write_page(struct mtd_info *mtd, 
struct nand_chip *chip,
 
 static int brcmnand_write_page_raw(struct mtd_info *mtd,
   struct nand_chip *chip, const uint8_t *buf,
-  int oob_required)
+  int oob_required, int page)
 

[PATCH 4/5] Staging: rtl8192u: Correct open brace placement

2015-10-01 Thread mike dupuis
This is a patch to move open braces to the appropriate lines in
two instances in ieee80211_crypt_ccmp.c

Signed-off-by: Mike Dupuis 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
index ca5139a..c8aaab3 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
@@ -229,8 +229,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
 
 
hdr = (struct rtl_80211_hdr_4addr *) skb->data;
-   if (!tcb_desc->bHwSec)
-   {
+   if (!tcb_desc->bHwSec) {
int blocks, last, len;
u8 *mic;
u8 *b0 = key->tx_b0;
@@ -320,8 +319,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
key->dot11RSNAStatsCCMPReplays++;
return -4;
}
-   if (!tcb_desc->bHwSec)
-   {
+   if (!tcb_desc->bHwSec) {
size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - 
CCMP_MIC_LEN;
u8 *mic = skb->data + skb->len - CCMP_MIC_LEN;
u8 *b0 = key->rx_b0;
-- 
2.1.4


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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


[PATCH 0/5] Staging: rtl8192u: checkpatch.pl issues

2015-10-01 Thread mike dupuis
This is a series of patches to correct several checkpatch.pl warnings
and errors in ieee80211_crypt_ccmp.c.

Checkpatch.pl before/after summary:
before: total: 2 errors, 23 warnings, 23 checks, 474 lines checked
after:  total: 0 errors, 10 warnings, 27 checks, 469 lines checked

Mike Dupuis (5):
  Staging: rtl8192u: quoted strings split across lines
  Staging: rtl8192u: missing blank lines after declarations
  Staging: rtl8192u: Fix block comment formatting
  Staging: rtl8192u: Correct open brace placement
  Staging: rtl8192u: Remove spaces at the start of lines

 .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c  | 47 ++
 1 file changed, 21 insertions(+), 26 deletions(-)

-- 
2.1.4


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
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] page-flags: hide PF_* validation check under separate config option

2015-10-01 Thread Kirill A. Shutemov
VM_BUG_ONs in PF_NO_TAIL() and PF_NO_COMPOUND() add 4+ KiB to
mm/build-in.o for DEBUG_VM kernel.

Let's hide them under new config option -- CONFIG_DEBUG_VM_PGFLAGS.
With the option enabled VM_BUG_ON_PGFLAGS() is equal to VM_BUG_ON_PAGE.

Signed-off-by: Kirill A. Shutemov 
---
 include/linux/mmdebug.h| 6 ++
 include/linux/page-flags.h | 8 +++-
 lib/Kconfig.debug  | 8 
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
index 877ef226f90f..c447d8055e50 100644
--- a/include/linux/mmdebug.h
+++ b/include/linux/mmdebug.h
@@ -55,4 +55,10 @@ void dump_mm(const struct mm_struct *mm);
 #define VIRTUAL_BUG_ON(cond) do { } while (0)
 #endif
 
+#ifdef CONFIG_DEBUG_VM_PGFLAGS
+#define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page)
+#else
+#define VM_BUG_ON_PGFLAGS(cond, page) BUILD_BUG_ON_INVALID(cond)
+#endif
+
 #endif
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 19e4129f00e5..8d6e4e9a98af 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -153,12 +153,10 @@ enum pageflags {
 #define PF_ANY(page, enforce)  page
 #define PF_HEAD(page, enforce) compound_head(page)
 #define PF_NO_TAIL(page, enforce) ({   \
-   if (enforce)\
-   VM_BUG_ON_PAGE(PageTail(page), page);   \
+   VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \
compound_head(page);})
-#define PF_NO_COMPOUND(page, enforce) ({   
\
-   if (enforce)\
-   VM_BUG_ON_PAGE(PageCompound(page), page);   \
+#define PF_NO_COMPOUND(page, enforce) ({   \
+   VM_BUG_ON_PGFLAGS(enforce && PageCompound(page), page); \
page;})
 
 /*
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e2894b23efb6..0d12bfa429de 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -570,6 +570,14 @@ config DEBUG_VM_RB
 
  If unsure, say N.
 
+config DEBUG_VM_PGFLAGS
+   bool "Debug page-flags operations"
+   depends on DEBUG_VM
+   help
+ Enables extra validation on page flags operations.
+
+ If unsure, say N.
+
 config DEBUG_VIRTUAL
bool "Debug VM translations"
depends on DEBUG_KERNEL && X86
-- 
2.5.1

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


Re: [PATCH v4 1/5] gadget: Introduce the notifier functions

2015-10-01 Thread Greg KH
On Thu, Oct 01, 2015 at 12:29:32PM -0500, Felipe Balbi wrote:
> On Thu, Sep 24, 2015 at 10:39:23AM -0700, Baolin Wang wrote:
> > The usb charger framework is based on usb gadget. The usb charger
> > need to be notified the state changing of usb gadget to confirm the
> > usb charger state.
> > 
> > Thus this patch adds a notifier mechanism for usb gadget to report a
> > event to usb charger when the usb gadget state is changed.
> > 
> > Signed-off-by: Baolin Wang 
> > ---
> >  drivers/usb/gadget/udc/udc-core.c | 32 
> >  include/linux/usb/gadget.h| 18 ++
> >  2 files changed, 50 insertions(+)
> > 
> > diff --git a/drivers/usb/gadget/udc/udc-core.c 
> > b/drivers/usb/gadget/udc/udc-core.c
> > index f660afb..4238fc3 100644
> > --- a/drivers/usb/gadget/udc/udc-core.c
> > +++ b/drivers/usb/gadget/udc/udc-core.c
> > @@ -129,6 +129,32 @@ void usb_gadget_giveback_request(struct usb_ep *ep,
> >  }
> >  EXPORT_SYMBOL_GPL(usb_gadget_giveback_request);
> >  
> > +int usb_gadget_register_notify(struct usb_gadget *gadget,
> > +  struct notifier_block *nb)
> > +{
> > +   int ret;
> > +
> > +   mutex_lock(>lock);
> > +   ret = raw_notifier_chain_register(>nh, nb);
> > +   mutex_unlock(>lock);
> > +
> > +   return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(usb_gadget_register_notify);
> > +
> > +int usb_gadget_unregister_notify(struct usb_gadget *gadget,
> > +struct notifier_block *nb)
> > +{
> > +   int ret;
> > +
> > +   mutex_lock(>lock);
> > +   ret = raw_notifier_chain_unregister(>nh, nb);
> 
> Greg, this is the kind of thing I wanted to avoid adding more of.
> 
> I was wondering if you would accept subsystems using kdbus for
> this sort of notification. I'm okay waiting for kdbus for another
> couple merge windows (if we have to) before that's merged, but
> if we take this raw notifier approach now, we will end up having
> to support it forever.

kdbus is userspace <-> userspace messages, it doesn't do kernel <->
userspace messages, sorry.

> Also, because soon enough we will have to support USB Power Delivery
> with Type C connector, this is bound to change in the coming months.
> 
> Frankly, I wanted all of this to be decided in userland with the
> kernel just providing notification and basic safety checks (we don't
> want to allow a bogus userspace daemon frying anybody's devices).
> 
> How would you feel about that ?

I agree I don't like new notifier chains being added, but as this is all
in-kernel, we can change the api in the future and there would not be a
problem, right?

And yeah, I'm worried about the USB Power delivery patches, I haven't
seen them yet, but I hear about different groups doing different things
here, and that worries me.

thanks,

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


[PATCH 2/3] page-flags: add documentation for policies

2015-10-01 Thread Kirill A. Shutemov
The patch adds description for page flags policies.

Signed-off-by: Kirill A. Shutemov 
---
 include/linux/page-flags.h | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 465ca42af633..19e4129f00e5 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -133,7 +133,23 @@ enum pageflags {
 
 #ifndef __GENERATING_BOUNDS_H
 
-/* Page flags policies wrt compound pages */
+/*
+ * Page flags policies wrt compound pages
+ *
+ * PF_ANY:
+ * the page flag is relevant for small, head and tail pages.
+ *
+ * PF_HEAD:
+ * for compound page all operations related to the page flag applied to
+ * head page.
+ *
+ * PF_NO_TAIL:
+ * modifications of the page flag must be done on small or head pages,
+ * checks can be done on tail pages too.
+ *
+ * PF_NO_COMPOUND:
+ * the page flag is not relevant for compound pages.
+ */
 #define PF_ANY(page, enforce)  page
 #define PF_HEAD(page, enforce) compound_head(page)
 #define PF_NO_TAIL(page, enforce) ({   \
-- 
2.5.1

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


[PATCH 0/3] page-flags updates

2015-10-01 Thread Kirill A. Shutemov
Few updates based on Andrew's feedback.

Kirill A. Shutemov (3):
  page-flags: do not corrupt caller 'page' in PF_NO_TAIL
  page-flags: add documentation for policies
  page-flags: hide PF_* validation check under separate config option

 include/linux/mmdebug.h|  6 ++
 include/linux/page-flags.h | 30 +-
 lib/Kconfig.debug  |  8 
 3 files changed, 35 insertions(+), 9 deletions(-)

-- 
2.5.1

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


[PATCH 1/3] page-flags: do not corrupt caller 'page' in PF_NO_TAIL

2015-10-01 Thread Kirill A. Shutemov
Andrew noticed that PF_NO_TAIL() modifies caller's 'page'. This doesn't
trigger any bad results, because all users are inline functions which
doesn't use the variable beyond the point. But still not good.

The patch changes PF_NO_TAIL() to always return head page, regardless
'enforce'. This makes operations of page flags with PF_NO_TAIL more
symmetrical: modifications and checks goes to head page. It gives
better chance to recover in case of bug for non-DEBUG_VM kernel.

DEBUG_VM kernel will still trigger VM_BUG_ON() on modifications to tail
pages.

Signed-off-by: Kirill A. Shutemov 
---
 include/linux/page-flags.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 2a2391c21558..465ca42af633 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -139,9 +139,7 @@ enum pageflags {
 #define PF_NO_TAIL(page, enforce) ({   \
if (enforce)\
VM_BUG_ON_PAGE(PageTail(page), page);   \
-   else\
-   page = compound_head(page); \
-   page;})
+   compound_head(page);})
 #define PF_NO_COMPOUND(page, enforce) ({   
\
if (enforce)\
VM_BUG_ON_PAGE(PageCompound(page), page);   \
-- 
2.5.1

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


[RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask

2015-10-01 Thread Namhyung Kim
It is more convenient saving mmap length rather than (bit) mask.  With
this patch, we can eliminate dependency to perf_evlist other than
getting mmap_desc for dealing with mmaps.  The mask and length can be
converted using perf_evlist__mmap_mask/len().

Cc: Jiri Olsa 
Cc: Adrian Hunter 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/evlist.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index c5180a29db1b..e46adcd5b408 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -29,6 +29,8 @@
 
 static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx);
 static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx);
+static size_t perf_evlist__mmap_mask(size_t len);
+static size_t perf_evlist__mmap_len(size_t mask);
 
 #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
 #define SID(e, x, y) xyarray__entry(e->sample_id, x, y)
@@ -871,7 +873,9 @@ void __weak auxtrace_mmap_params__set_idx(
 static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
 {
if (evlist->mmap[idx].base != NULL) {
-   munmap(evlist->mmap[idx].base, evlist->mmap_len);
+   size_t mmap_len = perf_evlist__mmap_len(evlist->mmap[idx].mask);
+
+   munmap(evlist->mmap[idx].base, mmap_len);
evlist->mmap[idx].base = NULL;
atomic_set(>mmap[idx].refcnt, 0);
}
@@ -901,8 +905,8 @@ static int perf_evlist__alloc_mmap(struct perf_evlist 
*evlist)
 }
 
 struct mmap_params {
-   int prot;
-   int mask;
+   int prot;
+   size_t  len;
struct auxtrace_mmap_params auxtrace_mp;
 };
 
@@ -924,8 +928,8 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, 
int idx,
 */
atomic_set(>mmap[idx].refcnt, 2);
evlist->mmap[idx].prev = 0;
-   evlist->mmap[idx].mask = mp->mask;
-   evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, mp->prot,
+   evlist->mmap[idx].mask = perf_evlist__mmap_mask(mp->len);
+   evlist->mmap[idx].base = mmap(NULL, mp->len, mp->prot,
  MAP_SHARED, fd, 0);
if (evlist->mmap[idx].base == MAP_FAILED) {
pr_debug2("failed to mmap perf event ring buffer, error %d\n",
@@ -1071,6 +1075,21 @@ static size_t perf_evlist__mmap_size(unsigned long pages)
return (pages + 1) * page_size;
 }
 
+static size_t perf_evlist__mmap_mask(size_t len)
+{
+   BUG_ON(len <= page_size);
+   BUG_ON((len % page_size) != 0);
+
+   return len - page_size - 1;
+}
+
+static size_t perf_evlist__mmap_len(size_t mask)
+{
+   BUG_ON(((mask + 1) % page_size) != 0);
+
+   return mask + 1 + page_size;
+}
+
 static long parse_pages_arg(const char *str, unsigned long min,
unsigned long max)
 {
@@ -1176,7 +1195,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, 
unsigned int pages,
evlist->overwrite = overwrite;
evlist->mmap_len = perf_evlist__mmap_size(pages);
pr_debug("mmap size %zuB\n", evlist->mmap_len);
-   mp.mask = evlist->mmap_len - page_size - 1;
+   mp.len = evlist->mmap_len;
 
auxtrace_mmap_params__init(_mp, evlist->mmap_len,
   auxtrace_pages, auxtrace_overwrite);
-- 
2.6.0

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


[RFC/PATCH 05/38] perf tools: Create separate mmap for dummy tracking event

2015-10-01 Thread Namhyung Kim
When indexed data file support is enabled, a dummy tracking event will
be used to track metadata (like task, comm and mmap events) for a
session and actual samples will be recorded in separate (intermediate)
files and then merged (with index table).

Provide separate mmap to the dummy tracking event.  The size is fixed
to 128KiB (+ 1 page) as the event rate will be lower than samples.  I
originally wanted to use a single mmap for this but cross-cpu sharing
is prohibited so it's per-cpu (or per-task) like normal mmaps.

Cc: Adrian Hunter 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-record.c |   2 +-
 tools/perf/util/evlist.c| 106 ++--
 tools/perf/util/evlist.h|   9 
 3 files changed, 93 insertions(+), 24 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 0accac6e0812..33dc2eafe2b5 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -74,7 +74,7 @@ static int process_synthesized_event(struct perf_tool *tool,
 
 static int record__mmap_read(struct record *rec, int idx)
 {
-   struct perf_mmap *md = >evlist->mmap[idx];
+   struct perf_mmap *md = perf_evlist__mmap_desc(rec->evlist, idx);
u64 head = perf_mmap__read_head(md);
u64 old = md->prev;
unsigned char *data = md->base + page_size;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 8d31883cbeb8..25a9c3b5f473 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -743,7 +743,7 @@ static struct perf_evsel *perf_evlist__event2evsel(struct 
perf_evlist *evlist,
 
 union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
 {
-   struct perf_mmap *md = >mmap[idx];
+   struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
u64 head;
u64 old = md->prev;
unsigned char *data = md->base + page_size;
@@ -812,28 +812,38 @@ union perf_event *perf_evlist__mmap_read(struct 
perf_evlist *evlist, int idx)
 
 static bool perf_evlist__mmap_empty(struct perf_evlist *evlist, int idx)
 {
-   struct perf_mmap *md = >mmap[idx];
+   struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
 
-   return perf_mmap__read_head(md) == md->prev &&
-   evlist->auxtrace_mmap[idx].base == NULL;
+   if (perf_mmap__read_head(md) != md->prev)
+   return false;
+
+   if (idx >= 0)
+   return !evlist->auxtrace_mmap[idx].base;
+   return true;
 }
 
 static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx)
 {
-   atomic_inc(>mmap[idx].refcnt);
+   struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
+
+   atomic_inc(>refcnt);
 }
 
 static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx)
 {
-   BUG_ON(atomic_read(>mmap[idx].refcnt) == 0);
+   struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
+
+   BUG_ON(atomic_read(>refcnt) == 0);
 
-   if (atomic_dec_and_test(>mmap[idx].refcnt))
-   __perf_evlist__munmap(evlist, idx);
+   if (!atomic_dec_and_test(>refcnt))
+   return;
+
+   __perf_evlist__munmap(evlist, idx);
 }
 
 void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
 {
-   struct perf_mmap *md = >mmap[idx];
+   struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
 
if (!evlist->overwrite) {
u64 old = md->prev;
@@ -875,14 +885,15 @@ void __weak auxtrace_mmap_params__set_idx(
 
 static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
 {
-   if (evlist->mmap[idx].base != NULL) {
-   size_t mmap_len = perf_evlist__mmap_len(evlist->mmap[idx].mask);
+   struct perf_mmap *md = perf_evlist__mmap_desc(evlist, idx);
+
+   if (md->base != NULL) {
+   size_t mmap_len = perf_evlist__mmap_len(md->mask);
 
-   munmap(evlist->mmap[idx].base, mmap_len);
-   evlist->mmap[idx].base = NULL;
-   atomic_set(>mmap[idx].refcnt, 0);
+   munmap(md->base, mmap_len);
+   md->base = NULL;
+   atomic_set(>refcnt, 0);
}
-   auxtrace_mmap__munmap(>auxtrace_mmap[idx]);
 }
 
 void perf_evlist__munmap(struct perf_evlist *evlist)
@@ -892,13 +903,17 @@ void perf_evlist__munmap(struct perf_evlist *evlist)
if (evlist->mmap == NULL)
return;
 
-   for (i = 0; i < evlist->nr_mmaps; i++)
+   for (i = 0; i < evlist->nr_mmaps; i++) {
__perf_evlist__munmap(evlist, i);
+   auxtrace_mmap__munmap(>auxtrace_mmap[i]);
+   if (evlist->track_mmap)
+   __perf_evlist__munmap(evlist, track_mmap_idx(i));
+   }
 
zfree(>mmap);
 }
 
-static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
+static int perf_evlist__alloc_mmap(struct perf_evlist *evlist, bool track_mmap)
 {
evlist->nr_mmaps = cpu_map__nr(evlist->cpus);
if 

[RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist

2015-10-01 Thread Namhyung Kim
Since it's gonna share struct mmap with dummy tracking evsel to track
meta events only, let's move auxtrace out of struct perf_mmap.

Cc: Adrian Hunter 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-record.c |  4 ++--
 tools/perf/util/evlist.c| 30 +-
 tools/perf/util/evlist.h|  2 +-
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 5e01c070dbf2..0accac6e0812 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -220,7 +220,7 @@ static int record__auxtrace_read_snapshot_all(struct record 
*rec)
 
for (i = 0; i < rec->evlist->nr_mmaps; i++) {
struct auxtrace_mmap *mm =
-   >evlist->mmap[i].auxtrace_mmap;
+   >evlist->auxtrace_mmap[i];
 
if (!mm->base)
continue;
@@ -405,7 +405,7 @@ static int record__mmap_read_all(struct record *rec)
int rc = 0;
 
for (i = 0; i < rec->evlist->nr_mmaps; i++) {
-   struct auxtrace_mmap *mm = >evlist->mmap[i].auxtrace_mmap;
+   struct auxtrace_mmap *mm = >evlist->auxtrace_mmap[i];
 
if (rec->evlist->mmap[i].base) {
if (record__mmap_read(rec, i) != 0) {
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index e46adcd5b408..042dffc67986 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -810,9 +810,12 @@ union perf_event *perf_evlist__mmap_read(struct 
perf_evlist *evlist, int idx)
return event;
 }
 
-static bool perf_mmap__empty(struct perf_mmap *md)
+static bool perf_evlist__mmap_empty(struct perf_evlist *evlist, int idx)
 {
-   return perf_mmap__read_head(md) == md->prev && !md->auxtrace_mmap.base;
+   struct perf_mmap *md = >mmap[idx];
+
+   return perf_mmap__read_head(md) == md->prev &&
+   evlist->auxtrace_mmap[idx].base == NULL;
 }
 
 static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx)
@@ -838,7 +841,7 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, 
int idx)
perf_mmap__write_tail(md, old);
}
 
-   if (atomic_read(>refcnt) == 1 && perf_mmap__empty(md))
+   if (atomic_read(>refcnt) == 1 && perf_evlist__mmap_empty(evlist, 
idx))
perf_evlist__mmap_put(evlist, idx);
 }
 
@@ -879,7 +882,7 @@ static void __perf_evlist__munmap(struct perf_evlist 
*evlist, int idx)
evlist->mmap[idx].base = NULL;
atomic_set(>mmap[idx].refcnt, 0);
}
-   auxtrace_mmap__munmap(>mmap[idx].auxtrace_mmap);
+   auxtrace_mmap__munmap(>auxtrace_mmap[idx]);
 }
 
 void perf_evlist__munmap(struct perf_evlist *evlist)
@@ -901,7 +904,15 @@ static int perf_evlist__alloc_mmap(struct perf_evlist 
*evlist)
if (cpu_map__empty(evlist->cpus))
evlist->nr_mmaps = thread_map__nr(evlist->threads);
evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
-   return evlist->mmap != NULL ? 0 : -ENOMEM;
+   if (evlist->mmap == NULL)
+   return -ENOMEM;
+   evlist->auxtrace_mmap = calloc(evlist->nr_mmaps,
+  sizeof(struct auxtrace_mmap));
+   if (evlist->auxtrace_mmap == NULL) {
+   zfree(>mmap);
+   return -ENOMEM;
+   }
+   return 0;
 }
 
 struct mmap_params {
@@ -938,10 +949,6 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, 
int idx,
return -1;
}
 
-   if (auxtrace_mmap__mmap(>mmap[idx].auxtrace_mmap,
-   >auxtrace_mp, evlist->mmap[idx].base, fd))
-   return -1;
-
return 0;
 }
 
@@ -963,6 +970,11 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist 
*evlist, int idx,
*output = fd;
if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0)
return -1;
+
+   if (auxtrace_mmap__mmap(>auxtrace_mmap[idx],
+   >auxtrace_mp,
+   evlist->mmap[idx].base, fd))
+   return -1;
} else {
if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
return -1;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 414e383885f5..51574ce8ac69 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -30,7 +30,6 @@ struct perf_mmap {
int  mask;
atomic_t refcnt;
u64  prev;
-   struct auxtrace_mmap auxtrace_mmap;
char event_copy[PERF_SAMPLE_MAX_SIZE] 
__attribute__((aligned(8)));
 };
 
@@ -53,6 +52,7 @@ struct perf_evlist {
} workload;
struct fdarray   pollfd;
struct perf_mmap 

Re: [RFC v2 6/7] powerpc: atomic: Make atomic{,64}_xchg and xchg a full barrier

2015-10-01 Thread Peter Zijlstra
On Fri, Oct 02, 2015 at 07:19:04AM +0800, Boqun Feng wrote:
> Hi Peter,
> 
> Please forgive me for the format of my reply. I'm travelling,
> and replying from my phone.
> 
> 2015年10月1日 下午7:28,"Peter Zijlstra" 写道:
> >
> > On Wed, Sep 16, 2015 at 11:49:34PM +0800, Boqun Feng wrote:
> > > According to memory-barriers.txt, xchg and its atomic{,64}_ versions
> > > need to imply a full barrier, however they are now just RELEASE+ACQUIRE,
> > > which is not a full barrier.
> > >
> > > So remove the definition of xchg(), and let __atomic_op_fence() build
> > > the full-barrier versions of these operations.
> >
> > Do you want to do a patch for -stable fixing the current implementation?
> 
> Good idea! I didn't think of this before, and I'd love to do the patch,
> but thing is that I'm not able to use my laptop until Oct 10th.
> I will send the patch once I'm back.
> Does that work for you?

Sure, no hurry.
--
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 08/38] perf tools: Handle indexed data file properly

2015-10-01 Thread Namhyung Kim
When perf detects data file has index table, process header part first
and then rest data files in a row.  Note that the indexed sample data is
recorded for each cpu/thread separately, it's already ordered with
respect to themselves so no need to use the ordered event queue
interface.

Signed-off-by: Namhyung Kim 
---
 tools/perf/perf.c |  1 +
 tools/perf/perf.h |  2 ++
 tools/perf/util/session.c | 55 +++
 3 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 1fded922bcc8..9664d84a9f8c 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -28,6 +28,7 @@ const char perf_more_info_string[] =
 int use_browser = -1;
 static int use_pager = -1;
 const char *input_name;
+bool perf_has_index;
 
 struct cmd_struct {
const char *cmd;
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 90129accffbe..f4b4d7d8752c 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -39,6 +39,8 @@ void pthread__unblock_sigwinch(void);
 
 #include "util/target.h"
 
+extern bool perf_has_index;
+
 struct record_opts {
struct target target;
bool group;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 428149bc64d2..91fa9647f565 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1586,7 +1586,9 @@ static int __perf_session__process_events(struct 
perf_session *session,
mmap_size = MMAP_SIZE;
if (mmap_size > file_size) {
mmap_size = file_size;
-   session->one_mmap = true;
+
+   if (!perf_has_index)
+   session->one_mmap = true;
}
 
memset(mmaps, 0, sizeof(mmaps));
@@ -1664,28 +1666,63 @@ out:
err = perf_session__flush_thread_stacks(session);
 out_err:
ui_progress__finish();
-   perf_session__warn_about_errors(session);
ordered_events__free(>ordered_events);
auxtrace__free_events(session);
session->one_mmap = false;
return err;
 }
 
+static int __perf_session__process_indexed_events(struct perf_session *session)
+{
+   struct perf_data_file *file = session->file;
+   struct perf_tool *tool = session->tool;
+   u64 size = perf_data_file__size(file);
+   int err = 0, i;
+
+   for (i = 0; i < (int)session->header.nr_index; i++) {
+   struct perf_file_section *idx = >header.index[i];
+
+   if (!idx->size)
+   continue;
+
+   /*
+* For indexed data file, samples are processed for
+* each cpu/thread so it's already ordered.  However
+* meta-events at index 0 should be processed in order.
+*/
+   if (i > 0)
+   tool->ordered_events = false;
+
+   err = __perf_session__process_events(session, idx->offset,
+idx->size, size);
+   if (err < 0)
+   break;
+   }
+
+   perf_session__warn_about_errors(session);
+   return err;
+}
+
 int perf_session__process_events(struct perf_session *session)
 {
-   u64 size = perf_data_file__size(session->file);
+   struct perf_data_file *file = session->file;
+   u64 size = perf_data_file__size(file);
int err;
 
if (perf_session__register_idle_thread(session) == NULL)
return -ENOMEM;
 
-   if (!perf_data_file__is_pipe(session->file))
-   err = __perf_session__process_events(session,
-
session->header.data_offset,
-session->header.data_size, 
size);
-   else
-   err = __perf_session__process_pipe_events(session);
+   if (perf_data_file__is_pipe(file))
+   return __perf_session__process_pipe_events(session);
+   if (perf_has_index)
+   return __perf_session__process_indexed_events(session);
+
+   err = __perf_session__process_events(session,
+session->header.data_offset,
+session->header.data_size,
+size);
 
+   perf_session__warn_about_errors(session);
return err;
 }
 
-- 
2.6.0

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


[RFC/PATCH 10/38] perf report: Skip dummy tracking event

2015-10-01 Thread Namhyung Kim
The dummy tracking event is only for tracking task/comom/mmap events
and has no sample data for itself.  So no need to report, just skip it.

Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c|  3 +++
 tools/perf/ui/browsers/hists.c | 30 --
 tools/perf/ui/gtk/hists.c  |  3 +++
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b5623639f67d..aeced4fa27e8 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -362,6 +362,9 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist 
*evlist,
struct hists *hists = evsel__hists(pos);
const char *evname = perf_evsel__name(pos);
 
+   if (perf_evsel__is_dummy_tracking(pos))
+   continue;
+
if (symbol_conf.event_group &&
!perf_evsel__is_group_leader(pos))
continue;
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index a4e9b370c037..c8227dbb0fcc 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2219,14 +2219,17 @@ out:
return key;
 }
 
-static bool filter_group_entries(struct ui_browser *browser __maybe_unused,
-void *entry)
+static bool filter_entries(struct ui_browser *browser __maybe_unused,
+  void *entry)
 {
struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node);
 
if (symbol_conf.event_group && !perf_evsel__is_group_leader(evsel))
return true;
 
+   if (perf_evsel__is_dummy_tracking(evsel))
+   return true;
+
return false;
 }
 
@@ -2243,7 +2246,7 @@ static int __perf_evlist__tui_browse_hists(struct 
perf_evlist *evlist,
.refresh= ui_browser__list_head_refresh,
.seek   = ui_browser__list_head_seek,
.write  = perf_evsel_menu__write,
-   .filter = filter_group_entries,
+   .filter = filter_entries,
.nr_entries = nr_entries,
.priv   = evlist,
},
@@ -2270,21 +2273,22 @@ int perf_evlist__tui_browse_hists(struct perf_evlist 
*evlist, const char *help,
  struct perf_env *env)
 {
int nr_entries = evlist->nr_entries;
+   struct perf_evsel *first = perf_evlist__first(evlist);
+   struct perf_evsel *pos;
 
 single_entry:
if (nr_entries == 1) {
-   struct perf_evsel *first = perf_evlist__first(evlist);
-
return perf_evsel__hists_browse(first, nr_entries, help,
false, hbt, min_pcnt,
env);
}
 
if (symbol_conf.event_group) {
-   struct perf_evsel *pos;
 
nr_entries = 0;
evlist__for_each(evlist, pos) {
+   if (perf_evsel__is_dummy_tracking(pos))
+   continue;
if (perf_evsel__is_group_leader(pos))
nr_entries++;
}
@@ -2293,6 +2297,20 @@ single_entry:
goto single_entry;
}
 
+   evlist__for_each(evlist, pos) {
+   if (perf_evsel__is_dummy_tracking(pos))
+   nr_entries--;
+   }
+
+   if (nr_entries == 1) {
+   evlist__for_each(evlist, pos) {
+   if (!perf_evsel__is_dummy_tracking(pos)) {
+   first = pos;
+   goto single_entry;
+   }
+   }
+   }
+
return __perf_evlist__tui_browse_hists(evlist, nr_entries, help,
   hbt, min_pcnt, env);
 }
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 4b3585eed1e8..83a7ecd5cda8 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -317,6 +317,9 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist 
*evlist,
char buf[512];
size_t size = sizeof(buf);
 
+   if (perf_evsel__is_dummy_tracking(pos))
+   continue;
+
if (symbol_conf.event_group) {
if (!perf_evsel__is_group_leader(pos))
continue;
-- 
2.6.0

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


Queueing b0a688ddcc50 "usb: musb: cppi41: allow it to work again" for -stable

2015-10-01 Thread Ezequiel Garcia
Hello,

Commit b0a688ddcc50 "usb: musb: cppi41: allow it to work again" seems
to fix a regression. It applies cleanly on v4.1 and removes the
"musb-hdrc musb-hdrc.1.auto: Need DT for the DMA engine." error.

Any chance you can queue it for -stable?

Thanks!
-- 
Ezequiel García, VanguardiaSur
www.vanguardiasur.com.ar
--
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 13/38] perf tools: Use thread__comm_by_time() when adding hist entries

2015-10-01 Thread Namhyung Kim
Now thread->comm can be handled with time properly, use it to find
the correct comm at the time when adding hist entries.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-annotate.c |  5 +++--
 tools/perf/builtin-diff.c |  8 
 tools/perf/tests/hists_link.c |  4 ++--
 tools/perf/util/hist.c| 19 ++-
 tools/perf/util/hist.h|  2 +-
 5 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 2bf9b3fd9e61..3afb858eac6e 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -47,7 +47,7 @@ struct perf_annotate {
 };
 
 static int perf_evsel__add_sample(struct perf_evsel *evsel,
- struct perf_sample *sample __maybe_unused,
+ struct perf_sample *sample,
  struct addr_location *al,
  struct perf_annotate *ann)
 {
@@ -72,7 +72,8 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return 0;
}
 
-   he = __hists__add_entry(hists, al, NULL, NULL, NULL, 1, 1, 0, true);
+   he = __hists__add_entry(hists, al, NULL, NULL, NULL, 1, 1, 0,
+   sample->time, true);
if (he == NULL)
return -ENOMEM;
 
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 0b180a885ba3..623ecc53c0c9 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -312,10 +312,10 @@ static int formula_fprintf(struct hist_entry *he, struct 
hist_entry *pair,
 
 static int hists__add_entry(struct hists *hists,
struct addr_location *al, u64 period,
-   u64 weight, u64 transaction)
+   u64 weight, u64 transaction, u64 timestamp)
 {
if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight,
-  transaction, true) != NULL)
+  transaction, timestamp, true) != NULL)
return 0;
return -ENOMEM;
 }
@@ -336,8 +336,8 @@ static int diff__process_sample_event(struct perf_tool 
*tool __maybe_unused,
return -1;
}
 
-   if (hists__add_entry(hists, , sample->period,
-sample->weight, sample->transaction)) {
+   if (hists__add_entry(hists, , sample->period, sample->weight,
+sample->transaction, sample->time)) {
pr_warning("problem incrementing symbol period, skipping 
event\n");
goto out_put;
}
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 8c102b011424..27bae90c9a95 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -90,7 +90,7 @@ static int add_hist_entries(struct perf_evlist *evlist, 
struct machine *machine)
goto out;
 
he = __hists__add_entry(hists, , NULL,
-   NULL, NULL, 1, 1, 0, true);
+   NULL, NULL, 1, 1, 0, -1, true);
if (he == NULL) {
addr_location__put();
goto out;
@@ -116,7 +116,7 @@ static int add_hist_entries(struct perf_evlist *evlist, 
struct machine *machine)
goto out;
 
he = __hists__add_entry(hists, , NULL,
-   NULL, NULL, 1, 1, 0, true);
+   NULL, NULL, 1, 1, 0, -1, true);
if (he == NULL) {
addr_location__put();
goto out;
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index c346b331b892..10454197a508 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -447,11 +447,11 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
  struct branch_info *bi,
  struct mem_info *mi,
  u64 period, u64 weight, u64 transaction,
- bool sample_self)
+ u64 timestamp, bool sample_self)
 {
struct hist_entry entry = {
.thread = al->thread,
-   .comm = thread__comm(al->thread),
+   .comm = thread__comm_by_time(al->thread, timestamp),
.ms = {
.map= al->map,
.sym= al->sym,
@@ -510,13 +510,14 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter, 
struct addr_location *al
 {
u64 cost;
struct mem_info *mi = iter->priv;
+   struct perf_sample *sample = iter->sample;
struct hists *hists 

[RFC/PATCH 15/38] perf tools: Introduce machine__find*_thread_by_time()

2015-10-01 Thread Namhyung Kim
With data file indexing is enabled, it needs to search thread based on
sample time since sample processing is done after other (task, comm and
mmap) events are processed.  This can be a problem if a session is very
long and pid is recycled - in that case it'll only see the last one.

So keep thread start time in it, and search thread based on the time.
This patch introduces machine__find{,new}_thread_by_time() function
for this.  It'll first search current (i.e. recent) thread rbtree and
then dead thread tree (and tid list).  If it couldn't find anyone,
it'll create a new (missing) thread.

The sample timestamp of 0 means that this is called from synthesized
event so just use current rbtree.  The timestamp will be -1 if sample
didn't record the timestamp so will see current threads automatically.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/tests/dwarf-unwind.c |   8 +--
 tools/perf/tests/hists_common.c |   3 +-
 tools/perf/tests/hists_link.c   |   2 +-
 tools/perf/util/event.c |   6 +-
 tools/perf/util/machine.c   | 126 +++-
 tools/perf/util/machine.h   |  10 +++-
 tools/perf/util/thread.c|   4 ++
 tools/perf/util/thread.h|   1 +
 8 files changed, 148 insertions(+), 12 deletions(-)

diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 40b36c462427..b9ca0a72fc4d 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -16,10 +16,10 @@
 
 static int mmap_handler(struct perf_tool *tool __maybe_unused,
union perf_event *event,
-   struct perf_sample *sample __maybe_unused,
+   struct perf_sample *sample,
struct machine *machine)
 {
-   return machine__process_mmap2_event(machine, event, NULL);
+   return machine__process_mmap2_event(machine, event, sample);
 }
 
 static int init_live_machine(struct machine *machine)
@@ -66,12 +66,10 @@ static int unwind_entry(struct unwind_entry *entry, void 
*arg)
 __attribute__ ((noinline))
 static int unwind_thread(struct thread *thread)
 {
-   struct perf_sample sample;
+   struct perf_sample sample = { .time = -1ULL, };
unsigned long cnt = 0;
int err = -1;
 
-   memset(, 0, sizeof(sample));
-
if (test__arch_unwind_sample(, thread)) {
pr_debug("failed to get unwind sample\n");
goto out;
diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c
index ce80b274b097..1d657fa2830f 100644
--- a/tools/perf/tests/hists_common.c
+++ b/tools/perf/tests/hists_common.c
@@ -80,6 +80,7 @@ static struct {
 struct machine *setup_fake_machine(struct machines *machines)
 {
struct machine *machine = machines__find(machines, HOST_KERNEL_ID);
+   struct perf_sample sample = { .time = -1ULL, };
size_t i;
 
if (machine == NULL) {
@@ -114,7 +115,7 @@ struct machine *setup_fake_machine(struct machines 
*machines)
strcpy(fake_mmap_event.mmap.filename,
   fake_mmap_info[i].filename);
 
-   machine__process_mmap_event(machine, _mmap_event, NULL);
+   machine__process_mmap_event(machine, _mmap_event, );
}
 
for (i = 0; i < ARRAY_SIZE(fake_symbols); i++) {
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 27bae90c9a95..cacc8617bf02 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -64,7 +64,7 @@ static int add_hist_entries(struct perf_evlist *evlist, 
struct machine *machine)
struct perf_evsel *evsel;
struct addr_location al;
struct hist_entry *he;
-   struct perf_sample sample = { .period = 1, };
+   struct perf_sample sample = { .period = 1, .time = -1ULL, };
size_t i = 0, k;
 
/*
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index cb98b5af9e17..3dff1b5cd4cc 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -9,6 +9,7 @@
 #include "strlist.h"
 #include "thread.h"
 #include "thread_map.h"
+#include "session.h"
 #include "symbol/kallsyms.h"
 
 static const char *perf_event__names[] = {
@@ -992,9 +993,10 @@ int perf_event__preprocess_sample(const union perf_event 
*event,
  struct perf_sample *sample)
 {
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
-   struct thread *thread = machine__findnew_thread(machine, sample->pid,
-   sample->tid);
+   struct thread *thread;
 
+   thread = machine__findnew_thread_by_time(machine, sample->pid,
+sample->tid, sample->time);
if (thread == NULL)
return -1;
 
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 2b9fbe55c896..7cfaa2c3f131 100644
--- a/tools/perf/util/machine.c

linux-next: Tree for Oct 2

2015-10-01 Thread Stephen Rothwell
Hi all,

There will be no linux-next release on Monday.

Changes since 20151001:

I used the h8300 tree from next-20150828 since the current tree has been
rebased onto linux-next again :-(

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

The target-updates tree gained a conflict against the kdbus tree.

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

The akpm-current tree gained a conflict against the tip tree.

Non-merge commits (relative to Linus' tree): 4318
 3547 files changed, 168949 insertions(+), 76355 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" and checkout or reset to the new
master.

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,
a multi_v7_defconfig for arm and a native build of tools/perf. After
the final fixups (if any), it is also built with powerpc allnoconfig
(32 and 64 bit), ppc44x_defconfig, allyesconfig (this fails its final
link) and pseries_le_defconfig and i386, sparc, sparc64 and arm defconfig.

Below is a summary of the state of the merge.

I am currently merging 226 trees (counting Linus' and 33 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.

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

$ git checkout master
$ git reset --hard stable
Merging origin/master (ccf70ddcbe99 Merge tag 'for-linus' of 
git://git.kernel.org/pub/scm/virt/kvm/kvm)
Merging fixes/master (c7e9ad7da219 Merge branch 'perf-urgent-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip)
Merging kbuild-current/rc-fixes (3d1450d54a4f Makefile: Force gzip and xz on 
module install)
Merging arc-current/for-curr (e4140819dadc ARC: signal handling robustify)
Merging arm-current/fixes (868e87ccda24 ARM: make RiscPC depend on MMU)
Merging m68k-current/for-linus (95bc06ef049b m68k/defconfig: Update defconfigs 
for v4.3-rc1)
Merging metag-fixes/fixes (0164a711c97b metag: Fix ioremap_wc/ioremap_cached 
build errors)
Merging mips-fixes/mips-fixes (1795cd9b3a91 Linux 3.16-rc5)
Merging powerpc-fixes/fixes (5f81b95fe2a2 cxl: fix leak of ctx->mapping when 
releasing kernel API contexts)
Merging powerpc-merge-mpe/fixes (bc0195aad0da Linux 4.2-rc2)
Merging sparc/master (73958c651fbf sparc64: use ENTRY/ENDPROC in VISsave)
Merging net/master (b84f78782052 net: Initialize flow flags in input path)
Merging ipsec/master (4e077237cfb6 xfrm: Fix state threshold configuration from 
userspace)
Merging sound-current/for-linus (7f57d803ee03 ALSA: hda - Disable 
power_save_node for Thinkpads)
Merging pci-current/for-linus (de24c18c0fac PCI: rcar: Add R8A7794 support)
Merging wireless-drivers/master (76d164f58215 ath10k: fix DMA related firmware 
crashes on multiple devices)
Merging driver-core.current/driver-core-linus (9ffecb102835 Linux 4.3-rc3)
Merging tty.current/tty-linus (9ffecb102835 Linux 4.3-rc3)
Merging usb.current/usb-linus (9ffecb102835 Linux 4.3-rc3)
Merging usb-gadget-fixes/fixes (f5f6afa85aa8 usb: renesas_usbhs: Add support 
for R-Car H3)
Merging usb-serial-fixes/usb-linus (19ab6bc5674a USB: option: add ZTE PIDs)
Merging staging.current/staging-linus (9ffecb102835 Linux 4.3-rc3)
Merging char-misc.current/char-misc-linus (9ffecb102835 Linux 4.3-rc3)
Merging input-current/for-linus (218c1f76b8b2 Input: psmouse - fix data race in 
__ps2_command)
Merging crypto-current/master (09185e2756a8 hwrng: xgene - fix handling 
platform_get_irq)
Merging ide/master (d681f1166919 ide: remove deprecated use of pci api)
Merging devicetree-current/devicetree/merge (f76502aa9140 of/dynamic: Fix test 
for PPC_PSERIES)
Merging rr-fixes/fixes (275d7d44d802 module: Fix locking in symbol_put_addr())
Merging vfio-fixes/for-linus (4bc94d5dc95d vfio: Fix lockdep issue)
Merging kselftest-fixes/fixes (ae7858180510 selftests: exec: revert to default 
emit rule)
Merging backlight-fixes/for-backlight-fixes (68feaca0b13e backlight: pwm: 
Handle EPROBE_DEFER while requesting the PWM)
Merging ftrac

[RFC/PATCH 17/38] perf tools: Maintain map groups list in a leader thread

2015-10-01 Thread Namhyung Kim
To support multi-threaded perf report, we need to maintain time-sorted
map groups.  Add ->mg_list member to struct thread and sort the list
by time.  Now leader threads have one more refcnt for map groups in
the list so also update the thread-mg-share test case.

Currently only add a new map groups when an exec (comm) event is
received.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/tests/thread-mg-share.c |   7 ++-
 tools/perf/util/event.c|   2 +
 tools/perf/util/machine.c  |  15 -
 tools/perf/util/map.c  |   3 +
 tools/perf/util/map.h  |   2 +
 tools/perf/util/thread.c   | 111 -
 tools/perf/util/thread.h   |   3 +
 7 files changed, 138 insertions(+), 5 deletions(-)

diff --git a/tools/perf/tests/thread-mg-share.c 
b/tools/perf/tests/thread-mg-share.c
index 01fabb19d746..b258d5298b9b 100644
--- a/tools/perf/tests/thread-mg-share.c
+++ b/tools/perf/tests/thread-mg-share.c
@@ -23,6 +23,9 @@ int test__thread_mg_share(void)
 * with several threads and checks they properly share and
 * maintain map groups info (struct map_groups).
 *
+* Note that a leader thread has one more refcnt for its
+* (current) map groups.
+*
 * thread group (pid: 0, tids: 0, 1, 2, 3)
 * other  group (pid: 4, tids: 4, 5)
*/
@@ -43,7 +46,7 @@ int test__thread_mg_share(void)
leader && t1 && t2 && t3 && other);
 
mg = leader->mg;
-   TEST_ASSERT_EQUAL("wrong refcnt", atomic_read(>refcnt), 4);
+   TEST_ASSERT_EQUAL("wrong refcnt", atomic_read(>refcnt), 5);
 
/* test the map groups pointer is shared */
TEST_ASSERT_VAL("map groups don't match", mg == t1->mg);
@@ -71,7 +74,7 @@ int test__thread_mg_share(void)
machine__remove_thread(machine, other_leader);
 
other_mg = other->mg;
-   TEST_ASSERT_EQUAL("wrong refcnt", atomic_read(_mg->refcnt), 2);
+   TEST_ASSERT_EQUAL("wrong refcnt", atomic_read(_mg->refcnt), 3);
 
TEST_ASSERT_VAL("map groups don't match", other_mg == other_leader->mg);
 
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 3dff1b5cd4cc..887f18266ab5 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -914,6 +914,8 @@ void thread__find_addr_map(struct thread *thread, u8 
cpumode,
return;
}
 
+   BUG_ON(mg == NULL);
+
if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
al->level = 'k';
mg = >kmaps;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7cfaa2c3f131..3373e8455945 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -349,8 +349,19 @@ static void machine__update_thread_pid(struct machine 
*machine,
if (!leader)
goto out_err;
 
-   if (!leader->mg)
-   leader->mg = map_groups__new(machine);
+   if (!leader->mg) {
+   struct map_groups *mg = map_groups__new(machine);
+
+   if (mg == NULL) {
+   pr_err("Not enough memory for map groups\n");
+   return;
+   }
+
+   if (thread__set_map_groups(leader, mg, 0) < 0) {
+   map_groups__put(mg);
+   goto out_err;
+   }
+   }
 
if (!leader->mg)
goto out_err;
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 4e38c396a897..addd4b323027 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -471,6 +471,8 @@ void map_groups__init(struct map_groups *mg, struct machine 
*machine)
}
mg->machine = machine;
atomic_set(>refcnt, 1);
+   mg->timestamp = 0;
+   INIT_LIST_HEAD(>list);
 }
 
 static void __maps__purge(struct maps *maps)
@@ -527,6 +529,7 @@ struct map_groups *map_groups__new(struct machine *machine)
 void map_groups__delete(struct map_groups *mg)
 {
map_groups__exit(mg);
+   list_del(>list);
free(mg);
 }
 
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 7309d64ce39e..1e3313a22d3a 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -68,6 +68,8 @@ struct map_groups {
struct maps  maps[MAP__NR_TYPES];
struct machine   *machine;
atomic_t refcnt;
+   u64  timestamp;
+   struct list_head list;
 };
 
 struct map_groups *map_groups__new(struct machine *machine);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index ad7c2a00bff8..33de8b010282 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -11,13 +11,79 @@
 #include "unwind.h"
 #include "machine.h"
 
+struct map_groups *thread__get_map_groups(struct thread *thread, u64 timestamp)
+{
+   struct map_groups *mg;
+   struct thread *leader = thread;
+
+   BUG_ON(thread->mg == NULL);
+
+   if 

[RFC/PATCH 19/38] perf callchain: Use thread__find_addr_location_by_time() and friends

2015-10-01 Thread Namhyung Kim
Find correct thread/map/symbol using proper functions.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/machine.c  | 25 -
 tools/perf/util/unwind-libdw.c | 12 +++-
 tools/perf/util/unwind-libunwind.c | 27 ++-
 3 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index d5e5b9de54b0..761b04b970ad 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1756,15 +1756,17 @@ static int add_callchain_ip(struct thread *thread,
struct symbol **parent,
struct addr_location *root_al,
u8 *cpumode,
-   u64 ip)
+   u64 ip,
+   u64 timestamp)
 {
struct addr_location al;
 
al.filtered = 0;
al.sym = NULL;
if (!cpumode) {
-   thread__find_cpumode_addr_location(thread, MAP__FUNCTION,
-  ip, );
+   thread__find_cpumode_addr_location_by_time(thread,
+  MAP__FUNCTION, ip,
+  , timestamp);
} else {
if (ip >= PERF_CONTEXT_MAX) {
switch (ip) {
@@ -1789,8 +1791,9 @@ static int add_callchain_ip(struct thread *thread,
}
return 0;
}
-   thread__find_addr_location(thread, *cpumode, MAP__FUNCTION,
-  ip, );
+   thread__find_addr_location_by_time(thread, *cpumode,
+  MAP__FUNCTION, ip,
+  , timestamp);
}
 
if (al.sym != NULL) {
@@ -1932,7 +1935,8 @@ static int resolve_lbr_callchain_sample(struct thread 
*thread,
ip = lbr_stack->entries[0].to;
}
 
-   err = add_callchain_ip(thread, parent, root_al, 
, ip);
+   err = add_callchain_ip(thread, parent, root_al, 
, ip,
+  sample->time);
if (err)
return (err < 0) ? err : 0;
}
@@ -1953,6 +1957,7 @@ static int thread__resolve_callchain_sample(struct thread 
*thread,
struct ip_callchain *chain = sample->callchain;
int chain_nr = min(max_stack, (int)chain->nr);
u8 cpumode = PERF_RECORD_MISC_USER;
+   u64 timestamp = sample->time;
int i, j, err;
int skip_idx = -1;
int first_call = 0;
@@ -2018,10 +2023,11 @@ static int thread__resolve_callchain_sample(struct 
thread *thread,
 
for (i = 0; i < nr; i++) {
err = add_callchain_ip(thread, parent, root_al,
-  NULL, be[i].to);
+  NULL, be[i].to, timestamp);
if (!err)
err = add_callchain_ip(thread, parent, root_al,
-  NULL, be[i].from);
+  NULL, be[i].from,
+  timestamp);
if (err == -EINVAL)
break;
if (err)
@@ -2050,7 +2056,8 @@ check_calls:
 #endif
ip = chain->ips[j];
 
-   err = add_callchain_ip(thread, parent, root_al, , ip);
+   err = add_callchain_ip(thread, parent, root_al, , ip,
+  timestamp);
 
if (err)
return (err < 0) ? err : 0;
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 2dcfe9a7c8d0..0dd2b6ff4093 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -26,9 +26,9 @@ static int __report_module(struct addr_location *al, u64 ip,
Dwfl_Module *mod;
struct dso *dso = NULL;
 
-   thread__find_addr_location(ui->thread,
-  PERF_RECORD_MISC_USER,
-  MAP__FUNCTION, ip, al);
+   thread__find_addr_location_by_time(ui->thread, PERF_RECORD_MISC_USER,
+  MAP__FUNCTION, ip, al,
+  ui->sample->time);
 
if (al->map)
dso = al->map->dso;
@@ -89,8 +89,10 @@ static int access_dso_mem(struct unwind_info *ui, Dwarf_Addr 
addr,
struct addr_location al;
ssize_t size;
 
-   thread__find_addr_map(ui->thread, PERF_RECORD_MISC_USER,
- MAP__FUNCTION, addr, );

Re: [PATCH 1/2] irqchip: sunxi-nmi: Use driver name instead of DT node name for identification

2015-10-01 Thread Chen-Yu Tsai
On Fri, Oct 2, 2015 at 4:14 AM, Maxime Ripard
 wrote:
> Hi,
>
> On Thu, Oct 01, 2015 at 11:33:48PM +0800, Chen-Yu Tsai wrote:
>> The device tree node name is typically "interrupt-controller", which is
>> rather useless when used in printk messages and irq chip names for
>> identification purposes. Use the driver name "sunxi-nmi" instead.
>>
>> Signed-off-by: Chen-Yu Tsai 
>> ---
>>  drivers/irqchip/irq-sunxi-nmi.c | 11 ++-
>>  1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/irqchip/irq-sunxi-nmi.c 
>> b/drivers/irqchip/irq-sunxi-nmi.c
>> index c143dd58410c..57e009917d2d 100644
>> --- a/drivers/irqchip/irq-sunxi-nmi.c
>> +++ b/drivers/irqchip/irq-sunxi-nmi.c
>> @@ -21,6 +21,7 @@
>>  #include 
>>
>>  #define SUNXI_NMI_SRC_TYPE_MASK  0x0003
>> +#define DRV_NAME "sunxi-nmi"
>>
>>  enum {
>>   SUNXI_SRC_TYPE_LEVEL_LOW = 0,
>> @@ -130,22 +131,22 @@ static int __init sunxi_sc_nmi_irq_init(struct 
>> device_node *node,
>>
>>   domain = irq_domain_add_linear(node, 1, _generic_chip_ops, NULL);
>>   if (!domain) {
>> - pr_err("%s: Could not register interrupt domain.\n", 
>> node->name);
>> + pr_err("%s: Could not register interrupt domain.\n", DRV_NAME);
>>   return -ENOMEM;
>>   }
>>
>> - ret = irq_alloc_domain_generic_chips(domain, 1, 2, node->name,
>> + ret = irq_alloc_domain_generic_chips(domain, 1, 2, DRV_NAME,
>>handle_fasteoi_irq, clr, 0,
>>IRQ_GC_INIT_MASK_CACHE);
>>   if (ret) {
>>pr_err("%s: Could not allocate generic interrupt chip.\n",
>> -  node->name);
>> +  DRV_NAME);
>>goto fail_irqd_remove;
>>   }
>>
>>   irq = irq_of_parse_and_map(node, 0);
>>   if (irq <= 0) {
>> - pr_err("%s: unable to parse irq\n", node->name);
>> + pr_err("%s: unable to parse irq\n", DRV_NAME);
>>   ret = -EINVAL;
>>   goto fail_irqd_remove;
>>   }
>> @@ -153,7 +154,7 @@ static int __init sunxi_sc_nmi_irq_init(struct 
>> device_node *node,
>>   gc = irq_get_domain_generic_chip(domain, 0);
>>   gc->reg_base = of_iomap(node, 0);
>>   if (!gc->reg_base) {
>> - pr_err("%s: unable to map resource\n", node->name);
>> + pr_err("%s: unable to map resource\n", DRV_NAME);
>
> All the pr_err changes can even be replaced by defining pr_fmt.

Cool. Learned something today.

ChenYu
--
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 28/38] perf tools: Move BUILD_ID_SIZE definition to perf.h

2015-10-01 Thread Namhyung Kim
The util/event.h includes util/build-id.h only for BUILD_ID_SIZE.
This is a problem when I include util/event.h from util/tool.h which
is also included by util/build-id.h since it now makes a circular
dependency resulting in incomplete type error.

Signed-off-by: Namhyung Kim 
---
 tools/perf/perf.h  | 3 +++
 tools/perf/util/build-id.h | 3 ---
 tools/perf/util/dso.h  | 1 +
 tools/perf/util/event.h| 1 -
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index df7c208abb74..d21b5c63f244 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -31,6 +31,9 @@ static inline unsigned long long rdclock(void)
 
 #define MAX_NR_CPUS1024
 
+#define BUILD_ID_SIZE  20
+#define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1)
+
 extern const char *input_name;
 extern bool perf_host, perf_guest;
 extern const char perf_version_string[];
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index 27a14a8a945b..8f9a5720bc5e 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -1,9 +1,6 @@
 #ifndef PERF_BUILD_ID_H_
 #define PERF_BUILD_ID_H_ 1
 
-#define BUILD_ID_SIZE  20
-#define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1)
-
 #include "tool.h"
 #include "strlist.h"
 #include 
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index fc8db9c764ac..416b9a57fcb9 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include "map.h"
+#include "perf.h"
 #include "build-id.h"
 
 enum dso_binary_type {
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index a0dbcbd4f6d8..3812d645362c 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -6,7 +6,6 @@
 
 #include "../perf.h"
 #include "map.h"
-#include "build-id.h"
 #include "perf_regs.h"
 
 struct mmap_event {
-- 
2.6.0

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


[RFC/PATCH 23/38] perf tools: Use map_groups__find_addr_by_time()

2015-10-01 Thread Namhyung Kim
Use timestamp to find a corresponding map so that it can find a match
symbol eventually.

Cc: Stephane Eranian 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/event.c  | 81 ++--
 tools/perf/util/thread.c |  8 +++--
 2 files changed, 77 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index c960cbcd30d4..d7997105ee7a 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -895,12 +895,11 @@ int perf_event__process(struct perf_tool *tool 
__maybe_unused,
return machine__process_event(machine, event, sample);
 }
 
-static void map_groups__find_addr_map(struct map_groups *mg, u8 cpumode,
- enum map_type type, u64 addr,
- struct addr_location *al)
+static bool map_groups__set_addr_location(struct map_groups *mg,
+ struct addr_location *al,
+ u8 cpumode, u64 addr)
 {
struct machine *machine = mg->machine;
-   bool load_map = false;
 
al->machine = machine;
al->addr = addr;
@@ -909,21 +908,17 @@ static void map_groups__find_addr_map(struct map_groups 
*mg, u8 cpumode,
 
if (machine == NULL) {
al->map = NULL;
-   return;
+   return true;
}
 
BUG_ON(mg == NULL);
 
if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
al->level = 'k';
-   mg = >kmaps;
-   load_map = true;
} else if (cpumode == PERF_RECORD_MISC_USER && perf_host) {
al->level = '.';
} else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) {
al->level = 'g';
-   mg = >kmaps;
-   load_map = true;
} else if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest) {
al->level = 'u';
} else {
@@ -939,8 +934,27 @@ static void map_groups__find_addr_map(struct map_groups 
*mg, u8 cpumode,
!perf_host)
al->filtered |= (1 << HIST_FILTER__HOST);
 
+   return true;
+   }
+   return false;
+}
+
+static void map_groups__find_addr_map(struct map_groups *mg, u8 cpumode,
+ enum map_type type, u64 addr,
+ struct addr_location *al)
+{
+   struct machine *machine = mg->machine;
+   bool load_map = false;
+
+   if (map_groups__set_addr_location(mg, al, cpumode, addr))
return;
+
+   if ((cpumode == PERF_RECORD_MISC_KERNEL && perf_host) ||
+   (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest)) {
+   mg = >kmaps;
+   load_map = true;
}
+
 try_again:
al->map = map_groups__find(mg, type, al->addr);
if (al->map == NULL) {
@@ -971,6 +985,53 @@ try_again:
}
 }
 
+static void map_groups__find_addr_map_by_time(struct map_groups *mg, u8 
cpumode,
+ enum map_type type, u64 addr,
+ struct addr_location *al,
+ u64 timestamp)
+{
+   struct machine *machine = mg->machine;
+   bool load_map = false;
+
+   if (map_groups__set_addr_location(mg, al, cpumode, addr))
+   return;
+
+   if ((cpumode == PERF_RECORD_MISC_KERNEL && perf_host) ||
+   (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest)) {
+   mg = >kmaps;
+   load_map = true;
+   }
+
+try_again:
+   al->map = map_groups__find_by_time(mg, type, al->addr, timestamp);
+   if (al->map == NULL) {
+   /*
+* If this is outside of all known maps, and is a negative
+* address, try to look it up in the kernel dso, as it might be
+* a vsyscall or vdso (which executes in user-mode).
+*
+* XXX This is nasty, we should have a symbol list in the
+* "[vdso]" dso, but for now lets use the old trick of looking
+* in the whole kernel symbol list.
+*/
+   if (cpumode == PERF_RECORD_MISC_USER && machine &&
+   mg != >kmaps &&
+   machine__kernel_ip(machine, al->addr)) {
+   mg = >kmaps;
+   load_map = true;
+   goto try_again;
+   }
+   } else {
+   /*
+* Kernel maps might be changed when loading symbols so loading
+* must be done prior to using kernel maps.
+*/
+   if (load_map)
+   map__load(al->map, machine->symbol_filter);
+   al->addr = al->map->map_ip(al->map, al->addr);
+   }
+}
+
 void thread__find_addr_map(struct thread *thread, u8 

[RFC/PATCH 25/38] perf callchain: Maintain libunwind's address space in map_groups

2015-10-01 Thread Namhyung Kim
Currently the address_space was kept in thread struct but it's more
appropriate to keep it in map_groups as it's maintained throughout
exec's with timestamps.  Also we should not flush the address space
after exec since it still can be accessed when used with an indexed
data file.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/tests/dwarf-unwind.c|  5 +++--
 tools/perf/util/map.c  |  5 +
 tools/perf/util/map.h  |  1 +
 tools/perf/util/thread.c   |  7 ---
 tools/perf/util/unwind-libunwind.c | 28 +---
 tools/perf/util/unwind.h   | 15 ++-
 6 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index b9ca0a72fc4d..c3774e0ebcf4 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -143,6 +143,9 @@ int test__dwarf_unwind(void)
struct thread *thread;
int err = -1;
 
+   /* The record_mode should be set before calling map_groups__init() */
+   callchain_param.record_mode = CALLCHAIN_DWARF;
+
machines__init();
 
machine = machines__find(, HOST_KERNEL_ID);
@@ -151,8 +154,6 @@ int test__dwarf_unwind(void)
return -1;
}
 
-   callchain_param.record_mode = CALLCHAIN_DWARF;
-
if (init_live_machine(machine)) {
pr_err("Could not init machine\n");
goto out;
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index c0f8933f29f0..c458a40f8d26 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -14,6 +14,7 @@
 #include "util.h"
 #include "debug.h"
 #include "machine.h"
+#include "unwind.h"
 #include 
 
 static void __maps__insert(struct maps *maps, struct map *map);
@@ -475,6 +476,8 @@ void map_groups__init(struct map_groups *mg, struct machine 
*machine)
atomic_set(>refcnt, 1);
mg->timestamp = 0;
INIT_LIST_HEAD(>list);
+
+   unwind__prepare_access(mg);
 }
 
 static void __maps__purge(struct maps *maps)
@@ -504,6 +507,8 @@ void map_groups__exit(struct map_groups *mg)
 
for (i = 0; i < MAP__NR_TYPES; ++i)
maps__exit(>maps[i]);
+
+   unwind__finish_access(mg);
 }
 
 bool map_groups__empty(struct map_groups *mg)
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 41a9a39f1027..ef3f8b1649ab 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -73,6 +73,7 @@ struct map_groups {
atomic_t refcnt;
u64  timestamp;
struct list_head list;
+   void *priv;
 };
 
 struct map_groups *map_groups__new(struct machine *machine);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 21de681415f4..05aaf7d0ad18 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -107,9 +107,6 @@ struct thread *thread__new(pid_t pid, pid_t tid)
INIT_LIST_HEAD(>comm_list);
INIT_LIST_HEAD(>mg_list);
 
-   if (unwind__prepare_access(thread) < 0)
-   goto err_thread;
-
comm_str = malloc(32);
if (!comm_str)
goto err_thread;
@@ -155,7 +152,6 @@ void thread__delete(struct thread *thread)
list_del(>list);
comm__free(comm);
}
-   unwind__finish_access(thread);
 
free(thread);
 }
@@ -252,9 +248,6 @@ int __thread__set_comm(struct thread *thread, const char 
*str, u64 timestamp,
break;
}
list_add_tail(>list, >list);
-
-   if (exec)
-   unwind__flush_access(thread);
}
 
if (exec) {
diff --git a/tools/perf/util/unwind-libunwind.c 
b/tools/perf/util/unwind-libunwind.c
index 5cac2dd68688..5cad1aecf051 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -32,6 +32,7 @@
 #include "symbol.h"
 #include "util.h"
 #include "debug.h"
+#include "map.h"
 
 extern int
 UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
@@ -566,7 +567,7 @@ static unw_accessors_t accessors = {
.get_proc_name  = get_proc_name,
 };
 
-int unwind__prepare_access(struct thread *thread)
+int unwind__prepare_access(struct map_groups *mg)
 {
unw_addr_space_t addr_space;
 
@@ -580,41 +581,38 @@ int unwind__prepare_access(struct thread *thread)
}
 
unw_set_caching_policy(addr_space, UNW_CACHE_GLOBAL);
-   thread__set_priv(thread, addr_space);
+   mg->priv = addr_space;
 
return 0;
 }
 
-void unwind__flush_access(struct thread *thread)
+void unwind__finish_access(struct map_groups *mg)
 {
-   unw_addr_space_t addr_space;
+   unw_addr_space_t addr_space = mg->priv;
 
if (callchain_param.record_mode != CALLCHAIN_DWARF)
return;
 
-   addr_space = thread__priv(thread);
-   

[RFC/PATCH 22/38] perf tools: Introduce map_groups__{insert,find}_by_time()

2015-10-01 Thread Namhyung Kim
It'll manage maps using timestamp so that it can find correct
map/symbol for sample at a certain time.  With this API, it can
maintain overlapping maps in a map_groups.

Cc: Stephane Eranian 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/map.c | 64 +++
 tools/perf/util/map.h | 25 
 2 files changed, 89 insertions(+)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 2034127ac3f0..c0f8933f29f0 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -777,6 +777,41 @@ void maps__insert(struct maps *maps, struct map *map)
pthread_rwlock_unlock(>lock);
 }
 
+static void __maps__insert_by_time(struct maps *maps, struct map *map)
+{
+   struct rb_node **p = >entries.rb_node;
+   struct rb_node *parent = NULL;
+   const u64 ip = map->start;
+   const u64 timestamp = map->timestamp;
+   struct map *m;
+
+   while (*p != NULL) {
+   parent = *p;
+   m = rb_entry(parent, struct map, rb_node);
+   if (ip < m->start)
+   p = &(*p)->rb_left;
+   else if (ip > m->start)
+   p = &(*p)->rb_right;
+   else if (timestamp > m->timestamp)
+   p = &(*p)->rb_left;
+   else if (timestamp < m->timestamp)
+   p = &(*p)->rb_right;
+   else
+   BUG_ON(1);
+   }
+
+   rb_link_node(>rb_node, parent, p);
+   rb_insert_color(>rb_node, >entries);
+   map__get(map);
+}
+
+void maps__insert_by_time(struct maps *maps, struct map *map)
+{
+   pthread_rwlock_wrlock(>lock);
+   __maps__insert_by_time(maps, map);
+   pthread_rwlock_unlock(>lock);
+}
+
 static void __maps__remove(struct maps *maps, struct map *map)
 {
rb_erase_init(>rb_node, >entries);
@@ -815,6 +850,35 @@ out:
return m;
 }
 
+struct map *maps__find_by_time(struct maps *maps, u64 ip, u64 timestamp)
+{
+   struct rb_node **p;
+   struct rb_node *parent = NULL;
+   struct map *m;
+   struct map *best = NULL;
+
+   pthread_rwlock_rdlock(>lock);
+
+   p = >entries.rb_node;
+   while (*p != NULL) {
+   parent = *p;
+   m = rb_entry(parent, struct map, rb_node);
+   if (ip < m->start)
+   p = &(*p)->rb_left;
+   else if (ip >= m->end)
+   p = &(*p)->rb_right;
+   else if (timestamp >= m->timestamp) {
+   if (!best || best->timestamp < m->timestamp)
+   best = m;
+   p = &(*p)->rb_left;
+   } else
+   p = &(*p)->rb_right;
+   }
+
+   pthread_rwlock_unlock(>lock);
+   return best;
+}
+
 struct map *maps__first(struct maps *maps)
 {
struct rb_node *first = rb_first(>entries);
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 858f700ea5a3..41a9a39f1027 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -10,6 +10,8 @@
 #include 
 #include 
 
+#include "perf.h"  /* for perf_has_index */
+
 enum map_type {
MAP__FUNCTION = 0,
MAP__VARIABLE,
@@ -191,8 +193,10 @@ void map__reloc_vmlinux(struct map *map);
 size_t __map_groups__fprintf_maps(struct map_groups *mg, enum map_type type,
  FILE *fp);
 void maps__insert(struct maps *maps, struct map *map);
+void maps__insert_by_time(struct maps *maps, struct map *map);
 void maps__remove(struct maps *maps, struct map *map);
 struct map *maps__find(struct maps *maps, u64 addr);
+struct map *maps__find_by_time(struct maps *maps, u64 addr, u64 timestamp);
 struct map *maps__first(struct maps *maps);
 struct map *map__next(struct map *map);
 struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
@@ -212,6 +216,17 @@ static inline void map_groups__insert(struct map_groups 
*mg, struct map *map)
map->groups = mg;
 }
 
+static inline void map_groups__insert_by_time(struct map_groups *mg,
+ struct map *map)
+{
+   if (perf_has_index)
+   maps__insert_by_time(>maps[map->type], map);
+   else
+   maps__insert(>maps[map->type], map);
+
+   map->groups = mg;
+}
+
 static inline void map_groups__remove(struct map_groups *mg, struct map *map)
 {
maps__remove(>maps[map->type], map);
@@ -223,6 +238,16 @@ static inline struct map *map_groups__find(struct 
map_groups *mg,
return maps__find(>maps[type], addr);
 }
 
+static inline struct map *map_groups__find_by_time(struct map_groups *mg,
+  enum map_type type, u64 addr,
+  u64 timestamp)
+{
+   if (!perf_has_index)
+   return maps__find(>maps[type], addr);
+
+   return maps__find_by_time(>maps[type], addr, 

[RFC/PATCH 21/38] perf tools: Save timestamp of a map creation

2015-10-01 Thread Namhyung Kim
It'll be used to support multiple maps on a same address like dlopen()
and/or JIT compile cases.

Cc: Stephane Eranian 
Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/dso.c |  2 +-
 tools/perf/util/machine.c | 29 +
 tools/perf/util/machine.h |  2 +-
 tools/perf/util/map.c | 12 +++-
 tools/perf/util/map.h |  9 ++---
 tools/perf/util/probe-event.c |  2 +-
 tools/perf/util/symbol-elf.c  |  2 +-
 tools/perf/util/symbol.c  |  4 ++--
 8 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 7c0c08386a1d..6cf2c0b095cf 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -859,7 +859,7 @@ struct map *dso__new_map(const char *name)
struct dso *dso = dso__new(name);
 
if (dso)
-   map = map__new2(0, dso, MAP__FUNCTION);
+   map = map__new2(0, dso, MAP__FUNCTION, 0);
 
return map;
 }
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 761b04b970ad..57f9aa1800a2 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -709,7 +709,7 @@ int machine__process_switch_event(struct machine *machine 
__maybe_unused,
 }
 
 struct map *machine__findnew_module_map(struct machine *machine, u64 start,
-   const char *filename)
+   const char *filename, u64 timestamp)
 {
struct map *map = NULL;
struct dso *dso;
@@ -727,7 +727,7 @@ struct map *machine__findnew_module_map(struct machine 
*machine, u64 start,
if (dso == NULL)
goto out;
 
-   map = map__new2(start, dso, MAP__FUNCTION);
+   map = map__new2(start, dso, MAP__FUNCTION, timestamp);
if (map == NULL)
goto out;
 
@@ -892,7 +892,7 @@ int __machine__create_kernel_maps(struct machine *machine, 
struct dso *kernel)
struct kmap *kmap;
struct map *map;
 
-   machine->vmlinux_maps[type] = map__new2(start, kernel, type);
+   machine->vmlinux_maps[type] = map__new2(start, kernel, type, 0);
if (machine->vmlinux_maps[type] == NULL)
return -1;
 
@@ -1192,7 +1192,7 @@ static int machine__create_module(void *arg, const char 
*name, u64 start)
struct machine *machine = arg;
struct map *map;
 
-   map = machine__findnew_module_map(machine, start, name);
+   map = machine__findnew_module_map(machine, start, name, 0);
if (map == NULL)
return -1;
 
@@ -1293,7 +1293,8 @@ static bool machine__uses_kcore(struct machine *machine)
 }
 
 static int machine__process_kernel_mmap_event(struct machine *machine,
- union perf_event *event)
+ union perf_event *event,
+ u64 timestamp)
 {
struct map *map;
char kmmap_prefix[PATH_MAX];
@@ -1316,7 +1317,8 @@ static int machine__process_kernel_mmap_event(struct 
machine *machine,
if (event->mmap.filename[0] == '/' ||
(!is_kernel_mmap && event->mmap.filename[0] == '[')) {
map = machine__findnew_module_map(machine, event->mmap.start,
- event->mmap.filename);
+ event->mmap.filename,
+ timestamp);
if (map == NULL)
goto out_problem;
 
@@ -1404,7 +1406,7 @@ out_problem:
 
 int machine__process_mmap2_event(struct machine *machine,
 union perf_event *event,
-struct perf_sample *sample __maybe_unused)
+struct perf_sample *sample)
 {
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
struct thread *thread;
@@ -1417,7 +1419,8 @@ int machine__process_mmap2_event(struct machine *machine,
 
if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
cpumode == PERF_RECORD_MISC_KERNEL) {
-   ret = machine__process_kernel_mmap_event(machine, event);
+   ret = machine__process_kernel_mmap_event(machine, event,
+sample->time);
if (ret < 0)
goto out_problem;
return 0;
@@ -1440,7 +1443,8 @@ int machine__process_mmap2_event(struct machine *machine,
event->mmap2.ino_generation,
event->mmap2.prot,
event->mmap2.flags,
-   event->mmap2.filename, type, thread);
+   event->mmap2.filename, type, thread,
+   sample->time);
 
if (map == NULL)
goto out_problem_map;
@@ -1458,7 

[RFC/PATCH 26/38] perf session: Pass struct events stats to event processing functions

2015-10-01 Thread Namhyung Kim
Pass stats structure so that it can point separate object when used in
multi-thread environment.

Signed-off-by: Namhyung Kim 
---
 tools/perf/util/session.c | 71 ++-
 1 file changed, 45 insertions(+), 26 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 7546c4d147b9..8cafc679096b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -19,6 +19,7 @@
 #include "thread-stack.h"
 
 static int perf_session__deliver_event(struct perf_session *session,
+  struct events_stats *stats,
   union perf_event *event,
   struct perf_sample *sample,
   struct perf_tool *tool,
@@ -107,7 +108,8 @@ static int ordered_events__deliver_event(struct 
ordered_events *oe,
return ret;
}
 
-   return perf_session__deliver_event(session, event->event, ,
+   return perf_session__deliver_event(session, >evlist->stats,
+  event->event, ,
   session->tool, event->file_offset);
 }
 
@@ -981,6 +983,7 @@ static struct machine *machines__find_for_cpumode(struct 
machines *machines,
 }
 
 static int deliver_sample_value(struct perf_evlist *evlist,
+   struct events_stats *stats,
struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
@@ -996,7 +999,7 @@ static int deliver_sample_value(struct perf_evlist *evlist,
}
 
if (!sid || sid->evsel == NULL) {
-   ++evlist->stats.nr_unknown_id;
+   ++stats->nr_unknown_id;
return 0;
}
 
@@ -1004,6 +1007,7 @@ static int deliver_sample_value(struct perf_evlist 
*evlist,
 }
 
 static int deliver_sample_group(struct perf_evlist *evlist,
+   struct events_stats *stats,
struct perf_tool *tool,
union  perf_event *event,
struct perf_sample *sample,
@@ -1013,7 +1017,7 @@ static int deliver_sample_group(struct perf_evlist 
*evlist,
u64 i;
 
for (i = 0; i < sample->read.group.nr; i++) {
-   ret = deliver_sample_value(evlist, tool, event, sample,
+   ret = deliver_sample_value(evlist, stats, tool, event, sample,
   >read.group.values[i],
   machine);
if (ret)
@@ -1025,6 +1029,7 @@ static int deliver_sample_group(struct perf_evlist 
*evlist,
 
 static int
  perf_evlist__deliver_sample(struct perf_evlist *evlist,
+struct events_stats *stats,
 struct perf_tool *tool,
 union  perf_event *event,
 struct perf_sample *sample,
@@ -1041,14 +1046,15 @@ static int
 
/* For PERF_SAMPLE_READ we have either single or group mode. */
if (read_format & PERF_FORMAT_GROUP)
-   return deliver_sample_group(evlist, tool, event, sample,
+   return deliver_sample_group(evlist, stats, tool, event, sample,
machine);
else
-   return deliver_sample_value(evlist, tool, event, sample,
+   return deliver_sample_value(evlist, stats, tool, event, sample,
>read.one, machine);
 }
 
 static int machines__deliver_event(struct machines *machines,
+  struct events_stats *stats,
   struct perf_evlist *evlist,
   union perf_event *event,
   struct perf_sample *sample,
@@ -1066,15 +1072,16 @@ static int machines__deliver_event(struct machines 
*machines,
switch (event->header.type) {
case PERF_RECORD_SAMPLE:
if (evsel == NULL) {
-   ++evlist->stats.nr_unknown_id;
+   ++stats->nr_unknown_id;
return 0;
}
dump_sample(evsel, event, sample);
if (machine == NULL) {
-   ++evlist->stats.nr_unprocessable_samples;
+   ++stats->nr_unprocessable_samples;
return 0;
}
-   return perf_evlist__deliver_sample(evlist, tool, event, sample, 
evsel, machine);
+   return perf_evlist__deliver_sample(evlist, stats, tool, event,
+  sample, evsel, machine);
case PERF_RECORD_MMAP:
return tool->mmap(tool, event, sample, machine);
case PERF_RECORD_MMAP2:
@@ 

[RFC/PATCH 27/38] perf hists: Pass hists struct to hist_entry_iter struct

2015-10-01 Thread Namhyung Kim
This is a preparation for perf report multi-thread support.  When
multi-thread is enable, each thread will have its own hists during the
sample processing.

Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-report.c   |  1 +
 tools/perf/builtin-top.c  |  1 +
 tools/perf/tests/hists_cumulate.c |  1 +
 tools/perf/tests/hists_filter.c   |  1 +
 tools/perf/tests/hists_output.c   |  1 +
 tools/perf/util/hist.c| 22 --
 tools/perf/util/hist.h|  1 +
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index aeced4fa27e8..f6e000b87108 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -145,6 +145,7 @@ static int process_sample_event(struct perf_tool *tool,
struct addr_location al;
struct hist_entry_iter iter = {
.evsel  = evsel,
+   .hists  = evsel__hists(evsel),
.sample = sample,
.hide_unresolved= rep->hide_unresolved,
.add_entry_cb   = hist_iter__report_callback,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 6f641fd68296..e1ead08755c8 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -787,6 +787,7 @@ static void perf_event__process_sample(struct perf_tool 
*tool,
struct hists *hists = evsel__hists(evsel);
struct hist_entry_iter iter = {
.evsel  = evsel,
+   .hists  = evsel__hists(evsel),
.sample = sample,
.add_entry_cb   = hist_iter__top_callback,
};
diff --git a/tools/perf/tests/hists_cumulate.c 
b/tools/perf/tests/hists_cumulate.c
index 7ed737019de7..0c046dde9a64 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -88,6 +88,7 @@ static int add_hist_entries(struct hists *hists, struct 
machine *machine)
};
struct hist_entry_iter iter = {
.evsel = evsel,
+   .hists = evsel__hists(evsel),
.sample = ,
.hide_unresolved = false,
};
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index 818acf875dd0..b866a5389a1d 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -65,6 +65,7 @@ static int add_hist_entries(struct perf_evlist *evlist,
};
struct hist_entry_iter iter = {
.evsel = evsel,
+   .hists = evsel__hists(evsel),
.sample = ,
.ops = _iter_normal,
.hide_unresolved = false,
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index adbebc852cc8..bf9efe145260 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -58,6 +58,7 @@ static int add_hist_entries(struct hists *hists, struct 
machine *machine)
};
struct hist_entry_iter iter = {
.evsel = evsel,
+   .hists = evsel__hists(evsel),
.sample = ,
.ops = _iter_normal,
.hide_unresolved = false,
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 10454197a508..045313c219b6 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -511,7 +511,7 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter, 
struct addr_location *al
u64 cost;
struct mem_info *mi = iter->priv;
struct perf_sample *sample = iter->sample;
-   struct hists *hists = evsel__hists(iter->evsel);
+   struct hists *hists = iter->hists;
struct hist_entry *he;
 
if (mi == NULL)
@@ -541,8 +541,7 @@ static int
 iter_finish_mem_entry(struct hist_entry_iter *iter,
  struct addr_location *al __maybe_unused)
 {
-   struct perf_evsel *evsel = iter->evsel;
-   struct hists *hists = evsel__hists(evsel);
+   struct hists *hists = iter->hists;
struct hist_entry *he = iter->he;
int err = -EINVAL;
 
@@ -614,8 +613,7 @@ static int
 iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location 
*al)
 {
struct branch_info *bi;
-   struct perf_evsel *evsel = iter->evsel;
-   struct hists *hists = evsel__hists(evsel);
+   struct hists *hists = iter->hists;
struct hist_entry *he = NULL;
int i = iter->curr;
int err = 0;
@@ -663,11 +661,10 @@ iter_prepare_normal_entry(struct hist_entry_iter *iter 
__maybe_unused,
 static int
 iter_add_single_normal_entry(struct hist_entry_iter *iter, struct 

[RFC/PATCH 28/38] perf tools: Move BUILD_ID_SIZE definition to perf.h

2015-10-01 Thread Namhyung Kim
The util/event.h includes util/build-id.h only for BUILD_ID_SIZE.
This is a problem when I include util/event.h from util/tool.h which
is also included by util/build-id.h since it now makes a circular
dependency resulting in incomplete type error.

Signed-off-by: Namhyung Kim 
---
 tools/perf/perf.h  | 3 +++
 tools/perf/util/build-id.h | 3 ---
 tools/perf/util/dso.h  | 1 +
 tools/perf/util/event.h| 1 -
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index df7c208abb74..d21b5c63f244 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -31,6 +31,9 @@ static inline unsigned long long rdclock(void)
 
 #define MAX_NR_CPUS1024
 
+#define BUILD_ID_SIZE  20
+#define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1)
+
 extern const char *input_name;
 extern bool perf_host, perf_guest;
 extern const char perf_version_string[];
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index 27a14a8a945b..8f9a5720bc5e 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -1,9 +1,6 @@
 #ifndef PERF_BUILD_ID_H_
 #define PERF_BUILD_ID_H_ 1
 
-#define BUILD_ID_SIZE  20
-#define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1)
-
 #include "tool.h"
 #include "strlist.h"
 #include 
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index fc8db9c764ac..416b9a57fcb9 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include "map.h"
+#include "perf.h"
 #include "build-id.h"
 
 enum dso_binary_type {
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index a0dbcbd4f6d8..3812d645362c 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -6,7 +6,6 @@
 
 #include "../perf.h"
 #include "map.h"
-#include "build-id.h"
 #include "perf_regs.h"
 
 struct mmap_event {
-- 
2.6.0

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


Re: [PATCH v2 1/4] dt-bindings: add sunxi SPDIF transceiver bindings

2015-10-01 Thread Code Kipper
>> +
>> +  - compatible   : should be one of the following:
>> +- "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
>> +- "allwinner,sun7i-a20-spdif": for the Allwinner A20 SoC
>> +- "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC
>
> Are all these compatibles really work? Is there any significant
> difference between the controller on all these SoCs?
Let us assume that there isn't any difference. Remember SPDIF details
for all of these devices is sketchy. In the A10 User Manual, it's not
even mentioned although devices such as the Mele A2000 which I use
come with the physical connector. It's only when the A20 Manual was
released that we see the pin details and related components. We didn't
see a SPDIF block spec until the H3 User Manual was released.

Looking at the SDK code I've only seen fifo level settings to be
different for the sun6i family. It was this release that also showed
Rx rotines. The fact of the matter is we won't know until these SoCs
have been tested and with that in mind I'm happy to remove all
capabilities for now until then.

BR,
CK

>
> Thanks,
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCH 16/38] perf tools: Add a test case for timed thread handling

2015-10-01 Thread Namhyung Kim
A test case for verifying live and dead thread tree management during
time change and new machine__find{,new}_thread_time().

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/tests/Build|   1 +
 tools/perf/tests/builtin-test.c   |   4 +
 tools/perf/tests/tests.h  |   1 +
 tools/perf/tests/thread-lookup-time.c | 179 ++
 4 files changed, 185 insertions(+)
 create mode 100644 tools/perf/tests/thread-lookup-time.c

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 6bf705c4cd89..fd4cabb9a1a0 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -26,6 +26,7 @@ perf-y += sw-clock.o
 perf-y += mmap-thread-lookup.o
 perf-y += thread-comm.o
 perf-y += thread-mg-share.o
+perf-y += thread-lookup-time.o
 perf-y += switch-tracking.o
 perf-y += keep-tracking.o
 perf-y += code-reading.o
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 5e6f4e56113c..027796fa105e 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -195,6 +195,10 @@ static struct test {
.func = test__thread_comm,
},
{
+   .desc = "Test thread lookup with time",
+   .func = test__thread_lookup_time,
+   },
+   {
.func = NULL,
},
 };
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 23552471535a..9c02755e86dd 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -66,6 +66,7 @@ int test__llvm(void);
 int test__insn_x86(void);
 int test_session_topology(void);
 int test__thread_comm(void);
+int test__thread_lookup_time(void);
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || 
defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
diff --git a/tools/perf/tests/thread-lookup-time.c 
b/tools/perf/tests/thread-lookup-time.c
new file mode 100644
index ..0133a241b9fc
--- /dev/null
+++ b/tools/perf/tests/thread-lookup-time.c
@@ -0,0 +1,179 @@
+#include "tests.h"
+#include "machine.h"
+#include "thread.h"
+#include "map.h"
+#include "debug.h"
+
+static int thread__print_cb(struct thread *th, void *arg __maybe_unused)
+{
+   printf("thread: %d, start time: %"PRIu64" %s\n",
+  th->tid, th->start_time,
+  th->dead ? "(dead)" : th->exited ? "(exited)" : "");
+   return 0;
+}
+
+static int lookup_with_timestamp(struct machine *machine)
+{
+   struct thread *t1, *t2, *t3;
+   union perf_event fork_event = {
+   .fork = {
+   .pid = 0,
+   .tid = 0,
+   .ppid = 1,
+   .ptid = 1,
+   },
+   };
+   struct perf_sample sample = {
+   .time = 5,
+   };
+
+   /* this is needed to keep dead threads in rbtree */
+   perf_has_index = true;
+
+   /* start_time is set to 0 */
+   t1 = machine__findnew_thread(machine, 0, 0);
+
+   if (verbose > 1) {
+   printf("= after t1 created ==\n");
+   machine__for_each_thread(machine, thread__print_cb, NULL);
+   }
+
+   TEST_ASSERT_VAL("wrong start time of old thread", t1->start_time == 0);
+
+   TEST_ASSERT_VAL("cannot find current thread",
+   machine__find_thread(machine, 0, 0) == t1);
+
+   TEST_ASSERT_VAL("cannot find current thread with time",
+   machine__findnew_thread_by_time(machine, 0, 0, 1) 
== t1);
+
+   /* start_time is overwritten to new value */
+   thread__set_comm(t1, "/usr/bin/perf", 2);
+
+   if (verbose > 1) {
+   printf("= after t1 set comm ==\n");
+   machine__for_each_thread(machine, thread__print_cb, NULL);
+   }
+
+   TEST_ASSERT_VAL("failed to update start time", t1->start_time == 2);
+
+   TEST_ASSERT_VAL("should not find passed thread",
+   /* this will create yet another dead thread */
+   machine__findnew_thread_by_time(machine, 0, 0, 1) 
!= t1);
+
+   TEST_ASSERT_VAL("cannot find overwritten thread with time",
+   machine__find_thread_by_time(machine, 0, 0, 2) == 
t1);
+
+   /* now t1 goes to dead thread tree, and create t2 */
+   machine__process_fork_event(machine, _event, );
+
+   if (verbose > 1) {
+   printf("= after t2 forked ==\n");
+   machine__for_each_thread(machine, thread__print_cb, NULL);
+   }
+
+   t2 = machine__find_thread(machine, 0, 0);
+
+   TEST_ASSERT_VAL("cannot find current thread", t2 != NULL);
+
+   TEST_ASSERT_VAL("wrong start time of new thread", t2->start_time == 
5);
+
+   TEST_ASSERT_VAL("dead thread cannot be found",
+   machine__find_thread_by_time(machine, 0, 0, 1) != 
t1);
+
+   TEST_ASSERT_VAL("cannot find dead 

[RFC/PATCH 20/38] perf tools: Add a test case for timed map groups handling

2015-10-01 Thread Namhyung Kim
A test case for verifying thread->mg and ->mg_list handling during
time change and new thread__find_addr_map_by_time() and friends.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/tests/Build|  1 +
 tools/perf/tests/builtin-test.c   |  4 ++
 tools/perf/tests/tests.h  |  1 +
 tools/perf/tests/thread-mg-time.c | 93 +++
 4 files changed, 99 insertions(+)
 create mode 100644 tools/perf/tests/thread-mg-time.c

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index fd4cabb9a1a0..d287b99ff3bb 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -27,6 +27,7 @@ perf-y += mmap-thread-lookup.o
 perf-y += thread-comm.o
 perf-y += thread-mg-share.o
 perf-y += thread-lookup-time.o
+perf-y += thread-mg-time.o
 perf-y += switch-tracking.o
 perf-y += keep-tracking.o
 perf-y += code-reading.o
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 027796fa105e..62de08a89e0e 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -199,6 +199,10 @@ static struct test {
.func = test__thread_lookup_time,
},
{
+   .desc = "Test thread map group handling with time",
+   .func = test__thread_mg_time,
+   },
+   {
.func = NULL,
},
 };
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 9c02755e86dd..03dcaccb570f 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -67,6 +67,7 @@ int test__insn_x86(void);
 int test_session_topology(void);
 int test__thread_comm(void);
 int test__thread_lookup_time(void);
+int test__thread_mg_time(void);
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || 
defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
diff --git a/tools/perf/tests/thread-mg-time.c 
b/tools/perf/tests/thread-mg-time.c
new file mode 100644
index ..841777125a64
--- /dev/null
+++ b/tools/perf/tests/thread-mg-time.c
@@ -0,0 +1,93 @@
+#include "tests.h"
+#include "machine.h"
+#include "thread.h"
+#include "map.h"
+#include "debug.h"
+
+#define PERF_MAP_START  0x4
+
+int test__thread_mg_time(void)
+{
+   struct machines machines;
+   struct machine *machine;
+   struct thread *t;
+   struct map_groups *mg;
+   struct map *map, *old_map;
+   struct addr_location al = { .map = NULL, };
+
+   /*
+* This test is to check whether it can retrieve a correct map
+* for a given time.  When multi-file data storage is enabled,
+* those task/comm/mmap events are processed first so the
+* later sample should find a matching comm properly.
+*/
+   machines__init();
+   machine = 
+
+   /* this is needed to add/find map by time */
+   perf_has_index = true;
+
+   t = machine__findnew_thread(machine, 0, 0);
+   mg = t->mg;
+
+   map = dso__new_map("/usr/bin/perf");
+   map->start = PERF_MAP_START;
+   map->end = PERF_MAP_START + 0x1000;
+
+   thread__insert_map(t, map);
+
+   if (verbose > 1)
+   map_groups__fprintf(t->mg, stderr);
+
+   thread__find_addr_map(t, PERF_RECORD_MISC_USER, MAP__FUNCTION,
+ PERF_MAP_START, );
+
+   TEST_ASSERT_VAL("cannot find mapping for perf", al.map != NULL);
+   TEST_ASSERT_VAL("non matched mapping found", al.map == map);
+   TEST_ASSERT_VAL("incorrect map groups", al.map->groups == mg);
+   TEST_ASSERT_VAL("incorrect map groups", al.map->groups == t->mg);
+
+   thread__find_addr_map_by_time(t, PERF_RECORD_MISC_USER, MAP__FUNCTION,
+ PERF_MAP_START, , -1ULL);
+
+   TEST_ASSERT_VAL("cannot find timed mapping for perf", al.map != NULL);
+   TEST_ASSERT_VAL("non matched timed mapping", al.map == map);
+   TEST_ASSERT_VAL("incorrect timed map groups", al.map->groups == mg);
+   TEST_ASSERT_VAL("incorrect map groups", al.map->groups == t->mg);
+
+
+   pr_debug("simulate EXEC event (generate new mg)\n");
+   __thread__set_comm(t, "perf-test", 1, true);
+
+   old_map = map;
+
+   map = dso__new_map("/usr/bin/perf-test");
+   map->start = PERF_MAP_START;
+   map->end = PERF_MAP_START + 0x2000;
+
+   thread__insert_map(t, map);
+
+   if (verbose > 1)
+   map_groups__fprintf(t->mg, stderr);
+
+   thread__find_addr_map(t, PERF_RECORD_MISC_USER, MAP__FUNCTION,
+ PERF_MAP_START + 4, );
+
+   TEST_ASSERT_VAL("cannot find mapping for perf-test", al.map != NULL);
+   TEST_ASSERT_VAL("invalid mapping found", al.map == map);
+   TEST_ASSERT_VAL("incorrect map groups", al.map->groups != mg);
+   TEST_ASSERT_VAL("incorrect map groups", al.map->groups == t->mg);
+
+   pr_debug("searching map in the old mag groups\n");
+   thread__find_addr_map_by_time(t, PERF_RECORD_MISC_USER, 

[RFC/PATCH 12/38] perf tools: Add a test case for thread comm handling

2015-10-01 Thread Namhyung Kim
The new test case checks various thread comm handling APIs like
overridding and time sorting.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/tests/Build  |  1 +
 tools/perf/tests/builtin-test.c |  4 
 tools/perf/tests/tests.h|  1 +
 tools/perf/tests/thread-comm.c  | 47 +
 4 files changed, 53 insertions(+)
 create mode 100644 tools/perf/tests/thread-comm.c

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index c6f198ae65fb..6bf705c4cd89 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -24,6 +24,7 @@ perf-y += bp_signal_overflow.o
 perf-y += task-exit.o
 perf-y += sw-clock.o
 perf-y += mmap-thread-lookup.o
+perf-y += thread-comm.o
 perf-y += thread-mg-share.o
 perf-y += switch-tracking.o
 perf-y += keep-tracking.o
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index d9bf51dc8cf5..5e6f4e56113c 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -191,6 +191,10 @@ static struct test {
.func = test_session_topology,
},
{
+   .desc = "Test thread comm handling",
+   .func = test__thread_comm,
+   },
+   {
.func = NULL,
},
 };
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 0b3549672c16..23552471535a 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -65,6 +65,7 @@ int test__thread_map(void);
 int test__llvm(void);
 int test__insn_x86(void);
 int test_session_topology(void);
+int test__thread_comm(void);
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || 
defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
diff --git a/tools/perf/tests/thread-comm.c b/tools/perf/tests/thread-comm.c
new file mode 100644
index ..d146dedf63b4
--- /dev/null
+++ b/tools/perf/tests/thread-comm.c
@@ -0,0 +1,47 @@
+#include "tests.h"
+#include "machine.h"
+#include "thread.h"
+#include "debug.h"
+
+int test__thread_comm(void)
+{
+   struct machines machines;
+   struct machine *machine;
+   struct thread *t;
+
+   /*
+* This test is to check whether it can retrieve a correct
+* comm for a given time.  When multi-file data storage is
+* enabled, those task/comm events are processed first so the
+* later sample should find a matching comm properly.
+*/
+   machines__init();
+   machine = 
+
+   t = machine__findnew_thread(machine, 100, 100);
+   TEST_ASSERT_VAL("wrong init thread comm",
+   !strcmp(thread__comm_str(t), ":100"));
+
+   thread__set_comm(t, "perf-test1", 1);
+   TEST_ASSERT_VAL("failed to override thread comm",
+   !strcmp(thread__comm_str(t), "perf-test1"));
+
+   thread__set_comm(t, "perf-test2", 2);
+   thread__set_comm(t, "perf-test3", 3);
+   thread__set_comm(t, "perf-test4", 4);
+
+   TEST_ASSERT_VAL("failed to find timed comm",
+   !strcmp(thread__comm_str_by_time(t, 2), 
"perf-test2"));
+   TEST_ASSERT_VAL("failed to find timed comm",
+   !strcmp(thread__comm_str_by_time(t, 35000), 
"perf-test3"));
+   TEST_ASSERT_VAL("failed to find timed comm",
+   !strcmp(thread__comm_str_by_time(t, 5), 
"perf-test4"));
+
+   thread__set_comm(t, "perf-test1.5", 15000);
+   TEST_ASSERT_VAL("failed to sort timed comm",
+   !strcmp(thread__comm_str_by_time(t, 15000), 
"perf-test1.5"));
+
+   machine__delete_threads(machine);
+   machines__exit();
+   return 0;
+}
-- 
2.6.0

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


[RFC/PATCH 06/38] perf tools: Extend perf_evlist__mmap_ex() to use track mmap

2015-10-01 Thread Namhyung Kim
The perf_evlist__mmap_ex function creates data and auxtrace mmaps and
optionally tracking mmaps for events now.  It'll be used for perf
record to save events in a separate files and build an index table.
Checking dummy tracking event in perf_evlist__mmap() alone is not
enough as users can specify a dummy event (like in keep tracking
testcase) without the index option.

Cc: Adrian Hunter 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-record.c | 2 +-
 tools/perf/util/evlist.c| 6 --
 tools/perf/util/evlist.h| 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 33dc2eafe2b5..90b1237d2525 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -306,7 +306,7 @@ try_again:
 
if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, false,
 opts->auxtrace_mmap_pages,
-opts->auxtrace_snapshot_mode) < 0) {
+opts->auxtrace_snapshot_mode, false) < 0) {
if (errno == EPERM) {
pr_err("Permission error mapping pages.\n"
   "Consider increasing "
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 25a9c3b5f473..61e83d930e92 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1243,6 +1243,7 @@ int perf_evlist__parse_mmap_pages(const struct option 
*opt, const char *str,
  * @overwrite: overwrite older events?
  * @auxtrace_pages - auxtrace map length in pages
  * @auxtrace_overwrite - overwrite older auxtrace data?
+ * @use_track_mmap: use another mmaps to track meta events
  *
  * If @overwrite is %false the user needs to signal event consumption using
  * perf_mmap__write_tail().  Using perf_evlist__mmap_read() does this
@@ -1255,13 +1256,14 @@ int perf_evlist__parse_mmap_pages(const struct option 
*opt, const char *str,
  */
 int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
 bool overwrite, unsigned int auxtrace_pages,
-bool auxtrace_overwrite)
+bool auxtrace_overwrite, bool use_track_mmap)
 {
struct perf_evsel *evsel;
const struct cpu_map *cpus = evlist->cpus;
const struct thread_map *threads = evlist->threads;
struct mmap_params mp = {
.prot = PROT_READ | (overwrite ? 0 : PROT_WRITE),
+   .track_mmap = use_track_mmap,
};
 
if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist, 
mp.track_mmap) < 0)
@@ -1294,7 +1296,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, 
unsigned int pages,
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
  bool overwrite)
 {
-   return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false);
+   return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false, false);
 }
 
 int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index fc53eb817c51..1ed7b7e8b968 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -144,7 +144,7 @@ int perf_evlist__parse_mmap_pages(const struct option *opt,
 
 int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
 bool overwrite, unsigned int auxtrace_pages,
-bool auxtrace_overwrite);
+bool auxtrace_overwrite, bool use_track_mmap);
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
  bool overwrite);
 void perf_evlist__munmap(struct perf_evlist *evlist);
-- 
2.6.0

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


[RFC/PATCH 18/38] perf tools: Introduce thread__find_addr_location_by_time() and friends

2015-10-01 Thread Namhyung Kim
These new functions are for find appropriate map (and symbol) at the
given time when used with an indexed data file.  This is based on the
fact that map_groups list is sorted by time in the previous patch.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/event.c   | 59 +++
 tools/perf/util/machine.c | 28 ++
 tools/perf/util/session.h |  1 +
 tools/perf/util/thread.c  | 26 +
 tools/perf/util/thread.h  | 11 +
 5 files changed, 106 insertions(+), 19 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 887f18266ab5..c960cbcd30d4 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -895,16 +895,14 @@ int perf_event__process(struct perf_tool *tool 
__maybe_unused,
return machine__process_event(machine, event, sample);
 }
 
-void thread__find_addr_map(struct thread *thread, u8 cpumode,
-  enum map_type type, u64 addr,
-  struct addr_location *al)
+static void map_groups__find_addr_map(struct map_groups *mg, u8 cpumode,
+ enum map_type type, u64 addr,
+ struct addr_location *al)
 {
-   struct map_groups *mg = thread->mg;
struct machine *machine = mg->machine;
bool load_map = false;
 
al->machine = machine;
-   al->thread = thread;
al->addr = addr;
al->cpumode = cpumode;
al->filtered = 0;
@@ -973,6 +971,29 @@ try_again:
}
 }
 
+void thread__find_addr_map(struct thread *thread, u8 cpumode,
+  enum map_type type, u64 addr,
+  struct addr_location *al)
+{
+   al->thread = thread;
+   map_groups__find_addr_map(thread->mg, cpumode, type, addr, al);
+}
+
+void thread__find_addr_map_by_time(struct thread *thread, u8 cpumode,
+  enum map_type type, u64 addr,
+  struct addr_location *al, u64 timestamp)
+{
+   struct map_groups *mg;
+
+   if (perf_has_index)
+   mg = thread__get_map_groups(thread, timestamp);
+   else
+   mg = thread->mg;
+
+   al->thread = thread;
+   map_groups__find_addr_map(mg, cpumode, type, addr, al);
+}
+
 void thread__find_addr_location(struct thread *thread,
u8 cpumode, enum map_type type, u64 addr,
struct addr_location *al)
@@ -985,6 +1006,23 @@ void thread__find_addr_location(struct thread *thread,
al->sym = NULL;
 }
 
+void thread__find_addr_location_by_time(struct thread *thread, u8 cpumode,
+   enum map_type type, u64 addr,
+   struct addr_location *al, u64 timestamp)
+{
+   if (perf_has_index)
+   thread__find_addr_map_by_time(thread, cpumode, type, addr, al,
+ timestamp);
+   else
+   thread__find_addr_map(thread, cpumode, type, addr, al);
+
+   if (al->map != NULL)
+   al->sym = map__find_symbol(al->map, al->addr,
+  thread->mg->machine->symbol_filter);
+   else
+   al->sym = NULL;
+}
+
 /*
  * Callers need to drop the reference to al->thread, obtained in
  * machine__findnew_thread()
@@ -1014,7 +1052,9 @@ int perf_event__preprocess_sample(const union perf_event 
*event,
machine__kernel_map(machine) == NULL)
machine__create_kernel_maps(machine);
 
-   thread__find_addr_map(thread, cpumode, MAP__FUNCTION, sample->ip, al);
+   thread__find_addr_map_by_time(thread, cpumode, MAP__FUNCTION,
+ sample->ip, al, sample->time);
+
dump_printf(" .. dso: %s\n",
al->map ? al->map->dso->long_name :
al->level == 'H' ? "[hypervisor]" : "");
@@ -1097,10 +1137,11 @@ void perf_event__preprocess_sample_addr(union 
perf_event *event,
 {
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 
-   thread__find_addr_map(thread, cpumode, MAP__FUNCTION, sample->addr, al);
+   thread__find_addr_map_by_time(thread, cpumode, MAP__FUNCTION,
+ sample->addr, al, sample->time);
if (!al->map)
-   thread__find_addr_map(thread, cpumode, MAP__VARIABLE,
- sample->addr, al);
+   thread__find_addr_map_by_time(thread, cpumode, MAP__VARIABLE,
+ sample->addr, al, sample->time);
 
al->cpu = sample->cpu;
al->sym = NULL;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 3373e8455945..d5e5b9de54b0 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1688,7 +1688,7 @@ static 

[RFC/PATCH 11/38] perf tools: Introduce thread__comm(_str)_by_time() helpers

2015-10-01 Thread Namhyung Kim
When data file indexing is enabled, it processes all task, comm and mmap
events first and then goes to the sample events.  So all it sees is the
last comm of a thread although it has information at the time of sample.

Sort thread's comm by time so that it can find appropriate comm at the
sample time.  The thread__comm_by_time() will mostly work even if
PERF_SAMPLE_TIME bit is off since in that case, sample->time will be
-1 so it'll take the last comm anyway.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/thread.c | 33 -
 tools/perf/util/thread.h |  2 ++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 0a9ae8014729..8244397753fd 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -121,6 +121,21 @@ struct comm *thread__exec_comm(const struct thread *thread)
return last;
 }
 
+struct comm *thread__comm_by_time(const struct thread *thread, u64 timestamp)
+{
+   struct comm *comm;
+
+   list_for_each_entry(comm, >comm_list, list) {
+   if (timestamp >= comm->start)
+   return comm;
+   }
+
+   if (list_empty(>comm_list))
+   return NULL;
+
+   return list_last_entry(>comm_list, struct comm, list);
+}
+
 int __thread__set_comm(struct thread *thread, const char *str, u64 timestamp,
   bool exec)
 {
@@ -136,7 +151,13 @@ int __thread__set_comm(struct thread *thread, const char 
*str, u64 timestamp,
new = comm__new(str, timestamp, exec);
if (!new)
return -ENOMEM;
-   list_add(>list, >comm_list);
+
+   /* sort by time */
+   list_for_each_entry(curr, >comm_list, list) {
+   if (timestamp >= curr->start)
+   break;
+   }
+   list_add_tail(>list, >list);
 
if (exec)
unwind__flush_access(thread);
@@ -157,6 +178,16 @@ const char *thread__comm_str(const struct thread *thread)
return comm__str(comm);
 }
 
+const char *thread__comm_str_by_time(const struct thread *thread, u64 
timestamp)
+{
+   const struct comm *comm = thread__comm_by_time(thread, timestamp);
+
+   if (!comm)
+   return NULL;
+
+   return comm__str(comm);
+}
+
 /* CHECKME: it should probably better return the max comm len from its comm 
list */
 int thread__comm_len(struct thread *thread)
 {
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index a0ac0317affb..33418e6dc64a 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -68,7 +68,9 @@ static inline int thread__set_comm(struct thread *thread, 
const char *comm,
 int thread__comm_len(struct thread *thread);
 struct comm *thread__comm(const struct thread *thread);
 struct comm *thread__exec_comm(const struct thread *thread);
+struct comm *thread__comm_by_time(const struct thread *thread, u64 timestamp);
 const char *thread__comm_str(const struct thread *thread);
+const char *thread__comm_str_by_time(const struct thread *thread, u64 
timestamp);
 void thread__insert_map(struct thread *thread, struct map *map);
 int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
 size_t thread__fprintf(struct thread *thread, FILE *fp);
-- 
2.6.0

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


[RFC/PATCH 14/38] perf tools: Convert dead thread list into rbtree

2015-10-01 Thread Namhyung Kim
Currently perf maintains dead threads in a linked list but this can be
a problem if someone needs to search from it especially in a large
session which might have many dead threads.  Convert it to a rbtree
like normal threads and it'll be used later with multi-thread changes.

The list node is now used for chaining dead threads of same tid since
it's easier to handle such threads in time order.

Cc: Frederic Weisbecker 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/machine.c | 82 +--
 tools/perf/util/machine.h |  2 +-
 tools/perf/util/thread.c  | 18 ++-
 tools/perf/util/thread.h  | 11 +++
 4 files changed, 96 insertions(+), 17 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 5ef90be2a249..2b9fbe55c896 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -30,8 +30,8 @@ int machine__init(struct machine *machine, const char 
*root_dir, pid_t pid)
dsos__init(>dsos);
 
machine->threads = RB_ROOT;
+   machine->dead_threads = RB_ROOT;
pthread_rwlock_init(>threads_lock, NULL);
-   INIT_LIST_HEAD(>dead_threads);
machine->last_match = NULL;
 
machine->vdso_info = NULL;
@@ -104,6 +104,28 @@ static void dsos__exit(struct dsos *dsos)
pthread_rwlock_destroy(>lock);
 }
 
+static void machine__delete_dead_threads(struct machine *machine)
+{
+   struct rb_node *nd = rb_first(>dead_threads);
+
+   while (nd) {
+   struct thread *t = rb_entry(nd, struct thread, rb_node);
+   struct thread *pos;
+
+   nd = rb_next(nd);
+   rb_erase_init(>rb_node, >dead_threads);
+
+   while (!list_empty(>tid_list)) {
+   pos = list_first_entry(>tid_list,
+  struct thread, tid_list);
+   list_del_init(>tid_list);
+   thread__delete(pos);
+   }
+
+   thread__delete(t);
+   }
+}
+
 void machine__delete_threads(struct machine *machine)
 {
struct rb_node *nd;
@@ -117,6 +139,8 @@ void machine__delete_threads(struct machine *machine)
__machine__remove_thread(machine, t, false);
}
pthread_rwlock_unlock(>threads_lock);
+
+   machine__delete_dead_threads(machine);
 }
 
 void machine__exit(struct machine *machine)
@@ -1361,6 +1385,10 @@ out_problem:
 
 static void __machine__remove_thread(struct machine *machine, struct thread 
*th, bool lock)
 {
+   struct rb_node **p = >dead_threads.rb_node;
+   struct rb_node *parent = NULL;
+   struct thread *pos;
+
if (machine->last_match == th)
machine->last_match = NULL;
 
@@ -1368,16 +1396,45 @@ static void __machine__remove_thread(struct machine 
*machine, struct thread *th,
if (lock)
pthread_rwlock_wrlock(>threads_lock);
rb_erase_init(>rb_node, >threads);
-   RB_CLEAR_NODE(>rb_node);
+
+   th->dead = true;
+
/*
-* Move it first to the dead_threads list, then drop the reference,
-* if this is the last reference, then the thread__delete destructor
-* will be called and we will remove it from the dead_threads list.
+* No need to have an additional reference for non-index file
+* as they can be released when reference holders died and
+* there will be no more new references.
 */
-   list_add_tail(>node, >dead_threads);
+   if (!perf_has_index) {
+   thread__put(th);
+   goto out;
+   }
+
+   /*
+* For indexed file, We may have references to this (dead)
+* thread, as samples are processed after fork/exit events.
+* Just move them to a separate rbtree and keep a reference.
+*/
+   while (*p != NULL) {
+   parent = *p;
+   pos = rb_entry(parent, struct thread, rb_node);
+
+   if (pos->tid == th->tid) {
+   list_add_tail(>tid_list, >tid_list);
+   goto out;
+   }
+
+   if (th->tid < pos->tid)
+   p = &(*p)->rb_left;
+   else
+   p = &(*p)->rb_right;
+   }
+
+   rb_link_node(>rb_node, parent, p);
+   rb_insert_color(>rb_node, >dead_threads);
+
+out:
if (lock)
pthread_rwlock_unlock(>threads_lock);
-   thread__put(th);
 }
 
 void machine__remove_thread(struct machine *machine, struct thread *th)
@@ -1899,7 +1956,7 @@ int machine__for_each_thread(struct machine *machine,
 void *priv)
 {
struct rb_node *nd;
-   struct thread *thread;
+   struct thread *thread, *pos;
int rc = 0;
 
for (nd = rb_first(>threads); nd; nd = rb_next(nd)) {
@@ -1909,10 +1966,17 @@ int machine__for_each_thread(struct machine *machine,
return rc;

[RFC/PATCH 24/38] perf tools: Add testcase for managing maps with time

2015-10-01 Thread Namhyung Kim
This tests new map_groups__{insert,find}_by_time() API working
correctly by using 3 * 100 maps.

Cc: Stephane Eranian 
Signed-off-by: Namhyung Kim 
---
 tools/perf/tests/Build |  1 +
 tools/perf/tests/builtin-test.c|  4 ++
 tools/perf/tests/tests.h   |  1 +
 tools/perf/tests/thread-map-time.c | 90 ++
 4 files changed, 96 insertions(+)
 create mode 100644 tools/perf/tests/thread-map-time.c

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index d287b99ff3bb..cc4e3af3e0fd 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -28,6 +28,7 @@ perf-y += thread-comm.o
 perf-y += thread-mg-share.o
 perf-y += thread-lookup-time.o
 perf-y += thread-mg-time.o
+perf-y += thread-map-time.o
 perf-y += switch-tracking.o
 perf-y += keep-tracking.o
 perf-y += code-reading.o
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 62de08a89e0e..d5f9fcef5571 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -203,6 +203,10 @@ static struct test {
.func = test__thread_mg_time,
},
{
+   .desc = "Test thread map lookup with time",
+   .func = test__thread_map_lookup_time,
+   },
+   {
.func = NULL,
},
 };
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 03dcaccb570f..e498b23f1580 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -68,6 +68,7 @@ int test_session_topology(void);
 int test__thread_comm(void);
 int test__thread_lookup_time(void);
 int test__thread_mg_time(void);
+int test__thread_map_lookup_time(void);
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || 
defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
diff --git a/tools/perf/tests/thread-map-time.c 
b/tools/perf/tests/thread-map-time.c
new file mode 100644
index ..6f28975faeb5
--- /dev/null
+++ b/tools/perf/tests/thread-map-time.c
@@ -0,0 +1,90 @@
+#include "debug.h"
+#include "tests.h"
+#include "machine.h"
+#include "thread.h"
+#include "map.h"
+
+#define PERF_MAP_START  0x4
+#define LIBC_MAP_START  0x8
+#define VDSO_MAP_START  0x7F000
+
+#define NR_MAPS  100
+
+static int lookup_maps(struct map_groups *mg)
+{
+   struct map *map;
+   int i, ret = -1;
+   size_t n;
+   struct {
+   const char *path;
+   u64 start;
+   } maps[] = {
+   { "/usr/bin/perf",  PERF_MAP_START },
+   { "/usr/lib/libc.so",   LIBC_MAP_START },
+   { "[vdso]", VDSO_MAP_START },
+   };
+
+   /* this is needed to insert/find map by time */
+   perf_has_index = true;
+
+   for (n = 0; n < ARRAY_SIZE(maps); n++) {
+   for (i = 0; i < NR_MAPS; i++) {
+   map = map__new2(maps[n].start, dso__new(maps[n].path),
+   MAP__FUNCTION, i * 1);
+   if (map == NULL) {
+   pr_debug("memory allocation failed\n");
+   goto out;
+   }
+
+   map->end = map->start + 0x1000;
+   map_groups__insert_by_time(mg, map);
+   }
+   }
+
+   if (verbose > 1)
+   map_groups__fprintf(mg, stderr);
+
+   for (n = 0; n < ARRAY_SIZE(maps); n++) {
+   for (i = 0; i < NR_MAPS; i++) {
+   u64 timestamp = i * 1;
+
+   map = map_groups__find_by_time(mg, MAP__FUNCTION,
+  maps[n].start,
+  timestamp);
+
+   TEST_ASSERT_VAL("cannot find map", map);
+   TEST_ASSERT_VAL("addr not matched",
+   map->start == maps[n].start);
+   TEST_ASSERT_VAL("pathname not matched",
+   !strcmp(map->dso->name, maps[n].path));
+   TEST_ASSERT_VAL("timestamp not matched",
+   map->timestamp == timestamp);
+   }
+   }
+
+   ret = 0;
+out:
+   return ret;
+}
+
+/*
+ * This test creates large number of overlapping maps for increasing
+ * time and find a map based on timestamp.
+ */
+int test__thread_map_lookup_time(void)
+{
+   struct machines machines;
+   struct machine *machine;
+   struct thread *t;
+   int ret;
+
+   machines__init();
+   machine = 
+
+   t = machine__findnew_thread(machine, 0, 0);
+
+   ret = lookup_maps(t->mg);
+
+   machine__delete_threads(machine);
+   return ret;
+}
-- 
2.6.0

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

[RFC/PATCH 09/38] perf record: Add --index option for building index table

2015-10-01 Thread Namhyung Kim
The new --index option will create indexed data file which can be
processed by multiple threads parallelly.  It saves meta event and
sample data in separate files and merges them with an index table.

If there's an index table in the data file, the HEADER_DATA_INDEX
feature bit is set and session->header.index[0] will point to the meta
event area, and rest are sample data.  It'd look like below:

+-+
| file header |
|-|
| |
|meta events[0] <-+--+
| |  |
|-|  |
| |  |
|sample data[1] <-+--+
| |  |
|-|  |
| |  |
|sample data[2] <-|--+
| |  |
|-|  |
| ... | ...
|-|  |
| feature data|  |
|   (contains index) -+--+
+-+

Signed-off-by: Namhyung Kim 
---
 tools/perf/Documentation/perf-record.txt |   4 +
 tools/perf/builtin-record.c  | 178 ---
 tools/perf/perf.h|   1 +
 tools/perf/util/header.c |   2 +
 tools/perf/util/session.c|   1 +
 5 files changed, 173 insertions(+), 13 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index 2e9ce77b5e14..71a9520b10b0 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -308,6 +308,10 @@ This option sets the time out limit. The default value is 
500 ms.
 Record context switch events i.e. events of type PERF_RECORD_SWITCH or
 PERF_RECORD_SWITCH_CPU_WIDE.
 
+--index::
+Build an index table for sample data.  This will speed up perf report by
+parallel processing.
+
 SEE ALSO
 
 linkperf:perf-stat[1], linkperf:perf-list[1]
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 623984c81478..096634c4c5ea 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -43,6 +43,7 @@ struct record {
u64 bytes_written;
struct perf_data_file   file;
struct auxtrace_record  *itr;
+   int *fds;
struct perf_evlist  *evlist;
struct perf_session *session;
const char  *progname;
@@ -52,9 +53,16 @@ struct record {
longsamples;
 };
 
-static int record__write(struct record *rec, void *bf, size_t size)
+static int record__write(struct record *rec, void *bf, size_t size, int idx)
 {
-   if (perf_data_file__write(rec->session->file, bf, size) < 0) {
+   int fd;
+
+   if (rec->fds && idx >= 0)
+   fd = rec->fds[idx];
+   else
+   fd = perf_data_file__fd(rec->session->file);
+
+   if (writen(fd, bf, size) < 0) {
pr_err("failed to write perf data, error: %m\n");
return -1;
}
@@ -69,7 +77,7 @@ static int process_synthesized_event(struct perf_tool *tool,
 struct machine *machine __maybe_unused)
 {
struct record *rec = container_of(tool, struct record, tool);
-   return record__write(rec, event, event->header.size);
+   return record__write(rec, event, event->header.size, -1);
 }
 
 static int record__mmap_read(struct record *rec, int idx)
@@ -94,7 +102,7 @@ static int record__mmap_read(struct record *rec, int idx)
size = md->mask + 1 - (old & md->mask);
old += size;
 
-   if (record__write(rec, buf, size) < 0) {
+   if (record__write(rec, buf, size, idx) < 0) {
rc = -1;
goto out;
}
@@ -104,7 +112,7 @@ static int record__mmap_read(struct record *rec, int idx)
size = head - old;
old += size;
 
-   if (record__write(rec, buf, size) < 0) {
+   if (record__write(rec, buf, size, idx) < 0) {
rc = -1;
goto out;
}
@@ -151,6 +159,7 @@ static int record__process_auxtrace(struct perf_tool *tool,
struct perf_data_file *file = >file;
size_t padding;
u8 pad[8] = {0};
+   int idx = event->auxtrace.idx;
 
if (!perf_data_file__is_pipe(file)) {
off_t file_offset;
@@ -171,11 +180,11 @@ static int record__process_auxtrace(struct perf_tool 
*tool,
if (padding)
padding = 8 - padding;
 
-   record__write(rec, event, event->header.size);
-   record__write(rec, data1, len1);
+   record__write(rec, event, event->header.size, idx);
+   record__write(rec, data1, len1, idx);
if (len2)
-   record__write(rec, data2, len2);
-   record__write(rec, , padding);
+ 

[RFC/PATCH 07/38] perf tools: Add HEADER_DATA_INDEX feature

2015-10-01 Thread Namhyung Kim
The HEADER_DATA_INDEX feature is to record index table for sample data
so that they can be processed by multiple thread concurrently.  Each
item is a struct perf_file_section which consists of an offset and size.

Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-record.c |  2 ++
 tools/perf/util/header.c| 64 +
 tools/perf/util/header.h|  3 +++
 3 files changed, 69 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 90b1237d2525..623984c81478 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -451,6 +451,8 @@ static void record__init_features(struct record *rec)
 
if (!rec->opts.full_auxtrace)
perf_header__clear_feat(>header, HEADER_AUXTRACE);
+
+   perf_header__clear_feat(>header, HEADER_DATA_INDEX);
 }
 
 static volatile int workload_exec_errno;
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 43838003c1a1..c357f7f47d32 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -868,6 +868,24 @@ static int write_auxtrace(int fd, struct perf_header *h,
return err;
 }
 
+static int write_data_index(int fd, struct perf_header *h,
+   struct perf_evlist *evlist __maybe_unused)
+{
+   int ret;
+   unsigned i;
+
+   ret = do_write(fd, >nr_index, sizeof(h->nr_index));
+   if (ret < 0)
+   return ret;
+
+   for (i = 0; i < h->nr_index; i++) {
+   ret = do_write(fd, >index[i], sizeof(*h->index));
+   if (ret < 0)
+   return ret;
+   }
+   return 0;
+}
+
 static void print_hostname(struct perf_header *ph, int fd __maybe_unused,
   FILE *fp)
 {
@@ -1221,6 +1239,12 @@ static void print_group_desc(struct perf_header *ph, int 
fd __maybe_unused,
}
 }
 
+static void print_data_index(struct perf_header *ph __maybe_unused,
+int fd __maybe_unused, FILE *fp)
+{
+   fprintf(fp, "# contains data index for parallel processing\n");
+}
+
 static int __event_process_build_id(struct build_id_event *bev,
char *filename,
struct perf_session *session)
@@ -1891,6 +1915,7 @@ out_free:
return ret;
 }
 
+
 static int process_auxtrace(struct perf_file_section *section,
struct perf_header *ph, int fd,
void *data __maybe_unused)
@@ -1907,6 +1932,44 @@ static int process_auxtrace(struct perf_file_section 
*section,
return err;
 }
 
+static int process_data_index(struct perf_file_section *section __maybe_unused,
+ struct perf_header *ph, int fd,
+ void *data __maybe_unused)
+{
+   ssize_t ret;
+   u64 nr_idx;
+   unsigned i;
+   struct perf_file_section *idx;
+
+   ret = readn(fd, _idx, sizeof(nr_idx));
+   if (ret != sizeof(nr_idx))
+   return -1;
+
+   if (ph->needs_swap)
+   nr_idx = bswap_64(nr_idx);
+
+   idx = calloc(nr_idx, sizeof(*idx));
+   if (idx == NULL)
+   return -1;
+
+   for (i = 0; i < nr_idx; i++) {
+   ret = readn(fd, [i], sizeof(*idx));
+   if (ret != sizeof(*idx)) {
+   free(idx);
+   return -1;
+   }
+
+   if (ph->needs_swap) {
+   idx[i].offset = bswap_64(idx[i].offset);
+   idx[i].size   = bswap_64(idx[i].size);
+   }
+   }
+
+   ph->index = idx;
+   ph->nr_index = nr_idx;
+   return 0;
+}
+
 struct feature_ops {
int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist);
void (*print)(struct perf_header *h, int fd, FILE *fp);
@@ -1948,6 +2011,7 @@ static const struct feature_ops 
feat_ops[HEADER_LAST_FEATURE] = {
FEAT_OPP(HEADER_PMU_MAPPINGS,   pmu_mappings),
FEAT_OPP(HEADER_GROUP_DESC, group_desc),
FEAT_OPP(HEADER_AUXTRACE,   auxtrace),
+   FEAT_OPP(HEADER_DATA_INDEX, data_index),
 };
 
 struct header_print_data {
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 05f27cb6b7e3..add455a7abff 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -31,6 +31,7 @@ enum {
HEADER_PMU_MAPPINGS,
HEADER_GROUP_DESC,
HEADER_AUXTRACE,
+   HEADER_DATA_INDEX,
HEADER_LAST_FEATURE,
HEADER_FEAT_BITS= 256,
 };
@@ -71,6 +72,8 @@ struct perf_header {
boolneeds_swap;
u64 data_offset;
u64 data_size;
+   struct perf_file_section*index;
+   u64 nr_index;
u64 feat_offset;
DECLARE_BITMAP(adds_features, 

[RFC/PATCH 01/38] perf tools: Use a software dummy event to track task/mmap events

2015-10-01 Thread Namhyung Kim
Add APIs for software dummy event to track task/comm/mmap events
separately.  The perf record will use them to save such events in a
separate mmap buffer to make it easy to index.  This is a preparation of
multi-thread support which will come later.

Cc: Adrian Hunter 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/evlist.c | 30 ++
 tools/perf/util/evlist.h |  1 +
 tools/perf/util/evsel.h  | 15 +++
 3 files changed, 46 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index e7e195d867ea..c5180a29db1b 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -248,6 +248,36 @@ error:
return -ENOMEM;
 }
 
+int perf_evlist__add_dummy_tracking(struct perf_evlist *evlist)
+{
+   struct perf_event_attr attr = {
+   .type = PERF_TYPE_SOFTWARE,
+   .config = PERF_COUNT_SW_DUMMY,
+   .exclude_kernel = 1,
+   };
+   struct perf_evsel *evsel;
+
+   event_attr_init();
+
+   evsel = perf_evsel__new();
+   if (evsel == NULL)
+   goto error;
+
+   /* use strdup() because free(evsel) assumes name is allocated */
+   evsel->name = strdup("dummy");
+   if (!evsel->name)
+   goto error_free;
+
+   perf_evlist__add(evlist, evsel);
+   perf_evlist__set_tracking_event(evlist, evsel);
+
+   return 0;
+error_free:
+   perf_evsel__delete(evsel);
+error:
+   return -ENOMEM;
+}
+
 static int perf_evlist__add_attrs(struct perf_evlist *evlist,
  struct perf_event_attr *attrs, size_t 
nr_attrs)
 {
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 66bc9d4c0869..414e383885f5 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -75,6 +75,7 @@ void perf_evlist__delete(struct perf_evlist *evlist);
 void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
 void perf_evlist__remove(struct perf_evlist *evlist, struct perf_evsel *evsel);
 int perf_evlist__add_default(struct perf_evlist *evlist);
+int perf_evlist__add_dummy_tracking(struct perf_evlist *evlist);
 int __perf_evlist__add_default_attrs(struct perf_evlist *evlist,
 struct perf_event_attr *attrs, size_t 
nr_attrs);
 
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 790580da..8d2445347b0f 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -359,6 +359,21 @@ static inline bool perf_evsel__is_function_event(struct 
perf_evsel *evsel)
 #undef FUNCTION_EVENT
 }
 
+/**
+ * perf_evsel__is_dummy_tracking - Return whether given evsel is a dummy
+ * event for tracking meta events only
+ *
+ * @evsel - evsel selector to be tested
+ *
+ * Return %true if event is a dummy tracking event
+ */
+static inline bool perf_evsel__is_dummy_tracking(struct perf_evsel *evsel)
+{
+   return evsel->attr.type == PERF_TYPE_SOFTWARE &&
+   evsel->attr.config == PERF_COUNT_SW_DUMMY &&
+   evsel->attr.task == 1 && evsel->attr.mmap == 1;
+}
+
 struct perf_attr_details {
bool freq;
bool verbose;
-- 
2.6.0

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


[RFC/PATCH 04/38] perf tools: pass perf_mmap desc directly

2015-10-01 Thread Namhyung Kim
Pass struct perf_mmap to mmap handling functions directly.  This will
be used by both of normal mmap and track mmap later.

Signed-off-by: Namhyung Kim 
---
 tools/perf/util/evlist.c | 24 +++-
 tools/perf/util/evlist.h |  1 +
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 042dffc67986..8d31883cbeb8 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -921,8 +921,8 @@ struct mmap_params {
struct auxtrace_mmap_params auxtrace_mp;
 };
 
-static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
-  struct mmap_params *mp, int fd)
+static int perf_mmap__mmap(struct perf_mmap *desc,
+  struct mmap_params *mp, int fd)
 {
/*
 * The last one will be done at perf_evlist__mmap_consume(), so that we
@@ -937,21 +937,26 @@ static int __perf_evlist__mmap(struct perf_evlist 
*evlist, int idx,
 * evlist layer can't just drop it when filtering events in
 * perf_evlist__filter_pollfd().
 */
-   atomic_set(>mmap[idx].refcnt, 2);
-   evlist->mmap[idx].prev = 0;
-   evlist->mmap[idx].mask = perf_evlist__mmap_mask(mp->len);
-   evlist->mmap[idx].base = mmap(NULL, mp->len, mp->prot,
+   atomic_set(>refcnt, 2);
+   desc->prev = 0;
+   desc->mask = perf_evlist__mmap_mask(mp->len);
+   desc->base = mmap(NULL, mp->len, mp->prot,
  MAP_SHARED, fd, 0);
-   if (evlist->mmap[idx].base == MAP_FAILED) {
+   if (desc->base == MAP_FAILED) {
pr_debug2("failed to mmap perf event ring buffer, error %d\n",
  errno);
-   evlist->mmap[idx].base = NULL;
+   desc->base = NULL;
return -1;
}
 
return 0;
 }
 
+struct perf_mmap *perf_evlist__mmap_desc(struct perf_evlist *evlist, int idx)
+{
+   return >mmap[idx];
+}
+
 static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
   struct mmap_params *mp, int cpu,
   int thread, int *output)
@@ -960,6 +965,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist 
*evlist, int idx,
 
evlist__for_each(evlist, evsel) {
int fd;
+   struct perf_mmap *desc = perf_evlist__mmap_desc(evlist, idx);
 
if (evsel->system_wide && thread)
continue;
@@ -968,7 +974,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist 
*evlist, int idx,
 
if (*output == -1) {
*output = fd;
-   if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0)
+   if (perf_mmap__mmap(desc, mp, *output) < 0)
return -1;
 
if (auxtrace_mmap__mmap(>auxtrace_mmap[idx],
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 51574ce8ac69..79f8245300ad 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -145,6 +145,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, 
unsigned int pages,
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
  bool overwrite);
 void perf_evlist__munmap(struct perf_evlist *evlist);
+struct perf_mmap *perf_evlist__mmap_desc(struct perf_evlist *evlist, int idx);
 
 void perf_evlist__disable(struct perf_evlist *evlist);
 void perf_evlist__enable(struct perf_evlist *evlist);
-- 
2.6.0

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


[RFC/PATCH 00/38] perf tools: Speed-up perf report by using multi thread (v5)

2015-10-01 Thread Namhyung Kim
Hello,

This patchset converts perf report to use multiple threads in order to
speed up the processing on large data files.  I can see a minimum ~30%
of speedup with this change.  The code is still experimental and
contains many rough edges.  But I'd like to share and give some
feedbacks.

 * changes in v5)
   - move struct machines from perf_session to perf_tool  (Arnaldo)
   - add --num-thread option to perf report  (David)
   - separate track_mmap code for review  (Jiri)
   - fix some minor bugs  (Jiri)

 * changes in v4)
   - rename to *_find(new)_by_time()
   - also sort struct map by time
   - use 'perf_has_index' global variable
   - fix an off-by-one bug in index generation
   - rebased onto the recent atomic thread refcounting
   - remove missing threads tree in favor of thread rwlock

 * changes in v3)
   - handle header (metadata) same as sample data (at index 0)
   - maintain libunwind address space in map_groups instead of thread
   - use *_time API only for indexed data file
   - resolve callchain with the *_time API
   - use dso__data_get/put_fd() to protect access to fd
   - synthesize COMM event for command line workload

 * changes in v2)
   - rework with single indexed data file rather than multiple files in
 a directory

The perf report processes (sample) events like below:

  1. preprocess sample to get matching thread/dso/symbol info
  2. insert it to hists rbtree (with callchain tree) based on the info
  3. optionally collapse hist entries that match given sort key(s)
  4. resort hist entries (by overhead) for output
  5. display the hist entries

The stage 1 is a preprocessing and mostly act like a read-only
operation in that it doesn't change a machine state during the sample
processing.  Meta events like fork, comm and mmap can change the
machine/thread state but symbols can be loaded during the processing
(stage 2).

The stage 2 consumes most of the time especially with callchains and
 --children option is enabled.  And this work can be easily patitioned
as each sample is independent to others.  But the resulting hists must
be combined/collapsed to a single global hists before going to further
steps.

The stage 3 is optional and only needed by certain sort keys - but
with stage 2 paralellized, it needs to be done always.

The stage 4 and 5 works on whole hists so must be done serially.

So my approach is like this:

Partially do stage 1 first - but only for meta events that changes
machine state.  To do this I add a dummy tracking event to perf record
and make it collect such meta events only.  They are saved as normal
data and processed before sample events at perf report time.

This also requires to handle multiple sample data concurrently and to
find a corresponding machine state when processing samples.  On a
large profiling session, many tasks were created and exited so pid
might be recycled (even more than once!).  To deal with it, I managed
to have thread, map_groups, map and comm in time sorted.  The only
remaining thing is symbol loading as it's done lazily when sample
requires it.

With that being done, the stage 2 can be done by multiple threads.  I
also save each sample data (per-cpu or per-thread) in separate files
during record and then merge them into a single data file with an
index table.  On perf report time, each region of sample data will be
processed by each thread.  And symbol loading is protected by a mutex
lock.

For DWARF post-unwinding, dso cache data also needs to be protected by
a lock and this caused a huge contention.  I made it to search the
rbtree speculatively first and then, if it didn't find one, search it
again under the dso lock.  Please take a look at it if it's acceptable.

The patch 1-9 are to support indexing for data file.  With --index
option, perf record will create a intermediate directory and then save
meta events and sample data to separate files.  And finally it'll
build an index table and concatenate the data files (and also remove
the intermediate directory).

The patch 10-24 are to manage machine and thread state using timestamp
so that it can be searched when processing samples.  The patch 25-35
are to implement parallel report.  And on patch 36 I implemented 'perf
data index' command to build an index table for a given data file.
The last two patches are to improve speed when using multi-thread.

This patchset didn't change perf record to use multi-thread.  But I
think it can be easily done later if needed.

Note that output has a slight difference to original version when
compared using indexed data file.  But they're mostly unresolved
symbols for callchains.

Here is the result:

This is just elapsed time measured by 'perf stat -r 5'.  Note that
overall performance in v5 slows down than v4 by ~30% possibly due to
more agressive use of atomic thread refcounting and rwlocks.

The data file was recorded during kernel build with fp callchain and
size is 2.1GB.  The machine has 6 core with hyper-threading enabled
and I got a 

Re: [PATCH 4.2 00/30] 4.2.3-stable review

2015-10-01 Thread Sudip Mukherjee
On Thu, Oct 01, 2015 at 11:21:22AM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.2.3 release.
> There are 30 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
Compiled and booted on x86_32. No errors in dmesg.

BTW, allmodconfig build of tile and tilegx failed. Nothing new. But the
fix is in Linus tree now. I will test tomorrow and send you for 4.2.4
release.

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


Re: [RFC] arm: Add generic smc wrapper

2015-10-01 Thread kbuild test robot
Hi Lars,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please 
ignore]

config: arm-rpc_defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All error/warnings (new ones prefixed by >>):

   arch/arm/kernel/smc-call.S: Assembler messages:
>> arch/arm/kernel/smc-call.S:21: Error: selected processor does not support 
>> ARM mode `bx lr'

vim +21 arch/arm/kernel/smc-call.S

15  
16  #include 
17  
18  /* int invoke_smc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
19  ENTRY(invoke_smc)
20  __SMC(0)
  > 21  bx  lr
22  ENDPROC(invoke_smc)

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH v3 2/5] mailbox: Add support for ST's Mailbox IP

2015-10-01 Thread Jassi Brar
On Wed, Aug 19, 2015 at 7:52 PM, Lee Jones  wrote:



> +
> +#define MBOX_BASE(mdev, inst)   ((mdev)->base + (inst * 4))
>
It should be(inst) * 4

> +/**
> + * STi Mailbox device data
> + *
> + * An IP Mailbox is currently composed of 4 instances
> + * Each instance is currently composed of 32 channels
> + * This means that we have 128 channels per Mailbox
> + * A channel an be used for TX or RX
> + *
> + * @dev:   Device to which it is attached
> + * @mbox:  Representation of a communication channel controller
> + * @base:  Base address of the register mapping region
> + * @name:  Name of the mailbox
> + * @enabled:   Local copy of enabled channels
> + * @lock:  Mutex protecting enabled status
> + */
> +struct sti_mbox_device {
> +   struct device   *dev;
> +   struct mbox_controller  *mbox;
> +   void __iomem*base;
> +   const char  *name;
> +   u32 enabled[STI_MBOX_INST_MAX];
> +   spinlock_t  lock;
> +   booltxonly;
>
txonly is never used after being initialized from DT :)   which is a
good sign. So maybe just drop it and the optional property 'tx-only'.

Cheers!
--
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: CPU hotplug and chained interrupts on x86

2015-10-01 Thread Mika Westerberg
On Thu, Oct 01, 2015 at 11:45:23PM +0200, Thomas Gleixner wrote:
> On Thu, 1 Oct 2015, Thomas Gleixner wrote:
> > On Thu, 1 Oct 2015, Mika Westerberg wrote:
> > > Now if I plug/unplug the card I may get few interrupts to CPU0 but rest
> > > of the interrupts never happen. Probably because IO-APIC forwards them
> > > to the lowest priority CPU which is offline at this point.
> > > 
> > > There is following check in fixup_irqs():
> > > 
> > >   if (!irq_has_action(irq) || irqd_is_per_cpu(data) ||
> > >   cpumask_subset(affinity, cpu_online_mask)) {
> > >   raw_spin_unlock(>lock);
> > >   continue;
> > >   }   
> > > 
> > > If an interrupt is requested by a driver it will force new affinity and
> > > everything works fine. However if the interrupt is chained (it does not
> > > have ->action) this is skipped and the current affinity remains.
> > > 
> > > We could detect here if the interrupt is chained but there seems to be
> > > no easy way to determine it currently so we would need to add a new flag
> > > to desc->status_use_accessors that gets set in __irq_do_set_handler()
> > > when is_chained is 1.
> > 
> > Either there or in irq_data. Need to look at it in detail.
> 
> desc->status_use_accessors is the place where this wants to go.

Thank you.

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


Re: [RFC PATCH 00/20] Coresight integration with perf

2015-10-01 Thread Alexander Shishkin
Mathieu Poirier  writes:

> On 30 September 2015 at 02:52, Alexander Shishkin
>  wrote:
>> Mathieu Poirier  writes:
>>
>>> This patchset aims to integrate configuration and control of
>>> the Coresight tracers with the perf sub-system.
>>>
>>> The goal is to use PMUs to represent tracers and the auxiliary
>>> buffer enhancement to collect processor traces.  As such a lot
>>> of work is done to move the current Coresight sysFS oriented
>>> configuration and control commands to perf's AUX API.
>>>
>>> For the time being the work concentrates on ETMv3 and ETB1.0
>>> sink buffers.  Work on ETMv4 and other type of sink buffers
>>> will follow once a foundation has been established.
>>>
>>> Enhancement to the perf command line tool can be found here [1].
>>> It is based on v4.2 but a rebase to v4.3-rcX will be available
>>> shortly.
>>>
>>> Best regards,
>>> Mathieu
>>>
>>> [1]. 
>>> https://git.linaro.org/people/mathieu.poirier/coresight.git/shortlog/refs/heads/perf-v4.2
>>
>> I had a peek there -- didn't see an actual decoder for the ETM/PTM
>> binary stream or did I miss it somehow?
>
> A stream decoder is not included in this patch set but a couple of
> people are currently working on it.

Ok, thanks. Can you provide instructions in the next version on how one
can use this code to get a trace and decode it?

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


[PATCH v2 14/38] clk: vt8500: fix sign of possible PLL values

2015-10-01 Thread Andrzej Hajda
With unsigned values underflow in loops can occur resulting in
theoretically infinite loops.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda 
---
Hi Stephen,

This is modified version according to your request, ie only problematic
variables have changed type.
I still think that 1st version is better, but of course it is up to you.

Regards
Andrzej

 drivers/clk/clk-vt8500.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
index 37e9288..98c4492 100644
--- a/drivers/clk/clk-vt8500.c
+++ b/drivers/clk/clk-vt8500.c
@@ -384,7 +384,8 @@ static void vt8500_find_pll_bits(unsigned long rate, 
unsigned long parent_rate,
 static void wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate,
u32 *multiplier, u32 *divisor1, u32 *divisor2)
 {
-   u32 mul, div1, div2;
+   u32 mul, div1;
+   int div2;
u32 best_mul, best_div1, best_div2;
unsigned long tclk, rate_err, best_err;
 
@@ -452,7 +453,8 @@ static u32 wm8750_get_filter(u32 parent_rate, u32 divisor1)
 static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
u32 *filter, u32 *multiplier, u32 *divisor1, 
u32 *divisor2)
 {
-   u32 mul, div1, div2;
+   u32 mul;
+   int div1, div2;
u32 best_mul, best_div1, best_div2;
unsigned long tclk, rate_err, best_err;
 
@@ -496,7 +498,8 @@ static void wm8750_find_pll_bits(unsigned long rate, 
unsigned long parent_rate,
 static void wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate,
u32 *multiplier, u32 *divisor1, u32 *divisor2)
 {
-   u32 mul, div1, div2;
+   u32 mul;
+   int div1, div2;
u32 best_mul, best_div1, best_div2;
unsigned long tclk, rate_err, best_err;
 
-- 
1.9.1

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


Re: [RFC PATCH 15/20] coresight: etm-perf: implementing 'setup_aux()' API

2015-10-01 Thread Alexander Shishkin
Mathieu Poirier  writes:

> On 30 September 2015 at 05:50, Alexander Shishkin
>  wrote:
>> Mathieu Poirier  writes:
>>
>>> +static void *etm_setup_aux(int cpu, void **pages,
>>> +   int nr_pages, bool overwrite)
>>> +{
>>> + struct coresight_device *csdev;
>>> +
>>> + if (cpu == -1)
>>> + cpu = smp_processor_id();
>>> +
>>> + csdev = per_cpu(csdev_sink, cpu);
>>> + if (!csdev)
>>> + return NULL;
>>> +
>>> + return sink_ops(csdev)->setup_aux(csdev, cpu, pages,
>>> +   nr_pages, overwrite);
>>
>> Is it guaranteed that this sink would always have .setup_aux()?
>
> A setup_aux() is vital to the design, both on Intel and ARM.  I really
> don't see how one could go without it.  I can return NULL if it hasn't
> been provided - that way the setup will fail without triggering a core
> dump.

It wasn't clear to me that the sink that ends up in csdev_sink will
always be the one that does have .setup_aux(). And if it indeed doesn't,
it's better to refuse to setup a buffer than crash.

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


Re: [RFC PATCH 06/20] coresight: etm3x: unlocking tracer in default arch init

2015-10-01 Thread Alexander Shishkin
Mathieu Poirier  writes:

> On 30 September 2015 at 05:33, Alexander Shishkin
>  wrote:
>> Mathieu Poirier  writes:
>>
>>> Calling function 'smp_call_function_single()' to unlock the
>>> tracer and calling it right after to perform the default
>>> initialisation doesn't make sense.
>>>
>>> Moving 'etm_os_unlock()' just before making the default
>>> initialisation results in the same outcome while saving
>>> one call to 'smp_call_function_single()'.
>>>
>>> Signed-off-by: Mathieu Poirier 
>>> ---
>>>  drivers/hwtracing/coresight/coresight-etm3x.c | 8 +---
>>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c 
>>> b/drivers/hwtracing/coresight/coresight-etm3x.c
>>> index c6880c1ade55..a4c158df0fef 100644
>>> --- a/drivers/hwtracing/coresight/coresight-etm3x.c
>>> +++ b/drivers/hwtracing/coresight/coresight-etm3x.c
>>> @@ -1867,6 +1867,11 @@ static void etm_init_arch_data(void *info)
>>>* certain registers might be ignored.
>>>*/
>>>   etm_clr_pwrdwn(drvdata);
>>> +
>>> + /* Make sure all registers are accessible */
>>> + etm_os_unlock(drvdata);
>>
>> In case of co-processor register access, this will end up unlocking the
>> local ETM instead of the one on target cpu, by the looks of it.
>
> "etm_init_arch_data()" is also called from "smp_function_calls()" and
> as such, will end up executing the correct CPU.

Yes, but it doesn't unlock the OSLAR register, which also needs to be
done on target cpu.

Regards,
--
Alex
--
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 v5 1/3] ARM: uniphier: add outer cache support

2015-10-01 Thread Masahiro Yamada
This commit adds support for UniPhier outer cache controller.
All the UniPhier SoCs are equipped with the L2 cache, while the L3
cache is currently only integrated on PH1-Pro5 SoC.

Signed-off-by: Masahiro Yamada 
Acked-by: Rob Herring 
---

 .../bindings/arm/uniphier/cache-uniphier.txt   |  60 +++
 MAINTAINERS|   2 +
 arch/arm/include/asm/hardware/cache-uniphier.h |  46 ++
 arch/arm/kernel/irq.c  |   3 +
 arch/arm/mm/Kconfig|  10 +
 arch/arm/mm/Makefile   |   1 +
 arch/arm/mm/cache-uniphier.c   | 555 +
 7 files changed, 677 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/uniphier/cache-uniphier.txt
 create mode 100644 arch/arm/include/asm/hardware/cache-uniphier.h
 create mode 100644 arch/arm/mm/cache-uniphier.c

diff --git a/Documentation/devicetree/bindings/arm/uniphier/cache-uniphier.txt 
b/Documentation/devicetree/bindings/arm/uniphier/cache-uniphier.txt
new file mode 100644
index 000..d27a646
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/uniphier/cache-uniphier.txt
@@ -0,0 +1,60 @@
+UniPhier outer cache controller
+
+UniPhier SoCs are integrated with a full-custom outer cache controller system.
+All of them have a level 2 cache controller, and some have a level 3 cache
+controller as well.
+
+Required properties:
+- compatible: should be "socionext,uniphier-system-cache"
+- reg: offsets and lengths of the register sets for the device.  It should
+  contain 3 regions: control register, revision register, operation register,
+  in this order.
+- cache-unified: specifies the cache is a unified cache.
+- cache-size: specifies the size in bytes of the cache
+- cache-sets: specifies the number of associativity sets of the cache
+- cache-line-size: specifies the line size in bytes
+- cache-level: specifies the level in the cache hierarchy.  The value should
+  be 2 for L2 cache, 3 for L3 cache, etc.
+
+Optional properties:
+- next-level-cache: phandle to the next level cache if present.  The next level
+  cache should be also compatible with "socionext,uniphier-system-cache".
+
+The L2 cache must exist to use the L3 cache; the cache hierarchy must be
+indicated correctly with "next-level-cache" properties.
+
+Example 1 (system with L2):
+   l2: l2-cache@500c {
+   compatible = "socionext,uniphier-system-cache";
+   reg = <0x500c 0x2000>, <0x503c0100 0x4>,
+ <0x506c 0x400>;
+   cache-unified;
+   cache-size = <0x8>;
+   cache-sets = <256>;
+   cache-line-size = <128>;
+   cache-level = <2>;
+   };
+
+Example 2 (system with L2 and L3):
+   l2: l2-cache@500c {
+   compatible = "socionext,uniphier-system-cache";
+   reg = <0x500c 0x2000>, <0x503c0100 0x8>,
+ <0x506c 0x400>;
+   cache-unified;
+   cache-size = <0x20>;
+   cache-sets = <512>;
+   cache-line-size = <128>;
+   cache-level = <2>;
+   next-level-cache = <>;
+   };
+
+   l3: l3-cache@500c8000 {
+   compatible = "socionext,uniphier-system-cache";
+   reg = <0x500c8000 0x2000>, <0x503c8100 0x8>,
+ <0x506c8000 0x400>;
+   cache-unified;
+   cache-size = <0x40>;
+   cache-sets = <512>;
+   cache-line-size = <256>;
+   cache-level = <3>;
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index 9f6685f..bced05f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1606,7 +1606,9 @@ M:Masahiro Yamada 
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
 S: Maintained
 F: arch/arm/boot/dts/uniphier*
+F: arch/arm/include/asm/hardware/cache-uniphier.h
 F: arch/arm/mach-uniphier/
+F: arch/arm/mm/cache-uniphier.c
 F: drivers/pinctrl/uniphier/
 F: drivers/tty/serial/8250/8250_uniphier.c
 N: uniphier
diff --git a/arch/arm/include/asm/hardware/cache-uniphier.h 
b/arch/arm/include/asm/hardware/cache-uniphier.h
new file mode 100644
index 000..102e3fb
--- /dev/null
+++ b/arch/arm/include/asm/hardware/cache-uniphier.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2015 Masahiro Yamada 
+ *
+ * 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 of the License, 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.
+ */
+
+#ifndef __CACHE_UNIPHIER_H

[PATCH v5 0/3] ARM: uniphier: add outer cache support and rework SMP operations

2015-10-01 Thread Masahiro Yamada
Hi Olof,

Now Linux 4.3-rc1 is out, so I am back to this.

1/3: add outer cache support
2/3: rework SMP operations
3/3: add device tree nodes

Because 2/3 highly depends on 1/3, I hope whole of this series
is applied through ARM-SOC tree.


Changes in v5:
  - Add __init to __uniphier_cache_set_locked_ways() function

Changes in v4:
  - Add more detailed comments to explain why no spin lock is needed
  - Add two examples to the binding document

Changes in v3:
  - Drop bogus includes

Changes in v2:
  - Use pr_fmt() to have pr_ are automatically prefixed
  - Re-design to initialize the outer cache earlier in init_IRQ()
  - Require DT properties such as "cacne-unified", "cache-size",
"cache-sets", "cache-size", "cache-line-size".
  - Follow "next-level-cache" property to search further outer caches

Masahiro Yamada (3):
  ARM: uniphier: add outer cache support
  ARM: uniphier: rework SMP operations to use trampoline code
  ARM: dts: uniphier: add outer cache controller nodes

 .../bindings/arm/uniphier/cache-uniphier.txt   |  60 +++
 MAINTAINERS|   2 +
 arch/arm/boot/dts/uniphier-ph1-ld4.dtsi|  13 +
 arch/arm/boot/dts/uniphier-ph1-pro4.dtsi   |  14 +
 arch/arm/boot/dts/uniphier-ph1-pro5.dtsi   |  27 +
 arch/arm/boot/dts/uniphier-ph1-sld3.dtsi   |  14 +
 arch/arm/boot/dts/uniphier-ph1-sld8.dtsi   |  13 +
 arch/arm/boot/dts/uniphier-proxstream2.dtsi|  16 +
 arch/arm/include/asm/hardware/cache-uniphier.h |  46 ++
 arch/arm/kernel/irq.c  |   3 +
 arch/arm/mach-uniphier/Makefile|   2 +-
 arch/arm/mach-uniphier/headsmp.S   |  43 ++
 arch/arm/mach-uniphier/platsmp.c   | 185 +--
 arch/arm/mm/Kconfig|  10 +
 arch/arm/mm/Makefile   |   1 +
 arch/arm/mm/cache-uniphier.c   | 555 +
 16 files changed, 973 insertions(+), 31 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/arm/uniphier/cache-uniphier.txt
 create mode 100644 arch/arm/include/asm/hardware/cache-uniphier.h
 create mode 100644 arch/arm/mach-uniphier/headsmp.S
 create mode 100644 arch/arm/mm/cache-uniphier.c

-- 
1.9.1

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


[PATCH v5 3/3] ARM: dts: uniphier: add outer cache controller nodes

2015-10-01 Thread Masahiro Yamada
Add L2 cache controller nodes for all the UniPhier SoC DTSI.
Also, add an L3 cache controller node for PH1-Pro5 DTSI.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/dts/uniphier-ph1-ld4.dtsi | 13 +
 arch/arm/boot/dts/uniphier-ph1-pro4.dtsi| 14 ++
 arch/arm/boot/dts/uniphier-ph1-pro5.dtsi| 27 +++
 arch/arm/boot/dts/uniphier-ph1-sld3.dtsi| 14 ++
 arch/arm/boot/dts/uniphier-ph1-sld8.dtsi| 13 +
 arch/arm/boot/dts/uniphier-proxstream2.dtsi | 16 
 6 files changed, 97 insertions(+)

diff --git a/arch/arm/boot/dts/uniphier-ph1-ld4.dtsi 
b/arch/arm/boot/dts/uniphier-ph1-ld4.dtsi
index a6a185f..ae13469 100644
--- a/arch/arm/boot/dts/uniphier-ph1-ld4.dtsi
+++ b/arch/arm/boot/dts/uniphier-ph1-ld4.dtsi
@@ -55,6 +55,7 @@
device_type = "cpu";
compatible = "arm,cortex-a9";
reg = <0>;
+   next-level-cache = <>;
};
};
 
@@ -91,6 +92,18 @@
#size-cells = <1>;
};
 
+   l2: l2-cache@500c {
+   compatible = "socionext,uniphier-system-cache";
+   reg = <0x500c 0x2000>, <0x503c0100 0x4>,
+ <0x506c 0x400>;
+   interrupts = <0 174 4>, <0 175 4>;
+   cache-unified;
+   cache-size = <(512 * 1024)>;
+   cache-sets = <256>;
+   cache-line-size = <128>;
+   cache-level = <2>;
+   };
+
serial0: serial@54006800 {
compatible = "socionext,uniphier-uart";
status = "disabled";
diff --git a/arch/arm/boot/dts/uniphier-ph1-pro4.dtsi 
b/arch/arm/boot/dts/uniphier-ph1-pro4.dtsi
index e8bbc45..85377b2 100644
--- a/arch/arm/boot/dts/uniphier-ph1-pro4.dtsi
+++ b/arch/arm/boot/dts/uniphier-ph1-pro4.dtsi
@@ -56,12 +56,14 @@
device_type = "cpu";
compatible = "arm,cortex-a9";
reg = <0>;
+   next-level-cache = <>;
};
 
cpu@1 {
device_type = "cpu";
compatible = "arm,cortex-a9";
reg = <1>;
+   next-level-cache = <>;
};
};
 
@@ -98,6 +100,18 @@
#size-cells = <1>;
};
 
+   l2: l2-cache@500c {
+   compatible = "socionext,uniphier-system-cache";
+   reg = <0x500c 0x2000>, <0x503c0100 0x4>,
+ <0x506c 0x400>;
+   interrupts = <0 174 4>, <0 175 4>;
+   cache-unified;
+   cache-size = <(768 * 1024)>;
+   cache-sets = <256>;
+   cache-line-size = <128>;
+   cache-level = <2>;
+   };
+
serial0: serial@54006800 {
compatible = "socionext,uniphier-uart";
status = "disabled";
diff --git a/arch/arm/boot/dts/uniphier-ph1-pro5.dtsi 
b/arch/arm/boot/dts/uniphier-ph1-pro5.dtsi
index 59c2b12..96da01e 100644
--- a/arch/arm/boot/dts/uniphier-ph1-pro5.dtsi
+++ b/arch/arm/boot/dts/uniphier-ph1-pro5.dtsi
@@ -56,12 +56,14 @@
device_type = "cpu";
compatible = "arm,cortex-a9";
reg = <0>;
+   next-level-cache = <>;
};
 
cpu@1 {
device_type = "cpu";
compatible = "arm,cortex-a9";
reg = <1>;
+   next-level-cache = <>;
};
};
 
@@ -98,6 +100,31 @@
#size-cells = <1>;
};
 
+   l2: l2-cache@500c {
+   compatible = "socionext,uniphier-system-cache";
+   reg = <0x500c 0x2000>, <0x503c0100 0x8>,
+ <0x506c 0x400>;
+   interrupts = <0 190 4>, <0 191 4>;
+   cache-unified;
+   cache-size = <(2 * 1024 * 1024)>;
+   cache-sets = <512>;
+   cache-line-size = <128>;
+   cache-level = <2>;
+   next-level-cache = <>;
+   };
+
+   l3: l3-cache@500c8000 {
+   compatible = "socionext,uniphier-system-cache";
+   reg = <0x500c8000 0x2000>, <0x503c8100 0x8>,
+ <0x506c8000 0x400>;
+   interrupts = <0 174 4>, <0 175 4>;
+   cache-unified;
+   cache-size = 

[PATCH v5 2/3] ARM: uniphier: rework SMP operations to use trampoline code

2015-10-01 Thread Masahiro Yamada
The complexity of the boot sequence of UniPhier SoC family is
a PITA due to the following hardware limitations:

[1] No dedicated on-chip SRAM
SoCs in general have small SRAM, on which a tiny firmware or a boot
loader can run before SDRAM is initialized.  As UniPhier SoCs do not
have any dedicated SRAM accessible from CPUs, the locked outer cache
is used instead.  Due to the ARM specification, to have access to
the outer cache, the MMU must be enabled.  This is done for all CPU
cores by the program hard-wired in the boot ROM.  The boot ROM code
loads a small amount of program (this is usually SPL of U-Boot) from
a non-volatile device onto the locked outer cache, and the primary
CPU jumps to it.  The secondary CPUs stay in the boot ROM until they
are kicked by the primary CPU.

[2] CPUs can not directly jump to SDRAM address space
As mentioned above, the MMU is enable for all the CPUs with the page
table hard-wired in the boot ROM.  Unfortunately, the page table only
has minimal sets of valid sections; all the sections of SDRAM address
space are zero-filled.  That means all the CPUs, including secondary
ones, can not jump directly to SDRAM address space.  So, the primary
CPU must bring up secondary CPUs to accessible address mapped onto
the outer cache, then again kick them to SDRAM address space.

Before this commit, this complex task was done with help of a boot
loader (U-Boot); U-Boot SPL brings up the secondary CPUs to the entry
of U-Boot SPL and they stay there until they are kicked by Linux.
This is not nice because a boot loader must put the secondary CPUs
into a certain state expected by the kernel.  It makes difficult to
port another boot loader because the boot loader and the kernel must
work in sync to wake up the secondary CPUs.

This commit reworks the SMP operations so that they do not rely on
particular boot loader implementation; the SMP operations (platsmp.c)
put trampoline code (headsmp.S) on a locked way of the outer cache.
The secondary CPUs jump from the boot ROM to secondary_entry via the
trampoline code.  The boot loader no longer needs to take care of SMP.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/Makefile  |   2 +-
 arch/arm/mach-uniphier/headsmp.S |  43 +
 arch/arm/mach-uniphier/platsmp.c | 185 ---
 3 files changed, 199 insertions(+), 31 deletions(-)
 create mode 100644 arch/arm/mach-uniphier/headsmp.S

diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile
index 60bd226..1233f9b 100644
--- a/arch/arm/mach-uniphier/Makefile
+++ b/arch/arm/mach-uniphier/Makefile
@@ -1,2 +1,2 @@
 obj-y  := uniphier.o
-obj-$(CONFIG_SMP)  += platsmp.o
+obj-$(CONFIG_SMP)  += platsmp.o headsmp.o
diff --git a/arch/arm/mach-uniphier/headsmp.S b/arch/arm/mach-uniphier/headsmp.S
new file mode 100644
index 000..c819dff
--- /dev/null
+++ b/arch/arm/mach-uniphier/headsmp.S
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2015 Masahiro Yamada 
+ *
+ * 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 of the License, 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.
+ */
+
+#include 
+#include 
+#include 
+
+ENTRY(uniphier_smp_trampoline)
+ARM_BE8(setend be) @ ensure we are in BE8 mode
+   mrc p15, 0, r0, c0, c0, 5   @ MPIDR (Multiprocessor Affinity Reg)
+   and r2, r0, #0x3@ CPU ID
+   ldr r1, uniphier_smp_trampoline_jump
+   ldr r3, uniphier_smp_trampoline_poll_addr
+   mrc p15, 0, r0, c1, c0, 0   @ SCTLR (System Control Register)
+   orr r0, r0, #CR_I   @ Enable ICache
+   bic r0, r0, #(CR_C | CR_M)  @ Disable MMU and Dcache
+   mcr p15, 0, r0, c1, c0, 0
+   b   1f  @ cache the following 5 instructions
+0: wfe
+1: ldr r0, [r3]
+   cmp r0, r2
+   bxeqr1  @ branch to secondary_startup
+   b   0b
+   .globl  uniphier_smp_trampoline_jump
+uniphier_smp_trampoline_jump:
+   .word   0   @ set virt_to_phys(secondary_startup)
+   .globl  uniphier_smp_trampoline_poll_addr
+uniphier_smp_trampoline_poll_addr:
+   .word   0   @ set CPU ID to be kicked to this reg
+   .globl  uniphier_smp_trampoline_end
+uniphier_smp_trampoline_end:
+ENDPROC(uniphier_smp_trampoline)
diff --git a/arch/arm/mach-uniphier/platsmp.c b/arch/arm/mach-uniphier/platsmp.c
index 4b784f7..f057766 100644
--- a/arch/arm/mach-uniphier/platsmp.c
+++ b/arch/arm/mach-uniphier/platsmp.c
@@ -12,73 +12,198 @@
  * GNU General 

Re: [RFC PATCH 01/20] coresight: etm3x: splitting 'etm_enable_hw()' operations

2015-10-01 Thread Alexander Shishkin
Mathieu Poirier  writes:

> On 30 September 2015 at 03:58, Alexander Shishkin
>  wrote:
>> Most of these things can also be bypassed, as at least initially perf
>> events won't be using trigger/sequencer configurations, so we could
>> simply clear all these things out when a first perf event is created
>> (which would also disallow any sysfs poking around the etm/etb) and not
>> worry about them in the pmu callbacks.
>
> I don't want to restrain configuration options to what is available
> through Perf's cmd line.  The sysFS interface is there to complement
> what is currently not available.

In practice this means that part of your trace configuration will be
global and part -- per event, which can indeed work if you only have one
event at a time, but again, makes using perf infrastructure redundant
for this driver. For multiple events this doesn't make much sense.

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


Re: [PATCH v4 0/3] ARM: uniphier: add outer cache support and rework SMP operations

2015-10-01 Thread Masahiro Yamada
2015-09-30 20:01 GMT+09:00 Masahiro Yamada :
> Hi Olof,
>
> Now Linux 4.3-rc1 is out, so I am back to this.
>
> 1/3: add outer cache support
> 2/3: rework SMP operations
> 3/3: add device tree nodes
>
> Because 2/3 highly depends on 1/3, I hope whole of this series
> is applied through ARM-SOC tree.
>
>
> Changes in v4:
>   - Add more detailed comments to explain why no spin lock is needed
>   - Add two examples to the binding document
>
> Changes in v3:
>   - Drop bogus includes
>
> Changes in v2:
>   - Use pr_fmt() to have pr_ are automatically prefixed
>   - Re-design to initialize the outer cache earlier in init_IRQ()
>   - Require DT properties such as "cacne-unified", "cache-size",
> "cache-sets", "cache-size", "cache-line-size".
>   - Follow "next-level-cache" property to search further outer caches
>


I found something to be fixed.

I will send v5.



-- 
Best Regards
Masahiro Yamada
--
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

2015-10-01 Thread Stephen Rothwell
Hi Andrew,

Today's linux-next merge of the akpm-current tree got conflicts in:

  Documentation/filesystems/proc.txt
  fs/proc/array.c
  fs/proc/base.c

between commit:

  b2f73922d119 ("fs/proc, core/debug: Don't expose absolute kernel addresses 
via wchan")

from the tip tree and commit:

  f01df89b6372 ("fs/proc: don't expose absolute kernel addresses via wchan")
  7adc347341f1 ("fs-proc-dont-expose-absolute-kernel-addresses-via-wchan-fix")

from the akpm-current tree.

I fixed it up (the tip tree version seemed newer, so I used that) and
can carry the fix as necessary (no action is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au
--
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: build failure after merge of the pinctrl tree

2015-10-01 Thread Stephen Rothwell
Hi Linus,

On Fri, 25 Sep 2015 13:34:10 +1000 Stephen Rothwell  
wrote:
>
> After merging the pinctrl tree, today's linux-next build (arm
> multi_v7_defconfig) failed like this:
> 
> drivers/pinctrl/pinctrl-at91-pio4.c: In function 'atmel_gpio_irq_set_type':
> drivers/pinctrl/pinctrl-at91-pio4.c:170:3: error: implicit declaration of 
> function '__irq_set_handler_locked' [-Werror=implicit-function-declaration]
>__irq_set_handler_locked(d->irq, handle_edge_irq);
>^
> drivers/pinctrl/pinctrl-at91-pio4.c: In function 'atmel_pinctrl_probe':
> drivers/pinctrl/pinctrl-at91-pio4.c:925:3: warning: passing argument 2 of 
> 'irq_set_chained_handler' from incompatible pointer type
>irq_set_chained_handler(res->start, atmel_gpio_irq_handler);
>^
> In file included from include/linux/gpio/driver.h:6:0,
>  from include/asm-generic/gpio.h:12,
>  from arch/arm/include/asm/gpio.h:9,
>  from include/linux/gpio.h:48,
>  from drivers/pinctrl/pinctrl-at91-pio4.c:18:
> include/linux/irq.h:548:1: note: expected 'irq_flow_handler_t' but argument 
> is of type 'void (*)(unsigned int,  struct irq_desc *)'
>  irq_set_chained_handler(unsigned int irq, irq_flow_handler_t handle)
>  ^
> 
> Caused by commit
> 
>   776180848b57 ("pinctrl: introduce driver for Atmel PIO4 controller")
> 
> I have used the pinctrl tree from next-20150924 for today.

I am still getting this error.

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au
--
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 target-updates tree with the kdbus tree

2015-10-01 Thread Stephen Rothwell
Hi Nicholas,

Today's linux-next merge of the target-updates tree got a conflict in:

  samples/Makefile

between commit:

  2d41f8138508 ("kdbus: add walk-through user space example")

from the kdbus tree and commit:

  f71933438300 ("configfs: remove old API")

from the target-updates 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 samples/Makefile
index f0ad51e5b342,48001d7e23f0..
--- a/samples/Makefile
+++ b/samples/Makefile
@@@ -1,5 -1,5 +1,5 @@@
  # Makefile for Linux samples code
  
  obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ trace_events/ livepatch/ \
 - hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
 - configfs/
 + hw_breakpoint/ kfifo/ kdb/ kdbus/ hidraw/ rpmsg/ \
-  seccomp/
++ seccomp/ configfs/
--
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: [v5, 2/6] fsl/fman: Add FMan support

2015-10-01 Thread Scott Wood
On Thu, Sep 24, 2015 at 12:10:34PM +0300, igal.liber...@freescale.com wrote:
> +int fman_get_rx_extra_headroom(void)
> +{
> + static bool fm_check_rx_extra_headroom;
> +
> + if (!fm_check_rx_extra_headroom) {
> + if (fsl_fm_rx_extra_headroom > FSL_FM_RX_EXTRA_HEADROOM_MAX ||
> + fsl_fm_rx_extra_headroom < FSL_FM_RX_EXTRA_HEADROOM_MIN) {
> + pr_warn("Invalid fsl_fm_rx_extra_headroom value (%d) in 
> bootargs, valid range is %d-%d. Falling back to the default (%d)\n",
> + fsl_fm_rx_extra_headroom,
> + FSL_FM_RX_EXTRA_HEADROOM_MIN,
> + FSL_FM_RX_EXTRA_HEADROOM_MAX,
> + FSL_FM_RX_EXTRA_HEADROOM);
> + fsl_fm_rx_extra_headroom = FSL_FM_RX_EXTRA_HEADROOM;
> + }
> +
> + fsl_fm_rx_extra_headroom = true;

I think you mean "fm_check_rx_extra_headroom = true".

> + fsl_fm_rx_extra_headroom = ALIGN(fsl_fm_rx_extra_headroom, 16);
> + }
> +
> + return fsl_fm_rx_extra_headroom;
> +}
> +EXPORT_SYMBOL(fman_get_rx_extra_headroom);

Please just check things like this once during module init. 
Init-on-first-use is unnecessarily complicated, and race-prone.

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


netpoll_send_skb_on_dev warning with bnx2

2015-10-01 Thread Vinson Lee
Hi.

I am seeing a netpoll_send_skb_on_dev warning with bnx2. It happens on
Linux 4.1 and I am able to reproduce the warning with Linux 4.3-rc3.

[ cut here ]
WARNING: CPU: 11 PID: 3110 at net/core/netpoll.c:368
netpoll_send_skb_on_dev+0x183/0x201()
netpoll_send_skb_on_dev(): eth0 enabled interrupts in poll
(bnx2_start_xmit+0x0/0x5d4 [bnx2])
Modules linked in: netconsole(+) configfs ipv6 ppdev parport_pc lp
parport tcp_diag inet_diag ipmi_devintf serio_raw iTCO_wdt
iTCO_vendor_support ipmi_si ipmi_msghandler hpilo hpwdt bnx2 coretemp
kvm_intel kvm crc32c_intel ghash_clmulni_intel microcode lpc_ich
mfd_core i7core_edac edac_core pcc_cpufreq acpi_cpufreq shpchp
sch_fq_codel hpsa radeon ttm drm_kms_helper drm fb_sys_fops sysimgblt
sysfillrect syscopyarea i2c_algo_bit i2c_core
CPU: 11 PID: 3110 Comm: modprobe Not tainted 4.3.0-rc3 #1
 0170 88060be17a18 812bc84c 818b1a78
 88060be17a68 88060be17a58 81064712 0be17a68
 814ec12e 88060bc10900  8800d941c000
Call Trace:
 [] dump_stack+0x48/0x5c
 [] warn_slowpath_common+0xa1/0xbb
 [] ? netpoll_send_skb_on_dev+0x183/0x201
 [] warn_slowpath_fmt+0x46/0x48
 [] ? bnx2_run_loopback+0x391/0x391 [bnx2]
 [] netpoll_send_skb_on_dev+0x183/0x201
 [] netpoll_send_udp+0x3df/0x3f1
 [] write_msg+0xaf/0xe9 [netconsole]
 [] call_console_drivers.clone.2+0xd1/0xe9
 [] console_unlock+0x30e/0x3a5
 [] register_console+0x2af/0x322
 [] init_netconsole+0x1b4/0x224 [netconsole]
 [] ? 0xa0497000
 [] do_one_initcall+0xf7/0x182
 [] ? kmem_cache_alloc_trace+0xb6/0xf0
 [] ? do_init_module+0x31/0x1e4
 [] do_init_module+0x69/0x1e4
 [] load_module+0x1451/0x160b
 [] ? mod_kobject_put+0x4d/0x4d
 [] ? __vmalloc_node+0x3e/0x40
 [] SyS_init_module+0x14f/0x155
 [] entry_SYSCALL_64_fastpath+0x12/0x6a
---[ end trace 878215466e581776 ]---

Cheers,
Vinson
--
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: [RESEND PATCH v2] mtd: nand: pass page number to ecc->write_xxx() methods

2015-10-01 Thread Brian Norris
On Thu, Oct 01, 2015 at 09:34:51PM +0200, Boris Brezillon wrote:
> The ->read_xxx() methods are all passed the page number the NAND controller
> is supposed to read, but ->write_xxx() do not have such a parameter.
> 
> This is a problem if we want to properly implement data
> scrambling/randomization in order to mitigate MLC sensibility to repeated
> pattern: to prevent bitflips in adjacent pages in the same block we need
> to avoid repeating the same pattern at the same offset in those pages,
> hence the randomizer/scrambler engine need to be passed the page value
> in order to adapt its seed accordingly.
> 
> Moreover, adding the page parameter to the ->write_xxx() methods add some
> consistency to the current API.
> 
> Signed-off-by: Boris Brezillon 
> CC: Josh Wu 
> CC: Ezequiel Garcia 
> CC: Maxime Ripard 
> CC: Greg Kroah-Hartman 
> CC: Huang Shijie 
> CC: Bryan Wu 
> CC: Stefan Agner 
> CC: de...@driverdev.osuosl.org
> CC: linux-arm-ker...@lists.infradead.org
> CC: linux-kernel@vger.kernel.org
> ---
> Sorry for the noise, I didn't send the correct patch version (the one
> fixing the compilation error in the doc4g driver).
> 
> Changes since v1:
> - rebased on l2-mtd/master
> - fixed compilation error in the doc4g driver

Didn't really look at the patch yet, but my build tests say:

drivers/mtd/nand/gpmi-nand/gpmi-nand.c: In function ‘gpmi_ecc_write_oob_raw’:
drivers/mtd/nand/gpmi-nand/gpmi-nand.c:1536:2: error: too few arguments to 
function ‘gpmi_ecc_write_page_raw’
drivers/mtd/nand/gpmi-nand/gpmi-nand.c:1446:12: note: declared here

Brian
--
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 2/5] mtd: nand: Qualcomm NAND controller driver

2015-10-01 Thread Brian Norris
Hi Archit,

On Wed, Aug 19, 2015 at 10:19:03AM +0530, Archit Taneja wrote:
> The Qualcomm NAND controller is found in SoCs like IPQ806x, MSM7xx,
> MDM9x15 series.
> 
> It exists as a sub block inside the IPs EBI2 (External Bus Interface 2)
> and QPIC (Qualcomm Parallel Interface Controller). These IPs provide a
> broader interface for external slow peripheral devices such as LCD and
> NAND/NOR flash memory or SRAM like interfaces.
> 
> We add support for the NAND controller found within EBI2. For the SoCs
> of our interest, we only use the NAND controller within EBI2. Therefore,
> it's safe for us to assume that the NAND controller is a standalone block
> within the SoC.
> 
> The controller supports 512B, 2kB, 4kB and 8kB page 8-bit and 16-bit NAND
> flash devices. It contains a HW ECC block that supports BCH ECC (4, 8 and
> 16 bit correction/step) and RS ECC(4 bit correction/step) that covers main
> and spare data. The controller contains an internal 512 byte page buffer
> to which we read/write via DMA. The EBI2 type NAND controller uses ADM DMA
> for register read/write and data transfers. The controller performs page
> reads and writes at a codeword/step level of 512 bytes. It can support up
> to 2 external chips of different configurations.
> 
> The driver prepares register read and write configuration descriptors for
> each codeword, followed by data descriptors to read or write data from the
> controller's internal buffer. It uses a single ADM DMA channel that we get
> via dmaengine API. The controller requires 2 ADM CRCIs for command and
> data flow control. These are passed via DT.
> 
> The ecc layout used by the controller is syndrome like, but we can't use
> the standard syndrome ecc ops because of several reasons. First, the amount
> of data bytes covered by ecc isn't same in each step. Second, writing to
> free oob space requires us writing to the entire step in which the oob
> lies. This forces us to create our own ecc ops.
> 
> One more difference is how the controller accesses the bad block marker.
> The controller ignores reading the marker when ECC is enabled. ECC needs
> to be explicity disabled to read or write to the bad block marker. For
> this reason, we use the newly created flag NAND_BBT_ACCESS_BBM_RAW to
> read the factory provided bad block markers.
> 
> v4:
> - Shrink submit_descs
> - add desc list node at the end of dma_prep_desc
> - Endianness and warning fixes
> 
> Signed-off-by: Stephen Boyd 

Where does this sign-off come into play? It's not grouped with yours.
Did Stephen have something to do with v4 only? Also, we typically trim
the change log from the commit message (and place it below the '---' to
do this automatically). Or did you intend for these changelogs to stay
in the git history? I suppose it's not really harmful to keep it in if
you'd like...

> 
> v3:
> - Refactor dma functions for maximum reuse
> - Use dma_slave_confing on stack
> - optimize and clean upempty_page_fixup using memchr_inv
> - ensure portability with dma register reads using le32_* funcs
> - use NAND_USE_BOUNCE_BUFFER instead of doing it ourselves
> - fix handling of return values of dmaengine funcs
> - constify wherever possible
> - Remove dependency on ADM DMA in Kconfig
> - Misc fixes and clean ups
> 
> v2:
> - Use new BBT flag that allows us to read BBM in raw mode
> - reduce memcpy-s in the driver
> - some refactor and clean ups because of above changes
> 
> Reviewed-by: Andy Gross 
> Signed-off-by: Archit Taneja 

Has this driver been tested with drivers/mtd/tests/? Which ones? I'm
particularly interested in oobtest, since you attempted to handle both
ECC and raw OOB.

> ---
>  drivers/mtd/nand/Kconfig  |7 +
>  drivers/mtd/nand/Makefile |1 +
>  drivers/mtd/nand/qcom_nandc.c | 1910 
> +
>  3 files changed, 1918 insertions(+)
>  create mode 100644 drivers/mtd/nand/qcom_nandc.c
> 
> diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
> index 5b2806a..6085b8a 100644
> --- a/drivers/mtd/nand/Kconfig
> +++ b/drivers/mtd/nand/Kconfig
> @@ -538,4 +538,11 @@ config MTD_NAND_HISI504
>   help
> Enables support for NAND controller on Hisilicon SoC Hip04.
>  
> +config MTD_NAND_QCOM
> + tristate "Support for NAND on QCOM SoCs"
> + depends on ARCH_QCOM
> + help
> +   Enables support for NAND flash chips on SoCs containing the EBI2 NAND
> +   controller. This controller is found on IPQ806x SoC.
> +
>  endif # MTD_NAND
> diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
> index 1f897ec..87b6a1d 100644
> --- a/drivers/mtd/nand/Makefile
> +++ b/drivers/mtd/nand/Makefile
> @@ -53,5 +53,6 @@ obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)+= 
> bcm47xxnflash/
>  obj-$(CONFIG_MTD_NAND_SUNXI) += sunxi_nand.o
>  obj-$(CONFIG_MTD_NAND_HISI504)   += hisi504_nand.o
>  obj-$(CONFIG_MTD_NAND_BRCMNAND)  += brcmnand/
> +obj-$(CONFIG_MTD_NAND_QCOM)  += qcom_nandc.o
>  

Re: [PATCH] soc: mediatek: Fix random hang up issue while kernel init

2015-10-01 Thread James Liao
Hi Daniel,

On Thu, 2015-10-01 at 18:08 +0800, Daniel Kurtz wrote:
> I see two cases where "a power domain is a consumer of a clock":
>   (a) the clock is needed to access the power domain control
> registers.  The clock must actually be in another power domain, since
> otherwise you could never turn *on* the power domain in question.
>   (b) the clock is needed to talk to the power domain that is about to
> turn off, or that was just turned on - these clocks are usually used
> to control some kind of bus arbitration, etc.  In this case, the
> clocks are only accessed when the power domain is on.
> 
> I would argue that in both cases, the clock should in theory should
> only be enabled/disabled by the power on/off routine for the duration
> of time that is needed, and that it should not be "left enabled" by
> the power domain on/off function...  I can see how this might be a
> useful optimization - but it also seems like a way to burn extra power
> by leaving on a clock that is not necessarily being used.
> 
> But - perhaps I am over thinking this, and it is standard practice to
> bundle power domains with the clocks that service components in the
> power domain.

Yes, you are right. Power domain on/off operations need clocks to get
status of the subsystem. Keeping clocks on during power domain on is an
optimization.

But to model a clock controller as a power domain consumer, or say we
need to control power domain before clock on/off, is not a good practice
because we always consider clock operations should be light weight.
Power domains should be controlled explicitly by subsystem drivers,
instead of hiding behind clock controls.

> Or, alternatively, just prepare venc_sel once during init, for each
> clock controller that needs it, when configuring the clock controller
> node (for example, in mtk_vencsys_init()). This is similar to how we
> set up 'critical clocks'.
> By just preparing the clock, you tell the common clock core:
>  "my clock controller will need this clock later; please make sure
> that it can be enabled/disabled later during atomic context."

In current implementation, PLLs will be turned on in clk_prepare(). So
if a clock is always prepared, its parent PLL will be kept on even if
the clock is not enabled. It consumes extra power, so we don't prefer
this kind of solution.


Best regards,

James


--
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] misc: mic: use kstrdup() in mic_sysfs

2015-10-01 Thread Geliang Tang
Use kstrdup instead of kmalloc and strncpy.

Signed-off-by: Geliang Tang 
---
 drivers/misc/mic/host/mic_sysfs.c | 23 ---
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/misc/mic/host/mic_sysfs.c 
b/drivers/misc/mic/host/mic_sysfs.c
index 6dd864e..7b67aea 100644
--- a/drivers/misc/mic/host/mic_sysfs.c
+++ b/drivers/misc/mic/host/mic_sysfs.c
@@ -210,18 +210,14 @@ cmdline_store(struct device *dev, struct device_attribute 
*attr,
mutex_lock(>mic_mutex);
kfree(mdev->cmdline);
 
-   mdev->cmdline = kmalloc(count + 1, GFP_KERNEL);
+   mdev->cmdline = kstrdup(buf, GFP_KERNEL);
if (!mdev->cmdline) {
count = -ENOMEM;
goto unlock;
}
 
-   strncpy(mdev->cmdline, buf, count);
-
if (mdev->cmdline[count - 1] == '\n')
mdev->cmdline[count - 1] = '\0';
-   else
-   mdev->cmdline[count] = '\0';
 unlock:
mutex_unlock(>mic_mutex);
return count;
@@ -256,17 +252,14 @@ firmware_store(struct device *dev, struct 
device_attribute *attr,
mutex_lock(>mic_mutex);
kfree(mdev->firmware);
 
-   mdev->firmware = kmalloc(count + 1, GFP_KERNEL);
+   mdev->firmware = kstrdup(buf, GFP_KERNEL);
if (!mdev->firmware) {
count = -ENOMEM;
goto unlock;
}
-   strncpy(mdev->firmware, buf, count);
 
if (mdev->firmware[count - 1] == '\n')
mdev->firmware[count - 1] = '\0';
-   else
-   mdev->firmware[count] = '\0';
 unlock:
mutex_unlock(>mic_mutex);
return count;
@@ -301,18 +294,14 @@ ramdisk_store(struct device *dev, struct device_attribute 
*attr,
mutex_lock(>mic_mutex);
kfree(mdev->ramdisk);
 
-   mdev->ramdisk = kmalloc(count + 1, GFP_KERNEL);
+   mdev->ramdisk = kstrdup(buf, GFP_KERNEL);
if (!mdev->ramdisk) {
count = -ENOMEM;
goto unlock;
}
 
-   strncpy(mdev->ramdisk, buf, count);
-
if (mdev->ramdisk[count - 1] == '\n')
mdev->ramdisk[count - 1] = '\0';
-   else
-   mdev->ramdisk[count] = '\0';
 unlock:
mutex_unlock(>mic_mutex);
return count;
@@ -350,18 +339,14 @@ bootmode_store(struct device *dev, struct 
device_attribute *attr,
mutex_lock(>mic_mutex);
kfree(mdev->bootmode);
 
-   mdev->bootmode = kmalloc(count + 1, GFP_KERNEL);
+   mdev->bootmode = kstrdup(buf, GFP_KERNEL);
if (!mdev->bootmode) {
count = -ENOMEM;
goto unlock;
}
 
-   strncpy(mdev->bootmode, buf, count);
-
if (mdev->bootmode[count - 1] == '\n')
mdev->bootmode[count - 1] = '\0';
-   else
-   mdev->bootmode[count] = '\0';
 unlock:
mutex_unlock(>mic_mutex);
return count;
-- 
2.5.0


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


Re: [PATCH v4 1/5] mtd: nand: Create a BBT flag to access bad block markers in raw mode

2015-10-01 Thread Brian Norris
On Wed, Aug 19, 2015 at 10:19:02AM +0530, Archit Taneja wrote:
> Some controllers can access the factory bad block marker from OOB only
> when they read it in raw mode. When ECC is enabled, these controllers
> discard reading/writing bad block markers, preventing access to them
> altogether.
> 
> The bbt driver assumes MTD_OPS_PLACE_OOB when scanning for bad blocks.
> This results in the nand driver's ecc->read_oob() op to be called, which
> works with ECC enabled.
> 
> Create a new BBT option flag that tells nand_bbt to force the mode to
> MTD_OPS_RAW. This would result in the correct op being called for the
> underlying nand controller driver.

MTD_OPS_RAW is probably the best way to do this, and we should switch
back to it for all users (rather than a new flag). But to do this, we
need to fix up some things. Particularly, we need to extend
'badblockbits' support so that it is applied consistently in all places
(I recall there is one code path in which bad block scanning does take
this into account, and one that doesn't.)

About badblockbits: it allows us to do a relaxed heuristic on matching
bad block markers, where we say the BBM is "bad" if more than fewer than
N bits are '1'. Right now, we just say that if there are any 0 bits in
the Bad Block Marker (BBM) region, then the block is bad. But this is
problematic for pages that have been worn down and might have bitflips.
So right now, part of a (bad) solution is to read with ECC, so worn
blocks that have data won't be later interpreted as bad blocks if we
rescan the BBMs (ECC will correct the bitflips, if the OOB is
protected).

But that solution is not really good, since ECC is not really a panacea
for misinterpreted BBMs. And HW like yours apparently won't work like
this.

So in summary: if we can consistently make BBM checks look for 6 or 7
"one" bits (rather than a full 8 bits, i.e. BBM == 0xff), then we can
just unconditionally switch to RAW rather than PLACE_OOB. And we don't
need a flag like this pach introduces.

Brian

> Reviewed-by: Andy Gross 
> Signed-off-by: Archit Taneja 
> ---
>  drivers/mtd/nand/nand_base.c | 6 +-
>  drivers/mtd/nand/nand_bbt.c  | 6 +-
>  include/linux/mtd/bbm.h  | 7 +++
>  3 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index ceb68ca..0a0c524 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -394,7 +394,11 @@ static int nand_default_block_markbad(struct mtd_info 
> *mtd, loff_t ofs)
>   } else {
>   ops.len = ops.ooblen = 1;
>   }
> - ops.mode = MTD_OPS_PLACE_OOB;
> +
> + if (unlikely(chip->bbt_options & NAND_BBT_ACCESS_BBM_RAW))
> + ops.mode = MTD_OPS_RAW;
> + else
> + ops.mode = MTD_OPS_PLACE_OOB;
>  
>   /* Write to first/last page(s) if necessary */
>   if (chip->bbt_options & NAND_BBT_SCANLASTPAGE)
> diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
> index 63a1a36..f2d89c9 100644
> --- a/drivers/mtd/nand/nand_bbt.c
> +++ b/drivers/mtd/nand/nand_bbt.c
> @@ -420,7 +420,11 @@ static int scan_block_fast(struct mtd_info *mtd, struct 
> nand_bbt_descr *bd,
>   ops.oobbuf = buf;
>   ops.ooboffs = 0;
>   ops.datbuf = NULL;
> - ops.mode = MTD_OPS_PLACE_OOB;
> +
> + if (unlikely(bd->options & NAND_BBT_ACCESS_BBM_RAW))
> + ops.mode = MTD_OPS_RAW;
> + else
> + ops.mode = MTD_OPS_PLACE_OOB;
>  
>   for (j = 0; j < numpages; j++) {
>   /*
> diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h
> index 36bb6a5..f67f84a 100644
> --- a/include/linux/mtd/bbm.h
> +++ b/include/linux/mtd/bbm.h
> @@ -116,6 +116,13 @@ struct nand_bbt_descr {
>  #define NAND_BBT_NO_OOB_BBM  0x0008
>  
>  /*
> + * Force MTD_OPS_RAW mode when trying to access bad block markes from OOB. To
> + * be used by controllers which can access BBM only when ECC is disabled, 
> i.e,
> + * when in RAW access mode
> + */
> +#define NAND_BBT_ACCESS_BBM_RAW  0x0010
> +
> +/*
>   * Flag set by nand_create_default_bbt_descr(), marking that the 
> nand_bbt_descr
>   * was allocated dynamicaly and must be freed in nand_release(). Has no 
> meaning
>   * in nand_chip.bbt_options.
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> hosted by The Linux Foundation
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [dpdk-dev] [PATCH 2/2] uio: new driver to support PCI MSI-X

2015-10-01 Thread Alexander Duyck

On 10/01/2015 05:04 PM, Stephen Hemminger wrote:

On Thu, 1 Oct 2015 16:40:10 -0700
Alexander Duyck  wrote:


Do you really need to map IORESOURCE bars?  Most drivers I can think of
don't use IO BARs anymore.  Maybe we could look at just dropping the
code and adding it back later if we have a use case that absolutely
needs it.

Mapping is not strictly necessary, but for virtio it acts a way to communicate
the regions.


I think I see what you are saying.  I was hoping we could get away from 
having to map any I/O ports but it looks like virtio is still using them 
for BAR 0, or at least that is what I am seeing on my VM with 
virtio_net.  I was really hoping we could get away from that since a 16b 
address space is far too restrictive anyway.



Also how many devices actually need resources beyond BAR 0?  I'm just
curious as I know BAR 2 on many of the Intel devices is the register
space related to MSI-X so now we have both the PCIe subsystem and user
space with access to this region.

VMXNet3 needs 2 bars. Most use only one.


So essentially we are needing to make exceptions for the virtual interfaces.

I guess there isn't much we can do then and we probably need to map any 
and all base address registers we can find for the given device.  I was 
hoping for something a bit more surgical since we are opening a security 
hole of sorts, but I guess it can't be helped if we want to support 
multiple devices and they all have such radically different configurations.


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


Re: [PATCH] ARM: shmobile: dt: Rename incorrect interrupt related binding

2015-10-01 Thread Simon Horman
[CCed linux-sh, Magnus]

On Tue, Sep 29, 2015 at 09:43:08AM +0100, Lee Jones wrote:
> interrupts-names => interrupt-names
> 
> Other line changes are re-aligning.
> 
> Signed-off-by: Lee Jones 

Thanks, I have queued this up as a cleanup for v4.4.

> ---
>  .../bindings/memory-controllers/renesas-memory-controllers.txt  | 6 
> +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git 
> a/Documentation/devicetree/bindings/memory-controllers/renesas-memory-controllers.txt
>  
> b/Documentation/devicetree/bindings/memory-controllers/renesas-memory-controllers.txt
> index c64b792..9f78e6c 100644
> --- 
> a/Documentation/devicetree/bindings/memory-controllers/renesas-memory-controllers.txt
> +++ 
> b/Documentation/devicetree/bindings/memory-controllers/renesas-memory-controllers.txt
> @@ -24,9 +24,9 @@ Required properties:
>  Optional properties:
>- interrupts: Must contain a list of interrupt specifiers for memory
>   controller interrupts, if available.
> -  - interrupts-names: Must contain a list of interrupt names corresponding to
> -   the interrupts in the interrupts property, if available.
> -   Valid interrupt names are:
> +  - interrupt-names: Must contain a list of interrupt names corresponding to
> +  the interrupts in the interrupts property, if available.
> +  Valid interrupt names are:
>   - "sec" (secure interrupt)
>   - "temp" (normal (temperature) interrupt)
>- power-domains: Must contain a reference to the PM domain that the memory
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] sched: Fix task_tick_fair from disabling numa_balancing

2015-10-01 Thread Srikar Dronamraju
If static branch sched_numa_balancing is enabled, it should kickstart
numa_balancing through task_tick_numa(). However Commit 2a1ed24
("sched/numa: Convert sched_numa_balancing to a static_branch")
erroneously disables this.

Fix this anomaly by enabling task_tick_numa when static branch
sched_numa_balancing is enabled.

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

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 4df37a4..3bdc3da 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7881,7 +7881,7 @@ static void task_tick_fair(struct rq *rq, struct 
task_struct *curr, int queued)
entity_tick(cfs_rq, se, queued);
}
 
-   if (!static_branch_unlikely(_numa_balancing))
+   if (static_branch_unlikely(_numa_balancing))
task_tick_numa(rq, curr);
 }
 
-- 
2.1.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/


Re: [PATCH] PM / devfreq: fix double kfree

2015-10-01 Thread MyungJoo Ham
> When device_register() fails, kfree(devfreq) is called already in
> devfreq_dev_release(), hence there is no need to call kfree(devfreq)
> in err_dev again.
> 
> Signed-off-by: Geliang Tang 

Thank you for pointing out that put_device() will eventually call kfree anyway.

Signed-off-by: MyungJoo Ham 



Cheers,
MyungJoo

> ---
>  drivers/devfreq/devfreq.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 3927ed9..9b352da 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -492,7 +492,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
>   if (err) {
>   put_device(>dev);
>   mutex_unlock(>lock);
> - goto err_dev;
> + goto err_out;
>   }
>  
>   mutex_unlock(>lock);
> @@ -518,7 +518,6 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  err_init:
>   list_del(>node);
>   device_unregister(>dev);
> -err_dev:
>   kfree(devfreq);
>  err_out:
>   return ERR_PTR(err);
> -- 
> 2.5.0
N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

Re: [PATCH 13/38] ARM: shmobile: apmu: correct type of CPU id

2015-10-01 Thread Simon Horman
On Mon, Sep 21, 2015 at 03:33:45PM +0200, Andrzej Hajda wrote:
> CPU id can be negative, so it cannot be assigned to unsigned variable.
> 
> The problem has been detected using proposed semantic patch
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
> 
> Signed-off-by: Andrzej Hajda 

Thanks, I have queued this up as a cleanup for v4.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/


Re: [PATCH] x86: uapi: Fix __BITS_PER_LONG for x32

2015-10-01 Thread Ben Hutchings
On Thu, 2015-10-01 at 21:54 +0100, Ben Hutchings wrote:
> On Thu, 2015-10-01 at 09:02 -0400, Brian Gerst wrote:
> > On Thu, Oct 1, 2015 at 4:23 AM, Ingo Molnar  wrote:
> > > 
> > > * Ben Hutchings  wrote:
> > > 
> > > > diff --git a/arch/x86/include/uapi/asm/bitsperlong.h
> > > > b/arch/x86/include/uapi/asm/bitsperlong.h
> > > > index b0ae1c4..217909b 100644
> > > > --- a/arch/x86/include/uapi/asm/bitsperlong.h
> > > > +++ b/arch/x86/include/uapi/asm/bitsperlong.h
> > > > @@ -1,7 +1,7 @@
> > > >  #ifndef __ASM_X86_BITSPERLONG_H
> > > >  #define __ASM_X86_BITSPERLONG_H
> > > > 
> > > > -#ifdef __x86_64__
> > > > +#if defined(__x86_64__) && !defined(__ILP32__)
> > > >  # define __BITS_PER_LONG 64
> > > 
> > > Can we write this as:
> > > 
> > >#ifdef __ILP64__
> 
> Assuming you meant __LP64__...
> 
> > Do all versions of gcc/clang define that, even if x32 isn't
> > supported?
> 
> For gcc, it's been defined since 2003 (gcc 3.3):
> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0bdab2d89e28ca4dc84f8f0fafed85a4822bca49
> 
> For clang, it's been defined since before its first public release:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?r1=38978=38987=161685
> 
> So gcc 3.1 and 3.2 didn't define it, but everything newer does.

As the kernel itself is supposed to still be compilable with gcc 3.2, I
think this means that my patch has the right condition.

Ben.

-- 
Ben Hutchings
When in doubt, use brute force. - Ken Thompson

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


Re: linux-next: build failure after merge of the battery tree

2015-10-01 Thread Stephen Rothwell
Hi Sebastian,

On Tue, 29 Sep 2015 11:45:31 +1000 Stephen Rothwell  
wrote:
>
> After merging the battery tree, today's linux-next build (arm
> multi_v7_defconfig) failed like this:
> 
> ERROR (phandle_references): Reference to non-existent node or label 
> "twl4030_madc"
> ERROR: Input tree has errors, aborting (use -f to force output)
> scripts/Makefile.lib:293: recipe for target 
> 'arch/arm/boot/dts/omap3-beagle-xm-ab.dtb' failed
> 
> and many more ...
> 
> Caused by commit
> 
>   af19161aaed7 ("ARM: dts: twl4030: Add iio properties for bci subnode")
> 
> Presumably some updates to other files were missed.
> 
> I have used the battery tree from next-20150925 fot today.

I am still getting this error.

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au
--
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: [dpdk-dev] [PATCH 0/2] uio_msi: device driver

2015-10-01 Thread Alexander Duyck

On 10/01/2015 05:04 PM, Stephen Hemminger wrote:

On Thu, 1 Oct 2015 16:43:23 -0700
Alexander Duyck  wrote:


Yes, but in the case of something like a VF it is going to just make a
bigger mess of things since INTx doesn't work.  So what would you expect
your driver to do in that case?  Also we have to keep in mind that the
MSI-X failure case is very unlikely.

One other thing that just occurred to me is that you may want to try
using the range allocation call instead of a hard set number of
interrupts.  Then if you start running short on vectors you don't hard
fail and instead just allocate what you can.

I tried that but the bookkeeping gets messy since there is no good
way to communicate that back to userspace and have it adapt.


Actually I kind of just realized that uio_msi_open is kind of messed 
up.  So if the MSI-X allocation fails due to no resources it will return 
a positive value indicating the number of vectors that could be 
allocated, a negative value if one of the input values is invalid, or 
0.  I'm not sure if returning a positive value on failure is an issue or 
not.  I know the open call is supposed to return a negative value or the 
file descriptor if not negative.  I don't know if the return value might 
be interpreted as a file descriptor or not.


Also if MSI-X is supported by the hardware, but disabled for some reason 
by the kernel ("pci=nomsi")  then this driver is rendered inoperable 
since it will never give you anything but -EINVAL from the open call.


I really think you should probably look at taking care of enabling MSI-X 
and maybe MSI as a fall-back in probe.  At least then you can post a 
message about how many vectors are enabled and what type. Then if you 
cannot enable any interrupts due to MSI being disabled you can simply 
fail at probe time and let then load a different driver.


- Alex
--
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 26/26] x86, pkeys: Documentation

2015-10-01 Thread Linus Torvalds
On Thu, Oct 1, 2015 at 6:56 PM, Dave Hansen  wrote:
>
> Also, a quick ftrace showed that most mmap() callers that set PROT_EXEC
> also set PROT_READ.  I'm just assuming that folks are setting PROT_READ
> but aren't _really_ going to read it, so we can safely deny them all
> access other than exec.

That's a completely insane assumption. There are tons of reasons to
have code and read-only data in the same segment, and it's very
traditional. Just assuming that you only execute out of something that
has PROT_EXEC | PROT_READ is insane.

No, what you *should* look at is to use the protection keys to
actually enforce a plain PROT_EXEC. That has never worked before
(because traditionally R implies X, and then we got NX).

That would at least allow people who know they don't intersperse
read-only constants in the code to use PROT_EXE only.

Of course, there may well be users who use PROT_EXE that actually *do*
do reads, and just relied on the old hardware behavior. So it's not
guaranteed to work either without any extra flags. But at least it's
worth a try, unlike the "yeah, the user asked for read, but the user
doesn't know what he's doing" thinking that is just crazy talk.

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


Re: [GIT PULL] clk: mediatek: New clocks support and fixes

2015-10-01 Thread Eddie Huang
On Thu, 2015-10-01 at 12:29 -0700, Stephen Boyd wrote:
> On 09/30, Daniel Kurtz wrote:
> > Hi Mike,
> > 
> > On Tue, Sep 22, 2015 at 5:53 PM, James Liao  
> > wrote:
> > > This is a collection of new Mediatek clocks support and fixes. These
> > > patches come from Joe [1], Pi-cheng [2] and me [3], including clock
> > > support for subsystems, CPU, GPT and some minor fixes.
> > >
> > > [1] https://patchwork.kernel.org/patch/6777041/
> > > [2] https://patchwork.kernel.org/patch/7174721/
> > > [3] https://lkml.org/lkml/2015/8/10/194
> > >
> > > 
> > >
> > > The following changes since commit 
> > > 1f93e4a96c9109378204c147b3eec0d0e8100fde:
> > >
> > >   Linux 4.3-rc2 (2015-09-20 14:32:34 -0700)
> > >
> > > are available in the git repository at:
> > >
> > >   https://github.com/jamesjjliao/linux.git v4.3-rc2-clk
> > >
> > > for you to fetch changes up to 74219612bb7e25e64409171acada05d9949228f2:
> > >
> > >   arm64: dts: mt8173: Add subsystem clock controller device nodes 
> > > (2015-07-09 12:58:14 +0800)
> > >
> > 
> > Will this be pulled for 4.3, or is it now destined for 4.4?
> > (sorry if you are receiving a duplicate email, the previous had HTML
> > and was rejected by the lists)
> 
> This won't make v4.3. I see that there's a third pull request
> now, with slightly different contents. Why?
> 

Sorry not explain in pull request mail. Third pull request remove two
patches:

1. arm64: dts: mt8173: Add subsystem clock controller device nodes
   I think this should pull by Matthias, so I suggest James remove this
patch.

2. clk: mediatek: Export CPU mux clocks for CPU frequency control
   Mike said this patch is ok before
(http://lists.infradead.org/pipermail/linux-arm-kernel/2015-August/364886.html) 
But he told Pi-cheng recently he is working on coordinate clock rate, he
suggest Pi-cheng change this patch, other patches are ok. So James
remove this patch.

Eddie
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 4.1 00/29] 4.1.10-stable review

2015-10-01 Thread Guenter Roeck
On Thu, Oct 01, 2015 at 11:31:36AM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.1.10 release.
> There are 29 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat Oct  3 09:31:26 UTC 2015.
> Anything received after that time might be too late.
> 
Build results:
total: 137 pass: 137 fail: 0
Qemu test results:
total: 93 pass: 92 fail: 1
Failed tests:
mips:fuloong2e_defconfig

Details are available at http://server.roeck-us.net:8010/builders.

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


[RFC][PATCH v2 0/2] PM / sleep: Make it possible to check if suspend/resume goes via firmware

2015-10-01 Thread Rafael J. Wysocki
On Wednesday, September 30, 2015 02:46:10 AM Rafael J. Wysocki wrote:
> Hi All,
> 
> Patch [1/2] introduces a new mechanism that can be used to check whether or 
> not
> platform firmware is going to be involved in system suspend or was involved
> in system resume.

That's still the case, but patch [2/2] modifies the PCI PM layer and the general
ACPI PM domain only to use the mechanism added by the [1/2].

Comments welcome.

Thanks,
Rafael

--
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 4.2 00/30] 4.2.3-stable review

2015-10-01 Thread Guenter Roeck
On Thu, Oct 01, 2015 at 11:21:22AM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.2.3 release.
> There are 30 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat Oct  3 09:20:05 UTC 2015.
> Anything received after that time might be too late.
> 

Build results:
total: 144 pass: 144 fail: 0
Qemu test results:
total: 93 pass: 92 fail: 1
Failed tests:
mips:fuloong2e_defconfig

Details are available at http://server.roeck-us.net:8010/builders.

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


[RFC][PATCH v2 2/2] PM / PCI / ACPI: Kick devices that might have been reset by firmware

2015-10-01 Thread Rafael J. Wysocki
From: Rafael J. Wysocki 

There is a concern that if the platform firmware was involved in
the system resume that's being completed,  some devices might have
been reset by it and if those devices had the power.direct_complete
flag set during the preceding suspend transition, they may stay
in a reset-power-on state indefinitely (until they are runtime-resumed
and then suspended again).  That may not be a big deal from the
individual device's perspective, but if the system is an SoC, it may
be prevented from entering deep SoC-wide low-power states on idle
because of that.

The devices that are most likely to be affected by this issue are
PCI devices and ACPI-enumerated devices using the general ACPI PM
domain, so to prevent it from happening for those devices, force a
runtime resume for them if they have their power.direct_complete
flags set and the platform firmware was involved in the resume
transition currently in progress.

Signed-off-by: Rafael J. Wysocki 
---

v1 -> v2: Do it for devices that are most likely to be affected (PCI and the
ACPI PM domain users) rather than for all devices in the system.

---
 drivers/acpi/acpi_lpss.c |2 +-
 drivers/acpi/device_pm.c |   19 +--
 drivers/base/power/generic_ops.c |   23 +++
 drivers/pci/pci-driver.c |2 +-
 include/linux/pm.h   |2 +-
 5 files changed, 27 insertions(+), 21 deletions(-)

Index: linux-pm/drivers/acpi/device_pm.c
===
--- linux-pm.orig/drivers/acpi/device_pm.c
+++ linux-pm/drivers/acpi/device_pm.c
@@ -963,23 +963,6 @@ int acpi_subsys_prepare(struct device *d
 EXPORT_SYMBOL_GPL(acpi_subsys_prepare);
 
 /**
- * acpi_subsys_complete - Finalize device's resume during system resume.
- * @dev: Device to handle.
- */
-void acpi_subsys_complete(struct device *dev)
-{
-   pm_generic_complete(dev);
-   /*
-* If the device had been runtime-suspended before the system went into
-* the sleep state it is going out of and it has never been resumed till
-* now, resume it in case the firmware powered it up.
-*/
-   if (dev->power.direct_complete)
-   pm_request_resume(dev);
-}
-EXPORT_SYMBOL_GPL(acpi_subsys_complete);
-
-/**
  * acpi_subsys_suspend - Run the device driver's suspend callback.
  * @dev: Device to handle.
  *
@@ -1047,7 +1030,7 @@ static struct dev_pm_domain acpi_general
.runtime_resume = acpi_subsys_runtime_resume,
 #ifdef CONFIG_PM_SLEEP
.prepare = acpi_subsys_prepare,
-   .complete = acpi_subsys_complete,
+   .complete = pm_complete_with_resume_check,
.suspend = acpi_subsys_suspend,
.suspend_late = acpi_subsys_suspend_late,
.resume_early = acpi_subsys_resume_early,
Index: linux-pm/drivers/acpi/acpi_lpss.c
===
--- linux-pm.orig/drivers/acpi/acpi_lpss.c
+++ linux-pm/drivers/acpi/acpi_lpss.c
@@ -664,7 +664,7 @@ static struct dev_pm_domain acpi_lpss_pm
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM_SLEEP
.prepare = acpi_subsys_prepare,
-   .complete = acpi_subsys_complete,
+   .complete = pm_complete_with_resume_check,
.suspend = acpi_subsys_suspend,
.suspend_late = acpi_lpss_suspend_late,
.resume_early = acpi_lpss_resume_early,
Index: linux-pm/drivers/base/power/generic_ops.c
===
--- linux-pm.orig/drivers/base/power/generic_ops.c
+++ linux-pm/drivers/base/power/generic_ops.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_PM
 /**
@@ -297,4 +298,26 @@ void pm_generic_complete(struct device *
if (drv && drv->pm && drv->pm->complete)
drv->pm->complete(dev);
 }
+
+/**
+ * pm_complete_with_resume_check - Complete a device power transition.
+ * @dev: Device to handle.
+ *
+ * Complete a device power transition during a system-wide power transition and
+ * optionally schedule a runtime resume of the device if the system resume in
+ * progress has been initated by the platform firmware and the device had its
+ * power.direct_complete flag set.
+ */
+void pm_complete_with_resume_check(struct device *dev)
+{
+   pm_generic_complete(dev);
+   /*
+* If the device had been runtime-suspended before the system went into
+* the sleep state it is going out of and it has never been resumed till
+* now, resume it in case the firmware powered it up.
+*/
+   if (dev->power.direct_complete && pm_resume_via_firmware())
+   pm_request_resume(dev);
+}
+EXPORT_SYMBOL_GPL(pm_complete_with_resume_check);
 #endif /* CONFIG_PM_SLEEP */
Index: linux-pm/drivers/pci/pci-driver.c
===
--- 

[RFC][PATCH v2 1/2] PM / sleep: Add flags to indicate platform firmware involvement

2015-10-01 Thread Rafael J. Wysocki
From: Rafael J. Wysocki 

There are quite a few cases in which device drivers, bus types or
even the PM core itself may benefit from knowing whether or not
the platform firmware will be involved in the upcoming system power
transition (during system suspend) or whether or not it was involved
in it (during system resume).

For this reason, introduce global system suspend flags that can be
used by the platform code to expose that information for the benefit
of the other parts of the kernel and make the ACPI core set them
as appropriate.

Users of the new flags will be added later.

Signed-off-by: Rafael J. Wysocki 
---

v1 -> v2: Apply EXPORT_SYMBOL_GPL() to pm_suspend_global_flags so modular
drivers can use it too.

---
 drivers/acpi/sleep.c|3 +++
 include/linux/suspend.h |   36 
 kernel/power/suspend.c  |4 
 3 files changed, 43 insertions(+)

Index: linux-pm/include/linux/suspend.h
===
--- linux-pm.orig/include/linux/suspend.h
+++ linux-pm/include/linux/suspend.h
@@ -202,6 +202,36 @@ struct platform_freeze_ops {
 extern void suspend_set_ops(const struct platform_suspend_ops *ops);
 extern int suspend_valid_only_mem(suspend_state_t state);
 
+extern unsigned int pm_suspend_global_flags;
+
+#define PM_SUSPEND_FLAG_FW_SUSPEND (1 << 0)
+#define PM_SUSPEND_FLAG_FW_RESUME  (1 << 1)
+
+static inline void pm_suspend_clear_flags(void)
+{
+   pm_suspend_global_flags = 0;
+}
+
+static inline void pm_set_suspend_via_firmware(void)
+{
+   pm_suspend_global_flags |= PM_SUSPEND_FLAG_FW_SUSPEND;
+}
+
+static inline void pm_set_resume_via_firmware(void)
+{
+   pm_suspend_global_flags |= PM_SUSPEND_FLAG_FW_RESUME;
+}
+
+static inline bool pm_suspend_via_firmware(void)
+{
+   return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_SUSPEND);
+}
+
+static inline bool pm_resume_via_firmware(void)
+{
+   return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_RESUME);
+}
+
 /* Suspend-to-idle state machnine. */
 enum freeze_state {
FREEZE_STATE_NONE,  /* Not suspended/suspending. */
@@ -241,6 +271,12 @@ extern int pm_suspend(suspend_state_t st
 #else /* !CONFIG_SUSPEND */
 #define suspend_valid_only_mem NULL
 
+static inline void pm_suspend_clear_flags(void) {}
+static inline void pm_set_suspend_via_firmware(void) {}
+static inline void pm_set_resume_via_firmware(void) {}
+static inline bool pm_suspend_via_firmware(void) { return false; }
+static inline bool pm_resume_via_firmware(void) { return false; }
+
 static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
 static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
 static inline bool idle_should_freeze(void) { return false; }
Index: linux-pm/kernel/power/suspend.c
===
--- linux-pm.orig/kernel/power/suspend.c
+++ linux-pm/kernel/power/suspend.c
@@ -35,6 +35,9 @@
 const char *pm_labels[] = { "mem", "standby", "freeze", NULL };
 const char *pm_states[PM_SUSPEND_MAX];
 
+unsigned int pm_suspend_global_flags;
+EXPORT_SYMBOL_GPL(pm_suspend_global_flags);
+
 static const struct platform_suspend_ops *suspend_ops;
 static const struct platform_freeze_ops *freeze_ops;
 static DECLARE_WAIT_QUEUE_HEAD(suspend_freeze_wait_head);
@@ -493,6 +496,7 @@ static int enter_state(suspend_state_t s
 #endif
 
pr_debug("PM: Preparing system for sleep (%s)\n", pm_states[state]);
+   pm_suspend_clear_flags();
error = suspend_prepare(state);
if (error)
goto Unlock;
Index: linux-pm/drivers/acpi/sleep.c
===
--- linux-pm.orig/drivers/acpi/sleep.c
+++ linux-pm/drivers/acpi/sleep.c
@@ -487,6 +487,8 @@ static int acpi_suspend_begin(suspend_st
pr_err("ACPI does not support sleep state S%u\n", acpi_state);
return -ENOSYS;
}
+   if (acpi_state > ACPI_STATE_S1)
+   pm_set_suspend_via_firmware();
 
acpi_pm_start(acpi_state);
return 0;
@@ -522,6 +524,7 @@ static int acpi_suspend_enter(suspend_st
if (error)
return error;
pr_info(PREFIX "Low-level resume complete\n");
+   pm_set_resume_via_firmware();
break;
}
trace_suspend_resume(TPS("acpi_suspend"), acpi_state, false);

--
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] modpost: Add flag -f for making section mismatches fatal

2015-10-01 Thread Rusty Russell
Nicolas Boichat  writes:
> The section mismatch warning can be easy to miss during the kernel build
> process. Allow it to be marked as fatal to be easily caught and prevent
> bugs from slipping in.
>
> Setting CONFIG_SECTION_MISMATCH_WARNING=y causes these warnings to be
> non-fatal, since there are a number of section mismatches when using
> allmodconfig on some architectures, and we do not want to break these
> builds by default.
>
> Signed-off-by: Nicolas Boichat 
>
> Change-Id: Ic346706e3297c9f0d790e3552aa94e5cff9897a6
> ---
>
> I'm trying to revive this old patch. When it was first submitted [1],
> Jonathan got the following feedback:
>  - The logic of the option should be inverted (i.e. SECTION_MISMATCH_WARNING),
>so that is not not enabled in allmodconfig for some architectures that do
>have section mismatches. I've seen some failures (namely, on arm64), so I
>did that.
>  - CONFIG_DEBUG_SECTION_MISMATCH should be removed and warnings should always
>be shown verbosely. This option does 3 things:
>  1. Enable -fno-inline-functions-called-onc
>  2. Run the section mismatch analysis for each module/built-in.o
>  3. Enable verbose reporting from modpost
>We definitely do not want 1 by default, so I think we should keep the 
> option.
>If we enable 2 & 3 by default, which I think would be reasonable, then the
>option name does not make much sense anymore, and I'm not sure what to do
>with the documentation that is currently provided in the Kconfig 
> description.
>
> Tested on x86-64 allmodconfig, setting the option to =n, and creating a
> section mismatch by running:
> sed -i -e 's/\(ssize_t soc_codec_reg_show\)/__init \1/' sound/soc/soc-core.c

Minor feedback:

1) Please rename to CONFIG_SECTION_MISMATCH_WARN_ONLY.
2) -f means force, perhaps -E for error?

Otherwise, quite nice.

Thanks,
Rusty.
--
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: [RESEND PATCH] sched: consider missed ticks when updating global cpu load

2015-10-01 Thread Byungchul Park
On Fri, Oct 02, 2015 at 09:43:17AM +0900, Byungchul Park wrote:
> On Sat, Sep 26, 2015 at 03:14:45PM +0200, Frederic Weisbecker wrote:
> > On Fri, Sep 25, 2015 at 05:52:37PM +0900, byungchul.p...@lge.com wrote:
> > > From: Byungchul Park 
> > > 
> > > hello,
> > > 
> > > i have already sent this patch about 1 month ago.
> > > (see https://lkml.org/lkml/2015/8/13/160)
> > > 
> > > now, i am resending the same patch with adding some additional commit 
> > > message.
> > > 
> > > thank you,
> > > byungchul
> > > 
> > > ->8-
> > > From 8ece9a0482e74a39cd2e9165bf8eec1d04665fa9 Mon Sep 17 00:00:00 2001
> > > From: Byungchul Park 
> > > Date: Fri, 25 Sep 2015 17:10:10 +0900
> > > Subject: [RESEND PATCH] sched: consider missed ticks when updating global 
> > > cpu
> > >  load
> > > 
> > > in hrtimer_interrupt(), the first tick_program_event() can be failed
> > > because the next timer could be already expired due to,
> > > (see the comment in hrtimer_interrupt())
> > > 
> > > - tracing
> > > - long lasting callbacks
> > > - being scheduled away when running in a VM
> > > 
> > > in the case that the first tick_program_event() is failed, the second
> > > tick_program_event() set the expired time to more than one tick later.
> > > then next tick can happen after more than one tick, even though tick is
> > > not stopped by e.g. NOHZ.
> > > 
> > > when the next tick occurs, update_process_times() -> scheduler_tick()
> > > -> update_cpu_load_active() is performed, assuming the distance between
> > > last tick and current tick is 1 tick! it's wrong in this case. thus,
> > > this abnormal case should be considered in update_cpu_load_active().
> > > 
> > > Signed-off-by: Byungchul Park 
> > > ---
> > >  kernel/sched/fair.c |7 +--
> > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > > index 4d5f97b..829282f 100644
> > > --- a/kernel/sched/fair.c
> > > +++ b/kernel/sched/fair.c
> > > @@ -4356,12 +4356,15 @@ void update_cpu_load_nohz(void)
> > >   */
> > >  void update_cpu_load_active(struct rq *this_rq)
> > >  {
> > > + unsigned long curr_jiffies = READ_ONCE(jiffies);
> > > + unsigned long pending_updates;
> > >   unsigned long load = weighted_cpuload(cpu_of(this_rq));
> > >   /*
> > >* See the mess around update_idle_cpu_load() / update_cpu_load_nohz().
> > >*/
> > > - this_rq->last_load_update_tick = jiffies;
> > > - __update_cpu_load(this_rq, load, 1);
> > > + pending_updates = curr_jiffies - this_rq->last_load_update_tick;
> > > + this_rq->last_load_update_tick = curr_jiffies;
> > > + __update_cpu_load(this_rq, load, pending_updates);
> > >  }
> > 
> > That's right but __update_cpu_load() doesn't handle correctly pending 
> > updates
> > with non-zero loads. Currently, pending updates are wheeled through 
> > decay_load_missed()
> > that assume it's all about idle load.
> 
> i see, i will check it.
> 
> > 
> > But in the cases you've enumerated, as well as in the nohz full case, 
> > missed pending
> > updates can be about buzy loads.
> 
> right. it can be about busy loads.
> 
> > 
> > I think we need to fix update_cpu_load() to handle that first, or your fix 
> > is
> > going to make things worse.
> 
> i will try to fix it at first if there's already that kind of bugs.

i checked it.. current code does not handle more than one active tick
at all, rather than bug..

> 
> thanks,
> byungchul
> 
> > --
> > 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/
--
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] kernel/params.c: remove confusing cast

2015-10-01 Thread Rusty Russell
Rasmus Villemoes  writes:
> Both sides of the assignment are const char*, so this cast is
> unnecessary and confusing.
>
> Signed-off-by: Rasmus Villemoes 

Acked-by: Rusty Russell 

Thanks,
Rusty.

>  kernel/params.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/params.c b/kernel/params.c
> index b6554aa71094..0b433fdb45eb 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -709,7 +709,7 @@ static __modinit int add_sysfs_param(struct 
> module_kobject *mk,
>   mk->mp->attrs[mk->mp->num].mattr.store = param_attr_store;
>   else
>   mk->mp->attrs[mk->mp->num].mattr.store = NULL;
> - mk->mp->attrs[mk->mp->num].mattr.attr.name = (char *)name;
> + mk->mp->attrs[mk->mp->num].mattr.attr.name = name;
>   mk->mp->attrs[mk->mp->num].mattr.attr.mode = kp->perm;
>   mk->mp->num++;
>  
> -- 
> 2.1.3
--
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: [dpdk-dev] [PATCH 2/2] uio: new driver to support PCI MSI-X

2015-10-01 Thread Alexander Duyck

On 10/01/2015 05:01 PM, Stephen Hemminger wrote:

On Thu, 1 Oct 2015 16:40:10 -0700
Alexander Duyck  wrote:


I agree with some other reviewers.  Why call pci_enable_msix in open?
It seems like it would make much more sense to do this on probe, and
then disable MSI-X on free.  I can only assume you are trying to do it
to save on resources but the fact is this is a driver you have to
explicitly force onto a device so you would probably be safe to assume
that they plan to use it in the near future.

Because if interface is not up, the MSI handle doesn't have to be open.
This saves resources and avoids some races.


Yes, but it makes things a bit messier for the interrupts.  Most drivers 
take care of interrupts during probe so that if there are any allocation 
problems they can take care of them then instead of leaving an interface 
out that will later fail when it is brought up.  It ends up being a way 
to deal with the whole MSI-X fall-back issue.


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


[GIT PULL] Power management and ACPI updates for v4.3-rc4

2015-10-01 Thread Rafael J. Wysocki
Hi Linus,

Please pull from

 git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git \
 pm+acpi-4.3-rc4

to receive power management and ACPI material for v4.3-rc4 with
top-most commit eb6d1c287ae1f7221248d5be26a5b1560073c09e

 Merge branches 'pm-cpuidle', 'pm-opp' and 'pm-tools'

on top of commit 9ffecb10283508260936b96022d4ee43a7798b4c

 Linux 4.3-rc3

These are fixes mostly, for a few changes made in this cycle
(the intel_idle driver, the OPP library, the ACPI EC driver,
turbostat) and for some issues that have just been discovered
(ACPI PCI IRQ management, PCI power management
documentation, turbostat), with a couple of cleanups on top
of them.

Specifics:

 - intel_idle driver fixup for the recently added Skylake chips
   support (Len Brown).

 - Operating Performance Points (OPP) library fix related to the
   recently added support for new DT bindings and a fix for a typo
   in a comment (Viresh Kumar, Stephen Boyd).

 - ACPI EC driver fix for a recently introduced memory leak in an
   error code path (Lv Zheng).

 - ACPI PCI IRQ management fix for the issue where an ISA IRQ is
   shared with a PCI device which requires it to be configured in a
   different way and may cause an interrupt storm to happen as a
   result with an extra ACPI SCI IRQ handling simplification on top
   of it (Jiang Liu).

 - Update of the PCI power management documentation that became
   outdated and started to actively confuse the readers to make
   it actually reflect the code (Rafael J Wysocki).

 - turbostat fixes including an IVB Xeon regression fix (related to
   the --debug command line option), Skylake adjustment for the TSC
   running at a frequency that doesn't match the base one exactly,
   and a Knights Landing quirk to account for the fact that it only
   updates APERF and MPERF every 1024 clock cycles plus bumping up
   the turbostat version number (Len Brown, Hubert Chrzaniuk).

Thanks!


---

Hubert Chrzaniuk (1):
  tools/power turbostat: KNL workaround for %Busy and Avg_MHz

Jiang Liu (2):
  ACPI, PCI, irq: Do not share PCI IRQ with ISA IRQ
  ACPI / PCI: Remove duplicated penalty on SCI IRQ

Len Brown (4):
  intel_idle: Skylake Client Support - updated
  tools/power turbostat: IVB Xeon: fix --debug regression
  tools/power turbostat: SKL: Adjust for TSC difference from base frequency
  tools/power turbosat: update version number

Lv Zheng (1):
  ACPI / EC: Fix a memory leak issue in acpi_ec_query()

Rafael J. Wysocki (1):
  PCI / PM: Update runtime PM documentation for PCI devices

Stephen Boyd (1):
  PM / OPP: Fix typo modifcation -> modification

Viresh Kumar (1):
  PM / OPP: of_property_count_u32_elems() can return errors

---

 Documentation/power/pci.txt   | 51 ++-
 drivers/acpi/ec.c |  2 ++
 drivers/acpi/pci_irq.c|  1 +
 drivers/acpi/pci_link.c   | 16 +--
 drivers/base/power/opp.c  | 17 
 drivers/idle/intel_idle.c | 12 +++--
 drivers/pci/pci-driver.c  |  7 ++---
 include/linux/acpi.h  |  1 +
 tools/power/x86/turbostat/turbostat.c | 39 +++
 9 files changed, 116 insertions(+), 30 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4] clk: add CS2000 Fractional-N driver

2015-10-01 Thread Kuninori Morimoto

Hi Stephen

Thank you for your review

> > +   init.parent_names   = parent_names;
> > +   init.num_parents= ARRAY_SIZE(parent_names);
> > +
> > +   priv->hw.init = 
> > +
> > +   clk = clk_register(NULL, >hw);
> 
> How about using devm_clk_register() and passing the i2c device
> down to this function?

Can I confirm ?
Does this "i2c device down" means call i2c_set_clientdata()
in this function ?

> > +static int cs2000_clk_init(struct cs2000_priv *priv)
> > +{
> > +   struct device *dev = priv_to_dev(priv);
> > +   struct device_node *np = dev->of_node;
> > +   u32 rate;
> > +   int ch = 0; /* it uses ch0 only at this point */
> > +   int ret;
> > +
> > +   if (of_property_read_u32(np, "clock-frequency", ))
> 
> Why can't we do this with DT assigned rates?

What doesn this "DT assigned rates" mean ?
this rate will be used as default output
--
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: [alsa-devel] [RESEND PATCH v2 1/1] ASoC: dwc: fix dma stop transferring issue

2015-10-01 Thread yitian
Hi Mark:

> From: alsa-devel-boun...@alsa-project.org
> [mailto:alsa-devel-boun...@alsa-project.org] On Behalf Of yitian
> Sent: Thursday, October 1, 2015 10:25 AM
> To: 'Mark Brown' 
> Cc: alsa-de...@alsa-project.org; w...@the-dreams.de;
> linux-kernel@vger.kernel.org; andrew.jack...@arm.com;
> lgirdw...@gmail.com; ti...@suse.com;
> linux-arm-ker...@lists.infradead.org
> Subject: Re: [alsa-devel] [RESEND PATCH v2 1/1] ASoC: dwc: fix dma stop
> transferring issue
> 
> > From: linux-arm-kernel
> > [mailto:linux-arm-kernel-boun...@lists.infradead.org] On Behalf Of
> Mark
> > Brown
> > Sent: Thursday, October 1, 2015 2:22 AM
> > To: yitian 
> > Cc: alsa-de...@alsa-project.org; w...@the-dreams.de;
> > linux-kernel@vger.kernel.org; andrew.jack...@arm.com;
> ti...@suse.com;
> > lgirdw...@gmail.com; pe...@perex.cz;
> > linux-arm-ker...@lists.infradead.org
> > Subject: Re: [RESEND PATCH v2 1/1] ASoC: dwc: fix dma stop transferring
> > issue
> >
> > On Tue, Sep 29, 2015 at 10:43:17PM +0800, yitian wrote:
> > > Designware I2S uses tx empty and rx available signals as the DMA
> > > handshaking signals. during music playing, if XRUN occurs,
> > > i2s_stop() function will be executed and both tx and rx irq are
> > > masked, when music continues to be played, i2s_start() is executed
> > > but both tx and rx irq are not unmasked which cause I2S stop
> > > sending DMA handshaking signal to DMA controller, and it finally
> > > causes music playing will be stopped once XRUN occurs for the first
> > > time.
> >
> > I'm a bit concerned about how this code ever worked given the above
> > description - is there some race condition which allows things to work
> > if we're lucky?
> 
> Hi Mark:
> 
> Thanks for your comments.
> I think maybe two reasons:
> 1. designware I2S IP in my chipset(new design) is using tx empty and rx
> available signal as the DMA handshaking signal, but it may be not true
> for all chipsets. If I2S has separate signal as DMA handshaking signal,
mask
> irq should not impact DMA transfer. But Synopsys's engineer recommend
> us to
> use
> tx and rx irq signal as the DMA handshaking signal, meanwhile we cannot
> find
> separate DMA handshaking signal from designware's IP spec, that's why
> tx/rx
> irq
> will impact DMA transfer.
> 
> 2. I am using a FPGA for test, the cpu frequency of it is only 26MHz, that
> means
> XRUN is very easy to happen on my board. But I guess most of the
> developers
> are using real chipset which can have at least 600MHz frequency so XRUN
> is
> not easy to be reproduced. As my test, No XUN, no this bug...

Do I need to provide anything else for this patch? 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 4.1 22/29] net: dsa: bcm_sf2: Do not override speed settings

2015-10-01 Thread David Miller
From: Ben Hutchings 
Date: Fri, 02 Oct 2015 01:47:23 +0100

> On Thu, 2015-10-01 at 11:31 +0200, Greg Kroah-Hartman wrote:
>> 4.1-stable review patch.  If anyone has any objections, please let me
>> know.
>> 
>> --
>> 
>> From: Florian Fainelli 
>> 
>> [ Upstream d2eac98f7d1b950b762a7eca05a9ce0ea1d878d2 in net-next tree,
>>   will be pushed to Linus very soon. ]
> [...]
> 
> Patches 22-25 are all in 4.3-rc3, so perhaps you should change these
> comments to match the real status?

Greg et al. can feel free to do this :-)
--
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: [RESEND PATCH] sched: consider missed ticks when updating global cpu load

2015-10-01 Thread Byungchul Park
On Wed, Sep 30, 2015 at 12:43:43PM +0200, Peter Zijlstra wrote:
> On Sat, Sep 26, 2015 at 03:14:45PM +0200, Frederic Weisbecker wrote:
> 
> > > when the next tick occurs, update_process_times() -> scheduler_tick()
> > > -> update_cpu_load_active() is performed, assuming the distance between
> > > last tick and current tick is 1 tick! it's wrong in this case. thus,
> > > this abnormal case should be considered in update_cpu_load_active().
> > > 
> > > Signed-off-by: Byungchul Park 
> > > ---
> > >  kernel/sched/fair.c |7 +--
> > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > > index 4d5f97b..829282f 100644
> > > --- a/kernel/sched/fair.c
> > > +++ b/kernel/sched/fair.c
> > > @@ -4356,12 +4356,15 @@ void update_cpu_load_nohz(void)
> > >   */
> > >  void update_cpu_load_active(struct rq *this_rq)
> > >  {
> > > + unsigned long curr_jiffies = READ_ONCE(jiffies);
> > > + unsigned long pending_updates;
> > >   unsigned long load = weighted_cpuload(cpu_of(this_rq));
> > >   /*
> > >* See the mess around update_idle_cpu_load() / update_cpu_load_nohz().
> > >*/
> > > - this_rq->last_load_update_tick = jiffies;
> > > - __update_cpu_load(this_rq, load, 1);
> > > + pending_updates = curr_jiffies - this_rq->last_load_update_tick;
> > > + this_rq->last_load_update_tick = curr_jiffies;
> > > + __update_cpu_load(this_rq, load, pending_updates);
> > >  }
> > 
> > That's right but __update_cpu_load() doesn't handle correctly pending 
> > updates
> > with non-zero loads. Currently, pending updates are wheeled through 
> > decay_load_missed()
> > that assume it's all about idle load.
> > 
> > But in the cases you've enumerated, as well as in the nohz full case, 
> > missed pending
> > updates can be about buzy loads.
> > 
> > I think we need to fix update_cpu_load() to handle that first, or your fix 
> > is
> > going to make things worse.
> 
> Its worse than that, the whole call chain of update_process_times()
> fully assumes a single tick, fixing just the one function deep down to

yes update_process_times() currently assumes a single tick which is not
good. i think this assuming should be removed one by one so that full
NOHZ works completely.

> handle more than 1 tick is ass backwards.

why do you think fixing this funciton to handle more than 1 tick is
assbackwards? i don't think so because there's no dependancy between
this function and any other tick handling functions. that kind of
bugs should be fixed carefully one by one until all is done, though it
could be assbackwards if fixing something effects another tick handling.

> --
> 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: [v3 1/8] devres: add devm_alloc_percpu()

2015-10-01 Thread Scott Wood
On Thu, Sep 24, 2015 at 06:00:12PM +0300, Madalin Bucur wrote:
> Introduce managed counterparts for alloc_percpu() and free_percpu().
> Add devm_alloc_percpu() and devm_free_percpu() into the managed
> interfaces list.
> 
> Signed-off-by: Madalin Bucur 
> Tested-by: Madalin-Cristian Bucur 
> ---
>  Documentation/driver-model/devres.txt |  4 +++
>  drivers/base/devres.c | 64 
> +++
>  include/linux/device.h| 19 +++
>  3 files changed, 87 insertions(+)

Greg KH needs to be CCed on any drivers/base changes.

-Scott
--
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: [V4 PATCH 4/4] x86/apic: Introduce noextnmi boot option

2015-10-01 Thread 河合英宏 / KAWAI,HIDEHIRO
> On Thu, Oct 01, 2015 at 10:24:19AM +, 河合英宏 / KAWAI,HIDEHIRO wrote:
> > But how do we check if the starting kernel is a dump capture kernel?
> 
> How does that first kernel pass info to the capture kernel?

As I described in the previous mail, You just have to add "noextnmi"
to KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump.  Then, "noextnmi"
option is passed to the capture kernel by the action of kexec command.

Cmdline option gives users flexibility.  I'm not sure all users
want to disable external NMIs in the 2nd kernel.

> > I think using cmdline option is the simplest way.
> 
> More often than not, simplest != correct.
> 
> What happens if I pass this option to the first kernel? All of a sudden
> my *first* kernel doesn't get external NMIs.

Yes, your first kernel doesn't get external NMIs, but basically
you don't have to set "noextnmi" option to the first kernel.


Hidehiro Kawai
Hitachi, Ltd. Research & Development Group




[PATCH v4 4/4] irqchip/gic-v3-its: Add handling of PCI requester id.

2015-10-01 Thread David Daney
From: David Daney 

Replace open coded generation PCI/MSI requester id with call to the
new function pci_msi_domain_get_msi_rid() which applies the "msi-map"
to the id value.

Signed-off-by: David Daney 
---
 drivers/irqchip/irq-gic-v3-its-pci-msi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c 
b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
index cf351c6..7bbf64a 100644
--- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
+++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
@@ -42,7 +42,6 @@ static struct irq_chip its_msi_irq_chip = {
 
 struct its_pci_alias {
struct pci_dev  *pdev;
-   u32 dev_id;
u32 count;
 };
 
@@ -60,7 +59,6 @@ static int its_get_pci_alias(struct pci_dev *pdev, u16 alias, 
void *data)
 {
struct its_pci_alias *dev_alias = data;
 
-   dev_alias->dev_id = alias;
if (pdev != dev_alias->pdev)
dev_alias->count += its_pci_msi_vec_count(dev_alias->pdev);
 
@@ -86,7 +84,7 @@ static int its_pci_msi_prepare(struct irq_domain *domain, 
struct device *dev,
pci_for_each_dma_alias(pdev, its_get_pci_alias, _alias);
 
/* ITS specific DeviceID, as the core ITS ignores dev. */
-   info->scratchpad[0].ul = dev_alias.dev_id;
+   info->scratchpad[0].ul = pci_msi_domain_get_msi_rid(domain, pdev);
 
return msi_info->ops->msi_prepare(domain->parent,
  dev, dev_alias.count, info);
-- 
1.9.1

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


[PATCH v4 2/4] of/irq: Add new function of_msi_map_rid()

2015-10-01 Thread David Daney
From: David Daney 

The device tree property "msi-map" specifies how to create the PCI
requester id used in some MSI controllers.  Add a new function
of_msi_map_rid() that finds the msi-map property and applies its
translation to a given requester id.

Reviewed-by: Marc Zyngier 
Acked-by: Rob Herring 
Signed-off-by: David Daney 
---
 drivers/of/irq.c   | 84 ++
 include/linux/of_irq.h |  7 +
 2 files changed, 91 insertions(+)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 55317fa..c90bd4e 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -598,3 +598,87 @@ void of_msi_configure(struct device *dev, struct 
device_node *np)
d = irq_find_host(msi_np);
dev_set_msi_domain(dev, d);
 }
+
+/**
+ * of_msi_map_rid - Map a MSI requester ID for a device.
+ * @dev: device for which the mapping is to be done.
+ * @msi_np: device node of the expected msi controller.
+ * @rid_in: unmapped MSI requester ID for the device.
+ *
+ * Walk up the device hierarchy looking for devices with a "msi-map"
+ * property.  If found, apply the mapping to @rid_in.
+ *
+ * Returns the mapped MSI requester ID.
+ */
+u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in)
+{
+   struct device *parent_dev;
+   struct device_node *msi_controller_node;
+   u32 map_mask, masked_rid, rid_base, msi_base, rid_len, phandle;
+   int msi_map_len;
+   bool matched;
+   u32 rid_out = rid_in;
+   const __be32 *msi_map = NULL;
+
+   /*
+* Walk up the device parent links looking for one with a
+* "msi-map" property.
+*/
+   for (parent_dev = dev; parent_dev; parent_dev = parent_dev->parent) {
+   if (!parent_dev->of_node)
+   continue;
+
+   msi_map = of_get_property(parent_dev->of_node,
+ "msi-map", _map_len);
+   if (!msi_map)
+   continue;
+
+   if (msi_map_len % (4 * sizeof(__be32))) {
+   dev_err(parent_dev, "Error: Bad msi-map length: %d\n",
+   msi_map_len);
+   return rid_out;
+   }
+   /* We have a good parent_dev and msi_map, let's use them. */
+   break;
+   }
+   if (!msi_map)
+   return rid_out;
+
+   /* The default is to select all bits. */
+   map_mask = 0x;
+
+   /*
+* Can be overridden by "msi-map-mask" property.  If
+* of_property_read_u32() fails, the default is used.
+*/
+   of_property_read_u32(parent_dev->of_node, "msi-map-mask", _mask);
+
+   masked_rid = map_mask & rid_in;
+   matched = false;
+   while (!matched && msi_map_len >= 4 * sizeof(__be32)) {
+   rid_base = be32_to_cpup(msi_map + 0);
+   phandle = be32_to_cpup(msi_map + 1);
+   msi_base = be32_to_cpup(msi_map + 2);
+   rid_len = be32_to_cpup(msi_map + 3);
+
+   msi_controller_node = of_find_node_by_phandle(phandle);
+
+   matched = masked_rid >= rid_base &&
+   masked_rid < rid_base + rid_len &&
+   msi_np == msi_controller_node;
+
+   of_node_put(msi_controller_node);
+   msi_map_len -= 4 * sizeof(__be32);
+   msi_map += 4;
+   }
+   if (!matched)
+   return rid_out;
+
+   rid_out = masked_rid + msi_base;
+   dev_dbg(dev,
+   "msi-map at: %s, using mask %08x, rid-base: %08x, msi-base: 
%08x, length: %08x, rid: %08x -> %08x\n",
+   dev_name(parent_dev), map_mask, rid_base, msi_base,
+   rid_len, rid_in, rid_out);
+
+   return rid_out;
+}
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index 4bcbd58..8cd9334 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -75,6 +75,7 @@ static inline int of_irq_to_resource_table(struct device_node 
*dev,
 extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
 extern struct device_node *of_irq_find_parent(struct device_node *child);
 extern void of_msi_configure(struct device *dev, struct device_node *np);
+u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in);
 
 #else /* !CONFIG_OF */
 static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
@@ -87,6 +88,12 @@ static inline void *of_irq_find_parent(struct device_node 
*child)
 {
return NULL;
 }
+
+static inline u32 of_msi_map_rid(struct device *dev,
+struct device_node *msi_np, u32 rid_in)
+{
+   return rid_in;
+}
 #endif /* !CONFIG_OF */
 
 #endif /* __OF_IRQ_H */
-- 
1.9.1

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

  1   2   3   4   5   6   7   8   9   10   >