[PATCH v2] perf: report/annotate: fix segfault problem.

2015-04-02 Thread Wang Nan
perf report and perf annotate are easy to trigger segfault if trace data
contain kernel module information like this:

 # perf report -D -i ./perf.data
 ...
 0 0 0x188 [0x50]: PERF_RECORD_MMAP -1/0: [0xffbff1018000(0xf068000) @ 0]: 
x [test_module]
 ...

 # perf report -i ./perf.data --objdump=/path/to/objdump 
--kallsyms=/path/to/kallsyms

 perf: Segmentation fault
  backtrace 
 /path/to/perf[0x503478]
 /lib64/libc.so.6(+0x3545f)[0x7fb201f3745f]
 /path/to/perf[0x499b56]
 /path/to/perf(dso__load_kallsyms+0x13c)[0x49b56c]
 /path/to/perf(dso__load+0x72e)[0x49c21e]
 /path/to/perf(map__load+0x6e)[0x4ae9ee]
 /path/to/perf(thread__find_addr_map+0x24c)[0x47deec]
 /path/to/perf(perf_event__preprocess_sample+0x88)[0x47e238]
 /path/to/perf[0x43ad02]
 /path/to/perf[0x4b55bc]
 /path/to/perf(ordered_events__flush+0xca)[0x4b57ea]
 /path/to/perf[0x4b1a01]
 /path/to/perf(perf_session__process_events+0x3be)[0x4b428e]
 /path/to/perf(cmd_report+0xf11)[0x43bfc1]
 /path/to/perf[0x474702]
 /path/to/perf(main+0x5f5)[0x42de95]
 /lib64/libc.so.6(__libc_start_main+0xf4)[0x7fb201f23bd4]
 /path/to/perf[0x42dfc4]

This is because __kmod_path__parse regard '[' leading name as kernel
instead of kernel module. The DSO will then be passed to
dso__load_kernel_sym() then dso__load_kcore() because of --kallsyms
argument. The segfault is triggered because the kmap structure is not
initialized.

Although in --vmlinux case such segfault can be avoided, the symbols in
the kernel module are unable to be retrived since the attribute of DSO
is incorrect.

This patch fixes __kmod_path__parse, make it regard names like
'[test_module]' as kernel module.

Signed-off-by: Wang Nan 
---

Patch v1 doesn't consider module named as [aaa.bbb].

---
 tools/perf/util/dso.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index fc0ddd5..08d7aaf 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -214,12 +214,23 @@ int __kmod_path__parse(struct kmod_path *m, const char 
*path,
 {
const char *name = strrchr(path, '/');
const char *ext  = strrchr(path, '.');
+   bool is_simple_name = false;
 
memset(m, 0x0, sizeof(*m));
name = name ? name + 1 : path;
 
+   /*
+* '.' is also a valid character. For example: [aaa.bbb] is a
+* valid module name. '[' should have higher priority than
+* '.ko' suffix.
+*/
+   if ((name[0] == '[') && (strncmp(name, "[vdso]", 6) != 0)) {
+   m->kmod = true;
+   is_simple_name = true;
+   }
+
/* No extension, just return name. */
-   if (ext == NULL) {
+   if ((ext == NULL) || is_simple_name) {
if (alloc_name) {
m->name = strdup(name);
return m->name ? 0 : -ENOMEM;
-- 
1.8.3.4

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


Re: [PATCH] PM / watchdog: iTCO: stop watchdog during system suspend

2015-04-02 Thread Guenter Roeck

On 04/02/2015 03:04 PM, Rafael J. Wysocki wrote:
[ ... ]


---
From: Rafael J. Wysocki 
Subject: PM / watchdog: iTCO: stop watchdog during system suspend

If the target sleep state of the system is not an ACPI sleep state
(S1, S2 or S3), the TCO watchdog needs to be stopped during system
suspend, because it may not be possible to ping it any more after
timekeeping has been suspended (suspend-to-idle does that for
one example).

For this reason, provide ->suspend_noirq and ->resume_noirq
callbacks for the iTCO watchdog driver and use them to stop
and restart the watchdog during system suspend and resume,
respectively, if the system is not going to enter an ACPI
sleep state (in which case the watchdog will be stopped
by the platform firmware before the state is entered).

Reported-by: Borun Fu 
Signed-off-by: Rafael J. Wysocki 


Reviewed-by: Guenter Roeck 


---
  drivers/watchdog/iTCO_wdt.c |   51 

  1 file changed, 51 insertions(+)

Index: linux-pm/drivers/watchdog/iTCO_wdt.c
===
--- linux-pm.orig/drivers/watchdog/iTCO_wdt.c
+++ linux-pm/drivers/watchdog/iTCO_wdt.c
@@ -51,6 +51,7 @@
  #define DRV_VERSION   "1.11"

  /* Includes */
+#include   /* For ACPI support */
  #include/* For module specific items */
  #include   /* For new moduleparam's */
  #include /* For standard types (like size_t) */
@@ -103,6 +104,8 @@ static struct { /* this is private data
struct platform_device *dev;
/* the PCI-device */
struct pci_dev *pdev;
+   /* whether or not the watchdog has been suspended */
+   bool suspended;
  } iTCO_wdt_private;

  /* module parameters */
@@ -571,12 +574,60 @@ static void iTCO_wdt_shutdown(struct pla
iTCO_wdt_stop(NULL);
  }

+#ifdef CONFIG_PM_SLEEP
+/*
+ * Suspend-to-idle requires this, because it stops the ticks and timekeeping, 
so
+ * the watchdog cannot be pinged while in that state.  In ACPI sleep states the
+ * watchdog is stopped by the platform firmware.
+ */
+
+#ifdef CONFIG_ACPI
+static inline bool need_suspend(void)
+{
+   return acpi_target_system_state() == ACPI_STATE_S0;
+}
+#else
+static inline bool need_suspend(void) { return true; }
+#endif
+
+static int iTCO_wdt_suspend_noirq(struct device *dev)
+{
+   int ret = 0;
+
+   iTCO_wdt_private.suspended = false;
+   if (watchdog_active(_wdt_watchdog_dev) && need_suspend()) {
+   ret = iTCO_wdt_stop(_wdt_watchdog_dev);
+   if (!ret)
+   iTCO_wdt_private.suspended = true;
+   }
+   return ret;
+}
+
+static int iTCO_wdt_resume_noirq(struct device *dev)
+{
+   if (iTCO_wdt_private.suspended)
+   iTCO_wdt_start(_wdt_watchdog_dev);
+
+   return 0;
+}
+
+struct dev_pm_ops iTCO_wdt_pm = {
+   .suspend_noirq = iTCO_wdt_suspend_noirq,
+   .resume_noirq = iTCO_wdt_resume_noirq,
+};
+
+#define ITCO_WDT_PM_OPS(_wdt_pm)
+#else
+#define ITCO_WDT_PM_OPSNULL
+#endif /* CONFIG_PM_SLEEP */
+
  static struct platform_driver iTCO_wdt_driver = {
.probe  = iTCO_wdt_probe,
.remove = iTCO_wdt_remove,
.shutdown   = iTCO_wdt_shutdown,
.driver = {
.name   = DRV_NAME,
+   .pm = ITCO_WDT_PM_OPS,
},
  };


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



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


Re: [PATCH] smp/call: Detect stuck CSD locks

2015-04-02 Thread Ingo Molnar

* Ingo Molnar  wrote:

> +static void csd_lock_wait(struct call_single_data *csd, int cpu)
>  {
> - while (csd->flags & CSD_FLAG_LOCK)
> + int bug_id = 0;
> + u64 ts0, ts1, ts_delta;
> +
> + ts0 = jiffies_to_msecs(jiffies);

Note that while 'jiffies' is a global variable, it's read-mostly 
accessed, so it is a pretty cheap way to acquire a timestamp in such a 
simple polling context that has irqs enabled.

Thanks,

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


Re: smp_call_function_single lockups

2015-04-02 Thread Ingo Molnar

* Chris J Arges  wrote:

> 
> 
> On 04/02/2015 02:07 PM, Ingo Molnar wrote:
> > 
> > * Chris J Arges  wrote:
> > 
> >> Whenever we look through the crashdump we see csd_lock_wait waiting 
> >> for CSD_FLAG_LOCK bit to be cleared.  Usually the signature leading 
> >> up to that looks like the following (in the openstack tempest on 
> >> openstack and nested VM stress case)
> >>
> >> (qemu-system-x86 task)
> >> kvm_sched_in
> >>  -> kvm_arch_vcpu_load
> >>   -> vmx_vcpu_load
> >>-> loaded_vmcs_clear
> >> -> smp_call_function_single
> >>
> >> (ksmd task)
> >> pmdp_clear_flush
> >>  -> flush_tlb_mm_range
> >>   -> native_flush_tlb_others
> >> -> smp_call_function_many
> > 
> > So is this two separate smp_call_function instances, crossing each 
> > other, and none makes any progress, indefinitely - as if the two IPIs 
> > got lost?
> > 
> 
> This is two different crash signatures. Sorry for the confusion.

So just in case, both crash signatures ought to be detected by the 
patch I just sent.

Thanks,

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


[PATCH] smp/call: Detect stuck CSD locks

2015-04-02 Thread Ingo Molnar

* Chris J Arges  wrote:

> Ingo,
> 
> I think tracking IPI calls from 'generic_exec_single' would make a lot
> of sense. When you say poll for completion do you mean a loop after
> 'arch_send_call_function_single_ipi' in kernel/smp.c? My main concern
> would be to not alter the timings too much so we can still reproduce the
> original problem.
> 
> Another approach:
> If we want to check for non-ACKed IPIs a possibility would be to add a
> timestamp field to 'struct call_single_data' and just record jiffies
> when the IPI gets called. Then have a per-cpu kthread check the
> 'call_single_queue' percpu list periodically if (jiffies - timestamp) >
> THRESHOLD. When we reach that condition print the stale entry in
> call_single_queue, backtrace, then re-send the IPI.
> 
> Let me know what makes the most sense to hack on.

Well, the thing is, putting this polling into an async kernel thread 
loses a lot of data context and right of reference that we might need 
to re-send an IPI.

And if the context is not lost we might as well send it from the 
original, still-looping context - which is a lot simpler as well.

( ... and on a deadlocked non-CONFIG_PREEMPT kernel the kernel thread
  won't run at all, so it won't be able to detect deadlocks. )

So I'd really suggest instrumenting the already existing CSD polling, 
which is already a slowpath, so it won't impact timing much.
 
I'd suggest the following, rather unintrusive approach:

 - first just take a jiffies timestamp and generate a warning message 
   if more than 10 seconds elapsed after sending the IPI, without 
   having heard from it.

 - then the IPI is resent. This means adding a bit of a control flow 
   to csd_lock_wait().

Something like the patch below, which implements both steps:

  - It will detect and print CSD deadlocks both in the single- and 
multi- function call APIs, and in the pre-IPI CSD lock wait case 
as well.

  - It will resend an IPI if possible

  - It generates various messages in the deadlock case that should 
give us some idea about how the deadlock played out and whether it 
got resolved.

The timeout is set to 10 seconds, that should be plenty even in a 
virtualization environment.

Only very lightly tested under a simple lkvm bootup: I verified that 
the boilerplate message is displayed, and that it doesn't generate 
false positive messages in light loads - but I haven't checked whether 
the deadlock detection works at all.

Thanks,

Ingo
---

 kernel/smp.c | 51 ++-
 1 file changed, 46 insertions(+), 5 deletions(-)

diff --git a/kernel/smp.c b/kernel/smp.c
index f38a1e692259..e0eec1ab3ef2 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -98,22 +98,63 @@ void __init call_function_init(void)
register_cpu_notifier(_cfd_notifier);
 }
 
+/* Locking timeout in ms: */
+#define CSD_LOCK_TIMEOUT (10*1000ULL)
+
+/* Print this ID in every printk line we output, to be able to easily sort 
them apart: */
+static int csd_bug_count;
+
 /*
  * csd_lock/csd_unlock used to serialize access to per-cpu csd resources
  *
  * For non-synchronous ipi calls the csd can still be in use by the
  * previous function call. For multi-cpu calls its even more interesting
  * as we'll have to ensure no other cpu is observing our csd.
+ *
+ * ( The overhead of deadlock detection is not a big problem, this is a
+ *   cpu_relax() loop that is actively wasting CPU cycles to poll for
+ *   completion. )
  */
-static void csd_lock_wait(struct call_single_data *csd)
+static void csd_lock_wait(struct call_single_data *csd, int cpu)
 {
-   while (csd->flags & CSD_FLAG_LOCK)
+   int bug_id = 0;
+   u64 ts0, ts1, ts_delta;
+
+   ts0 = jiffies_to_msecs(jiffies);
+
+   if (unlikely(!csd_bug_count)) {
+   csd_bug_count++;
+   printk("csd: CSD deadlock debugging initiated!\n");
+   }
+
+   while (csd->flags & CSD_FLAG_LOCK) {
+   ts1 = jiffies_to_msecs(jiffies);
+
+   ts_delta = ts1-ts0;
+   if (unlikely(ts_delta >= CSD_LOCK_TIMEOUT)) { /* Uh oh, it took 
too long. Why? */
+
+   bug_id = csd_bug_count;
+   csd_bug_count++;
+
+   ts0 = ts1; /* Re-start the timeout detection */
+
+   printk("csd: Detected non-responsive CSD lock (#%d) on 
CPU#%02d, waiting %Ld.%03Ld secs for CPU#%02d\n",
+   bug_id, raw_smp_processor_id(), 
ts_delta/1000ULL, ts_delta % 1000ULL, cpu);
+   if (cpu >= 0) {
+   printk("csd: Re-sending CSD lock (#%d) IPI from 
CPU#%02d to CPU#%02d\n", bug_id, raw_smp_processor_id(), cpu);
+   arch_send_call_function_single_ipi(cpu);
+   }
+   dump_stack();
+   }
cpu_relax();
+   }
+   if (unlikely(bug_id))
+   printk("csd: CSD lock 

Re: [PATCH 2/2] hrtimer: create for_each_active_base() to iterate over active clock-bases

2015-04-02 Thread viresh kumar
On 2 April 2015 at 19:15, Peter Zijlstra  wrote:
> On Thu, Apr 02, 2015 at 04:21:22PM +0530, Viresh Kumar wrote:
>> +#define for_each_active_base(_index, _base, _cpu_base, _active_bases)   
>>  \
>> + for ((_active_bases) = (_cpu_base)->active_bases;   \
>> + (_index) = ffs(_active_bases),  \
>> + (_base) = (_cpu_base)->clock_base + (_index) - 1, (_index); \
>> + (_active_bases) &= ~(1 << ((_index) - 1)))
>
> Can't use ffs here, some people end up using asm-generic/bitops/ffs.h
> and that sucks.
>
> Esp for small vectors like here, the unconditional iteration is faster.

Okay what about this instead (This is the best I could write :).) ?

+static inline int __next_bit(unsigned int active_bases, int bit)
+{
+   do {
+   if (active_bases & (1 << bit))
+   return bit;
+   } while (++bit < HRTIMER_MAX_CLOCK_BASES);
+
+   /* We should never reach here */
+   return 0;
+}
+/*
+ * for_each_active_base: iterate over all active clock bases
+ * @_bit: 'int' variable for internal purpose
+ * @_base: holds pointer to a active clock base
+ * @_cpu_base: cpu base to iterate on
+ * @_active_bases: 'unsigned int' variable for internal purpose
+ */
+#define for_each_active_base(_bit, _base, _cpu_base, _active_bases)\
+   for ((_active_bases) = (_cpu_base)->active_bases, (_bit) = -1;  \
+   (_active_bases) &&  \
+   ((_bit) = __next_bit(_active_bases, ++_bit),\
+   (_base) = (_cpu_base)->clock_base + _bit);  \
+   (_active_bases) &= ~(1 << (_bit)))
+


Tested it well with the help of: http://pastebin.com/cYyB513D, with
inputs from 0 to 15.

I will send it formally if it looks fine to you ..
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/3] watchdog: imgpdc: Allow timeout to be set in device-tree

2015-04-02 Thread Guenter Roeck

On 04/02/2015 07:35 PM, Guenter Roeck wrote:

On 04/02/2015 07:16 PM, Andrew Bresticker wrote:

Hi Guenter,

On Thu, Apr 2, 2015 at 6:52 PM, Guenter Roeck  wrote:

On 04/02/2015 09:46 AM, Andrew Bresticker wrote:


On Wed, Apr 1, 2015 at 6:08 PM, Guenter Roeck  wrote:


On 04/01/2015 03:22 PM, James Hogan wrote:



Hi Andrew,

On Wed, Apr 01, 2015 at 10:43:14AM -0700, Andrew Bresticker wrote:



Since the heartbeat is statically initialized to its default value,
watchdog_init_timeout() will never look in the device-tree for a
timeout-sec value.  Instead of statically initializing heartbeat,
fall back to the default timeout value if watchdog_init_timeout()
fails.




Whoops. Sorry about that. I wasn't aware that a timeout-sec value was
expected. It isn't mentioned in the DT binding documentation for this
device :-(.



Signed-off-by: Andrew Bresticker 
Cc: Ezequiel Garcia 
Cc: James Hogan 
---
New for v2.
---
drivers/watchdog/imgpdc_wdt.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/imgpdc_wdt.c
b/drivers/watchdog/imgpdc_wdt.c
index 0deaa4f..89b2abc 100644
--- a/drivers/watchdog/imgpdc_wdt.c
+++ b/drivers/watchdog/imgpdc_wdt.c
@@ -42,7 +42,7 @@
#define PDC_WDT_MIN_TIMEOUT   1
#define PDC_WDT_DEF_TIMEOUT   64

-static int heartbeat = PDC_WDT_DEF_TIMEOUT;
+static int heartbeat;
module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds "
  "(default=" __MODULE_STRING(PDC_WDT_DEF_TIMEOUT) ")");
@@ -195,9 +195,9 @@ static int pdc_wdt_probe(struct platform_device
*pdev)

  ret = watchdog_init_timeout(_wdt->wdt_dev, heartbeat,
>dev);
  if (ret < 0) {
-   pdc_wdt->wdt_dev.timeout =
pdc_wdt->wdt_dev.max_timeout;
+   pdc_wdt->wdt_dev.timeout = PDC_WDT_DEF_TIMEOUT;




The watchdog_init_timeout kerneldoc comment suggests that the old value
should be the default timeout, i.e. that timeout should be set to
PDC_WDT_DEF_TIMEOUT before calling watchdog_init_timeout, rather than
whenever ret < 0.

Indeed, if heartbeat is set to an invalid non-zero value,
watchdog_init_timeout will still try and set timeout from DT, but also
still returns -EINVAL regardless of whether that succeeds, and this
would incorrectly override the timeout from DT with the hardcoded
default.


  dev_warn(>dev,
-"Initial timeout out of range! setting max
timeout\n");
+"Initial timeout out of range! setting default
timeout\n");




It feels wrong for a presumably safe & normal situation (i.e. no default
in DT, which arguably shouldn't contain policy anyway) to show a
warning, but it can also show due to an invalid module parameter (or
invalid DT property) which is most definitely justified.



Agreed. I would suggest to leave that part alone and set the default
prior
to calling watchdog_init_timeout().



Yes, but I think James' concern here was that we'd now get a
dev_warn() in the normal case where no timeout is specified via module
parameter or DT.


My understanding is that watchdog_init_timeout only returns an error if
the second parameter is not 0 and invalid, or if the timeout-sec property
has been provided and is invalid. I am not entirely sure I understand
why you think this is a problem. Can you please explain ?


Unless I've gone completely insane, I'm pretty sure this will return
-EINVAL if timeout_parm is 0 and timeout-sec is not present:

int watchdog_init_timeout(struct watchdog_device *wdd,
 unsigned int timeout_parm, struct device *dev)
{
 unsigned int t = 0;
 int ret = 0;

 watchdog_check_min_max_timeout(wdd);

 /* try to get the timeout module parameter first */
 if (!watchdog_timeout_invalid(wdd, timeout_parm) && timeout_parm) {
 wdd->timeout = timeout_parm;
 return ret;
 }
 if (timeout_parm)
 ret = -EINVAL;

 /* try to get the timeout_sec property */
 if (dev == NULL || dev->of_node == NULL)
 return ret;
 of_property_read_u32(dev->of_node, "timeout-sec", );
 if (!watchdog_timeout_invalid(wdd, t) && t)
 wdd->timeout = t;
 else
 ret = -EINVAL;

 return ret;
}

That said, the behavior you describe makes more sense, so perhaps
watchdog_init_timeout() should be updated to match.



Ah yes, you are right, that last else case. Guess we'll need input from Wim
on how to handle this.



Actually, after looking into how other drivers use it, this is on purpose.
It says "I failed to initialize the timeout" and lets the caller deal with it.
Check other watchdog drivers for examples and possibilities.

Guenter

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

[PATCH] perf: report/annotate: fix segfault problem.

2015-04-02 Thread Wang Nan
perf report and perf annotate are easy to trigger segfault if trace data
contain kernel module information like this:

 # perf report -D -i ./perf.data
 ...
 0 0 0x188 [0x50]: PERF_RECORD_MMAP -1/0: [0xffbff1018000(0xf068000) @ 0]: 
x [test_module]
 ...

 # perf report -i ./perf.data --objdump=/path/to/objdump 
--kallsyms=/path/to/kallsyms

 perf: Segmentation fault
  backtrace 
 /path/to/perf[0x503478]
 /lib64/libc.so.6(+0x3545f)[0x7fb201f3745f]
 /path/to/perf[0x499b56]
 /path/to/perf(dso__load_kallsyms+0x13c)[0x49b56c]
 /path/to/perf(dso__load+0x72e)[0x49c21e]
 /path/to/perf(map__load+0x6e)[0x4ae9ee]
 /path/to/perf(thread__find_addr_map+0x24c)[0x47deec]
 /path/to/perf(perf_event__preprocess_sample+0x88)[0x47e238]
 /path/to/perf[0x43ad02]
 /path/to/perf[0x4b55bc]
 /path/to/perf(ordered_events__flush+0xca)[0x4b57ea]
 /path/to/perf[0x4b1a01]
 /path/to/perf(perf_session__process_events+0x3be)[0x4b428e]
 /path/to/perf(cmd_report+0xf11)[0x43bfc1]
 /path/to/perf[0x474702]
 /path/to/perf(main+0x5f5)[0x42de95]
 /lib64/libc.so.6(__libc_start_main+0xf4)[0x7fb201f23bd4]
 /path/to/perf[0x42dfc4]

This is because __kmod_path__parse regard '[' leading name as kernel
instead of kernel module. The DSO will then be passed to
dso__load_kernel_sym() then dso__load_kcore() because of --kallsyms
argument. The segfault is triggered because the kmap structure is not
initialized.

Although in --vmlinux case such segfault can be avoided, the symbols in
the kernel module are unable to be retrived since the attribute of DSO
is incorrect.

This patch fixes __kmod_path__parse, make it regard names like
'[test_module]' as kernel module.

Signed-off-by: Wang Nan 
---
 tools/perf/util/dso.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index fc0ddd5..4afeeaf 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -220,6 +220,8 @@ int __kmod_path__parse(struct kmod_path *m, const char 
*path,
 
/* No extension, just return name. */
if (ext == NULL) {
+   if ((name[0] == '[') && (strncmp(name, "[vdso]", 6) != 0))
+   m->kmod = true;
if (alloc_name) {
m->name = strdup(name);
return m->name ? 0 : -ENOMEM;
-- 
1.8.3.4

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


[PATCH v4] video: mxsfb: Make sure axi clock is enabled when accessing registers

2015-04-02 Thread Liu Ying
The LCDIF engines embedded in i.MX6sl and i.MX6sx SoCs need the axi clock
as the engine's system clock.  The clock should be enabled when accessing
LCDIF registers, otherwise the kernel would hang up.  We should also keep
the clock enabled when the engine is being active to scan out frames from
memory.  This patch makes sure the axi clock is enabled when accessing
registers so that the kernel hang up issue can be fixed.

Reported-by: Peter Chen 
Tested-by: Peter Chen 
Cc:  # 3.19+
Signed-off-by: Liu Ying 
---
v3->v4:
* To address Tomi's comment, enable/disable the axi clock in
  mxsfb_pan_display() directly instead of checking the host->enabled flag.

v2->v3:
* To address Tomi's comment, improve the commit message only.

v1->v2:
* Add 'Tested-by: Peter Chen ' tag.
* Add 'Cc:  # 3.19+' tag.

 drivers/video/fbdev/mxsfb.c | 68 +++--
 1 file changed, 54 insertions(+), 14 deletions(-)

diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c
index f8ac4a4..0f64165 100644
--- a/drivers/video/fbdev/mxsfb.c
+++ b/drivers/video/fbdev/mxsfb.c
@@ -316,6 +316,18 @@ static int mxsfb_check_var(struct fb_var_screeninfo *var,
return 0;
 }
 
+static inline void mxsfb_enable_axi_clk(struct mxsfb_info *host)
+{
+   if (host->clk_axi)
+   clk_prepare_enable(host->clk_axi);
+}
+
+static inline void mxsfb_disable_axi_clk(struct mxsfb_info *host)
+{
+   if (host->clk_axi)
+   clk_disable_unprepare(host->clk_axi);
+}
+
 static void mxsfb_enable_controller(struct fb_info *fb_info)
 {
struct mxsfb_info *host = to_imxfb_host(fb_info);
@@ -333,14 +345,13 @@ static void mxsfb_enable_controller(struct fb_info 
*fb_info)
}
}
 
-   if (host->clk_axi)
-   clk_prepare_enable(host->clk_axi);
-
if (host->clk_disp_axi)
clk_prepare_enable(host->clk_disp_axi);
clk_prepare_enable(host->clk);
clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U);
 
+   mxsfb_enable_axi_clk(host);
+
/* if it was disabled, re-enable the mode again */
writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_SET);
 
@@ -380,11 +391,11 @@ static void mxsfb_disable_controller(struct fb_info 
*fb_info)
reg = readl(host->base + LCDC_VDCTRL4);
writel(reg & ~VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4);
 
+   mxsfb_disable_axi_clk(host);
+
clk_disable_unprepare(host->clk);
if (host->clk_disp_axi)
clk_disable_unprepare(host->clk_disp_axi);
-   if (host->clk_axi)
-   clk_disable_unprepare(host->clk_axi);
 
host->enabled = 0;
 
@@ -421,6 +432,8 @@ static int mxsfb_set_par(struct fb_info *fb_info)
mxsfb_disable_controller(fb_info);
}
 
+   mxsfb_enable_axi_clk(host);
+
/* clear the FIFOs */
writel(CTRL1_FIFO_CLEAR, host->base + LCDC_CTRL1 + REG_SET);
 
@@ -438,6 +451,7 @@ static int mxsfb_set_par(struct fb_info *fb_info)
ctrl |= CTRL_SET_WORD_LENGTH(3);
switch (host->ld_intf_width) {
case STMLCDIF_8BIT:
+   mxsfb_disable_axi_clk(host);
dev_err(>pdev->dev,
"Unsupported LCD bus width mapping\n");
return -EINVAL;
@@ -451,6 +465,7 @@ static int mxsfb_set_par(struct fb_info *fb_info)
writel(CTRL1_SET_BYTE_PACKAGING(0x7), host->base + LCDC_CTRL1);
break;
default:
+   mxsfb_disable_axi_clk(host);
dev_err(>pdev->dev, "Unhandled color depth of %u\n",
fb_info->var.bits_per_pixel);
return -EINVAL;
@@ -504,6 +519,8 @@ static int mxsfb_set_par(struct fb_info *fb_info)
fb_info->fix.line_length * fb_info->var.yoffset,
host->base + host->devdata->next_buf);
 
+   mxsfb_disable_axi_clk(host);
+
if (reenable)
mxsfb_enable_controller(fb_info);
 
@@ -582,10 +599,14 @@ static int mxsfb_pan_display(struct fb_var_screeninfo 
*var,
 
offset = fb_info->fix.line_length * var->yoffset;
 
+   mxsfb_enable_axi_clk(host);
+
/* update on next VSYNC */
writel(fb_info->fix.smem_start + offset,
host->base + host->devdata->next_buf);
 
+   mxsfb_disable_axi_clk(host);
+
return 0;
 }
 
@@ -608,13 +629,17 @@ static int mxsfb_restore_mode(struct mxsfb_info *host,
unsigned line_count;
unsigned period;
unsigned long pa, fbsize;
-   int bits_per_pixel, ofs;
+   int bits_per_pixel, ofs, ret = 0;
u32 transfer_count, vdctrl0, vdctrl2, vdctrl3, vdctrl4, ctrl;
 
+   mxsfb_enable_axi_clk(host);
+
/* Only restore the mode when the controller is running */
ctrl = readl(host->base + LCDC_CTRL);
-   if (!(ctrl & CTRL_RUN))
-

Re: [PATCH] mtd: Add simple read disturb test

2015-04-02 Thread Andrea Scian

Hi all,

Il 02/04/2015 18:18, Richard Weinberger ha scritto:
> Am 02.04.2015 um 18:04 schrieb Brian Norris:
>> On Thu, Apr 02, 2015 at 04:13:46PM +0200, Richard Weinberger wrote:
>> [1] Although there are some latent issues in these tests that are still
>> getting get worked out (e.g., bad handling of 64-bit casting; too large
>> of stacks; uninterruptibility). The latter two would not even exist if
>> we were in user space.
> 
> uninterruptibility got solved by my "[PATCH] mtd: Make MTD tests cancelable" 
> patch.

And this is something I was looking for from years!

> But if we want to kill drivers/mtd/tests/ I'll happily help out.
> Where shall we move these tests into? mtd-utils?

I think so.
I'm writing a similar read disturb test on my own, mixing already
existing mtd-tools (flash_erase, nandwrite, nanddump) with some naive
bash scripting.
IMHO, we have a lot of pros running in userspace:
* dumping data
* better error/status log (which can be easily written on file, for
example, while mtdtests error log is mixed with other kernel messages)
* running test in parallel (if it make sense ;-)

For example on read disturb I already calculate RBER, which is, AFAIK, a
nice index on the quality of the NAND cell and of its data. I'm working
on writing down data on a separate CSV which can be easily processed
later (e.g. to make part to part comparison/statistics).

There's already a test directory inside mtd-utils, I think it's better
to start creating tests there, as userspace tools, whenever this is
possible.
Do we have any reason to have MTD tests as kernel module? (performance?)

Kind Regards,

-- 

Andrea SCIAN

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


[tip:x86/asm] x86/asm: Add support for the CLWB instruction

2015-04-02 Thread tip-bot for Ross Zwisler
Commit-ID:  d9dc64f30abe42f71bc7e9eb9d38c41006cf39f9
Gitweb: http://git.kernel.org/tip/d9dc64f30abe42f71bc7e9eb9d38c41006cf39f9
Author: Ross Zwisler 
AuthorDate: Tue, 27 Jan 2015 09:53:51 -0700
Committer:  Ingo Molnar 
CommitDate: Fri, 3 Apr 2015 06:56:38 +0200

x86/asm: Add support for the CLWB instruction

Add support for the new CLWB (cache line write back)
instruction.  This instruction was announced in the document
"Intel Architecture Instruction Set Extensions Programming
Reference" with reference number 319433-022.

  https://software.intel.com/sites/default/files/managed/0d/53/319433-022.pdf

The CLWB instruction is used to write back the contents of
dirtied cache lines to memory without evicting the cache lines
from the processor's cache hierarchy.  This should be used in
favor of clflushopt or clflush in cases where you require the
cache line to be written to memory but plan to access the data
again in the near future.

One of the main use cases for this is with persistent memory
where CLWB can be used with PCOMMIT to ensure that data has been
accepted to memory and is durable on the DIMM.

This function shows how to properly use CLWB/CLFLUSHOPT/CLFLUSH
and PCOMMIT with appropriate fencing:

void flush_and_commit_buffer(void *vaddr, unsigned int size)
{
void *vend = vaddr + size - 1;

for (; vaddr < vend; vaddr += boot_cpu_data.x86_clflush_size)
clwb(vaddr);

/* Flush any possible final partial cacheline */
clwb(vend);

/*
 * Use SFENCE to order CLWB/CLFLUSHOPT/CLFLUSH cache flushes.
 * (MFENCE via mb() also works)
 */
wmb();

/* PCOMMIT and the required SFENCE for ordering */
pcommit_sfence();
}

After this function completes the data pointed to by vaddr is
has been accepted to memory and will be durable if the vaddr
points to persistent memory.

Regarding the details of how the alternatives assembly is set
up, we need one additional byte at the beginning of the CLFLUSH
so that we can flip it into a CLFLUSHOPT by changing that byte
into a 0x66 prefix.  Two options are to either insert a 1 byte
ASM_NOP1, or to add a 1 byte NOP_DS_PREFIX.  Both have no
functional effect with the plain CLFLUSH, but I've been told
that executing a CLFLUSH + prefix should be faster than
executing a CLFLUSH + NOP.

We had to hard code the assembly for CLWB because, lacking the
ability to assemble the CLWB instruction itself, the next
closest thing is to have an xsaveopt instruction with a 0x66
prefix.  Unfortunately XSAVEOPT itself is also relatively new,
and isn't included by all the GCC versions that the kernel needs
to support.

Signed-off-by: Ross Zwisler 
Acked-by: Borislav Petkov 
Acked-by: H. Peter Anvin 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1422377631-8986-3-git-send-email-ross.zwis...@linux.intel.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/cpufeature.h|  1 +
 arch/x86/include/asm/special_insns.h | 14 ++
 2 files changed, 15 insertions(+)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 0f7a5a1..854c04b 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -233,6 +233,7 @@
 #define X86_FEATURE_SMAP   ( 9*32+20) /* Supervisor Mode Access Prevention 
*/
 #define X86_FEATURE_PCOMMIT( 9*32+22) /* PCOMMIT instruction */
 #define X86_FEATURE_CLFLUSHOPT ( 9*32+23) /* CLFLUSHOPT instruction */
+#define X86_FEATURE_CLWB   ( 9*32+24) /* CLWB instruction */
 #define X86_FEATURE_AVX512PF   ( 9*32+26) /* AVX-512 Prefetch */
 #define X86_FEATURE_AVX512ER   ( 9*32+27) /* AVX-512 Exponential and 
Reciprocal */
 #define X86_FEATURE_AVX512CD   ( 9*32+28) /* AVX-512 Conflict Detection */
diff --git a/arch/x86/include/asm/special_insns.h 
b/arch/x86/include/asm/special_insns.h
index 2ec1a53..aeb4666e 100644
--- a/arch/x86/include/asm/special_insns.h
+++ b/arch/x86/include/asm/special_insns.h
@@ -201,6 +201,20 @@ static inline void clflushopt(volatile void *__p)
   "+m" (*(volatile char __force *)__p));
 }
 
+static inline void clwb(volatile void *__p)
+{
+   volatile struct { char x[64]; } *p = __p;
+
+   asm volatile(ALTERNATIVE_2(
+   ".byte " __stringify(NOP_DS_PREFIX) "; clflush (%[pax])",
+   ".byte 0x66; clflush (%[pax])", /* clflushopt (%%rax) */
+   X86_FEATURE_CLFLUSHOPT,
+   ".byte 0x66, 0x0f, 0xae, 0x30",  /* clwb (%%rax) */
+   X86_FEATURE_CLWB)
+   : [p] "+m" (*p)
+   : [pax] "a" (p));
+}
+
 static inline void pcommit_sfence(void)
 {
alternative(ASM_NOP7,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

[tip:perf/core] perf data: Support using -f to override perf.data file ownership for 'convert'

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  bd05954bfa17f03a7bd4454178ba09786b35e383
Gitweb: http://git.kernel.org/tip/bd05954bfa17f03a7bd4454178ba09786b35e383
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:19 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:52 -0300

perf data: Support using -f to override perf.data file ownership for 'convert'

Enable perf data convert to use perf.data when it is not owned by
current user or root.

Example:

 # perf record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw--- 1 Yunlong.Song Yunlong.Song 28260 Apr  2 17:35 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf data convert --to-ctf=./ctf-data/
 File perf.data not owned by current user or root (use -f to override)
 # perf data convert --to-ctf=./ctf-data/ -f
   Error: unknown switch `f'

  usage: perf data convert []

 -v, --verbose be more verbose
 -i, --input input file name
 --to-ctf ...  Convert to CTF format

After this patch:

 # perf data convert --to-ctf=./ctf-data/
 File perf.data not owned by current user or root (use -f to override)
 # perf data convert --to-ctf=./ctf-data/ -f
 # ls ctf-data/
 metadata  perf_stream_0

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1427982439-27388-11-git-send-email-yunlong.s...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-data.c | 4 +++-
 tools/perf/util/data-convert-bt.c | 3 ++-
 tools/perf/util/data-convert-bt.h | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c
index 709152a..d6525bc 100644
--- a/tools/perf/builtin-data.c
+++ b/tools/perf/builtin-data.c
@@ -53,12 +53,14 @@ static int cmd_data_convert(int argc, const char **argv,
const char *prefix __maybe_unused)
 {
const char *to_ctf = NULL;
+   bool force = false;
const struct option options[] = {
OPT_INCR('v', "verbose", , "be more verbose"),
OPT_STRING('i', "input", _name, "file", "input file 
name"),
 #ifdef HAVE_LIBBABELTRACE_SUPPORT
OPT_STRING(0, "to-ctf", _ctf, NULL, "Convert to CTF format"),
 #endif
+   OPT_BOOLEAN('f', "force", , "don't complain, do it"),
OPT_END()
};
 
@@ -76,7 +78,7 @@ static int cmd_data_convert(int argc, const char **argv,
 
if (to_ctf) {
 #ifdef HAVE_LIBBABELTRACE_SUPPORT
-   return bt_convert__perf2ctf(input_name, to_ctf);
+   return bt_convert__perf2ctf(input_name, to_ctf, force);
 #else
pr_err("The libbabeltrace support is not compiled in.\n");
return -1;
diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index c6d6226..dd17c9a 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -791,12 +791,13 @@ err:
return -1;
 }
 
-int bt_convert__perf2ctf(const char *input, const char *path)
+int bt_convert__perf2ctf(const char *input, const char *path, bool force)
 {
struct perf_session *session;
struct perf_data_file file = {
.path = input,
.mode = PERF_DATA_MODE_READ,
+   .force = force,
};
struct convert c = {
.tool = {
diff --git a/tools/perf/util/data-convert-bt.h 
b/tools/perf/util/data-convert-bt.h
index dda30c5..4c20434 100644
--- a/tools/perf/util/data-convert-bt.h
+++ b/tools/perf/util/data-convert-bt.h
@@ -2,7 +2,7 @@
 #define __DATA_CONVERT_BT_H
 #ifdef HAVE_LIBBABELTRACE_SUPPORT
 
-int bt_convert__perf2ctf(const char *input_name, const char *to_ctf);
+int bt_convert__perf2ctf(const char *input_name, const char *to_ctf, bool 
force);
 
 #endif /* HAVE_LIBBABELTRACE_SUPPORT */
 #endif /* __DATA_CONVERT_BT_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf script: Support using -f to override perf.data file ownership

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  06af0f2c919d7c8f05efebe0d96a6f22297aafd4
Gitweb: http://git.kernel.org/tip/06af0f2c919d7c8f05efebe0d96a6f22297aafd4
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:16 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:50 -0300

perf script: Support using -f to override perf.data file ownership

Enable perf script to use perf.data when it is not owned by current user
or root. Change the short option name of --fields to -F to avoid confusion
with --force.

Example:

 # perf record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw--- 1 Yunlong.Song Yunlong.Song 28360 Apr  2 14:53 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf script
 File perf.data not owned by current user or root (use -f to override)
 # perf script -f
   Error: switch `f' requires a value

  usage: perf script []
 or: perf script [] record 

[tip:perf/core] perf timechart: Support using -f to override perf.data file ownership

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  44f7e432e3dc8a13f5661e8b722f53645df083d1
Gitweb: http://git.kernel.org/tip/44f7e432e3dc8a13f5661e8b722f53645df083d1
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:17 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:50 -0300

perf timechart: Support using -f to override perf.data file ownership

Enable perf timechart to use perf.data when it is not owned by current
user or root.

Example:

 # perf timechart record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw--- 1 Yunlong.Song Yunlong.Song 5471744 Apr  2 15:15 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf timechart
 File perf.data not owned by current user or root (use -f to override)
 # perf timechart -f
   Error: unknown switch `f'

  usage: perf timechart [] {record}

 -i, --input input file name
 -o, --outputoutput file name
 -w, --widthpage width
 --highlight 
   highlight tasks. Pass duration in ns or process name.
 -P, --power-only  output power data only
 -T, --tasks-only  output processes data only
 -p, --process 
   process selector. Pass a pid or process name.
 --symfs 
   Look for files with symbols relative to this 
directory
 -n, --proc-num min. number of tasks to print
 -t, --topologysort CPUs according to topology
 --io-skip-eagain  skip EAGAIN errors
 --io-min-time 
   all IO faster than min-time will visually appear 
longer
 --io-merge-dist 
   merge events that are merge-dist us apart

As shown above, the -f option does not work at all.

After this patch:

 # perf timechart
 File perf.data not owned by current user or root (use -f to override)
 # perf timechart -f
 Written 0.0 seconds of trace to output.svg.
 # cat output.svg
 
 http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd;>
 http://www.w3.org/2000/svg;>
 
   

[tip:perf/core] perf trace: Support using -f to override perf.data file ownership

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  e366a6d8949f3cfab01906b42c591098d59f3f35
Gitweb: http://git.kernel.org/tip/e366a6d8949f3cfab01906b42c591098d59f3f35
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:18 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:51 -0300

perf trace: Support using -f to override perf.data file ownership

Enable perf trace to use perf.data when it is not owned by current user
or root.

Example:

 # perf trace record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw--- 1 Yunlong.Song Yunlong.Song 4153101 Apr  2 15:28 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf trace -i perf.data
 File perf.data not owned by current user or root (use -f to override)
 # perf trace -i perf.data -f
   Error: unknown switch `f'

  usage: perf trace [] []
 or: perf trace [] --  []
 or: perf trace record [] []
 or: perf trace record [] --  []

 --eventevent selector. use 'perf list' to list
  available events
 --commshow the thread COMM next to its id
 --tool_stats  show tool stats
 -e, --expr  list of events to trace
 -o, --outputoutput file name
 -i, --input Analyze events in file
 -p, --pidtrace events on existing process id
 -t, --tidtrace events on existing thread id
 --filter-pids 
  ...

As shown above, the -f option does not work at all.

After this patch:

 # perf trace -i perf.data
 File perf.data not owned by current user or root (use -f to override)
 # perf trace -i perf.data -f
 0.056 ( 0.002 ms): ls/47325 brk( ...
 0.108 ( 0.018 ms): ls/47325 mmap(len: 4096, prot: READ|WRITE,...
 0.145 ( 0.013 ms): ls/47325 access(filename: 0x7f31259a0eb0, ...
 0.172 ( 0.008 ms): ls/47325 open(filename: 0x7fffeb9a0d00,   ...
 0.180 ( 0.004 ms): ls/47325 stat(filename: 0x7fffeb9a0d00,   ...
 0.185 ( 0.004 ms): ls/47325 open(filename: 0x7fffeb9a0d00,   ...
 0.189 ( 0.003 ms): ls/47325 stat(filename: 0x7fffeb9a0d00,   ...
 0.195 ( 0.004 ms): ls/47325 open(filename: 0x7fffeb9a0d00,   ...
 0.199 ( 0.002 ms): ls/47325 stat(filename: 0x7fffeb9a0d00,   ...
 0.205 ( 0.004 ms): ls/47325 open(filename: 0x7fffeb9a0d00,   ...
 0.211 ( 0.004 ms): ls/47325 stat(filename: 0x7fffeb9a0d00,   ...
 0.220 ( 0.007 ms): ls/47325 open(filename: 0x7f312599e8ff,   ...
 ...
 ...

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1427982439-27388-10-git-send-email-yunlong.s...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index bcc98ce..e124741 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1254,6 +1254,7 @@ struct trace {
boolshow_comm;
boolshow_tool_stats;
booltrace_syscalls;
+   boolforce;
int trace_pgfaults;
 };
 
@@ -2345,6 +2346,7 @@ static int trace__replay(struct trace *trace)
struct perf_data_file file = {
.path  = input_name,
.mode  = PERF_DATA_MODE_READ,
+   .force = trace->force,
};
struct perf_session *session;
struct perf_evsel *evsel;
@@ -2693,6 +2695,7 @@ int cmd_trace(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_CALLBACK_DEFAULT('F', "pf", _pgfaults, "all|maj|min",
 "Trace pagefaults", parse_pagefaults, "maj"),
OPT_BOOLEAN(0, "syscalls", _syscalls, "Trace syscalls"),
+   OPT_BOOLEAN('f', "force", , "don't complain, do it"),
OPT_END()
};
const char * const trace_subcommands[] = { "record", NULL };
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf lock: Support using -f to override perf.data file ownership

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  c4ac732a0377d1544a8385393a9877b693ff0652
Gitweb: http://git.kernel.org/tip/c4ac732a0377d1544a8385393a9877b693ff0652
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:14 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:48 -0300

perf lock: Support using -f to override perf.data file ownership

Enable perf lock to use perf.data when it is not owned by current user
or root.

Example:

 # perf lock record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw--- 1 Yunlong.Song Yunlong.Song 4880686 Apr  2 14:14 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf lock report
 File perf.data not owned by current user or root (use -f to override)
 Initializing perf session failed
 # perf lock report -f
   Error: unknown switch `f'

  usage: perf lock report []

 -k, --key   key for sorting (acquired / contended /
 avg_wait / wait_total / wait_max / wait_min)

As shown above, the -f option does not work at all.

After this patch:

 # perf lock report
 File perf.data not owned by current user or root (use -f to override)
 Initializing perf session failed
 # perf lock report -f
Name   acquired  contended   avg wait (ns) total wait (ns) ...

 >output_l...128  0   0   0 ...
  >lock114  0   0   0 ...
 >pi_lock112  0   0   0 ...
 &(>lock)->...112  0   0   0 ...
 &(>d_loc... 70  0   0   0 ...
 &(>file_lo... 62  0   0   0 ...
 &(>lock)->rl... 43  0   0   0 ...
 ...

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1427982439-27388-6-git-send-email-yunlong.s...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-lock.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 7893a9b..d49c2ab 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -846,6 +846,8 @@ static const struct perf_evsel_str_handler 
lock_tracepoints[] = {
{ "lock:lock_release",   perf_evsel__process_lock_release,   }, /* 
CONFIG_LOCKDEP */
 };
 
+static bool force;
+
 static int __cmd_report(bool display_info)
 {
int err = -EINVAL;
@@ -857,6 +859,7 @@ static int __cmd_report(bool display_info)
struct perf_data_file file = {
.path = input_name,
.mode = PERF_DATA_MODE_READ,
+   .force = force,
};
 
session = perf_session__new(, false, );
@@ -945,6 +948,7 @@ int cmd_lock(int argc, const char **argv, const char 
*prefix __maybe_unused)
"dump thread list in perf.data"),
OPT_BOOLEAN('m', "map", _map,
"map of lock instances (address:name table)"),
+   OPT_BOOLEAN('f', "force", , "don't complain, do it"),
OPT_END()
};
const struct option lock_options[] = {
@@ -956,6 +960,7 @@ int cmd_lock(int argc, const char **argv, const char 
*prefix __maybe_unused)
const struct option report_options[] = {
OPT_STRING('k', "key", _key, "acquired",
"key for sorting (acquired / contended / avg_wait / 
wait_total / wait_max / wait_min)"),
+   OPT_BOOLEAN('f', "force", , "don't complain, do it"),
/* TODO: type */
OPT_END()
};
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf mem: Support using -f to override perf.data file ownership

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  62a1a63a77451dee8fd318a5106ca108d6a8ebcb
Gitweb: http://git.kernel.org/tip/62a1a63a77451dee8fd318a5106ca108d6a8ebcb
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:15 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:49 -0300

perf mem: Support using -f to override perf.data file ownership

Enable perf mem to use perf.data when it is not owned by current user or
root.

Example:

 # perf mem -t load record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw--- 1 Yunlong.Song Yunlong.Song 16392 Apr  2 14:34 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf mem -D report
 File perf.data not owned by current user or root (use -f to override)
 # perf mem -D -f report
   Error: unknown switch `f'

  usage: perf mem [] {record|report}

 -t, --type  memory operations(load,store) Default load,store
 -D, --dump-raw-samples
   dump raw samples in ASCII
 -U, --hide-unresolved
   Only display entries resolved to a symbol
 -i, --input input file name
 -C, --cpulist of cpus to profile
 -x, --field-separator 
   separator for columns, no spaces will be added
   between columns '.' is reserved.

As shown above, the -f option does not work at all.

After this patch:

 # perf mem -D report
 File perf.data not owned by current user or root (use -f to override)
 # perf mem -D -f report
 # PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL
 39095 39095 0x81127e40 0x016887f45148338 8 0x68100142
 /proc/kcore:perf_event_aux
 39095 39095 0x8100a3fe 0x89007f8cb7d0 6 0x68100142
 /proc/kcore:native_sched_clock
 39095 39095 0x81309139 0x88bf44c9ded8 6 0x68100142
 /proc/kcore:acpi_map_lookup
 39095 39095 0x810f8c4c 0x89007f8ccd88 6 0x68100142
 /proc/kcore:rcu_nmi_exit
 39095 39095 0x81136346 0x88fea995dd50 6 0x68100142
 /proc/kcore:unlock_page
 39095 39095 0x812a64a2 0x88fea995dcc8 6 0x68100142
 /proc/kcore:half_md4_transform
 39095 39095 0x7f0cf877c7e9 0x25dfb94 6 0x68100142
 /lib64/libc-2.19.so:__readdir64
 39095 39095 0x7f0cf87575a3 0x7f0cf9163731 6 0x68100142
 /lib64/libc-2.19.so:__strcoll_l
 39095 39095 0x8116910e 0xea01c1bfbd50 23 0x68100242
 /proc/kcore:page_remove_rmap

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1427982439-27388-7-git-send-email-yunlong.s...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-mem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index b4dcf0b..675216e 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -15,6 +15,7 @@ struct perf_mem {
char const  *input_name;
boolhide_unresolved;
booldump_raw;
+   boolforce;
int operation;
const char  *cpu_list;
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -120,6 +121,7 @@ static int report_raw_events(struct perf_mem *mem)
struct perf_data_file file = {
.path = input_name,
.mode = PERF_DATA_MODE_READ,
+   .force = mem->force,
};
int err = -EINVAL;
int ret;
@@ -290,6 +292,7 @@ int cmd_mem(int argc, const char **argv, const char *prefix 
__maybe_unused)
   "separator",
   "separator for columns, no spaces will be added"
   " between columns '.' is reserved."),
+   OPT_BOOLEAN('f', "force", , "don't complain, do it"),
OPT_END()
};
const char *const mem_subcommands[] = { "record", "report", NULL };
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] ext4: better error handling of kstrdup()

2015-04-02 Thread Theodore Ts'o
On Fri, Mar 20, 2015 at 05:21:54PM -0400, Taesoo Kim wrote:
> Upon memory pressure, kstrdup() might fail and correctly
> handle memory error, although current implementation do not
> refer orig_data.
> 
> NOTE. fortunately the correct impl works, other than a
> corner case where kstrdup() fails and kzalloc() succeeds;
> it might record 'NULL' in the log.
> 
> Signed-off-by: Taesoo Kim 

Did you test this patch?  If there are no mount options (such as when
mounting the root file system, data is NULL, so orig_data is NULL),
and the mount fails.  So a kernel won't boot with this patch applied.

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


[tip:perf/core] perf kvm: Support using -f to override perf.data.guest file ownership

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  8cc5ec1f754355ed788838390e86389c9ffb7590
Gitweb: http://git.kernel.org/tip/8cc5ec1f754355ed788838390e86389c9ffb7590
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:13 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:47 -0300

perf kvm: Support using -f to override perf.data.guest file ownership

Enable perf kvm to use perf.data.guest when it is not owned by current
user or root.

Example:

 # perf kvm stat record ls
 # chown Yunlong.Song:Yunlong.Song perf.data.guest
 # ls -al perf.data.guest
 -rw--- 1 Yunlong.Song Yunlong.Song 4128937 Apr  2 11:05 perf.data.guest
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf kvm stat report
 File perf.data.guest not owned by current user or root (use -f to override)
 Initializing perf session failed
 # perf kvm stat report -f
   Error: unknown switch `f'

  usage: perf kvm stat report []

 --event 
   event for reporting: vmexit, mmio (x86 only),
   ioport (x86 only)
 --vcpu vcpu id to report
 -k, --key   key for sorting: sample(sort by samples
   number) time (sort by avg 
time)
 -p, --pidanalyze events only for given process id(s)

As shown above, the -f option does not work at all.

After this patch:

 # perf kvm stat report
 File perf.data.guest not owned by current user or root (use -f to override)
 Initializing perf session failed
 # perf kvm stat report -f
 Analyze events for all VMs, all VCPUs:

   VM-EXITSamples  Samples% Time%Min TimeMax Time   Avg time

 Total Samples:0, Total events handled time:0.00us.

As shown above, the -f option really works now. Since we have not
launched any KVM related process, the result shows 0 sample here.

Signed-off-by: Yunlong Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1427982439-27388-5-git-send-email-yunlong.s...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kvm.c   | 2 ++
 tools/perf/util/kvm-stat.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 643722f..1f9338f 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1047,6 +1047,7 @@ static int read_events(struct perf_kvm_stat *kvm)
struct perf_data_file file = {
.path = kvm->file_name,
.mode = PERF_DATA_MODE_READ,
+   .force = kvm->force,
};
 
kvm->tool = eops;
@@ -1204,6 +1205,7 @@ kvm_events_report(struct perf_kvm_stat *kvm, int argc, 
const char **argv)
" time (sort by avg time)"),
OPT_STRING('p', "pid", >opts.target.pid, "pid",
   "analyze events only for given process id(s)"),
+   OPT_BOOLEAN('f', "force", >force, "don't complain, do it"),
OPT_END()
};
 
diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h
index cf1d7913..ae825d4 100644
--- a/tools/perf/util/kvm-stat.h
+++ b/tools/perf/util/kvm-stat.h
@@ -99,6 +99,7 @@ struct perf_kvm_stat {
int timerfd;
unsigned int display_time;
bool live;
+   bool force;
 };
 
 struct kvm_reg_events_ops {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf kmem: Support using -f to override perf.data file ownership

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  d1eeb77c1811fd178442ccb8f58004a19ec40dd3
Gitweb: http://git.kernel.org/tip/d1eeb77c1811fd178442ccb8f58004a19ec40dd3
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:12 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:46 -0300

perf kmem: Support using -f to override perf.data file ownership

Enable perf kmem to use perf.data when it is not owned by current user
or root.

Example:

 # perf kmem record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw--- 1 Yunlong.Song Yunlong.Song 5315665 Apr  2 10:54 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf kmem stat
 File perf.data not owned by current user or root (use -f to override)
 # perf kmem stat -f
   Error: unknown switch `f'

  usage: perf kmem [] {record|stat}

 -i, --input input file name
 -v, --verbose be more verbose (show symbol address, etc)
 --caller  show per-callsite statistics
 --alloc   show per-allocation statistics
 -s, --sort 
   sort by keys: ptr, call_site, bytes, hit,
   pingpong, frag
 -l, --line   show n lines
 --raw-ip  show raw ip instead of symbol

As shown above, the -f option does not work at all.

After this patch:

 # perf kmem stat
 File perf.data not owned by current user or root (use -f to override)
 # perf kmem stat -f
 SUMMARY
 ===
 Total bytes requested: 437599
 Total bytes allocated: 615472
 Total bytes wasted on internal fragmentation: 177873
 Internal fragmentation: 28.900259%
 Cross CPU allocations: 6/1192

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1427982439-27388-4-git-send-email-yunlong.s...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kmem.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 64d3623..ac303ef 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -662,6 +662,10 @@ static int __cmd_record(int argc, const char **argv)
 int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 {
const char * const default_sort_order = "frag,hit,bytes";
+   struct perf_data_file file = {
+   .path = input_name,
+   .mode = PERF_DATA_MODE_READ,
+   };
const struct option kmem_options[] = {
OPT_STRING('i', "input", _name, "file", "input file name"),
OPT_INCR('v', "verbose", ,
@@ -675,6 +679,7 @@ int cmd_kmem(int argc, const char **argv, const char 
*prefix __maybe_unused)
 parse_sort_opt),
OPT_CALLBACK('l', "line", NULL, "num", "show n lines", parse_line_opt),
OPT_BOOLEAN(0, "raw-ip", _ip, "show raw ip instead of symbol"),
+   OPT_BOOLEAN('f', "force", , "don't complain, do it"),
OPT_END()
};
const char *const kmem_subcommands[] = { "record", "stat", NULL };
@@ -683,10 +688,6 @@ int cmd_kmem(int argc, const char **argv, const char 
*prefix __maybe_unused)
NULL
};
struct perf_session *session;
-   struct perf_data_file file = {
-   .path = input_name,
-   .mode = PERF_DATA_MODE_READ,
-   };
int ret = -1;
 
argc = parse_options_subcommand(argc, argv, kmem_options,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf probe: Fix to track down unnamed union/ structure members

2015-04-02 Thread tip-bot for Masami Hiramatsu
Commit-ID:  c72738355b2ac79506fbfa10ffee8fe3a27e69da
Gitweb: http://git.kernel.org/tip/c72738355b2ac79506fbfa10ffee8fe3a27e69da
Author: Masami Hiramatsu 
AuthorDate: Thu, 2 Apr 2015 16:33:12 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:44 -0300

perf probe: Fix to track down unnamed union/structure members

Fix 'perf probe' to track down unnamed union/structure members.

perf probe did not track down the tree of unnamed union/structure
members, since it just failed to find given "name" in a parent
structure/union.  To solve this issue, I've introduced 2 changes.

- Fix die_find_member() to track down the type-DIE if it is
  unnamed, and if it contains the specified member, returns the
  unnamed member.
  (note that we don't return found member, since unnamed member
   has the offset in the parent structure)
- Fix convert_variable_fields() to track down the unnamed union/
  structure (one-by-one).

With this patch, perf probe can access unnamed fields:
  -
  #./perf probe -nfx ./perf lock__delete ops 'locked_ops=ops->locked.ops'
  Added new event:
probe_perf:lock__delete (on lock__delete in 
/home/mhiramat/ksrc/linux-3/tools/perf/perf with ops locked_ops=ops->locked.ops)

  You can now use it in all perf tools, such as:

  perf record -e probe_perf:lock__delete -aR sleep 1
  -

Reported-by: Arnaldo Carvalho de Melo 
Report-Link: https://lkml.org/lkml/2015/3/5/431
Signed-off-by: Masami Hiramatsu 
Tested-by: Arnaldo Carvalho de Melo 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/20150402073312.14482.37942.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/dwarf-aux.c| 14 ++
 tools/perf/util/probe-finder.c |  8 +++-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 780b2bc..c34e024 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -801,10 +801,16 @@ static int __die_find_member_cb(Dwarf_Die *die_mem, void 
*data)
 {
const char *name = data;
 
-   if ((dwarf_tag(die_mem) == DW_TAG_member) &&
-   die_compare_name(die_mem, name))
-   return DIE_FIND_CB_END;
-
+   if (dwarf_tag(die_mem) == DW_TAG_member) {
+   if (die_compare_name(die_mem, name))
+   return DIE_FIND_CB_END;
+   else if (!dwarf_diename(die_mem)) { /* Unnamed structure */
+   Dwarf_Die type_die, tmp_die;
+   if (die_get_type(die_mem, _die) &&
+   die_find_member(_die, name, _die))
+   return DIE_FIND_CB_END;
+   }
+   }
return DIE_FIND_CB_SIBLING;
 }
 
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 46f009a..7831e2d 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -460,7 +460,8 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const 
char *varname,
   " nor array.\n", varname);
return -EINVAL;
}
-   if (field->ref) {
+   /* While prcessing unnamed field, we don't care about this */
+   if (field->ref && dwarf_diename(vr_die)) {
pr_err("Semantic error: %s must be referred by '.'\n",
   field->name);
return -EINVAL;
@@ -491,6 +492,11 @@ static int convert_variable_fields(Dwarf_Die *vr_die, 
const char *varname,
}
ref->offset += (long)offs;
 
+   /* If this member is unnamed, we need to reuse this field */
+   if (!dwarf_diename(die_mem))
+   return convert_variable_fields(die_mem, varname, field,
+   , die_mem);
+
 next:
/* Converting next field */
if (field->next)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf inject: Support using -f to override perf.data file ownership

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  ccaa474c8a0983d26ecb3eac755672b546b997c3
Gitweb: http://git.kernel.org/tip/ccaa474c8a0983d26ecb3eac755672b546b997c3
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:11 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:45 -0300

perf inject: Support using -f to override perf.data file ownership

Enable perf inject to use perf.data when it is not owned by current user
or root.

Example:

 # perf record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw--- 1 Yunlong.Song Yunlong.Song 28260 Apr  2 10:37 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf inject -v -b -i perf.data -o perf.data.new
 File perf.data not owned by current user or root (use -f to override)
 # perf inject -v -b -i perf.data -o perf.data.new -f
   Error: unknown switch `f'

  usage: perf inject []

 -b, --build-ids   Inject build-ids into the output stream
 -i, --input input file name
 -o, --outputoutput file name
 -s, --sched-stat  Merge sched-stat and sched-switch for getting
 events where and how long tasks slept
 -v, --verbose be more verbose (show build ids, etc)
 --kallsyms 
   kallsyms pathname

As shown above, the -f option does not work at all.

After this patch:

 # perf inject -v -b -i perf.data -o perf.data.new
 File perf.data not owned by current user or root (use -f to override)
 # perf inject -v -b -i perf.data -o perf.data.new -f
 build id event received for [kernel.kallsyms]:
 f6dcb66d8b98f1c0d9eb87bf043444b69f91d30c
 symsrc__init: cannot get elf header.
 Looking at the vmlinux_path (7 entries long)
 Using /proc/kcore for kernel object code
 Using /proc/kallsyms for symbols

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1427982439-27388-3-git-send-email-yunlong.s...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-inject.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index ea46df25..40a33d7 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -443,6 +443,7 @@ int cmd_inject(int argc, const char **argv, const char 
*prefix __maybe_unused)
 "be more verbose (show build ids, etc)"),
OPT_STRING(0, "kallsyms", _conf.kallsyms_name, "file",
   "kallsyms pathname"),
+   OPT_BOOLEAN('f', "force", , "don't complain, do it"),
OPT_END()
};
const char * const inject_usage[] = {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf evlist: Support using -f to override perf.data file ownership

2015-04-02 Thread tip-bot for Yunlong Song
Commit-ID:  9e3b6ec17374299516d83c2e36135b958a895aa3
Gitweb: http://git.kernel.org/tip/9e3b6ec17374299516d83c2e36135b958a895aa3
Author: Yunlong Song 
AuthorDate: Thu, 2 Apr 2015 21:47:10 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:45 -0300

perf evlist: Support using -f to override perf.data file ownership

Enable perf evlist to use perf.data when it is not owned by current user
or root.

Example:

 # perf record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw--- 1 Yunlong.Song Yunlong.Song 28260 Apr  2 10:18 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf evlist
 File perf.data not owned by current user or root (use -f to override)
 # perf evlist -f
   Error: unknown switch `f'

  usage: perf evlist []

 -i, --input Input file name
 -F, --freqShow the sample frequency
 -v, --verbose Show all event attr details
 -g, --group   Show event group information

As shown above, the -f option does not work at all.

After this patch:

 # perf evlist
 File perf.data not owned by current user or root (use -f to override)
 # perf evlist -f
 cycles

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1427982439-27388-2-git-send-email-yunlong.s...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-evlist.c | 2 ++
 tools/perf/util/evsel.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 0f93f85..695ec5a 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -24,6 +24,7 @@ static int __cmd_evlist(const char *file_name, struct 
perf_attr_details *details
struct perf_data_file file = {
.path = file_name,
.mode = PERF_DATA_MODE_READ,
+   .force = details->force,
};
 
session = perf_session__new(, 0, NULL);
@@ -47,6 +48,7 @@ int cmd_evlist(int argc, const char **argv, const char 
*prefix __maybe_unused)
"Show all event attr details"),
OPT_BOOLEAN('g', "group", _group,
"Show event group information"),
+   OPT_BOOLEAN('f', "force", , "don't complain, do it"),
OPT_END()
};
const char * const evlist_usage[] = {
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index dcf202a..c5a43d6 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -335,6 +335,7 @@ struct perf_attr_details {
bool freq;
bool verbose;
bool event_group;
+   bool force;
 };
 
 int perf_evsel__fprintf(struct perf_evsel *evsel,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf scripting: No need to pass thread twice to the scripting callbacks

2015-04-02 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  f9d5d549d2c2934be84b0bc7e5e034834459f591
Gitweb: http://git.kernel.org/tip/f9d5d549d2c2934be84b0bc7e5e034834459f591
Author: Arnaldo Carvalho de Melo 
AuthorDate: Wed, 1 Apr 2015 13:29:25 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:41 -0300

perf scripting: No need to pass thread twice to the scripting callbacks

It is already in the addr_location, so remove the redundant 'thread'
parameter from the callback signatures.

Acked-by: Jiri Olsa 
Acked-by: Namhyung Kim 
Cc: Adrian Hunter 
Cc: Borislav Petkov 
Cc: David Ahern 
Cc: Don Zickus 
Cc: Frederic Weisbecker 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/1427906210-10519-3-git-send-email-a...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-script.c|  6 +++---
 tools/perf/util/scripting-engines/trace-event-perl.c   |  5 ++---
 tools/perf/util/scripting-engines/trace-event-python.c | 13 +
 tools/perf/util/trace-event-scripting.c|  1 -
 tools/perf/util/trace-event.h  |  3 +--
 5 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c286b49..257dd06 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -446,9 +446,9 @@ static void print_sample_bts(union perf_event *event,
 }
 
 static void process_event(union perf_event *event, struct perf_sample *sample,
- struct perf_evsel *evsel, struct thread *thread,
- struct addr_location *al)
+ struct perf_evsel *evsel, struct addr_location *al)
 {
+   struct thread *thread = al->thread;
struct perf_event_attr *attr = >attr;
 
if (output[attr->type].fields == 0)
@@ -573,7 +573,7 @@ static int process_sample_event(struct perf_tool *tool 
__maybe_unused,
if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
return 0;
 
-   scripting_ops->process_event(event, sample, evsel, al.thread, );
+   scripting_ops->process_event(event, sample, evsel, );
 
return 0;
 }
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c 
b/tools/perf/util/scripting-engines/trace-event-perl.c
index 8171fed..430b5d2 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -360,10 +360,9 @@ static void perl_process_event_generic(union perf_event 
*event,
 static void perl_process_event(union perf_event *event,
   struct perf_sample *sample,
   struct perf_evsel *evsel,
-  struct thread *thread,
-  struct addr_location *al __maybe_unused)
+  struct addr_location *al)
 {
-   perl_process_tracepoint(sample, evsel, thread);
+   perl_process_tracepoint(sample, evsel, al->thread);
perl_process_event_generic(event, sample, evsel);
 }
 
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c 
b/tools/perf/util/scripting-engines/trace-event-python.c
index 2ec5dfb..de8df1d 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -381,7 +381,6 @@ exit:
 
 static void python_process_tracepoint(struct perf_sample *sample,
  struct perf_evsel *evsel,
- struct thread *thread,
  struct addr_location *al)
 {
struct event_format *event = evsel->tp_format;
@@ -395,7 +394,7 @@ static void python_process_tracepoint(struct perf_sample 
*sample,
int cpu = sample->cpu;
void *data = sample->raw_data;
unsigned long long nsecs = sample->time;
-   const char *comm = thread__comm_str(thread);
+   const char *comm = thread__comm_str(al->thread);
 
t = PyTuple_New(MAX_FIELDS);
if (!t)
@@ -766,7 +765,6 @@ static int python_process_call_return(struct call_return 
*cr, void *data)
 
 static void python_process_general_event(struct perf_sample *sample,
 struct perf_evsel *evsel,
-struct thread *thread,
 struct addr_location *al)
 {
PyObject *handler, *t, *dict, *callchain, *dict_sample;
@@ -816,7 +814,7 @@ static void python_process_general_event(struct perf_sample 
*sample,
pydict_set_item_string_decref(dict, "raw_buf", 
PyString_FromStringAndSize(
(const char *)sample->raw_data, sample->raw_size));
pydict_set_item_string_decref(dict, "comm",
-   PyString_FromString(thread__comm_str(thread)));
+   PyString_FromString(thread__comm_str(al->thread)));
if (al->map) {

[tip:perf/core] perf db-export: No need to have -> thread twice in struct export_sample

2015-04-02 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  b83e868d0a0350c107b98417b4dcc73834506f98
Gitweb: http://git.kernel.org/tip/b83e868d0a0350c107b98417b4dcc73834506f98
Author: Arnaldo Carvalho de Melo 
AuthorDate: Thu, 2 Apr 2015 11:16:05 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:43 -0300

perf db-export: No need to have ->thread twice in struct export_sample

As it comes from address_location->thread, that is already stored as
export_sample->al, where the thread can be obtained.

Cc: Adrian Hunter 
Cc: Borislav Petkov 
Cc: David Ahern 
Cc: Don Zickus 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/20150402141542.ga9...@kernel.org
Link: http://lkml.kernel.org/n/tip-bzotbl4epoztw0jd6sm2s...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/db-export.c| 1 -
 tools/perf/util/db-export.h| 1 -
 tools/perf/util/scripting-engines/trace-event-python.c | 2 +-
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index 5499887..bb39a3f 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -289,7 +289,6 @@ int db_export__sample(struct db_export *dbe, union 
perf_event *event,
.event = event,
.sample = sample,
.evsel = evsel,
-   .thread = thread,
.al = al,
};
struct thread *main_thread;
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index b9faa13..25e22fd 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -34,7 +34,6 @@ struct export_sample {
union perf_event*event;
struct perf_sample  *sample;
struct perf_evsel   *evsel;
-   struct thread   *thread;
struct addr_location*al;
u64 db_id;
u64 comm_db_id;
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c 
b/tools/perf/util/scripting-engines/trace-event-python.c
index 1d3cc1b..5544b8c 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -679,7 +679,7 @@ static int python_export_sample(struct db_export *dbe,
tuple_set_u64(t, 0, es->db_id);
tuple_set_u64(t, 1, es->evsel->db_id);
tuple_set_u64(t, 2, es->al->machine->db_id);
-   tuple_set_u64(t, 3, es->thread->db_id);
+   tuple_set_u64(t, 3, es->al->thread->db_id);
tuple_set_u64(t, 4, es->comm_db_id);
tuple_set_u64(t, 5, es->dso_db_id);
tuple_set_u64(t, 6, es->sym_db_id);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf script: No need to lookup thread twice

2015-04-02 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  79628f2cfe0f488b23e5dc99a4a9a599032fa653
Gitweb: http://git.kernel.org/tip/79628f2cfe0f488b23e5dc99a4a9a599032fa653
Author: Arnaldo Carvalho de Melo 
AuthorDate: Wed, 1 Apr 2015 13:26:45 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:21 -0300

perf script: No need to lookup thread twice

We get the thread when we call perf_event__preprocess_sample(), no need
to do it before that.

Acked-by: Jiri Olsa 
Acked-by: Namhyung Kim 
Cc: Adrian Hunter 
Cc: Borislav Petkov 
Cc: David Ahern 
Cc: Don Zickus 
Cc: Frederic Weisbecker 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/1427906210-10519-2-git-send-email-a...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-script.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 662366c..c286b49 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -549,14 +549,6 @@ static int process_sample_event(struct perf_tool *tool 
__maybe_unused,
struct machine *machine)
 {
struct addr_location al;
-   struct thread *thread = machine__findnew_thread(machine, sample->pid,
-   sample->tid);
-
-   if (thread == NULL) {
-   pr_debug("problem processing %d event, skipping it.\n",
-event->header.type);
-   return -1;
-   }
 
if (debug_mode) {
if (sample->time < last_timestamp) {
@@ -581,7 +573,7 @@ static int process_sample_event(struct perf_tool *tool 
__maybe_unused,
if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
return 0;
 
-   scripting_ops->process_event(event, sample, evsel, thread, );
+   scripting_ops->process_event(event, sample, evsel, al.thread, );
 
return 0;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf db-export: No need to pass thread twice to db_export__sample

2015-04-02 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  7327259d7ea96d04d02e7dbe51ee9201319dc204
Gitweb: http://git.kernel.org/tip/7327259d7ea96d04d02e7dbe51ee9201319dc204
Author: Arnaldo Carvalho de Melo 
AuthorDate: Thu, 2 Apr 2015 11:08:30 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 2 Apr 2015 13:18:42 -0300

perf db-export: No need to pass thread twice to db_export__sample

As it is available via another parameter, address_location->thread.

Acked-by: Adrian Hunter 
Cc: Borislav Petkov 
Cc: David Ahern 
Cc: Don Zickus 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Stephane Eranian 
Link: lkml.kernel.org/r/551d08f8.3040...@intel.com
Link: http://lkml.kernel.org/n/tip-6dbn0tcm9hyv92g7h3zj2...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/db-export.c| 3 ++-
 tools/perf/util/db-export.h| 2 +-
 tools/perf/util/scripting-engines/trace-event-python.c | 3 +--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index c81dae3..5499887 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -282,8 +282,9 @@ int db_export__branch_type(struct db_export *dbe, u32 
branch_type,
 
 int db_export__sample(struct db_export *dbe, union perf_event *event,
  struct perf_sample *sample, struct perf_evsel *evsel,
- struct thread *thread, struct addr_location *al)
+ struct addr_location *al)
 {
+   struct thread* thread = al->thread;
struct export_sample es = {
.event = event,
.sample = sample,
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index adbd22d..b9faa13 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -97,7 +97,7 @@ int db_export__branch_type(struct db_export *dbe, u32 
branch_type,
   const char *name);
 int db_export__sample(struct db_export *dbe, union perf_event *event,
  struct perf_sample *sample, struct perf_evsel *evsel,
- struct thread *thread, struct addr_location *al);
+ struct addr_location *al);
 
 int db_export__branch_types(struct db_export *dbe);
 
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c 
b/tools/perf/util/scripting-engines/trace-event-python.c
index de8df1d..1d3cc1b 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -852,8 +852,7 @@ static void python_process_event(union perf_event *event,
/* Reserve for future process_hw/sw/raw APIs */
default:
if (tables->db_export_mode)
-   db_export__sample(>dbe, event, sample, evsel,
- al->thread, al);
+   db_export__sample(>dbe, event, sample, evsel, 
al);
else
python_process_general_event(sample, evsel, al);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [tip:x86/asm] x86: Add support for the clwb instruction

2015-04-02 Thread Ingo Molnar

* Ross Zwisler  wrote:

> On Wed, 2015-02-18 at 16:29 -0800, tip-bot for Ross Zwisler wrote:
> > Commit-ID:  3b68983dc66c61da3ab4191b891084a7ab09e3e1
> > Gitweb: 
> > http://git.kernel.org/tip/3b68983dc66c61da3ab4191b891084a7ab09e3e1
> > Author: Ross Zwisler 
> > AuthorDate: Tue, 27 Jan 2015 09:53:51 -0700
> > Committer:  Ingo Molnar 
> > CommitDate: Thu, 19 Feb 2015 00:06:38 +0100
> > 
> > x86: Add support for the clwb instruction
> > 
> > Add support for the new clwb (cache line write back)
> > instruction.  This instruction was announced in the document
> > "Intel Architecture Instruction Set Extensions Programming
> > Reference" with reference number 319433-022.
> > 
> > https://software.intel.com/sites/default/files/managed/0d/53/319433-022.pdf
> > 
> > The clwb instruction is used to write back the contents of
> > dirtied cache lines to memory without evicting the cache lines
> > from the processor's cache hierarchy.  This should be used in
> > favor of clflushopt or clflush in cases where you require the
> > cache line to be written to memory but plan to access the data
> > again in the near future.
> > 
> > One of the main use cases for this is with persistent memory
> > where clwb can be used with pcommit to ensure that data has been
> > accepted to memory and is durable on the DIMM.
> > 
> > This function shows how to properly use clwb/clflushopt/clflush
> > and pcommit with appropriate fencing:
> > 
> > void flush_and_commit_buffer(void *vaddr, unsigned int size)
> > {
> > void *vend = vaddr + size - 1;
> > 
> > for (; vaddr < vend; vaddr += boot_cpu_data.x86_clflush_size)
> > clwb(vaddr);
> > 
> > /* Flush any possible final partial cacheline */
> > clwb(vend);
> > 
> > /*
> >  * sfence to order clwb/clflushopt/clflush cache flushes
> >  * mfence via mb() also works
> >  */
> > wmb();
> > 
> > /* pcommit and the required sfence for ordering */
> > pcommit_sfence();
> > }
> > 
> > After this function completes the data pointed to by vaddr is
> > has been accepted to memory and will be durable if the vaddr
> > points to persistent memory.
> > 
> > Regarding the details of how the alternatives assembly is set
> > up, we need one additional byte at the beginning of the clflush
> > so that we can flip it into a clflushopt by changing that byte
> > into a 0x66 prefix.  Two options are to either insert a 1 byte
> > ASM_NOP1, or to add a 1 byte NOP_DS_PREFIX.  Both have no
> > functional effect with the plain clflush, but I've been told
> > that executing a clflush + prefix should be faster than
> > executing a clflush + NOP.
> > 
> > We had to hard code the assembly for clwb because, lacking the
> > ability to assemble the clwb instruction itself, the next
> > closest thing is to have an xsaveopt instruction with a 0x66
> > prefix.  Unfortunately xsaveopt itself is also relatively new,
> > and isn't included by all the GCC versions that the kernel needs
> > to support.
> > 
> > Signed-off-by: Ross Zwisler 
> > Acked-by: Borislav Petkov 
> > Acked-by: H. Peter Anvin 
> > Cc: Linus Torvalds 
> > Cc: Thomas Gleixner 
> > Link: 
> > http://lkml.kernel.org/r/1422377631-8986-3-git-send-email-ross.zwis...@linux.intel.com
> > Signed-off-by: Ingo Molnar 
> 
> Ping on this patch - it looks like the pcommit patch is in the tip tree,
> but this one is missing?

Yeah, I applied it initially, then had some reservations about it - 
but those are now resolved so I've applied it to tip:x86/asm again.

Thanks,

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


[PATCH 3/7] ARM: socfpga: dts: enable UART1 for the debug uart

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

Arria10 devkit is using UART1 for the debug uart port.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/boot/dts/socfpga_arria10_socdk.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/socfpga_arria10_socdk.dts 
b/arch/arm/boot/dts/socfpga_arria10_socdk.dts
index 3015ce8..addec61 100755
--- a/arch/arm/boot/dts/socfpga_arria10_socdk.dts
+++ b/arch/arm/boot/dts/socfpga_arria10_socdk.dts
@@ -41,7 +41,7 @@
};
};
 
-   serial0@ffc02000 {
+   serial1@ffc02100 {
status = "okay";
};
};
-- 
2.2.1

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


[PATCH 0/3] clk: socfpga: Add clock driver for Arria10

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

Hi,

This patch series add the clock driver for the Arria10 platform. Although the
Arria10 SoC's clock framework has some similarities the Cyclone/Arria 5, the
differences are enough to warrant it's own driver, rather than polluting the
existing driver with platform lookups.

Dinh Nguyen (3):
  clk: socfpga: update clk.h so for Arria10 platform to use
  clk: socfpga: add a clock driver for the Arria 10 platform
  ARM: socfpga: dts: add clocks to the Arria10 platform

 arch/arm/boot/dts/socfpga_arria10.dtsi | 298 -
 drivers/clk/socfpga/Makefile   |   1 +
 drivers/clk/socfpga/clk-gate-a10.c | 187 +
 drivers/clk/socfpga/clk-gate.c |   4 -
 drivers/clk/socfpga/clk-periph-a10.c   | 131 +++
 drivers/clk/socfpga/clk-pll-a10.c  | 132 +++
 drivers/clk/socfpga/clk.c  |   7 +-
 drivers/clk/socfpga/clk.h  |  10 +-
 8 files changed, 760 insertions(+), 10 deletions(-)
 create mode 100644 drivers/clk/socfpga/clk-gate-a10.c
 create mode 100644 drivers/clk/socfpga/clk-periph-a10.c
 create mode 100644 drivers/clk/socfpga/clk-pll-a10.c

-- 
2.2.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: [GIT PULL 00/15] perf/core improvements and fixes

2015-04-02 Thread Ingo Molnar

* Arnaldo Carvalho de Melo  wrote:

> Hi Ingo,
> 
>   Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit e1abf2cc8d5d80b41c4419368ec743ccadbb131e:
> 
>   bpf: Fix the build on BPF_SYSCALL=y && !CONFIG_TRACING kernels, make it 
> more configurable (2015-04-02 16:28:06 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
> tags/perf-core-for-mingo
> 
> for you to fetch changes up to bd05954bfa17f03a7bd4454178ba09786b35e383:
> 
>   perf data: Support using -f to override perf.data file ownership for 
> 'convert' (2015-04-02 13:18:52 -0300)
> 
> 
> perf/core improvements and fixes:
> 
> User visible:
> 
> - Support unnamed union/structure members data collection in 'perf probe' 
> (Masami Hiramatsu)
> 
> - Support missing -f to override perf.data file ownership (Yunlong Song)
> 
> Infrastructure:
> 
> - No need to lookup thread twice when processing samples in 'perf script' 
> (Arnaldo Carvalho de Melo)
> 
> - No need to pass thread twice to the scripting callbacks (Arnaldo Carvalho 
> de Melo)
> 
> - No need to pass thread twice to the db-export facility (Arnaldo Carvalho de 
> Melo)
> 
> Signed-off-by: Arnaldo Carvalho de Melo 
> 
> 
> Arnaldo Carvalho de Melo (4):
>   perf script: No need to lookup thread twice
>   perf scripting: No need to pass thread twice to the scripting callbacks
>   perf db-export: No need to pass thread twice to db_export__sample
>   perf db-export: No need to have ->thread twice in struct export_sample
> 
> Masami Hiramatsu (1):
>   perf probe: Fix to track down unnamed union/structure members
> 
> Yunlong Song (10):
>   perf evlist: Support using -f to override perf.data file ownership
>   perf inject: Support using -f to override perf.data file ownership
>   perf kmem: Support using -f to override perf.data file ownership
>   perf kvm: Support using -f to override perf.data.guest file ownership
>   perf lock: Support using -f to override perf.data file ownership
>   perf mem: Support using -f to override perf.data file ownership
>   perf script: Support using -f to override perf.data file ownership
>   perf timechart: Support using -f to override perf.data file ownership
>   perf trace: Support using -f to override perf.data file ownership
>   perf data: Support using -f to override perf.data file ownership for 
> 'convert'
> 
>  tools/perf/builtin-data.c  |  4 +++-
>  tools/perf/builtin-evlist.c|  2 ++
>  tools/perf/builtin-inject.c|  1 +
>  tools/perf/builtin-kmem.c  |  9 +
>  tools/perf/builtin-kvm.c   |  2 ++
>  tools/perf/builtin-lock.c  |  5 +
>  tools/perf/builtin-mem.c   |  3 +++
>  tools/perf/builtin-script.c| 23 
> --
>  tools/perf/builtin-timechart.c |  3 +++
>  tools/perf/builtin-trace.c |  3 +++
>  tools/perf/util/data-convert-bt.c  |  3 ++-
>  tools/perf/util/data-convert-bt.h  |  2 +-
>  tools/perf/util/db-export.c|  4 ++--
>  tools/perf/util/db-export.h|  3 +--
>  tools/perf/util/dwarf-aux.c| 14 +
>  tools/perf/util/evsel.h|  1 +
>  tools/perf/util/kvm-stat.h |  1 +
>  tools/perf/util/probe-finder.c |  8 +++-
>  .../perf/util/scripting-engines/trace-event-perl.c |  5 ++---
>  .../util/scripting-engines/trace-event-python.c| 16 ++-
>  tools/perf/util/trace-event-scripting.c|  1 -
>  tools/perf/util/trace-event.h  |  3 +--
>  22 files changed, 69 insertions(+), 47 deletions(-)

Pulled, thanks a lot Arnaldo!

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


[PATCH 0/7] ARM: socfpga: Add support for Arria10 devkit

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

Hi,

This patchset enables and tidy up support for the Arria10 devkit. Along with
this patchset and the patch for enabling clocks on the Arria10, the devkit
can boot Linux.

Dinh Nguyen (7):
  ARM: socfpga: add cpu1-start-addr for Arria 10
  ARM: socfpga: disable the sdmmc, and uart nodes in the base arria10
  ARM: socfpga: dts: enable UART1 for the debug uart
  ARM: socfpga: rename socdk board file to socdk_sdmmc
  ARM: socfpga: Add support for UART1 debug uart for earlyprintk
  ARM: socfpga: remove the need to map uart_io_desc
  Documentation: DT bindings: add doc for Altera's SoCFPGA platform

 Documentation/devicetree/bindings/arm/altera.txt   | 14 
 arch/arm/Kconfig.debug | 25 +++--
 arch/arm/boot/dts/Makefile |  2 +-
 arch/arm/boot/dts/socfpga_arria10.dtsi |  4 
 ...rria10_socdk.dts => socfpga_arria10_socdk.dtsi} |  6 ++---
 arch/arm/boot/dts/socfpga_arria10_socdk_sdmmc.dts  | 26 ++
 arch/arm/mach-socfpga/socfpga.c|  9 
 7 files changed, 65 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/altera.txt
 rename arch/arm/boot/dts/{socfpga_arria10_socdk.dts => 
socfpga_arria10_socdk.dtsi} (92%)
 mode change 100755 => 100644
 create mode 100644 arch/arm/boot/dts/socfpga_arria10_socdk_sdmmc.dts

-- 
2.2.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 7/7] Documentation: DT bindings: add doc for Altera's SoCFPGA platform

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

Document "altr,socfpga-cyclone5", "altr,socfpga-arria5", and
"altr,socfpga-arria10".

Signed-off-by: Dinh Nguyen 
---
 Documentation/devicetree/bindings/arm/altera.txt | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/altera.txt

diff --git a/Documentation/devicetree/bindings/arm/altera.txt 
b/Documentation/devicetree/bindings/arm/altera.txt
new file mode 100644
index 000..558735a
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/altera.txt
@@ -0,0 +1,14 @@
+Altera's SoCFPGA platform device tree bindings
+-
+
+Boards with Cyclone 5 SoC:
+Required root node properties:
+compatible = "altr,socfpga-cyclone5", "altr,socfpga";
+
+Boards with Arria 5 SoC:
+Required root node properties:
+compatible = "altr,socfpga-arria5", "altr,socfpga";
+
+Boards with Arria 10 SoC:
+Required root node properties:
+compatible = "altr,socfpga-arria10", "altr,socfpga";
-- 
2.2.1

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


[PATCH 2/3] clk: socfpga: add a clock driver for the Arria 10 platform

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

The clocks on the Arria 10 platform is a bit different than the Cyclone/Arria 5
platform that it should just have it's own driver.

Signed-off-by: Dinh Nguyen 
---
 drivers/clk/socfpga/Makefile |   1 +
 drivers/clk/socfpga/clk-gate-a10.c   | 187 +++
 drivers/clk/socfpga/clk-periph-a10.c | 131 
 drivers/clk/socfpga/clk-pll-a10.c| 132 +
 drivers/clk/socfpga/clk.c|   7 +-
 drivers/clk/socfpga/clk.h|   4 +
 6 files changed, 461 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/socfpga/clk-gate-a10.c
 create mode 100644 drivers/clk/socfpga/clk-periph-a10.c
 create mode 100644 drivers/clk/socfpga/clk-pll-a10.c

diff --git a/drivers/clk/socfpga/Makefile b/drivers/clk/socfpga/Makefile
index 7e2d15a..d8bb239 100644
--- a/drivers/clk/socfpga/Makefile
+++ b/drivers/clk/socfpga/Makefile
@@ -2,3 +2,4 @@ obj-y += clk.o
 obj-y += clk-gate.o
 obj-y += clk-pll.o
 obj-y += clk-periph.o
+obj-y += clk-pll-a10.o clk-periph-a10.o clk-gate-a10.o
diff --git a/drivers/clk/socfpga/clk-gate-a10.c 
b/drivers/clk/socfpga/clk-gate-a10.c
new file mode 100644
index 000..7329657
--- /dev/null
+++ b/drivers/clk/socfpga/clk-gate-a10.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2015 Altera Corporation. All rights reserved
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "clk.h"
+
+#define streq(a, b) (strcmp((a), (b)) == 0)
+
+#define to_socfpga_gate_clk(p) container_of(p, struct socfpga_gate_clk, hw.hw)
+
+/* SDMMC Group for System Manager defines */
+#define SYSMGR_SDMMCGRP_CTRL_OFFSET0x28
+
+static unsigned long socfpga_gate_clk_recalc_rate(struct clk_hw *hwclk,
+   unsigned long parent_rate)
+{
+   struct socfpga_gate_clk *socfpgaclk = to_socfpga_gate_clk(hwclk);
+   u32 div = 1, val;
+
+   if (socfpgaclk->fixed_div)
+   div = socfpgaclk->fixed_div;
+   else if (socfpgaclk->div_reg) {
+   val = readl(socfpgaclk->div_reg) >> socfpgaclk->shift;
+   val &= div_mask(socfpgaclk->width);
+   div = (1 << val);
+   }
+
+   return parent_rate / div;
+}
+
+static int socfpga_clk_prepare(struct clk_hw *hwclk)
+{
+   struct socfpga_gate_clk *socfpgaclk = to_socfpga_gate_clk(hwclk);
+   struct regmap *sys_mgr_base_addr;
+   int i;
+   u32 hs_timing;
+   u32 clk_phase[2];
+
+   if (socfpgaclk->clk_phase[0] || socfpgaclk->clk_phase[1]) {
+   sys_mgr_base_addr = 
syscon_regmap_lookup_by_compatible("altr,sys-mgr");
+   if (IS_ERR(sys_mgr_base_addr)) {
+   pr_err("%s: failed to find altr,sys-mgr regmap!\n", 
__func__);
+   return -EINVAL;
+   }
+
+   for (i = 0; i < 2; i++) {
+   switch (socfpgaclk->clk_phase[i]) {
+   case 0:
+   clk_phase[i] = 0;
+   break;
+   case 45:
+   clk_phase[i] = 1;
+   break;
+   case 90:
+   clk_phase[i] = 2;
+   break;
+   case 135:
+   clk_phase[i] = 3;
+   break;
+   case 180:
+   clk_phase[i] = 4;
+   break;
+   case 225:
+   clk_phase[i] = 5;
+   break;
+   case 270:
+   clk_phase[i] = 6;
+   break;
+   case 315:
+   clk_phase[i] = 7;
+   break;
+   default:
+   clk_phase[i] = 0;
+   break;
+   }
+   }
+
+   hs_timing = SYSMGR_SDMMC_CTRL_SET(clk_phase[0], clk_phase[1]);
+   regmap_write(sys_mgr_base_addr, SYSMGR_SDMMCGRP_CTRL_OFFSET,
+hs_timing);
+   }
+   return 0;
+}
+
+static struct clk_ops gateclk_ops = {
+   .prepare = socfpga_clk_prepare,
+   

[PATCH 4/7] ARM: socfpga: rename socdk board file to socdk_sdmmc

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

Rename the socfpga_arria10_socdk board file to socfpga_arria10_socdk_sdmmc
as Arria 10 devkit cannot support SDMMC and QSPI at the same time. Thus
we will need to have 2 separate board files, one for SDMMC and one for
QSPI. We also add a new base board dtsi file, socfpga_arria10_socdk.dtsi
so that we use common peripherals for each flavor of the devkits.

Add the sdmmc node to the socfpga_arria10_socdk_sdmmc.dts board file.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/boot/dts/Makefile |  2 +-
 ...rria10_socdk.dts => socfpga_arria10_socdk.dtsi} |  4 +---
 arch/arm/boot/dts/socfpga_arria10_socdk_sdmmc.dts  | 26 ++
 3 files changed, 28 insertions(+), 4 deletions(-)
 rename arch/arm/boot/dts/{socfpga_arria10_socdk.dts => 
socfpga_arria10_socdk.dtsi} (94%)
 mode change 100755 => 100644
 create mode 100644 arch/arm/boot/dts/socfpga_arria10_socdk_sdmmc.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index a1c776b..e50441a 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -485,7 +485,7 @@ dtb-$(CONFIG_ARCH_SHMOBILE_MULTI) += \
r8a7794-alt.dtb
 dtb-$(CONFIG_ARCH_SOCFPGA) += \
socfpga_arria5_socdk.dtb \
-   socfpga_arria10_socdk.dtb \
+   socfpga_arria10_socdk_sdmmc.dtb \
socfpga_cyclone5_socdk.dtb \
socfpga_cyclone5_sockit.dtb \
socfpga_cyclone5_socrates.dtb \
diff --git a/arch/arm/boot/dts/socfpga_arria10_socdk.dts 
b/arch/arm/boot/dts/socfpga_arria10_socdk.dtsi
old mode 100755
new mode 100644
similarity index 94%
rename from arch/arm/boot/dts/socfpga_arria10_socdk.dts
rename to arch/arm/boot/dts/socfpga_arria10_socdk.dtsi
index addec61..2791f09
--- a/arch/arm/boot/dts/socfpga_arria10_socdk.dts
+++ b/arch/arm/boot/dts/socfpga_arria10_socdk.dtsi
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Altera Corporation 
+ * Copyright (C) 2015 Altera Corporation 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,8 +14,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see .
  */
-
-/dts-v1/;
 #include "socfpga_arria10.dtsi"
 
 / {
diff --git a/arch/arm/boot/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/boot/dts/socfpga_arria10_socdk_sdmmc.dts
new file mode 100644
index 000..dbbb751
--- /dev/null
+++ b/arch/arm/boot/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014-2015 Altera Corporation 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+/dts-v1/;
+#include "socfpga_arria10_socdk.dtsi"
+
+ {
+   status = "okay";
+   num-slots = <1>;
+   broken-cd;
+   bus-width = <4>;
+};
-- 
2.2.1

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


[PATCH 1/3] clk: socfpga: update clk.h so for Arria10 platform to use

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

There are 5 possible parent clocks for the SoCFPGA Arria10. Move the define
SYSMGR_SDMMC_CTRL_SET and streq() to clk.h so that the Arria clock driver
can use.

Signed-off-by: Dinh Nguyen 
---
 drivers/clk/socfpga/clk-gate.c | 4 
 drivers/clk/socfpga/clk.h  | 6 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
index dd3a78c..607ab35 100644
--- a/drivers/clk/socfpga/clk-gate.c
+++ b/drivers/clk/socfpga/clk-gate.c
@@ -32,14 +32,10 @@
 #define SOCFPGA_MMC_CLK"sdmmc_clk"
 #define SOCFPGA_GPIO_DB_CLK_OFFSET 0xA8
 
-#define streq(a, b) (strcmp((a), (b)) == 0)
-
 #define to_socfpga_gate_clk(p) container_of(p, struct socfpga_gate_clk, hw.hw)
 
 /* SDMMC Group for System Manager defines */
 #define SYSMGR_SDMMCGRP_CTRL_OFFSET0x108
-#define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \
-   smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0))
 
 static u8 socfpga_clk_get_parent(struct clk_hw *hwclk)
 {
diff --git a/drivers/clk/socfpga/clk.h b/drivers/clk/socfpga/clk.h
index d291f60..b09a5d5 100644
--- a/drivers/clk/socfpga/clk.h
+++ b/drivers/clk/socfpga/clk.h
@@ -26,9 +26,13 @@
 #define CLKMGR_L4SRC   0x70
 #define CLKMGR_PERPLL_SRC  0xAC
 
-#define SOCFPGA_MAX_PARENTS3
+#define SOCFPGA_MAX_PARENTS5
 #define div_mask(width) ((1 << (width)) - 1)
 
+#define streq(a, b) (strcmp((a), (b)) == 0)
+#define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \
+   smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0))
+
 extern void __iomem *clk_mgr_base_addr;
 
 void __init socfpga_pll_init(struct device_node *node);
-- 
2.2.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 6/7] ARM: socfpga: remove the need to map uart_io_desc

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

All the necessary debug uart mapping is already being done in
debug_ll_io_init, there's no need for it here.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/mach-socfpga/socfpga.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
index f5e597c..358f2c7 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -39,13 +39,6 @@ static struct map_desc scu_io_desc __initdata = {
.type   = MT_DEVICE,
 };
 
-static struct map_desc uart_io_desc __initdata = {
-   .virtual= 0xfec02000,
-   .pfn= __phys_to_pfn(0xffc02000),
-   .length = SZ_8K,
-   .type   = MT_DEVICE,
-};
-
 static void __init socfpga_scu_map_io(void)
 {
unsigned long base;
@@ -60,8 +53,6 @@ static void __init socfpga_scu_map_io(void)
 static void __init socfpga_map_io(void)
 {
socfpga_scu_map_io();
-   iotable_init(_io_desc, 1);
-   early_printk("Early printk initialized\n");
 }
 
 void __init socfpga_sysmgr_init(void)
-- 
2.2.1

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


[PATCH 3/3] ARM: socfpga: dts: add clocks to the Arria10 platform

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

Add all the clock nodes for the Arria10 platform. At the same time, update
the peripherals with their respective clocks property.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/boot/dts/socfpga_arria10.dtsi | 298 -
 1 file changed, 294 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index 8a05c47..341cb28 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -98,6 +98,21 @@
#address-cells = <1>;
#size-cells = <0>;
 
+   cb_intosc_hs_div2_clk: 
cb_intosc_hs_div2_clk {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   };
+
+   cb_intosc_ls_clk: cb_intosc_ls_clk {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   };
+
+   f2s_free_clk: f2s_free_clk {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   };
+
osc1: osc1 {
#clock-cells = <0>;
compatible = "fixed-clock";
@@ -107,16 +122,279 @@
#address-cells = <1>;
#size-cells = <0>;
#clock-cells = <0>;
-   compatible = 
"altr,socfpga-pll-clock";
-   clocks = <>;
+   compatible = 
"altr,socfpga-a10-pll-clock";
+   clocks = <>, 
<_intosc_ls_clk>,
+<_free_clk>;
+   reg = <0x40>;
+
+   main_mpu_base_clk: 
main_mpu_base_clk {
+   #clock-cells = <0>;
+   compatible = 
"altr,socfpga-a10-perip-clk";
+   clocks = <_pll>;
+   div-reg = <0x140 0 11>;
+   };
+
+   main_noc_base_clk: 
main_noc_base_clk {
+   #clock-cells = <0>;
+   compatible = 
"altr,socfpga-a10-perip-clk";
+   clocks = <_pll>;
+   div-reg = <0x144 0 11>;
+   };
+
+   main_emaca_clk: main_emaca_clk {
+   #clock-cells = <0>;
+   compatible = 
"altr,socfpga-a10-perip-clk";
+   clocks = <_pll>;
+   reg = <0x68>;
+   };
+
+   main_emacb_clk: main_emacb_clk {
+   #clock-cells = <0>;
+   compatible = 
"altr,socfpga-a10-perip-clk";
+   clocks = <_pll>;
+   reg = <0x6C>;
+   };
+
+   main_emac_ptp_clk: 
main_emac_ptp_clk {
+   #clock-cells = <0>;
+   compatible = 
"altr,socfpga-a10-perip-clk";
+   clocks = <_pll>;
+   reg = <0x70>;
+   };
+
+   main_gpio_db_clk: 
main_gpio_db_clk {
+   #clock-cells = <0>;
+   compatible = 
"altr,socfpga-a10-perip-clk";
+   clocks = <_pll>;
+ 

[PATCH 5/7] ARM: socfpga: Add support for UART1 debug uart for earlyprintk

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

Add support for hardware uart1 for earlyprintk support on Arria10 devkit.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/Kconfig.debug | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 970de75..0e52b92 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -920,13 +920,22 @@ choice
  on SA-11x0 UART ports. The kernel will check for the first
  enabled UART in a sequence 3-1-2.
 
-   config DEBUG_SOCFPGA_UART
+   config DEBUG_SOCFPGA_UART0
depends on ARCH_SOCFPGA
-   bool "Use SOCFPGA UART for low-level debug"
+   bool "Use SOCFPGA UART0 for low-level debug"
select DEBUG_UART_8250
help
  Say Y here if you want kernel low-level debugging support
- on SOCFPGA based platforms.
+ on SOCFPGA(Cyclone 5 and Arria 5) based platforms.
+
+   config DEBUG_SOCFPGA_UART1
+   depends on ARCH_SOCFPGA
+   bool "Use SOCFPGA UART1 for low-level debug"
+   select DEBUG_UART_8250
+   help
+ Say Y here if you want kernel low-level debugging support
+ on SOCFPGA(Arria 10) based platforms.
+
 
config DEBUG_SUN9I_UART0
bool "Kernel low-level debugging messages via sun9i UART0"
@@ -1419,7 +1428,8 @@ config DEBUG_UART_PHYS
default 0xfcb0 if DEBUG_HI3620_UART
default 0xfe80 if ARCH_IOP32X
default 0xff69 if DEBUG_RK32_UART2
-   default 0xffc02000 if DEBUG_SOCFPGA_UART
+   default 0xffc02000 if DEBUG_SOCFPGA_UART0
+   default 0xffc02100 if DEBUG_SOCFPGA_UART1
default 0xffd82340 if ARCH_IOP13XX
default 0xffe4 if DEBUG_RCAR_GEN1_SCIF0
default 0xffe42000 if DEBUG_RCAR_GEN1_SCIF2
@@ -1497,7 +1507,8 @@ config DEBUG_UART_VIRT
default 0xfeb26000 if DEBUG_RK3X_UART1
default 0xfeb30c00 if DEBUG_KEYSTONE_UART0
default 0xfeb31000 if DEBUG_KEYSTONE_UART1
-   default 0xfec02000 if DEBUG_SOCFPGA_UART
+   default 0xfec02000 if DEBUG_SOCFPGA_UART0
+   default 0xfec02100 if DEBUG_SOCFPGA_UART1
default 0xfec12000 if DEBUG_MVEBU_UART0 || DEBUG_MVEBU_UART0_ALTERNATE
default 0xfec12100 if DEBUG_MVEBU_UART1_ALTERNATE
default 0xfec1 if DEBUG_SIRFATLAS7_UART0
@@ -1542,8 +1553,8 @@ config DEBUG_UART_8250_WORD
bool "Use 32-bit accesses for 8250 UART"
depends on DEBUG_LL_UART_8250 || DEBUG_UART_8250
depends on DEBUG_UART_8250_SHIFT >= 2
-   default y if DEBUG_PICOXCELL_UART || DEBUG_SOCFPGA_UART || \
-   ARCH_KEYSTONE || \
+   default y if DEBUG_PICOXCELL_UART || DEBUG_SOCFPGA_UART0 || \
+   DEBUG_SOCFPGA_UART1 || ARCH_KEYSTONE || \
DEBUG_DAVINCI_DMx_UART0 || DEBUG_DAVINCI_DA8XX_UART1 || \
DEBUG_DAVINCI_DA8XX_UART2 || \
DEBUG_BCM_KONA_UART || DEBUG_RK32_UART2 || \
-- 
2.2.1

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


[PATCH 2/7] ARM: socfpga: disable the sdmmc, and uart nodes in the base arria10

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

Add status = "disabled" in the base DTSI for Arria10.  The SDMMC and uart
nodes should be enabled in the appropriate board file.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/boot/dts/socfpga_arria10.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index 69d616a..d843609 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -268,6 +268,7 @@
reg = <0xff808000 0x1000>;
interrupts = <0 98 IRQ_TYPE_LEVEL_HIGH>;
fifo-depth = <0x400>;
+   status = "disabled";
};
 
ocram: sram@ffe0 {
@@ -324,6 +325,7 @@
interrupts = <0 110 IRQ_TYPE_LEVEL_HIGH>;
reg-shift = <2>;
reg-io-width = <4>;
+   status = "disabled";
};
 
uart1: serial1@ffc02100 {
@@ -332,6 +334,7 @@
interrupts = <0 111 IRQ_TYPE_LEVEL_HIGH>;
reg-shift = <2>;
reg-io-width = <4>;
+   status = "disabled";
};
 
usbphy0: usbphy@0 {
-- 
2.2.1

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


[PATCH 1/7] ARM: socfpga: add cpu1-start-addr for Arria 10

2015-04-02 Thread dinguyen
From: Dinh Nguyen 

Signed-off-by: Dinh Nguyen 
---
 arch/arm/boot/dts/socfpga_arria10.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index 8a05c47..69d616a 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -284,6 +284,7 @@
sysmgr: sysmgr@ffd06000 {
compatible = "altr,sys-mgr", "syscon";
reg = <0xffd06000 0x300>;
+   cpu1-start-addr = <0xffd06230>;
};
 
/* Local timer */
-- 
2.2.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] kvm: mmu: lazy collapse small sptes into large sptes

2015-04-02 Thread Xiao Guangrong



On 03/30/2015 07:48 AM, Wanpeng Li wrote:

There are two scenarios for the requirement of collapsing small sptes
into large sptes.
- dirty logging tracks sptes in 4k granularity, so large sptes are splitted,
   the large sptes will be reallocated in the destination machine and the
   guest in the source machine will be destroyed when live migration 
successfully.
   However, the guest in the source machine will continue to run if live 
migration
   fail due to some reasons, the sptes still keep small which lead to bad
   performance.
- our customers write tools to track the dirty speed of guests by EPT D bit/PML
   in order to determine the most appropriate one to be live migrated, however
   sptes will still keep small after tracking dirty speed.

This patch introduce lazy collapse small sptes into large sptes, the memory 
region
will be scanned on the ioctl context when dirty log is stopped, the ones which 
can
be collapsed into large pages will be dropped during the scan, it depends the on
later #PF to reallocate all large sptes.

Signed-off-by: Wanpeng Li 
---
  arch/x86/include/asm/kvm_host.h |  2 ++
  arch/x86/kvm/mmu.c  | 66 +
  arch/x86/kvm/x86.c  |  5 
  3 files changed, 73 insertions(+)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index a236e39..73de5d3 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -859,6 +859,8 @@ void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask,
  void kvm_mmu_reset_context(struct kvm_vcpu *vcpu);
  void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
  struct kvm_memory_slot *memslot);
+void kvm_mmu_zap_collapsible_sptes(struct kvm *kvm,
+   struct kvm_memory_slot *memslot);
  void kvm_mmu_slot_leaf_clear_dirty(struct kvm *kvm,
   struct kvm_memory_slot *memslot);
  void kvm_mmu_slot_largepage_remove_write_access(struct kvm *kvm,
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index cee7592..d25ced1 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -4465,6 +4465,72 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
kvm_flush_remote_tlbs(kvm);
  }

+static int kvm_mmu_zap_collapsible_spte(struct kvm *kvm,
+   unsigned long *rmapp)


Can use 'bool' instead of 'int'. You used 'bool' in
kvm_mmu_zap_collapsible_sptes anyway.


+{
+   u64 *sptep;
+   struct rmap_iterator iter;
+   int need_tlb_flush = 0;
+   pfn_t pfn;
+   struct kvm_mmu_page *sp;
+
+   for (sptep = rmap_get_first(*rmapp, ); sptep;) {
+   BUG_ON(!(*sptep & PT_PRESENT_MASK));
+
+   sp = page_header(__pa(sptep));
+   pfn = spte_to_pfn(*sptep);
+   if (sp->role.direct &&


It only works on direct mapping, please drop a comment to explain
why.


+   !kvm_is_reserved_pfn(pfn) &&
+   PageTransCompound(pfn_to_page(pfn))) {
+   drop_spte(kvm, sptep);
+   need_tlb_flush = 1;
+   }
+   sptep = rmap_get_next();


You can not get the next spte after drop the current spte. Please
refer to kvm_unmap_rmapp().


+   }
+
+   return need_tlb_flush;
+}
+
+void kvm_mmu_zap_collapsible_sptes(struct kvm *kvm,
+   struct kvm_memory_slot *memslot)
+{
+   bool flush = false;
+   unsigned long *rmapp;
+   unsigned long last_index, index;
+   gfn_t gfn_start, gfn_end;
+
+   spin_lock(>mmu_lock);
+
+   gfn_start = memslot->base_gfn;
+   gfn_end = memslot->base_gfn + memslot->npages - 1;
+
+   if (gfn_start >= gfn_end)
+   goto out;
+
+   rmapp = memslot->arch.rmap[0];
+   last_index = gfn_to_index(gfn_end, memslot->base_gfn,
+   PT_PAGE_TABLE_LEVEL);
+
+   for (index = 0; index <= last_index; ++index, ++rmapp) {
+   if (*rmapp)
+   flush |= kvm_mmu_zap_collapsible_spte(kvm, rmapp);
+
+   if (need_resched() || spin_needbreak(>mmu_lock)) {
+   if (flush) {
+   kvm_flush_remote_tlbs(kvm);
+   flush = false;
+   }
+   cond_resched_lock(>mmu_lock);
+   }
+   }
+
+   if (flush)
+   kvm_flush_remote_tlbs(kvm);
+
+out:
+   spin_unlock(>mmu_lock);
+}
+
  void kvm_mmu_slot_leaf_clear_dirty(struct kvm *kvm,
   struct kvm_memory_slot *memslot)
  {
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c5f7e03..6037389 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7618,6 +7618,11 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
/* It's OK to get 'new' slot here as it has already been installed */
  

Re: [PATCH 1/1] ext4: better error handling of kstrdup()

2015-04-02 Thread Theodore Ts'o
On Fri, Mar 20, 2015 at 05:21:54PM -0400, Taesoo Kim wrote:
> Upon memory pressure, kstrdup() might fail and correctly
> handle memory error, although current implementation do not
> refer orig_data.
> 
> NOTE. fortunately the correct impl works, other than a
> corner case where kstrdup() fails and kzalloc() succeeds;
> it might record 'NULL' in the log.
> 
> Signed-off-by: Taesoo Kim 

Applied, thanks.

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] KVM: remove kvm_read_hva and kvm_read_hva_atomic

2015-04-02 Thread Xiao Guangrong



On 04/02/2015 08:08 PM, Paolo Bonzini wrote:

The corresponding write functions just use __copy_to_user.  Do the
same on the read side.

This reverts what's left of commit 86ab8cffb498 (KVM: introduce
gfn_to_hva_read/kvm_read_hva/kvm_read_hva_atomic, 2012-08-21)



It looks good to me.

Reviewed-by: Xiao Guangrong 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/2] extcon-axp288: Add axp288 extcon driver support

2015-04-02 Thread Chanwoo Choi
Hi Ramakrishna,

When I apply this patch for build test on extcon-next branch,
conflict happen. you have to implement this patchset on latest extcon-next 
branch.

Also, This patch must need more clean-up and use latest extcon helper API.
When you implement extcon-axp288.c, I recommend you refer to merged extcon 
drivers.

On 04/03/2015 04:19 AM, Ramakrishna Pallala wrote:
> This patch adds the extcon support for AXP288 PMIC which
> has the BC1.2 charger detection capability. Additionally
> it also adds the USB mux switching support b/w SOC and PMIC
> based on GPIO control.
> 
> Signed-off-by: Ramakrishna Pallala 
> ---
>  drivers/extcon/Kconfig |7 +
>  drivers/extcon/Makefile|1 +
>  drivers/extcon/extcon-axp288.c |  479 
> 
>  include/linux/mfd/axp20x.h |5 +
>  4 files changed, 492 insertions(+)
>  create mode 100644 drivers/extcon/extcon-axp288.c
> 
> diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
> index 6a1f7de..b8627f7 100644
> --- a/drivers/extcon/Kconfig
> +++ b/drivers/extcon/Kconfig
> @@ -93,4 +93,11 @@ config EXTCON_SM5502
> Silicon Mitus SM5502. The SM5502 is a USB port accessory
> detector and switch.
>  
> +config EXTCON_AXP288
> + tristate "AXP288 EXTCON support"

I recommend to add manufactor name of AXP288 PMIC chip.

> + depends on MFD_AXP20X && USB_PHY
> + help
> +   Say Y here to enable support for USB peripheral detection
> +   and USB MUX switching by AXP288 PMIC.
> +

Need to relocate EXTCON_AXP288 configuration alpabetically.

>  endif # MULTISTATE_SWITCH
> diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
> index 0370b42..832ad79 100644
> --- a/drivers/extcon/Makefile
> +++ b/drivers/extcon/Makefile
> @@ -12,3 +12,4 @@ obj-$(CONFIG_EXTCON_MAX8997)+= extcon-max8997.o
>  obj-$(CONFIG_EXTCON_PALMAS)  += extcon-palmas.o
>  obj-$(CONFIG_EXTCON_RT8973A) += extcon-rt8973a.o
>  obj-$(CONFIG_EXTCON_SM5502)  += extcon-sm5502.o
> +obj-$(CONFIG_EXTCON_AXP288)  += extcon-axp288.o

ditto.

> diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
> new file mode 100644
> index 000..2e75d45
> --- /dev/null
> +++ b/drivers/extcon/extcon-axp288.c
> @@ -0,0 +1,479 @@
> +/*
> + * extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver
> + *
> + * Copyright (C) 2015 Intel Corporation
> + * Ramakrishna Pallala 

Need to add 'Author' in front of name.

> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define AXP288_PS_STAT_REG   0x00
> +#define PS_STAT_VBUS_TRIGGER (1 << 0)
> +#define PS_STAT_BAT_CHRG_DIR (1 << 2)
> +#define PS_STAT_VBUS_ABOVE_VHOLD (1 << 3)
> +#define PS_STAT_VBUS_VALID   (1 << 4)
> +#define PS_STAT_VBUS_PRESENT (1 << 5)
> +
> +#define AXP288_BC_GLOBAL_REG 0x2c
> +#define BC_GLOBAL_RUN(1 << 0)
> +#define BC_GLOBAL_DET_STAT   (1 << 2)
> +#define BC_GLOBAL_DBP_TOUT   (1 << 3)
> +#define BC_GLOBAL_VLGC_COM_SEL   (1 << 4)
> +#define BC_GLOBAL_DCD_TOUT_MASK  0x60
> +#define BC_GLOBAL_DCD_TOUT_300MS 0x0
> +#define BC_GLOBAL_DCD_TOUT_100MS 0x1
> +#define BC_GLOBAL_DCD_TOUT_500MS 0x2
> +#define BC_GLOBAL_DCD_TOUT_900MS 0x3
> +#define BC_GLOBAL_DCD_DET_SEL(1 << 7)
> +
> +#define AXP288_BC_VBUS_CNTL_REG  0x2d
> +#define VBUS_CNTL_DPDM_PD_EN (1 << 4)
> +#define VBUS_CNTL_DPDM_FD_EN (1 << 5)
> +#define VBUS_CNTL_FIRST_PO_STAT  (1 << 6)
> +
> +#define AXP288_BC_USB_STAT_REG   0x2e
> +#define USB_STAT_BUS_STAT_MASK   0x0f
> +#define USB_STAT_BUS_STAT_OFFSET 0
> +#define USB_STAT_BUS_STAT_ATHD   0x0
> +#define USB_STAT_BUS_STAT_CONN   0x1
> +#define USB_STAT_BUS_STAT_SUSP   0x2
> +#define USB_STAT_BUS_STAT_CONF   0x3
> +#define USB_STAT_USB_SS_MODE (1 << 4)
> +#define USB_STAT_DEAD_BAT_DET(1 << 6)
> +#define USB_STAT_DBP_UNCFG   (1 << 7)
> +
> +#define AXP288_BC_DET_STAT_REG   0x2f
> +#define DET_STAT_MASK0xe0
> +#define DET_STAT_OFFSET  5
> +#define DET_STAT_SDP 0x1
> +#define DET_STAT_CDP  

Re: [PATCH] ext4: Remove useless condition in if statement.

2015-04-02 Thread Theodore Ts'o
On Tue, Mar 17, 2015 at 09:31:54AM +0800, Wei Yuan wrote:
> In this if statement, the previous condition is useless, the later one has 
> covered it.
> 
> Signed-off-by: Weiyuan 

Applied, thanks.

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 8/9] qspinlock: Generic paravirt support

2015-04-02 Thread Waiman Long

On 04/02/2015 03:48 PM, Peter Zijlstra wrote:

On Thu, Apr 02, 2015 at 07:20:57PM +0200, Peter Zijlstra wrote:

pv_wait_head():

pv_hash()
/* MB as per cmpxchg */
cmpxchg(>locked, _Q_LOCKED_VAL, _Q_SLOW_VAL);

VS

__pv_queue_spin_unlock():

if (xchg(>locked, 0) != _Q_SLOW_VAL)
return;

/* MB as per xchg */
pv_hash_find(lock);




Something like so.. compile tested only.

I took out the LFSR because that was likely over engineering from my
side :-)

--- a/kernel/locking/qspinlock_paravirt.h
+++ b/kernel/locking/qspinlock_paravirt.h
@@ -2,6 +2,8 @@
  #error "do not include this file"
  #endif

+#include
+
  /*
   * Implement paravirt qspinlocks; the general idea is to halt the vcpus 
instead
   * of spinning them.
@@ -107,7 +109,84 @@ static void pv_kick_node(struct mcs_spin
pv_kick(pn->cpu);
  }

-static DEFINE_PER_CPU(struct qspinlock *, __pv_lock_wait);
+/*
+ * Hash table using open addressing with an linear probe sequence.
+ *
+ * Since we should not be holding locks from NMI context (very rare indeed) the
+ * max load factor is 0.75, which is around the point where open adressing
+ * breaks down.
+ *
+ * Instead of probing just the immediate bucket we probe all buckets in the
+ * same cacheline.
+ *
+ * http://en.wikipedia.org/wiki/Hash_table#Open_addressing
+ *
+ */
+
+struct pv_hash_bucket {
+   struct qspinlock *lock;
+   int cpu;
+};
+
+/*
+ * XXX dynamic allocate using nr_cpu_ids instead...
+ */
+#define PV_LOCK_HASH_BITS  (2 + NR_CPUS_BITS)
+
+#if PV_LOCK_HASH_BITS<  6
+#undef PV_LOCK_HASH_BITS
+#define PB_LOCK_HASH_BITS  6
+#endif
+
+#define PV_LOCK_HASH_SIZE  (1<<  PV_LOCK_HASH_BITS)
+
+static struct pv_hash_bucket __pv_lock_hash[PV_LOCK_HASH_SIZE] 
cacheline_aligned;
+
+#define PV_HB_PER_LINE (SMP_CACHE_BYTES / sizeof(struct 
pv_hash_bucket))
+
+static inline u32 hash_align(u32 hash)
+{
+   return hash&  ~(PV_HB_PER_LINE - 1);
+}
+
+#define for_each_hash_bucket(hb, off, hash)
\
+   for (hash = hash_align(hash), off = 0, hb =&__pv_lock_hash[hash + off];\
+   off<  PV_LOCK_HASH_SIZE; \
+   off++, hb =&__pv_lock_hash[(hash + off) % PV_LOCK_HASH_SIZE])
+
+static struct pv_hash_bucket *pv_hash_insert(struct qspinlock *lock)
+{
+   u32 offset, hash = hash_ptr(lock, PV_LOCK_HASH_BITS);
+   struct pv_hash_bucket *hb;
+
+   for_each_hash_bucket(hb, offset, hash) {
+   if (!cmpxchg(>lock, NULL, lock)) {
+   WRITE_ONCE(hb->cpu, smp_processor_id());
+   return hb;
+   }
+   }
+
+   /*
+* Hard assumes there is an empty bucket somewhere.
+*/
+   BUG();
+}
+
+static struct pv_hash_bucket *pv_hash_find(struct qspinlock *lock)
+{
+   u32 offset, hash = hash_ptr(lock, PV_LOCK_HASH_BITS);
+   struct pv_hash_bucket *hb;
+
+   for_each_hash_bucket(hb, offset, hash) {
+   if (READ_ONCE(hb->lock) == lock)
+   return hb;
+   }
+
+   /*
+* Hard assumes we _WILL_ find a match.
+*/
+   BUG();
+}

  /*
   * Wait for l->locked to become clear; halt the vcpu after a short spin.
@@ -116,7 +195,9 @@ static DEFINE_PER_CPU(struct qspinlock *
  static void pv_wait_head(struct qspinlock *lock)
  {
struct __qspinlock *l = (void *)lock;
+   struct pv_hash_bucket *hb = NULL;
int loop;
+   u8 o;

for (;;) {
for (loop = SPIN_THRESHOLD; loop; loop--) {
@@ -126,29 +207,47 @@ static void pv_wait_head(struct qspinloc
cpu_relax();
}

-   this_cpu_write(__pv_lock_wait, lock);
-   /*
-* __pv_lock_wait must be set before setting _Q_SLOW_VAL
-*
-* [S] __pv_lock_wait = lock[RmW] l = l->locked = 0
-* MB MB
-* [S] l->locked = _Q_SLOW_VAL  [L]   __pv_lock_wait
-*
-* Matches the xchg() in pv_queue_spin_unlock().
-*/
-   if (!cmpxchg(>locked, _Q_LOCKED_VAL, _Q_SLOW_VAL))
-   goto done;
+   if (!hb) {
+   hb = pv_hash_insert(lock);
+   /*
+* hb  must be set before setting _Q_SLOW_VAL
+*
+* [S]   hb<- lock   [RmW] l = l->locked = 0
+*   MB MB
+* [RmW] l->locked ?= _Q_SLOW_VAL [L]   hb
+*
+* Matches the xchg() in pv_queue_spin_unlock().
+*/
+   o = cmpxchg(>locked, _Q_LOCKED_VAL, _Q_SLOW_VAL);
+   if (!o) {
+   /*
+

Re: [PATCH v2] video: mxsfb: Make sure axi clock is enabled when accessing registers

2015-04-02 Thread Liu Ying
2015-03-20 19:26 GMT+08:00 Tomi Valkeinen :
> On 11/03/15 05:03, Liu Ying wrote:
>
>>> Why do you check for host->enabled here, but not elsewhere?
>>
>> We need this check here to make sure the axi clock reference count is no 
>> greater
>> than 1.  Looking at the context of mxsfb_set_par(), mxsfb_restore_mode() and
>
> Why is that? The clock framework handles ref counting for you. All the
> driver needs to take care of is to call as many times disable as it
> calls enable.

Okay.  I'll remove the check and send another version.

Regards,
Liu Ying

>
>  Tomi
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 0/2] clockevents: Stop unused clockevent devices

2015-04-02 Thread Viresh Kumar
Hi,

A clockevent device is used to service timers/hrtimers requests and the next
event (when it should fire) is decided by the timer/hrtimer expiring next. When
no timers/hrtimers are pending to be serviced, the expiry time is set to a
special value: KTIME_MAX.

This would normally happen with NO_HZ_{IDLE|FULL} in both LOWRES/HIGHRES modes.

When 'expiry == KTIME_MAX', we either cancel the 'tick-sched' hrtimer
(NOHZ_MODE_HIGHRES) or skip reprogramming clockevent device (NOHZ_MODE_LOWRES).
But, the clockevent device is already reprogrammed from the tick-handler for
next tick.

As the clock event device is programmed in ONESHOT mode it will at least fire
one more time (unnecessarily). Timers on few implementations (like
arm_arch_timer, etc.) only support PERIODIC mode and their drivers emulate
ONESHOT over that. Which means that on these platforms we will get spurious
interrupts periodically (at last programmed interval rate, normally tick rate).

In order to avoid spurious interrupts, the unused clockevent device should be
stopped or its interrupts should be masked.

Thomas suggested to add an optional state ONESHOT_STOPPED to solve this problem:
lkml.org/lkml/2014/5/9/508.

First patch implements the required infrastructure to start/stop clockevent
device. The second patch stops/starts clockevent devices as and when required.

It is also pushed here:

git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/linux.git 
tick/oneshot-stopped

@Preeti: I have applied your Reviewed-by only for the first commit as others
have changed significantly. Feel free to give it again :)

V1->V2:
- Peter & Ingo suggested to to start/stop clockevent device from
  tick_program_event() instead of the call sites that called
  tick_program_event().

--
viresh

Viresh Kumar (2):
  clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state
  Clockevents: Stop unused clockevent devices

 include/linux/clockchips.h |  7 ++-
 kernel/time/clockevents.c  | 18 +-
 kernel/time/hrtimer.c  |  6 ++
 kernel/time/tick-oneshot.c | 16 
 kernel/time/timer_list.c   |  6 ++
 5 files changed, 47 insertions(+), 6 deletions(-)

-- 
2.3.0.rc0.44.ga94655d

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


[PATCH V2 2/2] Clockevents: Stop unused clockevent devices

2015-04-02 Thread Viresh Kumar
To avoid getting spurious interrupts on a tickless CPU, clockevent
device can now be stopped by switching to ONESHOT_STOPPED state.

The natural place for handling this transition is tick_program_event().

On 'expires == KTIME_MAX', we skip programming the event and so we need
to fix such call sites as well, to always call tick_program_event()
irrespective of the expires value.

Once the clockevent device is required again, check if it was earlier
put into ONESHOT_STOPPED state. If yes, switch its state to ONESHOT
before programming its event.

To make sure we haven't missed any corner case, add a WARN() for the
case where we try to reprogram clockevent device while we aren't
configured in ONESHOT_STOPPED state.

Signed-off-by: Viresh Kumar 
---
 kernel/time/clockevents.c  |  4 
 kernel/time/hrtimer.c  |  6 ++
 kernel/time/tick-oneshot.c | 16 
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 49ed2ea4294c..8ff54495f60b 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -335,6 +335,10 @@ int clockevents_program_event(struct clock_event_device 
*dev, ktime_t expires,
if (dev->state == CLOCK_EVT_STATE_SHUTDOWN)
return 0;
 
+   /* We must be in ONESHOT state here */
+   WARN_ONCE(dev->state != CLOCK_EVT_STATE_ONESHOT, "Current state: %d\n",
+ dev->state);
+
/* Shortcut for clockevent devices that can deal with ktime. */
if (dev->features & CLOCK_EVT_FEAT_KTIME)
return dev->set_next_ktime(expires, dev);
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 721d29b99d10..d1be3eda83fa 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -543,8 +543,7 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, 
int skip_equal)
if (cpu_base->hang_detected)
return;
 
-   if (cpu_base->expires_next.tv64 != KTIME_MAX)
-   tick_program_event(cpu_base->expires_next, 1);
+   tick_program_event(cpu_base->expires_next, 1);
 }
 
 /*
@@ -1308,8 +1307,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
raw_spin_unlock(_base->lock);
 
/* Reprogramming necessary ? */
-   if (expires_next.tv64 == KTIME_MAX ||
-   !tick_program_event(expires_next, 0)) {
+   if (!tick_program_event(expires_next, 0)) {
cpu_base->hang_detected = 0;
return;
}
diff --git a/kernel/time/tick-oneshot.c b/kernel/time/tick-oneshot.c
index 67a64b1670bf..f8de75715c2f 100644
--- a/kernel/time/tick-oneshot.c
+++ b/kernel/time/tick-oneshot.c
@@ -28,6 +28,22 @@ int tick_program_event(ktime_t expires, int force)
 {
struct clock_event_device *dev = 
__this_cpu_read(tick_cpu_device.evtdev);
 
+   if (unlikely(expires.tv64 == KTIME_MAX)) {
+   /*
+* We don't need the clock event device any more, stop it.
+*/
+   clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
+   return 0;
+   }
+
+   if (unlikely(dev->state == CLOCK_EVT_STATE_ONESHOT_STOPPED)) {
+   /*
+* We need the clock event again, configure it in ONESHOT mode
+* before using it.
+*/
+   clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT);
+   }
+
return clockevents_program_event(dev, expires, force);
 }
 
-- 
2.3.0.rc0.44.ga94655d

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/2] clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state

2015-04-02 Thread Viresh Kumar
When no timers/hrtimers are pending, the expiry time is set to a special value:
'KTIME_MAX'. This normally happens with NO_HZ_{IDLE|FULL} in both LOWRES/HIGHRES
modes.

When 'expiry == KTIME_MAX', we either cancel the 'tick-sched' hrtimer
(NOHZ_MODE_HIGHRES) or skip reprogramming clockevent device (NOHZ_MODE_LOWRES).
But, the clockevent device is already reprogrammed from the tick-handler for
next tick.

As the clock event device is programmed in ONESHOT mode it will at least fire
one more time (unnecessarily). Timers on few implementations (like
arm_arch_timer, etc.) only support PERIODIC mode and their drivers emulate
ONESHOT over that. Which means that on these platforms we will get spurious
interrupts periodically (at last programmed interval rate, normally tick rate).

In order to avoid spurious interrupts, the clockevent device should be stopped
or its interrupts should be masked.

A simple (yet hacky) solution to get this fixed could be: update
hrtimer_force_reprogram() to always reprogram clockevent device and update
clockevent drivers to STOP generating events (or delay it to max time) when
'expires' is set to KTIME_MAX. But the drawback here is that every clockevent
driver has to be hacked for this particular case and its very easy for new ones
to miss this.

However, Thomas suggested to add an optional state ONESHOT_STOPPED to solve this
problem: lkml.org/lkml/2014/5/9/508.

This patch adds support for ONESHOT_STOPPED state in clockevents core. It will
only be available to drivers that implement the state-specific callbacks instead
of the legacy ->set_mode() callback.

Reviewed-by: Preeti U. Murthy 
Signed-off-by: Viresh Kumar 
---
 include/linux/clockchips.h |  7 ++-
 kernel/time/clockevents.c  | 14 +-
 kernel/time/timer_list.c   |  6 ++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index caeca76d7b32..ee63865d3cd7 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -49,12 +49,15 @@ enum clock_event_mode {
  * reached from DETACHED or SHUTDOWN.
  * ONESHOT:Device is programmed to generate event only once. Can be reached
  * from DETACHED or SHUTDOWN.
+ * ONESHOT_STOPPED: Device was programmed in ONESHOT mode and is temporarily
+ * stopped.
  */
 enum clock_event_state {
CLOCK_EVT_STATE_DETACHED,
CLOCK_EVT_STATE_SHUTDOWN,
CLOCK_EVT_STATE_PERIODIC,
CLOCK_EVT_STATE_ONESHOT,
+   CLOCK_EVT_STATE_ONESHOT_STOPPED,
 };
 
 /*
@@ -102,6 +105,7 @@ enum clock_event_state {
  * @set_mode:  legacy set mode function, only for modes <= 
CLOCK_EVT_MODE_RESUME.
  * @set_state_periodic:switch state to periodic, if !set_mode
  * @set_state_oneshot: switch state to oneshot, if !set_mode
+ * @set_state_oneshot_stopped: switch state to oneshot_stopped, if !set_mode
  * @set_state_shutdown:switch state to shutdown, if !set_mode
  * @tick_resume:   resume clkevt device, if !set_mode
  * @broadcast: function to broadcast events
@@ -133,11 +137,12 @@ struct clock_event_device {
 * State transition callback(s): Only one of the two groups should be
 * defined:
 * - set_mode(), only for modes <= CLOCK_EVT_MODE_RESUME.
-* - set_state_{shutdown|periodic|oneshot}(), tick_resume().
+* - set_state_{shutdown|periodic|oneshot|oneshot_stopped}(), 
tick_resume().
 */
void(*set_mode)(enum clock_event_mode mode, struct 
clock_event_device *);
int (*set_state_periodic)(struct clock_event_device 
*);
int (*set_state_oneshot)(struct clock_event_device 
*);
+   int (*set_state_oneshot_stopped)(struct 
clock_event_device *);
int (*set_state_shutdown)(struct clock_event_device 
*);
int (*tick_resume)(struct clock_event_device *);
 
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 7af614829da1..49ed2ea4294c 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -138,6 +138,17 @@ static int __clockevents_set_state(struct 
clock_event_device *dev,
return -ENOSYS;
return dev->set_state_oneshot(dev);
 
+   case CLOCK_EVT_STATE_ONESHOT_STOPPED:
+   /* Core internal bug */
+   if (WARN_ONCE(dev->state != CLOCK_EVT_STATE_ONESHOT,
+ "Current state: %d\n", dev->state))
+   return -EINVAL;
+
+   if (dev->set_state_oneshot_stopped)
+   return dev->set_state_oneshot_stopped(dev);
+   else
+   return -ENOSYS;
+
default:
return -ENOSYS;
}
@@ -449,7 +460,8 @@ static int clockevents_sanity_check(struct 
clock_event_device *dev)
if (dev->set_mode) {

[PATCH 1/1] irqchip/gicv3-its: remove GITS_BASER_TYPE_CPU base on latest specification

2015-04-02 Thread Zhen Lei
Acutally, "Interrupt Collections" and "Physical Processors" is the
same thing.

Signed-off-by: Zhen Lei 
---
 drivers/irqchip/irq-gic-v3-its.c   | 2 +-
 include/linux/irqchip/arm-gic-v3.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 9687f8a..a795aae 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -777,7 +777,7 @@ static int __init its_alloc_lpi_tables(void)
 static const char *its_base_type_string[] = {
[GITS_BASER_TYPE_DEVICE]= "Devices",
[GITS_BASER_TYPE_VCPU]  = "Virtual CPUs",
-   [GITS_BASER_TYPE_CPU]   = "Physical CPUs",
+   [GITS_BASER_TYPE_RESERVED3] = "Reserved (3)",
[GITS_BASER_TYPE_COLLECTION]= "Interrupt Collections",
[GITS_BASER_TYPE_RESERVED5] = "Reserved (5)",
[GITS_BASER_TYPE_RESERVED6] = "Reserved (6)",
diff --git a/include/linux/irqchip/arm-gic-v3.h 
b/include/linux/irqchip/arm-gic-v3.h
index ffbc034..67f5779 100644
--- a/include/linux/irqchip/arm-gic-v3.h
+++ b/include/linux/irqchip/arm-gic-v3.h
@@ -233,7 +233,7 @@
 #define GITS_BASER_TYPE_NONE   0
 #define GITS_BASER_TYPE_DEVICE 1
 #define GITS_BASER_TYPE_VCPU   2
-#define GITS_BASER_TYPE_CPU3
+#define GITS_BASER_TYPE_RESERVED3  3
 #define GITS_BASER_TYPE_COLLECTION 4
 #define GITS_BASER_TYPE_RESERVED5  5
 #define GITS_BASER_TYPE_RESERVED6  6
--
1.8.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 RFC v9 09/20] drm/dsi: Add a helper to get bits per pixel of MIPI DSI pixel format

2015-04-02 Thread Liu Ying
Hi Thierry,

2015-03-03 19:07 GMT+08:00 Philipp Zabel :
> Hi,
>
> Am Donnerstag, den 12.02.2015, 14:01 +0800 schrieb Liu Ying:
>> Signed-off-by: Liu Ying 
>> ---
>> v8->v9:
>>  * Rebase onto the imx-drm/next branch of Philipp Zabel's open git 
>> repository.
>
> I can't test this myself for lack of hardware, but I see no further
> issues with patches 09 - 13 except for the use of
> imx_drm_encoder_get_mux_id. I'll either rebase my patches that remove it
> or fix it up when applying.
>
> Thierry, may I take these patches through imx-drm, or would you rather I
> waited for you to pick up the drm/dsi and drm/bridge patches?

Gentle ping.  What's your opinion on the patches Philipp mentioned?

Regards,
Liu Ying

>
> regards
> Philipp
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel



-- 
Best Regards,
Liu Ying
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: Build regression in next-20150331

2015-04-02 Thread Tyler Baker
On 2 April 2015 at 01:29, Peter Zijlstra  wrote:
> On Wed, Apr 01, 2015 at 11:46:10PM +0200, Rafael J. Wysocki wrote:
>
>> > > ---
>> > >  kernel/time/tick-internal.h |2 ++
>> > >  1 file changed, 2 insertions(+)
>> > >
>> > > Index: linux-pm/kernel/time/tick-internal.h
>> > > ===
>> > > --- linux-pm.orig/kernel/time/tick-internal.h
>> > > +++ linux-pm/kernel/time/tick-internal.h
>> > > @@ -110,7 +110,9 @@ static inline int tick_broadcast_update_
>> > >  /* Set the periodic handler in non broadcast mode */
>> > >  static inline void tick_set_periodic_handler(struct clock_event_device 
>> > > *dev, int broadcast)
>> > >  {
>> > > +#ifdef CONFIG_GENERIC_CLOCKEVENTS
>> > > dev->event_handler = tick_handle_periodic;
>> > > +#endif
>> > >  }
>> > >  #endif /* !BROADCAST */
>
>> Peter, do you think the above is acceptable or do I need to do anything more
>> sophisticated to fix this?  [The alternative would be probably to prepare an
>> empty definition of tick_handle_periodic() for CONFIG_GENERIC_CLOCKEVENTS and
>> move the definition of struct clock_event_device from under that Kconfig
>> option.]
>
>
> Does not something like the below make more sense? The entire broadcast
> thing doesn't make sense if we don't have generic_clockevents.
>
> Should we wrap more in generic_clockevents there?
>
> ---
>  kernel/time/tick-internal.h |2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
> index 2a1563a..5569e65 100644
> --- a/kernel/time/tick-internal.h
> +++ b/kernel/time/tick-internal.h
> @@ -81,6 +81,7 @@ static inline int tick_check_oneshot_change(int allow_nohz) 
> { return 0; }
>  #endif /* !TICK_ONESHOT */
>
>  /* Broadcasting support */
> +#ifdef CONFIG_GENERIC_CLOCKEVENTS
>  #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
>  extern int tick_device_uses_broadcast(struct clock_event_device *dev, int 
> cpu);
>  extern void tick_install_broadcast_device(struct clock_event_device *dev);
> @@ -114,6 +115,7 @@ static inline void tick_set_periodic_handler(struct 
> clock_event_device *dev, int
> dev->event_handler = tick_handle_periodic;
>  }
>  #endif /* !BROADCAST */
> +#endif /* GENERIC */
>
>  /* Functions related to oneshot broadcasting */
>  #if defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) && 
> defined(CONFIG_TICK_ONESHOT)

Tested-by: Tyler Baker 

Looks good to me.

Applied on top of next-20150402[0]:

---
 kernel/time/tick-internal.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index 2a1563a..e332bb4 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -81,6 +81,7 @@ static inline int tick_check_oneshot_change(int
allow_nohz) { return 0; }
 #endif /* !TICK_ONESHOT */

 /* Broadcasting support */
+#ifdef CONFIG_GENERIC_CLOCKEVENTS
 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
 extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
 extern void tick_install_broadcast_device(struct clock_event_device *dev);
@@ -114,7 +115,7 @@ static inline void
tick_set_periodic_handler(struct clock_event_device *dev, int
  dev->event_handler = tick_handle_periodic;
 }
 #endif /* !BROADCAST */
+#endif /* GENERIC */
 /* Functions related to oneshot broadcasting */
 #if defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) &&
defined(CONFIG_TICK_ONESHOT)
 extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
---

Tyler

[0] 
http://kernelci.org/build/tbaker/kernel/v4.0-rc6-8742-g76c8cce3+gcc-linaro-4.9-2015.02/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [3/4] powerpc: support CPU hotplug for e500mc, e5500 and e6500

2015-04-02 Thread chenhui.z...@freescale.com



From: Wood Scott-B07421
Sent: Friday, April 3, 2015 0:03
To: Zhao Chenhui-B35336
Cc: linuxppc-...@lists.ozlabs.org; devicet...@vger.kernel.org; 
linux-kernel@vger.kernel.org; Jin Zhengxiong-R64188
Subject: Re: [3/4] powerpc: support CPU hotplug for e500mc, e5500 and e6500

On Thu, 2015-04-02 at 06:16 -0500, Zhao Chenhui-B35336 wrote:
>
> 
> From: Wood Scott-B07421
> Sent: Tuesday, March 31, 2015 10:07
> To: Zhao Chenhui-B35336
> Cc: linuxppc-...@lists.ozlabs.org; devicet...@vger.kernel.org; 
> linux-kernel@vger.kernel.org; Jin Zhengxiong-R64188
> Subject: Re: [3/4] powerpc: support CPU hotplug for e500mc, e5500 and e6500
>
> On Thu, Mar 26, 2015 at 06:18:14PM +0800, chenhui zhao wrote:
> > @@ -189,16 +193,14 @@ _GLOBAL(fsl_secondary_thread_init)
> >   isync
> >
> >   /*
> > -  * Fix PIR to match the linear numbering in the device tree.
> > -  *
> > -  * On e6500, the reset value of PIR uses the low three bits for
> > -  * the thread within a core, and the upper bits for the core
> > -  * number.  There are two threads per core, so shift everything
> > -  * but the low bit right by two bits so that the cpu numbering is
> > -  * continuous.
>
> Why are you getting rid of this?  If it's to avoid doing it twice on the
> same thread, in my work-in-progress kexec patches I instead check to see
> whether BUCSR has already been set up -- if it has, I assume we've
> already been here.
>
> [chenhui] I didn't delete the branch prediction related code.

I didn't say you did.  I'm saying that you can check whether BUCSR has
been set up, to determine whether PIR has already been adjusted, if your
concern is avoiding running this twice on a thread between core resets.
If that's not your concern, then please explain.

[chenhui] If no need to change PIR in CPU hotplug, I will change the code as 
you mentioned.

> > + /*
> > +  * If both threads are offline, reset core to start.
> > +  * When core is up, Thread 0 always gets up first,
> > +  * so bind the current logical cpu with Thread 0.
> > +  */
>
> What if the core is not in a PM state that requires a reset?
> Where does this reset occur?
>
> [chenhui] Reset occurs in the function mpic_reset_core().
>
> > + if (hw_cpu != cpu_first_thread_sibling(hw_cpu)) {
> > + int hw_cpu1, hw_cpu2;
> > +
> > + hw_cpu1 = get_hard_smp_processor_id(primary);
> > + hw_cpu2 = get_hard_smp_processor_id(primary + 1);
> > + set_hard_smp_processor_id(primary, hw_cpu2);
> > + set_hard_smp_processor_id(primary + 1, hw_cpu1);
> > + /* get new physical cpu id */
> > + hw_cpu = get_hard_smp_processor_id(nr);
>
> Why are you swapping the hard smp ids?
>
> [chenhui] For example, Core1 has two threads, Thread0 and Thread1. In normal 
> boot, Thread0 is CPU2, and Thread1 is CPU3.
> But, if CPU2 and CPU3 are all off, user wants CPU3 up first. we need to call 
> Thread0 as CPU3 and Thead1 as CPU2, considering
> the limitation, after core is reset, only Thread0 is up, then Thread0 kicks 
> up Thread1.

There's no need for this.  I have booting from a thread1, and having it
kick its thread0, working locally without messing with the hwid/cpu
mapping.

[chenhui] Great. If you have completed your patches, can we merge our code?

> > @@ -252,11 +340,7 @@ static int smp_85xx_kick_cpu(int nr)
> >   spin_table = phys_to_virt(*cpu_rel_addr);
> >
> >   local_irq_save(flags);
> > -#ifdef CONFIG_PPC32
> >  #ifdef CONFIG_HOTPLUG_CPU
> > - /* Corresponding to generic_set_cpu_dead() */
> > - generic_set_cpu_up(nr);
> > -
>
> Why did you move this?
>
> [chenhui] It would be better to set this after CPU is really up.

Please make it a separate patch with an explanation.

-Scott

[chenhui] OK.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] drivers/i2c/i2c-core.c: Fix sparse warning

2015-04-02 Thread Nickolaus Woodruff
This patch fixes the following sparse warning in drivers/i2c/:

CHECK   drivers/i2c/i2c-core.c
drivers/i2c/i2c-core.c:2353:36: warning: dubious: x | !y

Signed-off-by: Nickolaus Woodruff 
---
 drivers/i2c/i2c-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index edf274c..f50d46e 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -2350,7 +2350,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
 static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
 {
/* The address will be sent first */
-   u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
+   u8 addr = (msg->addr << 1) | ((msg->flags & I2C_M_RD) != 0);
pec = i2c_smbus_pec(pec, , 1);

/* The data buffer follows */
--
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] PM / watchdog: iTCO: stop watchdog during system suspend

2015-04-02 Thread Fu, Borun
On Apr 3, 2015 06:04, Rafael J. Wysocki wrote:
> On Wednesday, April 01, 2015 06:21:40 PM Guenter Roeck wrote:
>> On 04/01/2015 05:31 PM, Rafael J. Wysocki wrote:
>>> From: Rafael J. Wysocki 
> 
> [cut]
> 
>> Hi Rafael,
>> 
>> This only covers suspend and resume, but not any of the other
>> sleep operations (like SIMPLE_DEV_PM_OPS would do).
>> Is that intentional ?
> 
> Yes, it is:
>  (1) The problemm at hand is strictly specific to system suspend.
>  (2) The SIMPLE_DEV_PM_OPS etc macros don't cover the _noirq callback
> variants
>  (and we want to use the _noirq variants, because we want the
>  watchdog to be stopped as late and restarted as early as reasonably
>  possible). (3) I'm not even sure if adding runtime PM support to
>  this driver would make any sense. :-)
>> 
>>> +};
>>> +
>>> +#define ITCO_WDT_PM_OPS_wdt_pm
>> 
>> Checkpatch wants to see (_wdt_pm).
>> 
>> ERROR: Macros with complex values should be enclosed in parentheses
> 
> Please find an updated patch below.
> 
> Rafael
> 
> 
Tested-by: Borun Fu 

Borun
> ---
> From: Rafael J. Wysocki 
> Subject: PM / watchdog: iTCO: stop watchdog during system suspend
> 
> If the target sleep state of the system is not an ACPI sleep state
> (S1, S2 or S3), the TCO watchdog needs to be stopped during system
> suspend, because it may not be possible to ping it any more after
> timekeeping has been suspended (suspend-to-idle does that for
> one example).
> 
> For this reason, provide ->suspend_noirq and ->resume_noirq
> callbacks for the iTCO watchdog driver and use them to stop
> and restart the watchdog during system suspend and resume,
> respectively, if the system is not going to enter an ACPI
> sleep state (in which case the watchdog will be stopped
> by the platform firmware before the state is entered).
> 
> Reported-by: Borun Fu 
> Signed-off-by: Rafael J. Wysocki 
> ---
>  drivers/watchdog/iTCO_wdt.c |   51
>   1 file changed, 51
>  insertions(+)
> Index: linux-pm/drivers/watchdog/iTCO_wdt.c
>  === ---
> linux-pm.orig/drivers/watchdog/iTCO_wdt.c +++
> linux-pm/drivers/watchdog/iTCO_wdt.c @@ -51,6 +51,7 @@
>  #define DRV_VERSION  "1.11"
>  
>  /* Includes */ +#include   /* For ACPI 
> support */
>  #include /* For module specific items */ #include
>  /* For new moduleparam's */ #include
>/* For standard types (like size_t) */ @@ -103,6
>  +104,8 @@ static struct {/* this is private data struct
>  platform_device *dev;/* the PCI-device */struct pci_dev *pdev;
> + /* whether or not the watchdog has been suspended */
> + bool suspended;
>  } iTCO_wdt_private;
>  
>  /* module parameters */ @@ -571,12 +574,60 @@ static void
>  iTCO_wdt_shutdown(struct pla iTCO_wdt_stop(NULL); }
> +#ifdef CONFIG_PM_SLEEP +/* + * Suspend-to-idle requires this, because
> it stops the ticks and timekeeping, so + * the watchdog cannot be pinged
> while in that state.  In ACPI sleep states the + * watchdog is stopped
> by the platform firmware. + */ + +#ifdef CONFIG_ACPI +static inline bool
> need_suspend(void) +{ +   return acpi_target_system_state() ==
> ACPI_STATE_S0; +} +#else +static inline bool need_suspend(void) { return
> true; } +#endif + +static int iTCO_wdt_suspend_noirq(struct device *dev)
> +{ +  int ret = 0; + +iTCO_wdt_private.suspended = false; +   if
> (watchdog_active(_wdt_watchdog_dev) && need_suspend()) { +   
> ret =
> iTCO_wdt_stop(_wdt_watchdog_dev); +  if (!ret)
> + iTCO_wdt_private.suspended = true; +} + return 
> ret; +} + +static
> int iTCO_wdt_resume_noirq(struct device *dev) +{ +if
> (iTCO_wdt_private.suspended) +
> iTCO_wdt_start(_wdt_watchdog_dev);
> + +   return 0; +} + +struct dev_pm_ops iTCO_wdt_pm = { + .suspend_noirq =
> iTCO_wdt_suspend_noirq, + .resume_noirq = iTCO_wdt_resume_noirq, +}; +
> +#define ITCO_WDT_PM_OPS  (_wdt_pm) +#else +#define
> ITCO_WDT_PM_OPS   NULL +#endif /* CONFIG_PM_SLEEP */ +
>  static struct platform_driver iTCO_wdt_driver = {.probe  =
>  iTCO_wdt_probe,  .remove = iTCO_wdt_remove,  .shutdown   
> =
>  iTCO_wdt_shutdown,   .driver = { .name   = DRV_NAME, +   
> .pm   
>   = ITCO_WDT_PM_OPS,  }, };

N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

Re: [PATCH v3 -next 11/11] serial: 8250_early: Remove setup_early_serial8250_console()

2015-04-02 Thread Yinghai Lu
On Thu, Apr 2, 2015 at 5:22 PM, Yinghai Lu  wrote:

 still have another problem.
 when using console=uart8250,io,0x3f8
 it works as earlycon at first.
 but after handover to normal console
 it will revert back to 9600 again.
>>>
>>> this regression should be caused by:
>>>
>>> commit c7cef0a84912cab3c9df8949b034e4aa62982ec9
>>> Author: Peter Hurley 
>>> Date:   Mon Mar 9 16:27:12 2015 -0400
>>>
>>> console: Add extensible console matching
>>
> So your whole patchset will need the first patch ?
>
> or can you just drop the first one patch ?

Please check attached patch that fix regresion by. commit c7cef0a849
("console: Add extensible console matching")

or you have better way?

Thanks

Yinghai
Subject: [PATCH] earlycon: Fix earlycon/console handover without options

commit c7cef0a84912 ("console: Add extensible console matching")
broke the earlycon/handover when booting
console=uart8250,io,0x3f8

the bootloader is using 115200, and the earlycon continue
use 115200, but console revert back to 9600.

Before the commit, probed baud rate is passed via console_cmdline
from earlycon to normal console.
That commit remove that and only check boot command line.

This patch use port match to get hold earlycon, and use earlycon
device options to update options for console.

Fixes: commit c7cef0a84912 ("console: Add extensible console matching")
Signed-off-by: Yinghai Lu 

---
 drivers/tty/serial/8250/8250_core.c  |   14 --
 drivers/tty/serial/8250/8250_early.c |   19 +++
 include/linux/console.h  |2 +-
 include/linux/serial_8250.h  |1 +
 kernel/printk/printk.c   |2 +-
 5 files changed, 34 insertions(+), 4 deletions(-)

Index: linux-2.6/drivers/tty/serial/8250/8250_core.c
===
--- linux-2.6.orig/drivers/tty/serial/8250/8250_core.c
+++ linux-2.6/drivers/tty/serial/8250/8250_core.c
@@ -3452,7 +3452,7 @@ static int univ8250_console_setup(struct
  *	@co:	  registering console
  *	@name:	  name from console command line
  *	@idx:	  index from console command line
- *	@options: ptr to option string from console command line
+ *	@options_p: ptr to ptr to option string from console command line
  *
  *	Only attempts to match console command lines of the form:
  *	console=uart<>,io|mmio|mmio32,,
@@ -3465,11 +3465,12 @@ static int univ8250_console_setup(struct
  *	Returns 0 if console matches; otherwise non-zero to use default matching
  */
 static int univ8250_console_match(struct console *co, char *name, int idx,
-  char *options)
+  char **options_p)
 {
 	char match[] = "uart";	/* 8250-specific earlycon name */
 	unsigned char iotype;
 	unsigned long addr;
+	char *options = *options_p;
 	int i;
 
 	if (strncmp(name, match, 4) != 0)
@@ -3491,6 +3492,15 @@ static int univ8250_console_match(struct
 			continue;
 
 		co->index = i;
+
+		if (!options || !options[0]) {
+			char *new_options = NULL;
+
+			if (!serial8250_get_earlycon_options(port,
+			 _options))
+options = *options_p = new_options;
+		}
+
 		return univ8250_console_setup(co, options);
 	}
 
Index: linux-2.6/drivers/tty/serial/8250/8250_early.c
===
--- linux-2.6.orig/drivers/tty/serial/8250/8250_early.c
+++ linux-2.6/drivers/tty/serial/8250/8250_early.c
@@ -105,6 +105,24 @@ static void __init early_serial8250_writ
 		serial8250_early_out(port, UART_IER, ier);
 }
 
+static struct earlycon_device *early_device;
+
+int serial8250_get_earlycon_options(struct uart_port *up, char **options_p)
+{
+	struct earlycon_device *device = early_device;
+	struct uart_port *port = device ? >port : NULL;
+
+	if (!port || (!port->membase && !port->iobase))
+		return -ENODEV;
+
+	if (!uart_match_port(up, port))
+		return -ENODEV;
+
+	*options_p = device->options;
+
+	return 0;
+}
+
 static unsigned int __init probe_baud(struct uart_port *port)
 {
 	unsigned char lcr, dll, dlm;
@@ -161,6 +179,7 @@ static int __init early_serial8250_setup
 	} else
 		init_port(device);
 
+	early_device = device;
 	device->con->write = early_serial8250_write;
 	return 0;
 }
Index: linux-2.6/include/linux/serial_8250.h
===
--- linux-2.6.orig/include/linux/serial_8250.h
+++ linux-2.6/include/linux/serial_8250.h
@@ -135,6 +135,7 @@ void serial8250_resume_port(int line);
 
 extern int early_serial_setup(struct uart_port *port);
 
+extern int serial8250_get_earlycon_options(struct uart_port *up, char **p);
 extern unsigned int serial8250_early_in(struct uart_port *port, int offset);
 extern void serial8250_early_out(struct uart_port *port, int offset, int value);
 extern void serial8250_do_set_termios(struct uart_port *port,
Index: linux-2.6/kernel/printk/printk.c
===
--- linux-2.6.orig/kernel/printk/printk.c
+++ 

Re: [PATCH V2 1/3] watchdog: imgpdc: Allow timeout to be set in device-tree

2015-04-02 Thread Guenter Roeck

On 04/02/2015 07:16 PM, Andrew Bresticker wrote:

Hi Guenter,

On Thu, Apr 2, 2015 at 6:52 PM, Guenter Roeck  wrote:

On 04/02/2015 09:46 AM, Andrew Bresticker wrote:


On Wed, Apr 1, 2015 at 6:08 PM, Guenter Roeck  wrote:


On 04/01/2015 03:22 PM, James Hogan wrote:



Hi Andrew,

On Wed, Apr 01, 2015 at 10:43:14AM -0700, Andrew Bresticker wrote:



Since the heartbeat is statically initialized to its default value,
watchdog_init_timeout() will never look in the device-tree for a
timeout-sec value.  Instead of statically initializing heartbeat,
fall back to the default timeout value if watchdog_init_timeout()
fails.




Whoops. Sorry about that. I wasn't aware that a timeout-sec value was
expected. It isn't mentioned in the DT binding documentation for this
device :-(.



Signed-off-by: Andrew Bresticker 
Cc: Ezequiel Garcia 
Cc: James Hogan 
---
New for v2.
---
drivers/watchdog/imgpdc_wdt.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/imgpdc_wdt.c
b/drivers/watchdog/imgpdc_wdt.c
index 0deaa4f..89b2abc 100644
--- a/drivers/watchdog/imgpdc_wdt.c
+++ b/drivers/watchdog/imgpdc_wdt.c
@@ -42,7 +42,7 @@
#define PDC_WDT_MIN_TIMEOUT   1
#define PDC_WDT_DEF_TIMEOUT   64

-static int heartbeat = PDC_WDT_DEF_TIMEOUT;
+static int heartbeat;
module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds "
  "(default=" __MODULE_STRING(PDC_WDT_DEF_TIMEOUT) ")");
@@ -195,9 +195,9 @@ static int pdc_wdt_probe(struct platform_device
*pdev)

  ret = watchdog_init_timeout(_wdt->wdt_dev, heartbeat,
>dev);
  if (ret < 0) {
-   pdc_wdt->wdt_dev.timeout =
pdc_wdt->wdt_dev.max_timeout;
+   pdc_wdt->wdt_dev.timeout = PDC_WDT_DEF_TIMEOUT;




The watchdog_init_timeout kerneldoc comment suggests that the old value
should be the default timeout, i.e. that timeout should be set to
PDC_WDT_DEF_TIMEOUT before calling watchdog_init_timeout, rather than
whenever ret < 0.

Indeed, if heartbeat is set to an invalid non-zero value,
watchdog_init_timeout will still try and set timeout from DT, but also
still returns -EINVAL regardless of whether that succeeds, and this
would incorrectly override the timeout from DT with the hardcoded
default.


  dev_warn(>dev,
-"Initial timeout out of range! setting max
timeout\n");
+"Initial timeout out of range! setting default
timeout\n");




It feels wrong for a presumably safe & normal situation (i.e. no default
in DT, which arguably shouldn't contain policy anyway) to show a
warning, but it can also show due to an invalid module parameter (or
invalid DT property) which is most definitely justified.



Agreed. I would suggest to leave that part alone and set the default
prior
to calling watchdog_init_timeout().



Yes, but I think James' concern here was that we'd now get a
dev_warn() in the normal case where no timeout is specified via module
parameter or DT.


My understanding is that watchdog_init_timeout only returns an error if
the second parameter is not 0 and invalid, or if the timeout-sec property
has been provided and is invalid. I am not entirely sure I understand
why you think this is a problem. Can you please explain ?


Unless I've gone completely insane, I'm pretty sure this will return
-EINVAL if timeout_parm is 0 and timeout-sec is not present:

int watchdog_init_timeout(struct watchdog_device *wdd,
 unsigned int timeout_parm, struct device *dev)
{
 unsigned int t = 0;
 int ret = 0;

 watchdog_check_min_max_timeout(wdd);

 /* try to get the timeout module parameter first */
 if (!watchdog_timeout_invalid(wdd, timeout_parm) && timeout_parm) {
 wdd->timeout = timeout_parm;
 return ret;
 }
 if (timeout_parm)
 ret = -EINVAL;

 /* try to get the timeout_sec property */
 if (dev == NULL || dev->of_node == NULL)
 return ret;
 of_property_read_u32(dev->of_node, "timeout-sec", );
 if (!watchdog_timeout_invalid(wdd, t) && t)
 wdd->timeout = t;
 else
 ret = -EINVAL;

 return ret;
}

That said, the behavior you describe makes more sense, so perhaps
watchdog_init_timeout() should be updated to match.



Ah yes, you are right, that last else case. Guess we'll need input from Wim
on how to handle this.

Guenter

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


Re: [alsa-devel] linux-next - strange audio bug

2015-04-02 Thread Valdis . Kletnieks
On Fri, 03 Apr 2015 08:44:12 +0800, Hui Wang said:

> It sounds like the suspend or resume of power management introduces this
> problem. Probably you could reproduce this problem very soon just
> repeatedly suspend and resume the system.

I don't do suspend on this laptop, I poweroff and reboot when I get
wherever I'm going.

However... device-level power management? Hmm..  I *do* remember that
each time I found it dead, I was coming back to my laptop from doing something
else, so the sound would have been idle

commit c4c2533f802d6877803c4d778def43d8a122f27b
Author: Takashi Iwai 
Date:   Tue Mar 3 17:22:12 2015 +0100

ALSA: hda - Fix possible runtime PM refcount unbalance

That landed in next-20150324 - which is broken for me.

Looks worth trying a revert before I bisect, thanks for the hint, will
report back (probably tomorrow) on what happens...


pgp5TEhCQJd47.pgp
Description: PGP signature


Re: [PATCH V2 1/3] watchdog: imgpdc: Allow timeout to be set in device-tree

2015-04-02 Thread Andrew Bresticker
Hi Guenter,

On Thu, Apr 2, 2015 at 6:52 PM, Guenter Roeck  wrote:
> On 04/02/2015 09:46 AM, Andrew Bresticker wrote:
>>
>> On Wed, Apr 1, 2015 at 6:08 PM, Guenter Roeck  wrote:
>>>
>>> On 04/01/2015 03:22 PM, James Hogan wrote:


 Hi Andrew,

 On Wed, Apr 01, 2015 at 10:43:14AM -0700, Andrew Bresticker wrote:
>
>
> Since the heartbeat is statically initialized to its default value,
> watchdog_init_timeout() will never look in the device-tree for a
> timeout-sec value.  Instead of statically initializing heartbeat,
> fall back to the default timeout value if watchdog_init_timeout()
> fails.



 Whoops. Sorry about that. I wasn't aware that a timeout-sec value was
 expected. It isn't mentioned in the DT binding documentation for this
 device :-(.

>
> Signed-off-by: Andrew Bresticker 
> Cc: Ezequiel Garcia 
> Cc: James Hogan 
> ---
> New for v2.
> ---
>drivers/watchdog/imgpdc_wdt.c | 6 +++---
>1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/watchdog/imgpdc_wdt.c
> b/drivers/watchdog/imgpdc_wdt.c
> index 0deaa4f..89b2abc 100644
> --- a/drivers/watchdog/imgpdc_wdt.c
> +++ b/drivers/watchdog/imgpdc_wdt.c
> @@ -42,7 +42,7 @@
>#define PDC_WDT_MIN_TIMEOUT   1
>#define PDC_WDT_DEF_TIMEOUT   64
>
> -static int heartbeat = PDC_WDT_DEF_TIMEOUT;
> +static int heartbeat;
>module_param(heartbeat, int, 0);
>MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds "
>  "(default=" __MODULE_STRING(PDC_WDT_DEF_TIMEOUT) ")");
> @@ -195,9 +195,9 @@ static int pdc_wdt_probe(struct platform_device
> *pdev)
>
>  ret = watchdog_init_timeout(_wdt->wdt_dev, heartbeat,
> >dev);
>  if (ret < 0) {
> -   pdc_wdt->wdt_dev.timeout =
> pdc_wdt->wdt_dev.max_timeout;
> +   pdc_wdt->wdt_dev.timeout = PDC_WDT_DEF_TIMEOUT;



 The watchdog_init_timeout kerneldoc comment suggests that the old value
 should be the default timeout, i.e. that timeout should be set to
 PDC_WDT_DEF_TIMEOUT before calling watchdog_init_timeout, rather than
 whenever ret < 0.

 Indeed, if heartbeat is set to an invalid non-zero value,
 watchdog_init_timeout will still try and set timeout from DT, but also
 still returns -EINVAL regardless of whether that succeeds, and this
 would incorrectly override the timeout from DT with the hardcoded
 default.

>  dev_warn(>dev,
> -"Initial timeout out of range! setting max
> timeout\n");
> +"Initial timeout out of range! setting default
> timeout\n");



 It feels wrong for a presumably safe & normal situation (i.e. no default
 in DT, which arguably shouldn't contain policy anyway) to show a
 warning, but it can also show due to an invalid module parameter (or
 invalid DT property) which is most definitely justified.

>>>
>>> Agreed. I would suggest to leave that part alone and set the default
>>> prior
>>> to calling watchdog_init_timeout().
>>
>>
>> Yes, but I think James' concern here was that we'd now get a
>> dev_warn() in the normal case where no timeout is specified via module
>> parameter or DT.
>>
> My understanding is that watchdog_init_timeout only returns an error if
> the second parameter is not 0 and invalid, or if the timeout-sec property
> has been provided and is invalid. I am not entirely sure I understand
> why you think this is a problem. Can you please explain ?

Unless I've gone completely insane, I'm pretty sure this will return
-EINVAL if timeout_parm is 0 and timeout-sec is not present:

int watchdog_init_timeout(struct watchdog_device *wdd,
unsigned int timeout_parm, struct device *dev)
{
unsigned int t = 0;
int ret = 0;

watchdog_check_min_max_timeout(wdd);

/* try to get the timeout module parameter first */
if (!watchdog_timeout_invalid(wdd, timeout_parm) && timeout_parm) {
wdd->timeout = timeout_parm;
return ret;
}
if (timeout_parm)
ret = -EINVAL;

/* try to get the timeout_sec property */
if (dev == NULL || dev->of_node == NULL)
return ret;
of_property_read_u32(dev->of_node, "timeout-sec", );
if (!watchdog_timeout_invalid(wdd, t) && t)
wdd->timeout = t;
else
ret = -EINVAL;

return ret;
}

That said, the behavior you describe makes more sense, so perhaps
watchdog_init_timeout() should be updated to match.

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

Re: [PATCH v5 2/2] memory: pl353: Add driver for arm pl353 static memory controller

2015-04-02 Thread punnaiah choudary kalluri
Hi Brian,

  This driver has not been reviewed completely. I will address your comments
and send next set of patches.

Thanks,
Punnaiah

On Fri, Apr 3, 2015 at 2:28 AM, Brian Norris
 wrote:
> I'm not following the review of the 'memory' portions much, but has this
> gotten much review? I was looking at the MTD portions when I noticed an
> obvious issue below:
>
> On Tue, Jan 06, 2015 at 11:19:17PM +0530, Punnaiah Choudary Kalluri wrote:
>> Add driver for arm pl353 static memory controller. This controller is
>> used in xilinx zynq soc for interfacing the nand and nor/sram memory
>> devices.
>>
>> Signed-off-by: Punnaiah Choudary Kalluri 
>> ---
>> Changes in v5:
>> - Added pl353_smc_get_clkrate function, made pl353_smc_set_cycles as public
>>   API
>> - Removed nand timing parameter initialization and moved it to nand driver
>> Changes in v4:
>> - Modified driver to support multiple instances
>> - Used sleep instaed of busywait for delay
>> Changes in v3:
>> - None
>> Changes in v2:
>> - Since now the timing parameters are in nano seconds, added logic to convert
>>   them to the cycles
>> ---
>>  drivers/memory/Kconfig   |6 +
>>  drivers/memory/Makefile  |1 +
>>  drivers/memory/pl353-smc.c   |  525 
>> ++
>>  include/linux/memory/pl353-smc.h |   37 +++
>>  4 files changed, 569 insertions(+), 0 deletions(-)
>>  create mode 100644 drivers/memory/pl353-smc.c
>>  create mode 100644 include/linux/memory/pl353-smc.h
>>
>> diff --git a/drivers/memory/Kconfig b/drivers/memory/Kconfig
>> index 6d91c27..9d4880f 100644
>> --- a/drivers/memory/Kconfig
>> +++ b/drivers/memory/Kconfig
>> @@ -85,4 +85,10 @@ config FSL_IFC
>>   bool
>>   depends on FSL_SOC
>>
>> +config PL353_SMC
>> + bool "ARM PL353 Static Memory Controller(SMC) driver"
>
> Space after 'Controller'. i.e.:
>
> bool "ARM PL353 Static Memory Controller (SMC) driver"
>
>> + default y
>
> We almost definitely don't want this to be 'default y', especially given
> that it would then be enabled on all ARM systems. Users could add it
> their configuration themselves if they want it, or you might add it to
> multi_v7_defconfig.
>
>> + depends on ARM
>> + help
>> +   This driver is for the ARM PL353 Static Memory Controller(SMC) 
>> module.
>
> Same spacing issue here.
>
>>  endif
>
> [...]
>
> Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2 1/3] watchdog: imgpdc: Allow timeout to be set in device-tree

2015-04-02 Thread Guenter Roeck

On 04/02/2015 09:46 AM, Andrew Bresticker wrote:

On Wed, Apr 1, 2015 at 6:08 PM, Guenter Roeck  wrote:

On 04/01/2015 03:22 PM, James Hogan wrote:


Hi Andrew,

On Wed, Apr 01, 2015 at 10:43:14AM -0700, Andrew Bresticker wrote:


Since the heartbeat is statically initialized to its default value,
watchdog_init_timeout() will never look in the device-tree for a
timeout-sec value.  Instead of statically initializing heartbeat,
fall back to the default timeout value if watchdog_init_timeout()
fails.



Whoops. Sorry about that. I wasn't aware that a timeout-sec value was
expected. It isn't mentioned in the DT binding documentation for this
device :-(.



Signed-off-by: Andrew Bresticker 
Cc: Ezequiel Garcia 
Cc: James Hogan 
---
New for v2.
---
   drivers/watchdog/imgpdc_wdt.c | 6 +++---
   1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/imgpdc_wdt.c
b/drivers/watchdog/imgpdc_wdt.c
index 0deaa4f..89b2abc 100644
--- a/drivers/watchdog/imgpdc_wdt.c
+++ b/drivers/watchdog/imgpdc_wdt.c
@@ -42,7 +42,7 @@
   #define PDC_WDT_MIN_TIMEOUT   1
   #define PDC_WDT_DEF_TIMEOUT   64

-static int heartbeat = PDC_WDT_DEF_TIMEOUT;
+static int heartbeat;
   module_param(heartbeat, int, 0);
   MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds "
 "(default=" __MODULE_STRING(PDC_WDT_DEF_TIMEOUT) ")");
@@ -195,9 +195,9 @@ static int pdc_wdt_probe(struct platform_device
*pdev)

 ret = watchdog_init_timeout(_wdt->wdt_dev, heartbeat,
>dev);
 if (ret < 0) {
-   pdc_wdt->wdt_dev.timeout = pdc_wdt->wdt_dev.max_timeout;
+   pdc_wdt->wdt_dev.timeout = PDC_WDT_DEF_TIMEOUT;



The watchdog_init_timeout kerneldoc comment suggests that the old value
should be the default timeout, i.e. that timeout should be set to
PDC_WDT_DEF_TIMEOUT before calling watchdog_init_timeout, rather than
whenever ret < 0.

Indeed, if heartbeat is set to an invalid non-zero value,
watchdog_init_timeout will still try and set timeout from DT, but also
still returns -EINVAL regardless of whether that succeeds, and this
would incorrectly override the timeout from DT with the hardcoded
default.


 dev_warn(>dev,
-"Initial timeout out of range! setting max
timeout\n");
+"Initial timeout out of range! setting default
timeout\n");



It feels wrong for a presumably safe & normal situation (i.e. no default
in DT, which arguably shouldn't contain policy anyway) to show a
warning, but it can also show due to an invalid module parameter (or
invalid DT property) which is most definitely justified.



Agreed. I would suggest to leave that part alone and set the default prior
to calling watchdog_init_timeout().


Yes, but I think James' concern here was that we'd now get a
dev_warn() in the normal case where no timeout is specified via module
parameter or DT.


My understanding is that watchdog_init_timeout only returns an error if
the second parameter is not 0 and invalid, or if the timeout-sec property
has been provided and is invalid. I am not entirely sure I understand
why you think this is a problem. Can you please explain ?

Thanks,
Guenter

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


[PATCH 11/18 v3] net/9p/tracing: Export enums in tracepoints to userspace

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

The tracepoints in the 9p code use a lot of enums for the __print_symbolic()
function. These enums are shown in the tracepoint format files, and user
space tools such as trace-cmd does not have the information to parse it.
Add helper macros to export the enums with TRACE_DEFINE_ENUM().

Cc: Aneesh Kumar K.V 
Cc: Eric Van Hensbergen 
Signed-off-by: Steven Rostedt 
---
 include/trace/events/9p.h | 157 ++
 1 file changed, 88 insertions(+), 69 deletions(-)

diff --git a/include/trace/events/9p.h b/include/trace/events/9p.h
index a0666362c111..633ee9ee9778 100644
--- a/include/trace/events/9p.h
+++ b/include/trace/events/9p.h
@@ -6,76 +6,95 @@
 
 #include 
 
+#define P9_MSG_T   \
+   EM( P9_TLERROR, "P9_TLERROR" )  \
+   EM( P9_RLERROR, "P9_RLERROR" )  \
+   EM( P9_TSTATFS, "P9_TSTATFS" )  \
+   EM( P9_RSTATFS, "P9_RSTATFS" )  \
+   EM( P9_TLOPEN,  "P9_TLOPEN" )   \
+   EM( P9_RLOPEN,  "P9_RLOPEN" )   \
+   EM( P9_TLCREATE,"P9_TLCREATE" ) \
+   EM( P9_RLCREATE,"P9_RLCREATE" ) \
+   EM( P9_TSYMLINK,"P9_TSYMLINK" ) \
+   EM( P9_RSYMLINK,"P9_RSYMLINK" ) \
+   EM( P9_TMKNOD,  "P9_TMKNOD" )   \
+   EM( P9_RMKNOD,  "P9_RMKNOD" )   \
+   EM( P9_TRENAME, "P9_TRENAME" )  \
+   EM( P9_RRENAME, "P9_RRENAME" )  \
+   EM( P9_TREADLINK,   "P9_TREADLINK" )\
+   EM( P9_RREADLINK,   "P9_RREADLINK" )\
+   EM( P9_TGETATTR,"P9_TGETATTR" ) \
+   EM( P9_RGETATTR,"P9_RGETATTR" ) \
+   EM( P9_TSETATTR,"P9_TSETATTR" ) \
+   EM( P9_RSETATTR,"P9_RSETATTR" ) \
+   EM( P9_TXATTRWALK,  "P9_TXATTRWALK" )   \
+   EM( P9_RXATTRWALK,  "P9_RXATTRWALK" )   \
+   EM( P9_TXATTRCREATE,"P9_TXATTRCREATE" ) \
+   EM( P9_RXATTRCREATE,"P9_RXATTRCREATE" ) \
+   EM( P9_TREADDIR,"P9_TREADDIR" ) \
+   EM( P9_RREADDIR,"P9_RREADDIR" ) \
+   EM( P9_TFSYNC,  "P9_TFSYNC" )   \
+   EM( P9_RFSYNC,  "P9_RFSYNC" )   \
+   EM( P9_TLOCK,   "P9_TLOCK" )\
+   EM( P9_RLOCK,   "P9_RLOCK" )\
+   EM( P9_TGETLOCK,"P9_TGETLOCK" ) \
+   EM( P9_RGETLOCK,"P9_RGETLOCK" ) \
+   EM( P9_TLINK,   "P9_TLINK" )\
+   EM( P9_RLINK,   "P9_RLINK" )\
+   EM( P9_TMKDIR,  "P9_TMKDIR" )   \
+   EM( P9_RMKDIR,  "P9_RMKDIR" )   \
+   EM( P9_TRENAMEAT,   "P9_TRENAMEAT" )\
+   EM( P9_RRENAMEAT,   "P9_RRENAMEAT" )\
+   EM( P9_TUNLINKAT,   "P9_TUNLINKAT" )\
+   EM( P9_RUNLINKAT,   "P9_RUNLINKAT" )\
+   EM( P9_TVERSION,"P9_TVERSION" ) \
+   EM( P9_RVERSION,"P9_RVERSION" ) \
+   EM( P9_TAUTH,   "P9_TAUTH" )\
+   EM( P9_RAUTH,   "P9_RAUTH" )\
+   EM( P9_TATTACH, "P9_TATTACH" )  \
+   EM( P9_RATTACH, "P9_RATTACH" )  \
+   EM( P9_TERROR,  "P9_TERROR" )   \
+   EM( P9_RERROR,  "P9_RERROR" )   \
+   EM( P9_TFLUSH,  "P9_TFLUSH" )   \
+   EM( P9_RFLUSH,  "P9_RFLUSH" )   \
+   EM( P9_TWALK,   "P9_TWALK" )\
+   EM( P9_RWALK,   "P9_RWALK" )\
+   EM( P9_TOPEN,   "P9_TOPEN" )\
+   EM( P9_ROPEN,   "P9_ROPEN" )\
+   EM( P9_TCREATE, "P9_TCREATE" )  \
+   EM( P9_RCREATE, "P9_RCREATE" )  \
+   EM( P9_TREAD,   

[PATCH 16/18 v3] v4l: Export enums used by tracepoints to user space

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Enums used by tracepoints for __print_symbolic() are shown in the
tracepoint format files with just their names and not their values.
This makes it difficult for user space tools to know how to convert the
binary data into their string representations.

By adding the use of TRACE_DEFINE_ENUM(), the enum names will be mapped
to their values and shown in the tracing file system to let tools
convert the data as necessary.

Cc: Mauro Carvalho Chehab 
Signed-off-by: Steven Rostedt 
---
 include/trace/events/v4l2.h | 75 ++---
 1 file changed, 50 insertions(+), 25 deletions(-)

diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index b9bb1f204693..20112170ff11 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -6,33 +6,58 @@
 
 #include 
 
-#define show_type(type)
   \
-   __print_symbolic(type, \
-   { V4L2_BUF_TYPE_VIDEO_CAPTURE,"VIDEO_CAPTURE" },   \
-   { V4L2_BUF_TYPE_VIDEO_OUTPUT, "VIDEO_OUTPUT" },\
-   { V4L2_BUF_TYPE_VIDEO_OVERLAY,"VIDEO_OVERLAY" },   \
-   { V4L2_BUF_TYPE_VBI_CAPTURE,  "VBI_CAPTURE" }, \
-   { V4L2_BUF_TYPE_VBI_OUTPUT,   "VBI_OUTPUT" },  \
-   { V4L2_BUF_TYPE_SLICED_VBI_CAPTURE,   "SLICED_VBI_CAPTURE" },  \
-   { V4L2_BUF_TYPE_SLICED_VBI_OUTPUT,"SLICED_VBI_OUTPUT" },   \
-   { V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" },\
-   { V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" },\
-   { V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,  "VIDEO_OUTPUT_MPLANE" }, \
-   { V4L2_BUF_TYPE_SDR_CAPTURE,  "SDR_CAPTURE" }, \
-   { V4L2_BUF_TYPE_PRIVATE,  "PRIVATE" })
+/* Enums require being exported to userspace, for user tool parsing */
+#undef EM
+#undef EMe
+#define EM(a, b)   TRACE_DEFINE_ENUM(a);
+#define EMe(a, b)  TRACE_DEFINE_ENUM(a);
+
+#define show_type(type)
\
+   __print_symbolic(type, SHOW_TYPE)
+
+#define SHOW_TYPE  \
+   EM( V4L2_BUF_TYPE_VIDEO_CAPTURE,"VIDEO_CAPTURE" )   \
+   EM( V4L2_BUF_TYPE_VIDEO_OUTPUT, "VIDEO_OUTPUT" )\
+   EM( V4L2_BUF_TYPE_VIDEO_OVERLAY,"VIDEO_OVERLAY" )   \
+   EM( V4L2_BUF_TYPE_VBI_CAPTURE,  "VBI_CAPTURE" ) \
+   EM( V4L2_BUF_TYPE_VBI_OUTPUT,   "VBI_OUTPUT" )  \
+   EM( V4L2_BUF_TYPE_SLICED_VBI_CAPTURE,   "SLICED_VBI_CAPTURE" )  \
+   EM( V4L2_BUF_TYPE_SLICED_VBI_OUTPUT,"SLICED_VBI_OUTPUT" )   \
+   EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" ) \
+   EM( V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" ) \
+   EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,  "VIDEO_OUTPUT_MPLANE" ) \
+   EM( V4L2_BUF_TYPE_SDR_CAPTURE,  "SDR_CAPTURE" ) \
+   EMe(V4L2_BUF_TYPE_PRIVATE,  "PRIVATE" )
+
+SHOW_TYPE
 
 #define show_field(field)  \
-   __print_symbolic(field, \
-   { V4L2_FIELD_ANY,   "ANY" },\
-   { V4L2_FIELD_NONE,  "NONE" },   \
-   { V4L2_FIELD_TOP,   "TOP" },\
-   { V4L2_FIELD_BOTTOM,"BOTTOM" }, \
-   { V4L2_FIELD_INTERLACED,"INTERLACED" }, \
-   { V4L2_FIELD_SEQ_TB,"SEQ_TB" }, \
-   { V4L2_FIELD_SEQ_BT,"SEQ_BT" }, \
-   { V4L2_FIELD_ALTERNATE, "ALTERNATE" },  \
-   { V4L2_FIELD_INTERLACED_TB, "INTERLACED_TB" },  \
-   { V4L2_FIELD_INTERLACED_BT, "INTERLACED_BT" })
+   __print_symbolic(field, SHOW_FIELD)
+
+#define SHOW_FIELD \
+   EM( V4L2_FIELD_ANY, "ANY" ) \
+   EM( V4L2_FIELD_NONE,"NONE" )\
+   EM( V4L2_FIELD_TOP, "TOP" ) \
+   EM( V4L2_FIELD_BOTTOM,  "BOTTOM" )  \
+   EM( V4L2_FIELD_INTERLACED,  "INTERLACED" )  \
+   EM( V4L2_FIELD_SEQ_TB,  "SEQ_TB" )  \
+   EM( V4L2_FIELD_SEQ_BT,  "SEQ_BT" )  \
+   EM( V4L2_FIELD_ALTERNATE,   "ALTERNATE" )   \
+   EM( V4L2_FIELD_INTERLACED_TB,   "INTERLACED_TB" )   \
+   EMe( V4L2_FIELD_INTERLACED_BT,  "INTERLACED_BT" 

[PATCH 02/18 v3] tracing: Add TRACE_SYSTEM_VAR to intel-sst

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

New code will require TRACE_SYSTEM to be a valid C variable name,
but some tracepoints have TRACE_SYSTEM with '-' and not '_', so
it can not be used. Instead, add a TRACE_SYSTEM_VAR that can
give the tracing infrastructure a unique name for the trace system.

Link: http://lkml.kernel.org/r/20150402142831.gt6...@sirena.org.uk

Acked-by: Mark Brown 
Signed-off-by: Steven Rostedt 
---
 include/trace/events/intel-sst.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/trace/events/intel-sst.h b/include/trace/events/intel-sst.h
index 76c72d3f1902..edc24e6dea1b 100644
--- a/include/trace/events/intel-sst.h
+++ b/include/trace/events/intel-sst.h
@@ -1,6 +1,13 @@
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM intel-sst
 
+/*
+ * The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a
+ * legitimate C variable. It is not exported to user space.
+ */
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR intel_sst
+
 #if !defined(_TRACE_INTEL_SST_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_INTEL_SST_H
 
-- 
2.1.4


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


[PATCH 10/18 v3] x86/tlb/trace: Export enums in used by tlb_flush tracepoint

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Have the enums used in __print_symbolic() by the trace_tlb_flush()
tracepoint exported to userpace such that they can be parsed by
userspace tools.

Cc: Dave Hansen 
Signed-off-by: Steven Rostedt 
---
 include/trace/events/tlb.h | 30 +-
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/include/trace/events/tlb.h b/include/trace/events/tlb.h
index 0e7635765153..4250f364a6ca 100644
--- a/include/trace/events/tlb.h
+++ b/include/trace/events/tlb.h
@@ -7,11 +7,31 @@
 #include 
 #include 
 
-#define TLB_FLUSH_REASON   \
-   { TLB_FLUSH_ON_TASK_SWITCH, "flush on task switch" },   \
-   { TLB_REMOTE_SHOOTDOWN, "remote shootdown" },   \
-   { TLB_LOCAL_SHOOTDOWN,  "local shootdown" },\
-   { TLB_LOCAL_MM_SHOOTDOWN,   "local mm shootdown" }
+#define TLB_FLUSH_REASON   \
+   EM(  TLB_FLUSH_ON_TASK_SWITCH,  "flush on task switch" )\
+   EM(  TLB_REMOTE_SHOOTDOWN,  "remote shootdown" )\
+   EM(  TLB_LOCAL_SHOOTDOWN,   "local shootdown" ) \
+   EMe( TLB_LOCAL_MM_SHOOTDOWN,"local mm shootdown" )
+
+/*
+ * First define the enums in TLB_FLUSH_REASON to be exported to userspace
+ * via TRACE_DEFINE_ENUM().
+ */
+#undef EM
+#undef EMe
+#define EM(a,b)TRACE_DEFINE_ENUM(a);
+#define EMe(a,b)   TRACE_DEFINE_ENUM(a);
+
+TLB_FLUSH_REASON
+
+/*
+ * Now redefine the EM() and EMe() macros to map the enums to the strings
+ * that will be printed in the output.
+ */
+#undef EM
+#undef EMe
+#define EM(a,b){ a, b },
+#define EMe(a,b)   { a, b }
 
 TRACE_EVENT_CONDITION(tlb_flush,
 
-- 
2.1.4


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


[PATCH 00/18 v3] tracing: Use TRACE_DEFINE_ENUM() to show enum values

2015-04-02 Thread Steven Rostedt
As there are many tracepoints that use __print_symbolic() to translate
numbers into ASCII strings, and several of these translate enums as
well, it causes a problem for user space tools that read the tracepoint
format files and have to translate the binary data to their associated
strings.

For example, with the tlb_flush tracepoint, we have this in the format
file:

print fmt: "pages:%ld reason:%s (%d)", REC->pages,
 __print_symbolic(REC->reason,
   { TLB_FLUSH_ON_TASK_SWITCH, "flush on task switch" },
   { TLB_REMOTE_SHOOTDOWN, "remote shootdown" },
   { TLB_LOCAL_SHOOTDOWN, "local shootdown" },
   { TLB_LOCAL_MM_SHOOTDOWN, "local mm shootdown" }), REC->reason

Now, userspace does not know what the value of TLB_REMOTE_SHOOTDOWN is.
To solve this, a new macro is created as a helper to allow tracepoints
to export enums they use to userspace. This macro is called,
TRACE_DEFINE_ENUM(), such that

 TRACE_DEFINE_ENUM(TLB_REMOTE_SHOOTDOWN);

will convert the "print fmt"s in the format files to its actual value
and no longer display the enum name.

On boot up (or module load), the enums saved via TRACE_DEFINE_ENUM()
will be searched for in the TP_printk()s of the tracepoints. Logic
knows enough to ignore quoted text.

And the output of the tlb_flush format is now:

print fmt: "pages:%ld reason:%s (%d)", REC->pages,
 __print_symbolic(REC->reason,
   { 0, "flush on task switch" },
   { 1, "remote shootdown" },
   { 2, "local shootdown" },
   { 3, "local mm shootdown" }), REC->reason

And userspace tools can easily parse that without special handling.

For debugging, if CONFIG_TRACE_ENUM_MAP_FILE is enabled, a file is added
in the tracing directory to show what enums were added, their values and
the TRACE_SYSTEM that added them:

 # cat /sys/kernel/debug/tracing/enum_map
TLB_LOCAL_MM_SHOOTDOWN 3 (tlb)
TLB_LOCAL_SHOOTDOWN 2 (tlb)
TLB_REMOTE_SHOOTDOWN 1 (tlb)
TLB_FLUSH_ON_TASK_SWITCH 0 (tlb)

-- Steve

Local SHA1: 6689c330e3a60defc4c89da17cf5d561649bc55b


Steven Rostedt (1):
  tracing/drm: Remove unused TRACE_SYSTEM_STRING define

Steven Rostedt (Red Hat) (17):
  tracing: Add TRACE_SYSTEM_VAR to intel-sst
  tracing: Add TRACE_SYSTEM_VAR to kvm-s390
  tracing: Add TRACE_SYSTEM_VAR to xhci-hcd
  tracing: Give system name a pointer
  tracing: Update trace-event-sample with TRACE_SYSTEM_VAR documentation
  tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values
  tracing: Allow for modules to convert their enums to values
  tracing/samples: Update the trace-event-sample.h with TRACE_DEFINE_ENUM()
  x86/tlb/trace: Export enums in used by tlb_flush tracepoint
  net/9p/tracing: Export enums in tracepoints to userspace
  f2fs: Export the enums in the tracepoints to userspace
  irq/tracing: Export enums in tracepoints to user space
  mm: tracing: Export enums in tracepoints to user space
  SUNRPC: Export enums in tracepoints to user space
  v4l: Export enums used by tracepoints to user space
  writeback: Export enums used by tracepoint to user space
  tracing: Add enum_map file to show enums that have been mapped


 arch/s390/kvm/trace-s390.h |   7 +
 drivers/gpu/drm/drm_trace.h|   1 -
 drivers/gpu/drm/i915/i915_trace.h  |   1 -
 drivers/gpu/drm/radeon/radeon_trace.h  |   1 -
 drivers/usb/host/xhci-trace.h  |   7 +
 include/asm-generic/vmlinux.lds.h  |   5 +-
 include/linux/ftrace_event.h   |   4 +-
 include/linux/module.h |   2 +
 include/linux/tracepoint.h |   8 +
 include/trace/events/9p.h  | 157 ---
 include/trace/events/f2fs.h|  30 +++
 include/trace/events/intel-sst.h   |   7 +
 include/trace/events/irq.h |  39 ++--
 include/trace/events/migrate.h |  42 +++-
 include/trace/events/sunrpc.h  |  62 --
 include/trace/events/tlb.h |  30 ++-
 include/trace/events/v4l2.h|  75 ---
 include/trace/events/writeback.h   |  33 +++-
 include/trace/ftrace.h |  41 +++-
 kernel/module.c|   3 +
 kernel/trace/Kconfig   |  28 +++
 kernel/trace/trace.c   | 304 -
 kernel/trace/trace.h   |   2 +
 kernel/trace/trace_events.c| 121 +++-
 samples/trace_events/trace-events-sample.h |  84 +++-
 25 files changed, 932 insertions(+), 162 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/


[PATCH 07/18 v3] tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Several tracepoints use the helper functions __print_symbolic() or
__print_flags() and pass in enums that do the mapping between the
binary data stored and the value to print. This works well for reading
the ASCII trace files, but when the data is read via userspace tools
such as perf and trace-cmd, the conversion of the binary value to a
human string format is lost if an enum is used, as userspace does not
have access to what the ENUM is.

For example, the tracepoint trace_tlb_flush() has:

 __print_symbolic(REC->reason,
{ TLB_FLUSH_ON_TASK_SWITCH, "flush on task switch" },
{ TLB_REMOTE_SHOOTDOWN, "remote shootdown" },
{ TLB_LOCAL_SHOOTDOWN, "local shootdown" },
{ TLB_LOCAL_MM_SHOOTDOWN, "local mm shootdown" })

Which maps the enum values to the strings they represent. But perf and
trace-cmd do no know what value TLB_LOCAL_MM_SHOOTDOWN is, and would
not be able to map it.

With TRACE_DEFINE_ENUM(), developers can place these in the event header
files and ftrace will convert the enums to their values:

By adding:

 TRACE_DEFINE_ENUM(TLB_FLUSH_ON_TASK_SWITCH);
 TRACE_DEFINE_ENUM(TLB_REMOTE_SHOOTDOWN);
 TRACE_DEFINE_ENUM(TLB_LOCAL_SHOOTDOWN);
 TRACE_DEFINE_ENUM(TLB_LOCAL_MM_SHOOTDOWN);

 $ cat /sys/kernel/debug/tracing/events/tlb/tlb_flush/format
[...]
 __print_symbolic(REC->reason,
{ 0, "flush on task switch" },
{ 1, "remote shootdown" },
{ 2, "local shootdown" },
{ 3, "local mm shootdown" })

The above is what userspace expects to see, and tools do not need to
be modified to parse them.

Cc: Guilherme Cox 
Cc: Tony Luck 
Cc: Xie XiuQi 
Signed-off-by: Steven Rostedt 
---
 include/asm-generic/vmlinux.lds.h |   5 +-
 include/linux/ftrace_event.h  |   2 +-
 include/linux/tracepoint.h|   8 +++
 include/trace/ftrace.h|  22 ++-
 kernel/trace/trace.c  |  26 -
 kernel/trace/trace.h  |   2 +
 kernel/trace/trace_events.c   | 119 ++
 7 files changed, 178 insertions(+), 6 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h 
b/include/asm-generic/vmlinux.lds.h
index ac78910d7416..f8e8b34dc427 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -124,7 +124,10 @@
 #define FTRACE_EVENTS(). = ALIGN(8);   
\
VMLINUX_SYMBOL(__start_ftrace_events) = .;  \
*(_ftrace_events)   \
-   VMLINUX_SYMBOL(__stop_ftrace_events) = .;
+   VMLINUX_SYMBOL(__stop_ftrace_events) = .;   \
+   VMLINUX_SYMBOL(__start_ftrace_enum_maps) = .;   \
+   *(_ftrace_enum_map) \
+   VMLINUX_SYMBOL(__stop_ftrace_enum_maps) = .;
 #else
 #define FTRACE_EVENTS()
 #endif
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 62b8fac7ded5..112cf49d9576 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -285,7 +285,7 @@ struct ftrace_event_call {
struct tracepoint   *tp;
};
struct trace_event  event;
-   const char  *print_fmt;
+   char*print_fmt;
struct event_filter *filter;
void*mod;
void*data;
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index c72851328ca9..a5f7f3ecafa3 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -36,6 +36,12 @@ struct tracepoint {
struct tracepoint_func __rcu *funcs;
 };
 
+struct trace_enum_map {
+   const char  *system;
+   const char  *enum_string;
+   unsigned long   enum_value;
+};
+
 extern int
 tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data);
 extern int
@@ -87,6 +93,8 @@ extern void syscall_unregfunc(void);
 
 #define PARAMS(args...) args
 
+#define TRACE_DEFINE_ENUM(x)
+
 #endif /* _LINUX_TRACEPOINT_H */
 
 /*
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 2f9b95b6d3fb..37d4b10b111d 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -33,6 +33,19 @@
 
 TRACE_MAKE_SYSTEM_STR();
 
+#undef TRACE_DEFINE_ENUM
+#define TRACE_DEFINE_ENUM(a)   \
+   static struct trace_enum_map __used __initdata  \
+   __##TRACE_SYSTEM##_##a =\
+   {   \
+   .system = TRACE_SYSTEM_STRING,  \
+   .enum_string = #a,  \
+   .enum_value = a \
+   };  \
+   static struct trace_enum_map __used \
+   __attribute__((section("_ftrace_enum_map")))\
+   *TRACE_SYSTEM##_##a = 

[PATCH 14/18 v3] mm: tracing: Export enums in tracepoints to user space

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

The enums used in tracepoints with __print_symbolic() have their
names shown in the tracepoint format files and not their values.
This makes it difficult for user space tools to convert the binary
data to the strings as user space does not know what those enums
are about.

By having them use TRACE_DEFINE_ENUM(), the names of the enums will
be mapped to the values and shown to user space.

Signed-off-by: Steven Rostedt 
---
 include/trace/events/migrate.h | 42 --
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/include/trace/events/migrate.h b/include/trace/events/migrate.h
index dd2b5467d905..539b25a76111 100644
--- a/include/trace/events/migrate.h
+++ b/include/trace/events/migrate.h
@@ -7,18 +7,40 @@
 #include 
 
 #define MIGRATE_MODE   \
-   {MIGRATE_ASYNC, "MIGRATE_ASYNC"},   \
-   {MIGRATE_SYNC_LIGHT,"MIGRATE_SYNC_LIGHT"},  \
-   {MIGRATE_SYNC,  "MIGRATE_SYNC"} 
+   EM( MIGRATE_ASYNC,  "MIGRATE_ASYNC")\
+   EM( MIGRATE_SYNC_LIGHT, "MIGRATE_SYNC_LIGHT")   \
+   EMe(MIGRATE_SYNC,   "MIGRATE_SYNC")
+
 
 #define MIGRATE_REASON \
-   {MR_COMPACTION, "compaction"},  \
-   {MR_MEMORY_FAILURE, "memory_failure"},  \
-   {MR_MEMORY_HOTPLUG, "memory_hotplug"},  \
-   {MR_SYSCALL,"syscall_or_cpuset"},   \
-   {MR_MEMPOLICY_MBIND,"mempolicy_mbind"}, \
-   {MR_NUMA_MISPLACED, "numa_misplaced"},  \
-   {MR_CMA,"cma"}
+   EM( MR_COMPACTION,  "compaction")   \
+   EM( MR_MEMORY_FAILURE,  "memory_failure")   \
+   EM( MR_MEMORY_HOTPLUG,  "memory_hotplug")   \
+   EM( MR_SYSCALL, "syscall_or_cpuset")\
+   EM( MR_MEMPOLICY_MBIND, "mempolicy_mbind")  \
+   EM( MR_NUMA_MISPLACED,  "numa_misplaced")   \
+   EMe(MR_CMA, "cma")
+
+/*
+ * First define the enums in the above macros to be exported to userspace
+ * via TRACE_DEFINE_ENUM().
+ */
+#undef EM
+#undef EMe
+#define EM(a, b)   TRACE_DEFINE_ENUM(a);
+#define EMe(a, b)  TRACE_DEFINE_ENUM(a);
+
+MIGRATE_MODE
+MIGRATE_REASON
+
+/*
+ * Now redefine the EM() and EMe() macros to map the enums to the strings
+ * that will be printed in the output.
+ */
+#undef EM
+#undef EMe
+#define EM(a, b)   {a, b},
+#define EMe(a, b)  {a, b}
 
 TRACE_EVENT(mm_migrate_pages,
 
-- 
2.1.4


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


[PATCH 17/18 v3] writeback: Export enums used by tracepoint to user space

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

The enums used in tracepoints for __print_symbolic() do not have their
values shown in the tracepoint format files and this makes it difficult
for user space tools to convert the binary values to the strings they
are to represent.

Add TRACE_DEFINE_ENUM(x) macros to export the enum names to their values
to make the tracing output from user space tools more robust.

Cc: Dave Chinner 
Cc: Jens Axboe 
Signed-off-by: Steven Rostedt 
---
 include/trace/events/writeback.h | 33 +
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 5a14ead59696..880dd7437172 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -23,15 +23,32 @@
{I_REFERENCED,  "I_REFERENCED"} \
)
 
+/* enums need to be exported to user space */
+#undef EM
+#undef EMe
+#define EM(a,b)TRACE_DEFINE_ENUM(a);
+#define EMe(a,b)   TRACE_DEFINE_ENUM(a);
+
 #define WB_WORK_REASON \
-   {WB_REASON_BACKGROUND,  "background"},  \
-   {WB_REASON_TRY_TO_FREE_PAGES,   "try_to_free_pages"},   \
-   {WB_REASON_SYNC,"sync"},\
-   {WB_REASON_PERIODIC,"periodic"},\
-   {WB_REASON_LAPTOP_TIMER,"laptop_timer"},\
-   {WB_REASON_FREE_MORE_MEM,   "free_more_memory"},\
-   {WB_REASON_FS_FREE_SPACE,   "fs_free_space"},   \
-   {WB_REASON_FORKER_THREAD,   "forker_thread"}
+   EM( WB_REASON_BACKGROUND,   "background")   \
+   EM( WB_REASON_TRY_TO_FREE_PAGES,"try_to_free_pages")\
+   EM( WB_REASON_SYNC, "sync") \
+   EM( WB_REASON_PERIODIC, "periodic") \
+   EM( WB_REASON_LAPTOP_TIMER, "laptop_timer") \
+   EM( WB_REASON_FREE_MORE_MEM,"free_more_memory") \
+   EM( WB_REASON_FS_FREE_SPACE,"fs_free_space")\
+   EMe(WB_REASON_FORKER_THREAD,"forker_thread")
+
+WB_WORK_REASON
+
+/*
+ * Now redefine the EM() and EMe() macros to map the enums to the strings
+ * that will be printed in the output.
+ */
+#undef EM
+#undef EMe
+#define EM(a,b){ a, b },
+#define EMe(a,b)   { a, b }
 
 struct wb_writeback_work;
 
-- 
2.1.4


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


[PATCH 15/18 v3] SUNRPC: Export enums in tracepoints to user space

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

The enums used in the tracepoints for __print_symbolic() have their
names shown in the tracepoint format files. User space tools do not know
how to convert those names into their values to be able to convert the
binary data.

Use TRACE_DEFINE_ENUM() to export the enum names to their values for
userspace to do the parsing correctly.

Cc: Trond Myklebust 
Signed-off-by: Steven Rostedt 
---
 include/trace/events/sunrpc.h | 62 ++-
 1 file changed, 44 insertions(+), 18 deletions(-)

diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
index b9c1dc6c825a..fd1a02cb3c82 100644
--- a/include/trace/events/sunrpc.h
+++ b/include/trace/events/sunrpc.h
@@ -179,27 +179,53 @@ DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,
 
 );
 
+/*
+ * First define the enums in the below macros to be exported to userspace
+ * via TRACE_DEFINE_ENUM().
+ */
+#undef EM
+#undef EMe
+#define EM(a, b)   TRACE_DEFINE_ENUM(a);
+#define EMe(a, b)  TRACE_DEFINE_ENUM(a);
+
+#define RPC_SHOW_SOCKET\
+   EM( SS_FREE, "FREE" )   \
+   EM( SS_UNCONNECTED, "UNCONNECTED" ) \
+   EM( SS_CONNECTING, "CONNECTING," )  \
+   EM( SS_CONNECTED, "CONNECTED," )\
+   EMe(SS_DISCONNECTING, "DISCONNECTING" )
+
 #define rpc_show_socket_state(state) \
-   __print_symbolic(state, \
-   { SS_FREE, "FREE" }, \
-   { SS_UNCONNECTED, "UNCONNECTED" }, \
-   { SS_CONNECTING, "CONNECTING," }, \
-   { SS_CONNECTED, "CONNECTED," }, \
-   { SS_DISCONNECTING, "DISCONNECTING" })
+   __print_symbolic(state, RPC_SHOW_SOCKET)
+
+RPC_SHOW_SOCKET
+
+#define RPC_SHOW_SOCK  \
+   EM( TCP_ESTABLISHED, "ESTABLISHED" )\
+   EM( TCP_SYN_SENT, "SYN_SENT" )  \
+   EM( TCP_SYN_RECV, "SYN_RECV" )  \
+   EM( TCP_FIN_WAIT1, "FIN_WAIT1" )\
+   EM( TCP_FIN_WAIT2, "FIN_WAIT2" )\
+   EM( TCP_TIME_WAIT, "TIME_WAIT" )\
+   EM( TCP_CLOSE, "CLOSE" )\
+   EM( TCP_CLOSE_WAIT, "CLOSE_WAIT" )  \
+   EM( TCP_LAST_ACK, "LAST_ACK" )  \
+   EM( TCP_LISTEN, "LISTEN" )  \
+   EMe( TCP_CLOSING, "CLOSING" )
 
 #define rpc_show_sock_state(state) \
-   __print_symbolic(state, \
-   { TCP_ESTABLISHED, "ESTABLISHED" }, \
-   { TCP_SYN_SENT, "SYN_SENT" }, \
-   { TCP_SYN_RECV, "SYN_RECV" }, \
-   { TCP_FIN_WAIT1, "FIN_WAIT1" }, \
-   { TCP_FIN_WAIT2, "FIN_WAIT2" }, \
-   { TCP_TIME_WAIT, "TIME_WAIT" }, \
-   { TCP_CLOSE, "CLOSE" }, \
-   { TCP_CLOSE_WAIT, "CLOSE_WAIT" }, \
-   { TCP_LAST_ACK, "LAST_ACK" }, \
-   { TCP_LISTEN, "LISTEN" }, \
-   { TCP_CLOSING, "CLOSING" })
+   __print_symbolic(state, RPC_SHOW_SOCK)
+
+RPC_SHOW_SOCK
+
+/*
+ * Now redefine the EM() and EMe() macros to map the enums to the strings
+ * that will be printed in the output.
+ */
+#undef EM
+#undef EMe
+#define EM(a, b)   {a, b},
+#define EMe(a, b)  {a, b}
 
 DECLARE_EVENT_CLASS(xs_socket_event,
 
-- 
2.1.4


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


[PATCH 12/18 v3] f2fs: Export the enums in the tracepoints to userspace

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

The tracepoints that use __print_symbolic() use enums as the value
to convert to strings. Unfortunately, the format files for these
tracepoints show the enum name and not their value. This causes some
userspace tools not to know how to convert __print_symbolic() to
their strings.

Add TRACE_DEFINE_ENUM() macros to export the enums used to userspace
to let those tools know what those enum values are.

Cc: Namjae Jeon 
Cc: Pankaj Kumar 
Cc: Jaegeuk Kim 
Signed-off-by: Steven Rostedt 
---
 include/trace/events/f2fs.h | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 5422dbfaf97d..36f4536b6149 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -9,6 +9,36 @@
 #define show_dev(entry)MAJOR(entry->dev), MINOR(entry->dev)
 #define show_dev_ino(entry)show_dev(entry), (unsigned long)entry->ino
 
+TRACE_DEFINE_ENUM(NODE);
+TRACE_DEFINE_ENUM(DATA);
+TRACE_DEFINE_ENUM(META);
+TRACE_DEFINE_ENUM(META_FLUSH);
+TRACE_DEFINE_ENUM(CURSEG_HOT_DATA);
+TRACE_DEFINE_ENUM(CURSEG_WARM_DATA);
+TRACE_DEFINE_ENUM(CURSEG_COLD_DATA);
+TRACE_DEFINE_ENUM(CURSEG_HOT_NODE);
+TRACE_DEFINE_ENUM(CURSEG_WARM_NODE);
+TRACE_DEFINE_ENUM(CURSEG_COLD_NODE);
+TRACE_DEFINE_ENUM(NO_CHECK_TYPE);
+TRACE_DEFINE_ENUM(GC_GREEDY);
+TRACE_DEFINE_ENUM(GC_CB);
+TRACE_DEFINE_ENUM(FG_GC);
+TRACE_DEFINE_ENUM(BG_GC);
+TRACE_DEFINE_ENUM(LFS);
+TRACE_DEFINE_ENUM(SSR);
+TRACE_DEFINE_ENUM(__REQ_RAHEAD);
+TRACE_DEFINE_ENUM(__REQ_WRITE);
+TRACE_DEFINE_ENUM(__REQ_SYNC);
+TRACE_DEFINE_ENUM(__REQ_NOIDLE);
+TRACE_DEFINE_ENUM(__REQ_FLUSH);
+TRACE_DEFINE_ENUM(__REQ_FUA);
+TRACE_DEFINE_ENUM(__REQ_PRIO);
+TRACE_DEFINE_ENUM(__REQ_META);
+TRACE_DEFINE_ENUM(CP_UMOUNT);
+TRACE_DEFINE_ENUM(CP_FASTBOOT);
+TRACE_DEFINE_ENUM(CP_SYNC);
+TRACE_DEFINE_ENUM(CP_DISCARD);
+
 #define show_block_type(type)  \
__print_symbolic(type,  \
{ NODE, "NODE" },   \
-- 
2.1.4


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


Re: [RFC PATCH 00/11] an introduction of library operating system for Linux (LibOS)

2015-04-02 Thread Hajime Tazaki

Thanks Rusty,

At Wed, 01 Apr 2015 11:59:39 +1030,
Rusty Russell wrote:
> 
> Hajime Tazaki  writes:
> > the issue here is the decision between 'no-ops' and
> > 'assert(false)' depends on the context. an auto-generated
> > mechanism needs some hand-written parameters I think.
> 
> Yes, I used auto-generated (fprintf, abort) stubs for similar testing in
> pettycoin, where if it failed to link it would generate such stubs
> for undefined symbols.
> 
> It's not a panacea, but it helps speed up rejiggin after code changes.
> Generating noop stubs can actually make that process slower, as you can
> get failures because you now need to do something in that stub.

is it the following ? it's really cool stuff !

https://github.com/rustyrussell/pettycoin/blob/master/test/mockup.sh
 
-- Hajime
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/18 v3] tracing: Add TRACE_SYSTEM_VAR to xhci-hcd

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

New code will require TRACE_SYSTEM to be a valid C variable name,
but some tracepoints have TRACE_SYSTEM with '-' and not '_', so
it can not be used. Instead, add a TRACE_SYSTEM_VAR that can
give the tracing infrastructure a unique name for the trace system.

Cc: Xenia Ragiadakou 
Cc: Sarah Sharp 
Signed-off-by: Steven Rostedt 
---
 drivers/usb/host/xhci-trace.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
index dde3959b7a33..59c05653b2ea 100644
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -14,6 +14,13 @@
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM xhci-hcd
 
+/*
+ * The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a
+ * legitimate C variable. It is not exported to user space.
+ */
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR xhci_hcd
+
 #if !defined(__XHCI_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
 #define __XHCI_TRACE_H
 
-- 
2.1.4


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


[PATCH 05/18 v3] tracing: Give system name a pointer

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Normally the compiler will use the same pointer for a string throughout
the file. But there's no guarantee of that happening. Later changes will
require that all events have the same pointer to the system string.

Name the system string and have all events point to it.

Testing this, it did not increases the size of the text, except for the
notes section, which should not harm the real size any.

Signed-off-by: Steven Rostedt 
---
 include/linux/ftrace_event.h |  2 +-
 include/trace/ftrace.h   | 19 +--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index c674ee8f7fca..62b8fac7ded5 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -202,7 +202,7 @@ enum trace_reg {
 struct ftrace_event_call;
 
 struct ftrace_event_class {
-   char*system;
+   const char  *system;
void*probe;
 #ifdef CONFIG_PERF_EVENTS
void*perf_probe;
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 41bf65f04dd9..2f9b95b6d3fb 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -18,6 +18,21 @@
 
 #include 
 
+#ifndef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR TRACE_SYSTEM
+#endif
+
+#define __app__(x, y) str__##x##y
+#define __app(x, y) __app__(x, y)
+
+#define TRACE_SYSTEM_STRING __app(TRACE_SYSTEM_VAR,__trace_system_name)
+
+#define TRACE_MAKE_SYSTEM_STR()\
+   static const char TRACE_SYSTEM_STRING[] =   \
+   __stringify(TRACE_SYSTEM)
+
+TRACE_MAKE_SYSTEM_STR();
+
 /*
  * DECLARE_EVENT_CLASS can be used to add a generic function
  * handlers for events. That is, if all events have the same
@@ -105,7 +120,6 @@
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
-
 /*
  * Stage 2 of the trace events.
  *
@@ -692,7 +706,7 @@ static inline void ftrace_test_probe_##call(void)   
\
 _TRACE_PERF_PROTO(call, PARAMS(proto));
\
 static const char print_fmt_##call[] = print;  \
 static struct ftrace_event_class __used __refdata event_class_##call = { \
-   .system = __stringify(TRACE_SYSTEM),\
+   .system = TRACE_SYSTEM_STRING,  \
.define_fields  = ftrace_define_fields_##call,  \
.fields = LIST_HEAD_INIT(event_class_##call.fields),\
.raw_init   = trace_event_raw_init, \
@@ -735,6 +749,7 @@ __attribute__((section("_ftrace_events"))) *__event_##call 
= _##call
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
+#undef TRACE_SYSTEM_VAR
 
 #ifdef CONFIG_PERF_EVENTS
 
-- 
2.1.4


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


[PATCH 09/18 v3] tracing/samples: Update the trace-event-sample.h with TRACE_DEFINE_ENUM()

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Document the use of TRACE_DEFINE_ENUM() by adding enums to the
trace-event-sample.h and using this macro to convert them in the format
files.

Also update the comments and sho the use of __print_symbolic() and
__print_flags() as well as adding comments abount __print_array().

Signed-off-by: Steven Rostedt 
---
 samples/trace_events/trace-events-sample.h | 64 +-
 1 file changed, 63 insertions(+), 1 deletion(-)

diff --git a/samples/trace_events/trace-events-sample.h 
b/samples/trace_events/trace-events-sample.h
index 19405f18cc8a..8965d1bb8811 100644
--- a/samples/trace_events/trace-events-sample.h
+++ b/samples/trace_events/trace-events-sample.h
@@ -198,8 +198,30 @@ static inline int __length_of(const int *list)
;
return i;
 }
+
+enum {
+   TRACE_SAMPLE_FOO = 2,
+   TRACE_SAMPLE_BAR = 4,
+   TRACE_SAMPLE_ZOO = 8,
+};
 #endif
 
+/*
+ * If enums are used in the TP_printk(), their names will be shown in
+ * format files and not their values. This can cause problems with user
+ * space programs that parse the format files to know how to translate
+ * the raw binary trace output into human readable text.
+ *
+ * To help out user space programs, any enum that is used in the TP_printk()
+ * should be defined by TRACE_DEFINE_ENUM() macro. All that is needed to
+ * be done is to add this macro with the enum within it in the trace
+ * header file, and it will be converted in the output.
+ */
+
+TRACE_DEFINE_ENUM(TRACE_SAMPLE_FOO);
+TRACE_DEFINE_ENUM(TRACE_SAMPLE_BAR);
+TRACE_DEFINE_ENUM(TRACE_SAMPLE_ZOO);
+
 TRACE_EVENT(foo_bar,
 
TP_PROTO(const char *foo, int bar, const int *lst,
@@ -224,7 +246,47 @@ TRACE_EVENT(foo_bar,
__assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus());
),
 
-   TP_printk("foo %s %d %s %s (%s)", __entry->foo, __entry->bar,
+   TP_printk("foo %s %d %s %s %s %s (%s)", __entry->foo, __entry->bar,
+
+/*
+ * Notice here the use of some helper functions. This includes:
+ *
+ *  __print_symbolic( variable, { value, "string" }, ... ),
+ *
+ *The variable is tested against each value of the { } pair. If
+ *the variable matches one of the values, then it will print the
+ *string in that pair. If non are matched, it returns a string
+ *version of the number (if __entry->bar == 7 then "7" is returned).
+ */
+ __print_symbolic(__entry->bar,
+  { 0, "zero" },
+  { TRACE_SAMPLE_FOO, "TWO" },
+  { TRACE_SAMPLE_BAR, "FOUR" },
+  { TRACE_SAMPLE_ZOO, "EIGHT" },
+  { 10, "TEN" }
+ ),
+
+/*
+ *  __print_flags( variable, "delim", { value, "flag" }, ... ),
+ *
+ *This is similar to __print_symbolic, except that it tests the bits
+ *of the value. If ((FLAG & variable) == FLAG) then the string is
+ *printed. If more than one flag matches, then each one that does is
+ *also printed with delim in between them.
+ *If not all bits are accounted for, then the not found bits will be
+ *added in hex format: 0x506 will show BIT2|BIT4|0x500
+ */
+ __print_flags(__entry->bar, "|",
+   { 1, "BIT1" },
+   { 2, "BIT2" },
+   { 4, "BIT3" },
+   { 8, "BIT4" }
+ ),
+/*
+ *  __print_array( array, len, element_size )
+ *
+ *This prints out the array that is defined by __array in a nice format.
+ */
  __print_array(__get_dynamic_array(list),
__get_dynamic_array_len(list),
sizeof(int)),
-- 
2.1.4


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


[PATCH 18/18 v3] tracing: Add enum_map file to show enums that have been mapped

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Add a enum_map file in the tracing directory to see what enums have been
saved to convert in the print fmt files.

As this requires the enum mapping to be persistent in memory, it is only
created if the new config option CONFIG_TRACE_ENUM_MAP_FILE is enabled.
This is for debugging and will increase the persistent memory footprint
of the kernel.

Signed-off-by: Steven Rostedt 
---
 kernel/trace/Kconfig |  28 ++
 kernel/trace/trace.c | 245 ++-
 2 files changed, 269 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index a5da09c899dd..fedbdd7d5d1e 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -599,6 +599,34 @@ config RING_BUFFER_STARTUP_TEST
 
 If unsure, say N
 
+config TRACE_ENUM_MAP_FILE
+   bool "Show enum mappings for trace events"
+   depends on TRACING
+   help
+The "print fmt" of the trace events will show the enum names instead
+   of their values. This can cause problems for user space tools that
+   use this string to parse the raw data as user space does not know
+   how to convert the string to its value.
+
+   To fix this, there's a special macro in the kernel that can be used
+   to convert the enum into its value. If this macro is used, then the
+   print fmt strings will have the enums converted to their values.
+
+   If something does not get converted properly, this option can be
+   used to show what enums the kernel tried to convert.
+
+   This option is for debugging the enum conversions. A file is created
+   in the tracing directory called "enum_map" that will show the enum
+   names matched with their values and what trace event system they
+   belong too.
+
+   Normally, the mapping of the strings to values will be freed after
+   boot up or module load. With this option, they will not be freed, as
+   they are needed for the "enum_map" file. Enabling this option will
+   increase the memory footprint of the running kernel.
+
+   If unsure, say N
+
 endif # FTRACE
 
 endif # TRACING_SUPPORT
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 28e6654e640d..39e69568302e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -123,6 +123,42 @@ enum ftrace_dump_mode ftrace_dump_on_oops;
 /* When set, tracing will stop when a WARN*() is hit */
 int __disable_trace_on_warning;
 
+#ifdef CONFIG_TRACE_ENUM_MAP_FILE
+/* Map of enums to their values, for "enum_map" file */
+struct trace_enum_map_head {
+   struct module   *mod;
+   unsigned long   length;
+};
+
+union trace_enum_map_item;
+
+struct trace_enum_map_tail {
+   /*
+* "end" is first and points to NULL as it must be different
+* than "mod" or "enum_string"
+*/
+   union trace_enum_map_item   *next;
+   const char  *end;   /* points to NULL */
+};
+
+static DEFINE_MUTEX(trace_enum_mutex);
+
+/*
+ * The trace_enum_maps are saved in an array with two extra elements,
+ * one at the beginning, and one at the end. The beginning item contains
+ * the count of the saved maps (head.length), and the module they
+ * belong to if not built in (head.mod). The ending item contains a
+ * pointer to the next array of saved enum_map items.
+ */
+union trace_enum_map_item {
+   struct trace_enum_map   map;
+   struct trace_enum_map_head  head;
+   struct trace_enum_map_tail  tail;
+};
+
+static union trace_enum_map_item *trace_enum_maps;
+#endif /* CONFIG_TRACE_ENUM_MAP_FILE */
+
 static int tracing_set_tracer(struct trace_array *tr, const char *buf);
 
 #define MAX_TRACER_SIZE100
@@ -3908,7 +3944,169 @@ static const struct file_operations 
tracing_saved_cmdlines_size_fops = {
.write  = tracing_saved_cmdlines_size_write,
 };
 
-static void trace_insert_enum_map(struct trace_enum_map **start, int len)
+#ifdef CONFIG_TRACE_ENUM_MAP_FILE
+static union trace_enum_map_item *
+update_enum_map(union trace_enum_map_item *ptr)
+{
+   if (!ptr->map.enum_string) {
+   if (ptr->tail.next) {
+   ptr = ptr->tail.next;
+   /* Set ptr to the next real item (skip head) */
+   ptr++;
+   } else
+   return NULL;
+   }
+   return ptr;
+}
+
+static void *enum_map_next(struct seq_file *m, void *v, loff_t *pos)
+{
+   union trace_enum_map_item *ptr = v;
+
+   /*
+* Paranoid! If ptr points to end, we don't want to increment past it.
+* This really should never happen.
+*/
+   ptr = update_enum_map(ptr);
+   if (WARN_ON_ONCE(!ptr))
+   return NULL;
+
+   ptr++;
+
+   (*pos)++;
+
+   ptr = update_enum_map(ptr);
+
+   return ptr;
+}
+
+static void *enum_map_start(struct seq_file *m, 

[PATCH 03/18 v3] tracing: Add TRACE_SYSTEM_VAR to kvm-s390

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

New code will require TRACE_SYSTEM to be a valid C variable name,
but some tracepoints have TRACE_SYSTEM with '-' and not '_', so
it can not be used. Instead, add a TRACE_SYSTEM_VAR that can
give the tracing infrastructure a unique name for the trace system.

Link: http://lkml.kernel.org/r/20150402111500.5e52c1ed.cornelia.h...@de.ibm.com

Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: David Hildenbrand 
Cc: Christian Borntraeger 
Acked-by: Cornelia Huck 
Signed-off-by: Steven Rostedt 
---
 arch/s390/kvm/trace-s390.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/s390/kvm/trace-s390.h b/arch/s390/kvm/trace-s390.h
index 653a7ec09ef5..3208d33a48cb 100644
--- a/arch/s390/kvm/trace-s390.h
+++ b/arch/s390/kvm/trace-s390.h
@@ -10,6 +10,13 @@
 #define TRACE_INCLUDE_FILE trace-s390
 
 /*
+ * The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a
+ * legitimate C variable. It is not exported to user space.
+ */
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR kvm_s390
+
+/*
  * Trace point for the creation of the kvm instance.
  */
 TRACE_EVENT(kvm_s390_create_vm,
-- 
2.1.4


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


[PATCH 06/18 v3] tracing: Update trace-event-sample with TRACE_SYSTEM_VAR documentation

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Add documentation about TRACE_SYSTEM needing to be alpha-numeric or with
underscores, and that if it is not, then the use of TRACE_SYSTEM_VAR is
required to make something that is.

An example of this is shown in samples/trace_events/trace-events-sample.h

Signed-off-by: Steven Rostedt 
---
 samples/trace_events/trace-events-sample.h | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/samples/trace_events/trace-events-sample.h 
b/samples/trace_events/trace-events-sample.h
index a2c8b02b6359..19405f18cc8a 100644
--- a/samples/trace_events/trace-events-sample.h
+++ b/samples/trace_events/trace-events-sample.h
@@ -22,7 +22,25 @@
  * protection, just like TRACE_INCLUDE_FILE.
  */
 #undef TRACE_SYSTEM
-#define TRACE_SYSTEM sample
+#define TRACE_SYSTEM sample-trace
+
+/*
+ * TRACE_SYSTEM is expected to be a C valid variable (alpha-numeric
+ * and underscore), although it may start with numbers. If for some
+ * reason it is not, you need to add the following lines:
+ */
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR sample_trace
+/*
+ * But the above is only needed if TRACE_SYSTEM is not alpha-numeric
+ * and underscored. By default, TRACE_SYSTEM_VAR will be equal to
+ * TRACE_SYSTEM. As TRACE_SYSTEM_VAR must be alpha-numeric, if
+ * TRACE_SYSTEM is not, then TRACE_SYSTEM_VAR must be defined with
+ * only alpha-numeric and underscores.
+ *
+ * The TRACE_SYSTEM_VAR is only used internally and not visible to
+ * user space.
+ */
 
 /*
  * Notice that this file is not protected like a normal header.
-- 
2.1.4


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


[PATCH 08/18 v3] tracing: Allow for modules to convert their enums to values

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Update the infrastructure such that modules that declare TRACE_DEFINE_ENUM()
will have those enums converted into their values in the tracepoint
print fmt strings.

Link: http://lkml.kernel.org/r/87vbhjp74q@rustcorp.com.au

Acked-by: Rusty Russell 
Signed-off-by: Steven Rostedt 
---
 include/linux/module.h  |  2 ++
 kernel/module.c |  3 +++
 kernel/trace/trace.c| 49 +
 kernel/trace/trace_events.c |  2 +-
 4 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index 42999fe2dbd0..53dc41dd5c62 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -338,6 +338,8 @@ struct module {
 #ifdef CONFIG_EVENT_TRACING
struct ftrace_event_call **trace_events;
unsigned int num_trace_events;
+   struct trace_enum_map **trace_enums;
+   unsigned int num_trace_enums;
 #endif
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
unsigned int num_ftrace_callsites;
diff --git a/kernel/module.c b/kernel/module.c
index b3d634ed06c9..d8f8ab271c2b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2753,6 +2753,9 @@ static int find_module_sections(struct module *mod, 
struct load_info *info)
mod->trace_events = section_objs(info, "_ftrace_events",
 sizeof(*mod->trace_events),
 >num_trace_events);
+   mod->trace_enums = section_objs(info, "_ftrace_enum_map",
+   sizeof(*mod->trace_enums),
+   >num_trace_enums);
 #endif
 #ifdef CONFIG_TRACING
mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ebf49649534c..28e6654e640d 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3908,11 +3908,9 @@ static const struct file_operations 
tracing_saved_cmdlines_size_fops = {
.write  = tracing_saved_cmdlines_size_write,
 };
 
-static void
-trace_insert_enum_map(struct trace_enum_map **start, struct trace_enum_map 
**stop)
+static void trace_insert_enum_map(struct trace_enum_map **start, int len)
 {
struct trace_enum_map **map;
-   int len = stop - start;
 
if (len <= 0)
return;
@@ -6561,9 +6559,48 @@ extern struct trace_enum_map *__stop_ftrace_enum_maps[];
 
 static void __init trace_enum_init(void)
 {
-   trace_insert_enum_map(__start_ftrace_enum_maps, 
__stop_ftrace_enum_maps);
+   int len;
+
+   len = __stop_ftrace_enum_maps - __start_ftrace_enum_maps;
+   trace_insert_enum_map(__start_ftrace_enum_maps, len);
+}
+
+#ifdef CONFIG_MODULES
+static void trace_module_add_enums(struct module *mod)
+{
+   if (!mod->num_trace_enums)
+   return;
+
+   /*
+* Modules with bad taint do not have events created, do
+* not bother with enums either.
+*/
+   if (trace_module_has_bad_taint(mod))
+   return;
+
+   trace_insert_enum_map(mod->trace_enums, mod->num_trace_enums);
+}
+
+static int trace_module_notify(struct notifier_block *self,
+  unsigned long val, void *data)
+{
+   struct module *mod = data;
+
+   switch (val) {
+   case MODULE_STATE_COMING:
+   trace_module_add_enums(mod);
+   break;
+   }
+
+   return 0;
 }
 
+static struct notifier_block trace_module_nb = {
+   .notifier_call = trace_module_notify,
+   .priority = 0,
+};
+#endif
+
 static __init int tracer_init_debugfs(void)
 {
struct dentry *d_tracer;
@@ -6590,6 +6627,10 @@ static __init int tracer_init_debugfs(void)
 
trace_enum_init();
 
+#ifdef CONFIG_MODULES
+   register_module_notifier(_module_nb);
+#endif
+
 #ifdef CONFIG_DYNAMIC_FTRACE
trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
_update_tot_cnt, _dyn_info_fops);
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index fc58c50fbf01..a576bbe75577 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2034,7 +2034,7 @@ static int trace_module_notify(struct notifier_block 
*self,
 
 static struct notifier_block trace_module_nb = {
.notifier_call = trace_module_notify,
-   .priority = 0,
+   .priority = 1, /* higher than trace.c module notify */
 };
 #endif /* CONFIG_MODULES */
 
-- 
2.1.4


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


[PATCH 13/18 v3] irq/tracing: Export enums in tracepoints to user space

2015-04-02 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

The enums used by the softirq mapping is what is shown in the output
of the __print_symbolic() and not their values, that are needed
to map them to their strings. Export them to userspace with the
TRACE_DEFINE_ENUM() macro so that user space tools can map the enums
with their values.

Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Signed-off-by: Steven Rostedt 
---
 include/trace/events/irq.h | 39 +++
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
index 3608bebd3d9c..ff8f6c091a15 100644
--- a/include/trace/events/irq.h
+++ b/include/trace/events/irq.h
@@ -9,19 +9,34 @@
 struct irqaction;
 struct softirq_action;
 
-#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
+#define SOFTIRQ_NAME_LIST  \
+softirq_name(HI)   \
+softirq_name(TIMER)\
+softirq_name(NET_TX)   \
+softirq_name(NET_RX)   \
+softirq_name(BLOCK)\
+softirq_name(BLOCK_IOPOLL) \
+softirq_name(TASKLET)  \
+softirq_name(SCHED)\
+softirq_name(HRTIMER)  \
+softirq_name_end(RCU)
+
+#undef softirq_name
+#undef softirq_name_end
+
+#define softirq_name(sirq) TRACE_DEFINE_ENUM(sirq##_SOFTIRQ);
+#define softirq_name_end(sirq)  TRACE_DEFINE_ENUM(sirq##_SOFTIRQ);
+
+SOFTIRQ_NAME_LIST
+
+#undef softirq_name
+#undef softirq_name_end
+
+#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq },
+#define softirq_name_end(sirq) { sirq##_SOFTIRQ, #sirq }
+
 #define show_softirq_name(val) \
-   __print_symbolic(val,   \
-softirq_name(HI),  \
-softirq_name(TIMER),   \
-softirq_name(NET_TX),  \
-softirq_name(NET_RX),  \
-softirq_name(BLOCK),   \
-softirq_name(BLOCK_IOPOLL),\
-softirq_name(TASKLET), \
-softirq_name(SCHED),   \
-softirq_name(HRTIMER), \
-softirq_name(RCU))
+   __print_symbolic(val, SOFTIRQ_NAME_LIST)
 
 /**
  * irq_handler_entry - called immediately before the irq action handler
-- 
2.1.4


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


[patch] mm, memcg: sync allocation and memcg charge gfp flags for thp fix fix

2015-04-02 Thread David Rientjes
"mm, memcg: sync allocation and memcg charge gfp flags for THP" in -mm 
introduces a formal to pass the gfp mask for khugepaged's hugepage 
allocation.  This is just too ugly to live.

alloc_hugepage_gfpmask() cannot differ between NUMA and UMA configs by 
anything in GFP_RECLAIM_MASK, which is the only thing that matters for 
memcg reclaim, so just determine the gfp flags once in 
collapse_huge_page() and avoid the complexity.

Signed-off-by: David Rientjes 
---
 -mm: intended to be folded into
  mm-memcg-sync-allocation-and-memcg-charge-gfp-flags-for-thp.patch

 mm/huge_memory.c | 21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2373,16 +2373,12 @@ static bool khugepaged_prealloc_page(struct page 
**hpage, bool *wait)
 }
 
 static struct page *
-khugepaged_alloc_page(struct page **hpage, gfp_t *gfp, struct mm_struct *mm,
+khugepaged_alloc_page(struct page **hpage, gfp_t gfp, struct mm_struct *mm,
   struct vm_area_struct *vma, unsigned long address,
   int node)
 {
VM_BUG_ON_PAGE(*hpage, *hpage);
 
-   /* Only allocate from the target node */
-   *gfp = alloc_hugepage_gfpmask(khugepaged_defrag(), __GFP_OTHER_NODE) |
-   __GFP_THISNODE;
-
/*
 * Before allocating the hugepage, release the mmap_sem read lock.
 * The allocation can take potentially a long time if it involves
@@ -2391,7 +2387,7 @@ khugepaged_alloc_page(struct page **hpage, gfp_t *gfp, 
struct mm_struct *mm,
 */
up_read(>mmap_sem);
 
-   *hpage = alloc_pages_exact_node(node, *gfp, HPAGE_PMD_ORDER);
+   *hpage = alloc_pages_exact_node(node, gfp, HPAGE_PMD_ORDER);
if (unlikely(!*hpage)) {
count_vm_event(THP_COLLAPSE_ALLOC_FAILED);
*hpage = ERR_PTR(-ENOMEM);
@@ -2445,18 +2441,13 @@ static bool khugepaged_prealloc_page(struct page 
**hpage, bool *wait)
 }
 
 static struct page *
-khugepaged_alloc_page(struct page **hpage, gfp_t *gfp, struct mm_struct *mm,
+khugepaged_alloc_page(struct page **hpage, gfp_t gfp, struct mm_struct *mm,
   struct vm_area_struct *vma, unsigned long address,
   int node)
 {
up_read(>mmap_sem);
VM_BUG_ON(!*hpage);
 
-   /*
-* khugepaged_alloc_hugepage is doing the preallocation, use the same
-* gfp flags here.
-*/
-   *gfp = alloc_hugepage_gfpmask(khugepaged_defrag(), 0);
return  *hpage;
 }
 #endif
@@ -2495,8 +2486,12 @@ static void collapse_huge_page(struct mm_struct *mm,
 
VM_BUG_ON(address & ~HPAGE_PMD_MASK);
 
+   /* Only allocate from the target node */
+   gfp = alloc_hugepage_gfpmask(khugepaged_defrag(), __GFP_OTHER_NODE) |
+   __GFP_THISNODE;
+
/* release the mmap_sem read lock. */
-   new_page = khugepaged_alloc_page(hpage, , mm, vma, address, node);
+   new_page = khugepaged_alloc_page(hpage, gfp, mm, vma, address, node);
if (!new_page)
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/


[PATCH v2] selftests/mount: output WARN messages when mount test skipped

2015-04-02 Thread Zhang Zhen
Without this patch, if /proc/self/uid_map is not exist,
the mount test case will skipped and no any prompting.

After applied this patch, the case will prompt why it skipped.
Just as follows:
root@kernel-host:/opt/kernel> make -C tools/testing/selftests TARGETS=mount 
run_tests
make: Entering directory `/opt/kernel/tools/testing/selftests'
for TARGET in mount; do \
make -C $TARGET; \
done;
make[1]: Entering directory `/opt/kernel/tools/testing/selftests/mount'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/kernel/tools/testing/selftests/mount'
for TARGET in mount; do \
make -C $TARGET run_tests; \
done;
make[1]: Entering directory `/opt/kernel/tools/testing/selftests/mount'
if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; else echo 
"WARN: No /proc/self/uid_map exist, test skipped." ; fi
WARN: No /proc/self/uid_map exist, test skipped.
make[1]: Leaving directory `/opt/kernel/tools/testing/selftests/mount'
make: Leaving directory `/opt/kernel/tools/testing/selftests'

Change v1 -> v2:
- fix syntax error when run kselftest_install.sh

Signed-off-by: Zhang Zhen 
---
 tools/testing/selftests/mount/Makefile | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mount/Makefile 
b/tools/testing/selftests/mount/Makefile
index a5b367f..038c777 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -8,7 +8,12 @@ unprivileged-remount-test: unprivileged-remount-test.c
 include ../lib.mk

 TEST_PROGS := unprivileged-remount-test
-override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then 
./unprivileged-remount-test ; fi
+override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
+ then  \
+   ./unprivileged-remount-test ; \
+ else  \
+   echo "WARN: No /proc/self/uid_map exist, test 
skipped." ; \
+ fi
 override EMIT_TESTS := echo "$(RUN_TESTS)"

 clean:
-- 
1.8.5.5


.




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


[PATCH v3 3/3] Documentation/ABI: Update sysfs-driver-toshiba_acpi entry

2015-04-02 Thread Azael Avalos
This patch updates the sysfs-driver-toshiba_acpi entry, adding the
missing entries for USB Sleep functions.

And also, while at the neighborhood, fix some typos and add a note
that some features require a reboot.

Signed-off-by: Azael Avalos 
---
 .../ABI/testing/sysfs-driver-toshiba_acpi  | 93 +++---
 1 file changed, 80 insertions(+), 13 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-driver-toshiba_acpi 
b/Documentation/ABI/testing/sysfs-driver-toshiba_acpi
index ca9c71a..eed922e 100644
--- a/Documentation/ABI/testing/sysfs-driver-toshiba_acpi
+++ b/Documentation/ABI/testing/sysfs-driver-toshiba_acpi
@@ -8,9 +8,11 @@ Description:   This file controls the keyboard backlight 
operation mode, valid
* 0x2  -> AUTO (also called TIMER)
* 0x8  -> ON
* 0x10 -> OFF
-   Note that the kernel 3.16 onwards this file accepts all listed
+   Note that from kernel 3.16 onwards this file accepts all listed
parameters, kernel 3.15 only accepts the first two (FN-Z and
AUTO).
+   Also note that toggling this value on type 1 devices, requires
+   a reboot for changes to take effect.
 Users: KToshiba
 
 What:  
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/kbd_backlight_timeout
@@ -67,15 +69,72 @@ Description:This file shows the current keyboard 
backlight type,
* 2 -> Type 2, supporting modes TIMER, ON and OFF
 Users: KToshiba
 
+What:  
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/usb_sleep_charge
+Date:  January 23, 2015
+KernelVersion: 4.0
+Contact:   Azael Avalos 
+Description:   This file controls the USB Sleep & Charge charging mode, which
+   can be:
+   * 0 -> Disabled (0x00)
+   * 1 -> Alternate(0x09)
+   * 2 -> Auto (0x21)
+   * 3 -> Typical  (0x11)
+   Note that from kernel 4.1 onwards this file accepts all listed
+   values, kernel 4.0 only supports the first three.
+   Note that this feature only works when connected to power, if
+   you want to use it under battery, see the entry named
+   "sleep_functions_on_battery"
+Users: KToshiba
+
+What:  
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/sleep_functions_on_battery
+Date:  January 23, 2015
+KernelVersion: 4.0
+Contact:   Azael Avalos 
+Description:   This file controls the USB Sleep Functions under battery, and
+   set the level at which point they will be disabled, accepted
+   values can be:
+   * 0 -> Disabled
+   * 1-100 -> Battery level to disable sleep functions
+   Currently it prints two values, the first one indicates if the
+   feature is enabled or disabled, while the second one shows the
+   current battery level set.
+   Note that when the value is set to disabled, the sleep function
+   will only work when connected to power.
+Users: KToshiba
+
+What:  
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/usb_rapid_charge
+Date:  January 23, 2015
+KernelVersion: 4.0
+Contact:   Azael Avalos 
+Description:   This file controls the USB Rapid Charge state, which can be:
+   * 0 -> Disabled
+   * 1 -> Enabled
+   Note that toggling this value requires a reboot for changes to
+   take effect.
+Users: KToshiba
+
+What:  
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/usb_sleep_music
+Date:  January 23, 2015
+KernelVersion: 4.0
+Contact:   Azael Avalos 
+Description:   This file controls the Sleep & Music state, which values can be:
+   * 0 -> Disabled
+   * 1 -> Enabled
+   Note that this feature only works when connected to power, if
+   you want to use it under battery, see the entry named
+   "sleep_functions_on_battery"
+Users: KToshiba
+
 What:  
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/version
-Date:  February, 2015
-KernelVersion: 3.20
+Date:  February 12, 2015
+KernelVersion: 4.0
 Contact:   Azael Avalos 
 Description:   This file shows the current version of the driver
+Users: KToshiba
 
 What:  /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/fan
-Date:  February, 2015
-KernelVersion: 3.20
+Date:  February 12, 2015
+KernelVersion: 4.0
 Contact:   Azael Avalos 
 Description:   This file controls the state of the internal fan, valid
values are:
@@ -83,8 +142,8 @@ 

[PATCH v3 2/3] toshiba_acpi: Fix pr_* messages from USB Sleep Functions

2015-04-02 Thread Azael Avalos
This patch fixes the messages displayed by the USB Sleep Functions,
they were printing wrong messages not associated to the feature
currently queried.

Signed-off-by: Azael Avalos 
---
 drivers/platform/x86/toshiba_acpi.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c 
b/drivers/platform/x86/toshiba_acpi.c
index 37f5f64..f624dd5 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -965,11 +965,11 @@ static int toshiba_usb_rapid_charge_get(struct 
toshiba_acpi_dev *dev,
status = tci_raw(dev, in, out);
sci_close(dev);
if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
-   pr_err("ACPI call to get USB S battery level failed\n");
+   pr_err("ACPI call to get USB Rapid Charge failed\n");
return -EIO;
} else if (out[0] == TOS_NOT_SUPPORTED ||
   out[0] == TOS_INPUT_DATA_ERROR) {
-   pr_info("USB Sleep and Charge not supported\n");
+   pr_info("USB Rapid Charge not supported\n");
return -ENODEV;
}
 
@@ -993,10 +993,10 @@ static int toshiba_usb_rapid_charge_set(struct 
toshiba_acpi_dev *dev,
status = tci_raw(dev, in, out);
sci_close(dev);
if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
-   pr_err("ACPI call to set USB S battery level failed\n");
+   pr_err("ACPI call to set USB Rapid Charge failed\n");
return -EIO;
} else if (out[0] == TOS_NOT_SUPPORTED) {
-   pr_info("USB Sleep and Charge not supported\n");
+   pr_info("USB Rapid Charge not supported\n");
return -ENODEV;
} else if (out[0] == TOS_INPUT_DATA_ERROR) {
return -EIO;
@@ -1015,10 +1015,10 @@ static int toshiba_usb_sleep_music_get(struct 
toshiba_acpi_dev *dev, u32 *state)
result = sci_read(dev, SCI_USB_SLEEP_MUSIC, state);
sci_close(dev);
if (result == TOS_FAILURE) {
-   pr_err("ACPI call to set USB S mode failed\n");
+   pr_err("ACPI call to get Sleep and Music failed\n");
return -EIO;
} else if (result == TOS_NOT_SUPPORTED) {
-   pr_info("USB Sleep and Charge not supported\n");
+   pr_info("Sleep and Music not supported\n");
return -ENODEV;
} else if (result == TOS_INPUT_DATA_ERROR) {
return -EIO;
@@ -1037,10 +1037,10 @@ static int toshiba_usb_sleep_music_set(struct 
toshiba_acpi_dev *dev, u32 state)
result = sci_write(dev, SCI_USB_SLEEP_MUSIC, state);
sci_close(dev);
if (result == TOS_FAILURE) {
-   pr_err("ACPI call to set USB S mode failed\n");
+   pr_err("ACPI call to set Sleep and Music failed\n");
return -EIO;
} else if (result == TOS_NOT_SUPPORTED) {
-   pr_info("USB Sleep and Charge not supported\n");
+   pr_info("Sleep and Music not supported\n");
return -ENODEV;
} else if (result == TOS_INPUT_DATA_ERROR) {
return -EIO;
-- 
2.3.4

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


[PATCH v3 1/3] toshiba_acpi: Update and fix USB Sleep and Charge modes

2015-04-02 Thread Azael Avalos
This patch fixes the USB Sleep and Charge mode on certain models
where the value returned by the BIOS is different, and thus, making
this feature not to work for those models.

Also, the "Typical" charging mode was added as a supported mode.

Signed-off-by: Azael Avalos 
---
 drivers/platform/x86/toshiba_acpi.c | 71 -
 1 file changed, 62 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c 
b/drivers/platform/x86/toshiba_acpi.c
index 17a259e..37f5f64 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -150,9 +150,10 @@ MODULE_LICENSE("GPL");
 #define SCI_KBD_MODE_OFF   0x10
 #define SCI_KBD_TIME_MAX   0x3c001a
 #define SCI_USB_CHARGE_MODE_MASK   0xff
-#define SCI_USB_CHARGE_DISABLED0x3
-#define SCI_USB_CHARGE_ALTERNATE   0x30009
-#define SCI_USB_CHARGE_AUTO0x30021
+#define SCI_USB_CHARGE_DISABLED0x00
+#define SCI_USB_CHARGE_ALTERNATE   0x09
+#define SCI_USB_CHARGE_TYPICAL 0x11
+#define SCI_USB_CHARGE_AUTO0x21
 #define SCI_USB_CHARGE_BAT_MASK0x7
 #define SCI_USB_CHARGE_BAT_LVL_OFF 0x1
 #define SCI_USB_CHARGE_BAT_LVL_ON  0x4
@@ -177,6 +178,7 @@ struct toshiba_acpi_dev {
int kbd_mode;
int kbd_time;
int usbsc_bat_level;
+   int usbsc_mode_base;
int hotkey_event_type;
 
unsigned int illumination_supported:1;
@@ -800,6 +802,54 @@ static int toshiba_accelerometer_get(struct 
toshiba_acpi_dev *dev,
 }
 
 /* Sleep (Charge and Music) utilities support */
+static void toshiba_usb_sleep_charge_available(struct toshiba_acpi_dev *dev)
+{
+   u32 in[TCI_WORDS] = { SCI_GET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 };
+   u32 out[TCI_WORDS];
+   acpi_status status;
+
+   /* Set the feature to "not supported" in case of error */
+   dev->usb_sleep_charge_supported = 0;
+
+   if (!sci_open(dev))
+   return;
+
+   status = tci_raw(dev, in, out);
+   if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
+   pr_err("ACPI call to get USB Sleep and Charge mode failed\n");
+   sci_close(dev);
+   return;
+   } else if (out[0] == TOS_NOT_SUPPORTED) {
+   pr_info("USB Sleep and Charge not supported\n");
+   sci_close(dev);
+   return;
+   } else if (out[0] == TOS_SUCCESS) {
+   dev->usbsc_mode_base = out[4];
+   }
+
+   in[5] = SCI_USB_CHARGE_BAT_LVL;
+   status = tci_raw(dev, in, out);
+   if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
+   pr_err("ACPI call to get USB Sleep and Charge mode failed\n");
+   sci_close(dev);
+   return;
+   } else if (out[0] == TOS_NOT_SUPPORTED) {
+   pr_info("USB Sleep and Charge not supported\n");
+   sci_close(dev);
+   return;
+   } else if (out[0] == TOS_SUCCESS) {
+   dev->usbsc_bat_level = out[2];
+   /*
+* If we reach this point, it means that the laptop has support
+* for this feature and all values are initialized.
+* Set it as supported.
+*/
+   dev->usb_sleep_charge_supported = 1;
+   }
+
+   sci_close(dev);
+}
+
 static int toshiba_usb_sleep_charge_get(struct toshiba_acpi_dev *dev,
u32 *mode)
 {
@@ -1976,17 +2026,21 @@ static ssize_t usb_sleep_charge_store(struct device 
*dev,
 * 0 - Disabled
 * 1 - Alternate (Non USB conformant devices that require more power)
 * 2 - Auto (USB conformant devices)
+* 3 - Typical
 */
-   if (state != 0 && state != 1 && state != 2)
+   if (state != 0 && state != 1 && state != 2 && state != 3)
return -EINVAL;
 
/* Set the USB charging mode to internal value */
+   mode = toshiba->usbsc_mode_base;
if (state == 0)
-   mode = SCI_USB_CHARGE_DISABLED;
+   mode |= SCI_USB_CHARGE_DISABLED;
else if (state == 1)
-   mode = SCI_USB_CHARGE_ALTERNATE;
+   mode |= SCI_USB_CHARGE_ALTERNATE;
else if (state == 2)
-   mode = SCI_USB_CHARGE_AUTO;
+   mode |= SCI_USB_CHARGE_AUTO;
+   else if (state == 3)
+   mode |= SCI_USB_CHARGE_TYPICAL;
 
ret = toshiba_usb_sleep_charge_set(toshiba, mode);
if (ret)
@@ -2756,8 +2810,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
ret = toshiba_accelerometer_supported(dev);
dev->accelerometer_supported = !ret;
 
-   ret = toshiba_usb_sleep_charge_get(dev, );
-   dev->usb_sleep_charge_supported = !ret;
+   toshiba_usb_sleep_charge_available(dev);
 
ret = toshiba_usb_rapid_charge_get(dev, );
dev->usb_rapid_charge_supported = !ret;
-- 
2.3.4

--

[PATCH v3 0/3] toshiba_acpi: Fix USB Sleep & Charge mode and documentation updates

2015-04-02 Thread Azael Avalos
This patch fixes the USB Sleep & Charge charging mode on certain
models, fixes pr_* messages and also adds the missing entries in the
documentation file.

Changes since v2:
- Check for TOS_SUCCESS to initialize and flag as supported on first
  patch

Changes since v1:
- Set the default supported value of sleep and charge to zero in case
  of an error and added comments.
- Updated the title and commit message of second patch to better
  reflect what the patch is doing.

Azael Avalos (3):
  toshiba_acpi: Update and fix USB Sleep and Charge modes
  toshiba_acpi: Fix pr_* messages from USB Sleep Functions
  Documentation/ABI: Update sysfs-driver-toshiba_acpi entry

 .../ABI/testing/sysfs-driver-toshiba_acpi  | 93 +++---
 drivers/platform/x86/toshiba_acpi.c| 87 
 2 files changed, 150 insertions(+), 30 deletions(-)

-- 
2.3.4

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


[PATCH v3 2/3] toshiba_acpi: Fix pr_* messages from USB Sleep Functions

2015-04-02 Thread Azael Avalos
This patch fixes the messages displayed by the USB Sleep Functions,
they were printing wrong messages not associated to the feature
currently queried.

Signed-off-by: Azael Avalos 
---
 drivers/platform/x86/toshiba_acpi.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c 
b/drivers/platform/x86/toshiba_acpi.c
index 37f5f64..f624dd5 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -965,11 +965,11 @@ static int toshiba_usb_rapid_charge_get(struct 
toshiba_acpi_dev *dev,
status = tci_raw(dev, in, out);
sci_close(dev);
if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
-   pr_err("ACPI call to get USB S battery level failed\n");
+   pr_err("ACPI call to get USB Rapid Charge failed\n");
return -EIO;
} else if (out[0] == TOS_NOT_SUPPORTED ||
   out[0] == TOS_INPUT_DATA_ERROR) {
-   pr_info("USB Sleep and Charge not supported\n");
+   pr_info("USB Rapid Charge not supported\n");
return -ENODEV;
}
 
@@ -993,10 +993,10 @@ static int toshiba_usb_rapid_charge_set(struct 
toshiba_acpi_dev *dev,
status = tci_raw(dev, in, out);
sci_close(dev);
if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
-   pr_err("ACPI call to set USB S battery level failed\n");
+   pr_err("ACPI call to set USB Rapid Charge failed\n");
return -EIO;
} else if (out[0] == TOS_NOT_SUPPORTED) {
-   pr_info("USB Sleep and Charge not supported\n");
+   pr_info("USB Rapid Charge not supported\n");
return -ENODEV;
} else if (out[0] == TOS_INPUT_DATA_ERROR) {
return -EIO;
@@ -1015,10 +1015,10 @@ static int toshiba_usb_sleep_music_get(struct 
toshiba_acpi_dev *dev, u32 *state)
result = sci_read(dev, SCI_USB_SLEEP_MUSIC, state);
sci_close(dev);
if (result == TOS_FAILURE) {
-   pr_err("ACPI call to set USB S mode failed\n");
+   pr_err("ACPI call to get Sleep and Music failed\n");
return -EIO;
} else if (result == TOS_NOT_SUPPORTED) {
-   pr_info("USB Sleep and Charge not supported\n");
+   pr_info("Sleep and Music not supported\n");
return -ENODEV;
} else if (result == TOS_INPUT_DATA_ERROR) {
return -EIO;
@@ -1037,10 +1037,10 @@ static int toshiba_usb_sleep_music_set(struct 
toshiba_acpi_dev *dev, u32 state)
result = sci_write(dev, SCI_USB_SLEEP_MUSIC, state);
sci_close(dev);
if (result == TOS_FAILURE) {
-   pr_err("ACPI call to set USB S mode failed\n");
+   pr_err("ACPI call to set Sleep and Music failed\n");
return -EIO;
} else if (result == TOS_NOT_SUPPORTED) {
-   pr_info("USB Sleep and Charge not supported\n");
+   pr_info("Sleep and Music not supported\n");
return -ENODEV;
} else if (result == TOS_INPUT_DATA_ERROR) {
return -EIO;
-- 
2.3.4

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


Re: [RFC PATCH 08/11] lib: other kernel glue layer code

2015-04-02 Thread Hajime Tazaki

Hi Richard,

At Tue, 31 Mar 2015 16:36:55 +0900,
Hajime Tazaki wrote:

> now I'm trying to minimize those stubs by reusing the original
> codes (i.e., fs/filesystems.c for register_filesystem()). I
> will let you know once I've done (maybe v2 RFC if you think
> it's better ?)

I've extensively removed about 1K LoC of stubs (glues)
including e.g., register_filesystem(). There are still stubs
need to be tracked, like file mount code, memory management,
but it can be improved later I think.

commit edc9109d6d1a36f691872549762f954783a9a628
Author: Hajime Tazaki 
Date:   Tue Mar 31 22:32:21 2015 +0900

lib: reduce glue codes (stubs)

 arch/lib/Makefile  |  22 ++--
 arch/lib/capability.c  |  47 +++
 arch/lib/cred.c|  16 ---
 arch/lib/dcache.c  |  93 --
 arch/lib/filemap.c |   5 +
 arch/lib/fs.c  | 239 ++--
 arch/lib/glue.c|  75 ++-
 arch/lib/include/asm/Kbuild|   2 +
 arch/lib/include/asm/atomic.h  |   5 +-
 arch/lib/include/asm/thread_info.h |   1 +
 arch/lib/inode.c   | 146 --
 arch/lib/lib.c |   5 +
 arch/lib/proc.c| 130 
 arch/lib/sched.c   |  41 +++
 arch/lib/security.c|  45 ---
 arch/lib/seq.c | 122 --
 arch/lib/slab.c|   3 +
 arch/lib/softirq.c |   4 +
 arch/lib/splice.c  |  20 ---
 arch/lib/super.c   | 210 ---
 arch/lib/sysctl.c  |  15 ---
 arch/lib/time.c|   5 -
 22 files changed, 142 insertions(+), 1109 deletions(-)

(full modification on this commit)
https://github.com/libos-nuse/net-next-nuse/commit/edc9109d6d1a36f691872549762f954783a9a628

I still have a couple of comments, which I haven't addressed
with the code (below). will work on too.

* build system (Makefile)
- parallel build issue
- cross-build issue
- missing dependency detection

* code location
- under arch/ or tools/

-- Hajime
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: Unreliable hibernation on Lenovo x230 (regression)

2015-04-02 Thread joeyli
On Thu, Apr 02, 2015 at 08:12:00PM +0200, rhn wrote:
> On Fri, 3 Apr 2015 01:22:21 +0800
> joeyli  wrote:
> 
> > On Fri, Apr 03, 2015 at 12:50:54AM +0800, joeyli wrote:
> > > Hi, 
> > > 
> > > On Thu, Apr 02, 2015 at 05:28:05PM +0200, Pavel Machek wrote:
> > > > On Wed 2015-04-01 21:47:43, rhn wrote:
> > > > > Hello,
> > > > > 
> > > > > Between kernel 3.16 and 3.17, a regression has been introduced where 
> > > > > the first hibernation after regular shutdown always fails to resume. 
> > > > > Subsequent hibernations succeed.
> > > > > 
> > > > > The system is a Lenovo x230 with Intel i5, booting with EFI, with the 
> > > > > hibernate partition located on a secondary SSD drive. Installed 
> > > > > system is Fedora 20, hibernation and reboots were issued using the 
> > > > > KDE shutdown dialog.
> > > > > 
> > > > > I have tracked the problem to first appear in the commit
> > > > > e67ee10190e69332f929bdd6594a312363321a66  Merge branches 
> > > > > 'pm-sleep', 'pm-cpufreq' and 'pm-cpuidle'
> > > > > 
> > > > > The problem itself manifests in dmesg as follows (system was first
> > > > > restarted, then hibernated - this log is from the subsequent
> > > > resume):
> > > > 
> > > > Ok, can you try to disable cpufreq and cpuidle, and then try if it
> > > > reproduces?
> > > > 
> > > > At that point, this is the candidate:
> > > > 
> > > > commit e67ee10190e69332f929bdd6594a312363321a66
> > > > Merge: 21c806d 84c91b7 39c8bba 372ba8c
> > > > Author: Rafael J. Wysocki 
> > > > Date:   Mon Aug 11 23:19:48 2014 +0200
> > > > 
> > > > Merge branches 'pm-sleep', 'pm-cpufreq' and 'pm-cpuidle'
> > > > 
> > > > * pm-sleep:
> > > >   PM / hibernate: avoid unsafe pages in e820 reserved regions
> > > > 
> > > > ...
> > > > Alternatively, you can just try to revert
> > > > 
> > > > commit 84c91b7ae07c62cf6dee7fde3277f4be21331f85
> > > > Author: Lee, Chun-Yi 
> > > > Date:   Mon Aug 4 23:23:21 2014 +0800
> > > > 
> > > > PM / hibernate: avoid unsafe pages in e820 reserved regions
> > > > 
> > > > When the machine doesn't well handle the e820 persistent when
> > > > hibernate
> > > > resuming, then it may cause page fault when writing image to
> > > > snapshot
> > > > buffer:
> > > > 
> > > > 
> > > > ...
> > > > 
> > > > Thanks,
> > > > 
> > > > Pavel
> > > 
> > > Before revert 84c91b7ae patch, please check does there have log similar as
> > > following in dmesg when hibernate resume fail?
> > > 
> > > [   24.349777] PM: 0xab9bc000 in e820 nosave region: [mem 
> > > 0xab9bc000-0xab9c2fff]
> > > 
> > > The address may different, by you should see "e820 nosave region" log. 
> > > Otherwise
> > > we got another problem.
> > >
> > 
> > Forgot to mention, please add "debug no_console_suspend=1 loglevel=9" to 
> > kernel
> > parameter then try to reproduce issue and look at dmesg.
> > 
> > 
> > Thanks a lot!
> > Joey Lee 
> 
> Yes, it's present in dmesg when hibernate fails (default kernel params):
> [3.138824] PM: 0x9d3d3000 in e820 nosave region: [mem 
> 0x9d3d3000-0x9d3d3fff]
>

OK, then the message means 0x9d3d3000 address used by image kernel but in e820
region of current boot. Need check does this e820 region used by setup_data so
reserved as E820_RESERVED_KERN.

Need your complete dmesg to verify the e820 table. If the above assumption is
true, then Yinghai Lu's patchset could fix this problem:

x86: Kill E820_RESERVED_KERN
https://lkml.org/lkml/2015/3/4/434

The target kernel version to merge his patches is v4.1
 
> I probably didn't make it clear - the top dmesg in my original message was 
> from failed resume.
> 
> Cheers,
> rhn

On the other hand,
Could you please check you are using platform mode to turn off machine for
hibernating?

$ cat /sys/power/disk
[platform] shutdown reboot suspend

And, if possible, please file bug on bugzilla.kernel.org and give me the bug
number. I prefer collect log and debugging history in bugzilla for further
tracking.


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


Re: [PATCH] Do not use arbitrary large movablecore to calculate kernelcore

2015-04-02 Thread Zhihui Zhang
If you specify movablecore > totalpages, required_kernelcore will end
up with a big number because corepages is an unsigned integer. If so,
the following nested is a waste of time. But I see your point.

-Zhihui

On Wed, Apr 1, 2015 at 7:00 PM, Mel Gorman  wrote:
> On Sat, Mar 28, 2015 at 11:36:02PM -0400, Zhihui Zhang wrote:
>> If kernelcore is not set, then we are working with a very large kernelcore
>> for nothing - no movable zone will be created. If kernelcore is set,
>> then it is not respected at all.
>>
>> Signed-off-by: Zhihui Zhang 
>
> I'm confused. What bug is this patch fixing? What is the user-visible
> impcat of the patch?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/3] toshiba_acpi: Update and fix USB Sleep and Charge modes

2015-04-02 Thread Azael Avalos
Hi Darren,

2015-04-01 23:21 GMT-06:00 Darren Hart :
> On Sun, Mar 29, 2015 at 07:25:39PM -0600, Azael Avalos wrote:
>> This patch fixes the USB Sleep and Charge mode on certain models
>> where the value returned by the BIOS is different, and thus, making
>> this feature not to work for those models.
>>
>> Also, the "Typical" charging mode was added as a supported mode.
>>
>> Signed-off-by: Azael Avalos 
>> ---
>>  drivers/platform/x86/toshiba_acpi.c | 69 
>> -
>>  1 file changed, 60 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/platform/x86/toshiba_acpi.c 
>> b/drivers/platform/x86/toshiba_acpi.c
>> index 17a259e..c8ad61c 100644
>> --- a/drivers/platform/x86/toshiba_acpi.c
>> +++ b/drivers/platform/x86/toshiba_acpi.c
>> @@ -150,9 +150,10 @@ MODULE_LICENSE("GPL");
>>  #define SCI_KBD_MODE_OFF 0x10
>>  #define SCI_KBD_TIME_MAX 0x3c001a
>>  #define SCI_USB_CHARGE_MODE_MASK 0xff
>> -#define SCI_USB_CHARGE_DISABLED  0x3
>> -#define SCI_USB_CHARGE_ALTERNATE 0x30009
>> -#define SCI_USB_CHARGE_AUTO  0x30021
>> +#define SCI_USB_CHARGE_DISABLED  0x00
>> +#define SCI_USB_CHARGE_ALTERNATE 0x09
>> +#define SCI_USB_CHARGE_TYPICAL   0x11
>> +#define SCI_USB_CHARGE_AUTO  0x21
>>  #define SCI_USB_CHARGE_BAT_MASK  0x7
>>  #define SCI_USB_CHARGE_BAT_LVL_OFF   0x1
>>  #define SCI_USB_CHARGE_BAT_LVL_ON0x4
>> @@ -177,6 +178,7 @@ struct toshiba_acpi_dev {
>>   int kbd_mode;
>>   int kbd_time;
>>   int usbsc_bat_level;
>> + int usbsc_mode_base;
>>   int hotkey_event_type;
>>
>>   unsigned int illumination_supported:1;
>> @@ -800,6 +802,52 @@ static int toshiba_accelerometer_get(struct 
>> toshiba_acpi_dev *dev,
>>  }
>>
>>  /* Sleep (Charge and Music) utilities support */
>> +static void toshiba_usb_sleep_charge_available(struct toshiba_acpi_dev *dev)
>> +{
>> + u32 in[TCI_WORDS] = { SCI_GET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 };
>> + u32 out[TCI_WORDS];
>> + acpi_status status;
>> +
>> + /* Set the feature to "not supported" in case of error */
>> + dev->usb_sleep_charge_supported = 0;
>> +
>> + if (!sci_open(dev))
>> + return;
>> +
>> + status = tci_raw(dev, in, out);
>> + if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
>> + pr_err("ACPI call to get USB Sleep and Charge mode failed\n");
>> + sci_close(dev);
>> + return;
>> + } else if (out[0] == TOS_NOT_SUPPORTED) {
>> + pr_info("USB Sleep and Charge not supported\n");
>> + sci_close(dev);
>> + return;
>> + }
>
> Sorry Azael for not asking the first time, and maybe this is just how it is -
> but it occurs to me that after the above tci_raw call, we check for 3 error
> cases, but we never test for success. Can we not check for out[0] == 
> TOS_SUCCESS
> or similar? The above logic seems like the kind to lead to failure going
> unnoticed as success is assumed and not confirmed.
>

No problem, will send v3 in a few :-)

>> + dev->usbsc_mode_base = out[4];
>> +
>> + in[5] = SCI_USB_CHARGE_BAT_LVL;
>> + status = tci_raw(dev, in, out);
>> + if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
>> + pr_err("ACPI call to get USB Sleep and Charge mode failed\n");
>> + sci_close(dev);
>> + return;
>> + } else if (out[0] == TOS_NOT_SUPPORTED) {
>> + pr_info("USB Sleep and Charge not supported\n");
>> + sci_close(dev);
>> + return;
>> + }
>
> Here too.
>
> --
> Darren Hart
> Intel Open Source Technology Center


Cheers
Azael


-- 
-- El mundo apesta y vosotros apestais tambien --
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] selftests/mount: output error messages when mount test fail

2015-04-02 Thread Zhang Zhen
On 2015/4/3 2:56, Eric W. Biederman wrote:
> Zhang Zhen  writes:
> 
>> Without this patch, if /proc/self/uid_map is not exist,
>> the mount test case will fail and no any prompting.
> 
> The intent was not to fail if /proc/self/uid_map is missing but to skip
> the test because it is not applicable.
> 
> Making this an error seems wrong.  Even if I did mess up the shell
> script error propagation and made it an error by accident.
> 
Ok, modify the output messages as follows:
WARN: No /proc/self/uid_map exist, test skipped.

Do you think this modification right?

Best regards!
>> After applied this patch, the case will prompt why it fail.
>> Just as follows:
>> root@kernel-host:/opt/kernel> make -C tools/testing/selftests TARGETS=mount 
>> run_tests
>> make: Entering directory `/opt/kernel/tools/testing/selftests'
>> for TARGET in mount; do \
>> make -C $TARGET; \
>> done;
>> make[1]: Entering directory `/opt/kernel/tools/testing/selftests/mount'
>> make[1]: Nothing to be done for `all'.
>> make[1]: Leaving directory `/opt/kernel/tools/testing/selftests/mount'
>> for TARGET in mount; do \
>> make -C $TARGET run_tests; \
>> done;
>> make[1]: Entering directory `/opt/kernel/tools/testing/selftests/mount'
>> ERROR: No /proc/self/uid_map exist
>> make[1]: Leaving directory `/opt/kernel/tools/testing/selftests/mount'
>> make: Leaving directory `/opt/kernel/tools/testing/selftests'
>>
>> Signed-off-by: Zhang Zhen 
>> ---
>>  tools/testing/selftests/mount/Makefile | 7 ++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/mount/Makefile 
>> b/tools/testing/selftests/mount/Makefile
>> index a5b367f..b3266db 100644
>> --- a/tools/testing/selftests/mount/Makefile
>> +++ b/tools/testing/selftests/mount/Makefile
>> @@ -8,7 +8,12 @@ unprivileged-remount-test: unprivileged-remount-test.c
>>  include ../lib.mk
>>
>>  TEST_PROGS := unprivileged-remount-test
>> -override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then 
>> ./unprivileged-remount-test ; fi
>> +override RUN_TESTS :=  @if [ -f /proc/self/uid_map ] ; \
>> +then\
>> +./unprivileged-remount-test ; \
>> +else\
>> +echo "ERROR: No /proc/self/uid_map exist" ; \
>> +fi
>>  override EMIT_TESTS := echo "$(RUN_TESTS)"
>>
>>  clean:
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] nohz,blk-mq: do not create blk-mq workqueues on nohz dedicated CPUs

2015-04-02 Thread Jens Axboe

On 04/01/2015 10:12 AM, Rik van Riel wrote:

On 03/31/2015 11:43 AM, Jens Axboe wrote:


That'd be easy enough to do, that's how blk-mq handles offline CPUs as
well. The attached patch is completely untested, but will handle offline
or nohz CPUs in the same fashion - they will punt to hardware queue 0,
which is mapped to CPU0 (and others, depending on the queue vs CPU ratio).


I have done some sanity testing with your patch,
starting a KVM guest with vcpus and emulator threads
all pinned to nohz_full cpus.

The guest is still able to do disk IO, so things
appear to work...

Thanks for looking into this, Jens.

Tested-by: Rik van Riel 


Great thanks, I'll do some sanity testing here too and get it applied 
for 4.1.


--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v1 02/47] x86: mtrr: generalize run time disabling of MTRR

2015-04-02 Thread Luis R. Rodriguez
On Thu, Apr 02, 2015 at 05:52:16PM -0600, Toshi Kani wrote:
> On Thu, 2015-04-02 at 23:49 +0200, Luis R. Rodriguez wrote:
> > On Sat, Mar 28, 2015 at 12:56:30AM +0100, Luis R. Rodriguez wrote:
> > > On Fri, Mar 27, 2015 at 02:40:17PM -0600, Toshi Kani wrote:
> > > > On Fri, 2015-03-20 at 16:17 -0700, Luis R. Rodriguez wrote:
> > > >  :
> > > > > @@ -734,6 +742,7 @@ void __init mtrr_bp_init(void)
> > > > >   }
> > > > >  
> > > > >   if (mtrr_if) {
> > > > > + mtrr_enabled = true;
> > > > >   set_num_var_ranges();
> > > > >   init_table();
> > > > >   if (use_intel()) {
> > > > get_mtrr_state();
> > > > 
> > > > After setting mtrr_enabled to true, get_mtrr_state() reads
> > > > MSR_MTRRdefType and sets 'mtrr_state.enabled', which also indicates if
> > > > MTRRs are enabled or not on the system.  So, potentially, we could have
> > > > a case that mtrr_enabled is set to true, but mtrr_state.enabled is set
> > > > to disabled when MTRRs are disabled by BIOS.
> > > 
> > > Thanks for the review, in this case then we should update mtrr_enabled to 
> > > false.
> > > 
> > > > ps.
> > > > I recently cleaned up this part of the MTRR code in the patch below,
> > > > which is currently available in the -mm & -next trees.
> > > > https://lkml.org/lkml/2015/3/24/1063
> > > 
> > > Great I will rebase and work with that and try to address this
> > > consideration you have raised.
> > 
> > OK I'll mesh in this change as well in my next respin:
> > 
> > diff --git a/arch/x86/kernel/cpu/mtrr/generic.c 
> > b/arch/x86/kernel/cpu/mtrr/generic.c
> > index a83f27a..ecf7cb9 100644
> > --- a/arch/x86/kernel/cpu/mtrr/generic.c
> > +++ b/arch/x86/kernel/cpu/mtrr/generic.c
> > @@ -438,7 +438,7 @@ static void __init print_mtrr_state(void)
> >  }
> >  
> >  /* Grab all of the MTRR state for this CPU into *state */
> > -void __init get_mtrr_state(void)
> > +bool __init get_mtrr_state(void)
> >  {
> > struct mtrr_var_range *vrs;
> > unsigned long flags;
> > @@ -482,6 +482,8 @@ void __init get_mtrr_state(void)
> >  
> > post_set();
> > local_irq_restore(flags);
> > +
> > +   return !!mtrr_state.enabled;
> 
> This should be:
>   return mtrr_state.enabled & MTRR_STATE_MTRR_ENABLED;
> 
> because the MTRR_STATE_MTRR_FIXED_ENABLED flag is ignored when the
> MTRR_STATE_MTRR_ENABLED flag is clear.

Thanks, I've used

return !!(mtrr_state.enabled & MTRR_STATE_MTRR_ENABLED);

Amended.

  Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 -mm] mm, mempool: poison elements backed by page allocator fix fix

2015-04-02 Thread David Rientjes
Elements backed by the page allocator might not be directly mapped into 
lowmem, so do k{,un}map_atomic() before poisoning and verifying contents 
to map into lowmem and return the virtual adddress.

Reported-by: Andrey Ryabinin 
Signed-off-by: David Rientjes 
---
 mm/mempool.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/mempool.c b/mm/mempool.c
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -61,9 +61,10 @@ static void check_element(mempool_t *pool, void *element)
/* Mempools backed by page allocator */
if (pool->free == mempool_free_pages) {
int order = (int)(long)pool->pool_data;
-   void *addr = page_address(element);
+   void *addr = kmap_atomic((struct page *)element);
 
__check_element(pool, addr, 1UL << (PAGE_SHIFT + order));
+   kunmap_atomic(addr);
}
 }
 
@@ -84,9 +85,10 @@ static void poison_element(mempool_t *pool, void *element)
/* Mempools backed by page allocator */
if (pool->alloc == mempool_alloc_pages) {
int order = (int)(long)pool->pool_data;
-   void *addr = page_address(element);
+   void *addr = kmap_atomic((struct page *)element);
 
__poison_element(addr, 1UL << (PAGE_SHIFT + order));
+   kunmap_atomic(addr);
}
 }
 #else /* CONFIG_DEBUG_SLAB || CONFIG_SLUB_DEBUG_ON */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next - strange audio bug

2015-04-02 Thread Valdis Kletnieks
Next-20150310 works OK, next-20150324 has the bug.

Dell Latitude E6530 laptop, lspci tells me:

01:00.1 Audio device: NVIDIA Corporation GF108 High Definition Audio Controller 
(rev a1)
Subsystem: Dell Device 0535
...
Kernel driver in use: snd_hda_intel

Symptoms:  Audio works perfectly at boot, and for some amount
of time after.  But somewhere around 6-8 hours of uptime, it gets
into a strange state where I'll get no audio... and then it will
cut in for all of 2 seconds or so (fairly consistent, that part),
and then cut back out for anywhere from 10 seconds to a minute,
then another 2 seconds of sound.. lather rinse repeat.

Before I start the thankless task of bisecting this (which means I'll
be able to do only 1, *maybe* 2 steps a day), does this ring any bells?


pgpMowQZ8TQrd.pgp
Description: PGP signature


Re: [PATCH] mvneta: implement SGMII-based in-band link state signaling

2015-04-02 Thread Florian Fainelli
On 02/04/15 17:51, David Miller wrote:
> From: Stas Sergeev 
> Date: Tue, 31 Mar 2015 16:24:59 +0300
> 
>> @@ -2590,6 +2651,7 @@ static int mvneta_mdio_probe(struct mvneta_port *pp)
>>
>>  static void mvneta_mdio_remove(struct mvneta_port *pp)
>>  {
>> +fixed_phy_set_link_update(pp->phy_dev, NULL);
> 
> I do not see any other driver doing this on shutdown.
> Please show me why it is necessary.

The primary reason is that if you do not do that, past the point where
you call phy_disconnect(), we stop the PHY state machine, detach from
the net_device, such that it won't invoke the adjust_link callback
anymore. The fixed PHY driver, though will still keep calling the
fixed_link_update callback asking the driver whether the link parameters
need to be updated, and that will just cause a NULL pointer de-reference
phydev->attached_dev, since we are now in detached state.

I guess another way to fix that is to look for the PHY state in
fixed_mdio_read() and do nothing if it is PHY_HALTED.

> 
> And if it is, all other drivers registering a fixed phy link update
> function need to be adjusted to do the same thing.
> 

I think the bcmgenet driver is now doing this as a result of Petri's
latest changes, and I meant to comment on that before the patch got in.
drivers/net/dsa/bcm_sf2.c has a similar construct but does not invoke
phy_disconnect() nor can be rmmod'd, so a lesser issue.
-- 
Florian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch -mm] mm, doc: cleanup and clarify munmap behavior for hugetlb memory fix

2015-04-02 Thread Hugh Dickins
On Thu, 2 Apr 2015, David Rientjes wrote:

> Don't only specify munmap(2) behavior with respect the hugetlb memory, all 
> other syscalls get naturally aligned to the native page size of the 
> processor.  Rather, pick out munmap(2) as a specific example.
> 
> Signed-off-by: David Rientjes 

Thanks, yes, good wording: it is best to be a bit vague here,
since each msyscall takes the approach most convenient for it.

Acked-by: Hugh Dickins 

> ---
>  Documentation/vm/hugetlbpage.txt | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/vm/hugetlbpage.txt 
> b/Documentation/vm/hugetlbpage.txt
> index 1270fb1..030977f 100644
> --- a/Documentation/vm/hugetlbpage.txt
> +++ b/Documentation/vm/hugetlbpage.txt
> @@ -313,8 +313,11 @@ into /proc/sys/vm/hugetlb_shm_group.  It is possible for 
> same or different
>  applications to use any combination of mmaps and shm* calls, though the 
> mount of
>  filesystem will be required for using mmap calls without MAP_HUGETLB.
>  
> -When using munmap(2) to unmap hugetlb memory, the length specified must be
> -hugepage aligned, otherwise it will fail with errno set to EINVAL.
> +Syscalls that operate on memory backed by hugetlb pages only have their 
> lengths
> +aligned to the native page size of the processor; they will normally fail 
> with
> +errno set to EINVAL or exclude hugetlb pages that extend beyond the length if
> +not hugepage aligned.  For example, munmap(2) will fail if memory is backed 
> by
> +a hugetlb page and the length is smaller than the hugepage size.
>  
>  
>  Examples
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >