[PATCH v2 3/3] fpga bridge driver

2014-10-23 Thread atull
From: Alan Tull 

Support for bringing bridges out of reset.  Bridges show up in sysfs
under /sys/class/fpga-bridge and can be enabled/disabled from sysfs
or from the device tree.

Supports enabling the following hps/fpga bridges:
 * fpga2sdram
 * fpga2hps
 * hps2fpga
 * lwhps2fpga

Control from sysfs:
 Enable:
  $ echo 1 > /sys/class/fpga-bridge/fpga2hps/enable

 Disable:
  $ echo 0 > /sys/class/fpga-bridge/fpga2hps/enable

 Check enable/disable status (checks for all bits set):
  $ cat /sys/class/fpga-bridge/fpga2hps/enable
  (will print '0' or '1')

Device tree has an optional property 'init-val'. This property
configures the driver to enable or disable the bridge when instantiated.
If the property does not exist, the driver will leave the bridge in
its current state.

Notes:

The L3 remap register is write-only (!) and reads zeros.  So
doing a 'read, modify, write' operation on that register will
clear the mpuzero bit that was set by u-boot.  So we keep
a cached copy of what we write to it.

The read, write, and command ports on the fpga2sdram bridge can
only be reconfigured if there are no transactions to the sdram
during the reconfiguration.  Currently, this guarantee can only
be made by code running out of onchip ram before Linux is started.
Therefore, this driver only supports enabling and disabling of the
ports that have already been configured.  Since the driver cannot
determine the port configuration in all cases, the device tree
must be populated with masks for all of the ports.

The fpga bridge framework needs be started before the individual
bridge drivers, and the individual bridge drivers need to be
started before any other driver for components on the FPGA.
The earliest the bridge drivers successfully start is during
arch_init().

Signed-off-by: Alan Tull 
Signed-off-by: Matthew Gerlach 
Signed-off-by: Dinh Nguyen 
---
 drivers/misc/Kconfig |3 +-
 drivers/misc/Makefile|1 +
 drivers/misc/fpga-bridge/Kconfig |   20 +++
 drivers/misc/fpga-bridge/Makefile|6 +
 drivers/misc/fpga-bridge/altera-fpga2sdram.c |  236 ++
 drivers/misc/fpga-bridge/altera-hps2fpga.c   |  220 
 drivers/misc/fpga-bridge/fpga-bridge.c   |  230 +
 drivers/misc/fpga-bridge/fpga-bridge.h   |   51 ++
 8 files changed, 766 insertions(+), 1 deletion(-)
 create mode 100644 drivers/misc/fpga-bridge/Kconfig
 create mode 100644 drivers/misc/fpga-bridge/Makefile
 create mode 100644 drivers/misc/fpga-bridge/altera-fpga2sdram.c
 create mode 100644 drivers/misc/fpga-bridge/altera-hps2fpga.c
 create mode 100644 drivers/misc/fpga-bridge/fpga-bridge.c
 create mode 100644 drivers/misc/fpga-bridge/fpga-bridge.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index bbeb451..6792a03 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -527,5 +527,6 @@ source "drivers/misc/vmw_vmci/Kconfig"
 source "drivers/misc/mic/Kconfig"
 source "drivers/misc/genwqe/Kconfig"
 source "drivers/misc/echo/Kconfig"
-source "drivers/misc/cxl/Kconfig"
+source "drivers/misc/fpga-bridge/Kconfig"
+
 endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 7d5c4cd..83dda02 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_C2PORT)  += c2port/
 obj-$(CONFIG_HMC6352)  += hmc6352.o
 obj-y  += eeprom/
 obj-y  += cb710/
+obj-$(CONFIG_FPGA_BRIDGE)  += fpga-bridge/
 obj-$(CONFIG_SPEAR13XX_PCIE_GADGET)+= spear13xx_pcie_gadget.o
 obj-$(CONFIG_VMWARE_BALLOON)   += vmw_balloon.o
 obj-$(CONFIG_ARM_CHARLCD)  += arm-charlcd.o
diff --git a/drivers/misc/fpga-bridge/Kconfig b/drivers/misc/fpga-bridge/Kconfig
new file mode 100644
index 000..725474e
--- /dev/null
+++ b/drivers/misc/fpga-bridge/Kconfig
@@ -0,0 +1,20 @@
+#
+# FPGA bridge manager configuration
+#
+
+menu "FPGA Bridges"
+
+config FPGA_BRIDGE
+   tristate "FPGA Bridge Drivers"
+   depends on OF
+   help
+ Say Y here if you want to support bridges connected between host
+processors and FPGAs or between FPGAs.
+
+config ALTERA_SOCFPGA_BRIDGE
+   tristate "Altera SoCFPGA Bridges"
+   depends on FPGA_BRIDGE
+   help
+ Say Y to enable drivers for FPGA bridges for Altera socfpga
+devices.
+endmenu
diff --git a/drivers/misc/fpga-bridge/Makefile 
b/drivers/misc/fpga-bridge/Makefile
new file mode 100644
index 000..3700f8a
--- /dev/null
+++ b/drivers/misc/fpga-bridge/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the fpga-bridge drivers
+#
+
+obj-$(CONFIG_FPGA_BRIDGE)  += fpga-bridge.o
+obj-$(CONFIG_ALTERA_SOCFPGA_BRIDGE) += altera-fpga2sdram.o altera-hps2fpga.o
\ No newline at end of file
diff --git a/drivers/misc/fpga-bridge/altera-fpga2sdram.c 
b/drivers/misc/fpga-bridge/altera-fpga2sdram.c
new file mode 100644
index 000..9e5765e
--- /dev/null

[PATCH v2 0/3] fpga bridge framework

2014-10-23 Thread atull
From: Alan Tull 

Followup to bridge framework that was posted on 2013/10/3

This is a driver for enabling/disabling the fpga bridges under control
of a sys entry.  It has a common framework and individual drivers for
the various bridges.

This framework uses the reset driver where appropriate.

Alan


Alan Tull (3):
  add sysfs document for fpga bridges
  ARM: dts: socfpga: fpga bridges bindings docs
  fpga bridge driver

 Documentation/ABI/testing/sysfs-class-fpga-bridge  |5 +
 .../bindings/fpga/altera-fpga2sdram-bridge.txt |   57 +
 .../bindings/fpga/altera-hps2fpga-bridge.txt   |   53 +
 drivers/misc/Kconfig   |3 +-
 drivers/misc/Makefile  |1 +
 drivers/misc/fpga-bridge/Kconfig   |   20 ++
 drivers/misc/fpga-bridge/Makefile  |6 +
 drivers/misc/fpga-bridge/altera-fpga2sdram.c   |  236 
 drivers/misc/fpga-bridge/altera-hps2fpga.c |  220 ++
 drivers/misc/fpga-bridge/fpga-bridge.c |  230 +++
 drivers/misc/fpga-bridge/fpga-bridge.h |   51 +
 11 files changed, 881 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-bridge
 create mode 100644 
Documentation/devicetree/bindings/fpga/altera-fpga2sdram-bridge.txt
 create mode 100644 
Documentation/devicetree/bindings/fpga/altera-hps2fpga-bridge.txt
 create mode 100644 drivers/misc/fpga-bridge/Kconfig
 create mode 100644 drivers/misc/fpga-bridge/Makefile
 create mode 100644 drivers/misc/fpga-bridge/altera-fpga2sdram.c
 create mode 100644 drivers/misc/fpga-bridge/altera-hps2fpga.c
 create mode 100644 drivers/misc/fpga-bridge/fpga-bridge.c
 create mode 100644 drivers/misc/fpga-bridge/fpga-bridge.h

-- 
1.7.9.5

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


Re: [PATCH v2 RESEND] perf tools: makes CPUINFO_PROC to array for different kernel version

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Fri, Oct 24, 2014 at 08:26:13AM +0900, Namhyung Kim escreveu:
> On Wed, 22 Oct 2014 15:40:14 +0800, Wang Nan wrote:
> > After kernel 3.7 (commit b4b8f770eb10a1bccaf8aa0ec1956e2dd7ed1e0a),
> > /proc/cpuinfo replaces 'Processor' to 'model name'. This patch makes
> > CPUINFO_PROC to an array and provides two choices for ARM, makes it
> > compatible for different kernel version.

> > v1 -> v2: minor changes as suggested by Namhyung Kim:

> >  - Doesn't pass @h and @evlist to __write_cpudesc;
> >  - Coding style fix.

> > Signed-off-by: Wang Nan 
 
> Acked-by: Namhyung Kim 

So now this will work with older kernels and new ones? Cool, thanks for
working on it, but:

[acme@ssdandy linux]$ patch -p1 < /wb/1.patch 
patching file tools/perf/perf.h
Hunk #1 FAILED at 6.
Hunk #2 FAILED at 15.
Hunk #3 FAILED at 25.
Hunk #4 FAILED at 40.
Hunk #5 FAILED at 74.
Hunk #6 FAILED at 91.
6 out of 6 hunks FAILED -- saving rejects to file tools/perf/perf.h.rej
patching file tools/perf/util/header.c
Hunk #1 succeeded at 579 (offset 29 lines).
Hunk #2 succeeded at 636 (offset 29 lines).
[acme@ssdandy linux]$

[acme@ssdandy linux]$ git log --oneline tools/perf/perf.h | head -10
87c43ee perf tools: Export usage string and option table of perf record
72a128a perf tools: Move callchain config from record_opts to callchain_param
73a31b7 perf tools: Move ACCESS_ONCE from perf.h header
82baa0e perf tools: Move sys_perf_event_open function from perf.h
43599d1 perf tools: Move syscall and arch specific defines from perf.h
2c83bc0 perf tools: Move perf_call_graph_mode enum from perf.h
0776eb5 perf tools: Move sample data structures from perf.h
36446f4 perf tools: Remove PR_TASK_PERF_EVENTS_* from perf.h
273a0a7 perf tools: Remove asmlinkage define from perf.h
1b7ae1c perf tools: Remove min define from perf.h
[acme@ssdandy linux]$

This is:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git perf/core

If you don't have time to fix this up, I'll try to find time tomorrow
and do it.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] pinctrl: rockchip: Set wake_enabled

2014-10-23 Thread Heiko Stübner
Am Donnerstag, 23. Oktober 2014, 09:55:27 schrieb Doug Anderson:
> Heiko,
> 
> On Thu, Oct 23, 2014 at 9:43 AM, Heiko Stübner  wrote:
> > Am Dienstag, 21. Oktober 2014, 10:47:32 schrieb Doug Anderson:
> >> The rockchip pinctrl driver uses irq_gc_set_wake() but doesn't setup
> >> the .wake_enabled member.  That means that we can never actually use a
> >> pin for wakeup.  When "irq_set_irq_wake()" tries to call through it
> >> will always get a failure from set_irq_wake_real() and will then set
> >> wake_depth to 0.  Assuming you can resume you'll later get an error
> >> message about "Unbalanced IRQ x wake disable".
> > 
> > The change itself looks reasonable. But now being able to read the docs
> > for
> > it, it doesn't look like all gpios are able to wake the system.
> > 
> > On the rk3288 it seems to be only the pins from gpio0 that can do this
> > (similar for different banks on the other Rockchip SoCs) - see
> > PMU_WAKEUP_CFG0 and PMU_WAKEUP_CFG1[1].
> > 
> > So I guess we'll need something more eloquent to handle this.
> 
> I think long term we're going to need something more elegant, yes.
> ...but it turns out that as long as you're not in the low, low power
> state that all pins can wake up the system.
> 
> Check out "Table 4-5 Power Domain Status Summary in all Work Mode".
> In Mode 3 (called "sleep") all GPIOs can wake the system up.  This is
> the mode that Chris's current suspend/resume patch uses (actually, it
> doesn't quite get all the way to that mode yet, but that's the
> target).  It would be ideal if we could get to Mode 4 (called
> "poweroff"), but when I talked to Rockchip they were a little hesitant
> about promising that it would work.

You're right ... didn't read far enough it seems, so this patch also

Reviewed-by: Heiko Stuebner 



> NOTE: One unresolved thing with the current series (this series +
> Chris's) is that pretty much any interrupt can wake up the system.
> Even typing on the UART seems to do it.  Somehow we're not masking
> interrupts in a way that prevents this, but I haven't tracked it down
> yet.  I don't think it's related to this patch.

I guess the interrupts that aren't wakeup sources should then get masked when 
going to sleep?




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


Re: [PATCH 2/4] mm: cma: Always consider a 0 base address reservation as dynamic

2014-10-23 Thread Laurent Pinchart
Hi Michal,

On Thursday 23 October 2014 18:55:20 Michal Nazarewicz wrote:
> On Thu, Oct 23 2014, Laurent Pinchart wrote:
> > The fixed parameter to cma_declare_contiguous() tells the function
> > whether the given base address must be honoured or should be considered
> > as a hint only. The API considers a zero base address as meaning any
> > base address, which must never be considered as a fixed value.
> > 
> > Part of the implementation correctly checks both fixed and base != 0,
> > but two locations check the fixed value only. Set fixed to false when
> > base is 0 to fix that and simplify the code.
> > 
> > Signed-off-by: Laurent Pinchart
> > 
> 
> Acked-by: Michal Nazarewicz 
> 
> And like before, this should also probably also go to stable.

v3.17 and older don't have the extra fixed checks, so I don't think there's a 
need to Cc stable.

> > ---
> > 
> >  mm/cma.c | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/mm/cma.c b/mm/cma.c
> > index 16c6650..6b14346 100644
> > --- a/mm/cma.c
> > +++ b/mm/cma.c
> > @@ -239,6 +239,9 @@ int __init cma_declare_contiguous(phys_addr_t base,
> > size = ALIGN(size, alignment);
> > limit &= ~(alignment - 1);
> > 
> > +   if (!base)
> > +   fixed = false;
> > +
> > /* size should be aligned with order_per_bit */
> > if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
> > return -EINVAL;
> > @@ -262,7 +265,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
> > }
> > 
> > /* Reserve memory */
> > -   if (base && fixed) {
> > +   if (fixed) {
> > if (memblock_is_region_reserved(base, size) ||
> > memblock_reserve(base, size) < 0) {
> > ret = -EBUSY;

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 1/2] staging: ion: shrink page-pool by page unit

2014-10-23 Thread Devendra Naga
On Fri, Oct 24, 2014 at 5:01 AM, Gioh Kim  wrote:
>
>
> 2014-10-24 오전 8:16, Gioh Kim 쓴 글:
>
>>
>>
>> 2014-10-24 오전 5:36, Devendra Naga 쓴 글:
>>>
>>> Hello,
>>>
>>> On Thu, Oct 23, 2014 at 6:22 PM, Gioh Kim  wrote:
  sys_heap = container_of(heap, struct ion_system_heap, heap);
 @@ -219,7 +219,10 @@ static int ion_system_heap_shrink(struct ion_heap
 *heap, gfp_t gfp_mask,
  for (i = 0; i < num_orders; i++) {
  struct ion_page_pool *pool = sys_heap->pools[i];

 -   nr_total += ion_page_pool_shrink(pool, gfp_mask,
 nr_to_scan);
 +   nr_freed += ion_page_pool_shrink(pool, gfp_mask,
 nr_to_scan);
>>>
>>>
>>> nr_freed is not initialised to zero. This might result in updating of
>>> a garbage value stored initially after nr_freed is created.
>>
>>
>> Yes, your're right. It's my mistake.
>> I testes this on my platform with custom kernel and copied codes.
>> I missed a line for it.
>> I'm sorry.
>
>
> Following is the correct code:
> nr_freed = ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
>

Thanks that is correct. You can send another patch with this fix (it
can be patchset v2 or rfc v2).

>
>>
>>>
 +   nr_total += nr_freed;
 +   /* nr_to_scan can be negative */
 +   nr_to_scan -= nr_freed;
  }

  return nr_total;
 --
 1.7.9.5

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


Re: [PATCH v3 00/14] Kbuild for perf

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Fri, Oct 24, 2014 at 12:28:08AM +0200, Alexis Berlemont escreveu:
> Hello,
> 
> Here is a proposal of perf's build process managed by Kbuild:
> * The file Makefile.perf is replaced by Makefile.kbuild
> * Makefile.kbuild generates a default .config file if none exists
>   (allyesconfig)
> * Makefile.kbuild adapts the .config file according to the
>   features-check tests results
> * Makefile.kbuild builds external dependencies (linux/tools/lib/*)
> * Makefile.kbuild leaves the rest to Kbuild 
> 
> Regards,

Thanks for working on this!

What was the branch this was made against?
 
> Alexis.
> 
> Alexis Berlemont (11):
>   kbuild: add support of custom paths for "auto.conf*" files
>   perf kbuild: remove Makefile.perf
>   perf kbuild: remove legacy tui/gui-related build variables
>   perf kbuild: remove legacy demangle-related build variables
>   perf kbuild: cross-compilation variables are now handled in Kconfig
>   perf kbuild: remove legacy misc build variables
>   perf kbuild: remove legacy libelf-related build variables
>   perf kbuild: remove legacy libdwarf-related build variables
>   perf kbuild: remove legacy script-related build variables
>   perf kbuild: final cosmetic changes
>   perf kbuild: add generated Kconfig build-test cases
> 
> Jiri Olsa (3):
>   perf tools: Kbuild builtin source related fixies
>   perf tools: Kbuild source related fixies
>   perf tools: Add kbuild support into Makefile.kbuild
> 
>  scripts/Makefile.build |   3 +-
>  scripts/kconfig/confdata.c |  23 +-
>  scripts/kconfig/lkc.h  |   1 +
>  tools/perf/Kbuild  |  47 +
>  tools/perf/Kconfig | 436 ++
>  tools/perf/MANIFEST|   1 +
>  tools/perf/Makefile|   2 +-
>  tools/perf/Makefile.kbuild | 443 ++
>  tools/perf/Makefile.perf   | 949 
> -
>  tools/perf/arch/Kbuild |   3 +
>  tools/perf/arch/arm/Kbuild |   2 +
>  tools/perf/arch/arm/Makefile   |  14 -
>  tools/perf/arch/arm/tests/Kbuild   |   2 +
>  tools/perf/arch/arm/util/Kbuild|   3 +
>  tools/perf/arch/arm64/Kbuild   |   1 +
>  tools/perf/arch/arm64/Makefile |   7 -
>  tools/perf/arch/arm64/util/Kbuild  |   2 +
>  tools/perf/arch/powerpc/Kbuild |   1 +
>  tools/perf/arch/powerpc/Makefile   |   6 -
>  tools/perf/arch/powerpc/util/Kbuild|   3 +
>  tools/perf/arch/s390/Kbuild|   1 +
>  tools/perf/arch/s390/Makefile  |   7 -
>  tools/perf/arch/s390/util/Kbuild   |   2 +
>  tools/perf/arch/sh/Kbuild  |   1 +
>  tools/perf/arch/sh/Makefile|   4 -
>  tools/perf/arch/sh/util/Kbuild |   1 +
>  tools/perf/arch/sparc/Kbuild   |   1 +
>  tools/perf/arch/sparc/Makefile |   4 -
>  tools/perf/arch/sparc/util/Kbuild  |   1 +
>  tools/perf/arch/x86/Kbuild |   2 +
>  tools/perf/arch/x86/Makefile   |  19 -
>  tools/perf/arch/x86/include/perf_regs.h|   8 +-
>  tools/perf/arch/x86/tests/Kbuild   |   3 +
>  tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c |   2 +-
>  tools/perf/arch/x86/tests/regs_load.S  |   3 +-
>  tools/perf/arch/x86/util/Kbuild|   6 +
>  tools/perf/arch/x86/util/unwind-libunwind.c|   5 +-
>  tools/perf/bench/Kbuild|  12 +
>  tools/perf/bench/mem-memcpy-arch.h |   4 +-
>  tools/perf/bench/mem-memcpy.c  |   4 +-
>  tools/perf/bench/mem-memset-arch.h |   4 +-
>  tools/perf/bench/mem-memset.c  |   4 +-
>  tools/perf/builtin-annotate.c  |   8 +-
>  tools/perf/builtin-bench.c |   5 +-
>  tools/perf/builtin-help.c  |   1 +
>  tools/perf/builtin-inject.c|   2 +-
>  tools/perf/builtin-kvm.c   |  38 +-
>  tools/perf/builtin-lock.c  |   5 +-
>  tools/perf/builtin-probe.c |  15 +-
>  tools/perf/builtin-record.c|   4 +-
>  tools/perf/builtin-report.c|   3 +
>  tools/perf/builtin-sched.c |   3 +
>  tools/perf/builtin-script.c|   6 +-
>  tools/perf/builtin-top.c   |  19 +-
>  tools/perf/config/Makefile | 430 +-
>  tools/perf/config/defconfig|  54 ++
>  

Re: [PATCH] x86: Don't allow stackprotector without TSC

2014-10-23 Thread Andy Lutomirski
On 10/23/2014 03:10 PM, Ben Harris wrote:
> On x86, boot_init_stack_canary() unconditionally calls
> __native_read_tsc().  This means that when a kernel with
> CONFIG_CC_STACKPROTECTOR enabled is booted on a CPU without a TSC, the
> kernel hangs at startup.  See  for an
> example.
> 
> To avoid this, make HAVE_CC_STACKPROTECTOR dependent on X86_TSC, which
> is defined iff all supported processors have a TSC.  Setting the minimum
> processor type to one without TSC thus disables the stack protector,
> making the kernel bootable on such processors.

Presumably the actual failure is a #GP when trying to do the rdtsc.  If
so, wouldn't a better fix be to make that rdtsc check cpuid first?  Can
we easily check cpuid that early?

--Andy

> 
> Signed-off-by: Ben Harris 
> 
> ---
> 
> This patch is against v3.18-rc1.
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index f2327e8..5acee0f 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -129,7 +129,6 @@ config X86
>  select RTC_LIB
>  select HAVE_DEBUG_STACKOVERFLOW
>  select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
> -select HAVE_CC_STACKPROTECTOR
>  select GENERIC_CPU_AUTOPROBE
>  select HAVE_ARCH_AUDITSYSCALL
>  select ARCH_SUPPORTS_ATOMIC_RMW
> diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
> index 6983314..9626e47 100644
> --- a/arch/x86/Kconfig.cpu
> +++ b/arch/x86/Kconfig.cpu
> @@ -360,6 +360,7 @@ config X86_P6_NOP
>  config X86_TSC
>  def_bool y
>  depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7
> || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 ||
> M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 ||
> MGEODE_LX || MCORE2 || MATOM) || X86_64
> +select HAVE_CC_STACKPROTECTOR
> 
>  config X86_CMPXCHG64
>  def_bool y
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 00/16] perf tools: Intel PT preparation continued

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Thu, Oct 23, 2014 at 01:45:08PM +0300, Adrian Hunter escreveu:
> Adrian Hunter (16):

Applied these, will test those and put in my next pull req to Ingo:

>   perf pmu: Let pmu's with no events show up on perf list
>   perf tools: Build programs to copy 32-bit compatibility VDSOs
>   perf tools: Add support for 32-bit compatibility VDSOs
>   perf tools: Do not attempt to run perf-read-vdso32 if it wasn't built

The next two are related, made questions about the first:

>   perf tools: Add id index
>   perf session: Add perf_session__deliver_synth_event()

Made some questions about these two as well:

>   perf tools: Add a thread stack for synthesizing call chains
>   perf tools: Enhance the thread stack to output call/return data

These all are about the db_export, if time permits tomorrow I'll try to
do what I suggested and post a patch for you to see, i.e. basically the
first one is the one with the questions.

>   perf tools: Add facility to export data in database-friendly way
>   perf tools: Extend Python script interface to export data in a 
> database-friendly way
>   perf tools: Add Python script to export to postgresql
>   perf tools: Add branch type to db export
>   perf tools: Add branch_type and in_tx to Python export
>   perf tools: Add call information to the database export API
>   perf tools: Add call information to Python export
>   perf tools: Defer export of comms that were not 'set'


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


Re: [PATCH 1/4] mm: cma: Don't crash on allocation if CMA area can't be activated

2014-10-23 Thread Laurent Pinchart
Hi Michal,

On Thursday 23 October 2014 18:53:36 Michal Nazarewicz wrote:
> On Thu, Oct 23 2014, Laurent Pinchart wrote:
> > If activation of the CMA area fails its mutex won't be initialized,
> > leading to an oops at allocation time when trying to lock the mutex. Fix
> > this by failing allocation if the area hasn't been successfully actived,
> > and detect that condition by moving the CMA bitmap allocation after page
> > block reservation completion.
> > 
> > Signed-off-by: Laurent Pinchart
> > 
> 
> Cc:   # v3.17
> Acked-by: Michal Nazarewicz 
> 
> As a matter of fact, this is present in kernels earlier than 3.17 but in
> the 3.17 the code has been moved from drivers/base/dma-contiguous.c to
> mm/cma.c so this might require separate stable patch.  I can track this
> and prepare a patch if you want.

That could be done, but I'm not sure if it's really worth it. The bug only 
occurs when the CMA zone activation fails. I've ran into that case due to a 
bug introduced in v3.18-rc1, but this shouldn't be the case for older kernel 
versions.

If you think the fix should be backported to stable kernels older than v3.17 
please feel free to cook up a patch.

> > ---
> > 
> >  mm/cma.c | 17 ++---
> >  1 file changed, 6 insertions(+), 11 deletions(-)
> > 
> > diff --git a/mm/cma.c b/mm/cma.c
> > index 963bc4a..16c6650 100644
> > --- a/mm/cma.c
> > +++ b/mm/cma.c
> > @@ -93,11 +93,6 @@ static int __init cma_activate_area(struct cma *cma)
> > unsigned i = cma->count >> pageblock_order;
> > struct zone *zone;
> > 
> > -   cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
> > -
> > -   if (!cma->bitmap)
> > -   return -ENOMEM;
> > -
> > WARN_ON_ONCE(!pfn_valid(pfn));
> > zone = page_zone(pfn_to_page(pfn));
> > 
> > @@ -114,17 +109,17 @@ static int __init cma_activate_area(struct cma *cma)
> >  * to be in the same zone.
> >  */
> > if (page_zone(pfn_to_page(pfn)) != zone)
> > -   goto err;
> > +   return -EINVAL;
> > }
> > init_cma_reserved_pageblock(pfn_to_page(base_pfn));
> > } while (--i);
> > 
> > +   cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
> > +   if (!cma->bitmap)
> > +   return -ENOMEM;
> > +
> > mutex_init(>lock);
> > return 0;
> > -
> > -err:
> > -   kfree(cma->bitmap);
> > -   return -EINVAL;
> >  }
> >  
> >  static int __init cma_init_reserved_areas(void)
> > @@ -313,7 +308,7 @@ struct page *cma_alloc(struct cma *cma, int count,
> > unsigned int align)
> > struct page *page = NULL;
> > int ret;
> > 
> > -   if (!cma || !cma->count)
> > +   if (!cma || !cma->count || !cma->bitmap)
> > return NULL;
> > 
> > pr_debug("%s(cma %p, count %d, align %d)\n", __func__, (void *)cma,

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/2] mm: Update generic gup implementation to handle hugepage directory

2014-10-23 Thread Benjamin Herrenschmidt
On Thu, 2014-10-23 at 18:40 -0400, David Miller wrote:
> Hey guys, was looking over the generic GUP while working on a sparc64
> issue and I noticed that you guys do speculative page gets, and after
> talking with Johannes Weiner (CC:'d) about this we don't see how it
> could be necessary.
> 
> If interrupts are disabled during the page table scan (which they
> are), no IPI tlb flushes can arrive.  Therefore any removal from the
> page tables is guarded by interrupts being re-enabled.  And as a
> result, page counts of pages we see in the page tables must always
> have a count > 0.
> 
> x86 does direct atomic_add() on >_count because of this
> invariant and I would rather see the generic version do this too.

This is of course only true of archs who use IPIs for TLB flushes, so if
we are going down the path of not being speculative, powerpc would have
to go back to doing its own since our broadcast TLB flush means we
aren't protected (we are only protected vs. the page tables themselves
being freed since we do that via sched RCU).

AFAIK, ARM also broadcasts TLB flushes...

Another option would be to make the generic code use something defined
by the arch to decide whether to use speculative get or
not. I like the idea of keeping the bulk of that code generic...

Cheers,
Ben.

> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org;> em...@kvack.org 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: getaddrinfo slowdown in 3.17.1, due to getifaddrs

2014-10-23 Thread Steinar H. Gunderson
On Tue, Oct 21, 2014 at 02:31:44PM +0100, Thomas Graf wrote:
> I'm currently testing the patch below and will submit with proper
> tested by attributions later today.

We applied this patch in a reboot today (on top of 3.17.1), and so far,
things seem to be going much better.

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


Re: [PATCHSET 0/5] perf tools: Speed up dwarf callchain post-unwinding for libunwind (v4)

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Wed, Oct 22, 2014 at 10:34:27AM +0900, Namhyung Kim escreveu:
> Hi Arnaldo,
> 
> On Wed, 15 Oct 2014 17:06:30 -0300, Arnaldo Carvalho de Melo wrote:
> > Next time please run: (I'm fixing this up this time)
> >
> > [acme@zoo linux]$ time make -C tools/perf build-test
> ...
> > In file included from util/machine.c:14:0:
> > util/unwind.h: In function ‘unwind__prepare_access’:
> > util/unwind.h:47:57: error: unused parameter ‘thread’
> > [-Werror=unused-parameter]
> >  static inline int unwind__prepare_access(struct thread *thread)
> >  ^
> > util/unwind.h: In function ‘unwind__finish_access’:
> > util/unwind.h:52:57: error: unused parameter ‘thread’
> > [-Werror=unused-parameter]
> >  static inline void unwind__finish_access(struct thread *thread) {}
> >  ^
> > cc1: all warnings being treated as errors
> > make[3]: *** [util/machine.o] Error 1
> > make[3]: *** Waiting for unfinished jobs
> > make[2]: *** [all] Error 2
> >   test: test -x ./perf
> > make[1]: *** [make_no_libelf] Error 1
> > make: *** [build-test] Error 2
> > make: Leaving directory `/home/git/linux/tools/perf'
> 
> So it seems you didn't include the patch 3/5 which is the key of this
> series..  Could you please check it again?

Yeah, I'm adding it now, and in this case as well the __maybe_unused was
missing, added.

I'll push later and will drop you a note, so that you can, please, check
if the end result is sane.

Sorry for the slip up,

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 1/2] staging: ion: shrink page-pool by page unit

2014-10-23 Thread Gioh Kim



2014-10-24 오전 8:16, Gioh Kim 쓴 글:



2014-10-24 오전 5:36, Devendra Naga 쓴 글:

Hello,

On Thu, Oct 23, 2014 at 6:22 PM, Gioh Kim  wrote:

This patch shrink page-pool by page unit.

Signed-off-by: Gioh Kim 
---
  drivers/staging/android/ion/ion_page_pool.c   |5 +++--
  drivers/staging/android/ion/ion_system_heap.c |7 +--
  2 files changed, 8 insertions(+), 4 deletions(-)






--- cut --


diff --git a/drivers/staging/android/ion/ion_system_heap.c 
b/drivers/staging/android/ion/ion_system_heap.c
index da2a63c..36e73c3 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -211,7 +211,7 @@ static int ion_system_heap_shrink(struct ion_heap *heap, 
gfp_t gfp_mask,
 int nr_to_scan)
  {
 struct ion_system_heap *sys_heap;
-   int nr_total = 0;
+   int nr_total = 0, nr_freed;
 int i;

 sys_heap = container_of(heap, struct ion_system_heap, heap);
@@ -219,7 +219,10 @@ static int ion_system_heap_shrink(struct ion_heap *heap, 
gfp_t gfp_mask,
 for (i = 0; i < num_orders; i++) {
 struct ion_page_pool *pool = sys_heap->pools[i];

-   nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
+   nr_freed += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);


nr_freed is not initialised to zero. This might result in updating of
a garbage value stored initially after nr_freed is created.


Yes, your're right. It's my mistake.
I testes this on my platform with custom kernel and copied codes.
I missed a line for it.
I'm sorry.


Following is the correct code:
nr_freed = ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);






+   nr_total += nr_freed;
+   /* nr_to_scan can be negative */
+   nr_to_scan -= nr_freed;
 }

 return nr_total;
--
1.7.9.5

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



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


mmotm 2014-10-23-16-26 uploaded

2014-10-23 Thread akpm
The mm-of-the-moment snapshot 2014-10-23-16-26 has been uploaded to

   http://www.ozlabs.org/~akpm/mmotm/

mmotm-readme.txt says

README for mm-of-the-moment:

http://www.ozlabs.org/~akpm/mmotm/

This is a snapshot of my -mm patch queue.  Uploaded at random hopefully
more than once a week.

You will need quilt to apply these patches to the latest Linus release (3.x
or 3.x-rcY).  The series file is in broken-out.tar.gz and is duplicated in
http://ozlabs.org/~akpm/mmotm/series

The file broken-out.tar.gz contains two datestamp files: .DATE and
.DATE--mm-dd-hh-mm-ss.  Both contain the string -mm-dd-hh-mm-ss,
followed by the base kernel version against which this patch series is to
be applied.

This tree is partially included in linux-next.  To see which patches are
included in linux-next, consult the `series' file.  Only the patches
within the #NEXT_PATCHES_START/#NEXT_PATCHES_END markers are included in
linux-next.

A git tree which contains the memory management portion of this tree is
maintained at git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git
by Michal Hocko.  It contains the patches which are between the
"#NEXT_PATCHES_START mm" and "#NEXT_PATCHES_END" markers, from the series
file, http://www.ozlabs.org/~akpm/mmotm/series.


A full copy of the full kernel tree with the linux-next and mmotm patches
already applied is available through git within an hour of the mmotm
release.  Individual mmotm releases are tagged.  The master branch always
points to the latest release, so it's constantly rebasing.

http://git.cmpxchg.org/?p=linux-mmotm.git;a=summary

To develop on top of mmotm git:

  $ git remote add mmotm 
git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git
  $ git remote update mmotm
  $ git checkout -b topic mmotm/master
  
  $ git send-email mmotm/master.. [...]

To rebase a branch with older patches to a new mmotm release:

  $ git remote update mmotm
  $ git rebase --onto mmotm/master  topic




The directory http://www.ozlabs.org/~akpm/mmots/ (mm-of-the-second)
contains daily snapshots of the -mm tree.  It is updated more frequently
than mmotm, and is untested.

A git copy of this tree is available at

http://git.cmpxchg.org/?p=linux-mmots.git;a=summary

and use of this tree is similar to
http://git.cmpxchg.org/?p=linux-mmotm.git, described above.


This mmotm tree contains the following patches against 3.18-rc1:
(patches marked "*" will be included in linux-next)

  origin.patch
  i-need-old-gcc.patch
  arch-alpha-kernel-systblss-remove-debug-check.patch
* cgroup-kmemleak-add-kmemleak_free-for-cgroup-deallocations.patch
* mm-compaction-avoid-premature-range-skip-in-isolate_migratepages_range.patch
* fsnotify-next_i-is-freed-during-fsnotify_unmount_inodes.patch
* gcov-add-arm64-to-gcov_profile_all.patch
* mm-free-compound-page-with-correct-order.patch
* drivers-of-add-return-value-to-of_reserved_mem_device_init.patch
* mm-thp-fix-collapsing-of-hugepages-on-madvise.patch
* rtc-pm8xxx-rework-to-support-pm8941-rtc.patch
* rtc-pm8xxx-rework-to-support-pm8941-rtc-checkpatch-fixes.patch
* rtc-pm8xxx-rework-to-support-pm8941-rtc-fix.patch
* kernel-kmod-fix-use-after-free-of-the-sub_info-structure.patch
* kernel-kmod-fix-use-after-free-of-the-sub_info-structure-v2.patch
* drivers-rtc-fix-s3c-rtc-initialization-failure-without-rtc-source-clock.patch
* 
memory-hotplug-clear-pgdat-which-is-allocated-by-bootmem-in-try_offline_node.patch
* 
memory-hotplug-clear-pgdat-which-is-allocated-by-bootmem-in-try_offline_node-v2.patch
* rtc-bq3000-fix-register-value.patch
* bitmap-fix-undefined-shift-in-__bitmap_shift_leftright.patch
* mm-page-writeback-inline-account_page_dirtied-into-single-caller.patch
* mm-memcontrol-fix-missed-end-writeback-page-accounting.patch
* mm-memcontrol-fix-missed-end-writeback-page-accounting-fix.patch
* mm-rmap-split-out-page_remove_file_rmap.patch
* ocfs2-fix-d_splice_alias-return-code-checking.patch
* mm-slab_common-dont-check-for-duplicate-cache-names.patch
* mm-cma-make-kmemleak-ignore-cma-regions.patch
* mm-cma-make-kmemleak-ignore-cma-regions-fix.patch
* mm-cma-make-kmemleak-ignore-cma-regions-fix-fix.patch
* fs-cifs-remove-obsolete-__constant.patch
* fs-cifs-filec-replace-countsize-kzalloc-by-kcalloc.patch
* fs-cifs-smb2filec-replace-countsize-kzalloc-by-kcalloc.patch
* fallocate-create-fan_modify-and-in_modify-events.patch
* kernel-posix-timersc-code-clean-up.patch
* kernel-posix-timersc-code-clean-up-checkpatch-fixes.patch
* input-route-kbd-leds-through-the-generic-leds-layer.patch
* input-route-kbd-leds-through-the-generic-leds-layer-fix.patch
* input-route-kbd-leds-through-the-generic-leds-layer-fix-2.patch
* fs-ext4-fsyncc-generic_file_fsync-call-based-on-barrier-flag.patch
* 
ocfs2-dlm-let-sender-retry-if-dlm_dispatch_assert_master-failed-with-enomem.patch
* ocfs2-fix-an-off-by-one-bug_on-statement.patch
* ocfs2-fix-xattr-check-in-ocfs2_get_xattr_nolock.patch
* ocfs2-remove-bogus-test-from-ocfs2_read_locked_inode.patch
* 

Re: [PATCH v4 1/6] sched/fair: Fix reschedule which is generated on throttled cfs_rq

2014-10-23 Thread Wanpeng Li

Hi Kirill,
8/6/14, 4:06 PM, Kirill Tkhai:

(sched_entity::on_rq == 1) does not guarantee the task is pickable;
changes on throttled cfs_rq must not lead to reschedule.


Why (sched_entity::on_rq == 1) doesn't guarantee the task is pickable 
since entity will be dequeued during throttling cfs_rq?




Check for task_struct::on_rq instead.


Do you mean task_struct::on_rq will be cleared during throttling cfs_rq? 
I can't find codes do this.


Regards,
Wanpeng Li



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

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bfa3c86..6f0ce2b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7465,7 +7465,7 @@ static void task_fork_fair(struct task_struct *p)
  static void
  prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio)
  {
-   if (!p->se.on_rq)
+   if (!p->on_rq)
return;
  
  	/*

@@ -7521,15 +7521,15 @@ static void switched_from_fair(struct rq *rq, struct 
task_struct *p)
   */
  static void switched_to_fair(struct rq *rq, struct task_struct *p)
  {
-   struct sched_entity *se = >se;
  #ifdef CONFIG_FAIR_GROUP_SCHED
+   struct sched_entity *se = >se;
/*
 * Since the real-depth could have been changed (only FAIR
 * class maintain depth value), reset depth properly.
 */
se->depth = se->parent ? se->parent->depth + 1 : 0;
  #endif
-   if (!se->on_rq)
+   if (!p->on_rq)
return;
  
  	/*




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


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


Re: [PATCH v2 RESEND] perf tools: makes CPUINFO_PROC to array for different kernel version

2014-10-23 Thread Namhyung Kim
On Wed, 22 Oct 2014 15:40:14 +0800, Wang Nan wrote:
> After kernel 3.7 (commit b4b8f770eb10a1bccaf8aa0ec1956e2dd7ed1e0a),
> /proc/cpuinfo replaces 'Processor' to 'model name'. This patch makes
> CPUINFO_PROC to an array and provides two choices for ARM, makes it
> compatible for different kernel version.
>
> v1 -> v2: minor changes as suggested by Namhyung Kim:
>
>  - Doesn't pass @h and @evlist to __write_cpudesc;
>  - Coding style fix.
>
> Signed-off-by: Wang Nan 

Acked-by: Namhyung Kim 

Thanks,
Namhyung


> ---
>  tools/perf/perf.h| 24 
>  tools/perf/util/header.c | 27 +--
>  2 files changed, 33 insertions(+), 18 deletions(-)
>
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index 32bd102..1a23392 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -6,7 +6,7 @@
>  #if defined(__i386__)
>  #define rmb()asm volatile("lock; addl $0,0(%%esp)" ::: 
> "memory")
>  #define cpu_relax()  asm volatile("rep; nop" ::: "memory");
> -#define CPUINFO_PROC "model name"
> +#define CPUINFO_PROC {"model name"}
>  #ifndef __NR_perf_event_open
>  # define __NR_perf_event_open 336
>  #endif
> @@ -15,7 +15,7 @@
>  #if defined(__x86_64__)
>  #define rmb()asm volatile("lfence" ::: "memory")
>  #define cpu_relax()  asm volatile("rep; nop" ::: "memory");
> -#define CPUINFO_PROC "model name"
> +#define CPUINFO_PROC {"model name"}
>  #ifndef __NR_perf_event_open
>  # define __NR_perf_event_open 298
>  #endif
> @@ -25,7 +25,7 @@
>  #include "../../arch/powerpc/include/uapi/asm/unistd.h"
>  #define rmb()asm volatile ("sync" ::: "memory")
>  #define cpu_relax()  asm volatile ("" ::: "memory");
> -#define CPUINFO_PROC "cpu"
> +#define CPUINFO_PROC {"cpu"}
>  #endif
>  
>  #ifdef __s390__
> @@ -40,31 +40,31 @@
>  # define rmb()   asm volatile("" ::: "memory")
>  #endif
>  #define cpu_relax()  asm volatile("" ::: "memory")
> -#define CPUINFO_PROC "cpu type"
> +#define CPUINFO_PROC {"cpu type"}
>  #endif
>  
>  #ifdef __hppa__
>  #define rmb()asm volatile("" ::: "memory")
>  #define cpu_relax()  asm volatile("" ::: "memory");
> -#define CPUINFO_PROC "cpu"
> +#define CPUINFO_PROC {"cpu"}
>  #endif
>  
>  #ifdef __sparc__
>  #define rmb()asm volatile("":::"memory")
>  #define cpu_relax()  asm volatile("":::"memory")
> -#define CPUINFO_PROC "cpu"
> +#define CPUINFO_PROC {"cpu"}
>  #endif
>  
>  #ifdef __alpha__
>  #define rmb()asm volatile("mb" ::: "memory")
>  #define cpu_relax()  asm volatile("" ::: "memory")
> -#define CPUINFO_PROC "cpu model"
> +#define CPUINFO_PROC {"cpu model"}
>  #endif
>  
>  #ifdef __ia64__
>  #define rmb()asm volatile ("mf" ::: "memory")
>  #define cpu_relax()  asm volatile ("hint @pause" ::: "memory")
> -#define CPUINFO_PROC "model name"
> +#define CPUINFO_PROC {"model name"}
>  #endif
>  
>  #ifdef __arm__
> @@ -74,7 +74,7 @@
>   */
>  #define rmb()((void(*)(void))0x0fa0)()
>  #define cpu_relax()  asm volatile("":::"memory")
> -#define CPUINFO_PROC "Processor"
> +#define CPUINFO_PROC {"model name", "Processor"}
>  #endif
>  
>  #ifdef __aarch64__
> @@ -91,19 +91,19 @@
>   : /* no input */\
>   : "memory")
>  #define cpu_relax()  asm volatile("" ::: "memory")
> -#define CPUINFO_PROC "cpu model"
> +#define CPUINFO_PROC {"cpu model"}
>  #endif
>  
>  #ifdef __arc__
>  #define rmb()asm volatile("" ::: "memory")
>  #define cpu_relax()  rmb()
> -#define CPUINFO_PROC "Processor"
> +#define CPUINFO_PROC {"Processor"}
>  #endif
>  
>  #ifdef __metag__
>  #define rmb()asm volatile("" ::: "memory")
>  #define cpu_relax()  asm volatile("" ::: "memory")
> -#define CPUINFO_PROC "CPU"
> +#define CPUINFO_PROC {"CPU"}
>  #endif
>  
>  #include 
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index b59350f..d48f571 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -550,16 +550,12 @@ static int write_version(int fd, struct perf_header *h 
> __maybe_unused,
>   return do_write_string(fd, perf_version_string);
>  }
>  
> -static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,
> -struct perf_evlist *evlist __maybe_unused)
> +static int __write_cpudesc(int fd, const char *cpuinfo_proc)
>  {
> -#ifndef CPUINFO_PROC
> -#define CPUINFO_PROC NULL
> -#endif
>   FILE *file;
>   char *buf = NULL;
>   char *s, *p;
> - const char *search = CPUINFO_PROC;
> + const char *search = cpuinfo_proc;
>   size_t len = 0;
>   int ret = -1;
>  
> @@ -611,6 +607,25 @@ done:
>   return ret;
>  }
>  
> +static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,
> +struct perf_evlist *evlist __maybe_unused)
> +{
> +#ifndef CPUINFO_PROC
> +#define CPUINFO_PROC {"model name", }
> 

[GIT PULL] overlay filesystem v25

2014-10-23 Thread Miklos Szeredi
Linus,

Please pull

  git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git overlayfs.v25

Plenty of bugs fixed relative to the previous version, thanks to Al Viro's
review and is now officially be BugFree(TM).  Also passes the
unionmount-testsuite by David Howells.

Thanks,
Miklos

---
Andy Whitcroft (1):
  overlayfs: add statfs support

Erez Zadok (1):
  overlayfs: implement show_options

Miklos Szeredi (11):
  vfs: add i_op->dentry_open()
  vfs: export do_splice_direct() to modules
  vfs: export __inode_permission() to modules
  vfs: introduce clone_private_mount()
  vfs: export check_sticky()
  vfs: add whiteout support
  vfs: add RENAME_WHITEOUT
  ext4: support RENAME_WHITEOUT
  shmem: support RENAME_WHITEOUT
  overlay filesystem
  fs: limit filesystem stacking depth

Neil Brown (1):
  overlay: overlay filesystem documentation

---
 Documentation/filesystems/Locking   |   2 +
 Documentation/filesystems/overlayfs.txt | 198 +++
 Documentation/filesystems/vfs.txt   |   7 +
 MAINTAINERS |   7 +
 fs/Kconfig  |   1 +
 fs/Makefile |   1 +
 fs/btrfs/ioctl.c|  20 +-
 fs/ecryptfs/main.c  |   7 +
 fs/ext4/namei.c |  95 +++-
 fs/internal.h   |   7 -
 fs/namei.c  |  41 +-
 fs/namespace.c  |  27 +
 fs/open.c   |  23 +-
 fs/overlayfs/Kconfig|  10 +
 fs/overlayfs/Makefile   |   7 +
 fs/overlayfs/copy_up.c  | 414 ++
 fs/overlayfs/dir.c  | 921 
 fs/overlayfs/inode.c| 425 +++
 fs/overlayfs/overlayfs.h| 191 +++
 fs/overlayfs/readdir.c  | 587 
 fs/overlayfs/super.c| 796 +++
 fs/splice.c |   1 +
 include/linux/fs.h  |  39 ++
 include/linux/mount.h   |   3 +
 include/uapi/linux/fs.h |   1 +
 mm/shmem.c  |  36 +-
 26 files changed, 3809 insertions(+), 58 deletions(-)
 create mode 100644 Documentation/filesystems/overlayfs.txt
 create mode 100644 fs/overlayfs/Kconfig
 create mode 100644 fs/overlayfs/Makefile
 create mode 100644 fs/overlayfs/copy_up.c
 create mode 100644 fs/overlayfs/dir.c
 create mode 100644 fs/overlayfs/inode.c
 create mode 100644 fs/overlayfs/overlayfs.h
 create mode 100644 fs/overlayfs/readdir.c
 create mode 100644 fs/overlayfs/super.c

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


Re: [RFC 1/2] staging: ion: shrink page-pool by page unit

2014-10-23 Thread Gioh Kim



2014-10-24 오전 5:36, Devendra Naga 쓴 글:

Hello,

On Thu, Oct 23, 2014 at 6:22 PM, Gioh Kim  wrote:

This patch shrink page-pool by page unit.

Signed-off-by: Gioh Kim 
---
  drivers/staging/android/ion/ion_page_pool.c   |5 +++--
  drivers/staging/android/ion/ion_system_heap.c |7 +--
  2 files changed, 8 insertions(+), 4 deletions(-)






--- cut --


diff --git a/drivers/staging/android/ion/ion_system_heap.c 
b/drivers/staging/android/ion/ion_system_heap.c
index da2a63c..36e73c3 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -211,7 +211,7 @@ static int ion_system_heap_shrink(struct ion_heap *heap, 
gfp_t gfp_mask,
 int nr_to_scan)
  {
 struct ion_system_heap *sys_heap;
-   int nr_total = 0;
+   int nr_total = 0, nr_freed;
 int i;

 sys_heap = container_of(heap, struct ion_system_heap, heap);
@@ -219,7 +219,10 @@ static int ion_system_heap_shrink(struct ion_heap *heap, 
gfp_t gfp_mask,
 for (i = 0; i < num_orders; i++) {
 struct ion_page_pool *pool = sys_heap->pools[i];

-   nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
+   nr_freed += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);


nr_freed is not initialised to zero. This might result in updating of
a garbage value stored initially after nr_freed is created.


Yes, your're right. It's my mistake.
I testes this on my platform with custom kernel and copied codes.
I missed a line for it.
I'm sorry.




+   nr_total += nr_freed;
+   /* nr_to_scan can be negative */
+   nr_to_scan -= nr_freed;
 }

 return nr_total;
--
1.7.9.5

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



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 0/9] mm/zbud: support highmem pages

2014-10-23 Thread Dan Streetman
On Tue, Oct 14, 2014 at 7:59 AM, Heesub Shin  wrote:
> zbud is a memory allocator for storing compressed data pages. It keeps
> two data objects of arbitrary size on a single page. This simple design
> provides very deterministic behavior on reclamation, which is one of
> reasons why zswap selected zbud as a default allocator over zsmalloc.
>
> Unlike zsmalloc, however, zbud does not support highmem. This is
> problomatic especially on 32-bit machines having relatively small
> lowmem. Compressing anonymous pages from highmem and storing them into
> lowmem could eat up lowmem spaces.
>
> This limitation is due to the fact that zbud manages its internal data
> structures on zbud_header which is kept in the head of zbud_page. For
> example, zbud_pages are tracked by several lists and have some status
> information, which are being referenced at any time by the kernel. Thus,
> zbud_pages should be allocated on a memory region directly mapped,
> lowmem.
>
> After some digging out, I found that internal data structures of zbud
> can be kept in the struct page, the same way as zsmalloc does. So, this
> series moves out all fields in zbud_header to struct page. Though it
> alters quite a lot, it does not add any functional differences except
> highmem support. I am afraid that this kind of modification abusing
> several fields in struct page would be ok.

Seth, have you had a chance to review this yet?  I'm going to try to
take a look at it next week if you haven't yet.  Letting zbud use
highmem would be a good thing.


>
> Heesub Shin (9):
>   mm/zbud: tidy up a bit
>   mm/zbud: remove buddied list from zbud_pool
>   mm/zbud: remove lru from zbud_header
>   mm/zbud: remove first|last_chunks from zbud_header
>   mm/zbud: encode zbud handle using struct page
>   mm/zbud: remove list_head for buddied list from zbud_header
>   mm/zbud: drop zbud_header
>   mm/zbud: allow clients to use highmem pages
>   mm/zswap: use highmem pages for compressed pool
>
>  mm/zbud.c  | 244 
> ++---
>  mm/zswap.c |   4 +-
>  2 files changed, 121 insertions(+), 127 deletions(-)
>
> --
> 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: [PATCH v2 2/3] sched/dl: Cleanup prio_changed_dl()

2014-10-23 Thread Wanpeng Li

10/22/14, 12:24 AM, Juri Lelli:

Hi Kirill,

On 02/10/14 10:52, Kirill Tkhai wrote:

В Чт, 02/10/2014 в 11:36 +0200, Peter Zijlstra пишет:

On Wed, Oct 01, 2014 at 01:04:35AM +0400, Kirill Tkhai wrote:

From: Kirill Tkhai 

rq->curr task can't be in "dequeued" state in prio_changed_dl().
(The only place we can have that is __schedule()). So, we delete
rq->curr check.

the CBS timer can throttle it right?

Yeah, it's better to check for on_dl_rq():

[PATCH]sched/dl: Cleanup prio_changed_dl()
 
rq->curr task can't be in "dequeued" state in prio_changed_dl().

(The only place we can have that is __schedule()). So, we delete
rq->curr check.

We shouldn't do balancing if deadline task is throttled too.

Also delete "else" branch which is dead code (switched_to_dl()
is not interested in dequeued tasks and we are not interested
in balancing in this case).


So, I agree that calling switched_to_dl() makes little sense,
but don't we have to deal with updates to not running tasks as
in rt.c? Something like this maybe?

 From 75ee75a5fd76526baaed3ba8a58f3ff7daa89cd6 Mon Sep 17 00:00:00 2001
From: Juri Lelli 
Date: Tue, 21 Oct 2014 17:15:15 +0100
Subject: [PATCH] sched/deadline: cleanup prio_changed_dl()

---
  kernel/sched/deadline.c | 16 +---
  1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 28d6088..1e62e31 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1661,7 +1661,10 @@ static void switched_to_dl(struct rq *rq, struct 
task_struct *p)
  static void prio_changed_dl(struct rq *rq, struct task_struct *p,
int oldprio)
  {
-   if (task_on_rq_queued(p) || rq->curr == p) {
+   if (!on_dl_rq(>dl))


I'm not sure if this should be task_on_rq_queued() check. All 
check_class_changed() callsites dequeue entity if task_on_rq_queued() is 
true which leads to on_dl_rq(>dl) always return false.


Regards,
Wanpeng Li


+   return;
+
+   if (rq->curr == p) {
  #ifdef CONFIG_SMP
/*
 * This might be too much, but unfortunately
@@ -1688,8 +1691,15 @@ static void prio_changed_dl(struct rq *rq, struct 
task_struct *p,
 */
resched_curr(rq);
  #endif /* CONFIG_SMP */
-   } else
-   switched_to_dl(rq, p);
+   } else {
+   /*
+* This task is not running, so if its deadline is
+* now more imminent than that of the current running
+* task then reschedule.
+*/
+   if (dl_time_before(p->dl.deadline, rq->curr->dl.deadline))
+   resched_curr(rq);
+   }
  }
  
  const struct sched_class dl_sched_class = {


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/2] mm: Update generic gup implementation to handle hugepage directory

2014-10-23 Thread David Miller

Hey guys, was looking over the generic GUP while working on a sparc64
issue and I noticed that you guys do speculative page gets, and after
talking with Johannes Weiner (CC:'d) about this we don't see how it
could be necessary.

If interrupts are disabled during the page table scan (which they
are), no IPI tlb flushes can arrive.  Therefore any removal from the
page tables is guarded by interrupts being re-enabled.  And as a
result, page counts of pages we see in the page tables must always
have a count > 0.

x86 does direct atomic_add() on >_count because of this
invariant and I would rather see the generic version do this too.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 08/14] perf kbuild: cross-compilation variables are now handled in Kconfig

2014-10-23 Thread Alexis Berlemont
The variable CONFIG_ARCH and CONFIG_CROSS_COMPILE were added.

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig  | 24 
 tools/perf/Makefile.kbuild  |  8 
 tools/perf/arch/x86/include/perf_regs.h |  8 +---
 tools/perf/arch/x86/tests/regs_load.S   |  3 ++-
 tools/perf/arch/x86/util/unwind-libunwind.c |  5 +++--
 tools/perf/bench/mem-memcpy-arch.h  |  4 +++-
 tools/perf/bench/mem-memcpy.c   |  4 +++-
 tools/perf/bench/mem-memset-arch.h  |  4 +++-
 tools/perf/bench/mem-memset.c   |  4 +++-
 tools/perf/config/Makefile  |  7 ++-
 10 files changed, 52 insertions(+), 19 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 026ef67..5f85923 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -1,6 +1,30 @@
 
 mainmenu "The perf configuration"
 
+config TARGET_ARCH
+   string
+   option env="ARCH"
+
+config TARGET_IS_X86_64
+   string
+   option env="IS_X86_64"
+
+config TARGET_CROSS_COMPILE
+   string
+   option env="CROSS_COMPILE"
+
+config ARCH
+   string
+   default TARGET_ARCH
+
+config X86_64
+   bool
+   default y if TARGET_ARCH = "x86" && TARGET_IS_X86_64 = "1"
+
+config CROSS_COMPILE
+   string
+   default TARGET_CROSS_COMPILE
+
 menu "Built-in commands"
 
 config BUILTIN_RECORD
diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild
index 8d9e8b0..b48fe7f 100644
--- a/tools/perf/Makefile.kbuild
+++ b/tools/perf/Makefile.kbuild
@@ -123,9 +123,12 @@ export KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG KCONFIG_SCRIPT
 
 # perf detected config
 CONFIG_DETECTED := $(obj-perf)/.config-detected
-
 export CONFIG_DETECTED
 
+# arch-related main variables
+include $(src-perf)/config/Makefile.arch
+export ARCH IS_X86_64 CROSS_COMPILE
+
 # external .a libs
 LIBTRACEEVENT   := $(obj-kernel)/tools/lib/traceevent/libtraceevent.a
 LIBAPIKFS   := $(obj-kernel)/tools/lib/api/libapikfs.a
@@ -202,9 +205,6 @@ ifndef dont-detect
 ifdef CONFIG_DETECTED_STORED
 # Following variables are needed within Kbuild files, we need
 # to export them as they are not part of the .config set.
-export CONFIG_ARCH := $(ARCH)
-export CROSS_COMPILE
-export CONFIG_X86_64
 export htmldir_SQ
 export infodir_SQ
 export mandir_SQ
diff --git a/tools/perf/arch/x86/include/perf_regs.h 
b/tools/perf/arch/x86/include/perf_regs.h
index 7df517a..d969cca 100644
--- a/tools/perf/arch/x86/include/perf_regs.h
+++ b/tools/perf/arch/x86/include/perf_regs.h
@@ -5,9 +5,11 @@
 #include 
 #include 
 
+#include "generated/autoconf.h"
+
 void perf_regs_load(u64 *regs);
 
-#ifndef HAVE_ARCH_X86_64_SUPPORT
+#ifndef CONFIG_X86_64
 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)
 #define PERF_REGS_MAX PERF_REG_X86_32_MAX
 #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32
@@ -58,7 +60,7 @@ static inline const char *perf_reg_name(int id)
return "FS";
case PERF_REG_X86_GS:
return "GS";
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef CONFIG_X86_64
case PERF_REG_X86_R8:
return "R8";
case PERF_REG_X86_R9:
@@ -75,7 +77,7 @@ static inline const char *perf_reg_name(int id)
return "R14";
case PERF_REG_X86_R15:
return "R15";
-#endif /* HAVE_ARCH_X86_64_SUPPORT */
+#endif /* CONFIG_X86_64 */
default:
return NULL;
}
diff --git a/tools/perf/arch/x86/tests/regs_load.S 
b/tools/perf/arch/x86/tests/regs_load.S
index 60875d5..822a797 100644
--- a/tools/perf/arch/x86/tests/regs_load.S
+++ b/tools/perf/arch/x86/tests/regs_load.S
@@ -1,4 +1,5 @@
 #include 
+#include "generated/autoconf.h"
 
 #define AX  0
 #define BX  1 * 8
@@ -26,7 +27,7 @@
 #define R1523 * 8
 
 .text
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef CONFIG_X86_64
 ENTRY(perf_regs_load)
movq %rax, AX(%rdi)
movq %rbx, BX(%rdi)
diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c 
b/tools/perf/arch/x86/util/unwind-libunwind.c
index db25e93..e4960c1 100644
--- a/tools/perf/arch/x86/util/unwind-libunwind.c
+++ b/tools/perf/arch/x86/util/unwind-libunwind.c
@@ -1,11 +1,12 @@
 
 #include 
 #include 
+#include "generated/autoconf.h"
 #include "perf_regs.h"
 #include "../../util/unwind.h"
 #include "../../util/debug.h"
 
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef CONFIG_X86_64
 int libunwind__arch_reg_id(int regnum)
 {
int id;
@@ -109,4 +110,4 @@ int libunwind__arch_reg_id(int regnum)
 
return id;
 }
-#endif /* HAVE_ARCH_X86_64_SUPPORT */
+#endif /* CONFIG_X86_64 */
diff --git a/tools/perf/bench/mem-memcpy-arch.h 
b/tools/perf/bench/mem-memcpy-arch.h
index 57b4ed8..8e3f0a9 100644
--- a/tools/perf/bench/mem-memcpy-arch.h
+++ b/tools/perf/bench/mem-memcpy-arch.h
@@ -1,5 +1,7 @@
 
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#include "generated/autoconf.h"
+
+#ifdef CONFIG_X86_64
 
 #define MEMCPY_FN(fn, name, desc)  \
   

[PATCH v3 06/14] perf kbuild: remove legacy tui/gui-related build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_SLANG (replaced by CONFIG_LIBSLANG)
Remove HAVE_SLANG_SUPPORT from CFLAGS (replaced by CONFIG_LIBSLANG)
Remove NO_GTK2 (replaced by CONFIG_LIBGTK2 or CONFIG_GTK2)
Remove HAVE_GTK2_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2)
Remove HAVE_GTK_INFO_BAR_SUPPORT from CFLAGS (replaced by
CONFIG_LIBGTK2_INFOBAR)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig| 21 +
 tools/perf/config/Makefile| 20 ++--
 tools/perf/config/Makefile.fix-config | 24 
 tools/perf/config/Makefile.fix-legacy |  8 
 tools/perf/ui/gtk/browser.c   |  4 +++-
 tools/perf/ui/gtk/gtk.h   |  5 +++--
 tools/perf/ui/gtk/util.c  |  6 --
 tools/perf/ui/setup.c |  4 +++-
 tools/perf/ui/ui.h|  4 +++-
 tools/perf/util/annotate.h|  4 +++-
 tools/perf/util/hist.h|  3 ++-
 11 files changed, 48 insertions(+), 55 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index f9fcf9e..eb59567 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -171,6 +171,7 @@ config STDIO
 
 config TUI
bool "Tui (slang based)"
+   depends on LIBSLANG
default y
 ---help---
  Text-based user interface which provides windowing
@@ -179,6 +180,7 @@ config TUI
 config GTK2
bool "Gtk2"
default y
+   depends on LIBGTK2
 ---help---
  Elaborate display mode based on libgtk2.
 
@@ -186,12 +188,31 @@ endmenu
 
 menu "Libraries / Dependencies"
 
+config LIBSLANG
+   bool "Slang (libslang)"
+   default y
+---help---
+ libslang
+
 config LIBAUDIT
bool "Audit (libaudit)"
default y
 ---help---
  Linux audit framework dependency.
 
+config LIBGTK2
+   bool "Gtk2 (libgtk2)"
+   default y
+---help---
+ libgtk2
+
+config LIBGTK2_INFOBAR
+   bool "Gtk2 infobar (libgtk2)"
+   depends on LIBGTK2
+   default y
+---help---
+ libgtk2-infobar
+
 config LIBPERL
bool "Perl"
default y
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 6106e24..27b092c 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -445,32 +445,26 @@ ifndef NO_LIBAUDIT
   endif
 endif
 
-ifdef NO_NEWT
-  NO_SLANG=1
-endif
-
-ifndef NO_SLANG
+ifdef CONFIG_LIBSLANG
   ifneq ($(feature-libslang), 1)
-msg := $(warning slang not found, disables TUI support. Please install 
slang-devel or libslang-dev);
-NO_SLANG := 1
+msg := $(warning slang not found, disables SLANG and TUI supports. Please 
install slang-devel or libslang-dev);
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBSLANG)
   else
 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
 CFLAGS += -I/usr/include/slang
-CFLAGS += -DHAVE_SLANG_SUPPORT
 EXTLIBS += -lslang
   endif
 endif
 
-ifndef NO_GTK2
+ifdef CONFIG_LIBGTK2
   FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs 
--cflags gtk+-2.0 2>/dev/null)
   ifneq ($(feature-gtk2), 1)
 msg := $(warning GTK2 not found, disables GTK2 support. Please install 
gtk2-devel or libgtk2.0-dev);
-NO_GTK2 := 1
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2)
   else
 ifeq ($(feature-gtk2-infobar), 1)
-  GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2_INFOBAR)
 endif
-CFLAGS += -DHAVE_GTK2_SUPPORT
 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
 EXTLIBS += -ldl
@@ -801,8 +795,6 @@ all:
$(call store,NO_LIBUNWIND)
$(call store,NO_LIBPERL)
$(call store,NO_LIBPYTHON)
-   $(call store,NO_NEWT)
-   $(call store,NO_GTK2)
$(call store,NO_DEMANGLE)
$(call store,NO_LIBELF)
$(call store,NO_LIBUNWIND)
diff --git a/tools/perf/config/Makefile.fix-config 
b/tools/perf/config/Makefile.fix-config
index 7f65fdb..3d84008 100644
--- a/tools/perf/config/Makefile.fix-config
+++ b/tools/perf/config/Makefile.fix-config
@@ -19,30 +19,6 @@ dummy := $(shell $(CONFIG) -d CONFIG_LIBPYTHON)
 endif
 endif
 
-# NO_NEWT
-ifdef CONFIG_TUI
-ifdef NO_NEWT
-dummy := $(info Disabling CONFIG_TUI)
-dummy := $(shell $(CONFIG) -d CONFIG_TUI)
-endif
-endif
-
-# NO_NEWT
-ifdef CONFIG_TUI
-ifdef NO_SLANG
-dummy := $(info Disabling CONFIG_TUI)
-dummy := $(shell $(CONFIG) -d CONFIG_TUI)
-endif
-endif
-
-# NO_GTK2
-ifdef CONFIG_GTK2
-ifdef NO_GTK2
-dummy := $(info Disabling CONFIG_GTK2)
-dummy := $(shell $(CONFIG) -d CONFIG_GTK2)
-endif
-endif
-
 # NO_DEMANGLE
 ifdef CONFIG_DEMANGLE
 ifdef NO_DEMANGLE
diff --git a/tools/perf/config/Makefile.fix-legacy 
b/tools/perf/config/Makefile.fix-legacy
index 2ec91f3..ca219e7 100644
--- a/tools/perf/config/Makefile.fix-legacy
+++ b/tools/perf/config/Makefile.fix-legacy
@@ -9,14 +9,6 @@ 

[PATCH v3 05/14] perf kbuild: remove Makefile.perf

2014-10-23 Thread Alexis Berlemont
The file Makefile.perf contained legacy build rules. It is replaced by
Makefile.kbuild which relies on Kbuild. Consequently, some minor
points need updates:
* The constant CONFIG_KBUILD can be removed
* The main Makefile wrapper now call Makefile.kbuild instead of
  Makefile.perf

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Makefile   |   2 +-
 tools/perf/Makefile.kbuild|   2 +-
 tools/perf/Makefile.perf  | 949 --
 tools/perf/builtin-annotate.c |   4 +-
 tools/perf/builtin-cmds.h |  25 --
 tools/perf/builtin-report.c   |   2 +-
 tools/perf/builtin-top.c  |   4 +-
 tools/perf/ui/setup.c |   4 +-
 8 files changed, 9 insertions(+), 983 deletions(-)
 delete mode 100644 tools/perf/Makefile.perf

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index cb2e586..4512f16 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -55,7 +55,7 @@ define print_msg
 endef
 
 define make
-  @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) 
$(SET_DEBUG) $@
+  @$(MAKE) -f Makefile.kbuild --no-print-directory -j$(JOBS) O=$(FULL_O) 
$(SET_DEBUG) $@
 endef
 
 #
diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild
index 51eba07..8d9e8b0 100644
--- a/tools/perf/Makefile.kbuild
+++ b/tools/perf/Makefile.kbuild
@@ -43,7 +43,7 @@ export QUIET_BISON QUIET_FLEX
 
 ifeq ($(KBUILD_SRC),)
 
-ifeq ("$(origin O)", "command line")
+ifneq ($(O),)
 KBUILD_OUTPUT := $(O)
 else
 KBUILD_OUTPUT := $(objtree)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
deleted file mode 100644
index dcf6248..000
--- a/tools/perf/Makefile.perf
+++ /dev/null
@@ -1,949 +0,0 @@
-include ../scripts/Makefile.include
-
-# The default target of this Makefile is...
-all:
-
-include config/utilities.mak
-
-# Define V to have a more verbose compile.
-#
-# Define VF to have a more verbose feature check output.
-#
-# Define O to save output files in a separate directory.
-#
-# Define ARCH as name of target architecture if you want cross-builds.
-#
-# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
-#
-# Define NO_LIBPERL to disable perl script extension.
-#
-# Define NO_LIBPYTHON to disable python script extension.
-#
-# Define PYTHON to point to the python binary if the default
-# `python' is not correct; for example: PYTHON=python2
-#
-# Define PYTHON_CONFIG to point to the python-config binary if
-# the default `$(PYTHON)-config' is not correct.
-#
-# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
-#
-# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL 
v1.72.
-#
-# Define LDFLAGS=-static to build a static binary.
-#
-# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for 
cross-builds.
-#
-# Define NO_DWARF if you do not want debug-info analysis feature at all.
-#
-# Define WERROR=0 to disable treating any warnings as errors.
-#
-# Define NO_NEWT if you do not want TUI support. (deprecated)
-#
-# Define NO_SLANG if you do not want TUI support.
-#
-# Define NO_GTK2 if you do not want GTK+ GUI support.
-#
-# Define NO_DEMANGLE if you do not want C++ symbol demangling.
-#
-# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
-#
-# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf
-# backtrace post unwind.
-#
-# Define NO_BACKTRACE if you do not want stack backtrace debug feature
-#
-# Define NO_LIBNUMA if you do not want numa perf benchmark
-#
-# Define NO_LIBAUDIT if you do not want libaudit support
-#
-# Define NO_LIBBIONIC if you do not want bionic support
-#
-# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
-# for dwarf backtrace post unwind.
-
-ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(shell pwd)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-#$(info Determined 'srctree' to be $(srctree))
-endif
-
-ifneq ($(objtree),)
-#$(info Determined 'objtree' to be $(objtree))
-endif
-
-ifneq ($(OUTPUT),)
-#$(info Determined 'OUTPUT' to be $(OUTPUT))
-endif
-
-$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
-   @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
-   @touch $(OUTPUT)PERF-VERSION-FILE
-
-CC = $(CROSS_COMPILE)gcc
-AR = $(CROSS_COMPILE)ar
-PKG_CONFIG = $(CROSS_COMPILE)pkg-config
-
-RM  = rm -f
-LN  = ln -f
-MKDIR   = mkdir
-FIND= find
-INSTALL = install
-FLEX= flex
-BISON   = bison
-STRIP   = strip
-
-LIB_DIR  = $(srctree)/tools/lib/api/
-TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
-
-# include config/Makefile by default and rule out
-# non-config cases
-config := 1
-
-NON_CONFIG_TARGETS := clean TAGS tags cscope help
-
-ifdef MAKECMDGOALS
-ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
-  config := 0
-endif
-endif
-
-ifeq ($(config),1)
-include config/Makefile
-endif
-
-export prefix bindir sharedir sysconfdir DESTDIR
-
-# sparse is architecture-neutral, which means that we need to tell it
-# explicitly what architecture to 

[PATCH v3 04/14] perf tools: Add kbuild support into Makefile.kbuild

2014-10-23 Thread Alexis Berlemont
From: Jiri Olsa 

Adding kbuild support into Makefile.kbuild. The 'legacy'
Makefile still stays untouched as it was.

It's possible to use kbuild by running 'make -f Makefile.kbuild'
with any option supported by 'legacy' Makefile.

We now have 2 config files:
  '.config' - user configured setup
  '.config-detected' - system detected setup

The '.config-detected' affects '.config' and if there's
configured feature in '.config' which was not detected
it is automatically disabled.

The '.config-detected' is re/created if:
  - there's no '.config-detected'
  - '.config' was changed

In a cleaned tree the perf is built with 'allyesconfig'
having disabled all non-detected features, just as it is
done now.

You can change '.config' via:
  make -f Makefile.kbuild menuconfig

There's difference for O=DIR build. The DIR is populated
based on kernel source tree, so the final binary is created
under DIR/tools/perf.

This commit was originally created by Jiri Olsa in February 2013; a
few changes were necessary to fit the perf version of June 2014:
* Add missing CFLAGS for specific .o targets
* Update Kbuild files (new source files, ...)
* Fix recursive invocation of config/features-checks
* Store .config-detected missing variables (libdir, ...)
* Fix missing dependencies between Kconfig options
* Fix installation of traceevent plugins
* Fix missing cleanings of feature-check binaries
* CROSS_COMPILE was not used to define AS, CC, ...
* CROSS_COMPILE was not stored in .config-detected
* Take into account DESTDIR and prefix set in the command line
* Add missing Kbuild files for non-x86 architectures
  (powerpc, arm, arm64, sh, s390, sparc)
* Move perf-time-to-tsc.c into x86-specific tests directory

Signed-off-by: Jiri Olsa 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Corey Ashford 
Cc: Frederic Weisbecker 
Cc: Namhyung Kim 
Cc: Borislav Petkov 
Cc: Michal Marek 
Cc: linux-kbu...@vger.kernel.org
Cc: Stephane Eranian 
Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kbuild  |  47 +++
 tools/perf/Kconfig | 284 ++
 tools/perf/Makefile.kbuild | 431 +
 tools/perf/Makefile.perf   |   2 +-
 tools/perf/arch/Kbuild |   3 +
 tools/perf/arch/arm/Kbuild |   2 +
 tools/perf/arch/arm/Makefile   |  14 -
 tools/perf/arch/arm/tests/Kbuild   |   2 +
 tools/perf/arch/arm/util/Kbuild|   3 +
 tools/perf/arch/arm64/Kbuild   |   1 +
 tools/perf/arch/arm64/Makefile |   7 -
 tools/perf/arch/arm64/util/Kbuild  |   2 +
 tools/perf/arch/powerpc/Kbuild |   1 +
 tools/perf/arch/powerpc/Makefile   |   6 -
 tools/perf/arch/powerpc/util/Kbuild|   3 +
 tools/perf/arch/s390/Kbuild|   1 +
 tools/perf/arch/s390/Makefile  |   7 -
 tools/perf/arch/s390/util/Kbuild   |   2 +
 tools/perf/arch/sh/Kbuild  |   1 +
 tools/perf/arch/sh/Makefile|   4 -
 tools/perf/arch/sh/util/Kbuild |   1 +
 tools/perf/arch/sparc/Kbuild   |   1 +
 tools/perf/arch/sparc/Makefile |   4 -
 tools/perf/arch/sparc/util/Kbuild  |   1 +
 tools/perf/arch/x86/Kbuild |   1 +
 tools/perf/arch/x86/tests/Kbuild   |   3 +
 tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c |   0
 tools/perf/arch/x86/util/Kbuild|   5 +
 tools/perf/bench/Kbuild|  12 +
 tools/perf/builtin-cmds.h  |   4 +
 tools/perf/config/Makefile |  55 ++-
 tools/perf/config/Makefile.fix-config  | 104 +
 tools/perf/config/Makefile.fix-legacy  |  46 +++
 tools/perf/config/defconfig|  54 +++
 tools/perf/perf-sys.h  |   4 +-
 tools/perf/scripts/perl/Perf-Trace-Util/Kbuild |   6 +
 tools/perf/scripts/python/Perf-Trace-Util/Kbuild   |   5 +
 tools/perf/tests/Kbuild|  38 ++
 tools/perf/ui/Kbuild   |  15 +
 tools/perf/ui/browsers/Kbuild  |   9 +
 tools/perf/ui/gtk/Kbuild   |   9 +
 tools/perf/ui/stdio/Kbuild |   1 +
 tools/perf/ui/tui/Kbuild   |   4 +
 tools/perf/util/Kbuild | 125 ++
 tools/perf/util/PERF-VERSION-GEN   |   4 +
 tools/perf/util/generate-cmdlist.sh|   8 +-
 tools/perf/util/scripting-engines/Kbuild   |  11 +
 tools/perf/util/setup.py   |   8 +-
 48 files changed, 1309 insertions(+), 52 

[PATCH v3 09/14] perf kbuild: remove legacy misc build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_LIBAUDIT (replaced by CONFIG_LIBAUDIT)
Remove HAVE_LIBAUDIT_SUPPORT from CFLAGS (replaced by CONFIG_LIBAUDIT)
Remove HAVE_TIMERFD_SUPPORT (replaced by CONFIG_TIMERFD)
Remove HAVE_ON_EXIT_SUPPORT (replaced by CONFIG_ON_EXIT)
Remove HAVE_BACKTRACE_SUPPORT (replaced by CONFIG_BACKTRACE)
Remove HAVE_LIBNUMA_SUPPORT (replaced by CONFIG_LIBNUMA)
Remove NO_BIONIC (replaced by CONFIG_BIONIC)
Remove NO_PERF_REGS (replaced by CONFIG_PERF_REGS)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig| 12 --
 tools/perf/arch/arm/tests/Kbuild  |  2 +-
 tools/perf/arch/x86/tests/Kbuild  |  2 +-
 tools/perf/bench/Kbuild   |  2 +-
 tools/perf/builtin-bench.c|  5 ++--
 tools/perf/builtin-kvm.c  | 13 ++-
 tools/perf/builtin-record.c   |  2 ++
 tools/perf/config/Makefile| 43 +--
 tools/perf/config/Makefile.fix-config | 32 --
 tools/perf/config/Makefile.fix-legacy | 16 -
 tools/perf/util/perf_regs.c   |  3 +++
 tools/perf/util/perf_regs.h   |  6 +++--
 tools/perf/util/util.c|  5 ++--
 13 files changed, 51 insertions(+), 92 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 5f85923..29853a6 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -312,8 +312,8 @@ config LIBUNWIND_DIR
  Directory holding the libuwind dependency (headers +
  libraries).
 
-config NUMA
-   bool "Numa support (bench)"
+config LIBNUMA
+   bool "Libnuma support"
default y
 ---help---
  The library libnuma offers facilities to configure NUMA
@@ -327,6 +327,14 @@ config BIONIC
  library code developed by Google for their Android operating
  system.
 
+config PERF_REGS
+   bool "Cache register accesses"
+   depends on (ARCH = "x86" || ARCH = "arm" || ARCH = "arm64")
+   default y
+---help---
+ Cache register accesses for unwind processing to speed-up
+ performances.
+
 endmenu
 
 menu "Build"
diff --git a/tools/perf/arch/arm/tests/Kbuild b/tools/perf/arch/arm/tests/Kbuild
index 5d63e9d..1318ed0 100644
--- a/tools/perf/arch/arm/tests/Kbuild
+++ b/tools/perf/arch/arm/tests/Kbuild
@@ -1,2 +1,2 @@
-obj-y += regs_load.o
+obj-$(CONFIG_PERF_REGS) += regs_load.o
 obj-y += dwarf-unwind.o
diff --git a/tools/perf/arch/x86/tests/Kbuild b/tools/perf/arch/x86/tests/Kbuild
index 3b5aa14..8287dae 100644
--- a/tools/perf/arch/x86/tests/Kbuild
+++ b/tools/perf/arch/x86/tests/Kbuild
@@ -1,3 +1,3 @@
 obj-y += perf-time-to-tsc.o
-obj-y += regs_load.o
+obj-$(CONFIG_PERF_REGS) += regs_load.o
 obj-y += dwarf-unwind.o
diff --git a/tools/perf/bench/Kbuild b/tools/perf/bench/Kbuild
index e604fe2..863646a 100644
--- a/tools/perf/bench/Kbuild
+++ b/tools/perf/bench/Kbuild
@@ -6,7 +6,7 @@ obj-y += futex-hash.o
 obj-y += futex-requeue.o
 obj-y += futex-wake.o
 
-obj-$(CONFIG_NUMA) += numa.o
+obj-$(CONFIG_LIBNUMA) += numa.o
 
 obj-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o
 obj-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index b9a56fa..5116d25 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -14,6 +14,7 @@
  *  numa  ... NUMA scheduling and MM performance
  *  futex ... Futex performance
  */
+#include "generated/autoconf.h"
 #include "perf.h"
 #include "util/util.h"
 #include "util/parse-options.h"
@@ -33,7 +34,7 @@ struct bench {
bench_fn_t  fn;
 };
 
-#ifdef HAVE_LIBNUMA_SUPPORT
+#ifdef CONFIG_LIBNUMA
 static struct bench numa_benchmarks[] = {
{ "mem","Benchmark for NUMA workloads", 
bench_numa  },
{ "all","Test all NUMA benchmarks", NULL
},
@@ -72,7 +73,7 @@ struct collection {
 static struct collection collections[] = {
{ "sched",  "Scheduler and IPC benchmarks", 
sched_benchmarks},
{ "mem","Memory access benchmarks", 
mem_benchmarks  },
-#ifdef HAVE_LIBNUMA_SUPPORT
+#ifdef CONFIG_LIBNUMA
{ "numa",   "NUMA scheduling and MM benchmarks",
numa_benchmarks },
 #endif
{"futex",   "Futex stressing benchmarks",   
futex_benchmarks},
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 400e92e..28371f9 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1,3 +1,4 @@
+#include "generated/autoconf.h"
 #include "builtin.h"
 #include "perf.h"
 
@@ -20,7 +21,7 @@
 #include "util/data.h"
 
 #include 
-#ifdef HAVE_TIMERFD_SUPPORT
+#ifdef CONFIG_TIMERFD
 #include 
 #endif
 
@@ -123,7 +124,7 @@ static void init_kvm_event_record(struct perf_kvm_stat *kvm)
INIT_LIST_HEAD(>kvm_events_cache[i]);
 }
 
-#ifdef HAVE_TIMERFD_SUPPORT
+#ifdef CONFIG_TIMERFD
 static void 

[PATCH v3 07/14] perf kbuild: remove legacy demangle-related build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_DEMANGLE (replaced by CONFIG_DEMANGLE)
Remove HAVE_LIBBFD_SUPPORT (replaced by CONFIG_LIBBFD)
Remove HAVE_CPLUS_DEMANGLE_SUPPORT (replaced by CONFIG_LIBIBERTY_ONLY)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig| 36 +--
 tools/perf/config/Makefile| 46 ++-
 tools/perf/config/Makefile.fix-legacy |  4 ---
 tools/perf/util/srcline.c |  8 +++---
 tools/perf/util/symbol.h  | 25 +--
 5 files changed, 75 insertions(+), 44 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index eb59567..026ef67 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -225,6 +225,35 @@ config LIBPYTHON
 ---help---
  Libpython dependency needed by the perf script feature.
 
+config TIMERFD
+   bool "Timer via file descriptor"
+   default y
+---help---
+ Timer via file descriptor
+
+config DEMANGLE
+   bool "Demangle symbols"
+   default y
+---help---
+ Enable demangling so as to display human-readable
+ symbols. This option is convenient with C++ programs.
+
+choice DEMANGLE_DEPS
+   prompt "Demangle dependency(ies)"
+   depends on DEMANGLE
+   default LIBBFD
+
+config LIBBFD
+   bool "BFD + libiberty libraries"
+---help---
+ Binary File Descriptor and libiberty libraries
+
+config LIBIBERTY_ONLY
+   bool "Libiberty only"
+---help---
+ Libiberty
+endchoice
+
 choice
prompt "Elf library"
default LIBELF
@@ -266,13 +295,6 @@ config NUMA
  The library libnuma offers facilities to configure NUMA
  policies supported by the linux kernel.
 
-config DEMANGLE
-   bool "Demangle symbols"
-   default y
----help---
- Enable demangling so as to display human-readable
- symbols. This option is convenient with C++ programs.
-
 config BIONIC
bool "Bionic support"
default n
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 27b092c..ce3a726 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -573,33 +573,36 @@ ifeq ($(feature-libbfd), 1)
   endif
 endif
 
-ifdef NO_DEMANGLE
-  CFLAGS += -DNO_DEMANGLE
-else
-  ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
-EXTLIBS += -liberty
-CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
-  else
-ifneq ($(feature-libbfd), 1)
-  ifneq ($(feature-liberty), 1)
-ifneq ($(feature-liberty-z), 1)
-  # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
-  # or any of 'bfd iberty z' trinity
-  ifeq ($(feature-cplus-demangle), 1)
-EXTLIBS += -liberty
-CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
-  else
-msg := $(warning No bfd.h/libbfd found, install 
binutils-dev[el]/zlib-static to gain symbol demangling)
-CFLAGS += -DNO_DEMANGLE
-  endif
+ifdef CONFIG_LIBBFD
+  ifneq ($(feature-libbfd), 1)
+# TODO: there might be an issue here: feature-liberty and
+# feature-liberty-z cannot be set; they can be set only if
+# feature-libbfd is set
+ifneq ($(feature-liberty), 1)
+  ifneq ($(feature-liberty-z), 1)
+# we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
+# or any of 'bfd iberty z' trinity
+ifeq ($(feature-cplus-demangle), 1)
+  EXTLIBS += -liberty
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBBFD)
+  $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBIBERTY_ONLY)
+else
+  msg := $(warning No bfd.h/libbfd found, install 
binutils-dev[el]/zlib-static to gain symbol demangling)
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE)
 endif
   endif
 endif
   endif
 endif
 
-ifneq ($(filter -lbfd,$(EXTLIBS)),)
-  CFLAGS += -DHAVE_LIBBFD_SUPPORT
+ifdef CONFIG_LIBIBERTY_ONLY
+  $(call feature_check,cplus-demangle)
+  ifeq ($(feature-cplus-demangle), 1)
+EXTLIBS += -liberty
+  else
+msg := $(warning No libiberty found, install binutils-dev[el]/zlib-static 
to gain symbol demangling)
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE)
+  endif
 endif
 
 ifndef NO_BACKTRACE
@@ -795,7 +798,6 @@ all:
$(call store,NO_LIBUNWIND)
$(call store,NO_LIBPERL)
$(call store,NO_LIBPYTHON)
-   $(call store,NO_DEMANGLE)
$(call store,NO_LIBELF)
$(call store,NO_LIBUNWIND)
$(call store,NO_BACKTRACE)
diff --git a/tools/perf/config/Makefile.fix-legacy 
b/tools/perf/config/Makefile.fix-legacy
index ca219e7..64dbb1a 100644
--- a/tools/perf/config/Makefile.fix-legacy
+++ b/tools/perf/config/Makefile.fix-legacy
@@ -9,10 +9,6 @@ ifndef CONFIG_LIBPYTHON
 NO_LIBPYTHON := 1
 endif
 
-ifndef CONFIG_DEMANGLE
-NO_DEMANGLE := 1
-endif
-
 ifndef CONFIG_LIBELF
 NO_LIBELF := 1
 endif
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index f3e4bc5..38df8f4 100644
--- a/tools/perf/util/srcline.c
+++ 

[PATCH v3 10/14] perf kbuild: remove legacy libelf-related build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_LIBELF (replaced by CONFIG_LIBELF)
Remove HAVE_LIBELF_SUPPORT (replaced by CONFIG_LIBELF)
Remove HAVE_LIBELF_MMAP_SUPPORT (replaced by CONFIG_LIBELF_MMAP)
Remove HAVE_LIBELF_GETPHDRNUM__SUPPORT (replaced by
CONFIG_LIBELF_GETPHDRNUM_)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig| 23 ++
 tools/perf/builtin-inject.c   |  2 +-
 tools/perf/config/Makefile| 37 +++
 tools/perf/config/Makefile.fix-config | 18 -
 tools/perf/config/Makefile.fix-legacy |  4 
 tools/perf/perf.c |  2 +-
 tools/perf/util/generate-cmdlist.sh   |  4 ++--
 tools/perf/util/map.c |  3 ++-
 tools/perf/util/symbol-elf.c  |  3 ++-
 tools/perf/util/symbol.h  |  8 
 10 files changed, 51 insertions(+), 53 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 29853a6..2eaf3ca 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -256,6 +256,7 @@ config TIMERFD
  Timer via file descriptor
 
 config DEMANGLE
+   depends on LIBELF
bool "Demangle symbols"
default y
 ---help---
@@ -298,7 +299,29 @@ choice
  Builtin elf support.
 endchoice
 
+config LIBELF_MMAP
+depends on LIBELF
+   bool "Libelf mmap support"
+   default y
+---help---
+ libdelf mmap
+
+config LIBELF_GETPHDRNUM
+depends on LIBELF
+   default y
+   bool "Libelf getphdrnum support"
+---help---
+ libdelf mmap
+
+config LIBDWARF
+   depends on LIBELF
+   bool "Dwarf (libdwarf)"
+   default y
+---help---
+ libdwarf
+
 config LIBUNWIND
+depends on LIBELF
bool "User space libunwind callchains"
default y
 ---help---
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index de99ca1..9d59c7f 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -230,7 +230,7 @@ static int perf_event__inject_buildid(struct perf_tool 
*tool,
 * account this as unresolved.
 */
} else {
-#ifdef HAVE_LIBELF_SUPPORT
+#ifdef CONFIG_LIBELF
pr_warning("no symbols found in %s, maybe "
   "install a debug package?\n",
   al.map->dso->long_name);
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 5be574c3..79fe047 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -303,12 +303,7 @@ ifdef CONFIG_BIONIC
   endif
 endif
 
-ifdef NO_LIBELF
-  NO_DWARF := 1
-  NO_DEMANGLE := 1
-  NO_LIBUNWIND := 1
-  NO_LIBDW_DWARF_UNWIND := 1
-else
+ifdef CONFIG_LIBELF
   ifeq ($(feature-libelf), 0)
 ifeq ($(feature-glibc), 1)
   LIBC_SUPPORT := 1
@@ -318,12 +313,9 @@ else
 endif
 ifeq ($(LIBC_SUPPORT),1)
   msg := $(warning No libelf found, disables 'probe' tool, please install 
elfutils-libelf-devel/libelf-dev);
-
-  NO_LIBELF := 1
-  NO_DWARF := 1
-  NO_DEMANGLE := 1
-  NO_LIBUNWIND := 1
-  NO_LIBDW_DWARF_UNWIND := 1
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF)
+  $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBELF_MINIMAL)
+  EXTLIBS := $(filter-out -lelf,$(EXTLIBS))
 else
   ifneq ($(filter s% -static%,$(LDFLAGS),),)
 msg := $(error No static glibc found, please install glibc-static);
@@ -332,6 +324,7 @@ else
   endif
 endif
   else
+LIBELF = 1
 ifndef NO_LIBDW_DWARF_UNWIND
   ifneq ($(feature-libdw-dwarf-unwind),1)
 NO_LIBDW_DWARF_UNWIND := 1
@@ -343,17 +336,20 @@ else
   NO_DWARF := 1
 endif # Dwarf support
   endif # libelf support
-endif # NO_LIBELF
+endif # CONFIG_LIBELF
 
-ifndef NO_LIBELF
-  CFLAGS += -DHAVE_LIBELF_SUPPORT
+ifeq ($(LIBELF), 1)
 
-  ifeq ($(feature-libelf-mmap), 1)
-CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
+  ifdef CONFIG_LIBELF_MMAP
+ifneq ($(feature-libelf-mmap), 1)
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP)
+endif
   endif
 
-  ifeq ($(feature-libelf-getphdrnum), 1)
-CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
+  ifdef CONFIG_LIBELF_MMAP
+ifneq ($(feature-libelf-getphdrnum), 1)
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP)
+endif
   endif
 
   # include ARCH specific config
@@ -369,7 +365,7 @@ ifndef NO_LIBELF
   EXTLIBS += -lelf -ldw
 endif # PERF_HAVE_DWARF_REGS
   endif # NO_DWARF
-endif # NO_LIBELF
+endif # LIBELF
 
 ifeq ($(ARCH),powerpc)
   ifndef NO_DWARF
@@ -787,7 +783,6 @@ all:
$(call store,NO_LIBUNWIND)
$(call store,NO_LIBPERL)
$(call store,NO_LIBPYTHON)
-   $(call store,NO_LIBELF)
$(call store,NO_LIBUNWIND)
$(call store,NO_LIBBIONIC)
$(call store,ETC_PERFCONFIG_SQ)
diff --git a/tools/perf/config/Makefile.fix-config 

[PATCH] x86: Don't allow stackprotector without TSC

2014-10-23 Thread Ben Harris
On x86, boot_init_stack_canary() unconditionally calls 
__native_read_tsc().  This means that when a kernel with 
CONFIG_CC_STACKPROTECTOR enabled is booted on a CPU without a TSC, the 
kernel hangs at startup.  See  for an 
example.


To avoid this, make HAVE_CC_STACKPROTECTOR dependent on X86_TSC, which is 
defined iff all supported processors have a TSC.  Setting the minimum 
processor type to one without TSC thus disables the stack protector, 
making the kernel bootable on such processors.


Signed-off-by: Ben Harris 

---

This patch is against v3.18-rc1.

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f2327e8..5acee0f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -129,7 +129,6 @@ config X86
select RTC_LIB
select HAVE_DEBUG_STACKOVERFLOW
select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
-   select HAVE_CC_STACKPROTECTOR
select GENERIC_CPU_AUTOPROBE
select HAVE_ARCH_AUDITSYSCALL
select ARCH_SUPPORTS_ATOMIC_RMW
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 6983314..9626e47 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -360,6 +360,7 @@ config X86_P6_NOP
 config X86_TSC
def_bool y
depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || 
MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX 
|| M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || 
MATOM) || X86_64
+   select HAVE_CC_STACKPROTECTOR

 config X86_CMPXCHG64
def_bool y

--
Ben Harris
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 11/14] perf kbuild: remove legacy libdwarf-related build variables

2014-10-23 Thread Alexis Berlemont
* Remove NO_DWARF (replaced by CONFIG_LIBDWARF)
* Remove HAVE_DWARF_SUPPORT (replaced by CONFIG_LIBDWARF)
* Remove the useless variable PERF_HAVE_DWARF_REGS
* fix compilation issues if PERF_REGS is disabled

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig   |  59 +-
 tools/perf/arch/arm/tests/Kbuild |   2 +-
 tools/perf/arch/arm/util/Kbuild  |   4 +-
 tools/perf/arch/arm64/util/Kbuild|   2 +-
 tools/perf/arch/powerpc/util/Kbuild  |   4 +-
 tools/perf/arch/s390/util/Kbuild |   2 +-
 tools/perf/arch/sh/util/Kbuild   |   2 +-
 tools/perf/arch/sparc/util/Kbuild|   2 +-
 tools/perf/arch/x86/Kbuild   |   1 +
 tools/perf/arch/x86/Makefile |   8 +-
 tools/perf/arch/x86/tests/Kbuild |   2 +-
 tools/perf/arch/x86/tests/perf-time-to-tsc.c |   2 +-
 tools/perf/arch/x86/util/Kbuild  |   3 +-
 tools/perf/builtin-probe.c   |  15 +--
 tools/perf/builtin-record.c  |   2 +-
 tools/perf/config/Makefile   | 170 +--
 tools/perf/config/Makefile.fix-config|   8 --
 tools/perf/config/Makefile.fix-legacy|   4 -
 tools/perf/tests/Kbuild  |   2 +
 tools/perf/tests/builtin-test.c  |   3 +-
 tools/perf/tests/tests.h |   6 +-
 tools/perf/util/Kbuild   |  11 +-
 tools/perf/util/callchain.c  |  11 +-
 tools/perf/util/callchain.h  |   3 +-
 tools/perf/util/include/dwarf-regs.h |   4 +-
 tools/perf/util/machine.c|   3 +-
 tools/perf/util/perf_regs.c  |   2 -
 tools/perf/util/probe-event.c|   6 +-
 tools/perf/util/probe-finder.h   |   5 +-
 tools/perf/util/unwind-libunwind.c   |   5 +-
 tools/perf/util/unwind.h |   7 +-
 31 files changed, 203 insertions(+), 157 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 2eaf3ca..54a194d 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -287,7 +287,6 @@ choice
  these tasks, perf can rely on either the libelf library or a
  minimal builtin support.
 
-
config LIBELF
bool "elf"
---help---
@@ -318,15 +317,51 @@ config LIBDWARF
bool "Dwarf (libdwarf)"
default y
 ---help---
- libdwarf
+ A library for parsing DWARF debug information.
+
+config LIBDWARF_DIR
+   string "libdwarf directory"
+   depends on LIBDWARF
+---help---
+ Directory holding the libdwarf dependency (headers +
+ libraries)
+
+config UNWIND
+depends on (LIBELF && PERF_REGS)
+   bool "User space unwind callchains"
+   default y
+---help---
+ Enable call-chain unwinding of user-space application.
+
+choice UNWIND_DEPS
+   prompt "Unwind dependency"
+   depends on UNWIND
+   default LIBUNWIND
 
 config LIBUNWIND
-depends on LIBELF
-   bool "User space libunwind callchains"
+depends on (LIBELF && PERF_REGS)
+   bool "Libunwind"
+---help---
+ Rely on libunwind post unwind support to determine the
+ call-chain of a user-space program. The library libunwind
+ supports all the architectures.
+
+config LIBDWARF_UNWIND
+depends on (LIBDWARF && PERF_REGS && (ARCH = "x86" || ARCH = "arm"))
+   bool "Libdwarf unwind"
+---help---
+ Rely on lidw DWARF post unwind support to determine the
+ call-chain of a user-space program. So far there's only x86
+ and arm libdw unwind support merged in perf.
+
+endchoice
+
+config LIBUNWIND_DEBUG_FRAME
+depends on LIBUNWIND
+   bool "libunwind debug frame"
default y
 ---help---
- The library libunwind provides a portable C API to determine
- the call-chain of a program.
+ libunwind debug frame
 
 config LIBUNWIND_DIR
string "libunwind directory"
@@ -335,6 +370,18 @@ config LIBUNWIND_DIR
  Directory holding the libuwind dependency (headers +
  libraries).
 
+config SKIP_CALLCHAIN_IDX
+   depends on (LIBDWARF && ARCH = "powerpc")
+   bool "Skip unnecessary callchain entries thanks to Dwarf"
+   default y
+---help---
+ When saving the callchain on Power, the kernel
+ conservatively saves excess entries in the callchain. A few
+ of these entries are needed in some cases but not others. If
+ the unnecessary entries are not ignored, we end up with
+ duplicate arcs in the call-graphs. Use DWARF debug
+ information to skip over any unnecessary callchain entries.
+
 config LIBNUMA
bool "Libnuma support"
default y
diff --git a/tools/perf/arch/arm/tests/Kbuild b/tools/perf/arch/arm/tests/Kbuild
index 1318ed0..f1d8426 100644
--- 

[PATCH v3 13/14] perf kbuild: final cosmetic changes

2014-10-23 Thread Alexis Berlemont
* Correctly rename internal makefile variables
* Remove makefiles in tools/perf/config which became empty and useless
* Remove builtin-cmds.h
* Remove arch/x86/Makefile
* Improve outputs of clean and install targets
* Remove creation of PERF-FEATURES file which is redundant with the
  .config file generated by Kconfig.
* replace HAVE_KVM_STAT_SUPPORT by a Kconfig option
* replace HAVE_SKIP_CALLCHAIN_IDX by a Kconfig option

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig|  7 
 tools/perf/Makefile.kbuild| 74 ++--
 tools/perf/arch/s390/util/Kbuild  |  2 +-
 tools/perf/arch/x86/Makefile  | 17 
 tools/perf/arch/x86/util/Kbuild   |  2 +-
 tools/perf/builtin-cmds.h |  6 ---
 tools/perf/builtin-help.c |  2 +-
 tools/perf/builtin-kvm.c  |  6 +--
 tools/perf/builtin-lock.c |  2 +-
 tools/perf/builtin-sched.c|  2 +-
 tools/perf/config/Makefile| 79 +++
 tools/perf/config/Makefile.fix-config |  6 ---
 tools/perf/config/Makefile.fix-legacy |  2 -
 tools/perf/perf.c |  2 +-
 14 files changed, 83 insertions(+), 126 deletions(-)
 delete mode 100644 tools/perf/arch/x86/Makefile
 delete mode 100644 tools/perf/builtin-cmds.h
 delete mode 100644 tools/perf/config/Makefile.fix-config
 delete mode 100644 tools/perf/config/Makefile.fix-legacy

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 54a194d..d1b44c3 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -128,6 +128,13 @@ config BUILTIN_KVM
 ---help---
  Tool to trace/measure kvm guest os
 
+config BUILTIN_KVM_STAT
+   bool "kvm-stat"
+   default y
+   depends on BUILTIN_KVM && (ARCH = "x86" || ARCH = "s390")
+---help---
+ Get performance counter statistics on a kvm guest os.
+
 config BUILTIN_LIST
bool "list"
default y
diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild
index b48fe7f..90b168d 100644
--- a/tools/perf/Makefile.kbuild
+++ b/tools/perf/Makefile.kbuild
@@ -1,6 +1,5 @@
 srctree := $(abspath $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)/../../))
 objtree := $(abspath $(if $(KBUILD_SRC),$(CURDIR),$(CURDIR)/../..))
-
 VPATH   := $(srctree)
 
 export srctree VPATH
@@ -36,7 +35,8 @@ export quiet Q KBUILD_VERBOSE
 ifndef V
 QUIET_LINK  = @echo '  LD  $@';
 QUIET_GEN   = @echo '  GEN $@';
-QUIET_CLEAN = @echo '  CLEAN   tools/perf';
+QUIET_CLEAN = @printf '  CLEAN%s\n' $1;
+QUIET_INSTALL = @printf '  INSTALL  %s\n' $1;
 endif
 
 export QUIET_BISON QUIET_FLEX
@@ -158,7 +158,6 @@ $(CONFIG_DETECTED): $(KCONFIG_CONFIG)
 # no need to include auto.conf.cmd, because .config
 # is the only dependency here
 $(KCONFIG_AUTOCONFIG): $(KCONFIG_CONFIG) $(CONFIG_DETECTED)
-   $(Q)$(MAKE) -f $(src-perf)/config/Makefile.fix-config
$(Q)mkdir -p $(obj-perf)/include/config
$(Q)mkdir -p $(obj-perf)/include/generated
$(Q)$(MAKE) -s $(build)=scripts/kconfig silentoldconfig
@@ -167,22 +166,26 @@ $(KCONFIG_AUTOCONFIG): $(KCONFIG_CONFIG) 
$(CONFIG_DETECTED)
 clean-dirs := $(addprefix _clean_, tools/perf/)
 
 $(clean-dirs):
+   $(call QUIET_CLEAN, core-objs)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.clean obj=$(patsubst 
_clean_%,%,$@)
 
-clean: $(clean-dirs) $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean
-   $(Q)$(QUIET_CLEAN)
-   $(Q)rm -f $(obj-perf)/perf
-   $(Q)rm -f $(obj-perf)/common-cmds.h
-   $(Q)rm -f $(obj-perf)/python/perf.so
+config-clean:
+   $(call QUIET_CLEAN, config)
+   @$(MAKE) OUTPUT=$(obj-perf)/config/feature-checks/ -C 
$(src-perf)/config/feature-checks clean >/dev/null
$(Q)rm -rf $(obj-perf)/include/generated $(obj-perf)/include/config
+   $(Q)rm -f $(CONFIG_DETECTED) $(KCONFIG_CONFIG)
+   $(Q)rm -f $(obj-perf)/common-cmds.h
+
+clean: $(clean-dirs) $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean config-clean
+   $(call QUIET_CLEAN, core-progs)
+   $(Q)rm -f $(obj-perf)/perf
+   $(call QUIET_CLEAN, misc)
$(Q)find $(obj-perf) \
\( -name '*.[oas]' -o -name '.*.cmd' \
-o -name '.*.d' -o -name '.*.tmp' \
-o -name '*-flex.[ch]' -o -name '*-bison.[ch]' \
\) -type f -print | xargs rm -f
-   $(Q)$(python-clean)
-   $(Q)rm -f $(CONFIG_DETECTED) $(KCONFIG_CONFIG)
-   @$(MAKE) OUTPUT=$(obj-perf)/config/feature-checks/ -C 
$(src-perf)/config/feature-checks clean >/dev/null
+   $(python-clean)
 
 TAGS tags:
$(Q)rm -f $(src-perf)/tags
@@ -257,7 +260,7 @@ PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
 
 export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
 
-python-clean := rm -rf $(PYTHON_EXTBUILD) $(obj-perf)/python/perf.so
+python-clean := $(call QUIET_CLEAN, python) rm -rf $(PYTHON_EXTBUILD) 
$(obj-perf)/python/perf.so
 
 PYTHON_EXT_SRCS   := $(addprefix $(src-perf)/,$(shell grep -v ^\# 

[PATCH v3 14/14] perf kbuild: add generated Kconfig build-test cases

2014-10-23 Thread Alexis Berlemont
Thanks to the python module kconfiglib, we were able to generate build
configurations. The set is, of course, not exhaustive but for each
option, all the possible states are tested.

Signed-off-by: Alexis Berlemont 
---
 tools/perf/MANIFEST|  1 +
 tools/perf/tests/configs/MINIMAL_config| 60 ++
 tools/perf/tests/configs/NO_BACKTRACE_config   | 73 ++
 .../perf/tests/configs/NO_BUILTIN_ANNOTATE_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_BENCH_config   | 73 ++
 .../tests/configs/NO_BUILTIN_BUILDID_CACHE_config  | 73 ++
 .../tests/configs/NO_BUILTIN_BUILDID_LIST_config   | 71 +
 tools/perf/tests/configs/NO_BUILTIN_DIFF_config| 71 +
 tools/perf/tests/configs/NO_BUILTIN_EVLIST_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_HELP_config| 73 ++
 tools/perf/tests/configs/NO_BUILTIN_INJECT_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_KMEM_config| 73 ++
 .../perf/tests/configs/NO_BUILTIN_KVM_STAT_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_KVM_config | 72 +
 tools/perf/tests/configs/NO_BUILTIN_LIST_config| 73 ++
 tools/perf/tests/configs/NO_BUILTIN_LOCK_config| 73 ++
 tools/perf/tests/configs/NO_BUILTIN_MEM_config | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_PROBE_config   | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_RECORD_config  | 63 +++
 tools/perf/tests/configs/NO_BUILTIN_REPORT_config  | 68 
 tools/perf/tests/configs/NO_BUILTIN_SCHED_config   | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_SCRIPT_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_STAT_config| 71 +
 tools/perf/tests/configs/NO_BUILTIN_TEST_config| 73 ++
 .../perf/tests/configs/NO_BUILTIN_TIMECHART_config | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_TOP_config | 71 +
 tools/perf/tests/configs/NO_BUILTIN_TRACE_config   | 73 ++
 tools/perf/tests/configs/NO_DEMANGLE_config| 71 +
 tools/perf/tests/configs/NO_GTK2_config| 73 ++
 tools/perf/tests/configs/NO_LIBAUDIT_config| 72 +
 tools/perf/tests/configs/NO_LIBDWARF_config| 71 +
 tools/perf/tests/configs/NO_LIBELF_MMAP_config | 73 ++
 tools/perf/tests/configs/NO_LIBGTK2_INFOBAR_config | 73 ++
 tools/perf/tests/configs/NO_LIBGTK2_config | 71 +
 tools/perf/tests/configs/NO_LIBNUMA_config | 73 ++
 tools/perf/tests/configs/NO_LIBPERL_config | 73 ++
 tools/perf/tests/configs/NO_LIBPYTHON_config   | 73 ++
 tools/perf/tests/configs/NO_LIBSLANG_config| 72 +
 .../tests/configs/NO_LIBUNWIND_DEBUG_FRAME_config  | 73 ++
 tools/perf/tests/configs/NO_PERF_REGS_config   | 73 ++
 tools/perf/tests/configs/NO_STDIO_config   | 73 ++
 tools/perf/tests/configs/NO_TIMERFD_config | 73 ++
 tools/perf/tests/configs/NO_TUI_config | 73 ++
 tools/perf/tests/configs/NO_UNWIND_config  | 69 
 tools/perf/tests/configs/REF_config| 73 ++
 tools/perf/tests/generate_configs.py   | 43 +
 tools/perf/tests/make  | 70 ++---
 47 files changed, 3227 insertions(+), 50 deletions(-)
 create mode 100644 tools/perf/tests/configs/MINIMAL_config
 create mode 100644 tools/perf/tests/configs/NO_BACKTRACE_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_ANNOTATE_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BENCH_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_CACHE_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_LIST_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_DIFF_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_EVLIST_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_HELP_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_INJECT_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KMEM_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KVM_STAT_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KVM_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_LIST_config
 create mode 100644 

[PATCH v3 02/14] perf tools: Kbuild builtin source related fixies

2014-10-23 Thread Alexis Berlemont
From: Jiri Olsa 

Adding CONFIG_BUILTIN_* defines to govern builtin commands.
This will be useful for kbuild process switch.

Signed-off-by: Jiri Olsa 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Corey Ashford 
Cc: Frederic Weisbecker 
Cc: Namhyung Kim 
Cc: Borislav Petkov 
Cc: Michal Marek 
Cc: linux-kbu...@vger.kernel.org
Cc: Stephane Eranian 
Signed-off-by: Alexis Berlemont 
---
 tools/perf/builtin-annotate.c   |  8 ++-
 tools/perf/builtin-cmds.h   | 27 ++
 tools/perf/builtin-help.c   |  1 +
 tools/perf/builtin-kvm.c| 19 ++--
 tools/perf/builtin-report.c |  3 +++
 tools/perf/builtin-top.c| 19 
 tools/perf/perf.c   | 45 +++--
 tools/perf/ui/setup.c   |  6 +++--
 tools/perf/util/generate-cmdlist.sh | 10 +
 9 files changed, 122 insertions(+), 16 deletions(-)
 create mode 100644 tools/perf/builtin-cmds.h

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index e7417fe..19cb967 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -5,6 +5,7 @@
  * look up and read DSOs and symbol information and display
  * a histogram of results, along various sorting keys.
  */
+#include "generated/autoconf.h"
 #include "builtin.h"
 
 #include "util/util.h"
@@ -115,7 +116,7 @@ static void hists__find_annotations(struct hists *hists,
struct perf_evsel *evsel,
struct perf_annotate *ann)
 {
-   struct rb_node *nd = rb_first(>entries), *next;
+   struct rb_node *nd = rb_first(>entries);
int key = K_RIGHT;
 
while (nd) {
@@ -154,7 +155,9 @@ find_next:
 
/* skip missing symbols */
nd = rb_next(nd);
+#ifdef CONFIG_TUI
} else if (use_browser == 1) {
+   struct rb_node *next = NULL;
key = hist_entry__tui_annotate(he, evsel, NULL);
switch (key) {
case -1:
@@ -173,6 +176,7 @@ find_next:
 
if (next != NULL)
nd = next;
+#endif /* CONFIG_TUI */
} else {
hist_entry__tty_annotate(he, evsel, ann);
nd = rb_next(nd);
@@ -299,7 +303,9 @@ int cmd_annotate(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_BOOLEAN('D', "dump-raw-trace", _trace,
"dump raw trace in ASCII"),
OPT_BOOLEAN(0, "gtk", _gtk, "Use the GTK interface"),
+#ifdef CONFIG_TUI
OPT_BOOLEAN(0, "tui", _tui, "Use the TUI interface"),
+#endif /* CONFIG_TUI */
OPT_BOOLEAN(0, "stdio", _stdio, "Use the stdio interface"),
OPT_STRING('k', "vmlinux", _conf.vmlinux_name,
   "file", "vmlinux pathname"),
diff --git a/tools/perf/builtin-cmds.h b/tools/perf/builtin-cmds.h
new file mode 100644
index 000..fec342a
--- /dev/null
+++ b/tools/perf/builtin-cmds.h
@@ -0,0 +1,27 @@
+#ifndef BUILTIN_CMDS_H
+#define BUILTIN_CMDS_H
+
+#define CONFIG_BUILTIN_REPORT 1
+#define CONFIG_BUILTIN_SCRIPT 1
+#define CONFIG_BUILTIN_BENCH 1
+#define CONFIG_BUILTIN_SCHED 1
+#define CONFIG_BUILTIN_TRACE 1
+#define CONFIG_BUILTIN_TOP 1
+#define CONFIG_BUILTIN_RECORD 1
+#define CONFIG_BUILTIN_BUILDID_LIST 1
+#define CONFIG_BUILTIN_INJECT 1
+#define CONFIG_BUILTIN_LOCK 1
+#define CONFIG_BUILTIN_KVM 1
+#define CONFIG_BUILTIN_BUILDID_CACHE 1
+#define CONFIG_BUILTIN_EVLIST 1
+#define CONFIG_BUILTIN_KMEM 1
+#define CONFIG_BUILTIN_STAT 1
+#define CONFIG_BUILTIN_DIFF 1
+#define CONFIG_BUILTIN_ANNOTATE 1
+#define CONFIG_BUILTIN_TIMECHART 1
+#define CONFIG_BUILTIN_LIST 1
+#define CONFIG_BUILTIN_HELP 1
+#define CONFIG_BUILTIN_PROBE 1
+#define CONFIG_BUILTIN_MEM 1
+
+#endif /* BUILTIN_CMDS_H */
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 25d2062..fbbbaa4 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -7,6 +7,7 @@
 #include "util/cache.h"
 #include "builtin.h"
 #include "util/exec_cmd.h"
+#include "builtin-cmds.h"
 #include "common-cmds.h"
 #include "util/parse-options.h"
 #include "util/run-command.h"
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index b65eb050..400e92e 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1531,20 +1531,25 @@ int cmd_kvm(int argc, const char **argv, const char 
*prefix __maybe_unused)
 
if (!strncmp(argv[0], "rec", 3))
return __cmd_record(file_name, argc, argv);
-   else if (!strncmp(argv[0], "rep", 3))
+
+   if (!strncmp(argv[0], "rep", 3))
return __cmd_report(file_name, argc, argv);
-   else if (!strncmp(argv[0], "diff", 4))
+
+   if (!strncmp(argv[0], "diff", 4))
return cmd_diff(argc, argv, NULL);
- 

[PATCH v3 03/14] perf tools: Kbuild source related fixies

2014-10-23 Thread Alexis Berlemont
From: Jiri Olsa 

Fixing several sources config dependencies to allow
separate config builds.

This commit was originally created by Jiri Olsa in 2013. Minor changes
were needed to get it working one year later:
* Remove #ifdef directives related with GUI / TUI (because of code
  changes in ui/setup.c)
* Fix a link issue if the option BUILTIN_TRACE is disabled.
* Fix typo (CONFIG_BULTIN_ instead CONFIG_BUILTIN_)

Signed-off-by: Jiri Olsa 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Corey Ashford 
Cc: Frederic Weisbecker 
Cc: Namhyung Kim 
Cc: Borislav Petkov 
Cc: Michal Marek 
Cc: linux-kbu...@vger.kernel.org
Cc: Stephane Eranian 
Signed-off-by: Alexis Berlemont 
---
 tools/perf/builtin-annotate.c|  6 +++---
 tools/perf/builtin-lock.c|  5 -
 tools/perf/builtin-report.c  |  2 +-
 tools/perf/builtin-sched.c   |  3 +++
 tools/perf/builtin-top.c |  4 ++--
 tools/perf/perf.c| 10 --
 tools/perf/ui/browsers/scripts.c |  4 
 tools/perf/ui/setup.c|  6 +++---
 8 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 19cb967..a46af8f 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -155,7 +155,7 @@ find_next:
 
/* skip missing symbols */
nd = rb_next(nd);
-#ifdef CONFIG_TUI
+#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD)
} else if (use_browser == 1) {
struct rb_node *next = NULL;
key = hist_entry__tui_annotate(he, evsel, NULL);
@@ -303,9 +303,9 @@ int cmd_annotate(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_BOOLEAN('D', "dump-raw-trace", _trace,
"dump raw trace in ASCII"),
OPT_BOOLEAN(0, "gtk", _gtk, "Use the GTK interface"),
-#ifdef CONFIG_TUI
+#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD)
OPT_BOOLEAN(0, "tui", _tui, "Use the TUI interface"),
-#endif /* CONFIG_TUI */
+#endif
OPT_BOOLEAN(0, "stdio", _stdio, "Use the stdio interface"),
OPT_STRING('k', "vmlinux", _conf.vmlinux_name,
   "file", "vmlinux pathname"),
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index e7ec715..05c0e1c 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -1,4 +1,5 @@
 #include "builtin.h"
+#include "builtin-cmds.h"
 #include "perf.h"
 
 #include "util/evlist.h"
@@ -995,9 +996,11 @@ int cmd_lock(int argc, const char **argv, const char 
*prefix __maybe_unused)
usage_with_options(report_usage, 
report_options);
}
rc = __cmd_report(false);
+#ifdef CONFIG_BUILTIN_SCRIPT
} else if (!strcmp(argv[0], "script")) {
/* Aliased to 'perf script' */
-   return cmd_script(argc, argv, prefix);
+   rc = cmd_script(argc, argv, prefix);
+#endif
} else if (!strcmp(argv[0], "info")) {
if (argc) {
argc = parse_options(argc, argv,
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 00d93ff..b639e58 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -407,7 +407,7 @@ static int report__browse_hists(struct report *rep)
const char *help = "For a higher level overview, try: perf report 
--sort comm,dso";
 
switch (use_browser) {
-#ifdef CONFIG_TUI
+#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD)
case 1:
ret = perf_evlist__tui_browse_hists(evlist, help, NULL,
rep->min_percent,
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 891c393..e38b021 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1,4 +1,5 @@
 #include "builtin.h"
+#include "builtin-cmds.h"
 #include "perf.h"
 
 #include "util/util.h"
@@ -1742,11 +1743,13 @@ int cmd_sched(int argc, const char **argv, const char 
*prefix __maybe_unused)
if (!argc)
usage_with_options(sched_usage, sched_options);
 
+#ifdef CONFIG_BUILTIN_SCRIPT
/*
 * Aliased to 'perf script' for now:
 */
if (!strcmp(argv[0], "script"))
return cmd_script(argc, argv, prefix);
+#endif
 
if (!strncmp(argv[0], "rec", 3)) {
return __cmd_record(argc, argv);
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index a2ff8b7..6f04452 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -535,7 +535,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, 
int c)
return ret;
 }
 
-#ifdef CONFIG_TUI
+#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD)
 static void perf_top__sort_new_samples(void *arg)
 {
struct perf_top *t = arg;
@@ -981,7 +981,7 @@ static int 

[PATCH v3 12/14] perf kbuild: remove legacy script-related build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_LIBPERL (replaced by CONFIG_LIBPERL)
Remove NO_LIBPYTHON (replaced by CONFIG_LIBPYTHON)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/builtin-script.c |  6 +++--
 tools/perf/config/Makefile  | 41 +
 tools/perf/config/Makefile.fix-config   | 16 -
 tools/perf/config/Makefile.fix-legacy   |  8 ---
 tools/perf/util/trace-event-scripting.c | 13 ++-
 5 files changed, 22 insertions(+), 62 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9708a12..cc9c305 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1,3 +1,5 @@
+#include "generated/autoconf.h"
+
 #include "builtin.h"
 
 #include "perf.h"
@@ -1372,11 +1374,11 @@ int find_scripts(char **scripts_array, char 
**scripts_path_array)
for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) {
snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
 lang_dirent.d_name);
-#ifdef NO_LIBPERL
+#ifndef CONFIG_LIBPERL
if (strstr(lang_path, "perl"))
continue;
 #endif
-#ifdef NO_LIBPYTHON
+#ifndef CONFIG_LIBPYTHON
if (strstr(lang_path, "python"))
continue;
 #endif
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index f667229..00d118c 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -101,7 +101,7 @@ ifdef PARSER_DEBUG
   CFLAGS += -DPARSER_DEBUG
 endif
 
-ifndef NO_LIBPYTHON
+ifdef CONFIG_LIBPYTHON
   # Try different combinations to accommodate systems that only have
   # python[2][-config] in weird combinations but always preferring
   # python2 and python2-config as per pep-0394. If we catch a
@@ -460,9 +460,7 @@ endif
 grep-libs  = $(filter -l%,$(1))
 strip-libs = $(filter-out -l%,$(1))
 
-ifdef NO_LIBPERL
-  CFLAGS += -DNO_LIBPERL
-else
+ifdef CONFIG_LIBPERL
   PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
   PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
   PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
@@ -470,9 +468,8 @@ else
   FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 
   ifneq ($(feature-libperl), 1)
-CFLAGS += -DNO_LIBPERL
-NO_LIBPERL := 1
 msg := $(warning Missing perl devel files. Disabling perl scripting 
support, consider installing perl-ExtUtils-Embed);
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPERL)
   else
 LDFLAGS += $(PERL_EMBED_LDFLAGS)
 EXTLIBS += $(PERL_EMBED_LIBADD)
@@ -486,17 +483,14 @@ ifdef CONFIG_TIMERFD
   endif
 endif
 
-disable-python = $(eval $(disable-python_code))
-define disable-python_code
-  CFLAGS += -DNO_LIBPYTHON
-  $(if $(1),$(warning No $(1) was found))
-  $(warning Python support will not be built)
-  NO_LIBPYTHON := 1
-endef
+ifdef CONFIG_LIBPYTHON
 
-ifdef NO_LIBPYTHON
-  $(call disable-python)
-else
+  disable-python = $(eval $(disable-python_code))
+  define disable-python_code
+$(if $(1),$(warning No $(1) was found))
+$(warning Python support will not be built)
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPYTHON)
+  endef
 
   ifndef PYTHON
 $(call disable-python,python interpreter)
@@ -520,18 +514,7 @@ else
   else
 
 ifneq ($(feature-libpython-version), 1)
-  $(warning Python 3 is not yet supported; please set)
-  $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
-  $(warning If you also have Python 2 installed, then)
-  $(warning try something like:)
-  $(warning $(and ,))
-  $(warning $(and ,)  make PYTHON=python2)
-  $(warning $(and ,))
-  $(warning Otherwise, disable Python support entirely:)
-  $(warning $(and ,))
-  $(warning $(and ,)  make NO_LIBPYTHON=1)
-  $(warning $(and ,))
-  $(error   $(and ,))
+  $(call disable-python,python2 interpreter)
 else
   LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
   EXTLIBS += $(PYTHON_EMBED_LIBADD)
@@ -781,8 +764,6 @@ all:
$(call store,PYTHON_EMBED_CCOPTS)
$(call store,PERL_EMBED_CCOPTS)
$(call store,NO_LIBUNWIND)
-   $(call store,NO_LIBPERL)
-   $(call store,NO_LIBPYTHON)
$(call store,ETC_PERFCONFIG_SQ)
$(call store,DESTDIR_SQ)
$(call store,bindir_SQ)
diff --git a/tools/perf/config/Makefile.fix-config 
b/tools/perf/config/Makefile.fix-config
index e63539f..3f0e33e 100644
--- a/tools/perf/config/Makefile.fix-config
+++ b/tools/perf/config/Makefile.fix-config
@@ -3,20 +3,4 @@ include $(KCONFIG_CONFIG)
 
 CONFIG := $(srctree)/scripts/config --file $(KCONFIG_CONFIG)
 
-# NO_LIBPERL
-ifdef CONFIG_LIBPERL
-ifdef NO_LIBPERL
-dummy := $(info Disabling CONFIG_LIBPERL)
-dummy := $(shell $(CONFIG) -d CONFIG_LIBPERL)
-endif
-endif
-
-# NO_LIBPYTHON
-ifdef CONFIG_LIBPYTHON
-ifdef NO_LIBPYTHON
-dummy := $(info Disabling CONFIG_LIBPYTHON)
-dummy := $(shell 

[PATCH v3 00/14] Kbuild for perf

2014-10-23 Thread Alexis Berlemont
Hello,

Here is a proposal of perf's build process managed by Kbuild:
* The file Makefile.perf is replaced by Makefile.kbuild
* Makefile.kbuild generates a default .config file if none exists
  (allyesconfig)
* Makefile.kbuild adapts the .config file according to the
  features-check tests results
* Makefile.kbuild builds external dependencies (linux/tools/lib/*)
* Makefile.kbuild leaves the rest to Kbuild 

Regards,

Alexis.

Alexis Berlemont (11):
  kbuild: add support of custom paths for "auto.conf*" files
  perf kbuild: remove Makefile.perf
  perf kbuild: remove legacy tui/gui-related build variables
  perf kbuild: remove legacy demangle-related build variables
  perf kbuild: cross-compilation variables are now handled in Kconfig
  perf kbuild: remove legacy misc build variables
  perf kbuild: remove legacy libelf-related build variables
  perf kbuild: remove legacy libdwarf-related build variables
  perf kbuild: remove legacy script-related build variables
  perf kbuild: final cosmetic changes
  perf kbuild: add generated Kconfig build-test cases

Jiri Olsa (3):
  perf tools: Kbuild builtin source related fixies
  perf tools: Kbuild source related fixies
  perf tools: Add kbuild support into Makefile.kbuild

 scripts/Makefile.build |   3 +-
 scripts/kconfig/confdata.c |  23 +-
 scripts/kconfig/lkc.h  |   1 +
 tools/perf/Kbuild  |  47 +
 tools/perf/Kconfig | 436 ++
 tools/perf/MANIFEST|   1 +
 tools/perf/Makefile|   2 +-
 tools/perf/Makefile.kbuild | 443 ++
 tools/perf/Makefile.perf   | 949 -
 tools/perf/arch/Kbuild |   3 +
 tools/perf/arch/arm/Kbuild |   2 +
 tools/perf/arch/arm/Makefile   |  14 -
 tools/perf/arch/arm/tests/Kbuild   |   2 +
 tools/perf/arch/arm/util/Kbuild|   3 +
 tools/perf/arch/arm64/Kbuild   |   1 +
 tools/perf/arch/arm64/Makefile |   7 -
 tools/perf/arch/arm64/util/Kbuild  |   2 +
 tools/perf/arch/powerpc/Kbuild |   1 +
 tools/perf/arch/powerpc/Makefile   |   6 -
 tools/perf/arch/powerpc/util/Kbuild|   3 +
 tools/perf/arch/s390/Kbuild|   1 +
 tools/perf/arch/s390/Makefile  |   7 -
 tools/perf/arch/s390/util/Kbuild   |   2 +
 tools/perf/arch/sh/Kbuild  |   1 +
 tools/perf/arch/sh/Makefile|   4 -
 tools/perf/arch/sh/util/Kbuild |   1 +
 tools/perf/arch/sparc/Kbuild   |   1 +
 tools/perf/arch/sparc/Makefile |   4 -
 tools/perf/arch/sparc/util/Kbuild  |   1 +
 tools/perf/arch/x86/Kbuild |   2 +
 tools/perf/arch/x86/Makefile   |  19 -
 tools/perf/arch/x86/include/perf_regs.h|   8 +-
 tools/perf/arch/x86/tests/Kbuild   |   3 +
 tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c |   2 +-
 tools/perf/arch/x86/tests/regs_load.S  |   3 +-
 tools/perf/arch/x86/util/Kbuild|   6 +
 tools/perf/arch/x86/util/unwind-libunwind.c|   5 +-
 tools/perf/bench/Kbuild|  12 +
 tools/perf/bench/mem-memcpy-arch.h |   4 +-
 tools/perf/bench/mem-memcpy.c  |   4 +-
 tools/perf/bench/mem-memset-arch.h |   4 +-
 tools/perf/bench/mem-memset.c  |   4 +-
 tools/perf/builtin-annotate.c  |   8 +-
 tools/perf/builtin-bench.c |   5 +-
 tools/perf/builtin-help.c  |   1 +
 tools/perf/builtin-inject.c|   2 +-
 tools/perf/builtin-kvm.c   |  38 +-
 tools/perf/builtin-lock.c  |   5 +-
 tools/perf/builtin-probe.c |  15 +-
 tools/perf/builtin-record.c|   4 +-
 tools/perf/builtin-report.c|   3 +
 tools/perf/builtin-sched.c |   3 +
 tools/perf/builtin-script.c|   6 +-
 tools/perf/builtin-top.c   |  19 +-
 tools/perf/config/Makefile | 430 +-
 tools/perf/config/defconfig|  54 ++
 tools/perf/perf-sys.h  |   4 +-
 tools/perf/perf.c  |  53 +-
 tools/perf/scripts/perl/Perf-Trace-Util/Kbuild |   6 +
 tools/perf/scripts/python/Perf-Trace-Util/Kbuild   |   5 +
 tools/perf/tests/Kbuild|  40 +
 tools/perf/tests/builtin-test.c

[PATCH v3 01/14] kbuild: add support of custom paths for "auto.conf*" files

2014-10-23 Thread Alexis Berlemont
In the scripts/Makefile.build, use KCONFIG_AUTOCONFIG to include a
custom path for the "auto.conf" file.

The "*conf" programs were modified so as to work with the environment
variable KCONFIG_AUTOCONFIG.

Signed-off-by: Alexis Berlemont 
---
 scripts/Makefile.build |  3 ++-
 scripts/kconfig/confdata.c | 23 ++-
 scripts/kconfig/lkc.h  |  1 +
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 649ce68..2abb82f 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -31,7 +31,8 @@ subdir-asflags-y :=
 subdir-ccflags-y :=
 
 # Read auto.conf if it exists, otherwise ignore
--include include/config/auto.conf
+kconfig-autoconfig := $(if 
$(KCONFIG_AUTOCONFIG),$(KCONFIG_AUTOCONFIG),include/config/auto.conf)
+-include $(kconfig-autoconfig)
 
 include scripts/Kbuild.include
 
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..75cf6bf 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -75,6 +75,23 @@ const char *conf_get_autoconfig_name(void)
return name ? name : "include/config/auto.conf";
 }
 
+const char *conf_get_autoconfigdep_name(void)
+{
+   static char res_value[PATH_MAX+1];
+
+   const char *name = conf_get_autoconfig_name();
+
+   if (strlen(name) > PATH_MAX - 4)
+   name = NULL;
+   else {
+   strcpy(res_value, name);
+   strcat(res_value, ".cmd");
+   name = res_value;
+   }
+
+   return name;
+}
+
 static char *conf_expand_value(const char *in)
 {
struct symbol *sym;
@@ -953,7 +970,11 @@ int conf_write_autoconf(void)
 
sym_clear_all_valid();
 
-   file_write_dep("include/config/auto.conf.cmd");
+   name = conf_get_autoconfigdep_name();
+   if (name == NULL)
+   return 1;
+
+   file_write_dep(name);
 
if (conf_split_config())
return 1;
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index d5daa7a..ac99004 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -84,6 +84,7 @@ const char *zconf_curname(void);
 /* confdata.c */
 const char *conf_get_configname(void);
 const char *conf_get_autoconfig_name(void);
+const char *conf_get_autoconfigdep_name(void);
 char *conf_get_default_confname(void);
 void sym_set_change_count(int count);
 void sym_add_change_count(int count);
-- 
2.1.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 RFC 1/2] drivers: pci: fix window allocation order wrt bus_range filtering

2014-10-23 Thread Bjorn Helgaas
On Thu, Oct 23, 2014 at 04:23:06PM +0100, Lorenzo Pieralisi wrote:
> The number of windows allocated for the host bridge depends on the
> bus resource. Instead of first allocating the windows and then
> limit the bus resource, this patch reshuffles the code so that if any
> limitation is applied to the bus resource it is taken into account in
> the windows allocation.
> 
> Cc: Will Deacon 
> Signed-off-by: Lorenzo Pieralisi 

Hi Lorenzo,

I can *read* your patches just fine, but when I save them using mutt to
apply them, they look like this:

  --- a/drivers/pci/host/pci-host-generic.c
  +++ b/drivers/pci/host/pci-host-generic.c
  @@ -276,17 +276,17 @@ static int gen_pci_parse_map_cfg_windows(struct gen_p=
  ci *pci)
   =09=09return err;
=09}
=20
-=09pci->cfg.win =3D devm_kcalloc(dev,
resource_size(>cfg.bus_range),

I can work around this by downloading them another way, but it is a
bit of a hassle.  I *think* this is because your email has

  Content-Type: text/plain; charset=WINDOWS-1252

which apparently confuses mutt.  Any idea why this is?  Anybody know how I
can fix mutt to deal with this?

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


Regression: USB mouse only recognized w/o commit "ACPI / PM: Always enable wakeup GPEs ..."

2014-10-23 Thread Jörg-Volker Peetz
Hi,

on an HP Pavilion dv7 notebook with stable kernel 3.17.1 a USB mouse is only
recognized w/o commit f35cec27d1037ff0d772edfd6e7b1e92cdc0 "ACPI / PM:
Always enable wakeup GPES ...", config file attached.
Any idea?

Regards,
jvp.

#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 3.17.1 Kernel Configuration
#
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_HAVE_LATENCYTOP_SUPPORT=y
CONFIG_MMU=y
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_ARCH_HAS_CPU_RELAX=y
CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
CONFIG_HAVE_SETUP_PER_CPU_AREA=y
CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
CONFIG_ZONE_DMA32=y
CONFIG_AUDIT_ARCH=y
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_X86_64_SMP=y
CONFIG_X86_HT=y
CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx 
-fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 
-fcall-saved-r11"
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y

#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
# CONFIG_COMPILE_TEST is not set
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
CONFIG_KERNEL_GZIP=y
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set
CONFIG_DEFAULT_HOSTNAME="uruz"
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
CONFIG_SYSVIPC_SYSCTL=y
CONFIG_POSIX_MQUEUE=y
CONFIG_POSIX_MQUEUE_SYSCTL=y
CONFIG_CROSS_MEMORY_ATTACH=y
# CONFIG_FHANDLE is not set
# CONFIG_USELIB is not set
# CONFIG_AUDIT is not set
CONFIG_HAVE_ARCH_AUDITSYSCALL=y

#
# IRQ subsystem
#
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_GENERIC_IRQ_SHOW=y
CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ=y
CONFIG_GENERIC_PENDING_IRQ=y
CONFIG_IRQ_DOMAIN=y
# CONFIG_IRQ_DOMAIN_DEBUG is not set
CONFIG_IRQ_FORCED_THREADING=y
CONFIG_SPARSE_IRQ=y
CONFIG_CLOCKSOURCE_WATCHDOG=y
CONFIG_ARCH_CLOCKSOURCE_DATA=y
CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y
CONFIG_GENERIC_TIME_VSYSCALL=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y
CONFIG_GENERIC_CMOS_UPDATE=y

#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
# CONFIG_NO_HZ_FULL is not set
# CONFIG_NO_HZ is not set
CONFIG_HIGH_RES_TIMERS=y

#
# CPU/Task time and stats accounting
#
CONFIG_TICK_CPU_ACCOUNTING=y
# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set
# CONFIG_IRQ_TIME_ACCOUNTING is not set
CONFIG_BSD_PROCESS_ACCT=y
# CONFIG_BSD_PROCESS_ACCT_V3 is not set
# CONFIG_TASKSTATS is not set

#
# RCU Subsystem
#
CONFIG_TREE_RCU=y
# CONFIG_PREEMPT_RCU is not set
CONFIG_RCU_STALL_COMMON=y
# CONFIG_RCU_USER_QS is not set
CONFIG_RCU_FANOUT=64
CONFIG_RCU_FANOUT_LEAF=16
# CONFIG_RCU_FANOUT_EXACT is not set
# CONFIG_RCU_FAST_NO_HZ is not set
# CONFIG_TREE_RCU_TRACE is not set
# CONFIG_RCU_NOCB_CPU is not set
CONFIG_BUILD_BIN2C=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=17
CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
CONFIG_ARCH_SUPPORTS_INT128=y
CONFIG_ARCH_WANTS_PROT_NUMA_PROT_NONE=y
# CONFIG_NUMA_BALANCING is not set
# CONFIG_CGROUPS is not set
# CONFIG_CHECKPOINT_RESTORE is not set
CONFIG_NAMESPACES=y
# CONFIG_UTS_NS is not set
# CONFIG_IPC_NS is not set
# CONFIG_USER_NS is not set
# CONFIG_PID_NS is not set
# CONFIG_NET_NS is not set
# CONFIG_SCHED_AUTOGROUP is not set
# CONFIG_SYSFS_DEPRECATED is not set
# CONFIG_RELAY is not set
# CONFIG_BLK_DEV_INITRD is not set
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
CONFIG_SYSCTL=y
CONFIG_ANON_INODES=y
CONFIG_SYSCTL_EXCEPTION_TRACE=y
CONFIG_HAVE_PCSPKR_PLATFORM=y
# CONFIG_EXPERT is not set
CONFIG_SGETMASK_SYSCALL=y
CONFIG_SYSFS_SYSCALL=y
# CONFIG_SYSCTL_SYSCALL is not set
CONFIG_KALLSYMS=y
CONFIG_PRINTK=y
CONFIG_BUG=y
CONFIG_ELF_CORE=y
CONFIG_PCSPKR_PLATFORM=y
CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPOLL=y
CONFIG_SIGNALFD=y
CONFIG_TIMERFD=y
CONFIG_EVENTFD=y
CONFIG_SHMEM=y
CONFIG_AIO=y
CONFIG_PCI_QUIRKS=y
# CONFIG_EMBEDDED is not set
CONFIG_HAVE_PERF_EVENTS=y

#
# Kernel Performance Events And Counters
#

[PATCH v3 2/2] staging: skein: Adds Loadable Module Support

2014-10-23 Thread Eric Rost
Adds loadable module support for the Skein Hashing Algorithm.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  2 +-
 drivers/staging/skein/skein_generic.c | 19 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index de8bdd7..012a823 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,5 +1,5 @@
 config CRYPTO_SKEIN
-   bool "Skein digest algorithm"
+   tristate "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
select CRYPTO_HASH
select CRYPTO_ALGAPI
diff --git a/drivers/staging/skein/skein_generic.c 
b/drivers/staging/skein/skein_generic.c
index 815f9a4..3c9c6d0 100644
--- a/drivers/staging/skein/skein_generic.c
+++ b/drivers/staging/skein/skein_generic.c
@@ -16,6 +16,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include "skein_base.h"
 
@@ -142,6 +143,7 @@ static struct shash_alg alg256 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_256_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -159,6 +161,7 @@ static struct shash_alg alg512 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_512_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -176,6 +179,7 @@ static struct shash_alg alg1024 = {
.cra_driver_name=   "skein",
.cra_flags  =   CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize  =   SKEIN_1024_BLOCK_BYTES,
+   .cra_module =   THIS_MODULE,
}
 };
 
@@ -191,4 +195,17 @@ static int __init skein_generic_init(void)
return 0;
 }
 
-device_initcall(skein_generic_init);
+static void __exit skein_generic_fini(void)
+{
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+   crypto_unregister_shash();
+}
+
+module_init(skein_generic_init);
+module_exit(skein_generic_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Skein Hash Algorithm");
+
+MODULE_ALIAS("skein");
-- 
2.1.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 v3 1/2] staging: skein: Adds CryptoAPI Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI support for skein256, skein512, and skein1024
algorithms. Also collapses threefish algorithm into skein.o and removes
Kconfig option for Threefish.

Signed-off-by: Eric Rost 
---
 drivers/staging/skein/Kconfig |  22 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 194 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1444 insertions(+), 1259 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
index b9172bf..de8bdd7 100644
--- a/drivers/staging/skein/Kconfig
+++ b/drivers/staging/skein/Kconfig
@@ -1,8 +1,8 @@
 config CRYPTO_SKEIN
bool "Skein digest algorithm"
depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_THREEFISH
select CRYPTO_HASH
+   select CRYPTO_ALGAPI
help
  Skein secure hash algorithm is one of 5 finalists from the NIST SHA3
  competition.
@@ -12,21 +12,5 @@ config CRYPTO_SKEIN
 
  http://www.skein-hash.info/sites/default/files/skein1.3.pdf
 
- for more information.  This module depends on the threefish block
- cipher module.
-
-config CRYPTO_THREEFISH
-   bool "Threefish tweakable block cipher"
-   depends on (X86 || UML_X86) && 64BIT && CRYPTO
-   select CRYPTO_ALGAPI
-   help
- Threefish cipher algorithm is the tweakable block cipher underneath
- the Skein family of secure hash algorithms.  Skein is one of 5
- finalists from the NIST SHA3 competition.
-
- Skein is optimized for modern, 64bit processors and is highly
- customizable.  See:
-
- http://www.skein-hash.info/sites/default/files/skein1.3.pdf
-
- for more information.
+ for more information. This module also contains the threefish block
+ cipher algorithm.
diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
index a14aadd..66c8799 100644
--- a/drivers/staging/skein/Makefile
+++ b/drivers/staging/skein/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the skein secure hash algorithm
 #
-obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
-   skein_api.o \
-   skein_block.o
-
-obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
- threefish_api.o
+obj-$(CONFIG_CRYPTO_SKEIN) += skein.o
+skein-y := skein_base.o \
+   skein_api.o \
+   skein_block.o \
+   threefish_block.o \
+   threefish_api.o \
+   skein_generic.o
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
deleted file mode 100644
index 8cc8358..000
--- a/drivers/staging/skein/skein.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***
-**
-** Implementation of the Skein hash function.
-**
-** Source code author: Doug Whiting, 2008.
-**
-** This algorithm and source code is released to the public domain.
-**
-/
-
-#define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
-
-#include/* get the memcpy/memset functions */
-#include "skein.h" /* get the Skein API definitions   */
-#include "skein_iv.h"/* get precomputed IVs */
-#include "skein_block.h"
-
-/*/
-/* 256-bit Skein */
-/*/
-
-/**/
-/* init the context for a straight hashing operation  */
-int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len)
-{
-   union {
-   u8 b[SKEIN_256_STATE_BYTES];
-   u64 w[SKEIN_256_STATE_WORDS];
-   } cfg;  /* config block */
-
-   skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN);
-   ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */
-
-   switch (hash_bit_len) { /* use pre-computed values, where available */
-   case  256:
-   memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x));
-   break;
-   case  

[PATCH v3 0/2] staging: skein: Adds CryptoAPI and Module Support

2014-10-23 Thread Eric Rost
Adds CryptoAPI and Loadable Module support to the Skein Hashing
Algorithm.

Eric Rost (2):
  staging: skein: Adds CryptoAPI Support
  staging: skein: Adds Loadable Module Support

 drivers/staging/skein/Kconfig |  24 +-
 drivers/staging/skein/Makefile|  13 +-
 drivers/staging/skein/skein.c | 883 -
 drivers/staging/skein/skein.h | 346 -
 drivers/staging/skein/skein_api.h |   2 +-
 drivers/staging/skein/skein_base.c| 884 ++
 drivers/staging/skein/skein_base.h| 351 ++
 drivers/staging/skein/skein_block.c   |   2 +-
 drivers/staging/skein/skein_block.h   |   2 +-
 drivers/staging/skein/skein_generic.c | 211 
 drivers/staging/skein/skein_iv.h  |   2 +-
 drivers/staging/skein/threefish_api.h |   2 +-
 12 files changed, 1462 insertions(+), 1260 deletions(-)
 delete mode 100644 drivers/staging/skein/skein.c
 delete mode 100644 drivers/staging/skein/skein.h
 create mode 100644 drivers/staging/skein/skein_base.c
 create mode 100644 drivers/staging/skein/skein_base.h
 create mode 100644 drivers/staging/skein/skein_generic.c

-- 
2.1.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 1/1 net-next] Bluetooth: fix shadow warning in hci_disconnect()

2014-10-23 Thread Marcel Holtmann
Hi Fabian,

>>> use cpr for hci_cp_read_clock_offset instead of cp
>>> (already defined above).
>>> 
>>> Signed-off-by: Fabian Frederick 
>>> ---
>>> net/bluetooth/hci_conn.c | 6 +++---
>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>> 
>>> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
>>> index b9517bd..6151e09 100644
>>> --- a/net/bluetooth/hci_conn.c
>>> +++ b/net/bluetooth/hci_conn.c
>>> @@ -141,10 +141,10 @@ int hci_disconnect(struct hci_conn *conn, __u8 reason)
>>>   */
>>>  if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER) {
>>>  struct hci_dev *hdev = conn->hdev;
>>> -   struct hci_cp_read_clock_offset cp;
>>> +   struct hci_cp_read_clock_offset cpr;
>>> 
>>> -   cp.handle = cpu_to_le16(conn->handle);
>>> -   hci_send_cmd(hdev, HCI_OP_READ_CLOCK_OFFSET, sizeof(cp), );
>>> +   cpr.handle = cpu_to_le16(conn->handle);
>>> +   hci_send_cmd(hdev, HCI_OP_READ_CLOCK_OFFSET, sizeof(cpr), );
>> 
>> valid change, but I do not like cpr as variable name. We need to come up with
>> a better one. There are other places in the code where we had the same thing.
>> Please have a look there.
> 
>   Maybe read_cp (like commit c1f23a2bfc89 with struct hci_cp_auth_requested
> auth_cp) ?

lets use clkoff_cp unless someone comes up with a better name.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: localed stuck in recent 3.18 git in copy_net_ns?

2014-10-23 Thread Paul E. McKenney
On Fri, Oct 24, 2014 at 12:45:40AM +0300, Yanko Kaneti wrote:
> 
> On Thu, 2014-10-23 at 13:05 -0700, Paul E. McKenney wrote:
> > On Thu, Oct 23, 2014 at 10:51:59PM +0300, Yanko Kaneti wrote:
> > > On Thu-10/23/14-2014 08:33, Paul E. McKenney wrote:
> > > > On Thu, Oct 23, 2014 at 05:27:50AM -0700, Paul E. McKenney wrote:
> > > > > On Thu, Oct 23, 2014 at 09:09:26AM +0300, Yanko Kaneti wrote:
> > > > > > On Wed, 2014-10-22 at 16:24 -0700, Paul E. McKenney wrote:
> > > > > > > On Thu, Oct 23, 2014 at 01:40:32AM +0300, Yanko Kaneti 
> > > > > > > wrote:
> > > > > > > > On Wed-10/22/14-2014 15:33, Josh Boyer wrote:
> > > > > > > > > On Wed, Oct 22, 2014 at 2:55 PM, Paul E. McKenney
> > > > > > > > >  wrote:
> > > > > > > 
> > > > > > > [ . . . ]
> > > > > > > 
> > > > > > > > > > Don't get me wrong -- the fact that this kthread 
> > > > > > > > > > appears to
> > > > > > > > > > have
> > > > > > > > > > blocked within rcu_barrier() for 120 seconds means 
> > > > > > > > > > that
> > > > > > > > > > something is
> > > > > > > > > > most definitely wrong here.  I am surprised that 
> > > > > > > > > > there are no
> > > > > > > > > > RCU CPU
> > > > > > > > > > stall warnings, but perhaps the blockage is in the 
> > > > > > > > > > callback
> > > > > > > > > > execution
> > > > > > > > > > rather than grace-period completion.  Or something is
> > > > > > > > > > preventing this
> > > > > > > > > > kthread from starting up after the wake-up callback 
> > > > > > > > > > executes.
> > > > > > > > > > Or...
> > > > > > > > > > 
> > > > > > > > > > Is this thing reproducible?
> > > > > > > > > 
> > > > > > > > > I've added Yanko on CC, who reported the backtrace 
> > > > > > > > > above and can
> > > > > > > > > recreate it reliably.  Apparently reverting the RCU 
> > > > > > > > > merge commit
> > > > > > > > > (d6dd50e) and rebuilding the latest after that does 
> > > > > > > > > not show the
> > > > > > > > > issue.  I'll let Yanko explain more and answer any 
> > > > > > > > > questions you
> > > > > > > > > have.
> > > > > > > > 
> > > > > > > > - It is reproducible
> > > > > > > > - I've done another build here to double check and its 
> > > > > > > > definitely
> > > > > > > > the rcu merge
> > > > > > > >   that's causing it.
> > > > > > > > 
> > > > > > > > Don't think I'll be able to dig deeper, but I can do 
> > > > > > > > testing if
> > > > > > > > needed.
> > > > > > > 
> > > > > > > Please!  Does the following patch help?
> > > > > > 
> > > > > > Nope, doesn't seem to make a difference to the modprobe 
> > > > > > ppp_generic
> > > > > > test
> > > > > 
> > > > > Well, I was hoping.  I will take a closer look at the RCU 
> > > > > merge commit
> > > > > and see what suggests itself.  I am likely to ask you to 
> > > > > revert specific
> > > > > commits, if that works for you.
> > > > 
> > > > Well, rather than reverting commits, could you please try 
> > > > testing the
> > > > following commits?
> > > > 
> > > > 11ed7f934cb8 (rcu: Make nocb leader kthreads process pending 
> > > > callbacks after spawning)
> > > > 
> > > > 73a860cd58a1 (rcu: Replace flush_signals() with 
> > > > WARN_ON(signal_pending()))
> > > > 
> > > > c847f14217d5 (rcu: Avoid misordering in nocb_leader_wait())
> > > > 
> > > > For whatever it is worth, I am guessing this one.
> > > 
> > > Indeed, c847f14217d5 it is.
> > > 
> > > Much to my embarrasment I just noticed that in addition to the
> > > rcu merge, triggering the bug "requires" my specific Fedora 
> > > rawhide network
> > > setup. Booting in single mode and modprobe ppp_generic is fine. 
> > > The bug
> > > appears when starting with my regular fedora network setup, which 
> > > in my case
> > > includes 3 ethernet adapters and a libvirt birdge+nat setup.
> > > 
> > > Hope that helps.
> > > 
> > > I am attaching the config.
> > 
> > It does help a lot, thank you!!!
> > 
> > The following patch is a bit of a shot in the dark, and assumes that
> > commit 1772947bd012 (rcu: Handle NOCB callbacks from irq-disabled 
> > idle
> > code) introduced the problem.  Does this patch fix things up?
> 
> Unfortunately not, This is linus-tip + patch

OK.  Can't have everything, I guess.

> INFO: task kworker/u16:6:96 blocked for more than 120 seconds.
>   Not tainted 3.18.0-rc1+ #4
> "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> kworker/u16:6   D 8800ca84cec0 1116896  2 0x
> Workqueue: netns cleanup_net
>  8802218339e8 0096 8800ca84cec0 001d5f00
>  880221833fd8 001d5f00 880223264ec0 8800ca84cec0
>  82c52040 7fff 81ee2658 81ee2650
> Call Trace:
>  [] schedule+0x29/0x70
>  [] schedule_timeout+0x26c/0x410
>  [] ? native_sched_clock+0x2a/0xa0
>  [] ? mark_held_locks+0x7c/0xb0
>  [] ? _raw_spin_unlock_irq+0x30/0x50
>  [] ? trace_hardirqs_on_caller+0x15d/0x200
>  [] wait_for_completion+0x10c/0x150
>  [] ? wake_up_state+0x20/0x20
>  [] 

[PATCH v2 05/14] perf kbuild: remove Makefile.perf

2014-10-23 Thread Alexis Berlemont
The file Makefile.perf contained legacy build rules. It is replaced by
Makefile.kbuild which relies on Kbuild. Consequently, some minor
points need updates:
* The constant CONFIG_KBUILD can be removed
* The main Makefile wrapper now call Makefile.kbuild instead of
  Makefile.perf

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Makefile   |   2 +-
 tools/perf/Makefile.kbuild|   2 +-
 tools/perf/Makefile.perf  | 949 --
 tools/perf/builtin-annotate.c |   4 +-
 tools/perf/builtin-cmds.h |  25 --
 tools/perf/builtin-report.c   |   2 +-
 tools/perf/builtin-top.c  |   4 +-
 tools/perf/ui/setup.c |   4 +-
 8 files changed, 9 insertions(+), 983 deletions(-)
 delete mode 100644 tools/perf/Makefile.perf

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index cb2e586..4512f16 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -55,7 +55,7 @@ define print_msg
 endef
 
 define make
-  @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) 
$(SET_DEBUG) $@
+  @$(MAKE) -f Makefile.kbuild --no-print-directory -j$(JOBS) O=$(FULL_O) 
$(SET_DEBUG) $@
 endef
 
 #
diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild
index 51eba07..8d9e8b0 100644
--- a/tools/perf/Makefile.kbuild
+++ b/tools/perf/Makefile.kbuild
@@ -43,7 +43,7 @@ export QUIET_BISON QUIET_FLEX
 
 ifeq ($(KBUILD_SRC),)
 
-ifeq ("$(origin O)", "command line")
+ifneq ($(O),)
 KBUILD_OUTPUT := $(O)
 else
 KBUILD_OUTPUT := $(objtree)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
deleted file mode 100644
index dcf6248..000
--- a/tools/perf/Makefile.perf
+++ /dev/null
@@ -1,949 +0,0 @@
-include ../scripts/Makefile.include
-
-# The default target of this Makefile is...
-all:
-
-include config/utilities.mak
-
-# Define V to have a more verbose compile.
-#
-# Define VF to have a more verbose feature check output.
-#
-# Define O to save output files in a separate directory.
-#
-# Define ARCH as name of target architecture if you want cross-builds.
-#
-# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
-#
-# Define NO_LIBPERL to disable perl script extension.
-#
-# Define NO_LIBPYTHON to disable python script extension.
-#
-# Define PYTHON to point to the python binary if the default
-# `python' is not correct; for example: PYTHON=python2
-#
-# Define PYTHON_CONFIG to point to the python-config binary if
-# the default `$(PYTHON)-config' is not correct.
-#
-# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
-#
-# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL 
v1.72.
-#
-# Define LDFLAGS=-static to build a static binary.
-#
-# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for 
cross-builds.
-#
-# Define NO_DWARF if you do not want debug-info analysis feature at all.
-#
-# Define WERROR=0 to disable treating any warnings as errors.
-#
-# Define NO_NEWT if you do not want TUI support. (deprecated)
-#
-# Define NO_SLANG if you do not want TUI support.
-#
-# Define NO_GTK2 if you do not want GTK+ GUI support.
-#
-# Define NO_DEMANGLE if you do not want C++ symbol demangling.
-#
-# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
-#
-# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf
-# backtrace post unwind.
-#
-# Define NO_BACKTRACE if you do not want stack backtrace debug feature
-#
-# Define NO_LIBNUMA if you do not want numa perf benchmark
-#
-# Define NO_LIBAUDIT if you do not want libaudit support
-#
-# Define NO_LIBBIONIC if you do not want bionic support
-#
-# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
-# for dwarf backtrace post unwind.
-
-ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(shell pwd)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-#$(info Determined 'srctree' to be $(srctree))
-endif
-
-ifneq ($(objtree),)
-#$(info Determined 'objtree' to be $(objtree))
-endif
-
-ifneq ($(OUTPUT),)
-#$(info Determined 'OUTPUT' to be $(OUTPUT))
-endif
-
-$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
-   @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
-   @touch $(OUTPUT)PERF-VERSION-FILE
-
-CC = $(CROSS_COMPILE)gcc
-AR = $(CROSS_COMPILE)ar
-PKG_CONFIG = $(CROSS_COMPILE)pkg-config
-
-RM  = rm -f
-LN  = ln -f
-MKDIR   = mkdir
-FIND= find
-INSTALL = install
-FLEX= flex
-BISON   = bison
-STRIP   = strip
-
-LIB_DIR  = $(srctree)/tools/lib/api/
-TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
-
-# include config/Makefile by default and rule out
-# non-config cases
-config := 1
-
-NON_CONFIG_TARGETS := clean TAGS tags cscope help
-
-ifdef MAKECMDGOALS
-ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
-  config := 0
-endif
-endif
-
-ifeq ($(config),1)
-include config/Makefile
-endif
-
-export prefix bindir sharedir sysconfdir DESTDIR
-
-# sparse is architecture-neutral, which means that we need to tell it
-# explicitly what architecture to 

[PATCH v2 00/14] Kbuild for perf

2014-10-23 Thread Alexis Berlemont
Hello,

Here is a proposal of perf's build process managed by Kbuild:
* The file Makefile.perf is replaced by Makefile.kbuild
* Makefile.kbuild generates a default .config file if none exists
  (allyesconfig)
* Makefile.kbuild adapts the .config file according to the
  features-check tests results
* Makefile.kbuild builds external dependencies (linux/tools/lib/*)
* Makefile.kbuild leaves the rest to Kbuild 

Regards,

Alexis.

Alexis Berlemont (11):
  kbuild: add support of custom paths for "auto.conf*" files
  perf kbuild: remove Makefile.perf
  perf kbuild: remove legacy tui/gui-related build variables
  perf kbuild: remove legacy demangle-related build variables
  perf kbuild: cross-compilation variables are now handled in Kconfig
  perf kbuild: remove legacy misc build variables
  perf kbuild: remove legacy libelf-related build variables
  perf kbuild: remove legacy libdwarf-related build variables
  perf kbuild: remove legacy script-related build variables
  perf kbuild: final cosmetic changes
  perf kbuild: add generated Kconfig build-test cases

Jiri Olsa (3):
  perf tools: Kbuild builtin source related fixies
  perf tools: Kbuild source related fixies
  perf tools: Add kbuild support into Makefile.kbuild

 scripts/Makefile.build |   3 +-
 scripts/kconfig/confdata.c |  23 +-
 scripts/kconfig/lkc.h  |   1 +
 tools/perf/Kbuild  |  47 +
 tools/perf/Kconfig | 436 ++
 tools/perf/MANIFEST|   1 +
 tools/perf/Makefile|   2 +-
 tools/perf/Makefile.kbuild | 443 ++
 tools/perf/Makefile.perf   | 949 -
 tools/perf/arch/Kbuild |   3 +
 tools/perf/arch/arm/Kbuild |   2 +
 tools/perf/arch/arm/Makefile   |  14 -
 tools/perf/arch/arm/tests/Kbuild   |   2 +
 tools/perf/arch/arm/util/Kbuild|   3 +
 tools/perf/arch/arm64/Kbuild   |   1 +
 tools/perf/arch/arm64/Makefile |   7 -
 tools/perf/arch/arm64/util/Kbuild  |   2 +
 tools/perf/arch/powerpc/Kbuild |   1 +
 tools/perf/arch/powerpc/Makefile   |   6 -
 tools/perf/arch/powerpc/util/Kbuild|   3 +
 tools/perf/arch/s390/Kbuild|   1 +
 tools/perf/arch/s390/Makefile  |   7 -
 tools/perf/arch/s390/util/Kbuild   |   2 +
 tools/perf/arch/sh/Kbuild  |   1 +
 tools/perf/arch/sh/Makefile|   4 -
 tools/perf/arch/sh/util/Kbuild |   1 +
 tools/perf/arch/sparc/Kbuild   |   1 +
 tools/perf/arch/sparc/Makefile |   4 -
 tools/perf/arch/sparc/util/Kbuild  |   1 +
 tools/perf/arch/x86/Kbuild |   2 +
 tools/perf/arch/x86/Makefile   |  19 -
 tools/perf/arch/x86/include/perf_regs.h|   8 +-
 tools/perf/arch/x86/tests/Kbuild   |   3 +
 tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c |   2 +-
 tools/perf/arch/x86/tests/regs_load.S  |   3 +-
 tools/perf/arch/x86/util/Kbuild|   6 +
 tools/perf/arch/x86/util/unwind-libunwind.c|   5 +-
 tools/perf/bench/Kbuild|  12 +
 tools/perf/bench/mem-memcpy-arch.h |   4 +-
 tools/perf/bench/mem-memcpy.c  |   4 +-
 tools/perf/bench/mem-memset-arch.h |   4 +-
 tools/perf/bench/mem-memset.c  |   4 +-
 tools/perf/builtin-annotate.c  |   8 +-
 tools/perf/builtin-bench.c |   5 +-
 tools/perf/builtin-help.c  |   1 +
 tools/perf/builtin-inject.c|   2 +-
 tools/perf/builtin-kvm.c   |  38 +-
 tools/perf/builtin-lock.c  |   5 +-
 tools/perf/builtin-probe.c |  15 +-
 tools/perf/builtin-record.c|   4 +-
 tools/perf/builtin-report.c|   3 +
 tools/perf/builtin-sched.c |   3 +
 tools/perf/builtin-script.c|   6 +-
 tools/perf/builtin-top.c   |  19 +-
 tools/perf/config/Makefile | 430 +-
 tools/perf/config/defconfig|  54 ++
 tools/perf/perf-sys.h  |   4 +-
 tools/perf/perf.c  |  53 +-
 tools/perf/scripts/perl/Perf-Trace-Util/Kbuild |   6 +
 tools/perf/scripts/python/Perf-Trace-Util/Kbuild   |   5 +
 tools/perf/tests/Kbuild|  40 +
 tools/perf/tests/builtin-test.c

[PATCH v2 04/14] perf tools: Add kbuild support into Makefile.kbuild

2014-10-23 Thread Alexis Berlemont
From: Jiri Olsa 

Adding kbuild support into Makefile.kbuild. The 'legacy'
Makefile still stays untouched as it was.

It's possible to use kbuild by running 'make -f Makefile.kbuild'
with any option supported by 'legacy' Makefile.

We now have 2 config files:
  '.config' - user configured setup
  '.config-detected' - system detected setup

The '.config-detected' affects '.config' and if there's
configured feature in '.config' which was not detected
it is automatically disabled.

The '.config-detected' is re/created if:
  - there's no '.config-detected'
  - '.config' was changed

In a cleaned tree the perf is built with 'allyesconfig'
having disabled all non-detected features, just as it is
done now.

You can change '.config' via:
  make -f Makefile.kbuild menuconfig

There's difference for O=DIR build. The DIR is populated
based on kernel source tree, so the final binary is created
under DIR/tools/perf.

This commit was originally created by Jiri Olsa in February 2013; a
few changes were necessary to fit the perf version of June 2014:
* Add missing CFLAGS for specific .o targets
* Update Kbuild files (new source files, ...)
* Fix recursive invocation of config/features-checks
* Store .config-detected missing variables (libdir, ...)
* Fix missing dependencies between Kconfig options
* Fix installation of traceevent plugins
* Fix missing cleanings of feature-check binaries
* CROSS_COMPILE was not used to define AS, CC, ...
* CROSS_COMPILE was not stored in .config-detected
* Take into account DESTDIR and prefix set in the command line
* Add missing Kbuild files for non-x86 architectures
  (powerpc, arm, arm64, sh, s390, sparc)
* Move perf-time-to-tsc.c into x86-specific tests directory

Signed-off-by: Jiri Olsa 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Corey Ashford 
Cc: Frederic Weisbecker 
Cc: Namhyung Kim 
Cc: Borislav Petkov 
Cc: Michal Marek 
Cc: linux-kbu...@vger.kernel.org
Cc: Stephane Eranian 
Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kbuild  |  47 +++
 tools/perf/Kconfig | 284 ++
 tools/perf/Makefile.kbuild | 431 +
 tools/perf/Makefile.perf   |   2 +-
 tools/perf/arch/Kbuild |   3 +
 tools/perf/arch/arm/Kbuild |   2 +
 tools/perf/arch/arm/Makefile   |  14 -
 tools/perf/arch/arm/tests/Kbuild   |   2 +
 tools/perf/arch/arm/util/Kbuild|   3 +
 tools/perf/arch/arm64/Kbuild   |   1 +
 tools/perf/arch/arm64/Makefile |   7 -
 tools/perf/arch/arm64/util/Kbuild  |   2 +
 tools/perf/arch/powerpc/Kbuild |   1 +
 tools/perf/arch/powerpc/Makefile   |   6 -
 tools/perf/arch/powerpc/util/Kbuild|   3 +
 tools/perf/arch/s390/Kbuild|   1 +
 tools/perf/arch/s390/Makefile  |   7 -
 tools/perf/arch/s390/util/Kbuild   |   2 +
 tools/perf/arch/sh/Kbuild  |   1 +
 tools/perf/arch/sh/Makefile|   4 -
 tools/perf/arch/sh/util/Kbuild |   1 +
 tools/perf/arch/sparc/Kbuild   |   1 +
 tools/perf/arch/sparc/Makefile |   4 -
 tools/perf/arch/sparc/util/Kbuild  |   1 +
 tools/perf/arch/x86/Kbuild |   1 +
 tools/perf/arch/x86/tests/Kbuild   |   3 +
 tools/perf/{ => arch/x86}/tests/perf-time-to-tsc.c |   0
 tools/perf/arch/x86/util/Kbuild|   5 +
 tools/perf/bench/Kbuild|  12 +
 tools/perf/builtin-cmds.h  |   4 +
 tools/perf/config/Makefile |  55 ++-
 tools/perf/config/Makefile.fix-config  | 104 +
 tools/perf/config/Makefile.fix-legacy  |  46 +++
 tools/perf/config/defconfig|  54 +++
 tools/perf/perf-sys.h  |   4 +-
 tools/perf/scripts/perl/Perf-Trace-Util/Kbuild |   6 +
 tools/perf/scripts/python/Perf-Trace-Util/Kbuild   |   5 +
 tools/perf/tests/Kbuild|  38 ++
 tools/perf/ui/Kbuild   |  15 +
 tools/perf/ui/browsers/Kbuild  |   9 +
 tools/perf/ui/gtk/Kbuild   |   9 +
 tools/perf/ui/stdio/Kbuild |   1 +
 tools/perf/ui/tui/Kbuild   |   4 +
 tools/perf/util/Kbuild | 125 ++
 tools/perf/util/PERF-VERSION-GEN   |   4 +
 tools/perf/util/generate-cmdlist.sh|   8 +-
 tools/perf/util/scripting-engines/Kbuild   |  11 +
 tools/perf/util/setup.py   |   8 +-
 48 files changed, 1309 insertions(+), 52 

[PATCH v2 06/14] perf kbuild: remove legacy tui/gui-related build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_SLANG (replaced by CONFIG_LIBSLANG)
Remove HAVE_SLANG_SUPPORT from CFLAGS (replaced by CONFIG_LIBSLANG)
Remove NO_GTK2 (replaced by CONFIG_LIBGTK2 or CONFIG_GTK2)
Remove HAVE_GTK2_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2)
Remove HAVE_GTK_INFO_BAR_SUPPORT from CFLAGS (replaced by
CONFIG_LIBGTK2_INFOBAR)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig| 21 +
 tools/perf/config/Makefile| 20 ++--
 tools/perf/config/Makefile.fix-config | 24 
 tools/perf/config/Makefile.fix-legacy |  8 
 tools/perf/ui/gtk/browser.c   |  4 +++-
 tools/perf/ui/gtk/gtk.h   |  5 +++--
 tools/perf/ui/gtk/util.c  |  6 --
 tools/perf/ui/setup.c |  4 +++-
 tools/perf/ui/ui.h|  4 +++-
 tools/perf/util/annotate.h|  4 +++-
 tools/perf/util/hist.h|  3 ++-
 11 files changed, 48 insertions(+), 55 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index f9fcf9e..eb59567 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -171,6 +171,7 @@ config STDIO
 
 config TUI
bool "Tui (slang based)"
+   depends on LIBSLANG
default y
 ---help---
  Text-based user interface which provides windowing
@@ -179,6 +180,7 @@ config TUI
 config GTK2
bool "Gtk2"
default y
+   depends on LIBGTK2
 ---help---
  Elaborate display mode based on libgtk2.
 
@@ -186,12 +188,31 @@ endmenu
 
 menu "Libraries / Dependencies"
 
+config LIBSLANG
+   bool "Slang (libslang)"
+   default y
+---help---
+ libslang
+
 config LIBAUDIT
bool "Audit (libaudit)"
default y
 ---help---
  Linux audit framework dependency.
 
+config LIBGTK2
+   bool "Gtk2 (libgtk2)"
+   default y
+---help---
+ libgtk2
+
+config LIBGTK2_INFOBAR
+   bool "Gtk2 infobar (libgtk2)"
+   depends on LIBGTK2
+   default y
+---help---
+ libgtk2-infobar
+
 config LIBPERL
bool "Perl"
default y
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 6106e24..27b092c 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -445,32 +445,26 @@ ifndef NO_LIBAUDIT
   endif
 endif
 
-ifdef NO_NEWT
-  NO_SLANG=1
-endif
-
-ifndef NO_SLANG
+ifdef CONFIG_LIBSLANG
   ifneq ($(feature-libslang), 1)
-msg := $(warning slang not found, disables TUI support. Please install 
slang-devel or libslang-dev);
-NO_SLANG := 1
+msg := $(warning slang not found, disables SLANG and TUI supports. Please 
install slang-devel or libslang-dev);
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBSLANG)
   else
 # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
 CFLAGS += -I/usr/include/slang
-CFLAGS += -DHAVE_SLANG_SUPPORT
 EXTLIBS += -lslang
   endif
 endif
 
-ifndef NO_GTK2
+ifdef CONFIG_LIBGTK2
   FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs 
--cflags gtk+-2.0 2>/dev/null)
   ifneq ($(feature-gtk2), 1)
 msg := $(warning GTK2 not found, disables GTK2 support. Please install 
gtk2-devel or libgtk2.0-dev);
-NO_GTK2 := 1
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2)
   else
 ifeq ($(feature-gtk2-infobar), 1)
-  GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBGTK2_INFOBAR)
 endif
-CFLAGS += -DHAVE_GTK2_SUPPORT
 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
 EXTLIBS += -ldl
@@ -801,8 +795,6 @@ all:
$(call store,NO_LIBUNWIND)
$(call store,NO_LIBPERL)
$(call store,NO_LIBPYTHON)
-   $(call store,NO_NEWT)
-   $(call store,NO_GTK2)
$(call store,NO_DEMANGLE)
$(call store,NO_LIBELF)
$(call store,NO_LIBUNWIND)
diff --git a/tools/perf/config/Makefile.fix-config 
b/tools/perf/config/Makefile.fix-config
index 7f65fdb..3d84008 100644
--- a/tools/perf/config/Makefile.fix-config
+++ b/tools/perf/config/Makefile.fix-config
@@ -19,30 +19,6 @@ dummy := $(shell $(CONFIG) -d CONFIG_LIBPYTHON)
 endif
 endif
 
-# NO_NEWT
-ifdef CONFIG_TUI
-ifdef NO_NEWT
-dummy := $(info Disabling CONFIG_TUI)
-dummy := $(shell $(CONFIG) -d CONFIG_TUI)
-endif
-endif
-
-# NO_NEWT
-ifdef CONFIG_TUI
-ifdef NO_SLANG
-dummy := $(info Disabling CONFIG_TUI)
-dummy := $(shell $(CONFIG) -d CONFIG_TUI)
-endif
-endif
-
-# NO_GTK2
-ifdef CONFIG_GTK2
-ifdef NO_GTK2
-dummy := $(info Disabling CONFIG_GTK2)
-dummy := $(shell $(CONFIG) -d CONFIG_GTK2)
-endif
-endif
-
 # NO_DEMANGLE
 ifdef CONFIG_DEMANGLE
 ifdef NO_DEMANGLE
diff --git a/tools/perf/config/Makefile.fix-legacy 
b/tools/perf/config/Makefile.fix-legacy
index 2ec91f3..ca219e7 100644
--- a/tools/perf/config/Makefile.fix-legacy
+++ b/tools/perf/config/Makefile.fix-legacy
@@ -9,14 +9,6 @@ 

[PATCH v2 07/14] perf kbuild: remove legacy demangle-related build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_DEMANGLE (replaced by CONFIG_DEMANGLE)
Remove HAVE_LIBBFD_SUPPORT (replaced by CONFIG_LIBBFD)
Remove HAVE_CPLUS_DEMANGLE_SUPPORT (replaced by CONFIG_LIBIBERTY_ONLY)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig| 36 +--
 tools/perf/config/Makefile| 46 ++-
 tools/perf/config/Makefile.fix-legacy |  4 ---
 tools/perf/util/srcline.c |  8 +++---
 tools/perf/util/symbol.h  | 25 +--
 5 files changed, 75 insertions(+), 44 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index eb59567..026ef67 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -225,6 +225,35 @@ config LIBPYTHON
 ---help---
  Libpython dependency needed by the perf script feature.
 
+config TIMERFD
+   bool "Timer via file descriptor"
+   default y
+---help---
+ Timer via file descriptor
+
+config DEMANGLE
+   bool "Demangle symbols"
+   default y
+---help---
+ Enable demangling so as to display human-readable
+ symbols. This option is convenient with C++ programs.
+
+choice DEMANGLE_DEPS
+   prompt "Demangle dependency(ies)"
+   depends on DEMANGLE
+   default LIBBFD
+
+config LIBBFD
+   bool "BFD + libiberty libraries"
+---help---
+ Binary File Descriptor and libiberty libraries
+
+config LIBIBERTY_ONLY
+   bool "Libiberty only"
+---help---
+ Libiberty
+endchoice
+
 choice
prompt "Elf library"
default LIBELF
@@ -266,13 +295,6 @@ config NUMA
  The library libnuma offers facilities to configure NUMA
  policies supported by the linux kernel.
 
-config DEMANGLE
-   bool "Demangle symbols"
-   default y
----help---
- Enable demangling so as to display human-readable
- symbols. This option is convenient with C++ programs.
-
 config BIONIC
bool "Bionic support"
default n
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 27b092c..ce3a726 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -573,33 +573,36 @@ ifeq ($(feature-libbfd), 1)
   endif
 endif
 
-ifdef NO_DEMANGLE
-  CFLAGS += -DNO_DEMANGLE
-else
-  ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
-EXTLIBS += -liberty
-CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
-  else
-ifneq ($(feature-libbfd), 1)
-  ifneq ($(feature-liberty), 1)
-ifneq ($(feature-liberty-z), 1)
-  # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
-  # or any of 'bfd iberty z' trinity
-  ifeq ($(feature-cplus-demangle), 1)
-EXTLIBS += -liberty
-CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
-  else
-msg := $(warning No bfd.h/libbfd found, install 
binutils-dev[el]/zlib-static to gain symbol demangling)
-CFLAGS += -DNO_DEMANGLE
-  endif
+ifdef CONFIG_LIBBFD
+  ifneq ($(feature-libbfd), 1)
+# TODO: there might be an issue here: feature-liberty and
+# feature-liberty-z cannot be set; they can be set only if
+# feature-libbfd is set
+ifneq ($(feature-liberty), 1)
+  ifneq ($(feature-liberty-z), 1)
+# we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
+# or any of 'bfd iberty z' trinity
+ifeq ($(feature-cplus-demangle), 1)
+  EXTLIBS += -liberty
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBBFD)
+  $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBIBERTY_ONLY)
+else
+  msg := $(warning No bfd.h/libbfd found, install 
binutils-dev[el]/zlib-static to gain symbol demangling)
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE)
 endif
   endif
 endif
   endif
 endif
 
-ifneq ($(filter -lbfd,$(EXTLIBS)),)
-  CFLAGS += -DHAVE_LIBBFD_SUPPORT
+ifdef CONFIG_LIBIBERTY_ONLY
+  $(call feature_check,cplus-demangle)
+  ifeq ($(feature-cplus-demangle), 1)
+EXTLIBS += -liberty
+  else
+msg := $(warning No libiberty found, install binutils-dev[el]/zlib-static 
to gain symbol demangling)
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_DEMANGLE)
+  endif
 endif
 
 ifndef NO_BACKTRACE
@@ -795,7 +798,6 @@ all:
$(call store,NO_LIBUNWIND)
$(call store,NO_LIBPERL)
$(call store,NO_LIBPYTHON)
-   $(call store,NO_DEMANGLE)
$(call store,NO_LIBELF)
$(call store,NO_LIBUNWIND)
$(call store,NO_BACKTRACE)
diff --git a/tools/perf/config/Makefile.fix-legacy 
b/tools/perf/config/Makefile.fix-legacy
index ca219e7..64dbb1a 100644
--- a/tools/perf/config/Makefile.fix-legacy
+++ b/tools/perf/config/Makefile.fix-legacy
@@ -9,10 +9,6 @@ ifndef CONFIG_LIBPYTHON
 NO_LIBPYTHON := 1
 endif
 
-ifndef CONFIG_DEMANGLE
-NO_DEMANGLE := 1
-endif
-
 ifndef CONFIG_LIBELF
 NO_LIBELF := 1
 endif
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index f3e4bc5..38df8f4 100644
--- a/tools/perf/util/srcline.c
+++ 

[PATCH v2 03/14] perf tools: Kbuild source related fixies

2014-10-23 Thread Alexis Berlemont
From: Jiri Olsa 

Fixing several sources config dependencies to allow
separate config builds.

This commit was originally created by Jiri Olsa in 2013. Minor changes
were needed to get it working one year later:
* Remove #ifdef directives related with GUI / TUI (because of code
  changes in ui/setup.c)
* Fix a link issue if the option BUILTIN_TRACE is disabled.
* Fix typo (CONFIG_BULTIN_ instead CONFIG_BUILTIN_)

Signed-off-by: Jiri Olsa 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Corey Ashford 
Cc: Frederic Weisbecker 
Cc: Namhyung Kim 
Cc: Borislav Petkov 
Cc: Michal Marek 
Cc: linux-kbu...@vger.kernel.org
Cc: Stephane Eranian 
Signed-off-by: Alexis Berlemont 
---
 tools/perf/builtin-annotate.c|  6 +++---
 tools/perf/builtin-lock.c|  5 -
 tools/perf/builtin-report.c  |  2 +-
 tools/perf/builtin-sched.c   |  3 +++
 tools/perf/builtin-top.c |  4 ++--
 tools/perf/perf.c| 10 --
 tools/perf/ui/browsers/scripts.c |  4 
 tools/perf/ui/setup.c|  6 +++---
 8 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 19cb967..a46af8f 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -155,7 +155,7 @@ find_next:
 
/* skip missing symbols */
nd = rb_next(nd);
-#ifdef CONFIG_TUI
+#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD)
} else if (use_browser == 1) {
struct rb_node *next = NULL;
key = hist_entry__tui_annotate(he, evsel, NULL);
@@ -303,9 +303,9 @@ int cmd_annotate(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_BOOLEAN('D', "dump-raw-trace", _trace,
"dump raw trace in ASCII"),
OPT_BOOLEAN(0, "gtk", _gtk, "Use the GTK interface"),
-#ifdef CONFIG_TUI
+#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD)
OPT_BOOLEAN(0, "tui", _tui, "Use the TUI interface"),
-#endif /* CONFIG_TUI */
+#endif
OPT_BOOLEAN(0, "stdio", _stdio, "Use the stdio interface"),
OPT_STRING('k', "vmlinux", _conf.vmlinux_name,
   "file", "vmlinux pathname"),
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index e7ec715..05c0e1c 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -1,4 +1,5 @@
 #include "builtin.h"
+#include "builtin-cmds.h"
 #include "perf.h"
 
 #include "util/evlist.h"
@@ -995,9 +996,11 @@ int cmd_lock(int argc, const char **argv, const char 
*prefix __maybe_unused)
usage_with_options(report_usage, 
report_options);
}
rc = __cmd_report(false);
+#ifdef CONFIG_BUILTIN_SCRIPT
} else if (!strcmp(argv[0], "script")) {
/* Aliased to 'perf script' */
-   return cmd_script(argc, argv, prefix);
+   rc = cmd_script(argc, argv, prefix);
+#endif
} else if (!strcmp(argv[0], "info")) {
if (argc) {
argc = parse_options(argc, argv,
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 00d93ff..b639e58 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -407,7 +407,7 @@ static int report__browse_hists(struct report *rep)
const char *help = "For a higher level overview, try: perf report 
--sort comm,dso";
 
switch (use_browser) {
-#ifdef CONFIG_TUI
+#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD)
case 1:
ret = perf_evlist__tui_browse_hists(evlist, help, NULL,
rep->min_percent,
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 891c393..e38b021 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1,4 +1,5 @@
 #include "builtin.h"
+#include "builtin-cmds.h"
 #include "perf.h"
 
 #include "util/util.h"
@@ -1742,11 +1743,13 @@ int cmd_sched(int argc, const char **argv, const char 
*prefix __maybe_unused)
if (!argc)
usage_with_options(sched_usage, sched_options);
 
+#ifdef CONFIG_BUILTIN_SCRIPT
/*
 * Aliased to 'perf script' for now:
 */
if (!strcmp(argv[0], "script"))
return cmd_script(argc, argv, prefix);
+#endif
 
if (!strncmp(argv[0], "rec", 3)) {
return __cmd_record(argc, argv);
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index a2ff8b7..6f04452 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -535,7 +535,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, 
int c)
return ret;
 }
 
-#ifdef CONFIG_TUI
+#if defined(CONFIG_TUI) || !defined(CONFIG_KBUILD)
 static void perf_top__sort_new_samples(void *arg)
 {
struct perf_top *t = arg;
@@ -981,7 +981,7 @@ static int 

[PATCH v2 14/14] perf kbuild: add generated Kconfig build-test cases

2014-10-23 Thread Alexis Berlemont
Thanks to the python module kconfiglib, we were able to generate build
configurations. The set is, of course, not exhaustive but for each
option, all the possible states are tested.

Signed-off-by: Alexis Berlemont 
---
 tools/perf/MANIFEST|  1 +
 tools/perf/tests/configs/MINIMAL_config| 60 ++
 tools/perf/tests/configs/NO_BACKTRACE_config   | 73 ++
 .../perf/tests/configs/NO_BUILTIN_ANNOTATE_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_BENCH_config   | 73 ++
 .../tests/configs/NO_BUILTIN_BUILDID_CACHE_config  | 73 ++
 .../tests/configs/NO_BUILTIN_BUILDID_LIST_config   | 71 +
 tools/perf/tests/configs/NO_BUILTIN_DIFF_config| 71 +
 tools/perf/tests/configs/NO_BUILTIN_EVLIST_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_HELP_config| 73 ++
 tools/perf/tests/configs/NO_BUILTIN_INJECT_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_KMEM_config| 73 ++
 .../perf/tests/configs/NO_BUILTIN_KVM_STAT_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_KVM_config | 72 +
 tools/perf/tests/configs/NO_BUILTIN_LIST_config| 73 ++
 tools/perf/tests/configs/NO_BUILTIN_LOCK_config| 73 ++
 tools/perf/tests/configs/NO_BUILTIN_MEM_config | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_PROBE_config   | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_RECORD_config  | 63 +++
 tools/perf/tests/configs/NO_BUILTIN_REPORT_config  | 68 
 tools/perf/tests/configs/NO_BUILTIN_SCHED_config   | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_SCRIPT_config  | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_STAT_config| 71 +
 tools/perf/tests/configs/NO_BUILTIN_TEST_config| 73 ++
 .../perf/tests/configs/NO_BUILTIN_TIMECHART_config | 73 ++
 tools/perf/tests/configs/NO_BUILTIN_TOP_config | 71 +
 tools/perf/tests/configs/NO_BUILTIN_TRACE_config   | 73 ++
 tools/perf/tests/configs/NO_DEMANGLE_config| 71 +
 tools/perf/tests/configs/NO_GTK2_config| 73 ++
 tools/perf/tests/configs/NO_LIBAUDIT_config| 72 +
 tools/perf/tests/configs/NO_LIBDWARF_config| 71 +
 tools/perf/tests/configs/NO_LIBELF_MMAP_config | 73 ++
 tools/perf/tests/configs/NO_LIBGTK2_INFOBAR_config | 73 ++
 tools/perf/tests/configs/NO_LIBGTK2_config | 71 +
 tools/perf/tests/configs/NO_LIBNUMA_config | 73 ++
 tools/perf/tests/configs/NO_LIBPERL_config | 73 ++
 tools/perf/tests/configs/NO_LIBPYTHON_config   | 73 ++
 tools/perf/tests/configs/NO_LIBSLANG_config| 72 +
 .../tests/configs/NO_LIBUNWIND_DEBUG_FRAME_config  | 73 ++
 tools/perf/tests/configs/NO_PERF_REGS_config   | 73 ++
 tools/perf/tests/configs/NO_STDIO_config   | 73 ++
 tools/perf/tests/configs/NO_TIMERFD_config | 73 ++
 tools/perf/tests/configs/NO_TUI_config | 73 ++
 tools/perf/tests/configs/NO_UNWIND_config  | 69 
 tools/perf/tests/configs/REF_config| 73 ++
 tools/perf/tests/generate_configs.py   | 43 +
 tools/perf/tests/make  | 70 ++---
 47 files changed, 3227 insertions(+), 50 deletions(-)
 create mode 100644 tools/perf/tests/configs/MINIMAL_config
 create mode 100644 tools/perf/tests/configs/NO_BACKTRACE_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_ANNOTATE_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BENCH_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_CACHE_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_BUILDID_LIST_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_DIFF_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_EVLIST_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_HELP_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_INJECT_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KMEM_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KVM_STAT_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_KVM_config
 create mode 100644 tools/perf/tests/configs/NO_BUILTIN_LIST_config
 create mode 100644 

[PATCH v2 11/14] perf kbuild: remove legacy libdwarf-related build variables

2014-10-23 Thread Alexis Berlemont
* Remove NO_DWARF (replaced by CONFIG_LIBDWARF)
* Remove HAVE_DWARF_SUPPORT (replaced by CONFIG_LIBDWARF)
* Remove the useless variable PERF_HAVE_DWARF_REGS
* fix compilation issues if PERF_REGS is disabled

Signed-off-by: Alexis Berlemont 
---

Changes since v1:
 * Add the config parameter SKIP_CALLCHAIN_IDX
 * Fix LIBDWARF_UNWIND directives

 tools/perf/Kconfig   |  59 +-
 tools/perf/arch/arm/tests/Kbuild |   2 +-
 tools/perf/arch/arm/util/Kbuild  |   4 +-
 tools/perf/arch/arm64/util/Kbuild|   2 +-
 tools/perf/arch/powerpc/util/Kbuild  |   4 +-
 tools/perf/arch/s390/util/Kbuild |   2 +-
 tools/perf/arch/sh/util/Kbuild   |   2 +-
 tools/perf/arch/sparc/util/Kbuild|   2 +-
 tools/perf/arch/x86/Kbuild   |   1 +
 tools/perf/arch/x86/Makefile |   8 +-
 tools/perf/arch/x86/tests/Kbuild |   2 +-
 tools/perf/arch/x86/tests/perf-time-to-tsc.c |   2 +-
 tools/perf/arch/x86/util/Kbuild  |   3 +-
 tools/perf/builtin-probe.c   |  15 +--
 tools/perf/builtin-record.c  |   2 +-
 tools/perf/config/Makefile   | 170 +--
 tools/perf/config/Makefile.fix-config|   8 --
 tools/perf/config/Makefile.fix-legacy|   4 -
 tools/perf/tests/Kbuild  |   2 +
 tools/perf/tests/builtin-test.c  |   3 +-
 tools/perf/tests/tests.h |   6 +-
 tools/perf/util/Kbuild   |  11 +-
 tools/perf/util/callchain.c  |  11 +-
 tools/perf/util/callchain.h  |   3 +-
 tools/perf/util/include/dwarf-regs.h |   4 +-
 tools/perf/util/machine.c|   3 +-
 tools/perf/util/perf_regs.c  |   2 -
 tools/perf/util/probe-event.c|   6 +-
 tools/perf/util/probe-finder.h   |   5 +-
 tools/perf/util/unwind-libunwind.c   |   5 +-
 tools/perf/util/unwind.h |   7 +-
 31 files changed, 203 insertions(+), 157 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 2eaf3ca..54a194d 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -287,7 +287,6 @@ choice
  these tasks, perf can rely on either the libelf library or a
  minimal builtin support.
 
-
config LIBELF
bool "elf"
---help---
@@ -318,15 +317,51 @@ config LIBDWARF
bool "Dwarf (libdwarf)"
default y
 ---help---
- libdwarf
+ A library for parsing DWARF debug information.
+
+config LIBDWARF_DIR
+   string "libdwarf directory"
+   depends on LIBDWARF
+---help---
+ Directory holding the libdwarf dependency (headers +
+ libraries)
+
+config UNWIND
+depends on (LIBELF && PERF_REGS)
+   bool "User space unwind callchains"
+   default y
+---help---
+ Enable call-chain unwinding of user-space application.
+
+choice UNWIND_DEPS
+   prompt "Unwind dependency"
+   depends on UNWIND
+   default LIBUNWIND
 
 config LIBUNWIND
-depends on LIBELF
-   bool "User space libunwind callchains"
+depends on (LIBELF && PERF_REGS)
+   bool "Libunwind"
+---help---
+ Rely on libunwind post unwind support to determine the
+ call-chain of a user-space program. The library libunwind
+ supports all the architectures.
+
+config LIBDWARF_UNWIND
+depends on (LIBDWARF && PERF_REGS && (ARCH = "x86" || ARCH = "arm"))
+   bool "Libdwarf unwind"
+---help---
+ Rely on lidw DWARF post unwind support to determine the
+ call-chain of a user-space program. So far there's only x86
+ and arm libdw unwind support merged in perf.
+
+endchoice
+
+config LIBUNWIND_DEBUG_FRAME
+depends on LIBUNWIND
+   bool "libunwind debug frame"
default y
 ---help---
- The library libunwind provides a portable C API to determine
- the call-chain of a program.
+ libunwind debug frame
 
 config LIBUNWIND_DIR
string "libunwind directory"
@@ -335,6 +370,18 @@ config LIBUNWIND_DIR
  Directory holding the libuwind dependency (headers +
  libraries).
 
+config SKIP_CALLCHAIN_IDX
+   depends on (LIBDWARF && ARCH = "powerpc")
+   bool "Skip unnecessary callchain entries thanks to Dwarf"
+   default y
+---help---
+ When saving the callchain on Power, the kernel
+ conservatively saves excess entries in the callchain. A few
+ of these entries are needed in some cases but not others. If
+ the unnecessary entries are not ignored, we end up with
+ duplicate arcs in the call-graphs. Use DWARF debug
+ information to skip over any unnecessary callchain entries.
+
 config LIBNUMA
bool "Libnuma support"
default y
diff --git 

[PATCH v2 09/14] perf kbuild: remove legacy misc build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_LIBAUDIT (replaced by CONFIG_LIBAUDIT)
Remove HAVE_LIBAUDIT_SUPPORT from CFLAGS (replaced by CONFIG_LIBAUDIT)
Remove HAVE_TIMERFD_SUPPORT (replaced by CONFIG_TIMERFD)
Remove HAVE_ON_EXIT_SUPPORT (replaced by CONFIG_ON_EXIT)
Remove HAVE_BACKTRACE_SUPPORT (replaced by CONFIG_BACKTRACE)
Remove HAVE_LIBNUMA_SUPPORT (replaced by CONFIG_LIBNUMA)
Remove NO_BIONIC (replaced by CONFIG_BIONIC)
Remove NO_PERF_REGS (replaced by CONFIG_PERF_REGS)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig| 12 --
 tools/perf/arch/arm/tests/Kbuild  |  2 +-
 tools/perf/arch/x86/tests/Kbuild  |  2 +-
 tools/perf/bench/Kbuild   |  2 +-
 tools/perf/builtin-bench.c|  5 ++--
 tools/perf/builtin-kvm.c  | 13 ++-
 tools/perf/builtin-record.c   |  2 ++
 tools/perf/config/Makefile| 43 +--
 tools/perf/config/Makefile.fix-config | 32 --
 tools/perf/config/Makefile.fix-legacy | 16 -
 tools/perf/util/perf_regs.c   |  3 +++
 tools/perf/util/perf_regs.h   |  6 +++--
 tools/perf/util/util.c|  5 ++--
 13 files changed, 51 insertions(+), 92 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 5f85923..29853a6 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -312,8 +312,8 @@ config LIBUNWIND_DIR
  Directory holding the libuwind dependency (headers +
  libraries).
 
-config NUMA
-   bool "Numa support (bench)"
+config LIBNUMA
+   bool "Libnuma support"
default y
 ---help---
  The library libnuma offers facilities to configure NUMA
@@ -327,6 +327,14 @@ config BIONIC
  library code developed by Google for their Android operating
  system.
 
+config PERF_REGS
+   bool "Cache register accesses"
+   depends on (ARCH = "x86" || ARCH = "arm" || ARCH = "arm64")
+   default y
+---help---
+ Cache register accesses for unwind processing to speed-up
+ performances.
+
 endmenu
 
 menu "Build"
diff --git a/tools/perf/arch/arm/tests/Kbuild b/tools/perf/arch/arm/tests/Kbuild
index 5d63e9d..1318ed0 100644
--- a/tools/perf/arch/arm/tests/Kbuild
+++ b/tools/perf/arch/arm/tests/Kbuild
@@ -1,2 +1,2 @@
-obj-y += regs_load.o
+obj-$(CONFIG_PERF_REGS) += regs_load.o
 obj-y += dwarf-unwind.o
diff --git a/tools/perf/arch/x86/tests/Kbuild b/tools/perf/arch/x86/tests/Kbuild
index 3b5aa14..8287dae 100644
--- a/tools/perf/arch/x86/tests/Kbuild
+++ b/tools/perf/arch/x86/tests/Kbuild
@@ -1,3 +1,3 @@
 obj-y += perf-time-to-tsc.o
-obj-y += regs_load.o
+obj-$(CONFIG_PERF_REGS) += regs_load.o
 obj-y += dwarf-unwind.o
diff --git a/tools/perf/bench/Kbuild b/tools/perf/bench/Kbuild
index e604fe2..863646a 100644
--- a/tools/perf/bench/Kbuild
+++ b/tools/perf/bench/Kbuild
@@ -6,7 +6,7 @@ obj-y += futex-hash.o
 obj-y += futex-requeue.o
 obj-y += futex-wake.o
 
-obj-$(CONFIG_NUMA) += numa.o
+obj-$(CONFIG_LIBNUMA) += numa.o
 
 obj-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o
 obj-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index b9a56fa..5116d25 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -14,6 +14,7 @@
  *  numa  ... NUMA scheduling and MM performance
  *  futex ... Futex performance
  */
+#include "generated/autoconf.h"
 #include "perf.h"
 #include "util/util.h"
 #include "util/parse-options.h"
@@ -33,7 +34,7 @@ struct bench {
bench_fn_t  fn;
 };
 
-#ifdef HAVE_LIBNUMA_SUPPORT
+#ifdef CONFIG_LIBNUMA
 static struct bench numa_benchmarks[] = {
{ "mem","Benchmark for NUMA workloads", 
bench_numa  },
{ "all","Test all NUMA benchmarks", NULL
},
@@ -72,7 +73,7 @@ struct collection {
 static struct collection collections[] = {
{ "sched",  "Scheduler and IPC benchmarks", 
sched_benchmarks},
{ "mem","Memory access benchmarks", 
mem_benchmarks  },
-#ifdef HAVE_LIBNUMA_SUPPORT
+#ifdef CONFIG_LIBNUMA
{ "numa",   "NUMA scheduling and MM benchmarks",
numa_benchmarks },
 #endif
{"futex",   "Futex stressing benchmarks",   
futex_benchmarks},
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 400e92e..28371f9 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1,3 +1,4 @@
+#include "generated/autoconf.h"
 #include "builtin.h"
 #include "perf.h"
 
@@ -20,7 +21,7 @@
 #include "util/data.h"
 
 #include 
-#ifdef HAVE_TIMERFD_SUPPORT
+#ifdef CONFIG_TIMERFD
 #include 
 #endif
 
@@ -123,7 +124,7 @@ static void init_kvm_event_record(struct perf_kvm_stat *kvm)
INIT_LIST_HEAD(>kvm_events_cache[i]);
 }
 
-#ifdef HAVE_TIMERFD_SUPPORT
+#ifdef CONFIG_TIMERFD
 static void 

[PATCH v2 10/14] perf kbuild: remove legacy libelf-related build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_LIBELF (replaced by CONFIG_LIBELF)
Remove HAVE_LIBELF_SUPPORT (replaced by CONFIG_LIBELF)
Remove HAVE_LIBELF_MMAP_SUPPORT (replaced by CONFIG_LIBELF_MMAP)
Remove HAVE_LIBELF_GETPHDRNUM__SUPPORT (replaced by
CONFIG_LIBELF_GETPHDRNUM_)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig| 23 ++
 tools/perf/builtin-inject.c   |  2 +-
 tools/perf/config/Makefile| 37 +++
 tools/perf/config/Makefile.fix-config | 18 -
 tools/perf/config/Makefile.fix-legacy |  4 
 tools/perf/perf.c |  2 +-
 tools/perf/util/generate-cmdlist.sh   |  4 ++--
 tools/perf/util/map.c |  3 ++-
 tools/perf/util/symbol-elf.c  |  3 ++-
 tools/perf/util/symbol.h  |  8 
 10 files changed, 51 insertions(+), 53 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 29853a6..2eaf3ca 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -256,6 +256,7 @@ config TIMERFD
  Timer via file descriptor
 
 config DEMANGLE
+   depends on LIBELF
bool "Demangle symbols"
default y
 ---help---
@@ -298,7 +299,29 @@ choice
  Builtin elf support.
 endchoice
 
+config LIBELF_MMAP
+depends on LIBELF
+   bool "Libelf mmap support"
+   default y
+---help---
+ libdelf mmap
+
+config LIBELF_GETPHDRNUM
+depends on LIBELF
+   default y
+   bool "Libelf getphdrnum support"
+---help---
+ libdelf mmap
+
+config LIBDWARF
+   depends on LIBELF
+   bool "Dwarf (libdwarf)"
+   default y
+---help---
+ libdwarf
+
 config LIBUNWIND
+depends on LIBELF
bool "User space libunwind callchains"
default y
 ---help---
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index de99ca1..9d59c7f 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -230,7 +230,7 @@ static int perf_event__inject_buildid(struct perf_tool 
*tool,
 * account this as unresolved.
 */
} else {
-#ifdef HAVE_LIBELF_SUPPORT
+#ifdef CONFIG_LIBELF
pr_warning("no symbols found in %s, maybe "
   "install a debug package?\n",
   al.map->dso->long_name);
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 5be574c3..79fe047 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -303,12 +303,7 @@ ifdef CONFIG_BIONIC
   endif
 endif
 
-ifdef NO_LIBELF
-  NO_DWARF := 1
-  NO_DEMANGLE := 1
-  NO_LIBUNWIND := 1
-  NO_LIBDW_DWARF_UNWIND := 1
-else
+ifdef CONFIG_LIBELF
   ifeq ($(feature-libelf), 0)
 ifeq ($(feature-glibc), 1)
   LIBC_SUPPORT := 1
@@ -318,12 +313,9 @@ else
 endif
 ifeq ($(LIBC_SUPPORT),1)
   msg := $(warning No libelf found, disables 'probe' tool, please install 
elfutils-libelf-devel/libelf-dev);
-
-  NO_LIBELF := 1
-  NO_DWARF := 1
-  NO_DEMANGLE := 1
-  NO_LIBUNWIND := 1
-  NO_LIBDW_DWARF_UNWIND := 1
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF)
+  $(shell $(KCONFIG_SCRIPT) -e CONFIG_LIBELF_MINIMAL)
+  EXTLIBS := $(filter-out -lelf,$(EXTLIBS))
 else
   ifneq ($(filter s% -static%,$(LDFLAGS),),)
 msg := $(error No static glibc found, please install glibc-static);
@@ -332,6 +324,7 @@ else
   endif
 endif
   else
+LIBELF = 1
 ifndef NO_LIBDW_DWARF_UNWIND
   ifneq ($(feature-libdw-dwarf-unwind),1)
 NO_LIBDW_DWARF_UNWIND := 1
@@ -343,17 +336,20 @@ else
   NO_DWARF := 1
 endif # Dwarf support
   endif # libelf support
-endif # NO_LIBELF
+endif # CONFIG_LIBELF
 
-ifndef NO_LIBELF
-  CFLAGS += -DHAVE_LIBELF_SUPPORT
+ifeq ($(LIBELF), 1)
 
-  ifeq ($(feature-libelf-mmap), 1)
-CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
+  ifdef CONFIG_LIBELF_MMAP
+ifneq ($(feature-libelf-mmap), 1)
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP)
+endif
   endif
 
-  ifeq ($(feature-libelf-getphdrnum), 1)
-CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
+  ifdef CONFIG_LIBELF_MMAP
+ifneq ($(feature-libelf-getphdrnum), 1)
+  $(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBELF_MMAP)
+endif
   endif
 
   # include ARCH specific config
@@ -369,7 +365,7 @@ ifndef NO_LIBELF
   EXTLIBS += -lelf -ldw
 endif # PERF_HAVE_DWARF_REGS
   endif # NO_DWARF
-endif # NO_LIBELF
+endif # LIBELF
 
 ifeq ($(ARCH),powerpc)
   ifndef NO_DWARF
@@ -787,7 +783,6 @@ all:
$(call store,NO_LIBUNWIND)
$(call store,NO_LIBPERL)
$(call store,NO_LIBPYTHON)
-   $(call store,NO_LIBELF)
$(call store,NO_LIBUNWIND)
$(call store,NO_LIBBIONIC)
$(call store,ETC_PERFCONFIG_SQ)
diff --git a/tools/perf/config/Makefile.fix-config 

[PATCH v2 12/14] perf kbuild: remove legacy script-related build variables

2014-10-23 Thread Alexis Berlemont
Remove NO_LIBPERL (replaced by CONFIG_LIBPERL)
Remove NO_LIBPYTHON (replaced by CONFIG_LIBPYTHON)

Signed-off-by: Alexis Berlemont 
---
 tools/perf/builtin-script.c |  6 +++--
 tools/perf/config/Makefile  | 41 +
 tools/perf/config/Makefile.fix-config   | 16 -
 tools/perf/config/Makefile.fix-legacy   |  8 ---
 tools/perf/util/trace-event-scripting.c | 13 ++-
 5 files changed, 22 insertions(+), 62 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9708a12..cc9c305 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1,3 +1,5 @@
+#include "generated/autoconf.h"
+
 #include "builtin.h"
 
 #include "perf.h"
@@ -1372,11 +1374,11 @@ int find_scripts(char **scripts_array, char 
**scripts_path_array)
for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) {
snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
 lang_dirent.d_name);
-#ifdef NO_LIBPERL
+#ifndef CONFIG_LIBPERL
if (strstr(lang_path, "perl"))
continue;
 #endif
-#ifdef NO_LIBPYTHON
+#ifndef CONFIG_LIBPYTHON
if (strstr(lang_path, "python"))
continue;
 #endif
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index f667229..00d118c 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -101,7 +101,7 @@ ifdef PARSER_DEBUG
   CFLAGS += -DPARSER_DEBUG
 endif
 
-ifndef NO_LIBPYTHON
+ifdef CONFIG_LIBPYTHON
   # Try different combinations to accommodate systems that only have
   # python[2][-config] in weird combinations but always preferring
   # python2 and python2-config as per pep-0394. If we catch a
@@ -460,9 +460,7 @@ endif
 grep-libs  = $(filter -l%,$(1))
 strip-libs = $(filter-out -l%,$(1))
 
-ifdef NO_LIBPERL
-  CFLAGS += -DNO_LIBPERL
-else
+ifdef CONFIG_LIBPERL
   PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
   PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
   PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
@@ -470,9 +468,8 @@ else
   FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 
   ifneq ($(feature-libperl), 1)
-CFLAGS += -DNO_LIBPERL
-NO_LIBPERL := 1
 msg := $(warning Missing perl devel files. Disabling perl scripting 
support, consider installing perl-ExtUtils-Embed);
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPERL)
   else
 LDFLAGS += $(PERL_EMBED_LDFLAGS)
 EXTLIBS += $(PERL_EMBED_LIBADD)
@@ -486,17 +483,14 @@ ifdef CONFIG_TIMERFD
   endif
 endif
 
-disable-python = $(eval $(disable-python_code))
-define disable-python_code
-  CFLAGS += -DNO_LIBPYTHON
-  $(if $(1),$(warning No $(1) was found))
-  $(warning Python support will not be built)
-  NO_LIBPYTHON := 1
-endef
+ifdef CONFIG_LIBPYTHON
 
-ifdef NO_LIBPYTHON
-  $(call disable-python)
-else
+  disable-python = $(eval $(disable-python_code))
+  define disable-python_code
+$(if $(1),$(warning No $(1) was found))
+$(warning Python support will not be built)
+$(shell $(KCONFIG_SCRIPT) -d CONFIG_LIBPYTHON)
+  endef
 
   ifndef PYTHON
 $(call disable-python,python interpreter)
@@ -520,18 +514,7 @@ else
   else
 
 ifneq ($(feature-libpython-version), 1)
-  $(warning Python 3 is not yet supported; please set)
-  $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
-  $(warning If you also have Python 2 installed, then)
-  $(warning try something like:)
-  $(warning $(and ,))
-  $(warning $(and ,)  make PYTHON=python2)
-  $(warning $(and ,))
-  $(warning Otherwise, disable Python support entirely:)
-  $(warning $(and ,))
-  $(warning $(and ,)  make NO_LIBPYTHON=1)
-  $(warning $(and ,))
-  $(error   $(and ,))
+  $(call disable-python,python2 interpreter)
 else
   LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
   EXTLIBS += $(PYTHON_EMBED_LIBADD)
@@ -781,8 +764,6 @@ all:
$(call store,PYTHON_EMBED_CCOPTS)
$(call store,PERL_EMBED_CCOPTS)
$(call store,NO_LIBUNWIND)
-   $(call store,NO_LIBPERL)
-   $(call store,NO_LIBPYTHON)
$(call store,ETC_PERFCONFIG_SQ)
$(call store,DESTDIR_SQ)
$(call store,bindir_SQ)
diff --git a/tools/perf/config/Makefile.fix-config 
b/tools/perf/config/Makefile.fix-config
index e63539f..3f0e33e 100644
--- a/tools/perf/config/Makefile.fix-config
+++ b/tools/perf/config/Makefile.fix-config
@@ -3,20 +3,4 @@ include $(KCONFIG_CONFIG)
 
 CONFIG := $(srctree)/scripts/config --file $(KCONFIG_CONFIG)
 
-# NO_LIBPERL
-ifdef CONFIG_LIBPERL
-ifdef NO_LIBPERL
-dummy := $(info Disabling CONFIG_LIBPERL)
-dummy := $(shell $(CONFIG) -d CONFIG_LIBPERL)
-endif
-endif
-
-# NO_LIBPYTHON
-ifdef CONFIG_LIBPYTHON
-ifdef NO_LIBPYTHON
-dummy := $(info Disabling CONFIG_LIBPYTHON)
-dummy := $(shell 

[PATCH v2 08/14] perf kbuild: cross-compilation variables are now handled in Kconfig

2014-10-23 Thread Alexis Berlemont
The variable CONFIG_ARCH and CONFIG_CROSS_COMPILE were added.

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig  | 24 
 tools/perf/Makefile.kbuild  |  8 
 tools/perf/arch/x86/include/perf_regs.h |  8 +---
 tools/perf/arch/x86/tests/regs_load.S   |  3 ++-
 tools/perf/arch/x86/util/unwind-libunwind.c |  5 +++--
 tools/perf/bench/mem-memcpy-arch.h  |  4 +++-
 tools/perf/bench/mem-memcpy.c   |  4 +++-
 tools/perf/bench/mem-memset-arch.h  |  4 +++-
 tools/perf/bench/mem-memset.c   |  4 +++-
 tools/perf/config/Makefile  |  7 ++-
 10 files changed, 52 insertions(+), 19 deletions(-)

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 026ef67..5f85923 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -1,6 +1,30 @@
 
 mainmenu "The perf configuration"
 
+config TARGET_ARCH
+   string
+   option env="ARCH"
+
+config TARGET_IS_X86_64
+   string
+   option env="IS_X86_64"
+
+config TARGET_CROSS_COMPILE
+   string
+   option env="CROSS_COMPILE"
+
+config ARCH
+   string
+   default TARGET_ARCH
+
+config X86_64
+   bool
+   default y if TARGET_ARCH = "x86" && TARGET_IS_X86_64 = "1"
+
+config CROSS_COMPILE
+   string
+   default TARGET_CROSS_COMPILE
+
 menu "Built-in commands"
 
 config BUILTIN_RECORD
diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild
index 8d9e8b0..b48fe7f 100644
--- a/tools/perf/Makefile.kbuild
+++ b/tools/perf/Makefile.kbuild
@@ -123,9 +123,12 @@ export KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG KCONFIG_SCRIPT
 
 # perf detected config
 CONFIG_DETECTED := $(obj-perf)/.config-detected
-
 export CONFIG_DETECTED
 
+# arch-related main variables
+include $(src-perf)/config/Makefile.arch
+export ARCH IS_X86_64 CROSS_COMPILE
+
 # external .a libs
 LIBTRACEEVENT   := $(obj-kernel)/tools/lib/traceevent/libtraceevent.a
 LIBAPIKFS   := $(obj-kernel)/tools/lib/api/libapikfs.a
@@ -202,9 +205,6 @@ ifndef dont-detect
 ifdef CONFIG_DETECTED_STORED
 # Following variables are needed within Kbuild files, we need
 # to export them as they are not part of the .config set.
-export CONFIG_ARCH := $(ARCH)
-export CROSS_COMPILE
-export CONFIG_X86_64
 export htmldir_SQ
 export infodir_SQ
 export mandir_SQ
diff --git a/tools/perf/arch/x86/include/perf_regs.h 
b/tools/perf/arch/x86/include/perf_regs.h
index 7df517a..d969cca 100644
--- a/tools/perf/arch/x86/include/perf_regs.h
+++ b/tools/perf/arch/x86/include/perf_regs.h
@@ -5,9 +5,11 @@
 #include 
 #include 
 
+#include "generated/autoconf.h"
+
 void perf_regs_load(u64 *regs);
 
-#ifndef HAVE_ARCH_X86_64_SUPPORT
+#ifndef CONFIG_X86_64
 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)
 #define PERF_REGS_MAX PERF_REG_X86_32_MAX
 #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32
@@ -58,7 +60,7 @@ static inline const char *perf_reg_name(int id)
return "FS";
case PERF_REG_X86_GS:
return "GS";
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef CONFIG_X86_64
case PERF_REG_X86_R8:
return "R8";
case PERF_REG_X86_R9:
@@ -75,7 +77,7 @@ static inline const char *perf_reg_name(int id)
return "R14";
case PERF_REG_X86_R15:
return "R15";
-#endif /* HAVE_ARCH_X86_64_SUPPORT */
+#endif /* CONFIG_X86_64 */
default:
return NULL;
}
diff --git a/tools/perf/arch/x86/tests/regs_load.S 
b/tools/perf/arch/x86/tests/regs_load.S
index 60875d5..822a797 100644
--- a/tools/perf/arch/x86/tests/regs_load.S
+++ b/tools/perf/arch/x86/tests/regs_load.S
@@ -1,4 +1,5 @@
 #include 
+#include "generated/autoconf.h"
 
 #define AX  0
 #define BX  1 * 8
@@ -26,7 +27,7 @@
 #define R1523 * 8
 
 .text
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef CONFIG_X86_64
 ENTRY(perf_regs_load)
movq %rax, AX(%rdi)
movq %rbx, BX(%rdi)
diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c 
b/tools/perf/arch/x86/util/unwind-libunwind.c
index db25e93..e4960c1 100644
--- a/tools/perf/arch/x86/util/unwind-libunwind.c
+++ b/tools/perf/arch/x86/util/unwind-libunwind.c
@@ -1,11 +1,12 @@
 
 #include 
 #include 
+#include "generated/autoconf.h"
 #include "perf_regs.h"
 #include "../../util/unwind.h"
 #include "../../util/debug.h"
 
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef CONFIG_X86_64
 int libunwind__arch_reg_id(int regnum)
 {
int id;
@@ -109,4 +110,4 @@ int libunwind__arch_reg_id(int regnum)
 
return id;
 }
-#endif /* HAVE_ARCH_X86_64_SUPPORT */
+#endif /* CONFIG_X86_64 */
diff --git a/tools/perf/bench/mem-memcpy-arch.h 
b/tools/perf/bench/mem-memcpy-arch.h
index 57b4ed8..8e3f0a9 100644
--- a/tools/perf/bench/mem-memcpy-arch.h
+++ b/tools/perf/bench/mem-memcpy-arch.h
@@ -1,5 +1,7 @@
 
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#include "generated/autoconf.h"
+
+#ifdef CONFIG_X86_64
 
 #define MEMCPY_FN(fn, name, desc)  \
   

[PATCH v2 02/14] perf tools: Kbuild builtin source related fixies

2014-10-23 Thread Alexis Berlemont
From: Jiri Olsa 

Adding CONFIG_BUILTIN_* defines to govern builtin commands.
This will be useful for kbuild process switch.

Signed-off-by: Jiri Olsa 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Corey Ashford 
Cc: Frederic Weisbecker 
Cc: Namhyung Kim 
Cc: Borislav Petkov 
Cc: Michal Marek 
Cc: linux-kbu...@vger.kernel.org
Cc: Stephane Eranian 
Signed-off-by: Alexis Berlemont 
---
 tools/perf/builtin-annotate.c   |  8 ++-
 tools/perf/builtin-cmds.h   | 27 ++
 tools/perf/builtin-help.c   |  1 +
 tools/perf/builtin-kvm.c| 19 ++--
 tools/perf/builtin-report.c |  3 +++
 tools/perf/builtin-top.c| 19 
 tools/perf/perf.c   | 45 +++--
 tools/perf/ui/setup.c   |  6 +++--
 tools/perf/util/generate-cmdlist.sh | 10 +
 9 files changed, 122 insertions(+), 16 deletions(-)
 create mode 100644 tools/perf/builtin-cmds.h

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index e7417fe..19cb967 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -5,6 +5,7 @@
  * look up and read DSOs and symbol information and display
  * a histogram of results, along various sorting keys.
  */
+#include "generated/autoconf.h"
 #include "builtin.h"
 
 #include "util/util.h"
@@ -115,7 +116,7 @@ static void hists__find_annotations(struct hists *hists,
struct perf_evsel *evsel,
struct perf_annotate *ann)
 {
-   struct rb_node *nd = rb_first(>entries), *next;
+   struct rb_node *nd = rb_first(>entries);
int key = K_RIGHT;
 
while (nd) {
@@ -154,7 +155,9 @@ find_next:
 
/* skip missing symbols */
nd = rb_next(nd);
+#ifdef CONFIG_TUI
} else if (use_browser == 1) {
+   struct rb_node *next = NULL;
key = hist_entry__tui_annotate(he, evsel, NULL);
switch (key) {
case -1:
@@ -173,6 +176,7 @@ find_next:
 
if (next != NULL)
nd = next;
+#endif /* CONFIG_TUI */
} else {
hist_entry__tty_annotate(he, evsel, ann);
nd = rb_next(nd);
@@ -299,7 +303,9 @@ int cmd_annotate(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_BOOLEAN('D', "dump-raw-trace", _trace,
"dump raw trace in ASCII"),
OPT_BOOLEAN(0, "gtk", _gtk, "Use the GTK interface"),
+#ifdef CONFIG_TUI
OPT_BOOLEAN(0, "tui", _tui, "Use the TUI interface"),
+#endif /* CONFIG_TUI */
OPT_BOOLEAN(0, "stdio", _stdio, "Use the stdio interface"),
OPT_STRING('k', "vmlinux", _conf.vmlinux_name,
   "file", "vmlinux pathname"),
diff --git a/tools/perf/builtin-cmds.h b/tools/perf/builtin-cmds.h
new file mode 100644
index 000..fec342a
--- /dev/null
+++ b/tools/perf/builtin-cmds.h
@@ -0,0 +1,27 @@
+#ifndef BUILTIN_CMDS_H
+#define BUILTIN_CMDS_H
+
+#define CONFIG_BUILTIN_REPORT 1
+#define CONFIG_BUILTIN_SCRIPT 1
+#define CONFIG_BUILTIN_BENCH 1
+#define CONFIG_BUILTIN_SCHED 1
+#define CONFIG_BUILTIN_TRACE 1
+#define CONFIG_BUILTIN_TOP 1
+#define CONFIG_BUILTIN_RECORD 1
+#define CONFIG_BUILTIN_BUILDID_LIST 1
+#define CONFIG_BUILTIN_INJECT 1
+#define CONFIG_BUILTIN_LOCK 1
+#define CONFIG_BUILTIN_KVM 1
+#define CONFIG_BUILTIN_BUILDID_CACHE 1
+#define CONFIG_BUILTIN_EVLIST 1
+#define CONFIG_BUILTIN_KMEM 1
+#define CONFIG_BUILTIN_STAT 1
+#define CONFIG_BUILTIN_DIFF 1
+#define CONFIG_BUILTIN_ANNOTATE 1
+#define CONFIG_BUILTIN_TIMECHART 1
+#define CONFIG_BUILTIN_LIST 1
+#define CONFIG_BUILTIN_HELP 1
+#define CONFIG_BUILTIN_PROBE 1
+#define CONFIG_BUILTIN_MEM 1
+
+#endif /* BUILTIN_CMDS_H */
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 25d2062..fbbbaa4 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -7,6 +7,7 @@
 #include "util/cache.h"
 #include "builtin.h"
 #include "util/exec_cmd.h"
+#include "builtin-cmds.h"
 #include "common-cmds.h"
 #include "util/parse-options.h"
 #include "util/run-command.h"
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index b65eb050..400e92e 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1531,20 +1531,25 @@ int cmd_kvm(int argc, const char **argv, const char 
*prefix __maybe_unused)
 
if (!strncmp(argv[0], "rec", 3))
return __cmd_record(file_name, argc, argv);
-   else if (!strncmp(argv[0], "rep", 3))
+
+   if (!strncmp(argv[0], "rep", 3))
return __cmd_report(file_name, argc, argv);
-   else if (!strncmp(argv[0], "diff", 4))
+
+   if (!strncmp(argv[0], "diff", 4))
return cmd_diff(argc, argv, NULL);
- 

[PATCH v2 13/14] perf kbuild: final cosmetic changes

2014-10-23 Thread Alexis Berlemont
* Correctly rename internal makefile variables
* Remove makefiles in tools/perf/config which became empty and useless
* Remove builtin-cmds.h
* Remove arch/x86/Makefile
* Improve outputs of clean and install targets
* Remove creation of PERF-FEATURES file which is redundant with the
  .config file generated by Kconfig.
* replace HAVE_KVM_STAT_SUPPORT by a Kconfig option
* replace HAVE_SKIP_CALLCHAIN_IDX by a Kconfig option

Signed-off-by: Alexis Berlemont 
---
 tools/perf/Kconfig|  7 
 tools/perf/Makefile.kbuild| 74 ++--
 tools/perf/arch/s390/util/Kbuild  |  2 +-
 tools/perf/arch/x86/Makefile  | 17 
 tools/perf/arch/x86/util/Kbuild   |  2 +-
 tools/perf/builtin-cmds.h |  6 ---
 tools/perf/builtin-help.c |  2 +-
 tools/perf/builtin-kvm.c  |  6 +--
 tools/perf/builtin-lock.c |  2 +-
 tools/perf/builtin-sched.c|  2 +-
 tools/perf/config/Makefile| 79 +++
 tools/perf/config/Makefile.fix-config |  6 ---
 tools/perf/config/Makefile.fix-legacy |  2 -
 tools/perf/perf.c |  2 +-
 14 files changed, 83 insertions(+), 126 deletions(-)
 delete mode 100644 tools/perf/arch/x86/Makefile
 delete mode 100644 tools/perf/builtin-cmds.h
 delete mode 100644 tools/perf/config/Makefile.fix-config
 delete mode 100644 tools/perf/config/Makefile.fix-legacy

diff --git a/tools/perf/Kconfig b/tools/perf/Kconfig
index 54a194d..d1b44c3 100644
--- a/tools/perf/Kconfig
+++ b/tools/perf/Kconfig
@@ -128,6 +128,13 @@ config BUILTIN_KVM
 ---help---
  Tool to trace/measure kvm guest os
 
+config BUILTIN_KVM_STAT
+   bool "kvm-stat"
+   default y
+   depends on BUILTIN_KVM && (ARCH = "x86" || ARCH = "s390")
+---help---
+ Get performance counter statistics on a kvm guest os.
+
 config BUILTIN_LIST
bool "list"
default y
diff --git a/tools/perf/Makefile.kbuild b/tools/perf/Makefile.kbuild
index b48fe7f..90b168d 100644
--- a/tools/perf/Makefile.kbuild
+++ b/tools/perf/Makefile.kbuild
@@ -1,6 +1,5 @@
 srctree := $(abspath $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)/../../))
 objtree := $(abspath $(if $(KBUILD_SRC),$(CURDIR),$(CURDIR)/../..))
-
 VPATH   := $(srctree)
 
 export srctree VPATH
@@ -36,7 +35,8 @@ export quiet Q KBUILD_VERBOSE
 ifndef V
 QUIET_LINK  = @echo '  LD  $@';
 QUIET_GEN   = @echo '  GEN $@';
-QUIET_CLEAN = @echo '  CLEAN   tools/perf';
+QUIET_CLEAN = @printf '  CLEAN%s\n' $1;
+QUIET_INSTALL = @printf '  INSTALL  %s\n' $1;
 endif
 
 export QUIET_BISON QUIET_FLEX
@@ -158,7 +158,6 @@ $(CONFIG_DETECTED): $(KCONFIG_CONFIG)
 # no need to include auto.conf.cmd, because .config
 # is the only dependency here
 $(KCONFIG_AUTOCONFIG): $(KCONFIG_CONFIG) $(CONFIG_DETECTED)
-   $(Q)$(MAKE) -f $(src-perf)/config/Makefile.fix-config
$(Q)mkdir -p $(obj-perf)/include/config
$(Q)mkdir -p $(obj-perf)/include/generated
$(Q)$(MAKE) -s $(build)=scripts/kconfig silentoldconfig
@@ -167,22 +166,26 @@ $(KCONFIG_AUTOCONFIG): $(KCONFIG_CONFIG) 
$(CONFIG_DETECTED)
 clean-dirs := $(addprefix _clean_, tools/perf/)
 
 $(clean-dirs):
+   $(call QUIET_CLEAN, core-objs)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.clean obj=$(patsubst 
_clean_%,%,$@)
 
-clean: $(clean-dirs) $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean
-   $(Q)$(QUIET_CLEAN)
-   $(Q)rm -f $(obj-perf)/perf
-   $(Q)rm -f $(obj-perf)/common-cmds.h
-   $(Q)rm -f $(obj-perf)/python/perf.so
+config-clean:
+   $(call QUIET_CLEAN, config)
+   @$(MAKE) OUTPUT=$(obj-perf)/config/feature-checks/ -C 
$(src-perf)/config/feature-checks clean >/dev/null
$(Q)rm -rf $(obj-perf)/include/generated $(obj-perf)/include/config
+   $(Q)rm -f $(CONFIG_DETECTED) $(KCONFIG_CONFIG)
+   $(Q)rm -f $(obj-perf)/common-cmds.h
+
+clean: $(clean-dirs) $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean config-clean
+   $(call QUIET_CLEAN, core-progs)
+   $(Q)rm -f $(obj-perf)/perf
+   $(call QUIET_CLEAN, misc)
$(Q)find $(obj-perf) \
\( -name '*.[oas]' -o -name '.*.cmd' \
-o -name '.*.d' -o -name '.*.tmp' \
-o -name '*-flex.[ch]' -o -name '*-bison.[ch]' \
\) -type f -print | xargs rm -f
-   $(Q)$(python-clean)
-   $(Q)rm -f $(CONFIG_DETECTED) $(KCONFIG_CONFIG)
-   @$(MAKE) OUTPUT=$(obj-perf)/config/feature-checks/ -C 
$(src-perf)/config/feature-checks clean >/dev/null
+   $(python-clean)
 
 TAGS tags:
$(Q)rm -f $(src-perf)/tags
@@ -257,7 +260,7 @@ PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
 
 export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
 
-python-clean := rm -rf $(PYTHON_EXTBUILD) $(obj-perf)/python/perf.so
+python-clean := $(call QUIET_CLEAN, python) rm -rf $(PYTHON_EXTBUILD) 
$(obj-perf)/python/perf.so
 
 PYTHON_EXT_SRCS   := $(addprefix $(src-perf)/,$(shell grep -v ^\# 

[PATCH v2 01/14] kbuild: add support of custom paths for "auto.conf*" files

2014-10-23 Thread Alexis Berlemont
In the scripts/Makefile.build, use KCONFIG_AUTOCONFIG to include a
custom path for the "auto.conf" file.

The "*conf" programs were modified so as to work with the environment
variable KCONFIG_AUTOCONFIG.

Signed-off-by: Alexis Berlemont 
---

Changes since v1:
 * Use PATH_MAX instead of PATH_MAXLENGTH
 * Simplify conf_get_autoconfigdep_name() according to Micheal Marek's
   advices
 * Remove a superfluous assignment

 scripts/Makefile.build |  3 ++-
 scripts/kconfig/confdata.c | 23 ++-
 scripts/kconfig/lkc.h  |  1 +
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 649ce68..2abb82f 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -31,7 +31,8 @@ subdir-asflags-y :=
 subdir-ccflags-y :=
 
 # Read auto.conf if it exists, otherwise ignore
--include include/config/auto.conf
+kconfig-autoconfig := $(if 
$(KCONFIG_AUTOCONFIG),$(KCONFIG_AUTOCONFIG),include/config/auto.conf)
+-include $(kconfig-autoconfig)
 
 include scripts/Kbuild.include
 
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..75cf6bf 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -75,6 +75,23 @@ const char *conf_get_autoconfig_name(void)
return name ? name : "include/config/auto.conf";
 }
 
+const char *conf_get_autoconfigdep_name(void)
+{
+   static char res_value[PATH_MAX+1];
+
+   const char *name = conf_get_autoconfig_name();
+
+   if (strlen(name) > PATH_MAX - 4)
+   name = NULL;
+   else {
+   strcpy(res_value, name);
+   strcat(res_value, ".cmd");
+   name = res_value;
+   }
+
+   return name;
+}
+
 static char *conf_expand_value(const char *in)
 {
struct symbol *sym;
@@ -953,7 +970,11 @@ int conf_write_autoconf(void)
 
sym_clear_all_valid();
 
-   file_write_dep("include/config/auto.conf.cmd");
+   name = conf_get_autoconfigdep_name();
+   if (name == NULL)
+   return 1;
+
+   file_write_dep(name);
 
if (conf_split_config())
return 1;
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index d5daa7a..ac99004 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -84,6 +84,7 @@ const char *zconf_curname(void);
 /* confdata.c */
 const char *conf_get_configname(void);
 const char *conf_get_autoconfig_name(void);
+const char *conf_get_autoconfigdep_name(void);
 char *conf_get_default_confname(void);
 void sym_set_change_count(int count);
 void sym_add_change_count(int count);
-- 
2.1.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 15/15] perf: replace _BSD_SOURCE macro by _DEFAULT_SOURCE

2014-10-23 Thread Alexis Berlemont
Aaro Koskinen wrote:
> Hi,
> 
> On Mon, Sep 22, 2014 at 11:53:16PM +0200, Alexis Berlemont wrote:
> > Starting from glibc-2.20, the macro _BSD_SOURCE is deprecated and
> > should be replaced by _DEFAULT_SOURCE.
> 
> This patch fixes perf build breakage with glibc-2.20, so _DEFAULT_SOURCE
> is needed.
> 
> But shouldn't you also keep _BSD_SOURCE still there for a while for
> backwards compatibility? (Not sure if it has relevance for those
> using older glibcs...).

One more terrible mistake... Sorry.

> 
> Anyway to fix the perf + glibc-2.20 build failure:
> 
> Tested-by: Aaro Koskinen 
> 
> (BTW, your patch was missing Signed-off-by.)
> 

OK. I fixed that on the next patch set (and I read the doc
linux/Documentation/SubmittingPatches). I hope my next patch set will
be less ludicrous...

Thank you for your feedback.

Alexis

> A.
> 
> > ---
> >  tools/perf/util/util.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> > index 6686436..f56b4e0 100644
> > --- a/tools/perf/util/util.h
> > +++ b/tools/perf/util/util.h
> > @@ -38,7 +38,7 @@
> >  #define decimal_length(x)  ((int)(sizeof(x) * 2.56 + 0.5) + 1)
> >  
> >  #define _ALL_SOURCE 1
> > -#define _BSD_SOURCE 1
> > +#define _DEFAULT_SOURCE 1
> >  #define HAS_BOOL
> >  
> >  #include 
> > -- 
> > 2.1.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/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 01/15] kbuild: add support of custom paths for "auto.conf*" files

2014-10-23 Thread Alexis Berlemont
Michal Marek wrote:
> On 2014-09-22 23:53, Alexis Berlemont wrote:
> > In the scripts/Makefile.build, use KCONFIG_AUTOCONFIG to include a
> > custom path for the "auto.conf" file.
> > 
> > The "*conf" programs were modified so as to work with the environment
> > variable KCONFIG_AUTOCONFIG.
> > ---
> >  scripts/Makefile.build |  3 ++-
> >  scripts/kconfig/confdata.c | 27 ++-
> >  scripts/kconfig/lkc.h  |  1 +
> >  3 files changed, 29 insertions(+), 2 deletions(-)
> > 
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index bf3e677..ef60769 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -31,7 +31,8 @@ subdir-asflags-y :=
> >  subdir-ccflags-y :=
> >  
> >  # Read auto.conf if it exists, otherwise ignore
> > --include include/config/auto.conf
> > +kconfig-autoconfig := $(if 
> > $(KCONFIG_AUTOCONFIG),$(KCONFIG_AUTOCONFIG),include/config/auto.conf)
> > +-include $(kconfig-autoconfig)
> >  
> >  include scripts/Kbuild.include
> >  
> > diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> > index f88d90f..d4d8920 100644
> > --- a/scripts/kconfig/confdata.c
> > +++ b/scripts/kconfig/confdata.c
> > @@ -75,6 +75,27 @@ const char *conf_get_autoconfig_name(void)
> > return name ? name : "include/config/auto.conf";
> >  }
> >  
> > +#define PATH_MAXLENGTH 4096
> > +const char *conf_get_autoconfigdep_name(void)
> > +{
> > +   static char res_value[PATH_MAXLENGTH];
> > +
> > +   char *name = getenv("KCONFIG_AUTOCONFIG");
> > +
> > +   if (name == NULL)
> > +   name = "include/config/auto.conf.cmd";
> 
> This will result in "include/config/auto.conf.cmd.cmd". Better simplify
> it to name = conf_get_autoconfig_name().
> 

Sorry for such a terrible mistake. I broke everything just to make
kconfig work for perf...

> 
> > +   if (strlen(name) > PATH_MAXLENGTH - 5)
> > +   name = NULL;
> > +   else {
> > +   res_value[0] = 0;
> 
> This assignment is superfluous.

OK.

> 
> 
> > +   strncpy(res_value, name, PATH_MAXLENGTH);
> > +   strcat(res_value, ".cmd");
> > +   name = res_value;
> 
> Michal
> 

Alexis
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] perf tools: ensure return negitive value when write header error

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Wed, Oct 22, 2014 at 04:00:12PM +0900, Namhyung Kim escreveu:
> On Thu, 16 Oct 2014 11:08:29 +0800, Wang Nan wrote:
> > When 'perf record' write headers, it calls write_xxx in
> > tools/perf/util/header.c, and check return value. It rolls back all
> > working only when return value is negative.
> >
> > This patch ensures write_cpudesc() and write_total_mem() return negative 
> > number
> > when error. Without this patch, headers reported by 'perf report' header is
> > error in some platform. Following output is caputured on ARM, which doesn't
> > contain "Processor" field in /proc/cpuinfo. See "cpudesc", "total memory" 
> > and
> > "cmdline" field.
> >
> >bash-4.2# perf record ls
> >...
> >[ perf record: Woken up 1 times to write data ]
> >[ perf record: Captured and wrote 0.001 MB perf.data (~36 samples) ]
> >bash-4.2# perf report --stdio --header
> >Error:
> >The perf.data file has no samples!
> ># 
> ># captured on: Fri Sep 12 10:09:10 2014
> ># hostname : arma15el
> ># os release : 3.17.0+
> ># perf version : 3.10.53
> ># arch : armv7l
> ># nrcpus online : 4
> ># nrcpus avail : 1
> ># cpudesc : (null)
> ># total memory : 0 kB
> ># cmdline :
> ># event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 
> > = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, 
> > precise_ip = 0
> ># pmu mappings: not available
> ># 
> >#
> >
> > Signed-off-by: Wang Nan 
> 
> I guess the total_memory, cmdline and pmu mappings are somehow affected
> by the broken cpudesc.  Do they have their own problem on ARM?
> 
> Anyway I think it's good to check the result properly, so
> 
> Acked-by: Namhyung Kim 

Thanks, applied

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


Re: [PATCH 01/15] kbuild: add support of custom paths for "auto.conf*" files

2014-10-23 Thread Alexis Berlemont
Michal Marek wrote:
> On 2014-09-22 23:53, Alexis Berlemont wrote:
> > +#define PATH_MAXLENGTH 4096
> > +const char *conf_get_autoconfigdep_name(void)
> > +{
> > +   static char res_value[PATH_MAXLENGTH];
> 
> Please use the PATH_MAX macro instead.

One month later, I take time to answer and apologize... I have some
trouble with my free time. 

Thanks you. This is fixed in the next patch set.

Alexis
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: localed stuck in recent 3.18 git in copy_net_ns?

2014-10-23 Thread Yanko Kaneti

On Thu, 2014-10-23 at 13:05 -0700, Paul E. McKenney wrote:
> On Thu, Oct 23, 2014 at 10:51:59PM +0300, Yanko Kaneti wrote:
> > On Thu-10/23/14-2014 08:33, Paul E. McKenney wrote:
> > > On Thu, Oct 23, 2014 at 05:27:50AM -0700, Paul E. McKenney wrote:
> > > > On Thu, Oct 23, 2014 at 09:09:26AM +0300, Yanko Kaneti wrote:
> > > > > On Wed, 2014-10-22 at 16:24 -0700, Paul E. McKenney wrote:
> > > > > > On Thu, Oct 23, 2014 at 01:40:32AM +0300, Yanko Kaneti 
> > > > > > wrote:
> > > > > > > On Wed-10/22/14-2014 15:33, Josh Boyer wrote:
> > > > > > > > On Wed, Oct 22, 2014 at 2:55 PM, Paul E. McKenney
> > > > > > > >  wrote:
> > > > > > 
> > > > > > [ . . . ]
> > > > > > 
> > > > > > > > > Don't get me wrong -- the fact that this kthread 
> > > > > > > > > appears to
> > > > > > > > > have
> > > > > > > > > blocked within rcu_barrier() for 120 seconds means 
> > > > > > > > > that
> > > > > > > > > something is
> > > > > > > > > most definitely wrong here.  I am surprised that 
> > > > > > > > > there are no
> > > > > > > > > RCU CPU
> > > > > > > > > stall warnings, but perhaps the blockage is in the 
> > > > > > > > > callback
> > > > > > > > > execution
> > > > > > > > > rather than grace-period completion.  Or something is
> > > > > > > > > preventing this
> > > > > > > > > kthread from starting up after the wake-up callback 
> > > > > > > > > executes.
> > > > > > > > > Or...
> > > > > > > > > 
> > > > > > > > > Is this thing reproducible?
> > > > > > > > 
> > > > > > > > I've added Yanko on CC, who reported the backtrace 
> > > > > > > > above and can
> > > > > > > > recreate it reliably.  Apparently reverting the RCU 
> > > > > > > > merge commit
> > > > > > > > (d6dd50e) and rebuilding the latest after that does 
> > > > > > > > not show the
> > > > > > > > issue.  I'll let Yanko explain more and answer any 
> > > > > > > > questions you
> > > > > > > > have.
> > > > > > > 
> > > > > > > - It is reproducible
> > > > > > > - I've done another build here to double check and its 
> > > > > > > definitely
> > > > > > > the rcu merge
> > > > > > >   that's causing it.
> > > > > > > 
> > > > > > > Don't think I'll be able to dig deeper, but I can do 
> > > > > > > testing if
> > > > > > > needed.
> > > > > > 
> > > > > > Please!  Does the following patch help?
> > > > > 
> > > > > Nope, doesn't seem to make a difference to the modprobe 
> > > > > ppp_generic
> > > > > test
> > > > 
> > > > Well, I was hoping.  I will take a closer look at the RCU 
> > > > merge commit
> > > > and see what suggests itself.  I am likely to ask you to 
> > > > revert specific
> > > > commits, if that works for you.
> > > 
> > > Well, rather than reverting commits, could you please try 
> > > testing the
> > > following commits?
> > > 
> > > 11ed7f934cb8 (rcu: Make nocb leader kthreads process pending 
> > > callbacks after spawning)
> > > 
> > > 73a860cd58a1 (rcu: Replace flush_signals() with 
> > > WARN_ON(signal_pending()))
> > > 
> > > c847f14217d5 (rcu: Avoid misordering in nocb_leader_wait())
> > > 
> > > For whatever it is worth, I am guessing this one.
> > 
> > Indeed, c847f14217d5 it is.
> > 
> > Much to my embarrasment I just noticed that in addition to the
> > rcu merge, triggering the bug "requires" my specific Fedora 
> > rawhide network
> > setup. Booting in single mode and modprobe ppp_generic is fine. 
> > The bug
> > appears when starting with my regular fedora network setup, which 
> > in my case
> > includes 3 ethernet adapters and a libvirt birdge+nat setup.
> > 
> > Hope that helps.
> > 
> > I am attaching the config.
> 
> It does help a lot, thank you!!!
> 
> The following patch is a bit of a shot in the dark, and assumes that
> commit 1772947bd012 (rcu: Handle NOCB callbacks from irq-disabled 
> idle
> code) introduced the problem.  Does this patch fix things up?

Unfortunately not, This is linus-tip + patch


INFO: task kworker/u16:6:96 blocked for more than 120 seconds.
  Not tainted 3.18.0-rc1+ #4
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
kworker/u16:6   D 8800ca84cec0 1116896  2 0x
Workqueue: netns cleanup_net
 8802218339e8 0096 8800ca84cec0 001d5f00
 880221833fd8 001d5f00 880223264ec0 8800ca84cec0
 82c52040 7fff 81ee2658 81ee2650
Call Trace:
 [] schedule+0x29/0x70
 [] schedule_timeout+0x26c/0x410
 [] ? native_sched_clock+0x2a/0xa0
 [] ? mark_held_locks+0x7c/0xb0
 [] ? _raw_spin_unlock_irq+0x30/0x50
 [] ? trace_hardirqs_on_caller+0x15d/0x200
 [] wait_for_completion+0x10c/0x150
 [] ? wake_up_state+0x20/0x20
 [] _rcu_barrier+0x159/0x200
 [] rcu_barrier+0x15/0x20
 [] netdev_run_todo+0x6f/0x310
 [] ? rollback_registered_many+0x265/0x2e0
 [] rtnl_unlock+0xe/0x10
 [] default_device_exit_batch+0x156/0x180
 [] ? abort_exclusive_wait+0xb0/0xb0
 [] ops_exit_list.isra.1+0x53/0x60
 [] cleanup_net+0x100/0x1f0
 [] process_one_work+0x218/0x850
 [] ? 

Re: [PATCH 05/16] perf tools: Add facility to export data in database-friendly way

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Thu, Oct 23, 2014 at 01:45:13PM +0300, Adrian Hunter escreveu:
> This patch introduces an abstraction for exporting sample
> data in a database-friendly way.  The abstraction does not
> implement the actual output.  A subsequent patch takes this
> facility into use for extending the script interface.
> 
> The abstraction is needed because static data like symbols,
> dsos, comms etc need to be exported only once.  That means
> allocating them a unique identifier and recording it on each
> structure.  The member 'db_id' is used for that.  'db_id'
> is just a 64-bit sequence number.
> 
> Exporting centres around the db_export__sample() function
> which exports the associated data structures if they have
> not yet been allocated a db_id.

So this ends up bloating all data structures with 8 extra bytes, can't
we use the priv pointer that some of the structures already have for
tooling to put tool specific stuff?

In places like this:

> @@ -25,6 +25,7 @@ struct thread {
>   booldead; /* if set thread has exited */
>   struct list_headcomm_list;
>   int comm_len;
> + u64 db_id;
>  
>   void*priv;
>   struct thread_stack *ts;

Instead we would have:

union {
void*priv;
u64 db_id;
};

Using a unnamed union is all that is needed in struct thread case, I
think, the rest of your patch that deals with 'struct thread' doesn't
need to change and the end impact for other tools that have no use
whatsoever fot this thread->db_id is zero.

Because after all you will end up using some tool to just process
samples, etc, i.e. basically a 'perf report' like tool that instead of
creating hist_entries, etc will end up just populating the

machines ->
machine ->
threads ->
map_groups ->
map ->
dso ->
symbols

Hierarchy, right?

Struct symbol even has a mechanism for reserving space for private use,
that symbol_conf.priv_size + symbol__priv(), so that we don't incur even
in the cost of the priv pointer.

struct perf_evsel already has:

union {
void*priv;
off_t   id_offset;
};

Just add db_id there and the rest of your patch that deals with
perf_evsel will not need to be changed and again the impact for tools
that do not use this will be zero.

The other data structures that still don't have a ->priv area can have
one added.

I.e. tool specific bloating of core data structures should be avoided.

Fixing up these things will allow a good chunk of this patchkit to be
processed.

Thanks,

- Arnaldo
 
> Signed-off-by: Adrian Hunter 
> ---
>  tools/perf/Makefile.perf|   2 +
>  tools/perf/util/comm.h  |   1 +
>  tools/perf/util/db-export.c | 268 
> 
>  tools/perf/util/db-export.h |  86 ++
>  tools/perf/util/dso.h   |   1 +
>  tools/perf/util/evsel.h |   1 +
>  tools/perf/util/machine.h   |   1 +
>  tools/perf/util/symbol.h|   1 +
>  tools/perf/util/thread.h|   1 +
>  9 files changed, 362 insertions(+)
>  create mode 100644 tools/perf/util/db-export.c
>  create mode 100644 tools/perf/util/db-export.h
> 
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 5bbe1ff..9134c93 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -305,6 +305,7 @@ LIB_H += ui/ui.h
>  LIB_H += util/data.h
>  LIB_H += util/kvm-stat.h
>  LIB_H += util/thread-stack.h
> +LIB_H += util/db-export.h
>  
>  LIB_OBJS += $(OUTPUT)util/abspath.o
>  LIB_OBJS += $(OUTPUT)util/alias.o
> @@ -382,6 +383,7 @@ LIB_OBJS += $(OUTPUT)util/data.o
>  LIB_OBJS += $(OUTPUT)util/tsc.o
>  LIB_OBJS += $(OUTPUT)util/cloexec.o
>  LIB_OBJS += $(OUTPUT)util/thread-stack.o
> +LIB_OBJS += $(OUTPUT)util/db-export.o
>  
>  LIB_OBJS += $(OUTPUT)ui/setup.o
>  LIB_OBJS += $(OUTPUT)ui/helpline.o
> diff --git a/tools/perf/util/comm.h b/tools/perf/util/comm.h
> index 51c10ab..99e7021 100644
> --- a/tools/perf/util/comm.h
> +++ b/tools/perf/util/comm.h
> @@ -10,6 +10,7 @@ struct comm_str;
>  struct comm {
>   struct comm_str *comm_str;
>   u64 start;
> + u64 db_id;
>   struct list_head list;
>   bool exec;
>  };
> diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
> new file mode 100644
> index 000..53d0e75
> --- /dev/null
> +++ b/tools/perf/util/db-export.c
> @@ -0,0 +1,268 @@
> +/*
> + * db-export.c: Support for exporting data suitable for import to a database
> + * Copyright (c) 2014, Intel Corporation.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software 

[PATCH RFC] virtio_blk: WCE is assumed on under VIRTIO 1.0

2014-10-23 Thread Michael S. Tsirkin
Signed-off-by: Michael S. Tsirkin 
---
 drivers/block/virtio_blk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index adfba9f..1f8b111 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -478,7 +478,8 @@ static int virtblk_get_cache_mode(struct virtio_device 
*vdev)
   struct virtio_blk_config, wce,
   );
if (err)
-   writeback = virtio_has_feature(vdev, VIRTIO_BLK_F_WCE);
+   writeback = virtio_has_feature(vdev, VIRTIO_BLK_F_WCE) ||
+   virtio_has_feature(vdev, VIRTIO_F_VERSION_1);
 
return writeback;
 }
-- 
MST
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: rcu_preempt detected stalls.

2014-10-23 Thread Paul E. McKenney
On Thu, Oct 23, 2014 at 11:13:04PM +0200, Oleg Nesterov wrote:
> On 10/23, Paul E. McKenney wrote:
> >
> > Your code, your rules.  ;-)
> 
> Heh, no. I do not trust my (perverted) taste, I never-never
> argue with cosmetic issues ;)
> 
> Cough... and at the same time I have a small nit.

;-) ;-) ;-)

> > But given this structure, why not use a for() loop replace the
> > "goto retry" with an inverted condition and a "return error"?
> > Maybe something like the following patch?
> 
> Thanks,
> 
> Acked-by: Oleg Nesterov 

Got it, thank you!

Thanx, Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/5] Simplify hotplug/suspend handling

2014-10-23 Thread Saravana Kannan

On 10/16/2014 01:53 AM, Viresh Kumar wrote:

On 25 July 2014 06:37, Saravana Kannan  wrote:

Series of patchs to simplify policy/sysfs/kobj/locking handling across
suspend/resume

The following have been tested so far on a 2x2 cluster environment:
- Boot with 2 cpus and no cpufreq driver.
- mod probe driver and see cpufreq sysfs files show up only for the 1st cluster.
- Online the rest of the 2 CPUs and have files show up correctly.
- rmmod the driver and see the files go away.
- modprobe again (or back and forth multiples times) and see it work.
- suspend/resume works as expected.
- When a cluster is offline, all read/writes to its sysfs files return an error

v4
- Split it up into smaller patches
- Will handle physical CPU removal correctly
- Fixed earlier mistake of deleting code under !recover_policy
- Dropped some code refactor that reuses a lot of code between add/remove
- Dropped fix for exiting hotplug race with cpufreq driver probe/rmmod
- Dropped changes will come later once this series is acked.


Hi Saravana,

Any  updates on this? We might need some of this soon or should somebody
else start working on this ?



Hey,

Sorry for the delay. Got side tracked with some commercial stuff. I'm 
still invested in finishing this up. I'll try to send out something 
within a week.


I did notice (didn't read mych) the "Locking issues with cpufreq and 
sysfs" thread. I think my patches should side step most of it.


Thanks,
Saravana

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


[PATCH v2 1/1] ftruncate, truncate: create fanotify events

2014-10-23 Thread Heinrich Schuchardt
:: On Tue, 7 Oct 2014 21:23:30 Jan Kara wrote:
::
::   Yeah, so the reason why we don't generate FSNOTIFY_EVENT_PATH in
:: notify_change() is because we have only dentry available there. OTOH from a
:: quick look it doesn't look impossible to pass path there from the callers.
:: So I'd rather propagate path to notify_change() and generate also fanotify
:: events there than generating truncate events for fanotify separately
:: somewhere else...

The attached second version of the patch follows this idea of Jan.

The fanotify and fanotify API can be used to monitor changes of the file
system.

System calls ftruncate and truncate  modify files. Hence they should trigger
the corresponding fanotify (FAN_MODIFY) event.

Prior to the patch only a inotify (IN_MODIFY) event is triggered because
the path information is not passed to the notification framework.

The patch changes the interface of fsnotify_change to allow path information
to be passed. Fsnotify_change is only called by notify_change and by
fat_ioctl_set_attributes.

notify_change is called by a larger number of callers. Not all of these
have access to path object. To limit the number of changes the patch renames
notify_change to do_notify_change and adds a path parameter. The patch further
adds two wrappers: notify_change for callers that cannot provide a path
and notify_change_path for callers that can provide a path.

The patch changes do_truncate to accept a path parameter passed to
notify_change_path and adjusts all callers of do_truncate.

Signed-off-by: Heinrich Schuchardt 
---
 fs/attr.c| 35 ---
 fs/fat/file.c|  2 +-
 fs/namei.c   |  2 +-
 fs/open.c| 10 ++
 include/linux/fs.h   |  3 ++-
 include/linux/fsnotify.h | 12 +---
 6 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index 6530ced..894967e 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -168,13 +168,17 @@ void setattr_copy(struct inode *inode, const struct iattr 
*attr)
 EXPORT_SYMBOL(setattr_copy);
 
 /**
- * notify_change - modify attributes of a filesytem object
+ * do_notify_change - modify attributes of a filesytem object
+ * @path:  path of object affected
  * @dentry:object affected
  * @iattr: new attributes
  * @delegated_inode: returns inode, if the inode is delegated
  *
  * The caller must hold the i_mutex on the affected object.
  *
+ * If NULL is passed in attribute path, fanotify events cannot be
+ * created.
+ *
  * If notify_change discovers a delegation in need of breaking,
  * it will return -EWOULDBLOCK and return a reference to the inode in
  * delegated_inode.  The caller should then break the delegation and
@@ -187,7 +191,8 @@ EXPORT_SYMBOL(setattr_copy);
  * the file open for write, as there can be no conflicting delegation in
  * that case.
  */
-int notify_change(struct dentry * dentry, struct iattr * attr, struct inode 
**delegated_inode)
+int do_notify_change(struct path *path, struct dentry *dentry,
+   struct iattr *attr, struct inode **delegated_inode)
 {
struct inode *inode = dentry->d_inode;
umode_t mode = inode->i_mode;
@@ -268,11 +273,35 @@ int notify_change(struct dentry * dentry, struct iattr * 
attr, struct inode **de
error = simple_setattr(dentry, attr);
 
if (!error) {
-   fsnotify_change(dentry, ia_valid);
+   fsnotify_change(path, dentry, ia_valid);
ima_inode_post_setattr(dentry);
evm_inode_post_setattr(dentry, ia_valid);
}
 
return error;
 }
+
+/*
+ * notify_change - modify attributes of a filesytem object
+ *
+ * This call will not create fanotify events. It should be replaced by
+ * notify_change_path where possible.
+ */
+int notify_change(struct dentry *dentry, struct iattr *attr,
+   struct inode **delegated_inode)
+{
+   return do_notify_change(NULL, dentry, attr, delegated_inode);
+}
 EXPORT_SYMBOL(notify_change);
+
+/*
+ * notify_change_path - modify attributes of a filesytem object
+ *
+ * This call is a replacement for notify_change. It creates fanotify events.
+ */
+int notify_change_path(struct path *path, struct iattr *attr,
+   struct inode **delegated_inode)
+{
+   return do_notify_change(path, path->dentry, attr, delegated_inode);
+}
+EXPORT_SYMBOL(notify_change_path);
diff --git a/fs/fat/file.c b/fs/fat/file.c
index f2c73ae..d293a0b 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -101,7 +101,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 
__user *user_attr)
if (err)
goto out_unlock_inode;
 
-   fsnotify_change(file->f_path.dentry, ia.ia_valid);
+   fsnotify_change(>f_path, file->f_path.dentry, ia.ia_valid);
if (sbi->options.sys_immutable) {
if (attr & ATTR_SYS)
inode->i_flags |= S_IMMUTABLE;
diff --git a/fs/namei.c b/fs/namei.c
index 43927d1..0a1f3b7 

Re: GPIO bindings guidelines (Was: Re: [PATCH v5 10/12] gpio: Support for unified device properties interface)

2014-10-23 Thread Rafael J. Wysocki
On Thursday, October 23, 2014 03:56:55 PM Mika Westerberg wrote:
> On Thu, Oct 23, 2014 at 01:21:06AM +0200, Rafael J. Wysocki wrote:
> > OK, would the below make sense, then (completely untested, on top of the v6
> > of the device properties patchset)?
> 
> Yes it does :-)
> 
> With the the below fix it works nicely with the modified rfkill-gpio.c
> driver.
> 
> > +static bool acpi_get_driver_gpio_data(struct acpi_device *adev,
> > + const char *name,
> > + struct acpi_reference_args *args)
> > +{
> > +   struct acpi_gpio_data *gd;
> > +
> > +   mutex_lock(_gpio_data_lock);
> > +
> > +   list_for_each_entry(gd, >driver_gpios, item)
> > +   if (!strcmp(name, gd->name)) {
> > +   args->adev = adev;
> > +   args->args[0] = gd->entry_index;
> > +   args->args[1] = gd->pin_index;
> > +   args->args[2] = gd->active_low;
> > +   args->nargs = 3;
> 
>   mutex_unlock(_gpio_data_lock);
> 
> > +   return true;
> > +   }
> > +
> > +   mutex_unlock(_gpio_data_lock);
> > +
> > +   return false;
> > +}
> 
> Also I think the two functions should be exported to modules as well.
> 
> Here are the modifications needed for rfkill-gpio.c driver. I think it
> is not that bad considering that now the driver supports both ACPI _DSD
> and non-_DSD at the same time.

OK, let's try to take that a bit farther. :-)

With the (untested) patch below applied (which is a replacement for the one
sent previously), the driver can use static tables like these:

static struct acpi_gpio_params reset_gpios = { 0, 0, false };
statuc struct acpi_gpio_params shutdown_gpios = { 1, 0, false };

static struct acpi_gpio_mapping my_gpio_mapping[] = {
{ "reset-gpios", _gpios, 1 },
{ "shutdown-gpios", _gpios, 1 },
NULL,
};

->

> 
> diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
> index 0f62326c0f5e..f8754e7d81ea 100644
> --- a/net/rfkill/rfkill-gpio.c
> +++ b/net/rfkill/rfkill-gpio.c
> @@ -67,6 +67,8 @@ static int rfkill_gpio_acpi_probe(struct device *dev,
> struct rfkill_gpio_data *rfkill)
>  {
>   const struct acpi_device_id *id;
> + struct acpi_device *adev = ACPI_COMPANION(dev);
> + int ret;
>  
>   id = acpi_match_device(dev->driver->acpi_match_table, dev);
>   if (!id)
> @@ -75,6 +77,20 @@ static int rfkill_gpio_acpi_probe(struct device *dev,
>   rfkill->name = dev_name(dev);
>   rfkill->type = (unsigned)id->driver_data;
>  
> + /*
> +  * Add default mapping for ACPI _DSD properties now just in case
> +  * there is no _DSD for this device.
> +  */
> + ret = acpi_dev_add_driver_gpio(adev, "reset-gpios", 0, 0, false);
> + if (ret)
> + return ret;
> +
> + ret = acpi_dev_add_driver_gpio(adev, "shutdown-gpios", 1, 0, false);
> + if (ret) {
> + acpi_dev_remove_driver_gpios(adev);
> + return ret;
> + }

-> and then simply do

ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), _gpio_mapping);

instead of the above.

>   return 0;
>  }
>  
> @@ -110,7 +126,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
>   rfkill->reset_gpio = gpio;
>   }
>  
> - gpio = devm_gpiod_get_index(>dev, "shutdown", 1);
> + gpio = devm_gpiod_get_index(>dev, "shutdown", 0);
>   if (!IS_ERR(gpio)) {
>   ret = gpiod_direction_output(gpio, 0);
>   if (ret)
> @@ -150,6 +166,9 @@ static int rfkill_gpio_remove(struct platform_device 
> *pdev)
>   rfkill_unregister(rfkill->rfkill_dev);
>   rfkill_destroy(rfkill->rfkill_dev);
>  
> + if (ACPI_COMPANION(>dev))
> + acpi_dev_remove_driver_gpios(ACPI_COMPANION(>dev));
> +

And here simply 

acpi_dev_remove_driver_gpios(ACPI_COMPANION(>dev));

>   return 0;
>  }

and then we can even cover situations in which there is one name for a list of
GPIOs.

Rafael


---
 drivers/gpio/gpiolib-acpi.c |   40 ++--
 include/acpi/acpi_bus.h |3 +++
 include/linux/acpi.h|   30 ++
 3 files changed, 71 insertions(+), 2 deletions(-)

Index: linux-pm/include/acpi/acpi_bus.h
===
--- linux-pm.orig/include/acpi/acpi_bus.h
+++ linux-pm/include/acpi/acpi_bus.h
@@ -345,6 +345,8 @@ struct acpi_device_data {
const union acpi_object *of_compatible;
 };
 
+struct acpi_gpio_mapping;
+
 /* Device */
 struct acpi_device {
int device_type;
@@ -366,6 +368,7 @@ struct acpi_device {
struct acpi_scan_handler *handler;
struct acpi_hotplug_context *hp;
struct acpi_driver *driver;
+   struct acpi_gpio_mapping *driver_gpios;
void *driver_data;
struct device dev;
unsigned int physical_node_count;

Re: unaligned accesses in SLAB etc.

2014-10-23 Thread David Miller
From: David Miller 
Date: Thu, 23 Oct 2014 13:02:58 -0400 (EDT)

> From: Meelis Roos 
> Date: Thu, 23 Oct 2014 02:22:36 +0300 (EEST)
> 
>>> Whilst I don't have access to my reproducer machine until tomorrow in
>>> order to test this myself, I wanted to toss this patch your way so you
>>> could get a head start on me.
>> 
>> Unfortunately it fails earlier during the boot:
>> 
>> [   25.232318] clocksource: mult[5355] shift[24]
>> [   25.288559] clockevent: mult[3126e98] shift[32]
>> [   25.342813] Console: colour dummy device 80x25
>> [   25.395990] console [tty0] enabled
>> [   25.436726] bootconsole [earlyprom0] disabled
>> ERROR: Last Trap: Memory Address not Aligned
>> 
>> ok
> 
> I can reproduce and I know what the problem is, fixed patch coming up
> shortly.

Ok, please test this patch below.

I tested the full matrix of pre-gcc-4.9, gcc-4.9, hypervisor boot
without HOTPLUG_CPU enabled, hypervisor boot with HOTPLUG_CPU enabled,
pre-hypervisor boot.


[PATCH] sparc64: Fix register corruption in top-most kernel stack frame during 
boot.

Meelis Roos reported that kernels built with gcc-4.9 do not boot, we
eventually narrowed this down to only impacting machines using
UltraSPARC-III and derivitive cpus.

The crash happens right when the first user process is spawned:

[   54.451346] Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x0004
[   54.451346]
[   54.571516] CPU: 1 PID: 1 Comm: init Not tainted 3.16.0-rc2-00211-gd7933ab 
#96
[   54.666431] Call Trace:
[   54.698453]  [00762f8c] panic+0xb0/0x224
[   54.759071]  [0045cf68] do_exit+0x948/0x960
[   54.823123]  [0042cbc0] fault_in_user_windows+0xe0/0x100
[   54.902036]  [00404ad0] __handle_user_windows+0x0/0x10
[   54.978662] Press Stop-A (L1-A) to return to the boot prom
[   55.050713] ---[ end Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x0004

Further investigation showed that compiling only per_cpu_patch() with
an older compiler fixes the boot.

Detailed analysis showed that the function is not being miscompiled by
gcc-4.9, but it is using a different register allocation ordering.

With the gcc-4.9 compiled function, something during the code patching
causes some of the %i* input registers to get corrupted.  Perhaps
we have a TLB miss path into the firmware that is deep enough to
cause a register window spill and subsequent restore when we get
back from the TLB miss trap.

Let's plug this up by doing two things:

1) Stop using the firmware stack for client interface calls into
   the firmware.  Just use the kernel's stack.

2) As soon as we can, call into a new function "start_early_boot()"
   to put a one-register-window buffer between the firmware's
   deepest stack frame and the top-most initial kernel one.

Reported-by: Meelis Roos 
Signed-off-by: David S. Miller 
---
 arch/sparc/include/asm/oplib_64.h |  3 ++-
 arch/sparc/kernel/entry.h |  3 ---
 arch/sparc/kernel/head_64.S   | 38 +-
 arch/sparc/kernel/hvtramp.S   |  1 -
 arch/sparc/kernel/setup_64.c  | 28 
 arch/sparc/kernel/trampoline_64.S | 12 +++-
 arch/sparc/prom/cif.S |  5 ++---
 arch/sparc/prom/init_64.c |  6 +++---
 arch/sparc/prom/p1275.c   |  2 --
 9 files changed, 35 insertions(+), 63 deletions(-)

diff --git a/arch/sparc/include/asm/oplib_64.h 
b/arch/sparc/include/asm/oplib_64.h
index f346824..2e3a4ad 100644
--- a/arch/sparc/include/asm/oplib_64.h
+++ b/arch/sparc/include/asm/oplib_64.h
@@ -62,7 +62,8 @@ struct linux_mem_p1275 {
 /* You must call prom_init() before using any of the library services,
  * preferably as early as possible.  Pass it the romvec pointer.
  */
-void prom_init(void *cif_handler, void *cif_stack);
+void prom_init(void *cif_handler);
+void prom_init_report(void);
 
 /* Boot argument acquisition, returns the boot command line string. */
 char *prom_getbootargs(void);
diff --git a/arch/sparc/kernel/entry.h b/arch/sparc/kernel/entry.h
index ebaba61..88d322b 100644
--- a/arch/sparc/kernel/entry.h
+++ b/arch/sparc/kernel/entry.h
@@ -65,13 +65,10 @@ struct pause_patch_entry {
 extern struct pause_patch_entry __pause_3insn_patch,
__pause_3insn_patch_end;
 
-void __init per_cpu_patch(void);
 void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *,
 struct sun4v_1insn_patch_entry *);
 void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *,
 struct sun4v_2insn_patch_entry *);
-void __init sun4v_patch(void);
-void __init boot_cpu_id_too_large(int cpu);
 extern unsigned int dcache_parity_tl1_occurred;
 extern unsigned int icache_parity_tl1_occurred;
 
diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
index 4fdeb80..43e27ce 100644
--- a/arch/sparc/kernel/head_64.S
+++ b/arch/sparc/kernel/head_64.S
@@ -672,14 +672,12 @@ tlb_fixup_done:
sethi   

Re: [fuse-devel] [PATCH v4 4/5] fuse: Support privileged xattrs only with a mount option

2014-10-23 Thread Seth Forshee
On Thu, Oct 23, 2014 at 11:32:41AM -0700, Andy Lutomirski wrote:
> On Oct 21, 2014 9:59 PM, "Seth Forshee"  wrote:
> >
> > On Tue, Oct 21, 2014 at 02:27:13PM -0700, Andy Lutomirski wrote:
> > > On Tue, Oct 21, 2014 at 2:21 PM, Seth Forshee
> > >
> > > > return s;
> > > >
> > > >  fail:
> > > > diff --git a/fs/xattr.c b/fs/xattr.c
> > > > index 64e83efb742d..383bb9f2 100644
> > > > --- a/fs/xattr.c
> > > > +++ b/fs/xattr.c
> > > > @@ -40,6 +40,12 @@ xattr_permission(struct inode *inode, const char 
> > > > *name, int mask)
> > > > return -EPERM;
> > > > }
> > > >
> > > > +   /* Restrict security.* and trusted.* to mounts from 
> > > > init_user_ns. */
> > > > +   if (inode->i_sb->s_user_ns != _user_ns &&
> > > > +   (!strcmp(name, XATTR_SECURITY_PREFIX, 
> > > > XATTR_SECURITY_PREFIX_LEN) ||
> > > > +!strcmp(name, XATTR_TRUSTED_PREFIX, 
> > > > XATTR_TRUSTED_PREFIX_LEN)))
> > > > +   return -EPERM;
> > > > +
> > >
> > > trusted.* should be fine already, I think -- it checks global
> > > capabilities.  And I still think that security.* should be left to
> > > LSMs, which IMO really do need to be fixed for user namespaces.
> > >
> > > But how does this help with FUSE at all?   Does FUSE end up calling
> > > xattr_permission?
> >
> > It gets called from vfs_getxattr, and thus for the getxattr syscall for
> > all fs types, so this would block reading any trusted.* xattrs from the
> > fuse userspace process.
> 
> Oh.  It seems weird to me that getxattr would get an error instead of
> FUSE being prevented from setting those attributes.
> 
> I'm still unconvinced that this is the right approach.  And anything
> that tries to use LSMs in a container will eventually want those
> attributes.

I suppose so. I'll have to think about this some more.

Thanks,
Seth
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 RFC 4/4] virtio_net: bigger header when VERSION_1 is set

2014-10-23 Thread Michael S. Tsirkin
With VERSION_1 virtio_net uses same header size
whether mergeable buffers are enabled or not.

Signed-off-by: Michael S. Tsirkin 
---
 drivers/net/virtio_net.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 9c6d50f..a2fe340 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1764,7 +1764,8 @@ static int virtnet_probe(struct virtio_device *vdev)
if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
vi->mergeable_rx_bufs = true;
 
-   if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
+   if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF) ||
+   virtio_has_feature(vdev, VIRTIO_F_VERSION_1))
vi->hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf);
else
vi->hdr_len = sizeof(struct virtio_net_hdr);
-- 
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 RFC 3/4] virtio_net: stricter short buffer length checks

2014-10-23 Thread Michael S. Tsirkin
Our buffer length check is not strict enough for mergeable
buffers: buffer can still be shorter that header + address
by 2 bytes.

Fix that up.

Signed-off-by: Michael S. Tsirkin 
---
 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index a795a23..9c6d50f 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -437,7 +437,7 @@ static void receive_buf(struct virtnet_info *vi, struct 
receive_queue *rq,
struct sk_buff *skb;
struct virtio_net_hdr_mrg_rxbuf *hdr;
 
-   if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
+   if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
pr_debug("%s: short packet %i\n", dev->name, len);
dev->stats.rx_length_errors++;
if (vi->mergeable_rx_bufs) {
-- 
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 RFC 1/4] virtio_net: pass vi around

2014-10-23 Thread Michael S. Tsirkin
Too many places poke at [rs]q->vq->vdev->priv just to get
the the vi structure.  Let's just pass the pointer around: seems
cleaner, and might even be faster.

Signed-off-by: Michael S. Tsirkin 
---
 drivers/net/virtio_net.c | 36 +++-
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 57cbc7d..36f3dfc 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -241,11 +241,11 @@ static unsigned long mergeable_buf_to_ctx(void *buf, 
unsigned int truesize)
 }
 
 /* Called from bottom half context */
-static struct sk_buff *page_to_skb(struct receive_queue *rq,
+static struct sk_buff *page_to_skb(struct virtnet_info *vi,
+  struct receive_queue *rq,
   struct page *page, unsigned int offset,
   unsigned int len, unsigned int truesize)
 {
-   struct virtnet_info *vi = rq->vq->vdev->priv;
struct sk_buff *skb;
struct skb_vnet_hdr *hdr;
unsigned int copy, hdr_len, hdr_padded_len;
@@ -328,12 +328,13 @@ static struct sk_buff *receive_small(void *buf, unsigned 
int len)
 }
 
 static struct sk_buff *receive_big(struct net_device *dev,
+  struct virtnet_info *vi,
   struct receive_queue *rq,
   void *buf,
   unsigned int len)
 {
struct page *page = buf;
-   struct sk_buff *skb = page_to_skb(rq, page, 0, len, PAGE_SIZE);
+   struct sk_buff *skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE);
 
if (unlikely(!skb))
goto err;
@@ -359,7 +360,8 @@ static struct sk_buff *receive_mergeable(struct net_device 
*dev,
int offset = buf - page_address(page);
unsigned int truesize = max(len, mergeable_ctx_to_buf_truesize(ctx));
 
-   struct sk_buff *head_skb = page_to_skb(rq, page, offset, len, truesize);
+   struct sk_buff *head_skb = page_to_skb(vi, rq, page, offset, len,
+  truesize);
struct sk_buff *curr_skb = head_skb;
 
if (unlikely(!curr_skb))
@@ -433,9 +435,9 @@ err_buf:
return NULL;
 }
 
-static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
+static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
+   void *buf, unsigned int len)
 {
-   struct virtnet_info *vi = rq->vq->vdev->priv;
struct net_device *dev = vi->dev;
struct virtnet_stats *stats = this_cpu_ptr(vi->stats);
struct sk_buff *skb;
@@ -459,9 +461,9 @@ static void receive_buf(struct receive_queue *rq, void 
*buf, unsigned int len)
if (vi->mergeable_rx_bufs)
skb = receive_mergeable(dev, vi, rq, (unsigned long)buf, len);
else if (vi->big_packets)
-   skb = receive_big(dev, rq, buf, len);
+   skb = receive_big(dev, vi, rq, buf, len);
else
-   skb = receive_small(buf, len);
+   skb = receive_small(vi, buf, len);
 
if (unlikely(!skb))
return;
@@ -530,9 +532,9 @@ frame_err:
dev_kfree_skb(skb);
 }
 
-static int add_recvbuf_small(struct receive_queue *rq, gfp_t gfp)
+static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
+gfp_t gfp)
 {
-   struct virtnet_info *vi = rq->vq->vdev->priv;
struct sk_buff *skb;
struct skb_vnet_hdr *hdr;
int err;
@@ -655,9 +657,9 @@ static int add_recvbuf_mergeable(struct receive_queue *rq, 
gfp_t gfp)
  * before we're receiving packets, or from refill_work which is
  * careful to disable receiving (using napi_disable).
  */
-static bool try_fill_recv(struct receive_queue *rq, gfp_t gfp)
+static bool try_fill_recv(struct virtnet_info *vi, struct receive_queue *rq,
+ gfp_t gfp)
 {
-   struct virtnet_info *vi = rq->vq->vdev->priv;
int err;
bool oom;
 
@@ -668,7 +670,7 @@ static bool try_fill_recv(struct receive_queue *rq, gfp_t 
gfp)
else if (vi->big_packets)
err = add_recvbuf_big(rq, gfp);
else
-   err = add_recvbuf_small(rq, gfp);
+   err = add_recvbuf_small(vi, rq, gfp);
 
oom = err == -ENOMEM;
if (err)
@@ -717,7 +719,7 @@ static void refill_work(struct work_struct *work)
struct receive_queue *rq = >rq[i];
 
napi_disable(>napi);
-   still_empty = !try_fill_recv(rq, GFP_KERNEL);
+   still_empty = !try_fill_recv(vi, rq, GFP_KERNEL);
virtnet_napi_enable(rq);
 
/* In theory, this can happen: if we don't get any buffers in
@@ -736,12 +738,12 @@ static int virtnet_receive(struct receive_queue *rq, int 
budget)
 

[PATCH RFC 2/4] virtio_net: get rid of virtio_net_hdr/skb_vnet_hdr

2014-10-23 Thread Michael S. Tsirkin
virtio 1.0 doesn't use virtio_net_hdr anymore, and in fact, it's not
really useful since virtio_net_hdr_mrg_rxbuf includes that as the first
field anyway.

Let's drop it, precalculate header len and store within vi instead.

This way we can also remove struct skb_vnet_hdr.

Signed-off-by: Michael S. Tsirkin 
---
 drivers/net/virtio_net.c | 88 ++--
 1 file changed, 40 insertions(+), 48 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 36f3dfc..a795a23 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -123,6 +123,9 @@ struct virtnet_info {
/* Host can handle any s/g split between our header and packet data */
bool any_header_sg;
 
+   /* Packet virtio header size */
+   u8 hdr_len;
+
/* Active statistics */
struct virtnet_stats __percpu *stats;
 
@@ -139,21 +142,14 @@ struct virtnet_info {
struct notifier_block nb;
 };
 
-struct skb_vnet_hdr {
-   union {
-   struct virtio_net_hdr hdr;
-   struct virtio_net_hdr_mrg_rxbuf mhdr;
-   };
-};
-
 struct padded_vnet_hdr {
-   struct virtio_net_hdr hdr;
+   struct virtio_net_hdr_mrg_rxbuf hdr;
/*
-* virtio_net_hdr should be in a separated sg buffer because of a
-* QEMU bug, and data sg buffer shares same page with this header sg.
-* This padding makes next sg 16 byte aligned after virtio_net_hdr.
+* hdr is in a separate sg buffer, and data sg buffer shares same page
+* with this header sg. This padding makes next sg 16 byte aligned
+* after the header.
 */
-   char padding[6];
+   char padding[4];
 };
 
 /* Converting between virtqueue no. and kernel tx/rx queue no.
@@ -179,9 +175,9 @@ static int rxq2vq(int rxq)
return rxq * 2;
 }
 
-static inline struct skb_vnet_hdr *skb_vnet_hdr(struct sk_buff *skb)
+static inline struct virtio_net_hdr_mrg_rxbuf *skb_vnet_hdr(struct sk_buff 
*skb)
 {
-   return (struct skb_vnet_hdr *)skb->cb;
+   return (struct virtio_net_hdr_mrg_rxbuf *)skb->cb;
 }
 
 /*
@@ -247,7 +243,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
   unsigned int len, unsigned int truesize)
 {
struct sk_buff *skb;
-   struct skb_vnet_hdr *hdr;
+   struct virtio_net_hdr_mrg_rxbuf *hdr;
unsigned int copy, hdr_len, hdr_padded_len;
char *p;
 
@@ -260,13 +256,11 @@ static struct sk_buff *page_to_skb(struct virtnet_info 
*vi,
 
hdr = skb_vnet_hdr(skb);
 
-   if (vi->mergeable_rx_bufs) {
-   hdr_len = sizeof hdr->mhdr;
-   hdr_padded_len = sizeof hdr->mhdr;
-   } else {
-   hdr_len = sizeof hdr->hdr;
+   hdr_len = vi->hdr_len;
+   if (vi->mergeable_rx_bufs)
+   hdr_padded_len = sizeof *hdr;
+   else
hdr_padded_len = sizeof(struct padded_vnet_hdr);
-   }
 
memcpy(hdr, p, hdr_len);
 
@@ -317,11 +311,11 @@ static struct sk_buff *page_to_skb(struct virtnet_info 
*vi,
return skb;
 }
 
-static struct sk_buff *receive_small(void *buf, unsigned int len)
+static struct sk_buff *receive_small(struct virtnet_info *vi, void *buf, 
unsigned int len)
 {
struct sk_buff * skb = buf;
 
-   len -= sizeof(struct virtio_net_hdr);
+   len -= vi->hdr_len;
skb_trim(skb, len);
 
return skb;
@@ -354,8 +348,8 @@ static struct sk_buff *receive_mergeable(struct net_device 
*dev,
 unsigned int len)
 {
void *buf = mergeable_ctx_to_buf_address(ctx);
-   struct skb_vnet_hdr *hdr = buf;
-   u16 num_buf = virtio16_to_cpu(rq->vq->vdev, hdr->mhdr.num_buffers);
+   struct virtio_net_hdr_mrg_rxbuf *hdr = buf;
+   u16 num_buf = virtio16_to_cpu(vi->vdev, hdr->num_buffers);
struct page *page = virt_to_head_page(buf);
int offset = buf - page_address(page);
unsigned int truesize = max(len, mergeable_ctx_to_buf_truesize(ctx));
@@ -373,8 +367,8 @@ static struct sk_buff *receive_mergeable(struct net_device 
*dev,
if (unlikely(!ctx)) {
pr_debug("%s: rx error: %d buffers out of %d missing\n",
 dev->name, num_buf,
-virtio16_to_cpu(rq->vq->vdev,
-hdr->mhdr.num_buffers));
+virtio16_to_cpu(vi->vdev,
+hdr->num_buffers));
dev->stats.rx_length_errors++;
goto err_buf;
}
@@ -441,7 +435,7 @@ static void receive_buf(struct virtnet_info *vi, struct 
receive_queue *rq,
struct net_device *dev = vi->dev;
struct virtnet_stats *stats = this_cpu_ptr(vi->stats);
struct sk_buff *skb;
-   struct skb_vnet_hdr *hdr;
+   struct 

[PATCH v2] powernv/iommu: disable IOMMU bypass with param iommu=nobypass

2014-10-23 Thread Thadeu Lima de Souza Cascardo
When IOMMU bypass is enabled, a PCI device can read and write memory
that was not mapped by the driver without causing an EEH. That might
cause memory corruption, for example.

When we disable bypass, DMA reads and writes to addresses not mapped by
the IOMMU will cause an EEH, allowing us to debug such issues.

Signed-off-by: Thadeu Lima de Souza Cascardo 
Reviewed-by: Gavin Shan 
---
 Documentation/kernel-parameters.txt   |2 ++
 arch/powerpc/platforms/powernv/pci-ioda.c |   24 +++-
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index 988160a..b03322a 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1454,6 +1454,8 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
forcesac
soft
pt  [x86, IA-64]
+   nobypass[PPC/POWERNV]
+   Disable IOMMU bypass, using IOMMU for PCI devices.
 
 
io7=[HW] IO7 for Marvel based alpha systems
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index 468a0f2..a7d2f32 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -75,6 +75,27 @@ static void pe_level_printk(const struct pnv_ioda_pe *pe, 
const char *level,
 #define pe_info(pe, fmt, ...)  \
pe_level_printk(pe, KERN_INFO, fmt, ##__VA_ARGS__)
 
+static bool pnv_iommu_bypass_disabled __read_mostly;
+
+static int __init iommu_setup(char *str)
+{
+   if (!str)
+   return -EINVAL;
+   while (*str) {
+   if (!strncmp(str, "nobypass", 8)) {
+   pnv_iommu_bypass_disabled = true;
+   pr_info("PowerNV: IOMMU bypass window disabled.\n");
+   }
+   str += strcspn(str, ",");
+   if (*str == ',')
+   str++;
+   }
+
+   return 0;
+}
+
+early_param("iommu", iommu_setup);
+
 /*
  * stdcix is only supposed to be used in hypervisor real mode as per
  * the architecture spec
@@ -1243,7 +1264,8 @@ static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb 
*phb,
pnv_ioda_setup_bus_dma(pe, pe->pbus, true);
 
/* Also create a bypass window */
-   pnv_pci_ioda2_setup_bypass_pe(phb, pe);
+   if (!pnv_iommu_bypass_disabled)
+   pnv_pci_ioda2_setup_bypass_pe(phb, pe);
return;
 fail:
if (pe->tce32_seg >= 0)
-- 
1.7.1

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


Re: rcu_preempt detected stalls.

2014-10-23 Thread Oleg Nesterov
On 10/23, Paul E. McKenney wrote:
>
> Your code, your rules.  ;-)

Heh, no. I do not trust my (perverted) taste, I never-never
argue with cosmetic issues ;)

Cough... and at the same time I have a small nit.

> But given this structure, why not use a for() loop replace the
> "goto retry" with an inverted condition and a "return error"?
> Maybe something like the following patch?

Thanks,

Acked-by: Oleg Nesterov 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 00/16] perf tools: Intel PT preparation continued

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Thu, Oct 23, 2014 at 01:45:08PM +0300, Adrian Hunter escreveu:
> Hi
> 
> Here are the remaining Intel PT preparation patches.  They are
> all patches that have been posted before, although "perf tools:
> Do not attempt to run perf-read-vdso32 if it wasn't built" wasn't
> sent as a separate email.
> 
> With regard to "32-bit compatibility VDSOs", you may recall that
> Ingo had a problem getting "sh: perf-read-vdso32: command not found".
> That message is inevitable when using popen to run perf-read-vdso32
> and perf-read-vdso32 cannot be found.  At least with the patch
> "perf tools: Do not attempt to run perf-read-vdso32 if it wasn't built"
> one reason for the message is eliminated.

The above patches I will try to process, look ok but since they are at
the end of the patch kit, it conflicts if I don't process the ones at
the start of the patchkit, which I am still not confortable merging.

- Arnaldo
 
> It would be nice to target 3.19 for Intel PT, but there are still the
> real patches of which there are about 48.
> 
> 
> Adrian Hunter (16):
>   perf tools: Add id index
>   perf pmu: Let pmu's with no events show up on perf list
>   perf session: Add perf_session__deliver_synth_event()
>   perf tools: Add a thread stack for synthesizing call chains
>   perf tools: Add facility to export data in database-friendly way
>   perf tools: Extend Python script interface to export data in a 
> database-friendly way
>   perf tools: Add Python script to export to postgresql
>   perf tools: Add branch type to db export
>   perf tools: Add branch_type and in_tx to Python export
>   perf tools: Enhance the thread stack to output call/return data
>   perf tools: Add call information to the database export API
>   perf tools: Add call information to Python export
>   perf tools: Defer export of comms that were not 'set'
>   perf tools: Build programs to copy 32-bit compatibility VDSOs
>   perf tools: Add support for 32-bit compatibility VDSOs
>   perf tools: Do not attempt to run perf-read-vdso32 if it wasn't built
> 
>  tools/perf/Makefile.perf   |  42 +-
>  tools/perf/builtin-inject.c|   1 +
>  tools/perf/config/Makefile |  29 +-
>  tools/perf/config/Makefile.arch|   8 +
>  tools/perf/config/feature-checks/Makefile  |  10 +-
>  tools/perf/config/feature-checks/test-compile.c|   4 +
>  tools/perf/perf-read-vdso.c|  34 +
>  .../scripts/python/bin/export-to-postgresql-record |   8 +
>  .../scripts/python/bin/export-to-postgresql-report |  29 +
>  tools/perf/scripts/python/export-to-postgresql.py  | 444 +
>  tools/perf/util/comm.h |   1 +
>  tools/perf/util/db-export.c| 426 +
>  tools/perf/util/db-export.h| 107 
>  tools/perf/util/dso.h  |   1 +
>  tools/perf/util/event.c|   1 +
>  tools/perf/util/event.h|  41 ++
>  tools/perf/util/evlist.c   |  26 +-
>  tools/perf/util/evsel.h|   4 +
>  tools/perf/util/find-vdso-map.c|  30 +
>  tools/perf/util/machine.h  |   1 +
>  tools/perf/util/pmu.c  |  13 +-
>  tools/perf/util/pmu.h  |   1 +
>  .../util/scripting-engines/trace-event-python.c| 395 +++-
>  tools/perf/util/session.c  | 136 
>  tools/perf/util/session.h  |  15 +
>  tools/perf/util/symbol.h   |   1 +
>  tools/perf/util/thread-stack.c | 690 
> +
>  tools/perf/util/thread-stack.h |  79 +++
>  tools/perf/util/thread.c   |   3 +
>  tools/perf/util/thread.h   |   4 +
>  tools/perf/util/tool.h |   3 +-
>  tools/perf/util/vdso.c | 217 ++-
>  tools/perf/util/vdso.h |   4 +-
>  33 files changed, 2760 insertions(+), 48 deletions(-)
>  create mode 100644 tools/perf/config/feature-checks/test-compile.c
>  create mode 100644 tools/perf/perf-read-vdso.c
>  create mode 100644 tools/perf/scripts/python/bin/export-to-postgresql-record
>  create mode 100644 tools/perf/scripts/python/bin/export-to-postgresql-report
>  create mode 100644 tools/perf/scripts/python/export-to-postgresql.py
>  create mode 100644 tools/perf/util/db-export.c
>  create mode 100644 tools/perf/util/db-export.h
>  create mode 100644 tools/perf/util/find-vdso-map.c
>  create mode 100644 tools/perf/util/thread-stack.c
>  create mode 100644 tools/perf/util/thread-stack.h
> 
> 
> Regards
> Adrian
--
To unsubscribe from this list: send the line "unsubscribe 

Re: [PATCH] mm/cma: Make kmemleak ignore CMA regions

2014-10-23 Thread Catalin Marinas
On 23 October 2014 21:22, Andrew Morton  wrote:
> On Tue, 21 Oct 2014 14:14:56 +0200 Thierry Reding  
> wrote:
>
>> From: Thierry Reding 
>>
>> kmemleak will add allocations as objects to a pool. The memory allocated
>> for each object in this pool is periodically searched for pointers to
>> other allocated objects. This only works for memory that is mapped into
>> the kernel's virtual address space, which happens not to be the case for
>> most CMA regions.
>>
>> Furthermore, CMA regions are typically used to store data transferred to
>> or from a device and therefore don't contain pointers to other objects.
>>
>> Signed-off-by: Thierry Reding 
>> ---
>> Note: I'm not sure this is really the right fix. But without this, the
>> kernel crashes on the first execution of the scan_gray_list() because
>> it tries to access highmem. Perhaps a more appropriate fix would be to
>> reject any object that can't map to a kernel virtual address?
>
> Let's cc Catalin.
>
>> --- a/mm/cma.c
>> +++ b/mm/cma.c
>> @@ -280,6 +280,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
>>   ret = -ENOMEM;
>>   goto err;
>>   } else {
>> + kmemleak_ignore(phys_to_virt(addr));
>>   base = addr;
>>   }
>>   }

I wonder whether using __va() for the argument of kmemleak_alloc() in
memblock_alloc_range_nid() is always correct. Is
memblock.current_limit guaranteed to be in lowmem? If not, I think we
need some logic not to call kmemleak_alloc() for all memblock
allocations (and avoid the need to ignore them later).

> And let's tell our poor readers why we did stuff.  Something like this.
>
> --- a/mm/cma.c~mm-cma-make-kmemleak-ignore-cma-regions-fix
> +++ a/mm/cma.c
> @@ -280,6 +280,10 @@ int __init cma_declare_contiguous(phys_a
> ret = -ENOMEM;
> goto err;
> } else {
> +   /*
> +* kmemleak writes metadata to the tracked objects, 
> but
> +* this address isn't mapped and accessible.
> +*/
> kmemleak_ignore(phys_to_virt(addr));
> base = addr;
> }

The reason is different, as per Therry's patch description. Kmemleak
does not write metadata to the tracked objects but reads them during
memory scanning. So maybe something like "kmemleak scans/reads tracked
objects for pointers to other objects but this address isn't mapped
and accessible."

A better API to use here would have been kmemleak_no_scan(), however,
I don't think we care about such CMA pointers anyway since they seem
to be tracked by physical address which kmemleak doesn't store.

-- 
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 1/3] ACPI / platform: provide default DMA mask

2014-10-23 Thread Rafael J. Wysocki
On Thursday, October 23, 2014 10:06:05 AM Felipe Balbi wrote:
> 
> --HSQ3hISbU3Um6hch
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
> 
> On Wed, Oct 22, 2014 at 04:19:45PM +0200, Rafael J. Wysocki wrote:
> > On Wednesday, October 22, 2014 10:33:08 AM Adrian Hunter wrote:
> > > On 21/10/14 16:13, Adrian Hunter wrote:
> > > > On 21/10/14 16:08, Rafael J. Wysocki wrote:
> > > >> On Tuesday, October 21, 2014 03:27:45 PM Adrian Hunter wrote:
> > > >>> On 24/09/14 16:49, Rafael J. Wysocki wrote:
> > >  On Wednesday, September 24, 2014 11:00:37 AM Heikki Krogerus wrote:
> > > > Most devices are configured for 32-bit DMA addresses.
> > > > Setting the mask to 32-bit here removes the need for the
> > > > drivers to do it separately.
> > > >
> > > > Signed-off-by: Heikki Krogerus 
> > > > Cc: "Rafael J. Wysocki" 
> > > 
> > >  ACK
> > > >>>
> > > >>> Hi
> > > >>>
> > > >>> I need this for another driver.  Did this patch go anywhere?
> > > >>
> > > >> It's not in 3.18-rc1 as far as I can say.
> > > >>
> > > >>> Note Heikki is away at the moment.
> > > >>
> > > >> That's OK.  I guess I can queue up this one for you.
> > > >>
> > > >> When do you need this to get into the Linus' tree?
> > > >=20
> > > > My patches are aiming for 3.19
> > >=20
> > > Actually it would be easier for me if Heikki's patch is already in
> > > 3.18, but all I need to know is when it will hit?
> >=20
> > I've applied the Heiki's patch and I'm going to push it for 3.18-rc2.
> 
> I had this queued for v3.19 with your Ack. It didn't feel like it should
> be in v3.18-rc as it's not really fixing any bug. In any case, fine by
> me; I'll drop it from my queue.

OK, thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 01/16] perf tools: Add id index

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Thu, Oct 23, 2014 at 01:45:09PM +0300, Adrian Hunter escreveu:
> Add an index of the event identifiers.
> 
> This is needed to queue Instruction
> Trace samples according to the mmap
> buffer from which they were recorded.

This gets difficult to review, I end up having to look at all the
patches together to figure out the use cases, to see if this here makes
sense...

Can you try to explain like to a seven year old?

Sigh.

'id' is somethig super vague, what does this identifies? I want to make
progress processing these patches, but with so short explanations like
the above one, it gets difficult.

- Arnaldo
 
> Signed-off-by: Adrian Hunter 
> ---
>  tools/perf/builtin-inject.c |   1 +
>  tools/perf/util/event.c |   1 +
>  tools/perf/util/event.h |  15 ++
>  tools/perf/util/evlist.c|  26 --
>  tools/perf/util/evsel.h |   3 ++
>  tools/perf/util/session.c   | 122 
> 
>  tools/perf/util/session.h   |  10 
>  tools/perf/util/tool.h  |   3 +-
>  8 files changed, 177 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
> index de99ca1..046c719 100644
> --- a/tools/perf/builtin-inject.c
> +++ b/tools/perf/builtin-inject.c
> @@ -410,6 +410,7 @@ int cmd_inject(int argc, const char **argv, const char 
> *prefix __maybe_unused)
>   .tracing_data   = perf_event__repipe_op2_synth,
>   .finished_round = perf_event__repipe_op2_synth,
>   .build_id   = perf_event__repipe_op2_synth,
> + .id_index   = perf_event__repipe_op2_synth,
>   },
>   .input_name  = "-",
>   .samples = LIST_HEAD_INIT(inject.samples),
> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> index 4af6b27..bbf6705 100644
> --- a/tools/perf/util/event.c
> +++ b/tools/perf/util/event.c
> @@ -28,6 +28,7 @@ static const char *perf_event__names[] = {
>   [PERF_RECORD_HEADER_TRACING_DATA]   = "TRACING_DATA",
>   [PERF_RECORD_HEADER_BUILD_ID]   = "BUILD_ID",
>   [PERF_RECORD_FINISHED_ROUND]= "FINISHED_ROUND",
> + [PERF_RECORD_ID_INDEX]  = "ID_INDEX",
>  };
>  
>  const char *perf_event__name(unsigned int id)
> diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
> index 5699e7e..c89518e 100644
> --- a/tools/perf/util/event.h
> +++ b/tools/perf/util/event.h
> @@ -187,6 +187,7 @@ enum perf_user_event_type { /* above any possible kernel 
> type */
>   PERF_RECORD_HEADER_TRACING_DATA = 66,
>   PERF_RECORD_HEADER_BUILD_ID = 67,
>   PERF_RECORD_FINISHED_ROUND  = 68,
> + PERF_RECORD_ID_INDEX= 69,
>   PERF_RECORD_HEADER_MAX
>  };
>  
> @@ -239,6 +240,19 @@ struct tracing_data_event {
>   u32 size;
>  };
>  
> +struct id_index_entry {
> + u64 id;
> + u64 idx;
> + u64 cpu;
> + u64 tid;
> +};
> +
> +struct id_index_event {
> + struct perf_event_header header;
> + u64 nr;
> + struct id_index_entry entries[0];
> +};
> +
>  union perf_event {
>   struct perf_event_headerheader;
>   struct mmap_event   mmap;
> @@ -253,6 +267,7 @@ union perf_event {
>   struct event_type_event event_type;
>   struct tracing_data_event   tracing_data;
>   struct build_id_event   build_id;
> + struct id_index_event   id_index;
>  };
>  
>  void perf_event__print_totals(void);
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 3c9e77d..0babd39 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -527,6 +527,22 @@ static int perf_evlist__id_add_fd(struct perf_evlist 
> *evlist,
>   return 0;
>  }
>  
> +static void perf_evlist__set_sid_idx(struct perf_evlist *evlist,
> +  struct perf_evsel *evsel, int idx, int cpu,
> +  int thread)
> +{
> + struct perf_sample_id *sid = SID(evsel, cpu, thread);
> + sid->idx = idx;
> + if (evlist->cpus && cpu >= 0)
> + sid->cpu = evlist->cpus->map[cpu];
> + else
> + sid->cpu = -1;
> + if (!evsel->system_wide && evlist->threads && thread >= 0)
> + sid->tid = evlist->threads->map[thread];
> + else
> + sid->tid = -1;
> +}
> +
>  struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 
> id)
>  {
>   struct hlist_head *head;
> @@ -805,9 +821,13 @@ static int perf_evlist__mmap_per_evsel(struct 
> perf_evlist *evlist, int idx,
>   return -1;
>   }
>  
> - if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
> - perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0)
> - return -1;
> + if (evsel->attr.read_format & PERF_FORMAT_ID) {
> + if 

Re: [PATCH v2] ARM: supplementing IO accessors with 64 bit capability

2014-10-23 Thread Nicolas Pitre
On Thu, 23 Oct 2014, mathieu.poir...@linaro.org wrote:

> From: Mathieu Poirier 
> 
> Some drivers on ARMv7 need 64 bit read and writes.
> 
> Signed-off-by: Mathieu Poirier 

If you make __LINUX_ARM_ARCH__ >= 6 then you may add

Acked-by: Nicolas Pitre 

> ---
> Changes for v2:
>  - Protecting [readq, writeq]_relaxed with architecture constraint.
> 
>  arch/arm/include/asm/io.h | 25 +
>  1 file changed, 25 insertions(+)
> 
> diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
> index 1805674..027832b 100644
> --- a/arch/arm/include/asm/io.h
> +++ b/arch/arm/include/asm/io.h
> @@ -118,6 +118,24 @@ static inline u32 __raw_readl(const volatile void 
> __iomem *addr)
>   return val;
>  }
>  
> +#if __LINUX_ARM_ARCH__ >= 5
> +static inline void __raw_writeq(u64 val, volatile void __iomem *addr)
> +{
> + asm volatile("strd %1, %0"
> +  : "+Qo" (*(volatile u64 __force *)addr)
> +  : "r" (val));
> +}
> +
> +static inline u64 __raw_readq(const volatile void __iomem *addr)
> +{
> + u64 val;
> + asm volatile("ldrd %1, %0"
> +  : "+Qo" (*(volatile u64 __force *)addr),
> +"=r" (val));
> + return val;
> +}
> +#endif
> +
>  /*
>   * Architecture ioremap implementation.
>   */
> @@ -306,10 +324,17 @@ extern void _memset_io(volatile void __iomem *, int, 
> size_t);
>   __raw_readw(c)); __r; })
>  #define readl_relaxed(c) ({ u32 __r = le32_to_cpu((__force __le32) \
>   __raw_readl(c)); __r; })
> +#if __LINUX_ARM_ARCH__ >= 5
> +#define readq_relaxed(c) ({ u64 __r = le64_to_cpu((__force __le64) \
> + __raw_readq(c)); __r; })
> +#endif
>  
>  #define writeb_relaxed(v,c)  __raw_writeb(v,c)
>  #define writew_relaxed(v,c)  __raw_writew((__force u16) cpu_to_le16(v),c)
>  #define writel_relaxed(v,c)  __raw_writel((__force u32) cpu_to_le32(v),c)
> +#if __LINUX_ARM_ARCH__ >= 5
> +#define writeq_relaxed(v,c)  __raw_writeq((__force u64) cpu_to_le64(v),c)
> +#endif
>  
>  #define readb(c) ({ u8  __v = readb_relaxed(c); __iormb(); __v; 
> })
>  #define readw(c) ({ u16 __v = readw_relaxed(c); __iormb(); __v; 
> })
> -- 
> 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/
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: kernel 3.17.1: fail to use USB3 device after resuming from suspend

2014-10-23 Thread Rafael J. Wysocki
On Thursday, October 23, 2014 10:15:50 PM Francis Moreau wrote:
> Hello,
> 
> After resuming from a suspend (to RAM), I can't use an external USB hard
> drive anymore, the kernel seems to fail to detect it.
> 
> Here is the kernel log when doing a suspend/resume cycle.
> 
> [Oct23 22:03] wlp2s0: deauthenticating from 92:23:b1:f9:54:e4 by local
> choice (Reason: 3=DEAUTH_LEAVING)
> [  +0.025152] cfg80211: Calling CRDA to update world regulatory domain
> [  +0.052636] IPv6: ADDRCONF(NETDEV_UP): wlp2s0: link is not ready
> [  +0.071175] PM: Syncing filesystems ... done.
> [  +0.099223] PM: Preparing system for mem sleep
> [  +0.000347] Freezing user space processes ... (elapsed 0.001 seconds)
> done.
> [  +0.001406] Freezing remaining freezable tasks ... (elapsed 0.001
> seconds) done.
> [  +0.001083] PM: Entering mem sleep
> [  +0.17] Suspending console(s) (use no_console_suspend to debug)
> [  +0.000264] sd 4:0:0:0: [sdb] Synchronizing SCSI cache
> [  +0.36] sd 4:0:0:0: [sdb] Stopping disk
> [  +0.04] sd 0:0:0:0: [sda] Synchronizing SCSI cache
> [  +0.49] sd 0:0:0:0: [sda] Stopping disk
> [  +1.058316] PM: suspend of devices complete after 1057.429 msecs
> [  +0.013434] PM: late suspend of devices complete after 13.410 msecs
> [  +0.000875] ehci-pci :00:1d.0: System wakeup enabled by ACPI
> [  +0.13] r8169 :03:00.2: System wakeup enabled by ACPI
> [  +0.000101] ehci-pci :00:1a.0: System wakeup enabled by ACPI
> [  +0.47] xhci_hcd :00:14.0: System wakeup enabled by ACPI
> [  +0.012356] PM: noirq suspend of devices complete after 13.373 msecs
> [  +0.000401] ACPI: Preparing to enter system sleep state S3
> [  +0.002149] PM: Saving platform NVS memory
> [  +0.06] Disabling non-boot CPUs ...
> [  +0.75] intel_pstate CPU 1 exiting
> [  +0.001363] kvm: disabling virtualization on CPU1
> [  +0.28] smpboot: CPU 1 is now offline
> [  +0.000436] intel_pstate CPU 2 exiting
> [  +0.001348] kvm: disabling virtualization on CPU2
> [  +0.100773] smpboot: CPU 2 is now offline
> [  +0.000322] intel_pstate CPU 3 exiting
> [  +0.001260] kvm: disabling virtualization on CPU3
> [  +0.101855] smpboot: CPU 3 is now offline
> [  +0.000246] intel_pstate CPU 4 exiting
> [  +0.001181] kvm: disabling virtualization on CPU4
> [  +0.102021] smpboot: CPU 4 is now offline
> [  +0.000396] intel_pstate CPU 5 exiting
> [  +0.001242] kvm: disabling virtualization on CPU5
> [  +0.101801] smpboot: CPU 5 is now offline
> [  +0.000292] intel_pstate CPU 6 exiting
> [  +0.001301] kvm: disabling virtualization on CPU6
> [  +0.101880] smpboot: CPU 6 is now offline
> [  +0.000496] intel_pstate CPU 7 exiting
> [  +0.001265] kvm: disabling virtualization on CPU7
> [  +0.101649] smpboot: CPU 7 is now offline
> [  +0.002022] ACPI: Low-level resume complete
> [  +0.43] PM: Restoring platform NVS memory
> [  +0.000342] Enabling non-boot CPUs ...
> [  +0.47] x86: Booting SMP configuration:
> [  +0.02] smpboot: Booting Node 0 Processor 1 APIC 0x2
> [  +0.011516] kvm: enabling virtualization on CPU1
> [  +0.002301] CPU1 is up
> [  +0.25] smpboot: Booting Node 0 Processor 2 APIC 0x4
> [  +0.011466] kvm: enabling virtualization on CPU2
> [  +0.002307] CPU2 is up
> [  +0.22] smpboot: Booting Node 0 Processor 3 APIC 0x6
> [  +0.011469] kvm: enabling virtualization on CPU3
> [  +0.002305] CPU3 is up
> [  +0.22] smpboot: Booting Node 0 Processor 4 APIC 0x1
> [  +0.011483] kvm: enabling virtualization on CPU4
> [  +0.002298] CPU4 is up
> [  +0.18] smpboot: Booting Node 0 Processor 5 APIC 0x3
> [  +0.011437] kvm: enabling virtualization on CPU5
> [  +0.002305] CPU5 is up
> [  +0.17] smpboot: Booting Node 0 Processor 6 APIC 0x5
> [  +0.011550] kvm: enabling virtualization on CPU6
> [  +0.002297] CPU6 is up
> [  +0.17] smpboot: Booting Node 0 Processor 7 APIC 0x7
> [  +0.011457] kvm: enabling virtualization on CPU7
> [  +0.002312] CPU7 is up
> [  +0.006813] ACPI: Waking up from system sleep state S3
> [  +0.046539] ehci-pci :00:1d.0: System wakeup disabled by ACPI
> [  +0.000267] ehci-pci :00:1a.0: System wakeup disabled by ACPI
> [  +0.000123] xhci_hcd :00:14.0: System wakeup disabled by ACPI
> [  +0.53] PM: noirq resume of devices complete after 13.005 msecs
> [  +0.000523] PM: early resume of devices complete after 0.479 msecs
> [  +0.000120] mei_me :00:16.0: irq 28 for MSI/MSI-X
> [  +0.47] r8169 :03:00.2: System wakeup disabled by ACPI
> [  +0.97] snd_hda_intel :00:1b.0: irq 29 for MSI/MSI-X
> [  +0.003073] rtc_cmos 00:02: System wakeup disabled by ACPI
> [  +0.008776] sd 4:0:0:0: [sdb] Starting disk
> [  +0.09] sd 0:0:0:0: [sda] Starting disk
> [  +0.053104] r8169 :03:00.2 enp3s0f2: link down
> [  +0.254016] usb 1-4: reset full-speed USB device number 2 using xhci_hcd
> [  +0.16] xhci_hcd :00:14.0: Setup ERROR: setup context command
> for slot 1.
> [  +0.03] usb 1-4: hub failed to enable device, error -22
> [  +0.019787] 

Re: [PATCH 04/16] perf tools: Add a thread stack for synthesizing call chains

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Thu, Oct 23, 2014 at 01:45:12PM +0300, Adrian Hunter escreveu:
> Add a thread stack for synthesizing call chains from call
> and return events.
> 
> Signed-off-by: Adrian Hunter 
> ---
>  tools/perf/Makefile.perf   |   2 +
>  tools/perf/util/event.h|  26 +++
>  tools/perf/util/thread-stack.c | 151 
> +
>  tools/perf/util/thread-stack.h |  32 +
>  tools/perf/util/thread.c   |   3 +
>  tools/perf/util/thread.h   |   3 +
>  6 files changed, 217 insertions(+)
>  create mode 100644 tools/perf/util/thread-stack.c
>  create mode 100644 tools/perf/util/thread-stack.h
> 
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 262916f..5bbe1ff 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -304,6 +304,7 @@ LIB_H += ui/util.h
>  LIB_H += ui/ui.h
>  LIB_H += util/data.h
>  LIB_H += util/kvm-stat.h
> +LIB_H += util/thread-stack.h
>  
>  LIB_OBJS += $(OUTPUT)util/abspath.o
>  LIB_OBJS += $(OUTPUT)util/alias.o
> @@ -380,6 +381,7 @@ LIB_OBJS += $(OUTPUT)util/srcline.o
>  LIB_OBJS += $(OUTPUT)util/data.o
>  LIB_OBJS += $(OUTPUT)util/tsc.o
>  LIB_OBJS += $(OUTPUT)util/cloexec.o
> +LIB_OBJS += $(OUTPUT)util/thread-stack.o
>  
>  LIB_OBJS += $(OUTPUT)ui/setup.o
>  LIB_OBJS += $(OUTPUT)ui/helpline.o
> diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
> index c89518e..e84f929 100644
> --- a/tools/perf/util/event.h
> +++ b/tools/perf/util/event.h
> @@ -143,6 +143,32 @@ struct branch_stack {
>   struct branch_entry entries[0];
>  };
>  
> +enum {
> + PERF_FLAG_BRANCH= 1ULL << 0,
> + PERF_FLAG_CALL  = 1ULL << 1,
> + PERF_FLAG_RETURN= 1ULL << 2,
> + PERF_FLAG_CONDITIONAL   = 1ULL << 3,
> + PERF_FLAG_SYSCALLRET= 1ULL << 4,
> + PERF_FLAG_ASYNC = 1ULL << 5,
> + PERF_FLAG_INTERRUPT = 1ULL << 6,
> + PERF_FLAG_TX_ABORT  = 1ULL << 7,
> + PERF_FLAG_TRACE_BEGIN   = 1ULL << 8,
> + PERF_FLAG_TRACE_END = 1ULL << 9,
> + PERF_FLAG_IN_TX = 1ULL << 10,
> +};
> +
> +#define PERF_BRANCH_MASK (\
> + PERF_FLAG_BRANCH|\
> + PERF_FLAG_CALL  |\
> + PERF_FLAG_RETURN|\
> + PERF_FLAG_CONDITIONAL   |\
> + PERF_FLAG_SYSCALLRET|\
> + PERF_FLAG_ASYNC |\
> + PERF_FLAG_INTERRUPT |\
> + PERF_FLAG_TX_ABORT  |\
> + PERF_FLAG_TRACE_BEGIN   |\
> + PERF_FLAG_TRACE_END)
> +
>  struct perf_sample {
>   u64 ip;
>   u32 pid, tid;
> diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
> new file mode 100644
> index 000..c1ca2a9
> --- /dev/null
> +++ b/tools/perf/util/thread-stack.c
> @@ -0,0 +1,151 @@
> +/*
> + * thread-stack.c: Synthesize a thread's stack using call / return events
> + * Copyright (c) 2014, Intel Corporation.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope 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 "thread.h"
> +#include "event.h"
> +#include "util.h"
> +#include "thread-stack.h"
> +
> +#define STACK_GROWTH 4096
> +
> +struct thread_stack_entry {
> + u64 ret_addr;
> +};
> +
> +struct thread_stack {
> + struct thread_stack_entry *stack;
> + size_t cnt;
> + size_t sz;
> + u64 trace_nr;
> +};
> +
> +static void thread_stack__grow(struct thread_stack *ts)
> +{
> + struct thread_stack_entry *new_stack;
> + size_t sz, new_sz;
> +
> + new_sz = ts->sz + STACK_GROWTH;
> + sz = new_sz * sizeof(struct thread_stack_entry);
> + new_stack = realloc(ts->stack, sz);
> + if (new_stack) {
> + ts->stack = new_stack;
> + ts->sz = new_sz;
> + }
> +}
> +
> +static struct thread_stack *thread_stack__new(void)
> +{
> + struct thread_stack *ts;
> +
> + ts = zalloc(sizeof(struct thread_stack));
> + if (!ts)
> + return NULL;
> +
> + thread_stack__grow(ts);
> + if (!ts->stack) {
> + free(ts);
> + return NULL;
> + }
> +
> + return ts;
> +}
> +
> +static void thread_stack__push(struct thread_stack *ts, u64 ret_addr)
> +{
> + if (ts->cnt == ts->sz) {
> + thread_stack__grow(ts);
> + if (ts->cnt == ts->sz)
> + ts->cnt = 0;
> + }
> +
> + ts->stack[ts->cnt++].ret_addr = ret_addr;
> +}

So can you elaborate on the use case, i.e. this silently trows the
existing stack contents away if it doesn't grow, looks strange :-\

Merits some explanation 

Re: rcu_preempt detected stalls.

2014-10-23 Thread Paul E. McKenney
On Thu, Oct 23, 2014 at 04:28:16PM -0400, Dave Jones wrote:
> On Thu, Oct 23, 2014 at 12:52:21PM -0700, Paul E. McKenney wrote:
>  > On Thu, Oct 23, 2014 at 03:37:59PM -0400, Dave Jones wrote:
>  > > On Thu, Oct 23, 2014 at 12:28:07PM -0700, Paul E. McKenney wrote:
>  > > 
>  > >  > >  > This one will require more looking.  But did you do something 
> like
>  > >  > >  > create a pair of mutually recursive symlinks or something?  ;-)
>  > >  > > 
>  > >  > > I'm not 100% sure, but this may have been on a box that I was 
> running
>  > >  > > tests on NFS. So maybe the server had disappeared with the mount
>  > >  > > still active..
>  > >  > > 
>  > >  > > Just a guess tbh.
>  > >  > 
>  > >  > Another possibility might be that the box was so overloaded that tasks
>  > >  > were getting preempted for 21 seconds as a matter of course, and 
> sometimes
>  > >  > within RCU read-side critical sections.  Or did the box have ample 
> idle
>  > >  > time?
>  > > 
>  > > I fairly recently upped the number of child processes I typically run
>  > > with, so it being overloaded does sound highly likely.
>  > 
>  > Ah, that could do it!  One way to test extreme loads and not trigger
>  > RCU CPU stall warnings might be to make all of your child processes all
>  > sleep during a given interval of a few hundred milliseconds during each
>  > ten-second interval.  Would that work for you?
> 
> This feels like hiding from the problem rather than fixing it.
> I'm not sure it even makes sense to add sleeps to the fuzzer, other than
> to slow things down, and if I were to do that, I may as well just run
> it with fewer threads instead.

I was thinking of the RCU CPU stall warnings that were strictly due to
overload as being false positives.  If trinity caused a kthread to loop
within an RCU read-side critical section, you would still get the RCU
CPU stall warning even with the sleeps.

But just a suggestion, no strong feelings.  Might change if there is an
excess of false-positive RCU CPU stall warnings, of course.  ;-)

> While the fuzzer is doing pretty crazy stuff, what's different about it
> from any other application that overcommits the CPU with too many threads?

The (presumably) much higher probability of being preempted in the kernel,
and thus within an RCU read-side critical section.

> We impose rlimits to stop people from forkbombing and the like, but this
> doesn't even need that many processes to trigger, and with some effort
> could probably done with even fewer if I found ways to keep other cores
> busy in the kernel for long enough.
> 
> That all said, I don't have easy reproducers for this right now, due
> to other bugs manifesting long before this gets to be a problem.

Fair enough!  ;-)

Thanx, Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 1/2] staging: ion: shrink page-pool by page unit

2014-10-23 Thread Devendra Naga
Hello,

On Thu, Oct 23, 2014 at 6:22 PM, Gioh Kim  wrote:
> This patch shrink page-pool by page unit.
>
> Signed-off-by: Gioh Kim 
> ---
>  drivers/staging/android/ion/ion_page_pool.c   |5 +++--
>  drivers/staging/android/ion/ion_system_heap.c |7 +--
>  2 files changed, 8 insertions(+), 4 deletions(-)

>

--- cut --

> diff --git a/drivers/staging/android/ion/ion_system_heap.c 
> b/drivers/staging/android/ion/ion_system_heap.c
> index da2a63c..36e73c3 100644
> --- a/drivers/staging/android/ion/ion_system_heap.c
> +++ b/drivers/staging/android/ion/ion_system_heap.c
> @@ -211,7 +211,7 @@ static int ion_system_heap_shrink(struct ion_heap *heap, 
> gfp_t gfp_mask,
> int nr_to_scan)
>  {
> struct ion_system_heap *sys_heap;
> -   int nr_total = 0;
> +   int nr_total = 0, nr_freed;
> int i;
>
> sys_heap = container_of(heap, struct ion_system_heap, heap);
> @@ -219,7 +219,10 @@ static int ion_system_heap_shrink(struct ion_heap *heap, 
> gfp_t gfp_mask,
> for (i = 0; i < num_orders; i++) {
> struct ion_page_pool *pool = sys_heap->pools[i];
>
> -   nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
> +   nr_freed += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);

nr_freed is not initialised to zero. This might result in updating of
a garbage value stored initially after nr_freed is created.

> +   nr_total += nr_freed;
> +   /* nr_to_scan can be negative */
> +   nr_to_scan -= nr_freed;
> }
>
> return nr_total;
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 0/2] document ->sighand protection, rcu_read_unlock() deadlocks

2014-10-23 Thread Paul E. McKenney
On Thu, Oct 23, 2014 at 09:56:04PM +0200, Oleg Nesterov wrote:
> Ping ;)
> 
> Paul, should I resend or you do not think this can go via your rcu
> tree?

Please accept my apologies for missing these!

They are now queued for 3.19.

Thanx, Paul

> On 09/28, Oleg Nesterov wrote:
> >
> > Paul, could you take these 2 doc patches? Assuming that you agree
> > with the comments, of course.
> >
> > On 09/24, Paul E. McKenney wrote:
> > >
> > > On Tue, Sep 23, 2014 at 09:03:48PM +0200, Oleg Nesterov wrote:
> > > >
> > > > Paul, will you agree if we turn it into
> > > > ...
> > > >  /*
> > > >   * On the succesfull return we hold ->siglock. According to comment
> > > >   * above rcu_read_unlock() this is against the rules, but scheduler
> > > >   * locks are fine under this lock, signal_wake_up() takes them too.
> > > >   */
> > > >  rcu_read_unlock();
> > >
> > > If you guys continue the guarantee of no deadlock, I am OK with this 
> > > change.
> >
> > Heh. Contrary to what I said (and you all were agree ;), this deadlock
> > is actually possible, so we can not remove the deadlock-avoidance from
> > __lock_task_sighand(). And I do not see how we can cleanup this code
> > because preempt_disable() + spin_lock() is not -rt friendly.
> >
> > I think this deserves a bit of documentation, see 2/2. Perhaps this is
> > just me, but imo the current comment is a bit misleading.
> >
> > "if the caller of rcu_read_unlock() already holds one of these locks ..."
> > is not a problem in fact. I mean, pi_lock or rq->lock are special enough,
> > nobody should ever call the outermost rcu_read_unlock() with these locks
> > held. rt_mutex->wait_lock should be fine too, also because ->boost_mtx
> > is private to rcu_boost() and rcu_read_unlock_special().
> >
> > But. They can race with each other, and that is why rcu_read_unlock()
> > under (say) ->siglock can actually lead to deadlock. And only because
> > rt_mutex->wait_lock doesn't disable irqs. Or I am totally confused.
> >
> > Perhaps we can change rtmutex.c to use raw_spin_lock_irqsave(), or do
> > something else...
> >
> > Oleg.
> >
> >  include/linux/rcupdate.h |4 +++-
> >  kernel/fork.c|5 -
> >  kernel/signal.c  |   12 +++-
> >  3 files changed, 18 insertions(+), 3 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: [PATCHSET 0/5] perf tools: option parsing improvement

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Thu, Oct 23, 2014 at 12:15:44AM +0900, Namhyung Kim escreveu:
> Hello,
> 
> This patchset tries to enhance option parser a bit.  Patch 1-3 are to
> reuse existing perf record options for other commands like perf kvm
> stat record.  Patch 4-5 are to support exclusive options that cannot
> be used at the same time.  The perf probe has such options and upcoming
> sdt-cache command also.
> 
> You can get it from 'perf/option-share-v2' branch on my tree:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
> 
> Any comments are welcome, thanks
> Namhyung

Thanks, applied the series.

- Arnaldo
 
> 
> Cc: Masami Hiramatsu 
> Cc: Hemant Kumar 
> Cc: Alexander Yarygin 
> 
> 
> Namhyung Kim (5):
>   perf tools: Add PARSE_OPT_DISABLED flag
>   perf tools: Export usage string and option table of perf record
>   perf kvm: Print kvm specific --help output
>   perf tools: Add support for exclusive option
>   perf probe: Use PARSE_OPT_EXCLUSIVE flag
> 
>  tools/perf/builtin-kvm.c| 25 +
>  tools/perf/builtin-probe.c  | 54 +---
>  tools/perf/builtin-record.c |  7 ++--
>  tools/perf/builtin-script.c |  1 -
>  tools/perf/builtin-timechart.c  |  7 ++--
>  tools/perf/perf.h   |  3 ++
>  tools/perf/util/parse-options.c | 78 
> ++---
>  tools/perf/util/parse-options.h |  4 +++
>  8 files changed, 116 insertions(+), 63 deletions(-)
> 
> -- 
> 2.0.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] i386/audit: stop scribbling on the stack frame

2014-10-23 Thread Andy Lutomirski
On Thu, Oct 23, 2014 at 12:30 PM, Eric Paris  wrote:
> On Thu, 2014-10-23 at 12:20 -0700, Andy Lutomirski wrote:
>> On Thu, Oct 23, 2014 at 12:15 PM, Eric Paris  wrote:
>> > On Thu, 2014-10-23 at 11:39 -0700, Andy Lutomirski wrote:
>> >> On 10/22/2014 09:04 PM, Eric Paris wrote:
>> >> > git commit b4f0d3755c5e9cc86292d5fd78261903b4f23d4a was very very dumb.
>> >> > It was writing over %esp/pt_regs semi-randomly on i686  with the 
>> >> > expected
>> >> > "system can't boot" results.  As noted in:
>> >> >
>> >> > https://bugs.freedesktop.org/show_bug.cgi?id=85277
>> >> >
>> >> > This patch stops fscking with pt_regs.  Instead it sets up the registers
>> >> > for the call to __audit_syscall_entry in the most obvious conceivable
>> >> > way.  It then does just a tiny tiny touch of magic.  We need to get what
>> >> > started in PT_EDX into 0(%esp) and PT_ESI into 4(%esp).  This is as easy
>> >> > as a pair of pushes.
>> >> >
>> >> > After the call to __audit_syscall_entry all we need to do is get that
>> >> > now useless junk off the stack (pair of pops) and reload %eax with the
>> >> > original syscall so other stuff can keep going about it's business.
>> >> >
>> >> > Signed-off-by: Eric Paris 
>> >> > Cc: Thomas Gleixner 
>> >> > Cc: Ingo Molnar 
>> >> > Cc: "H. Peter Anvin" 
>> >> > Cc: x...@kernel.org
>> >> > Cc: linux-kernel@vger.kernel.org
>> >> > Cc: linux-au...@redhat.com
>> >> > ---
>> >> >  arch/x86/kernel/entry_32.S | 15 +++
>> >> >  1 file changed, 7 insertions(+), 8 deletions(-)
>> >> >
>> >> > diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
>> >> > index f9e3fab..fb01d22 100644
>> >> > --- a/arch/x86/kernel/entry_32.S
>> >> > +++ b/arch/x86/kernel/entry_32.S
>> >> > @@ -447,15 +447,14 @@ sysenter_exit:
>> >> >  sysenter_audit:
>> >> > testl $(_TIF_WORK_SYSCALL_ENTRY & 
>> >> > ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
>> >> > jnz syscall_trace_entry
>> >> > -   addl $4,%esp
>> >> > -   CFI_ADJUST_CFA_OFFSET -4
>> >> > -   movl %esi,4(%esp)   /* 5th arg: 4th syscall arg */
>> >> > -   movl %edx,(%esp)/* 4th arg: 3rd syscall arg */
>> >> > -   /* %ecx already in %ecx3rd arg: 2nd syscall arg */
>> >> > -   movl %ebx,%edx  /* 2nd arg: 1st syscall arg */
>> >> > -   /* %eax already in %eax1st arg: syscall number */
>> >> > +   /* movl PT_EAX(%esp), %eax  already set, syscall number: 1st 
>> >> > arg to audit */
>> >> > +   movl PT_EBX(%esp), %edx /* ebx/a0: 2nd arg to audit */
>> >> > +   /* movl PT_ECX(%esp), %ecx  already set, a1: 3nd arg to audit */
>> >> > +   pushl_cfi PT_ESI(%esp)  /* a3: 5th arg */
>> >> > +   pushl_cfi PT_EDX+4(%esp)/* a2: 4th arg */
>> >> > call __audit_syscall_entry
>> >> > -   pushl_cfi %ebx
>> >> > +   popl_cfi %ecx /* get that remapped edx off the stack */
>> >> > +   popl_cfi %ecx /* get that remapped esi off the stack */
>> >> > movl PT_EAX(%esp),%eax  /* reload syscall number */
>> >> > jmp sysenter_do_call
>> >> >
>> >> >
>> >>
>> >> This looks reasonably likely to be correct, but this code is complicated
>> >> and now ever slower.
>> >
>> > I guess I could just use push/pop and do the CFI_ADJUST_CFA_OFFSET by
>> > hand.  But I figured this was reasonable enough...
>> >
>>
>> I'm not complaining about your new assembly in particular.  There's
>> just too much assembly in there in general.
>>
>> But I feel like I'm missing something in the new code.  Aren't you
>> corrupting ecx with those popl_cfi insns?
>
> After the call __audit_syscall_entry aren't they already polluted?
> Isn't that the reason we need to reload EAX?  You can verify this leaves
> things in a similar state (although slightly differently polluted) than
> before it got screwed up.  Here is diff between before the breakage and
> what I propose we do now.
>
> (I admit I don't understand how the pushl_cfi %ebx wasn't messing up
> PT_EBX)
>
> /me anxiously awaits x86 guy to tell me how dumb I am
>

hpa, do you have time to figure this out?  I don't know the 32-bit ABI
well enough, nor will I have time to disassemble things or find and
read the spec to figure this out in the next few days.

--Andy

> $ git diff a17c8b54dc738c4fda31e8be0302cd131a04c19f -- 
> arch/x86/kernel/entry_32.S
> diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
> index 0d0c9d4..fb01d22 100644
> --- a/arch/x86/kernel/entry_32.S
> +++ b/arch/x86/kernel/entry_32.S
> @@ -447,16 +447,14 @@ sysenter_exit:
>  sysenter_audit:
> testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
> jnz syscall_trace_entry
> -   addl $4,%esp
> -   CFI_ADJUST_CFA_OFFSET -4
> -   /* %esi already in 8(%esp) 6th arg: 4th syscall arg */
> -   /* %edx already in 4(%esp) 5th arg: 3rd syscall arg */
> -   /* %ecx already in 0(%esp) 4th arg: 2nd syscall arg */
> -   movl %ebx,%ecx  /* 3rd arg: 

Re: [PATCH 4/5] perf tools: Add support for exclusive option

2014-10-23 Thread Arnaldo Carvalho de Melo
Em Thu, Oct 23, 2014 at 02:05:08PM +0900, Masami Hiramatsu escreveu:
> (2014/10/23 0:15), Namhyung Kim wrote:
> > Some options cannot be used at the same time.  To handle such options
> > add a new PARSE_OPT_EXCLUSIVE flag and show error message if more than
> > one of them is used.
> 
> Looks useful for me :)
> 
> Reviewed-by: Masami Hiramatsu 
> 
> I just have a comment below;
> 
> > @@ -360,19 +378,21 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
> > }
> >  
> > if (arg[1] != '-') {
> > -   ctx->opt = arg + 1;
> > +   ctx->opt = ++arg;
> > if (internal_help && *ctx->opt == 'h')
> > return usage_with_options_internal(usagestr, 
> > options, 0);
> > switch (parse_short_opt(ctx, options)) {
> > case -1:
> > -   return parse_options_usage(usagestr, options, 
> > arg + 1, 1);
> > +   return parse_options_usage(usagestr, options, 
> > arg, 1);
> > case -2:
> > goto unknown;
> > +   case -3:
> > +   goto exclusive;
> 
> BTW, it may be a time to define return error codes.

Yeah, this thing looks unnecessarily complicated :-\
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: rcu_preempt detected stalls.

2014-10-23 Thread Dave Jones
On Thu, Oct 23, 2014 at 12:52:21PM -0700, Paul E. McKenney wrote:
 > On Thu, Oct 23, 2014 at 03:37:59PM -0400, Dave Jones wrote:
 > > On Thu, Oct 23, 2014 at 12:28:07PM -0700, Paul E. McKenney wrote:
 > > 
 > >  > >  > This one will require more looking.  But did you do something like
 > >  > >  > create a pair of mutually recursive symlinks or something?  ;-)
 > >  > > 
 > >  > > I'm not 100% sure, but this may have been on a box that I was running
 > >  > > tests on NFS. So maybe the server had disappeared with the mount
 > >  > > still active..
 > >  > > 
 > >  > > Just a guess tbh.
 > >  > 
 > >  > Another possibility might be that the box was so overloaded that tasks
 > >  > were getting preempted for 21 seconds as a matter of course, and 
 > > sometimes
 > >  > within RCU read-side critical sections.  Or did the box have ample idle
 > >  > time?
 > > 
 > > I fairly recently upped the number of child processes I typically run
 > > with, so it being overloaded does sound highly likely.
 > 
 > Ah, that could do it!  One way to test extreme loads and not trigger
 > RCU CPU stall warnings might be to make all of your child processes all
 > sleep during a given interval of a few hundred milliseconds during each
 > ten-second interval.  Would that work for you?

This feels like hiding from the problem rather than fixing it.
I'm not sure it even makes sense to add sleeps to the fuzzer, other than
to slow things down, and if I were to do that, I may as well just run
it with fewer threads instead.

While the fuzzer is doing pretty crazy stuff, what's different about it
from any other application that overcommits the CPU with too many threads?

We impose rlimits to stop people from forkbombing and the like, but this
doesn't even need that many processes to trigger, and with some effort
could probably done with even fewer if I found ways to keep other cores
busy in the kernel for long enough.

That all said, I don't have easy reproducers for this right now, due
to other bugs manifesting long before this gets to be a problem.

Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: rcu_preempt detected stalls.

2014-10-23 Thread Paul E. McKenney
On Thu, Oct 23, 2014 at 09:53:37PM +0200, Oleg Nesterov wrote:
> On 10/23, Paul E. McKenney wrote:
> >
> > OK, so making each pass through the loop a separate RCU read-side critical
> > section might be considered to be suppressing notification of an error
> > condition?
> 
> I agree, this change probably makes sense anyway. Personally I'd prefer
> the version below (somehow I hate multiple unlock's), but I won't insist.

Your code, your rules.  ;-)

But given this structure, why not use a for() loop replace the
"goto retry" with an inverted condition and a "return error"?
Maybe something like the following patch?

Thanx, Paul



signal: Exit RCU read-side critical section on each pass through loop

The kill_pid_info() can potentially loop indefinitely if tasks are created
and deleted sufficiently quickly, and if this happens, this function
will remain in a single RCU read-side critical section indefinitely.
This commit therefore exits the RCU read-side critical section on each
pass through the loop.  Because a race must happen to retry the loop,
this should have no performance impact in the common case.

Reported-by: Dave Jones 
Signed-off-by: Paul E. McKenney 
Cc: Oleg Nesterov 

diff --git a/kernel/signal.c b/kernel/signal.c
index 8f0876f9f6dd..54820984a872 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1331,23 +1331,21 @@ int kill_pid_info(int sig, struct siginfo *info, struct 
pid *pid)
int error = -ESRCH;
struct task_struct *p;
 
-   rcu_read_lock();
-retry:
-   p = pid_task(pid, PIDTYPE_PID);
-   if (p) {
-   error = group_send_sig_info(sig, info, p);
-   if (unlikely(error == -ESRCH))
-   /*
-* The task was unhashed in between, try again.
-* If it is dead, pid_task() will return NULL,
-* if we race with de_thread() it will find the
-* new leader.
-*/
-   goto retry;
-   }
-   rcu_read_unlock();
+   for (;;) {
+   rcu_read_lock();
+   p = pid_task(pid, PIDTYPE_PID);
+   if (p)
+   error = group_send_sig_info(sig, info, p);
+   rcu_read_unlock();
+   if (likely(!p || error != -ESRCH))
+   return error;
 
-   return error;
+   /*
+* The task was unhashed in between, try again.  If it
+* is dead, pid_task() will return NULL, if we race with
+* de_thread() it will find the new leader.
+*/
+   }
 }
 
 int kill_proc_info(int sig, struct siginfo *info, pid_t pid)

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


RE: [PATCH] staging: comedi: introduce some sample size manipulation functions

2014-10-23 Thread Hartley Sweeten
On Thursday, October 23, 2014 5:48 AM, Ian Abbott wrote:
> Introduce a few static inline helper functions:
>
> `comedi_bytes_per_sample(s)` is the same as the existing
> `bytes_per_sample(s)` and determines the size of a comedi sample in
> bytes.  (`bytes_per_sample(s)` will be removed.)
>
> `comedi_sample_shift(s)` determines the log2 of the comedi sample size,
> so it can be used in bit-shift operations to multiply or divide by the
> sample size.
>
> `comedi_bytes_to_samples(s, nbytes)` converts a number of bytes to a
> number of samples (rounding down).
>
> `comedi_samples_to_bytes(s, nsamples)` converts a number of samples to a
> number of bytes.
>
> Signed-off-by: Ian Abbott 
> ---
>  drivers/staging/comedi/comedidev.h | 63 
> +++---
>  1 file changed, 59 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/comedi/comedidev.h 
> b/drivers/staging/comedi/comedidev.h
> index 1b2bbd5..69cf6fe 100644
> --- a/drivers/staging/comedi/comedidev.h
> +++ b/drivers/staging/comedi/comedidev.h
> @@ -391,12 +391,67 @@ static inline unsigned int comedi_offset_munge(struct 
> comedi_subdevice *s,
>   return val ^ s->maxdata ^ (s->maxdata >> 1);
>  }
> 
> -static inline unsigned int bytes_per_sample(const struct comedi_subdevice 
> *subd)
> +/**
> + * comedi_bytes_per_sample - determine subdevice sample size
> + * @s:   comedi_subdevice struct
> + *
> + * The sample size will be 4 (sizeof int) or 2 (sizeof short) depending on
> + * whether the SDF_LSAMPL subdevice flag is set or not.
> + *
> + * Returns the subdevice sample size.
> + */
> +static inline unsigned int comedi_bytes_per_sample(struct comedi_subdevice 
> *s)
>  {
> - if (subd->subdev_flags & SDF_LSAMPL)
> - return sizeof(unsigned int);
> + return s->subdev_flags & SDF_LSAMPL ? sizeof(int) : sizeof(short);

The samples are really 'unsigned' types but I guess it doesn't matter here.

> +}
 
Reviewed-by: H Hartley Sweeten 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] i386/audit: stop scribbling on the stack frame

2014-10-23 Thread Eric Paris
On Thu, 2014-10-23 at 12:20 -0700, Andy Lutomirski wrote:
> On Thu, Oct 23, 2014 at 12:15 PM, Eric Paris  wrote:
> > On Thu, 2014-10-23 at 11:39 -0700, Andy Lutomirski wrote:
> >> On 10/22/2014 09:04 PM, Eric Paris wrote:
> >> > git commit b4f0d3755c5e9cc86292d5fd78261903b4f23d4a was very very dumb.
> >> > It was writing over %esp/pt_regs semi-randomly on i686  with the expected
> >> > "system can't boot" results.  As noted in:
> >> >
> >> > https://bugs.freedesktop.org/show_bug.cgi?id=85277
> >> >
> >> > This patch stops fscking with pt_regs.  Instead it sets up the registers
> >> > for the call to __audit_syscall_entry in the most obvious conceivable
> >> > way.  It then does just a tiny tiny touch of magic.  We need to get what
> >> > started in PT_EDX into 0(%esp) and PT_ESI into 4(%esp).  This is as easy
> >> > as a pair of pushes.
> >> >
> >> > After the call to __audit_syscall_entry all we need to do is get that
> >> > now useless junk off the stack (pair of pops) and reload %eax with the
> >> > original syscall so other stuff can keep going about it's business.
> >> >
> >> > Signed-off-by: Eric Paris 
> >> > Cc: Thomas Gleixner 
> >> > Cc: Ingo Molnar 
> >> > Cc: "H. Peter Anvin" 
> >> > Cc: x...@kernel.org
> >> > Cc: linux-kernel@vger.kernel.org
> >> > Cc: linux-au...@redhat.com
> >> > ---
> >> >  arch/x86/kernel/entry_32.S | 15 +++
> >> >  1 file changed, 7 insertions(+), 8 deletions(-)
> >> >
> >> > diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
> >> > index f9e3fab..fb01d22 100644
> >> > --- a/arch/x86/kernel/entry_32.S
> >> > +++ b/arch/x86/kernel/entry_32.S
> >> > @@ -447,15 +447,14 @@ sysenter_exit:
> >> >  sysenter_audit:
> >> > testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
> >> > jnz syscall_trace_entry
> >> > -   addl $4,%esp
> >> > -   CFI_ADJUST_CFA_OFFSET -4
> >> > -   movl %esi,4(%esp)   /* 5th arg: 4th syscall arg */
> >> > -   movl %edx,(%esp)/* 4th arg: 3rd syscall arg */
> >> > -   /* %ecx already in %ecx3rd arg: 2nd syscall arg */
> >> > -   movl %ebx,%edx  /* 2nd arg: 1st syscall arg */
> >> > -   /* %eax already in %eax1st arg: syscall number */
> >> > +   /* movl PT_EAX(%esp), %eax  already set, syscall number: 1st arg 
> >> > to audit */
> >> > +   movl PT_EBX(%esp), %edx /* ebx/a0: 2nd arg to audit */
> >> > +   /* movl PT_ECX(%esp), %ecx  already set, a1: 3nd arg to audit */
> >> > +   pushl_cfi PT_ESI(%esp)  /* a3: 5th arg */
> >> > +   pushl_cfi PT_EDX+4(%esp)/* a2: 4th arg */
> >> > call __audit_syscall_entry
> >> > -   pushl_cfi %ebx
> >> > +   popl_cfi %ecx /* get that remapped edx off the stack */
> >> > +   popl_cfi %ecx /* get that remapped esi off the stack */
> >> > movl PT_EAX(%esp),%eax  /* reload syscall number */
> >> > jmp sysenter_do_call
> >> >
> >> >
> >>
> >> This looks reasonably likely to be correct, but this code is complicated
> >> and now ever slower.
> >
> > I guess I could just use push/pop and do the CFI_ADJUST_CFA_OFFSET by
> > hand.  But I figured this was reasonable enough...
> >
> 
> I'm not complaining about your new assembly in particular.  There's
> just too much assembly in there in general.
> 
> But I feel like I'm missing something in the new code.  Aren't you
> corrupting ecx with those popl_cfi insns?

After the call __audit_syscall_entry aren't they already polluted?
Isn't that the reason we need to reload EAX?  You can verify this leaves
things in a similar state (although slightly differently polluted) than
before it got screwed up.  Here is diff between before the breakage and
what I propose we do now.

(I admit I don't understand how the pushl_cfi %ebx wasn't messing up
PT_EBX)

/me anxiously awaits x86 guy to tell me how dumb I am

$ git diff a17c8b54dc738c4fda31e8be0302cd131a04c19f -- 
arch/x86/kernel/entry_32.S
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 0d0c9d4..fb01d22 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -447,16 +447,14 @@ sysenter_exit:
 sysenter_audit:
testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
jnz syscall_trace_entry
-   addl $4,%esp
-   CFI_ADJUST_CFA_OFFSET -4
-   /* %esi already in 8(%esp) 6th arg: 4th syscall arg */
-   /* %edx already in 4(%esp) 5th arg: 3rd syscall arg */
-   /* %ecx already in 0(%esp) 4th arg: 2nd syscall arg */
-   movl %ebx,%ecx  /* 3rd arg: 1st syscall arg */
-   movl %eax,%edx  /* 2nd arg: syscall number */
-   movl $AUDIT_ARCH_I386,%eax  /* 1st arg: audit arch */
+   /* movl PT_EAX(%esp), %eax  already set, syscall number: 1st arg to 
audit */
+   movl PT_EBX(%esp), %edx /* ebx/a0: 2nd arg to audit */
+   /* movl PT_ECX(%esp), %ecx  already set, a1: 3nd arg to audit */
+   

Re: [PATCH] mm/cma: Make kmemleak ignore CMA regions

2014-10-23 Thread Andrew Morton
On Tue, 21 Oct 2014 14:14:56 +0200 Thierry Reding  
wrote:

> From: Thierry Reding 
> 
> kmemleak will add allocations as objects to a pool. The memory allocated
> for each object in this pool is periodically searched for pointers to
> other allocated objects. This only works for memory that is mapped into
> the kernel's virtual address space, which happens not to be the case for
> most CMA regions.
> 
> Furthermore, CMA regions are typically used to store data transferred to
> or from a device and therefore don't contain pointers to other objects.
> 
> Signed-off-by: Thierry Reding 
> ---
> Note: I'm not sure this is really the right fix. But without this, the
> kernel crashes on the first execution of the scan_gray_list() because
> it tries to access highmem. Perhaps a more appropriate fix would be to
> reject any object that can't map to a kernel virtual address?

Let's cc Catalin.

> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -280,6 +280,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
>   ret = -ENOMEM;
>   goto err;
>   } else {
> + kmemleak_ignore(phys_to_virt(addr));
>   base = addr;
>   }
>   }

And let's tell our poor readers why we did stuff.  Something like this.

--- a/mm/cma.c~mm-cma-make-kmemleak-ignore-cma-regions-fix
+++ a/mm/cma.c
@@ -280,6 +280,10 @@ int __init cma_declare_contiguous(phys_a
ret = -ENOMEM;
goto err;
} else {
+   /*
+* kmemleak writes metadata to the tracked objects, but
+* this address isn't mapped and accessible.
+*/
kmemleak_ignore(phys_to_virt(addr));
base = addr;
}
_

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 tree for y2038 patches, to be added to linux-next

2014-10-23 Thread Arnd Bergmann
Hi Stephen,

I'm collecting patches for 64-bit time_t conversion. I'm getting patches
for this topic from the OPW application, and hopefully soon from an intern
in the program.

The plan is to have most of the patches being  merged through subsystem
maintainer trees as much as possible, but I also want to give them linux-next
exposure as early as possible, in particular since a lot of the code that
is being changed is not actively maintained.  I will send the remaining
patches to Thomas Gleixner so he can put them into the tip tree.

Please add

git://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git y2038

to linux-next. At the moment there is only one simple patch in it,
I assume there will be more soon.

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


Re: [PATCH] ARM: supplementing IO accessors with 64 bit capability

2014-10-23 Thread Nicolas Pitre
On Thu, 23 Oct 2014, Russell King - ARM Linux wrote:

> On Thu, Oct 23, 2014 at 03:47:32PM -0400, Nicolas Pitre wrote:
> > On Wed, 22 Oct 2014, Catalin Marinas wrote:
> > 
> > > On Wed, Oct 22, 2014 at 05:06:23PM +0100, mathieu.poir...@linaro.org 
> > > wrote:
> > > > +#if __LINUX_ARM_ARCH__ >= 5
> > > 
> > > My old ARMv5 book does not list LDRD/STRD. It looks like they only come
> > > with ARMv5TE. Are there any processors prior to this supported by the
> > > kernel?
> > 
> > We still supports ARMv4 targets.
> > 
> > As far as I know, all the ARMv5 targets we support are also TE capable.
> 
> Not quite.  We have ARM1020, which according to our proc-*.S files is
> only ARMv5T, not ARMv5TE.

Oh well.  Never saw such a beast in the field though.

Maybe to be on the very safe side, given that no ARMV5TE is likely to 
need 64-bit IO accessors at this point, this could simply be 
__LINUX_ARM_ARCH__ >= 6 instead.


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


kernel 3.17.1: fail to use USB3 device after resuming from suspend

2014-10-23 Thread Francis Moreau
Hello,

After resuming from a suspend (to RAM), I can't use an external USB hard
drive anymore, the kernel seems to fail to detect it.

Here is the kernel log when doing a suspend/resume cycle.

[Oct23 22:03] wlp2s0: deauthenticating from 92:23:b1:f9:54:e4 by local
choice (Reason: 3=DEAUTH_LEAVING)
[  +0.025152] cfg80211: Calling CRDA to update world regulatory domain
[  +0.052636] IPv6: ADDRCONF(NETDEV_UP): wlp2s0: link is not ready
[  +0.071175] PM: Syncing filesystems ... done.
[  +0.099223] PM: Preparing system for mem sleep
[  +0.000347] Freezing user space processes ... (elapsed 0.001 seconds)
done.
[  +0.001406] Freezing remaining freezable tasks ... (elapsed 0.001
seconds) done.
[  +0.001083] PM: Entering mem sleep
[  +0.17] Suspending console(s) (use no_console_suspend to debug)
[  +0.000264] sd 4:0:0:0: [sdb] Synchronizing SCSI cache
[  +0.36] sd 4:0:0:0: [sdb] Stopping disk
[  +0.04] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  +0.49] sd 0:0:0:0: [sda] Stopping disk
[  +1.058316] PM: suspend of devices complete after 1057.429 msecs
[  +0.013434] PM: late suspend of devices complete after 13.410 msecs
[  +0.000875] ehci-pci :00:1d.0: System wakeup enabled by ACPI
[  +0.13] r8169 :03:00.2: System wakeup enabled by ACPI
[  +0.000101] ehci-pci :00:1a.0: System wakeup enabled by ACPI
[  +0.47] xhci_hcd :00:14.0: System wakeup enabled by ACPI
[  +0.012356] PM: noirq suspend of devices complete after 13.373 msecs
[  +0.000401] ACPI: Preparing to enter system sleep state S3
[  +0.002149] PM: Saving platform NVS memory
[  +0.06] Disabling non-boot CPUs ...
[  +0.75] intel_pstate CPU 1 exiting
[  +0.001363] kvm: disabling virtualization on CPU1
[  +0.28] smpboot: CPU 1 is now offline
[  +0.000436] intel_pstate CPU 2 exiting
[  +0.001348] kvm: disabling virtualization on CPU2
[  +0.100773] smpboot: CPU 2 is now offline
[  +0.000322] intel_pstate CPU 3 exiting
[  +0.001260] kvm: disabling virtualization on CPU3
[  +0.101855] smpboot: CPU 3 is now offline
[  +0.000246] intel_pstate CPU 4 exiting
[  +0.001181] kvm: disabling virtualization on CPU4
[  +0.102021] smpboot: CPU 4 is now offline
[  +0.000396] intel_pstate CPU 5 exiting
[  +0.001242] kvm: disabling virtualization on CPU5
[  +0.101801] smpboot: CPU 5 is now offline
[  +0.000292] intel_pstate CPU 6 exiting
[  +0.001301] kvm: disabling virtualization on CPU6
[  +0.101880] smpboot: CPU 6 is now offline
[  +0.000496] intel_pstate CPU 7 exiting
[  +0.001265] kvm: disabling virtualization on CPU7
[  +0.101649] smpboot: CPU 7 is now offline
[  +0.002022] ACPI: Low-level resume complete
[  +0.43] PM: Restoring platform NVS memory
[  +0.000342] Enabling non-boot CPUs ...
[  +0.47] x86: Booting SMP configuration:
[  +0.02] smpboot: Booting Node 0 Processor 1 APIC 0x2
[  +0.011516] kvm: enabling virtualization on CPU1
[  +0.002301] CPU1 is up
[  +0.25] smpboot: Booting Node 0 Processor 2 APIC 0x4
[  +0.011466] kvm: enabling virtualization on CPU2
[  +0.002307] CPU2 is up
[  +0.22] smpboot: Booting Node 0 Processor 3 APIC 0x6
[  +0.011469] kvm: enabling virtualization on CPU3
[  +0.002305] CPU3 is up
[  +0.22] smpboot: Booting Node 0 Processor 4 APIC 0x1
[  +0.011483] kvm: enabling virtualization on CPU4
[  +0.002298] CPU4 is up
[  +0.18] smpboot: Booting Node 0 Processor 5 APIC 0x3
[  +0.011437] kvm: enabling virtualization on CPU5
[  +0.002305] CPU5 is up
[  +0.17] smpboot: Booting Node 0 Processor 6 APIC 0x5
[  +0.011550] kvm: enabling virtualization on CPU6
[  +0.002297] CPU6 is up
[  +0.17] smpboot: Booting Node 0 Processor 7 APIC 0x7
[  +0.011457] kvm: enabling virtualization on CPU7
[  +0.002312] CPU7 is up
[  +0.006813] ACPI: Waking up from system sleep state S3
[  +0.046539] ehci-pci :00:1d.0: System wakeup disabled by ACPI
[  +0.000267] ehci-pci :00:1a.0: System wakeup disabled by ACPI
[  +0.000123] xhci_hcd :00:14.0: System wakeup disabled by ACPI
[  +0.53] PM: noirq resume of devices complete after 13.005 msecs
[  +0.000523] PM: early resume of devices complete after 0.479 msecs
[  +0.000120] mei_me :00:16.0: irq 28 for MSI/MSI-X
[  +0.47] r8169 :03:00.2: System wakeup disabled by ACPI
[  +0.97] snd_hda_intel :00:1b.0: irq 29 for MSI/MSI-X
[  +0.003073] rtc_cmos 00:02: System wakeup disabled by ACPI
[  +0.008776] sd 4:0:0:0: [sdb] Starting disk
[  +0.09] sd 0:0:0:0: [sda] Starting disk
[  +0.053104] r8169 :03:00.2 enp3s0f2: link down
[  +0.254016] usb 1-4: reset full-speed USB device number 2 using xhci_hcd
[  +0.16] xhci_hcd :00:14.0: Setup ERROR: setup context command
for slot 1.
[  +0.03] usb 1-4: hub failed to enable device, error -22
[  +0.019787] ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[  +0.002347] ata3.00: configured for UDMA/100
[  +0.004325] ata5: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[  +0.014796] ata5.00: ACPI cmd ef/10:06:00:00:00:00 (SET FEATURES)
succeeded
[  

<    1   2   3   4   5   6   7   8   9   10   >