[PATCH] staging: sm750fb: rename macro roundedDiv to rounded_div in ddk750_chip.c

2016-10-01 Thread Moshe Green
Rename CamelCased macro roundedDiv to rounded_div.

This issue was found by checkpatch.pl

Signed-off-by: Moshe Green 
---
 drivers/staging/sm750fb/ddk750_chip.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index 3a0afe1..e4efe91 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -7,7 +7,7 @@
 #include "ddk750_power.h"
 
 /* n / d + 1 / 2 = (2n + d) / 2d */
-#define roundedDiv(num, denom) ((2 * (num) + (denom)) / (2 * (denom)))
+#define rounded_div(num, denom)((2 * (num) + (denom)) / (2 * (denom)))
 #define MHz(x) ((x) * 100)
 
 logical_chip_type_t sm750_get_chip_type(void)
@@ -102,7 +102,7 @@ static void setMemoryClock(unsigned int frequency)
frequency = MHz(336);
 
/* Calculate the divisor */
-   divisor = roundedDiv(get_mxclk_freq(), frequency);
+   divisor = rounded_div(get_mxclk_freq(), frequency);
 
/* Set the corresponding divisor in the register. */
reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_M2XCLK_MASK;
@@ -152,7 +152,7 @@ static void setMasterClock(unsigned int frequency)
frequency = MHz(190);
 
/* Calculate the divisor */
-   divisor = roundedDiv(get_mxclk_freq(), frequency);
+   divisor = rounded_div(get_mxclk_freq(), frequency);
 
/* Set the corresponding divisor in the register. */
reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_MCLK_MASK;
-- 
2.7.4



[PATCH] staging: sm750fb: rename macro roundedDiv to rounded_div in ddk750_chip.c

2016-10-01 Thread Moshe Green
Rename CamelCased macro roundedDiv to rounded_div.

This issue was found by checkpatch.pl

Signed-off-by: Moshe Green 
---
 drivers/staging/sm750fb/ddk750_chip.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index 3a0afe1..e4efe91 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -7,7 +7,7 @@
 #include "ddk750_power.h"
 
 /* n / d + 1 / 2 = (2n + d) / 2d */
-#define roundedDiv(num, denom) ((2 * (num) + (denom)) / (2 * (denom)))
+#define rounded_div(num, denom)((2 * (num) + (denom)) / (2 * (denom)))
 #define MHz(x) ((x) * 100)
 
 logical_chip_type_t sm750_get_chip_type(void)
@@ -102,7 +102,7 @@ static void setMemoryClock(unsigned int frequency)
frequency = MHz(336);
 
/* Calculate the divisor */
-   divisor = roundedDiv(get_mxclk_freq(), frequency);
+   divisor = rounded_div(get_mxclk_freq(), frequency);
 
/* Set the corresponding divisor in the register. */
reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_M2XCLK_MASK;
@@ -152,7 +152,7 @@ static void setMasterClock(unsigned int frequency)
frequency = MHz(190);
 
/* Calculate the divisor */
-   divisor = roundedDiv(get_mxclk_freq(), frequency);
+   divisor = rounded_div(get_mxclk_freq(), frequency);
 
/* Set the corresponding divisor in the register. */
reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_MCLK_MASK;
-- 
2.7.4



Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Rich Felker
On Sat, Oct 01, 2016 at 08:00:49PM -0400, Rich Felker wrote:
> > > > > > - During the whole sequence, hrtimer expiration times are being set 
> > > > > > to
> > > > > >   exact jiffies (@ 100 Hz), whereas before it they're quite 
> > > > > > arbitrary.
> > > > > 
> > > > > When a CPU goes into NOHZ idle and the next (timer/hrtimer) is 
> > > > > farther out
> > > > > than the next tick, then tick_sched_timer is set to this next event 
> > > > > which
> > > > > can be far out. So that's expected.
> > > > > 
> > > > > > - The CLOCK_MONOTONIC hrtimer times do not match up with the
> > > > > >   timestamps; they're off by about 0.087s. I assume this is just
> > > > > >   sched_clock vs clocksource time and not a big deal.
> > > > > 
> > > > > Yes. You can tell the tracer to use clock monotonic so then they 
> > > > > should match.
> > > > > 
> > > > > > - The rcu_sched process is sleeping with timeout=1. This seems
> > > > > >   odd/excessive.
> > > > > 
> > > > > Why is that odd? That's one tick, i.e. 10ms in your case. And that's 
> > > > > not
> > > > > the problem at all. The problem is your timer not firing, but the cpu 
> > > > > is
> > > > > obviously either getting out of idle and then moves the tick ahead 
> > > > > for some
> > > > > unknown reason.
> > > > 
> > > > And a one-jiffy timeout is in fact expected behavior when HZ=100.
> > > > You have to be running HZ=250 or better to have two-jiffy timeouts,
> > > > and HZ=500 or better for three-jiffy timeouts.
> > > 
> > > One possible theory I'm looking at is that the two cpus are both
> > > waking up (leaving cpu_idle_poll or cpuidle_idle_call) every jiffy
> > > with sufficient consistency that every time the rcu_gp_fqs_check_wake
> > > loop wakes up in rcu_gp_kthread, the other cpu is in cpu_idle_loop but
> > > outside the rcu_idle_enter/rcu_idle_exit range. Would this block
> > > forward process? I added an LED indicator in rcu_gp_fqs_check_wake
> > > that shows the low 2 bits of rnp->qsmask every time it's called, and
> > > under normal operation the LEDs just flash on momentarily or just one
> > > stays on for a few seconds then goes off. During a stall both are
> > > stuck on. I'm still trying to make sense of the code but my impression
> > > so far is that, on a 2-cpu machine, this is a leaf node and the 2 bits
> > > correspond directly to cpus; is that right? If so I'm a bit confused
> > > because I don't see how forward progress could ever happen if the cpu
> > > on which rcu_gp_kthread is blocking forward progress of
> > > rcu_gp_kthread.
> > 
> > No.  If the CPUs are entering and leaving idle, and if your timers
> > were waking up rcu_sched every few jiffies like it asks, then the
> > repeated idle entry/exit events would be noticed, courtesy of the atomic
> > increments of ->dynticks and the rcu_sched kthread's snapshotting and
> > checking of this value.
> 
> I don't see how rcu_sched could notice the changes if it's stuck in
> the wait loop I think it's stuck in. There is no check of ->dynticks
> in rcu_gp_fqs_check_wake. Just in case checking *gfp & RCU_GP_FLAG_FQS
> accomplishes this, I updated my LED hacks to clear the LEDs in that
> exit path (and killed the other place that could turn them back on
> from cpu_idle_loop) but I still get 2 LEDs on for 21s followed by a
> stall message.
> 
> > Even if the CPUs were always non-idle on every
> > time force_quiescent_state() is invoked, give or take the possibility
> > of counter wrap -- but even on a 32-bit system, that takes awhile.
> 
> Perhaps force_quiescent_state is not getting invoked? Does that sound
> plausible, and if so, how should I go about debugging it? I see it is
> called from the stall reporting code, so that's presumably what's
> breaking the stalls.

I can confirm that force_quiescent_state is not being called at all
except from the stall handler. Where is it supposed to be called from?
I can't find any code paths to it except the stall handler and
__call_rcu_core, but the latter seems to only be called when adding
new rcu callbacks, not as a response to a stalled rcu_sched thread.
Maybe I'm missing something but this seems like incorrect logic in the
rcu subsystem.

Rich


Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Rich Felker
On Sat, Oct 01, 2016 at 08:00:49PM -0400, Rich Felker wrote:
> > > > > > - During the whole sequence, hrtimer expiration times are being set 
> > > > > > to
> > > > > >   exact jiffies (@ 100 Hz), whereas before it they're quite 
> > > > > > arbitrary.
> > > > > 
> > > > > When a CPU goes into NOHZ idle and the next (timer/hrtimer) is 
> > > > > farther out
> > > > > than the next tick, then tick_sched_timer is set to this next event 
> > > > > which
> > > > > can be far out. So that's expected.
> > > > > 
> > > > > > - The CLOCK_MONOTONIC hrtimer times do not match up with the
> > > > > >   timestamps; they're off by about 0.087s. I assume this is just
> > > > > >   sched_clock vs clocksource time and not a big deal.
> > > > > 
> > > > > Yes. You can tell the tracer to use clock monotonic so then they 
> > > > > should match.
> > > > > 
> > > > > > - The rcu_sched process is sleeping with timeout=1. This seems
> > > > > >   odd/excessive.
> > > > > 
> > > > > Why is that odd? That's one tick, i.e. 10ms in your case. And that's 
> > > > > not
> > > > > the problem at all. The problem is your timer not firing, but the cpu 
> > > > > is
> > > > > obviously either getting out of idle and then moves the tick ahead 
> > > > > for some
> > > > > unknown reason.
> > > > 
> > > > And a one-jiffy timeout is in fact expected behavior when HZ=100.
> > > > You have to be running HZ=250 or better to have two-jiffy timeouts,
> > > > and HZ=500 or better for three-jiffy timeouts.
> > > 
> > > One possible theory I'm looking at is that the two cpus are both
> > > waking up (leaving cpu_idle_poll or cpuidle_idle_call) every jiffy
> > > with sufficient consistency that every time the rcu_gp_fqs_check_wake
> > > loop wakes up in rcu_gp_kthread, the other cpu is in cpu_idle_loop but
> > > outside the rcu_idle_enter/rcu_idle_exit range. Would this block
> > > forward process? I added an LED indicator in rcu_gp_fqs_check_wake
> > > that shows the low 2 bits of rnp->qsmask every time it's called, and
> > > under normal operation the LEDs just flash on momentarily or just one
> > > stays on for a few seconds then goes off. During a stall both are
> > > stuck on. I'm still trying to make sense of the code but my impression
> > > so far is that, on a 2-cpu machine, this is a leaf node and the 2 bits
> > > correspond directly to cpus; is that right? If so I'm a bit confused
> > > because I don't see how forward progress could ever happen if the cpu
> > > on which rcu_gp_kthread is blocking forward progress of
> > > rcu_gp_kthread.
> > 
> > No.  If the CPUs are entering and leaving idle, and if your timers
> > were waking up rcu_sched every few jiffies like it asks, then the
> > repeated idle entry/exit events would be noticed, courtesy of the atomic
> > increments of ->dynticks and the rcu_sched kthread's snapshotting and
> > checking of this value.
> 
> I don't see how rcu_sched could notice the changes if it's stuck in
> the wait loop I think it's stuck in. There is no check of ->dynticks
> in rcu_gp_fqs_check_wake. Just in case checking *gfp & RCU_GP_FLAG_FQS
> accomplishes this, I updated my LED hacks to clear the LEDs in that
> exit path (and killed the other place that could turn them back on
> from cpu_idle_loop) but I still get 2 LEDs on for 21s followed by a
> stall message.
> 
> > Even if the CPUs were always non-idle on every
> > time force_quiescent_state() is invoked, give or take the possibility
> > of counter wrap -- but even on a 32-bit system, that takes awhile.
> 
> Perhaps force_quiescent_state is not getting invoked? Does that sound
> plausible, and if so, how should I go about debugging it? I see it is
> called from the stall reporting code, so that's presumably what's
> breaking the stalls.

I can confirm that force_quiescent_state is not being called at all
except from the stall handler. Where is it supposed to be called from?
I can't find any code paths to it except the stall handler and
__call_rcu_core, but the latter seems to only be called when adding
new rcu callbacks, not as a response to a stalled rcu_sched thread.
Maybe I'm missing something but this seems like incorrect logic in the
rcu subsystem.

Rich


[PATCH perf/core] perf script: fix a use after free crash.

2016-10-01 Thread Krister Johansen
If dso__load_kcore frees all of the existing maps, but one has already
been attached to a callchain cursor node, then we can get a SIGSEGV in
any function that happens to try to use this cursor with the invalid
map.  Use the existing map refcount mechanism to forestall cleanup of a
map until the cursor iterates past the node.

Signed-off-by: Krister Johansen 
---
 tools/perf/util/callchain.c | 12 ++--
 tools/perf/util/callchain.h | 20 
 tools/perf/util/hist.c  |  4 
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 07fd30b..15c89b2 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -439,7 +439,7 @@ fill_node(struct callchain_node *node, struct 
callchain_cursor *cursor)
}
call->ip = cursor_node->ip;
call->ms.sym = cursor_node->sym;
-   call->ms.map = cursor_node->map;
+   call->ms.map = map__get(cursor_node->map);
list_add_tail(>list, >val);
 
callchain_cursor_advance(cursor);
@@ -464,6 +464,7 @@ add_child(struct callchain_node *parent,
 
list_for_each_entry_safe(call, tmp, >val, list) {
list_del(>list);
+   map__zput(call->ms.map);
free(call);
}
free(new);
@@ -732,6 +733,7 @@ merge_chain_branch(struct callchain_cursor *cursor,
callchain_cursor_append(cursor, list->ip,
list->ms.map, list->ms.sym);
list_del(>list);
+   map__zput(list->ms.map);
free(list);
}
 
@@ -780,7 +782,8 @@ int callchain_cursor_append(struct callchain_cursor *cursor,
}
 
node->ip = ip;
-   node->map = map;
+   map__zput(node->map);
+   node->map = map__get(map);
node->sym = sym;
 
cursor->nr++;
@@ -830,6 +833,8 @@ int fill_callchain_info(struct addr_location *al, struct 
callchain_cursor_node *
goto out;
}
 
+   map__get(al->map);
+
if (al->map->groups == >machine->kmaps) {
if (machine__is_host(al->machine)) {
al->cpumode = PERF_RECORD_MISC_KERNEL;
@@ -947,11 +952,13 @@ static void free_callchain_node(struct callchain_node 
*node)
 
list_for_each_entry_safe(list, tmp, >parent_val, list) {
list_del(>list);
+   map__zput(list->ms.map);
free(list);
}
 
list_for_each_entry_safe(list, tmp, >val, list) {
list_del(>list);
+   map__zput(list->ms.map);
free(list);
}
 
@@ -1035,6 +1042,7 @@ int callchain_node__make_parent_list(struct 
callchain_node *node)
 out:
list_for_each_entry_safe(chain, new, , list) {
list_del(>list);
+   map__zput(chain->ms.map);
free(chain);
}
return -ENOMEM;
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 13e7554..0d944ef 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include "event.h"
+#include "map.h"
 #include "symbol.h"
 
 #define HELP_PAD "\t\t\t\t"
@@ -178,8 +179,13 @@ int callchain_merge(struct callchain_cursor *cursor,
  */
 static inline void callchain_cursor_reset(struct callchain_cursor *cursor)
 {
+   struct callchain_cursor_node *node;
+
cursor->nr = 0;
cursor->last = >first;
+
+   for (node = cursor->first; node != NULL; node = node->next)
+   map__zput(node->map);
 }
 
 int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip,
@@ -238,12 +244,26 @@ int perf_callchain_config(const char *var, const char 
*value);
 static inline void callchain_cursor_snapshot(struct callchain_cursor *dest,
 struct callchain_cursor *src)
 {
+   struct callchain_cursor_node *node;
+
*dest = *src;
 
dest->first = src->curr;
dest->nr -= src->pos;
+
+   for (node = dest->first; node != NULL; node = node->next)
+   map__get(node->map);
 }
 
+static inline void callchain_cursor_snapshot_rele(struct callchain_cursor 
*curs)
+{
+   struct callchain_cursor_node *node;
+
+   for (node = curs->first; node != NULL; node = node->next)
+   map__put(node->map);
+}
+
+
 #ifdef HAVE_SKIP_CALLCHAIN_IDX
 int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain);
 #else
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index b02992e..f8335e8 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1,6 +1,7 @@
 #include "util.h"
 #include "build-id.h"
 #include "hist.h"
+#include "map.h"
 #include "session.h"
 #include "sort.h"
 #include "evlist.h"
@@ -970,6 

[PATCH perf/core] perf script: fix a use after free crash.

2016-10-01 Thread Krister Johansen
If dso__load_kcore frees all of the existing maps, but one has already
been attached to a callchain cursor node, then we can get a SIGSEGV in
any function that happens to try to use this cursor with the invalid
map.  Use the existing map refcount mechanism to forestall cleanup of a
map until the cursor iterates past the node.

Signed-off-by: Krister Johansen 
---
 tools/perf/util/callchain.c | 12 ++--
 tools/perf/util/callchain.h | 20 
 tools/perf/util/hist.c  |  4 
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 07fd30b..15c89b2 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -439,7 +439,7 @@ fill_node(struct callchain_node *node, struct 
callchain_cursor *cursor)
}
call->ip = cursor_node->ip;
call->ms.sym = cursor_node->sym;
-   call->ms.map = cursor_node->map;
+   call->ms.map = map__get(cursor_node->map);
list_add_tail(>list, >val);
 
callchain_cursor_advance(cursor);
@@ -464,6 +464,7 @@ add_child(struct callchain_node *parent,
 
list_for_each_entry_safe(call, tmp, >val, list) {
list_del(>list);
+   map__zput(call->ms.map);
free(call);
}
free(new);
@@ -732,6 +733,7 @@ merge_chain_branch(struct callchain_cursor *cursor,
callchain_cursor_append(cursor, list->ip,
list->ms.map, list->ms.sym);
list_del(>list);
+   map__zput(list->ms.map);
free(list);
}
 
@@ -780,7 +782,8 @@ int callchain_cursor_append(struct callchain_cursor *cursor,
}
 
node->ip = ip;
-   node->map = map;
+   map__zput(node->map);
+   node->map = map__get(map);
node->sym = sym;
 
cursor->nr++;
@@ -830,6 +833,8 @@ int fill_callchain_info(struct addr_location *al, struct 
callchain_cursor_node *
goto out;
}
 
+   map__get(al->map);
+
if (al->map->groups == >machine->kmaps) {
if (machine__is_host(al->machine)) {
al->cpumode = PERF_RECORD_MISC_KERNEL;
@@ -947,11 +952,13 @@ static void free_callchain_node(struct callchain_node 
*node)
 
list_for_each_entry_safe(list, tmp, >parent_val, list) {
list_del(>list);
+   map__zput(list->ms.map);
free(list);
}
 
list_for_each_entry_safe(list, tmp, >val, list) {
list_del(>list);
+   map__zput(list->ms.map);
free(list);
}
 
@@ -1035,6 +1042,7 @@ int callchain_node__make_parent_list(struct 
callchain_node *node)
 out:
list_for_each_entry_safe(chain, new, , list) {
list_del(>list);
+   map__zput(chain->ms.map);
free(chain);
}
return -ENOMEM;
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 13e7554..0d944ef 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include "event.h"
+#include "map.h"
 #include "symbol.h"
 
 #define HELP_PAD "\t\t\t\t"
@@ -178,8 +179,13 @@ int callchain_merge(struct callchain_cursor *cursor,
  */
 static inline void callchain_cursor_reset(struct callchain_cursor *cursor)
 {
+   struct callchain_cursor_node *node;
+
cursor->nr = 0;
cursor->last = >first;
+
+   for (node = cursor->first; node != NULL; node = node->next)
+   map__zput(node->map);
 }
 
 int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip,
@@ -238,12 +244,26 @@ int perf_callchain_config(const char *var, const char 
*value);
 static inline void callchain_cursor_snapshot(struct callchain_cursor *dest,
 struct callchain_cursor *src)
 {
+   struct callchain_cursor_node *node;
+
*dest = *src;
 
dest->first = src->curr;
dest->nr -= src->pos;
+
+   for (node = dest->first; node != NULL; node = node->next)
+   map__get(node->map);
 }
 
+static inline void callchain_cursor_snapshot_rele(struct callchain_cursor 
*curs)
+{
+   struct callchain_cursor_node *node;
+
+   for (node = curs->first; node != NULL; node = node->next)
+   map__put(node->map);
+}
+
+
 #ifdef HAVE_SKIP_CALLCHAIN_IDX
 int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain);
 #else
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index b02992e..f8335e8 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1,6 +1,7 @@
 #include "util.h"
 #include "build-id.h"
 #include "hist.h"
+#include "map.h"
 #include "session.h"
 #include "sort.h"
 #include "evlist.h"
@@ -970,6 +971,8 @@ 

arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3900' requires '-mfp32'

2016-10-01 Thread kbuild test robot
Hi Guenter,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e MIPS: VDSO: Fix build error 
with binutils 2.24 and earlier
date:   9 months ago
config: mips-jmr3927_defconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3900' requires '-mfp32'
/*


vim +1 arch/mips/vdso/gettimeofday.c

a7f4df4e Alex Smith 2015-10-21 @1  /*
a7f4df4e Alex Smith 2015-10-21  2   * Copyright (C) 2015 Imagination 
Technologies
a7f4df4e Alex Smith 2015-10-21  3   * Author: Alex Smith 
a7f4df4e Alex Smith 2015-10-21  4   *
a7f4df4e Alex Smith 2015-10-21  5   * This program is free software; you can 
redistribute it and/or modify it
a7f4df4e Alex Smith 2015-10-21  6   * under the terms of the GNU General Public 
License as published by the
a7f4df4e Alex Smith 2015-10-21  7   * Free Software Foundation;  either version 
2 of the  License, or (at your
a7f4df4e Alex Smith 2015-10-21  8   * option) any later version.
a7f4df4e Alex Smith 2015-10-21  9   */

:: The code at line 1 was first introduced by commit
:: a7f4df4e21dd8a8dab96e88acd2c9c5017b83fc6 MIPS: VDSO: Add implementations 
of gettimeofday() and clock_gettime()

:: TO: Alex Smith 
:: CC: Ralf Baechle 

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


.config.gz
Description: application/gzip


arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3900' requires '-mfp32'

2016-10-01 Thread kbuild test robot
Hi Guenter,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e MIPS: VDSO: Fix build error 
with binutils 2.24 and earlier
date:   9 months ago
config: mips-jmr3927_defconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3900' requires '-mfp32'
/*


vim +1 arch/mips/vdso/gettimeofday.c

a7f4df4e Alex Smith 2015-10-21 @1  /*
a7f4df4e Alex Smith 2015-10-21  2   * Copyright (C) 2015 Imagination 
Technologies
a7f4df4e Alex Smith 2015-10-21  3   * Author: Alex Smith 
a7f4df4e Alex Smith 2015-10-21  4   *
a7f4df4e Alex Smith 2015-10-21  5   * This program is free software; you can 
redistribute it and/or modify it
a7f4df4e Alex Smith 2015-10-21  6   * under the terms of the GNU General Public 
License as published by the
a7f4df4e Alex Smith 2015-10-21  7   * Free Software Foundation;  either version 
2 of the  License, or (at your
a7f4df4e Alex Smith 2015-10-21  8   * option) any later version.
a7f4df4e Alex Smith 2015-10-21  9   */

:: The code at line 1 was first introduced by commit
:: a7f4df4e21dd8a8dab96e88acd2c9c5017b83fc6 MIPS: VDSO: Add implementations 
of gettimeofday() and clock_gettime()

:: TO: Alex Smith 
:: CC: Ralf Baechle 

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


.config.gz
Description: application/gzip


arch/mips/vdso/elf.S:1:0: error: '-march=r3900' requires '-mfp32'

2016-10-01 Thread kbuild test robot
Hi Alex,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: ebb5e78cc63417a35254a791de66e1cc84f963cc MIPS: Initial implementation 
of a VDSO
date:   11 months ago
config: mips-jmr3927_defconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout ebb5e78cc63417a35254a791de66e1cc84f963cc
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/elf.S:1:0: error: '-march=r3900' requires '-mfp32'
/*

--
>> arch/mips/vdso/sigreturn.S:1:0: error: '-march=r3900' requires '-mfp32'
/*


vim +1 arch/mips/vdso/elf.S

   > 1  /*
 2   * Copyright (C) 2015 Imagination Technologies
 3   * Author: Alex Smith 
 4   *

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


.config.gz
Description: application/gzip


arch/mips/vdso/elf.S:1:0: error: '-march=r3900' requires '-mfp32'

2016-10-01 Thread kbuild test robot
Hi Alex,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: ebb5e78cc63417a35254a791de66e1cc84f963cc MIPS: Initial implementation 
of a VDSO
date:   11 months ago
config: mips-jmr3927_defconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout ebb5e78cc63417a35254a791de66e1cc84f963cc
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/elf.S:1:0: error: '-march=r3900' requires '-mfp32'
/*

--
>> arch/mips/vdso/sigreturn.S:1:0: error: '-march=r3900' requires '-mfp32'
/*


vim +1 arch/mips/vdso/elf.S

   > 1  /*
 2   * Copyright (C) 2015 Imagination Technologies
 3   * Author: Alex Smith 
 4   *

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


.config.gz
Description: application/gzip


[PATCH] selftests/futex: Check ANSI terminal color support

2016-10-01 Thread SeongJae Park
Because test for color support of the running shell does not aware ANSI
type terminals, it does not print colorful messages on some environemnt.
This commit modifies the test to aware ANSI type terminal, too.

Signed-off-by: SeongJae Park 
---
 tools/testing/selftests/futex/functional/run.sh | 2 +-
 tools/testing/selftests/futex/run.sh| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/run.sh 
b/tools/testing/selftests/futex/functional/run.sh
index e87dbe2a0b0d..7ff002eed624 100755
--- a/tools/testing/selftests/futex/functional/run.sh
+++ b/tools/testing/selftests/futex/functional/run.sh
@@ -24,7 +24,7 @@
 
 # Test for a color capable console
 if [ -z "$USE_COLOR" ]; then
-tput setf 7
+tput setf 7 || tput setaf 7
 if [ $? -eq 0 ]; then
 USE_COLOR=1
 tput sgr0
diff --git a/tools/testing/selftests/futex/run.sh 
b/tools/testing/selftests/futex/run.sh
index 4126312ad64e..88bcb1767362 100755
--- a/tools/testing/selftests/futex/run.sh
+++ b/tools/testing/selftests/futex/run.sh
@@ -23,7 +23,7 @@
 
 # Test for a color capable shell and pass the result to the subdir scripts
 USE_COLOR=0
-tput setf 7
+tput setf 7 || tput setaf 7
 if [ $? -eq 0 ]; then
 USE_COLOR=1
 tput sgr0
-- 
2.10.0



[PATCH] selftests/futex: Check ANSI terminal color support

2016-10-01 Thread SeongJae Park
Because test for color support of the running shell does not aware ANSI
type terminals, it does not print colorful messages on some environemnt.
This commit modifies the test to aware ANSI type terminal, too.

Signed-off-by: SeongJae Park 
---
 tools/testing/selftests/futex/functional/run.sh | 2 +-
 tools/testing/selftests/futex/run.sh| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/run.sh 
b/tools/testing/selftests/futex/functional/run.sh
index e87dbe2a0b0d..7ff002eed624 100755
--- a/tools/testing/selftests/futex/functional/run.sh
+++ b/tools/testing/selftests/futex/functional/run.sh
@@ -24,7 +24,7 @@
 
 # Test for a color capable console
 if [ -z "$USE_COLOR" ]; then
-tput setf 7
+tput setf 7 || tput setaf 7
 if [ $? -eq 0 ]; then
 USE_COLOR=1
 tput sgr0
diff --git a/tools/testing/selftests/futex/run.sh 
b/tools/testing/selftests/futex/run.sh
index 4126312ad64e..88bcb1767362 100755
--- a/tools/testing/selftests/futex/run.sh
+++ b/tools/testing/selftests/futex/run.sh
@@ -23,7 +23,7 @@
 
 # Test for a color capable shell and pass the result to the subdir scripts
 USE_COLOR=0
-tput setf 7
+tput setf 7 || tput setaf 7
 if [ $? -eq 0 ]; then
 USE_COLOR=1
 tput sgr0
-- 
2.10.0



[PATCH] padata: add helper function for queue length

2016-10-01 Thread Jason A. Donenfeld
Since padata has a maximum number of inflight jobs, currently 1000, it's
very useful to know how many jobs are currently queued up. This adds a
simple helper function to expose this information.

Signed-off-by: Jason A. Donenfeld 
---
 include/linux/padata.h |  2 ++
 kernel/padata.c| 16 
 2 files changed, 18 insertions(+)

diff --git a/include/linux/padata.h b/include/linux/padata.h
index 113ee62..4840ae4 100644
--- a/include/linux/padata.h
+++ b/include/linux/padata.h
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2008, 2009 secunet Security Networks AG
  * Copyright (C) 2008, 2009 Steffen Klassert 
+ * Copyright (C) 2016 Jason A. Donenfeld 
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -181,4 +182,5 @@ extern int padata_register_cpumask_notifier(struct 
padata_instance *pinst,
struct notifier_block *nblock);
 extern int padata_unregister_cpumask_notifier(struct padata_instance *pinst,
  struct notifier_block *nblock);
+extern int padata_queue_len(struct padata_instance *pinst);
 #endif
diff --git a/kernel/padata.c b/kernel/padata.c
index 9932788..17c1e08 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 2008, 2009 secunet Security Networks AG
  * Copyright (C) 2008, 2009 Steffen Klassert 
+ * Copyright (C) 2016 Jason A. Donenfeld 
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -1039,3 +1040,18 @@ void padata_free(struct padata_instance *pinst)
kobject_put(>kobj);
 }
 EXPORT_SYMBOL(padata_free);
+
+/**
+ * padata_queue_len - retreive the number of in progress jobs
+ *
+ * @padata_inst: padata instance from which to read the queue size
+ */
+int padata_queue_len(struct padata_instance *pinst)
+{
+   int len;
+   rcu_read_lock_bh();
+   len = atomic_read(_dereference_bh(pinst->pd)->refcnt);
+   rcu_read_unlock_bh();
+   return len;
+}
+EXPORT_SYMBOL(padata_queue_len);
-- 
2.10.0



[PATCH] padata: add helper function for queue length

2016-10-01 Thread Jason A. Donenfeld
Since padata has a maximum number of inflight jobs, currently 1000, it's
very useful to know how many jobs are currently queued up. This adds a
simple helper function to expose this information.

Signed-off-by: Jason A. Donenfeld 
---
 include/linux/padata.h |  2 ++
 kernel/padata.c| 16 
 2 files changed, 18 insertions(+)

diff --git a/include/linux/padata.h b/include/linux/padata.h
index 113ee62..4840ae4 100644
--- a/include/linux/padata.h
+++ b/include/linux/padata.h
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2008, 2009 secunet Security Networks AG
  * Copyright (C) 2008, 2009 Steffen Klassert 
+ * Copyright (C) 2016 Jason A. Donenfeld 
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -181,4 +182,5 @@ extern int padata_register_cpumask_notifier(struct 
padata_instance *pinst,
struct notifier_block *nblock);
 extern int padata_unregister_cpumask_notifier(struct padata_instance *pinst,
  struct notifier_block *nblock);
+extern int padata_queue_len(struct padata_instance *pinst);
 #endif
diff --git a/kernel/padata.c b/kernel/padata.c
index 9932788..17c1e08 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 2008, 2009 secunet Security Networks AG
  * Copyright (C) 2008, 2009 Steffen Klassert 
+ * Copyright (C) 2016 Jason A. Donenfeld 
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -1039,3 +1040,18 @@ void padata_free(struct padata_instance *pinst)
kobject_put(>kobj);
 }
 EXPORT_SYMBOL(padata_free);
+
+/**
+ * padata_queue_len - retreive the number of in progress jobs
+ *
+ * @padata_inst: padata instance from which to read the queue size
+ */
+int padata_queue_len(struct padata_instance *pinst)
+{
+   int len;
+   rcu_read_lock_bh();
+   len = atomic_read(_dereference_bh(pinst->pd)->refcnt);
+   rcu_read_unlock_bh();
+   return len;
+}
+EXPORT_SYMBOL(padata_queue_len);
-- 
2.10.0



vgacon.c:undefined reference to `screen_info'

2016-10-01 Thread kbuild test robot
Hi Chen,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: f69405ce6c0fc9f4a039011007371b31f80b470d openrisc: include: asm: 
Kbuild: add default "vga.h"
date:   2 years, 11 months ago
config: openrisc-alldefconfig (attached as .config)
compiler: or32-linux-gcc (GCC) 4.5.1-or32-1.0rc1
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout f69405ce6c0fc9f4a039011007371b31f80b470d
# save the attached .config to linux build tree
make.cross ARCH=openrisc 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `vgacon_save_screen':
>> vgacon.c:(.text+0x20e0): undefined reference to `screen_info'
   vgacon.c:(.text+0x20e8): undefined reference to `screen_info'
   drivers/built-in.o: In function `vgacon_init':
   vgacon.c:(.text+0x284c): undefined reference to `screen_info'
   vgacon.c:(.text+0x2850): undefined reference to `screen_info'
   drivers/built-in.o: In function `vgacon_startup':
   vgacon.c:(.text+0x28d8): undefined reference to `screen_info'
   drivers/built-in.o:vgacon.c:(.text+0x28f0): more undefined references to 
`screen_info' follow

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


.config.gz
Description: application/gzip


vgacon.c:undefined reference to `screen_info'

2016-10-01 Thread kbuild test robot
Hi Chen,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: f69405ce6c0fc9f4a039011007371b31f80b470d openrisc: include: asm: 
Kbuild: add default "vga.h"
date:   2 years, 11 months ago
config: openrisc-alldefconfig (attached as .config)
compiler: or32-linux-gcc (GCC) 4.5.1-or32-1.0rc1
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout f69405ce6c0fc9f4a039011007371b31f80b470d
# save the attached .config to linux build tree
make.cross ARCH=openrisc 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `vgacon_save_screen':
>> vgacon.c:(.text+0x20e0): undefined reference to `screen_info'
   vgacon.c:(.text+0x20e8): undefined reference to `screen_info'
   drivers/built-in.o: In function `vgacon_init':
   vgacon.c:(.text+0x284c): undefined reference to `screen_info'
   vgacon.c:(.text+0x2850): undefined reference to `screen_info'
   drivers/built-in.o: In function `vgacon_startup':
   vgacon.c:(.text+0x28d8): undefined reference to `screen_info'
   drivers/built-in.o:vgacon.c:(.text+0x28f0): more undefined references to 
`screen_info' follow

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


.config.gz
Description: application/gzip


include/linux/kprobes.h:361:2: error: invalid use of undefined type 'struct kprobe_ctlblk'

2016-10-01 Thread kbuild test robot
Hi Russell,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: b2c0b2cbb282f0cf42518ffacbe197e6f2884168 nmi: create generic NMI 
backtrace implementation
date:   1 year, 3 months ago
config: mn10300-allyesconfig (attached as .config)
compiler: am33_2.0-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout b2c0b2cbb282f0cf42518ffacbe197e6f2884168
# save the attached .config to linux build tree
make.cross ARCH=mn10300 

All errors (new ones prefixed by >>):

   In file included from lib/nmi_backtrace.c:17:0:
   include/linux/kprobes.h: In function 'get_kprobe_ctlblk':
>> include/linux/kprobes.h:361:2: error: invalid use of undefined type 'struct 
>> kprobe_ctlblk'
 return this_cpu_ptr(_ctlblk);
 ^~

vim +361 include/linux/kprobes.h

e65845235 Ananth N Mavinakayanahalli 2005-11-07  355  {
b76834bc1 Christoph Lameter  2010-12-06  356
__this_cpu_write(current_kprobe, NULL);
e65845235 Ananth N Mavinakayanahalli 2005-11-07  357  }
e65845235 Ananth N Mavinakayanahalli 2005-11-07  358  
e65845235 Ananth N Mavinakayanahalli 2005-11-07  359  static inline struct 
kprobe_ctlblk *get_kprobe_ctlblk(void)
e65845235 Ananth N Mavinakayanahalli 2005-11-07  360  {
bdffd893a Christoph Lameter  2014-04-29 @361return 
this_cpu_ptr(_ctlblk);
e65845235 Ananth N Mavinakayanahalli 2005-11-07  362  }
e65845235 Ananth N Mavinakayanahalli 2005-11-07  363  
^1da177e4 Linus Torvalds 2005-04-16  364  int 
register_kprobe(struct kprobe *p);

:: The code at line 361 was first introduced by commit
:: bdffd893a0e9c431304142d12d9a0a21d365c502 tracing: Replace __get_cpu_var 
uses with this_cpu_ptr

:: TO: Christoph Lameter 
:: CC: Steven Rostedt 

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


.config.gz
Description: application/gzip


include/linux/kprobes.h:361:2: error: invalid use of undefined type 'struct kprobe_ctlblk'

2016-10-01 Thread kbuild test robot
Hi Russell,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: b2c0b2cbb282f0cf42518ffacbe197e6f2884168 nmi: create generic NMI 
backtrace implementation
date:   1 year, 3 months ago
config: mn10300-allyesconfig (attached as .config)
compiler: am33_2.0-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout b2c0b2cbb282f0cf42518ffacbe197e6f2884168
# save the attached .config to linux build tree
make.cross ARCH=mn10300 

All errors (new ones prefixed by >>):

   In file included from lib/nmi_backtrace.c:17:0:
   include/linux/kprobes.h: In function 'get_kprobe_ctlblk':
>> include/linux/kprobes.h:361:2: error: invalid use of undefined type 'struct 
>> kprobe_ctlblk'
 return this_cpu_ptr(_ctlblk);
 ^~

vim +361 include/linux/kprobes.h

e65845235 Ananth N Mavinakayanahalli 2005-11-07  355  {
b76834bc1 Christoph Lameter  2010-12-06  356
__this_cpu_write(current_kprobe, NULL);
e65845235 Ananth N Mavinakayanahalli 2005-11-07  357  }
e65845235 Ananth N Mavinakayanahalli 2005-11-07  358  
e65845235 Ananth N Mavinakayanahalli 2005-11-07  359  static inline struct 
kprobe_ctlblk *get_kprobe_ctlblk(void)
e65845235 Ananth N Mavinakayanahalli 2005-11-07  360  {
bdffd893a Christoph Lameter  2014-04-29 @361return 
this_cpu_ptr(_ctlblk);
e65845235 Ananth N Mavinakayanahalli 2005-11-07  362  }
e65845235 Ananth N Mavinakayanahalli 2005-11-07  363  
^1da177e4 Linus Torvalds 2005-04-16  364  int 
register_kprobe(struct kprobe *p);

:: The code at line 361 was first introduced by commit
:: bdffd893a0e9c431304142d12d9a0a21d365c502 tracing: Replace __get_cpu_var 
uses with this_cpu_ptr

:: TO: Christoph Lameter 
:: CC: Steven Rostedt 

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


.config.gz
Description: application/gzip


[PATCH] ARM: dts: vfxxx: Add node corresponding to OCOTP

2016-10-01 Thread Andrey Smirnov
Add node corresponding to OCOTP IP block.

Signed-off-by: Andrey Smirnov 
---
 arch/arm/boot/dts/vfxxx.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/vfxxx.dtsi b/arch/arm/boot/dts/vfxxx.dtsi
index 2c13ec6..75850c0 100644
--- a/arch/arm/boot/dts/vfxxx.dtsi
+++ b/arch/arm/boot/dts/vfxxx.dtsi
@@ -520,6 +520,12 @@
status = "disabled";
};
 
+   ocotp: ocotp@400a5000 {
+   compatible = "fsl,vf610-ocotp";
+   reg = <0x400a5000 0x1000>;
+   clocks = < VF610_CLK_OCOTP>;
+   };
+
snvs0: snvs@400a7000 {
compatible = "fsl,sec-v4.0-mon", "syscon", 
"simple-mfd";
reg = <0x400a7000 0x2000>;
-- 
2.5.5



[PATCH] ARM: dts: vfxxx: Add node corresponding to OCOTP

2016-10-01 Thread Andrey Smirnov
Add node corresponding to OCOTP IP block.

Signed-off-by: Andrey Smirnov 
---
 arch/arm/boot/dts/vfxxx.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/vfxxx.dtsi b/arch/arm/boot/dts/vfxxx.dtsi
index 2c13ec6..75850c0 100644
--- a/arch/arm/boot/dts/vfxxx.dtsi
+++ b/arch/arm/boot/dts/vfxxx.dtsi
@@ -520,6 +520,12 @@
status = "disabled";
};
 
+   ocotp: ocotp@400a5000 {
+   compatible = "fsl,vf610-ocotp";
+   reg = <0x400a5000 0x1000>;
+   clocks = < VF610_CLK_OCOTP>;
+   };
+
snvs0: snvs@400a7000 {
compatible = "fsl,sec-v4.0-mon", "syscon", 
"simple-mfd";
reg = <0x400a7000 0x2000>;
-- 
2.5.5



[PATCH] ARM: dts: vf610-zii-dev-rev-b: Remove I2C3

2016-10-01 Thread Andrey Smirnov
I2C3 bus was only brought out in revision A1 of the board and revision
B1 only brings out 3 I2C busses (I2C0, I2C1 and I2C2).

Signed-off-by: Andrey Smirnov 
---
 arch/arm/boot/dts/vf610-zii-dev-rev-b.dts | 14 --
 1 file changed, 14 deletions(-)

diff --git a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts 
b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
index 5c1fcab..fa19cfd 100644
--- a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
+++ b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
@@ -499,13 +499,6 @@
};
 };
 
- {
-   clock-frequency = <10>;
-   pinctrl-names = "default";
-   pinctrl-0 = <_i2c3>;
-   status = "okay";
-};
-
  {
pinctrl-names = "default";
pinctrl-0 = <_uart0>;
@@ -663,13 +656,6 @@
>;
};
 
-   pinctrl_i2c3: i2c3grp {
-   fsl,pins = <
-   VF610_PAD_PTA30__I2C3_SCL   0x37ff
-   VF610_PAD_PTA31__I2C3_SDA   0x37ff
-   >;
-   };
-
pinctrl_leds_debug: pinctrl-leds-debug {
fsl,pins = <
 VF610_PAD_PTD20__GPIO_74   0x31c2
-- 
2.5.5



[PATCH] ARM: dts: vf610-zii-dev-rev-b: Remove I2C3

2016-10-01 Thread Andrey Smirnov
I2C3 bus was only brought out in revision A1 of the board and revision
B1 only brings out 3 I2C busses (I2C0, I2C1 and I2C2).

Signed-off-by: Andrey Smirnov 
---
 arch/arm/boot/dts/vf610-zii-dev-rev-b.dts | 14 --
 1 file changed, 14 deletions(-)

diff --git a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts 
b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
index 5c1fcab..fa19cfd 100644
--- a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
+++ b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
@@ -499,13 +499,6 @@
};
 };
 
- {
-   clock-frequency = <10>;
-   pinctrl-names = "default";
-   pinctrl-0 = <_i2c3>;
-   status = "okay";
-};
-
  {
pinctrl-names = "default";
pinctrl-0 = <_uart0>;
@@ -663,13 +656,6 @@
>;
};
 
-   pinctrl_i2c3: i2c3grp {
-   fsl,pins = <
-   VF610_PAD_PTA30__I2C3_SCL   0x37ff
-   VF610_PAD_PTA31__I2C3_SDA   0x37ff
-   >;
-   };
-
pinctrl_leds_debug: pinctrl-leds-debug {
fsl,pins = <
 VF610_PAD_PTD20__GPIO_74   0x31c2
-- 
2.5.5



drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used uninitialized in this function

2016-10-01 Thread kbuild test robot
Hi Dave,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91 drm/i915: Introduce & use new 
lightweight SGL iterators
date:   5 months ago
config: x86_64-randconfig-s0-10020750 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All errors (new ones prefixed by >>):

   cc1: warnings being treated as errors
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen8_ggtt_insert_entries':
>> drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used 
>> uninitialized in this function
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen6_ggtt_insert_entries':
   drivers/gpu/drm/i915/i915_gem_gtt.c:2442: error: 'gtt_entry' may be used 
uninitialized in this function

vim +/gtt_entry +2367 drivers/gpu/drm/i915/i915_gem_gtt.c

  2361   enum i915_cache_level level, u32 
unused)
  2362  {
  2363  struct drm_i915_private *dev_priv = to_i915(vm->dev);
  2364  struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
  2365  struct sgt_iter sgt_iter;
  2366  gen8_pte_t __iomem *gtt_entries;
> 2367  gen8_pte_t gtt_entry;
  2368  dma_addr_t addr;
  2369  int rpm_atomic_seq;
  2370  int i = 0;

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


.config.gz
Description: application/gzip


drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used uninitialized in this function

2016-10-01 Thread kbuild test robot
Hi Dave,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91 drm/i915: Introduce & use new 
lightweight SGL iterators
date:   5 months ago
config: x86_64-randconfig-s0-10020750 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All errors (new ones prefixed by >>):

   cc1: warnings being treated as errors
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen8_ggtt_insert_entries':
>> drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used 
>> uninitialized in this function
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen6_ggtt_insert_entries':
   drivers/gpu/drm/i915/i915_gem_gtt.c:2442: error: 'gtt_entry' may be used 
uninitialized in this function

vim +/gtt_entry +2367 drivers/gpu/drm/i915/i915_gem_gtt.c

  2361   enum i915_cache_level level, u32 
unused)
  2362  {
  2363  struct drm_i915_private *dev_priv = to_i915(vm->dev);
  2364  struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
  2365  struct sgt_iter sgt_iter;
  2366  gen8_pte_t __iomem *gtt_entries;
> 2367  gen8_pte_t gtt_entry;
  2368  dma_addr_t addr;
  2369  int rpm_atomic_seq;
  2370  int i = 0;

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


.config.gz
Description: application/gzip


Re: [PATCH v3 07/13] futex: Throughput-optimized (TP) futexes

2016-10-01 Thread Waiman Long

On 10/01/2016 02:47 AM, Thomas Gleixner wrote:

On Fri, 30 Sep 2016, Waiman Long wrote:

+   WRITE_ONCE(state->owner, current);
+   preempt_disable();
+   for (;;) {
+   ret = futex_trylock(uaddr, vpid,, true);

Did you actually read what I said? You CANNOT access userspace in a preempt
disabled region without disabling pagefaults and handle the resulting
wreckage yourself.


I think I had missed that comment. My bad:-(

I will fix that with the code changes below. I will also double-check 
your comments again to see if I miss some others.


Cheers,
Longman


---[ cut here 
]-


diff --git a/kernel/futex.c b/kernel/futex.c
index bc16eca..132a36d 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -3520,6 +3520,13 @@ static int futex_spin_on_owner(u32 __user *uaddr, 
u32 vpid,

bool on_owner_pi_list = false;

WRITE_ONCE(state->owner, current);
+retry:
+   /*
+* The preempt_disable() has similar effect as pagefault_disable().
+* As a result, we will have to disable page fault as well and 
handle

+* the case of faulting in the futex word.
+*/
+   pagefault_disable();
preempt_disable();
for (;; loop--) {
ret = futex_trylock(uaddr, vpid, , true);
@@ -3648,6 +3655,14 @@ static int futex_spin_on_owner(u32 __user *uaddr, 
u32 vpid,

}
 out:
preempt_enable();
+   pagefault_enable();
+
+   if (ret == -EFAULT) {
+   ret = fault_in_user_writeable(uaddr);
+   if (!ret)
+   goto retry;
+   }
+
if (owner_task) {
if (on_owner_pi_list)
task_pi_list_del(owner_task, state, false);



Re: [PATCH v3 07/13] futex: Throughput-optimized (TP) futexes

2016-10-01 Thread Waiman Long

On 10/01/2016 02:47 AM, Thomas Gleixner wrote:

On Fri, 30 Sep 2016, Waiman Long wrote:

+   WRITE_ONCE(state->owner, current);
+   preempt_disable();
+   for (;;) {
+   ret = futex_trylock(uaddr, vpid,, true);

Did you actually read what I said? You CANNOT access userspace in a preempt
disabled region without disabling pagefaults and handle the resulting
wreckage yourself.


I think I had missed that comment. My bad:-(

I will fix that with the code changes below. I will also double-check 
your comments again to see if I miss some others.


Cheers,
Longman


---[ cut here 
]-


diff --git a/kernel/futex.c b/kernel/futex.c
index bc16eca..132a36d 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -3520,6 +3520,13 @@ static int futex_spin_on_owner(u32 __user *uaddr, 
u32 vpid,

bool on_owner_pi_list = false;

WRITE_ONCE(state->owner, current);
+retry:
+   /*
+* The preempt_disable() has similar effect as pagefault_disable().
+* As a result, we will have to disable page fault as well and 
handle

+* the case of faulting in the futex word.
+*/
+   pagefault_disable();
preempt_disable();
for (;; loop--) {
ret = futex_trylock(uaddr, vpid, , true);
@@ -3648,6 +3655,14 @@ static int futex_spin_on_owner(u32 __user *uaddr, 
u32 vpid,

}
 out:
preempt_enable();
+   pagefault_enable();
+
+   if (ret == -EFAULT) {
+   ret = fault_in_user_writeable(uaddr);
+   if (!ret)
+   goto retry;
+   }
+
if (owner_task) {
if (on_owner_pi_list)
task_pi_list_del(owner_task, state, false);



Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread Rik van Riel
On Sat, 2016-10-01 at 16:44 -0700, Andy Lutomirski wrote:
> On Sat, Oct 1, 2016 at 1:31 PM,   wrote:
> > 
> > 
> > +static inline void switch_fpu_finish(void)
> >  {
> > +   set_thread_flag(TIF_LOAD_FPU);
> >  }
> 
> I can imagine this causing problems with kernel code that accesses
> current's FPU state, e.g. get_xsave_field_ptr(). 

That makes me wonder, what test programs do people have
to verify the correctness of the FPU switching code?

I have a few floating point benchmarks that check
the results for correctness, but nothing that adds in
signals, for example.

What do people use?

-- 
All Rights Reversed.

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


Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread Rik van Riel
On Sat, 2016-10-01 at 16:44 -0700, Andy Lutomirski wrote:
> On Sat, Oct 1, 2016 at 1:31 PM,   wrote:
> > 
> > 
> > +static inline void switch_fpu_finish(void)
> >  {
> > +   set_thread_flag(TIF_LOAD_FPU);
> >  }
> 
> I can imagine this causing problems with kernel code that accesses
> current's FPU state, e.g. get_xsave_field_ptr(). 

That makes me wonder, what test programs do people have
to verify the correctness of the FPU switching code?

I have a few floating point benchmarks that check
the results for correctness, but nothing that adds in
signals, for example.

What do people use?

-- 
All Rights Reversed.

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


Re: [PATCH v2 1/1] mm/percpu.c: fix potential memory leakage for pcpu_embed_first_chunk()

2016-10-01 Thread zijun_hu
Hi Tejun,
  as we discussed, i include some discussion content in the commit message.
could you give some new comments or acknowledgment for this patch?

On 2016/9/30 19:30, zijun_hu wrote:
> From: zijun_hu 
> 
> it will cause memory leakage for pcpu_embed_first_chunk() to go to
> label @out_free if the chunk spans over 3/4 VMALLOC area. all memory
> are allocated and recorded into array @areas for each CPU group, but
> the memory allocated aren't be freed before returning after going to
> label @out_free.
> 
> in order to fix this bug, we check chunk spanned area immediately
> after completing memory allocation for all CPU group, we go to label
> @out_free_areas other than @out_free to free all memory allocated if
> the checking is failed.
> 
> in order to verify the approach, we dump all memory allocated then
> enforce the jump then dump all memory freed, the result is okay after
> checking whether we free all memory we allocate in this function.
> 
> BTW, The approach is chosen after thinking over the below scenes
>  - we don't go to label @out_free directly to fix this issue since we
>maybe free several allocated memory blocks twice
>  - the aim of jumping after pcpu_setup_first_chunk() is bypassing free
>usable memory other than handling error, moreover, the function does
>not return error code in any case, it either panics due to BUG_ON()
>or return 0.
> 
> Signed-off-by: zijun_hu 
> Tested-by: zijun_hu 
> ---
>  this patch is based on mmotm/linux-next branch so can be
>  applied to them directly
> 
>  Changes in v2: 
>   - more detailed commit message is provided as discussed
> with t...@kernel.org
> 
>  mm/percpu.c | 36 ++--
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index 41d9d0b35801..7a5dae185ce1 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -1963,7 +1963,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, 
> size_t dyn_size,
>   struct pcpu_alloc_info *ai;
>   size_t size_sum, areas_size;
>   unsigned long max_distance;
> - int group, i, rc;
> + int group, i, j, rc;
>  
>   ai = pcpu_build_alloc_info(reserved_size, dyn_size, atom_size,
>  cpu_distance_fn);
> @@ -1979,7 +1979,8 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, 
> size_t dyn_size,
>   goto out_free;
>   }
>  
> - /* allocate, copy and determine base address */
> + /* allocate, copy and determine base address & max_distance */
> + j = 0;
>   for (group = 0; group < ai->nr_groups; group++) {
>   struct pcpu_group_info *gi = >groups[group];
>   unsigned int cpu = NR_CPUS;
> @@ -2000,6 +2001,21 @@ int __init pcpu_embed_first_chunk(size_t 
> reserved_size, size_t dyn_size,
>   areas[group] = ptr;
>  
>   base = min(ptr, base);
> + if (ptr > areas[j])
> + j = group;
> + }
> + max_distance = areas[j] - base;
> + max_distance += ai->unit_size * ai->groups[j].nr_units;
> +
> + /* warn if maximum distance is further than 75% of vmalloc space */
> + if (max_distance > VMALLOC_TOTAL * 3 / 4) {
> + pr_warn("max_distance=0x%lx too large for vmalloc space 
> 0x%lx\n",
> + max_distance, VMALLOC_TOTAL);
> +#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
> + /* and fail if we have fallback */
> + rc = -EINVAL;
> + goto out_free_areas;
> +#endif
>   }
>  
>   /*
> @@ -2024,24 +2040,8 @@ int __init pcpu_embed_first_chunk(size_t 
> reserved_size, size_t dyn_size,
>   }
>  
>   /* base address is now known, determine group base offsets */
> - i = 0;
>   for (group = 0; group < ai->nr_groups; group++) {
>   ai->groups[group].base_offset = areas[group] - base;
> - if (areas[group] > areas[i])
> - i = group;
> - }
> - max_distance = ai->groups[i].base_offset +
> - (unsigned long)ai->unit_size * ai->groups[i].nr_units;
> -
> - /* warn if maximum distance is further than 75% of vmalloc space */
> - if (max_distance > VMALLOC_TOTAL * 3 / 4) {
> - pr_warn("max_distance=0x%lx too large for vmalloc space 
> 0x%lx\n",
> - max_distance, VMALLOC_TOTAL);
> -#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
> - /* and fail if we have fallback */
> - rc = -EINVAL;
> - goto out_free;
> -#endif
>   }
>  
>   pr_info("Embedded %zu pages/cpu @%p s%zu r%zu d%zu u%zu\n",
> 



Re: [PATCH v2 1/1] mm/percpu.c: fix potential memory leakage for pcpu_embed_first_chunk()

2016-10-01 Thread zijun_hu
Hi Tejun,
  as we discussed, i include some discussion content in the commit message.
could you give some new comments or acknowledgment for this patch?

On 2016/9/30 19:30, zijun_hu wrote:
> From: zijun_hu 
> 
> it will cause memory leakage for pcpu_embed_first_chunk() to go to
> label @out_free if the chunk spans over 3/4 VMALLOC area. all memory
> are allocated and recorded into array @areas for each CPU group, but
> the memory allocated aren't be freed before returning after going to
> label @out_free.
> 
> in order to fix this bug, we check chunk spanned area immediately
> after completing memory allocation for all CPU group, we go to label
> @out_free_areas other than @out_free to free all memory allocated if
> the checking is failed.
> 
> in order to verify the approach, we dump all memory allocated then
> enforce the jump then dump all memory freed, the result is okay after
> checking whether we free all memory we allocate in this function.
> 
> BTW, The approach is chosen after thinking over the below scenes
>  - we don't go to label @out_free directly to fix this issue since we
>maybe free several allocated memory blocks twice
>  - the aim of jumping after pcpu_setup_first_chunk() is bypassing free
>usable memory other than handling error, moreover, the function does
>not return error code in any case, it either panics due to BUG_ON()
>or return 0.
> 
> Signed-off-by: zijun_hu 
> Tested-by: zijun_hu 
> ---
>  this patch is based on mmotm/linux-next branch so can be
>  applied to them directly
> 
>  Changes in v2: 
>   - more detailed commit message is provided as discussed
> with t...@kernel.org
> 
>  mm/percpu.c | 36 ++--
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index 41d9d0b35801..7a5dae185ce1 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -1963,7 +1963,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, 
> size_t dyn_size,
>   struct pcpu_alloc_info *ai;
>   size_t size_sum, areas_size;
>   unsigned long max_distance;
> - int group, i, rc;
> + int group, i, j, rc;
>  
>   ai = pcpu_build_alloc_info(reserved_size, dyn_size, atom_size,
>  cpu_distance_fn);
> @@ -1979,7 +1979,8 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, 
> size_t dyn_size,
>   goto out_free;
>   }
>  
> - /* allocate, copy and determine base address */
> + /* allocate, copy and determine base address & max_distance */
> + j = 0;
>   for (group = 0; group < ai->nr_groups; group++) {
>   struct pcpu_group_info *gi = >groups[group];
>   unsigned int cpu = NR_CPUS;
> @@ -2000,6 +2001,21 @@ int __init pcpu_embed_first_chunk(size_t 
> reserved_size, size_t dyn_size,
>   areas[group] = ptr;
>  
>   base = min(ptr, base);
> + if (ptr > areas[j])
> + j = group;
> + }
> + max_distance = areas[j] - base;
> + max_distance += ai->unit_size * ai->groups[j].nr_units;
> +
> + /* warn if maximum distance is further than 75% of vmalloc space */
> + if (max_distance > VMALLOC_TOTAL * 3 / 4) {
> + pr_warn("max_distance=0x%lx too large for vmalloc space 
> 0x%lx\n",
> + max_distance, VMALLOC_TOTAL);
> +#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
> + /* and fail if we have fallback */
> + rc = -EINVAL;
> + goto out_free_areas;
> +#endif
>   }
>  
>   /*
> @@ -2024,24 +2040,8 @@ int __init pcpu_embed_first_chunk(size_t 
> reserved_size, size_t dyn_size,
>   }
>  
>   /* base address is now known, determine group base offsets */
> - i = 0;
>   for (group = 0; group < ai->nr_groups; group++) {
>   ai->groups[group].base_offset = areas[group] - base;
> - if (areas[group] > areas[i])
> - i = group;
> - }
> - max_distance = ai->groups[i].base_offset +
> - (unsigned long)ai->unit_size * ai->groups[i].nr_units;
> -
> - /* warn if maximum distance is further than 75% of vmalloc space */
> - if (max_distance > VMALLOC_TOTAL * 3 / 4) {
> - pr_warn("max_distance=0x%lx too large for vmalloc space 
> 0x%lx\n",
> - max_distance, VMALLOC_TOTAL);
> -#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
> - /* and fail if we have fallback */
> - rc = -EINVAL;
> - goto out_free;
> -#endif
>   }
>  
>   pr_info("Embedded %zu pages/cpu @%p s%zu r%zu d%zu u%zu\n",
> 



Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread Rik van Riel
On Sat, 2016-10-01 at 16:44 -0700, Andy Lutomirski wrote:
> On Sat, Oct 1, 2016 at 1:31 PM,   wrote:
> > 
> >  #define CREATE_TRACE_POINTS
> >  #include 
> > @@ -197,6 +198,9 @@ __visible inline void
> > prepare_exit_to_usermode(struct pt_regs *regs)
> > if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
> > exit_to_usermode_loop(regs, cached_flags);
> > 
> > +   if (unlikely(test_and_clear_thread_flag(TIF_LOAD_FPU)))
> > +   switch_fpu_return();
> > +
> 
> How about:
> 
> if (unlikely(...)) {
>   exit_to_usermode_loop(regs, cached_flags);
>   cached_flags = READ_ONCE(ti->flags);
> }
> 
> if (ti->flags & _TIF_LOAD_FPU) {
>   clear_thread_flag(TIF_LOAD_FPU);
>   switch_fpu_return();
> }

It looks like test_thread_flag should be fine for avoiding
atomics, too?

  if (unlikely(test_thread_flag(TIF_LOAD_FPU))) {
      clear_thread_flag(TIF_LOAD_FPU);
      switch_fpu_return();
  }


> > +static inline void switch_fpu_finish(void)
> >  {
> > +   set_thread_flag(TIF_LOAD_FPU);
> >  }
> 
> I can imagine this causing problems with kernel code that accesses
> current's FPU state, e.g. get_xsave_field_ptr().  I wonder if it
> would
> make sense to make your changes deeper into the FPU core innards so
> that, for example, we'd have explicit functions that cause the

Whereabouts do you have in mind?

I like your general idea, but am not sure quite where
to put it.

> in-memory state for current to be up-to-date and readable, to cause
> the in-memory state to be up-to-date and writable (which is the same
> thing + TIF_FPU_LOAD + whatever other bookkeeping), and causing the
> in-CPU state to be up-to-date (possibly readable and writable).
> TIF_LOAD_FPU would trigger the latter.
> 
> I've often found it confusing that fpu__save by itself has somewhat
> ill-defined effects.

Fully agreed on both. I guess that means we want a few
different functions:

1) initialize FPU state, both in memory and in registers

2) cause FPU state in registers to be updated from memory,
   if necessary

3) cause FPU state in memory to be updated from registers,
   if necessary

The latter functions could use fpu->fpregs_active to see
whether any action is required, and be called from various
places in the code.

The signal code in particular is doing some strange things
that should probably be hidden away in FPU specific functions.

> 
> > 
> > +/*
> > + * Set up the userspace FPU context before returning to userspace.
> > + */
> > +void switch_fpu_return(void)
> > +{
> > +   struct fpu *fpu = >thread.fpu;
> > +   bool preload;
> > +   /*
> > +* If the task has used the math, pre-load the FPU on xsave
> > processors
> > +* or if the past 5 consecutive context-switches used math.
> > +*/
> > +   preload = static_cpu_has(X86_FEATURE_FPU) &&
> > + fpu->fpstate_active &&
> > + (use_eager_fpu() || fpu->counter > 5);
> > +
> > +   if (preload) {
> > +   prefetch(>state);
> > +   fpu->counter++;
> > +   __fpregs_activate(fpu);
> > +   trace_x86_fpu_regs_activated(fpu);
> > +
> > +   /* Don't change CR0.TS if we just switch! */
> > +   if (!__this_cpu_read(fpu_active)) {
> > +   __fpregs_activate_hw();
> > +   __this_cpu_write(fpu_active, true);
> > +   }
> 
> We should just finish getting rid of all TS uses.

Agreed. I will rebase on top of your FPU changes, that
will make things easier for everybody.

-- 
All Rights Reversed.

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


Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread Rik van Riel
On Sat, 2016-10-01 at 16:44 -0700, Andy Lutomirski wrote:
> On Sat, Oct 1, 2016 at 1:31 PM,   wrote:
> > 
> >  #define CREATE_TRACE_POINTS
> >  #include 
> > @@ -197,6 +198,9 @@ __visible inline void
> > prepare_exit_to_usermode(struct pt_regs *regs)
> > if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
> > exit_to_usermode_loop(regs, cached_flags);
> > 
> > +   if (unlikely(test_and_clear_thread_flag(TIF_LOAD_FPU)))
> > +   switch_fpu_return();
> > +
> 
> How about:
> 
> if (unlikely(...)) {
>   exit_to_usermode_loop(regs, cached_flags);
>   cached_flags = READ_ONCE(ti->flags);
> }
> 
> if (ti->flags & _TIF_LOAD_FPU) {
>   clear_thread_flag(TIF_LOAD_FPU);
>   switch_fpu_return();
> }

It looks like test_thread_flag should be fine for avoiding
atomics, too?

  if (unlikely(test_thread_flag(TIF_LOAD_FPU))) {
      clear_thread_flag(TIF_LOAD_FPU);
      switch_fpu_return();
  }


> > +static inline void switch_fpu_finish(void)
> >  {
> > +   set_thread_flag(TIF_LOAD_FPU);
> >  }
> 
> I can imagine this causing problems with kernel code that accesses
> current's FPU state, e.g. get_xsave_field_ptr().  I wonder if it
> would
> make sense to make your changes deeper into the FPU core innards so
> that, for example, we'd have explicit functions that cause the

Whereabouts do you have in mind?

I like your general idea, but am not sure quite where
to put it.

> in-memory state for current to be up-to-date and readable, to cause
> the in-memory state to be up-to-date and writable (which is the same
> thing + TIF_FPU_LOAD + whatever other bookkeeping), and causing the
> in-CPU state to be up-to-date (possibly readable and writable).
> TIF_LOAD_FPU would trigger the latter.
> 
> I've often found it confusing that fpu__save by itself has somewhat
> ill-defined effects.

Fully agreed on both. I guess that means we want a few
different functions:

1) initialize FPU state, both in memory and in registers

2) cause FPU state in registers to be updated from memory,
   if necessary

3) cause FPU state in memory to be updated from registers,
   if necessary

The latter functions could use fpu->fpregs_active to see
whether any action is required, and be called from various
places in the code.

The signal code in particular is doing some strange things
that should probably be hidden away in FPU specific functions.

> 
> > 
> > +/*
> > + * Set up the userspace FPU context before returning to userspace.
> > + */
> > +void switch_fpu_return(void)
> > +{
> > +   struct fpu *fpu = >thread.fpu;
> > +   bool preload;
> > +   /*
> > +* If the task has used the math, pre-load the FPU on xsave
> > processors
> > +* or if the past 5 consecutive context-switches used math.
> > +*/
> > +   preload = static_cpu_has(X86_FEATURE_FPU) &&
> > + fpu->fpstate_active &&
> > + (use_eager_fpu() || fpu->counter > 5);
> > +
> > +   if (preload) {
> > +   prefetch(>state);
> > +   fpu->counter++;
> > +   __fpregs_activate(fpu);
> > +   trace_x86_fpu_regs_activated(fpu);
> > +
> > +   /* Don't change CR0.TS if we just switch! */
> > +   if (!__this_cpu_read(fpu_active)) {
> > +   __fpregs_activate_hw();
> > +   __this_cpu_write(fpu_active, true);
> > +   }
> 
> We should just finish getting rid of all TS uses.

Agreed. I will rebase on top of your FPU changes, that
will make things easier for everybody.

-- 
All Rights Reversed.

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


Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Rich Felker
On Sat, Oct 01, 2016 at 10:58:37AM -0700, Paul E. McKenney wrote:
> On Sat, Oct 01, 2016 at 01:05:08PM -0400, Rich Felker wrote:
> > On Fri, Sep 30, 2016 at 06:48:35AM -0700, Paul E. McKenney wrote:
> > > On Fri, Sep 30, 2016 at 03:15:11PM +0200, Thomas Gleixner wrote:
> > > > On Tue, 27 Sep 2016, Rich Felker wrote:
> > > > > I've managed to get a trace with a stall. I'm not sure what the best
> > > > > way to share the full thing is, since it's large, but here are the
> > > > > potentially interesting parts.
> > > 
> > > [ . . . ]
> > > 
> > > Some RCU commentary, on the off-chance that it helps...
> > > 
> > > > So that should kick rcu_sched-7 in 10ms, latest 20ms from now and CPU1 
> > > > goes
> > > > into a NOHZ idle sleep.
> > > > 
> > > > >   -0 [001] d...   109.953436: tick_stop: success=1 
> > > > > dependency=NONE
> > > > >   -0 [001] d...   109.953617: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > >   -0 [001] d...   109.953818: hrtimer_start: 
> > > > > hrtimer=109f449c function=tick_sched_timer expires=10988000 
> > > > > softexpires=10988000
> > > > 
> > > > which is (using the 0.087621us delta between the trace clock and clock
> > > > MONO) at: 109.880 + 0.087621 = 109.968
> > > > 
> > > > Which is about correct as we expect the RCU timer to fire at:
> > > >   
> > > >   109.952633 + 0.01 = 109.963633
> > > > 
> > > > or latest at
> > > > 
> > > >   109.952633 + 0.02 = 109.983633
> > > >
> > > > There is another caveat. That nohz stuff can queue the rcu timer on 
> > > > CPU0, which
> > > > it did not because:
> > > 
> > > Just for annoying completeness, the location of the timer depends on how
> > > the rcuo callback-offload kthreads are constrained.  And yes, in the most
> > > constrained case where all CPUs except for CPU 0 are nohz CPUs, they will
> > > by default all run on CPU 0.
> > 
> > In default full nohz configuration, am I correct that all cpus except
> > cpu0 willd be nohz and that the rcu callbacks then have to run on
> > cpu0?
> 
> In recent kernels, it looks to me that the default is that none of the
> CPUs will be nohz by default.  You have to build with both NO_HZ_FULL
> and NO_HZ_FULL_ALL to get the everything-on-CPU-0 behavior.

Actually NO_HZ_FULL is not supported because
HAVE_VIRT_CPU_ACCOUNTING_GEN and HAVE_CONTEXT_TRACKING are missing, so
it's just normal NO_HZ. I listed the relevant config items somewhere
earlier in this thread I think.

> But are there rcu0 kthreads running on your system?

Apparently not:

# ps aux | grep rcu
7 root   0:00 [rcu_sched]
8 root   0:00 [rcu_bh]
  395 root   0:00 grep rcu
  
> > > > >rcu_sched-7 [001] d...   109.952633: timer_start: 
> > > > > timer=160a9eb0 function=process_timeout expires=4294948284 
> > > > > [timeout=1] flags=0x0001
> > > > 
> > > > The CPU nr encoded in flags is: 1
> > > > 
> > > > Now we cancel and restart the timer w/o seing the interrupt expiring
> > > > it. And that expiry should have happened at 109.968000 !?!
> > > > 
> > > > >   -0 [001] d...   109.968225: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > >   -0 [001] d...   109.968526: hrtimer_start: 
> > > > > hrtimer=109f449c function=tick_sched_timer expires=10989000 
> > > > > softexpires=10989000
> > > > 
> > > > So this advances the next tick even further out. And CPU 0 sets the 
> > > > timer to
> > > > the exact smae value:
> > > > 
> > > > >   -0 [000] d.h.   109.969104: hrtimer_start: 
> > > > > hrtimer=109e949c function=tick_sched_timer expires=10989000 
> > > > > softexpires=10989000
> > > > 
> > > > 
> > > > >   -0 [000] d.h.   109.977690: irq_handler_entry: 
> > > > > irq=16 name=jcore_pit
> > > > >   -0 [000] d.h.   109.977911: hrtimer_cancel: 
> > > > > hrtimer=109e949c
> > > > >   -0 [000] d.h.   109.978053: hrtimer_expire_entry: 
> > > > > hrtimer=109e949c function=tick_sched_timer now=109890434160
> > > > 
> > > > Which expires here. And CPU1 instead of getting an interrupt and 
> > > > expiring
> > > > the timer does the cancel/restart to the next jiffie again:
> > > > 
> > > > >   -0 [001] d...   109.978206: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > >   -0 [001] d...   109.978495: hrtimer_start: 
> > > > > hrtimer=109f449c function=tick_sched_timer expires=1099 
> > > > > softexpires=1099
> > > > 
> > > > And this repeats;
> > > > 
> > > > >   -0 [000] d.h.   109.987726: irq_handler_entry: 
> > > > > irq=16 name=jcore_pit
> > > > >   -0 [000] d.h.   109.987954: hrtimer_cancel: 
> > > > > hrtimer=109e949c
> > > > >   -0 [000] d.h.   109.988095: hrtimer_expire_entry: 
> > > > > hrtimer=109e949c function=tick_sched_timer now=109900474620
> > > > 
> > > > >   -0 [001] d...   109.988243: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > > 

Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Rich Felker
On Sat, Oct 01, 2016 at 10:58:37AM -0700, Paul E. McKenney wrote:
> On Sat, Oct 01, 2016 at 01:05:08PM -0400, Rich Felker wrote:
> > On Fri, Sep 30, 2016 at 06:48:35AM -0700, Paul E. McKenney wrote:
> > > On Fri, Sep 30, 2016 at 03:15:11PM +0200, Thomas Gleixner wrote:
> > > > On Tue, 27 Sep 2016, Rich Felker wrote:
> > > > > I've managed to get a trace with a stall. I'm not sure what the best
> > > > > way to share the full thing is, since it's large, but here are the
> > > > > potentially interesting parts.
> > > 
> > > [ . . . ]
> > > 
> > > Some RCU commentary, on the off-chance that it helps...
> > > 
> > > > So that should kick rcu_sched-7 in 10ms, latest 20ms from now and CPU1 
> > > > goes
> > > > into a NOHZ idle sleep.
> > > > 
> > > > >   -0 [001] d...   109.953436: tick_stop: success=1 
> > > > > dependency=NONE
> > > > >   -0 [001] d...   109.953617: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > >   -0 [001] d...   109.953818: hrtimer_start: 
> > > > > hrtimer=109f449c function=tick_sched_timer expires=10988000 
> > > > > softexpires=10988000
> > > > 
> > > > which is (using the 0.087621us delta between the trace clock and clock
> > > > MONO) at: 109.880 + 0.087621 = 109.968
> > > > 
> > > > Which is about correct as we expect the RCU timer to fire at:
> > > >   
> > > >   109.952633 + 0.01 = 109.963633
> > > > 
> > > > or latest at
> > > > 
> > > >   109.952633 + 0.02 = 109.983633
> > > >
> > > > There is another caveat. That nohz stuff can queue the rcu timer on 
> > > > CPU0, which
> > > > it did not because:
> > > 
> > > Just for annoying completeness, the location of the timer depends on how
> > > the rcuo callback-offload kthreads are constrained.  And yes, in the most
> > > constrained case where all CPUs except for CPU 0 are nohz CPUs, they will
> > > by default all run on CPU 0.
> > 
> > In default full nohz configuration, am I correct that all cpus except
> > cpu0 willd be nohz and that the rcu callbacks then have to run on
> > cpu0?
> 
> In recent kernels, it looks to me that the default is that none of the
> CPUs will be nohz by default.  You have to build with both NO_HZ_FULL
> and NO_HZ_FULL_ALL to get the everything-on-CPU-0 behavior.

Actually NO_HZ_FULL is not supported because
HAVE_VIRT_CPU_ACCOUNTING_GEN and HAVE_CONTEXT_TRACKING are missing, so
it's just normal NO_HZ. I listed the relevant config items somewhere
earlier in this thread I think.

> But are there rcu0 kthreads running on your system?

Apparently not:

# ps aux | grep rcu
7 root   0:00 [rcu_sched]
8 root   0:00 [rcu_bh]
  395 root   0:00 grep rcu
  
> > > > >rcu_sched-7 [001] d...   109.952633: timer_start: 
> > > > > timer=160a9eb0 function=process_timeout expires=4294948284 
> > > > > [timeout=1] flags=0x0001
> > > > 
> > > > The CPU nr encoded in flags is: 1
> > > > 
> > > > Now we cancel and restart the timer w/o seing the interrupt expiring
> > > > it. And that expiry should have happened at 109.968000 !?!
> > > > 
> > > > >   -0 [001] d...   109.968225: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > >   -0 [001] d...   109.968526: hrtimer_start: 
> > > > > hrtimer=109f449c function=tick_sched_timer expires=10989000 
> > > > > softexpires=10989000
> > > > 
> > > > So this advances the next tick even further out. And CPU 0 sets the 
> > > > timer to
> > > > the exact smae value:
> > > > 
> > > > >   -0 [000] d.h.   109.969104: hrtimer_start: 
> > > > > hrtimer=109e949c function=tick_sched_timer expires=10989000 
> > > > > softexpires=10989000
> > > > 
> > > > 
> > > > >   -0 [000] d.h.   109.977690: irq_handler_entry: 
> > > > > irq=16 name=jcore_pit
> > > > >   -0 [000] d.h.   109.977911: hrtimer_cancel: 
> > > > > hrtimer=109e949c
> > > > >   -0 [000] d.h.   109.978053: hrtimer_expire_entry: 
> > > > > hrtimer=109e949c function=tick_sched_timer now=109890434160
> > > > 
> > > > Which expires here. And CPU1 instead of getting an interrupt and 
> > > > expiring
> > > > the timer does the cancel/restart to the next jiffie again:
> > > > 
> > > > >   -0 [001] d...   109.978206: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > >   -0 [001] d...   109.978495: hrtimer_start: 
> > > > > hrtimer=109f449c function=tick_sched_timer expires=1099 
> > > > > softexpires=1099
> > > > 
> > > > And this repeats;
> > > > 
> > > > >   -0 [000] d.h.   109.987726: irq_handler_entry: 
> > > > > irq=16 name=jcore_pit
> > > > >   -0 [000] d.h.   109.987954: hrtimer_cancel: 
> > > > > hrtimer=109e949c
> > > > >   -0 [000] d.h.   109.988095: hrtimer_expire_entry: 
> > > > > hrtimer=109e949c function=tick_sched_timer now=109900474620
> > > > 
> > > > >   -0 [001] d...   109.988243: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > > 

[PATCH] fnic: Use time64_t to represent trace timestamps

2016-10-01 Thread Deepa Dinamani
trace timestamps use struct timespec and CURRENT_TIME which
are not y2038 safe.
These timestamps are only part of the trace log on the machine
and are not shared with the fnic.
Replace then with y2038 safe struct timespec64 and
ktime_get_real_ts64(), respectively.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Hiral Patel 
Cc: Suma Ramars 
Cc: Brian Uchino 
Cc: "James E.J. Bottomley" 
Cc: "Martin K. Petersen" 
Cc: linux-s...@vger.kernel.org
---
 drivers/scsi/fnic/fnic_trace.c | 4 ++--
 drivers/scsi/fnic/fnic_trace.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 4e15c4b..5a5fa01 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -613,7 +613,7 @@ int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
fc_trace_entries.rd_idx = 0;
}
 
-   fc_buf->time_stamp = CURRENT_TIME;
+   ktime_get_real_ts64(_buf->time_stamp);
fc_buf->host_no = host_no;
fc_buf->frame_type = frame_type;
 
@@ -740,7 +740,7 @@ void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
 
len = *orig_len;
 
-   time_to_tm(tdata->time_stamp.tv_sec, 0, );
+   time64_to_tm(tdata->time_stamp.tv_sec, 0, );
 
fmt = "%02d:%02d:%04ld %02d:%02d:%02d.%09lu ns%8x   %c%8x\t";
len += snprintf(fnic_dbgfs_prt->buffer + len,
diff --git a/drivers/scsi/fnic/fnic_trace.h b/drivers/scsi/fnic/fnic_trace.h
index a8aa057..e375d0c 100644
--- a/drivers/scsi/fnic/fnic_trace.h
+++ b/drivers/scsi/fnic/fnic_trace.h
@@ -72,7 +72,7 @@ struct fnic_trace_data {
 typedef struct fnic_trace_data fnic_trace_data_t;
 
 struct fc_trace_hdr {
-   struct timespec time_stamp;
+   struct timespec64 time_stamp;
u32 host_no;
u8 frame_type;
u8 frame_len;
-- 
2.7.4



[PATCH] fnic: Use time64_t to represent trace timestamps

2016-10-01 Thread Deepa Dinamani
trace timestamps use struct timespec and CURRENT_TIME which
are not y2038 safe.
These timestamps are only part of the trace log on the machine
and are not shared with the fnic.
Replace then with y2038 safe struct timespec64 and
ktime_get_real_ts64(), respectively.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Hiral Patel 
Cc: Suma Ramars 
Cc: Brian Uchino 
Cc: "James E.J. Bottomley" 
Cc: "Martin K. Petersen" 
Cc: linux-s...@vger.kernel.org
---
 drivers/scsi/fnic/fnic_trace.c | 4 ++--
 drivers/scsi/fnic/fnic_trace.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 4e15c4b..5a5fa01 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -613,7 +613,7 @@ int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
fc_trace_entries.rd_idx = 0;
}
 
-   fc_buf->time_stamp = CURRENT_TIME;
+   ktime_get_real_ts64(_buf->time_stamp);
fc_buf->host_no = host_no;
fc_buf->frame_type = frame_type;
 
@@ -740,7 +740,7 @@ void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
 
len = *orig_len;
 
-   time_to_tm(tdata->time_stamp.tv_sec, 0, );
+   time64_to_tm(tdata->time_stamp.tv_sec, 0, );
 
fmt = "%02d:%02d:%04ld %02d:%02d:%02d.%09lu ns%8x   %c%8x\t";
len += snprintf(fnic_dbgfs_prt->buffer + len,
diff --git a/drivers/scsi/fnic/fnic_trace.h b/drivers/scsi/fnic/fnic_trace.h
index a8aa057..e375d0c 100644
--- a/drivers/scsi/fnic/fnic_trace.h
+++ b/drivers/scsi/fnic/fnic_trace.h
@@ -72,7 +72,7 @@ struct fnic_trace_data {
 typedef struct fnic_trace_data fnic_trace_data_t;
 
 struct fc_trace_hdr {
-   struct timespec time_stamp;
+   struct timespec64 time_stamp;
u32 host_no;
u8 frame_type;
u8 frame_len;
-- 
2.7.4



[PATCH] fs: nfs: Make nfs boot time y2038 safe

2016-10-01 Thread Deepa Dinamani
boot_time is represented as a struct timespec.
struct timespec and CURRENT_TIME are not y2038 safe.
Overall, the plan is to use timespec64 and ktime_t for
all internal kernel representation of timestamps.
CURRENT_TIME will also be removed.

boot_time is used to construct the nfs client boot verifier.

Use ktime_t to represent boot_time and ktime_get_real() for
the boot_time value.

Following Trond's request https://lkml.org/lkml/2016/6/9/22 ,
use ktime_t instead of converting to struct timespec64.

Use higher and lower 32 bit parts of ktime_t for the boot
verifier.

Use the lower 32 bit part of ktime_t for the authsys_parms
stamp field.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Trond Myklebust 
Cc: Anna Schumaker 
Cc: linux-...@vger.kernel.org
---
 fs/nfs/client.c   |  2 +-
 fs/nfs/netns.h|  2 +-
 fs/nfs/nfs4proc.c | 10 ++
 fs/nfs/nfs4xdr.c  |  2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 1e10678..44d42a4 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1078,7 +1078,7 @@ void nfs_clients_init(struct net *net)
idr_init(>cb_ident_idr);
 #endif
spin_lock_init(>nfs_client_lock);
-   nn->boot_time = CURRENT_TIME;
+   nn->boot_time = ktime_get_real();
 }
 
 #ifdef CONFIG_PROC_FS
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index f0e06e4..fbce0d8 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -29,7 +29,7 @@ struct nfs_net {
int cb_users[NFS4_MAX_MINOR_VERSION + 1];
 #endif
spinlock_t nfs_client_lock;
-   struct timespec boot_time;
+   ktime_t boot_time;
 #ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfsfs;
 #endif
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index a9dec32..b517cc2 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5123,12 +5123,14 @@ static void nfs4_init_boot_verifier(const struct 
nfs_client *clp,
if (test_bit(NFS4CLNT_PURGE_STATE, >cl_state)) {
/* An impossible timestamp guarantees this value
 * will never match a generated boot time. */
-   verf[0] = 0;
-   verf[1] = cpu_to_be32(NSEC_PER_SEC + 1);
+   verf[0] = cpu_to_be32(U32_MAX);
+   verf[1] = cpu_to_be32(U32_MAX);
} else {
struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
-   verf[0] = cpu_to_be32(nn->boot_time.tv_sec);
-   verf[1] = cpu_to_be32(nn->boot_time.tv_nsec);
+   u64 ns = ktime_to_ns(nn->boot_time);
+
+   verf[0] = cpu_to_be32(ns >> 32);
+   verf[1] = cpu_to_be32(ns);
}
memcpy(bootverf->data, verf, sizeof(bootverf->data));
 }
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 7bd3a5c..a961e15 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1850,7 +1850,7 @@ static void encode_create_session(struct xdr_stream *xdr,
*p++ = cpu_to_be32(RPC_AUTH_UNIX);  /* auth_sys */
 
/* authsys_parms rfc1831 */
-   *p++ = cpu_to_be32(nn->boot_time.tv_nsec);  /* stamp */
+   *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
*p++ = cpu_to_be32(0);  /* UID */
*p++ = cpu_to_be32(0);  /* GID */
-- 
2.7.4



[PATCH] fs: nfs: Make nfs boot time y2038 safe

2016-10-01 Thread Deepa Dinamani
boot_time is represented as a struct timespec.
struct timespec and CURRENT_TIME are not y2038 safe.
Overall, the plan is to use timespec64 and ktime_t for
all internal kernel representation of timestamps.
CURRENT_TIME will also be removed.

boot_time is used to construct the nfs client boot verifier.

Use ktime_t to represent boot_time and ktime_get_real() for
the boot_time value.

Following Trond's request https://lkml.org/lkml/2016/6/9/22 ,
use ktime_t instead of converting to struct timespec64.

Use higher and lower 32 bit parts of ktime_t for the boot
verifier.

Use the lower 32 bit part of ktime_t for the authsys_parms
stamp field.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Trond Myklebust 
Cc: Anna Schumaker 
Cc: linux-...@vger.kernel.org
---
 fs/nfs/client.c   |  2 +-
 fs/nfs/netns.h|  2 +-
 fs/nfs/nfs4proc.c | 10 ++
 fs/nfs/nfs4xdr.c  |  2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 1e10678..44d42a4 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1078,7 +1078,7 @@ void nfs_clients_init(struct net *net)
idr_init(>cb_ident_idr);
 #endif
spin_lock_init(>nfs_client_lock);
-   nn->boot_time = CURRENT_TIME;
+   nn->boot_time = ktime_get_real();
 }
 
 #ifdef CONFIG_PROC_FS
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index f0e06e4..fbce0d8 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -29,7 +29,7 @@ struct nfs_net {
int cb_users[NFS4_MAX_MINOR_VERSION + 1];
 #endif
spinlock_t nfs_client_lock;
-   struct timespec boot_time;
+   ktime_t boot_time;
 #ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfsfs;
 #endif
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index a9dec32..b517cc2 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5123,12 +5123,14 @@ static void nfs4_init_boot_verifier(const struct 
nfs_client *clp,
if (test_bit(NFS4CLNT_PURGE_STATE, >cl_state)) {
/* An impossible timestamp guarantees this value
 * will never match a generated boot time. */
-   verf[0] = 0;
-   verf[1] = cpu_to_be32(NSEC_PER_SEC + 1);
+   verf[0] = cpu_to_be32(U32_MAX);
+   verf[1] = cpu_to_be32(U32_MAX);
} else {
struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
-   verf[0] = cpu_to_be32(nn->boot_time.tv_sec);
-   verf[1] = cpu_to_be32(nn->boot_time.tv_nsec);
+   u64 ns = ktime_to_ns(nn->boot_time);
+
+   verf[0] = cpu_to_be32(ns >> 32);
+   verf[1] = cpu_to_be32(ns);
}
memcpy(bootverf->data, verf, sizeof(bootverf->data));
 }
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 7bd3a5c..a961e15 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1850,7 +1850,7 @@ static void encode_create_session(struct xdr_stream *xdr,
*p++ = cpu_to_be32(RPC_AUTH_UNIX);  /* auth_sys */
 
/* authsys_parms rfc1831 */
-   *p++ = cpu_to_be32(nn->boot_time.tv_nsec);  /* stamp */
+   *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
*p++ = cpu_to_be32(0);  /* UID */
*p++ = cpu_to_be32(0);  /* GID */
-- 
2.7.4



net/sunrpc/stats.c:204: undefined reference to `_GLOBAL_OFFSET_TABLE_'

2016-10-01 Thread kbuild test robot
Hi Nicolas,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: 461a5e51060c93f5844113f4be9dba513cc92830 do_div(): generic optimization 
for constant divisor on 32-bit machines
date:   11 months ago
config: microblaze-mmu_defconfig (attached as .config)
compiler: microblaze-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 461a5e51060c93f5844113f4be9dba513cc92830
# save the attached .config to linux build tree
make.cross ARCH=microblaze 

All errors (new ones prefixed by >>):

   net/built-in.o: In function `rpc_print_iostats':
>> net/sunrpc/stats.c:204: undefined reference to `_GLOBAL_OFFSET_TABLE_'
   scripts/link-vmlinux.sh: line 52: 107322 Segmentation fault  ${LD} 
${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} -T ${lds} ${KBUILD_VMLINUX_INIT} 
--start-group ${KBUILD_VMLINUX_MAIN} --end-group ${1}

vim +204 net/sunrpc/stats.c

840210fc Weston Andros Adamson 2014-06-24  188  
  [task->tk_msg.rpc_proc->p_statidx]);
840210fc Weston Andros Adamson 2014-06-24  189  }
0a702195 Weston Andros Adamson 2012-02-17  190  
EXPORT_SYMBOL_GPL(rpc_count_iostats);
11c556b3 Chuck Lever   2006-03-20  191  
ec535ce1 Adrian Bunk   2006-04-18  192  static void _print_name(struct 
seq_file *seq, unsigned int op,
ec535ce1 Adrian Bunk   2006-04-18  193  struct 
rpc_procinfo *procs)
cc0175c1 Chuck Lever   2006-03-20  194  {
cc0175c1 Chuck Lever   2006-03-20  195  if (procs[op].p_name)
cc0175c1 Chuck Lever   2006-03-20  196  seq_printf(seq, 
"\t%12s: ", procs[op].p_name);
cc0175c1 Chuck Lever   2006-03-20  197  else if (op == 0)
cc0175c1 Chuck Lever   2006-03-20  198  seq_printf(seq, 
"\tNULL: ");
cc0175c1 Chuck Lever   2006-03-20  199  else
cc0175c1 Chuck Lever   2006-03-20  200  seq_printf(seq, 
"\t%12u: ", op);
cc0175c1 Chuck Lever   2006-03-20  201  }
cc0175c1 Chuck Lever   2006-03-20  202  
11c556b3 Chuck Lever   2006-03-20  203  void rpc_print_iostats(struct 
seq_file *seq, struct rpc_clnt *clnt)
11c556b3 Chuck Lever   2006-03-20 @204  {
11c556b3 Chuck Lever   2006-03-20  205  struct rpc_iostats 
*stats = clnt->cl_metrics;
2446ab60 Trond Myklebust   2012-03-01  206  struct rpc_xprt *xprt;
11c556b3 Chuck Lever   2006-03-20  207  unsigned int op, 
maxproc = clnt->cl_maxproc;
11c556b3 Chuck Lever   2006-03-20  208  
11c556b3 Chuck Lever   2006-03-20  209  if (!stats)
11c556b3 Chuck Lever   2006-03-20  210  return;
11c556b3 Chuck Lever   2006-03-20  211  
11c556b3 Chuck Lever   2006-03-20  212  seq_printf(seq, "\tRPC 
iostats version: %s  ", RPC_IOSTATS_VERS);

:: The code at line 204 was first introduced by commit
:: 11c556b3d8d481829ab5f9933a25d29b00913b5a SUNRPC: provide a mechanism for 
collecting stats in the RPC client

:: TO: Chuck Lever 
:: CC: Trond Myklebust 

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


.config.gz
Description: application/gzip


net/sunrpc/stats.c:204: undefined reference to `_GLOBAL_OFFSET_TABLE_'

2016-10-01 Thread kbuild test robot
Hi Nicolas,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: 461a5e51060c93f5844113f4be9dba513cc92830 do_div(): generic optimization 
for constant divisor on 32-bit machines
date:   11 months ago
config: microblaze-mmu_defconfig (attached as .config)
compiler: microblaze-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 461a5e51060c93f5844113f4be9dba513cc92830
# save the attached .config to linux build tree
make.cross ARCH=microblaze 

All errors (new ones prefixed by >>):

   net/built-in.o: In function `rpc_print_iostats':
>> net/sunrpc/stats.c:204: undefined reference to `_GLOBAL_OFFSET_TABLE_'
   scripts/link-vmlinux.sh: line 52: 107322 Segmentation fault  ${LD} 
${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} -T ${lds} ${KBUILD_VMLINUX_INIT} 
--start-group ${KBUILD_VMLINUX_MAIN} --end-group ${1}

vim +204 net/sunrpc/stats.c

840210fc Weston Andros Adamson 2014-06-24  188  
  [task->tk_msg.rpc_proc->p_statidx]);
840210fc Weston Andros Adamson 2014-06-24  189  }
0a702195 Weston Andros Adamson 2012-02-17  190  
EXPORT_SYMBOL_GPL(rpc_count_iostats);
11c556b3 Chuck Lever   2006-03-20  191  
ec535ce1 Adrian Bunk   2006-04-18  192  static void _print_name(struct 
seq_file *seq, unsigned int op,
ec535ce1 Adrian Bunk   2006-04-18  193  struct 
rpc_procinfo *procs)
cc0175c1 Chuck Lever   2006-03-20  194  {
cc0175c1 Chuck Lever   2006-03-20  195  if (procs[op].p_name)
cc0175c1 Chuck Lever   2006-03-20  196  seq_printf(seq, 
"\t%12s: ", procs[op].p_name);
cc0175c1 Chuck Lever   2006-03-20  197  else if (op == 0)
cc0175c1 Chuck Lever   2006-03-20  198  seq_printf(seq, 
"\tNULL: ");
cc0175c1 Chuck Lever   2006-03-20  199  else
cc0175c1 Chuck Lever   2006-03-20  200  seq_printf(seq, 
"\t%12u: ", op);
cc0175c1 Chuck Lever   2006-03-20  201  }
cc0175c1 Chuck Lever   2006-03-20  202  
11c556b3 Chuck Lever   2006-03-20  203  void rpc_print_iostats(struct 
seq_file *seq, struct rpc_clnt *clnt)
11c556b3 Chuck Lever   2006-03-20 @204  {
11c556b3 Chuck Lever   2006-03-20  205  struct rpc_iostats 
*stats = clnt->cl_metrics;
2446ab60 Trond Myklebust   2012-03-01  206  struct rpc_xprt *xprt;
11c556b3 Chuck Lever   2006-03-20  207  unsigned int op, 
maxproc = clnt->cl_maxproc;
11c556b3 Chuck Lever   2006-03-20  208  
11c556b3 Chuck Lever   2006-03-20  209  if (!stats)
11c556b3 Chuck Lever   2006-03-20  210  return;
11c556b3 Chuck Lever   2006-03-20  211  
11c556b3 Chuck Lever   2006-03-20  212  seq_printf(seq, "\tRPC 
iostats version: %s  ", RPC_IOSTATS_VERS);

:: The code at line 204 was first introduced by commit
:: 11c556b3d8d481829ab5f9933a25d29b00913b5a SUNRPC: provide a mechanism for 
collecting stats in the RPC client

:: TO: Chuck Lever 
:: CC: Trond Myklebust 

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


.config.gz
Description: application/gzip


Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread Andy Lutomirski
On Sat, Oct 1, 2016 at 1:31 PM,   wrote:
> From: Rik van Riel 
>
> Delay the loading of FPU registers until a process switches back to
> userspace. This allows us to skip FPU saving & restoring for kernel
> threads, the idle task, and tasks that are spinning in kernel space.
>
> It also allows us to not repeatedly save & restore the userspace FPU
> context on repeated invocations of kernel_fpu_start & kernel_fpu_end.
>
> Not overwriting the FPU state of a task unless we need to also allows
> us to be be lazier about restoring it, in a future patch.
>
> Signed-off-by: Rik van Riel 
> ---
>  arch/x86/entry/common.c |  4 
>  arch/x86/include/asm/fpu/api.h  |  5 +
>  arch/x86/include/asm/fpu/internal.h | 44 
> +
>  arch/x86/include/asm/thread_info.h  |  4 +++-
>  arch/x86/kernel/fpu/core.c  | 17 --
>  arch/x86/kernel/process.c   | 35 +
>  arch/x86/kernel/process_32.c|  5 ++---
>  arch/x86/kernel/process_64.c|  5 ++---
>  8 files changed, 71 insertions(+), 48 deletions(-)
>
> diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
> index 1433f6b4607d..a69bbefa3408 100644
> --- a/arch/x86/entry/common.c
> +++ b/arch/x86/entry/common.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define CREATE_TRACE_POINTS
>  #include 
> @@ -197,6 +198,9 @@ __visible inline void prepare_exit_to_usermode(struct 
> pt_regs *regs)
> if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
> exit_to_usermode_loop(regs, cached_flags);
>
> +   if (unlikely(test_and_clear_thread_flag(TIF_LOAD_FPU)))
> +   switch_fpu_return();
> +

How about:

if (unlikely(...)) {
  exit_to_usermode_loop(regs, cached_flags);
  cached_flags = READ_ONCE(ti->flags);
}

if (ti->flags & _TIF_LOAD_FPU) {
  clear_thread_flag(TIF_LOAD_FPU);
  switch_fpu_return();
}

or something along those lines.  The issue is that
test_and_clear_thread_flag is unconditionally atomic, which means that
it will slow down the common fast case by quite a bit.

Alternatively, you could try to jam it into thread_struct::status,
which would let you avoid an atomic operation when you clear it, but
you'd still need an atomic op to set it, so this might not be a win.


> +static inline void switch_fpu_finish(void)
>  {
> -   bool preload;
> -   /*
> -* If the task has used the math, pre-load the FPU on xsave processors
> -* or if the past 5 consecutive context-switches used math.
> -*/
> -   preload = static_cpu_has(X86_FEATURE_FPU) &&
> - new_fpu->fpstate_active &&
> - (use_eager_fpu() || new_fpu->counter > 5);
> -
> -   if (preload) {
> -   prefetch(_fpu->state);
> -   new_fpu->counter++;
> -   __fpregs_activate(new_fpu);
> -   trace_x86_fpu_regs_activated(new_fpu);
> -
> -   /* Don't change CR0.TS if we just switch! */
> -   if (!__this_cpu_read(fpu_active)) {
> -   __fpregs_activate_hw();
> -   __this_cpu_write(fpu_active, true);
> -   }
> -
> -   copy_kernel_to_fpregs(_fpu->state);
> -   } else if (__this_cpu_read(fpu_active)) {
> -   __this_cpu_write(fpu_active, false);
> -   __fpregs_deactivate_hw();
> -   }
> +   set_thread_flag(TIF_LOAD_FPU);
>  }

I can imagine this causing problems with kernel code that accesses
current's FPU state, e.g. get_xsave_field_ptr().  I wonder if it would
make sense to make your changes deeper into the FPU core innards so
that, for example, we'd have explicit functions that cause the
in-memory state for current to be up-to-date and readable, to cause
the in-memory state to be up-to-date and writable (which is the same
thing + TIF_FPU_LOAD + whatever other bookkeeping), and causing the
in-CPU state to be up-to-date (possibly readable and writable).
TIF_LOAD_FPU would trigger the latter.

I've often found it confusing that fpu__save by itself has somewhat
ill-defined effects.


> +/*
> + * Set up the userspace FPU context before returning to userspace.
> + */
> +void switch_fpu_return(void)
> +{
> +   struct fpu *fpu = >thread.fpu;
> +   bool preload;
> +   /*
> +* If the task has used the math, pre-load the FPU on xsave processors
> +* or if the past 5 consecutive context-switches used math.
> +*/
> +   preload = static_cpu_has(X86_FEATURE_FPU) &&
> + fpu->fpstate_active &&
> + (use_eager_fpu() || fpu->counter > 5);
> +
> +   if (preload) {
> +   prefetch(>state);
> +   fpu->counter++;
> +   __fpregs_activate(fpu);
> +   trace_x86_fpu_regs_activated(fpu);
> +
> +   /* Don't change CR0.TS if we just switch! */
> +  

Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread Andy Lutomirski
On Sat, Oct 1, 2016 at 1:31 PM,   wrote:
> From: Rik van Riel 
>
> Delay the loading of FPU registers until a process switches back to
> userspace. This allows us to skip FPU saving & restoring for kernel
> threads, the idle task, and tasks that are spinning in kernel space.
>
> It also allows us to not repeatedly save & restore the userspace FPU
> context on repeated invocations of kernel_fpu_start & kernel_fpu_end.
>
> Not overwriting the FPU state of a task unless we need to also allows
> us to be be lazier about restoring it, in a future patch.
>
> Signed-off-by: Rik van Riel 
> ---
>  arch/x86/entry/common.c |  4 
>  arch/x86/include/asm/fpu/api.h  |  5 +
>  arch/x86/include/asm/fpu/internal.h | 44 
> +
>  arch/x86/include/asm/thread_info.h  |  4 +++-
>  arch/x86/kernel/fpu/core.c  | 17 --
>  arch/x86/kernel/process.c   | 35 +
>  arch/x86/kernel/process_32.c|  5 ++---
>  arch/x86/kernel/process_64.c|  5 ++---
>  8 files changed, 71 insertions(+), 48 deletions(-)
>
> diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
> index 1433f6b4607d..a69bbefa3408 100644
> --- a/arch/x86/entry/common.c
> +++ b/arch/x86/entry/common.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define CREATE_TRACE_POINTS
>  #include 
> @@ -197,6 +198,9 @@ __visible inline void prepare_exit_to_usermode(struct 
> pt_regs *regs)
> if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
> exit_to_usermode_loop(regs, cached_flags);
>
> +   if (unlikely(test_and_clear_thread_flag(TIF_LOAD_FPU)))
> +   switch_fpu_return();
> +

How about:

if (unlikely(...)) {
  exit_to_usermode_loop(regs, cached_flags);
  cached_flags = READ_ONCE(ti->flags);
}

if (ti->flags & _TIF_LOAD_FPU) {
  clear_thread_flag(TIF_LOAD_FPU);
  switch_fpu_return();
}

or something along those lines.  The issue is that
test_and_clear_thread_flag is unconditionally atomic, which means that
it will slow down the common fast case by quite a bit.

Alternatively, you could try to jam it into thread_struct::status,
which would let you avoid an atomic operation when you clear it, but
you'd still need an atomic op to set it, so this might not be a win.


> +static inline void switch_fpu_finish(void)
>  {
> -   bool preload;
> -   /*
> -* If the task has used the math, pre-load the FPU on xsave processors
> -* or if the past 5 consecutive context-switches used math.
> -*/
> -   preload = static_cpu_has(X86_FEATURE_FPU) &&
> - new_fpu->fpstate_active &&
> - (use_eager_fpu() || new_fpu->counter > 5);
> -
> -   if (preload) {
> -   prefetch(_fpu->state);
> -   new_fpu->counter++;
> -   __fpregs_activate(new_fpu);
> -   trace_x86_fpu_regs_activated(new_fpu);
> -
> -   /* Don't change CR0.TS if we just switch! */
> -   if (!__this_cpu_read(fpu_active)) {
> -   __fpregs_activate_hw();
> -   __this_cpu_write(fpu_active, true);
> -   }
> -
> -   copy_kernel_to_fpregs(_fpu->state);
> -   } else if (__this_cpu_read(fpu_active)) {
> -   __this_cpu_write(fpu_active, false);
> -   __fpregs_deactivate_hw();
> -   }
> +   set_thread_flag(TIF_LOAD_FPU);
>  }

I can imagine this causing problems with kernel code that accesses
current's FPU state, e.g. get_xsave_field_ptr().  I wonder if it would
make sense to make your changes deeper into the FPU core innards so
that, for example, we'd have explicit functions that cause the
in-memory state for current to be up-to-date and readable, to cause
the in-memory state to be up-to-date and writable (which is the same
thing + TIF_FPU_LOAD + whatever other bookkeeping), and causing the
in-CPU state to be up-to-date (possibly readable and writable).
TIF_LOAD_FPU would trigger the latter.

I've often found it confusing that fpu__save by itself has somewhat
ill-defined effects.


> +/*
> + * Set up the userspace FPU context before returning to userspace.
> + */
> +void switch_fpu_return(void)
> +{
> +   struct fpu *fpu = >thread.fpu;
> +   bool preload;
> +   /*
> +* If the task has used the math, pre-load the FPU on xsave processors
> +* or if the past 5 consecutive context-switches used math.
> +*/
> +   preload = static_cpu_has(X86_FEATURE_FPU) &&
> + fpu->fpstate_active &&
> + (use_eager_fpu() || fpu->counter > 5);
> +
> +   if (preload) {
> +   prefetch(>state);
> +   fpu->counter++;
> +   __fpregs_activate(fpu);
> +   trace_x86_fpu_regs_activated(fpu);
> +
> +   /* Don't change CR0.TS if we just switch! */
> +   if (!__this_cpu_read(fpu_active)) {
> +   

[PATCH] audit: Use timespec64 to represent audit timestamps

2016-10-01 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Acked-by: Paul Moore 
Acked-by: Richard Guy Briggs 
Cc: Eric Paris 
Cc: Paul Moore 
Cc: Richard Guy Briggs 
Cc: linux-au...@redhat.com
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c| 10 +-
 kernel/audit.h|  2 +-
 kernel/auditsc.c  |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 9d4443f..e51782b 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -332,7 +332,7 @@ static inline void audit_ptrace(struct task_struct *t)
/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial);
+ struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -490,7 +490,7 @@ static inline void __audit_seccomp(unsigned long syscall, 
long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial)
+ struct timespec64 *t, unsigned int *serial)
 {
return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index a8a91bd..b03b6c7 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1325,10 +1325,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-   *t = CURRENT_TIME;
+   ktime_get_real_ts64(t);
*serial = audit_serial();
}
 }
@@ -1370,7 +1370,7 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 int type)
 {
struct audit_buffer *ab = NULL;
-   struct timespec t;
+   struct timespec64   t;
unsigned intuninitialized_var(serial);
int reserve = 5; /* Allow atomic callers to go up to five
entries over the normal backlog limit */
@@ -1422,8 +1422,8 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 
audit_get_stamp(ab->ctx, , );
 
-   audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-t.tv_sec, t.tv_nsec/100, serial);
+   audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+(unsigned long long)t.tv_sec, t.tv_nsec/100, 
serial);
return ab;
 }
 
diff --git a/kernel/audit.h b/kernel/audit.h
index 431444c..55d1ca2 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -112,7 +112,7 @@ struct audit_context {
enum audit_statestate, current_state;
unsigned intserial; /* serial number for record */
int major;  /* syscall number */
-   struct timespec ctime;  /* time of syscall entry */
+   struct timespec64   ctime;  /* time of syscall entry */
unsigned long   argv[4];/* syscall arguments */
longreturn_code;/* syscall return code */
u64 prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 5abf1dc..8dc7fe9 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1522,7 +1522,7 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
return;
 
context->serial = 0;
-   context->ctime  = CURRENT_TIME;
+   ktime_get_real_ts64(>ctime);
context->in_syscall = 1;
context->current_state  = state;
context->ppid   = 0;
@@ -1931,13 +1931,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-  struct timespec 

[PATCH] audit: Use timespec64 to represent audit timestamps

2016-10-01 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Acked-by: Paul Moore 
Acked-by: Richard Guy Briggs 
Cc: Eric Paris 
Cc: Paul Moore 
Cc: Richard Guy Briggs 
Cc: linux-au...@redhat.com
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c| 10 +-
 kernel/audit.h|  2 +-
 kernel/auditsc.c  |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 9d4443f..e51782b 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -332,7 +332,7 @@ static inline void audit_ptrace(struct task_struct *t)
/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial);
+ struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -490,7 +490,7 @@ static inline void __audit_seccomp(unsigned long syscall, 
long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial)
+ struct timespec64 *t, unsigned int *serial)
 {
return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index a8a91bd..b03b6c7 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1325,10 +1325,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-   *t = CURRENT_TIME;
+   ktime_get_real_ts64(t);
*serial = audit_serial();
}
 }
@@ -1370,7 +1370,7 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 int type)
 {
struct audit_buffer *ab = NULL;
-   struct timespec t;
+   struct timespec64   t;
unsigned intuninitialized_var(serial);
int reserve = 5; /* Allow atomic callers to go up to five
entries over the normal backlog limit */
@@ -1422,8 +1422,8 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 
audit_get_stamp(ab->ctx, , );
 
-   audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-t.tv_sec, t.tv_nsec/100, serial);
+   audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+(unsigned long long)t.tv_sec, t.tv_nsec/100, 
serial);
return ab;
 }
 
diff --git a/kernel/audit.h b/kernel/audit.h
index 431444c..55d1ca2 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -112,7 +112,7 @@ struct audit_context {
enum audit_statestate, current_state;
unsigned intserial; /* serial number for record */
int major;  /* syscall number */
-   struct timespec ctime;  /* time of syscall entry */
+   struct timespec64   ctime;  /* time of syscall entry */
unsigned long   argv[4];/* syscall arguments */
longreturn_code;/* syscall return code */
u64 prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 5abf1dc..8dc7fe9 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1522,7 +1522,7 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
return;
 
context->serial = 0;
-   context->ctime  = CURRENT_TIME;
+   ktime_get_real_ts64(>ctime);
context->in_syscall = 1;
context->current_state  = state;
context->ppid   = 0;
@@ -1931,13 +1931,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx->in_syscall)
  

[PATCH] fs: ocfs2: Replace CURRENT_TIME macro

2016-10-01 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.

Use y2038 safe ktime_get_real_seconds() here for timestamps.
struct heartbeat_block's hb_seq and deletetion time are already
64 bits wide and accommodate times beyond y2038.

Also use y2038 safe ktime_get_real_ts64() for on disk inode
timestamps.
These are also wide enough to accommodate time64_t.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Joel Becker 
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/cluster/heartbeat.c | 2 +-
 fs/ocfs2/inode.c | 2 +-
 fs/ocfs2/namei.c | 6 --
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 636abcb..9158c98 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -741,7 +741,7 @@ static inline void o2hb_prepare_block(struct o2hb_region 
*reg,
hb_block = (struct o2hb_disk_heartbeat_block *)slot->ds_raw_block;
memset(hb_block, 0, reg->hr_block_bytes);
/* TODO: time stuff */
-   cputime = CURRENT_TIME.tv_sec;
+   cputime = ktime_get_real_seconds();
if (!cputime)
cputime = 1;
 
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index c56a767..382401d 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -703,7 +703,7 @@ static int ocfs2_remove_inode(struct inode *inode,
goto bail_commit;
}
 
-   di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec);
+   di->i_dtime = cpu_to_le64(ktime_get_real_seconds());
di->i_flags &= cpu_to_le32(~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL));
ocfs2_journal_dirty(handle, di_bh);
 
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index a8f1225..e96ed24 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -516,6 +516,7 @@ static int __ocfs2_mknod_locked(struct inode *dir,
struct ocfs2_extent_list *fel;
u16 feat;
struct ocfs2_inode_info *oi = OCFS2_I(inode);
+   struct timespec64 ts;
 
*new_fe_bh = NULL;
 
@@ -564,10 +565,11 @@ static int __ocfs2_mknod_locked(struct inode *dir,
fe->i_last_eb_blk = 0;
strcpy(fe->i_signature, OCFS2_INODE_SIGNATURE);
fe->i_flags |= cpu_to_le32(OCFS2_VALID_FL);
+   ktime_get_real_ts64();
fe->i_atime = fe->i_ctime = fe->i_mtime =
-   cpu_to_le64(CURRENT_TIME.tv_sec);
+   cpu_to_le64(ts.tv_sec);
fe->i_mtime_nsec = fe->i_ctime_nsec = fe->i_atime_nsec =
-   cpu_to_le32(CURRENT_TIME.tv_nsec);
+   cpu_to_le32(ts.tv_nsec);
fe->i_dtime = 0;
 
/*
-- 
2.7.4



[PATCH] fs: ocfs2: Replace CURRENT_TIME macro

2016-10-01 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.

Use y2038 safe ktime_get_real_seconds() here for timestamps.
struct heartbeat_block's hb_seq and deletetion time are already
64 bits wide and accommodate times beyond y2038.

Also use y2038 safe ktime_get_real_ts64() for on disk inode
timestamps.
These are also wide enough to accommodate time64_t.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Joel Becker 
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/cluster/heartbeat.c | 2 +-
 fs/ocfs2/inode.c | 2 +-
 fs/ocfs2/namei.c | 6 --
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 636abcb..9158c98 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -741,7 +741,7 @@ static inline void o2hb_prepare_block(struct o2hb_region 
*reg,
hb_block = (struct o2hb_disk_heartbeat_block *)slot->ds_raw_block;
memset(hb_block, 0, reg->hr_block_bytes);
/* TODO: time stuff */
-   cputime = CURRENT_TIME.tv_sec;
+   cputime = ktime_get_real_seconds();
if (!cputime)
cputime = 1;
 
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index c56a767..382401d 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -703,7 +703,7 @@ static int ocfs2_remove_inode(struct inode *inode,
goto bail_commit;
}
 
-   di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec);
+   di->i_dtime = cpu_to_le64(ktime_get_real_seconds());
di->i_flags &= cpu_to_le32(~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL));
ocfs2_journal_dirty(handle, di_bh);
 
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index a8f1225..e96ed24 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -516,6 +516,7 @@ static int __ocfs2_mknod_locked(struct inode *dir,
struct ocfs2_extent_list *fel;
u16 feat;
struct ocfs2_inode_info *oi = OCFS2_I(inode);
+   struct timespec64 ts;
 
*new_fe_bh = NULL;
 
@@ -564,10 +565,11 @@ static int __ocfs2_mknod_locked(struct inode *dir,
fe->i_last_eb_blk = 0;
strcpy(fe->i_signature, OCFS2_INODE_SIGNATURE);
fe->i_flags |= cpu_to_le32(OCFS2_VALID_FL);
+   ktime_get_real_ts64();
fe->i_atime = fe->i_ctime = fe->i_mtime =
-   cpu_to_le64(CURRENT_TIME.tv_sec);
+   cpu_to_le64(ts.tv_sec);
fe->i_mtime_nsec = fe->i_ctime_nsec = fe->i_atime_nsec =
-   cpu_to_le32(CURRENT_TIME.tv_nsec);
+   cpu_to_le32(ts.tv_nsec);
fe->i_dtime = 0;
 
/*
-- 
2.7.4



[PATCH] fs: ocfs2: Use time64_t to represent orphan scan times

2016-10-01 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Use time64_t which is y2038 safe to represent orphan
scan times.
time64_t is sufficient here as only the seconds delta
times are relevant.

Also use appropriate time functions that return time in
time64_t format. Time functions now return monotonic
time instead of real time as only delta scan times are
relevant and these values are not persistent across
reboots.

The format string for the debug print is still using long
as this is only the time elapsed since the last scan and
long is sufficient to represent this value.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Mark Fasheh 
Cc: Joel Becker 
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/journal.c | 4 ++--
 fs/ocfs2/ocfs2.h   | 2 +-
 fs/ocfs2/super.c   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index a244f14..d5e5fa7 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1947,7 +1947,7 @@ static void ocfs2_queue_orphan_scan(struct ocfs2_super 
*osb)
 */
seqno++;
os->os_count++;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
 unlock:
ocfs2_orphan_scan_unlock(osb, seqno);
 out:
@@ -2004,7 +2004,7 @@ void ocfs2_orphan_scan_start(struct ocfs2_super *osb)
struct ocfs2_orphan_scan *os;
 
os = >osb_orphan_scan;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
atomic_set(>os_state, ORPHAN_SCAN_INACTIVE);
else {
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index e63af7d..7e5958b 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -224,7 +224,7 @@ struct ocfs2_orphan_scan {
struct ocfs2_super  *os_osb;
struct ocfs2_lock_res   os_lockres; /* lock to synchronize scans */
struct delayed_work os_orphan_scan_work;
-   struct timespec os_scantime;  /* time this node ran the scan */
+   time64_tos_scantime;  /* time this node ran the scan */
u32 os_count;  /* tracks node specific scans */
u32 os_seqno;   /* tracks cluster wide scans */
atomic_tos_state;  /* ACTIVE or INACTIVE */
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 603b28d..bf3ca30 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -337,7 +337,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char 
*buf, int len)
out += snprintf(buf + out, len - out, "Disabled\n");
else
out += snprintf(buf + out, len - out, "%lu seconds ago\n",
-   (get_seconds() - os->os_scantime.tv_sec));
+   (unsigned long)(ktime_get_seconds() - 
os->os_scantime));
 
out += snprintf(buf + out, len - out, "%10s => %3s  %10s\n",
"Slots", "Num", "RecoGen");
-- 
2.7.4



[PATCH] fs: ocfs2: Use time64_t to represent orphan scan times

2016-10-01 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Use time64_t which is y2038 safe to represent orphan
scan times.
time64_t is sufficient here as only the seconds delta
times are relevant.

Also use appropriate time functions that return time in
time64_t format. Time functions now return monotonic
time instead of real time as only delta scan times are
relevant and these values are not persistent across
reboots.

The format string for the debug print is still using long
as this is only the time elapsed since the last scan and
long is sufficient to represent this value.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Mark Fasheh 
Cc: Joel Becker 
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/journal.c | 4 ++--
 fs/ocfs2/ocfs2.h   | 2 +-
 fs/ocfs2/super.c   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index a244f14..d5e5fa7 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1947,7 +1947,7 @@ static void ocfs2_queue_orphan_scan(struct ocfs2_super 
*osb)
 */
seqno++;
os->os_count++;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
 unlock:
ocfs2_orphan_scan_unlock(osb, seqno);
 out:
@@ -2004,7 +2004,7 @@ void ocfs2_orphan_scan_start(struct ocfs2_super *osb)
struct ocfs2_orphan_scan *os;
 
os = >osb_orphan_scan;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
atomic_set(>os_state, ORPHAN_SCAN_INACTIVE);
else {
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index e63af7d..7e5958b 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -224,7 +224,7 @@ struct ocfs2_orphan_scan {
struct ocfs2_super  *os_osb;
struct ocfs2_lock_res   os_lockres; /* lock to synchronize scans */
struct delayed_work os_orphan_scan_work;
-   struct timespec os_scantime;  /* time this node ran the scan */
+   time64_tos_scantime;  /* time this node ran the scan */
u32 os_count;  /* tracks node specific scans */
u32 os_seqno;   /* tracks cluster wide scans */
atomic_tos_state;  /* ACTIVE or INACTIVE */
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 603b28d..bf3ca30 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -337,7 +337,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char 
*buf, int len)
out += snprintf(buf + out, len - out, "Disabled\n");
else
out += snprintf(buf + out, len - out, "%lu seconds ago\n",
-   (get_seconds() - os->os_scantime.tv_sec));
+   (unsigned long)(ktime_get_seconds() - 
os->os_scantime));
 
out += snprintf(buf + out, len - out, "%10s => %3s  %10s\n",
"Slots", "Num", "RecoGen");
-- 
2.7.4



Re: [PATCH v4 2/5] driver core: Functional dependencies tracking support

2016-10-01 Thread Rafael J. Wysocki
On Sat, Oct 1, 2016 at 9:43 AM, Lukas Wunner  wrote:
> On Thu, Sep 29, 2016 at 02:38:04AM +0200, Rafael J. Wysocki wrote:
>> +static int device_reorder_to_tail(struct device *dev, void *not_used)
>> +{
>> + struct device_link *link;
>> +
>> + /*
>> +  * Devices that have not been registered yet will be put to the ends
>> +  * of the lists during the registratio, so skip them here.
>   ^
>   n
>
>> + if (device_is_registered(dev))
>> + devices_kset_move_last(dev);
>> +
>> + if (device_pm_initialized(dev))
>> + device_pm_move_last(dev);
>
> Clever solution to this problem.  So little code!
>
>
>> +/**
>> + * device_links_check_suppliers - Check presence of supplier drivers.
>> + * @dev: Consumer device.
>> + *
>> + * Check links from this device to any suppliers.  Walk the list of the 
>> device's
>> + * consumer links and see if all of the suppliers are available.  If not, 
>> simply
>   
>  "supplier links and see if all if them are available."
>
>
>> +/*
>> + * Device link flags.
>> + *
>> + * STATELESS: The core won't track the presence of supplier/consumer 
>> drivers.
>> + * AUTOREMOVE: Remove this link automatically on cunsumer driver unbind.
>  ^
>  o
>
>
> Apart from these nits patch [2/5] LGTM, so FWIW:
>
> Reviewed-by: Lukas Wunner 

Thanks for the review, much appreciated!

Cheers,
Rafael


Re: [PATCH v4 2/5] driver core: Functional dependencies tracking support

2016-10-01 Thread Rafael J. Wysocki
On Sat, Oct 1, 2016 at 9:43 AM, Lukas Wunner  wrote:
> On Thu, Sep 29, 2016 at 02:38:04AM +0200, Rafael J. Wysocki wrote:
>> +static int device_reorder_to_tail(struct device *dev, void *not_used)
>> +{
>> + struct device_link *link;
>> +
>> + /*
>> +  * Devices that have not been registered yet will be put to the ends
>> +  * of the lists during the registratio, so skip them here.
>   ^
>   n
>
>> + if (device_is_registered(dev))
>> + devices_kset_move_last(dev);
>> +
>> + if (device_pm_initialized(dev))
>> + device_pm_move_last(dev);
>
> Clever solution to this problem.  So little code!
>
>
>> +/**
>> + * device_links_check_suppliers - Check presence of supplier drivers.
>> + * @dev: Consumer device.
>> + *
>> + * Check links from this device to any suppliers.  Walk the list of the 
>> device's
>> + * consumer links and see if all of the suppliers are available.  If not, 
>> simply
>   
>  "supplier links and see if all if them are available."
>
>
>> +/*
>> + * Device link flags.
>> + *
>> + * STATELESS: The core won't track the presence of supplier/consumer 
>> drivers.
>> + * AUTOREMOVE: Remove this link automatically on cunsumer driver unbind.
>  ^
>  o
>
>
> Apart from these nits patch [2/5] LGTM, so FWIW:
>
> Reviewed-by: Lukas Wunner 

Thanks for the review, much appreciated!

Cheers,
Rafael


[PATCH] fs: f2fs: Use ktime_get_real_seconds for sit_info times

2016-10-01 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe.

Replace use of CURRENT_TIME_SEC with ktime_get_real_seconds
in segment timestamps used by GC algorithm including the
segment mtime timestamps.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Jaegeuk Kim 
Cc: Changman Lee 
Cc: linux-f2fs-de...@lists.sourceforge.net
---
 fs/f2fs/segment.c | 2 +-
 fs/f2fs/segment.h | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index a46296f..34bb30e 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2168,7 +2168,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
sit_i->dirty_sentries = 0;
sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
-   sit_i->mounted_time = CURRENT_TIME_SEC.tv_sec;
+   sit_i->mounted_time = ktime_get_real_seconds();
mutex_init(_i->sentry_lock);
return 0;
 }
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index b33f73e..2423749 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -662,8 +662,9 @@ static inline void set_to_next_sit(struct sit_info *sit_i, 
unsigned int start)
 static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
 {
struct sit_info *sit_i = SIT_I(sbi);
-   return sit_i->elapsed_time + CURRENT_TIME_SEC.tv_sec -
-   sit_i->mounted_time;
+   time64_t now = ktime_get_real_seconds();
+
+   return sit_i->elapsed_time + now - sit_i->mounted_time;
 }
 
 static inline void set_summary(struct f2fs_summary *sum, nid_t nid,
-- 
2.7.4



[PATCH] fs: f2fs: Use ktime_get_real_seconds for sit_info times

2016-10-01 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe.

Replace use of CURRENT_TIME_SEC with ktime_get_real_seconds
in segment timestamps used by GC algorithm including the
segment mtime timestamps.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Jaegeuk Kim 
Cc: Changman Lee 
Cc: linux-f2fs-de...@lists.sourceforge.net
---
 fs/f2fs/segment.c | 2 +-
 fs/f2fs/segment.h | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index a46296f..34bb30e 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2168,7 +2168,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
sit_i->dirty_sentries = 0;
sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
-   sit_i->mounted_time = CURRENT_TIME_SEC.tv_sec;
+   sit_i->mounted_time = ktime_get_real_seconds();
mutex_init(_i->sentry_lock);
return 0;
 }
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index b33f73e..2423749 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -662,8 +662,9 @@ static inline void set_to_next_sit(struct sit_info *sit_i, 
unsigned int start)
 static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
 {
struct sit_info *sit_i = SIT_I(sbi);
-   return sit_i->elapsed_time + CURRENT_TIME_SEC.tv_sec -
-   sit_i->mounted_time;
+   time64_t now = ktime_get_real_seconds();
+
+   return sit_i->elapsed_time + now - sit_i->mounted_time;
 }
 
 static inline void set_summary(struct f2fs_summary *sum, nid_t nid,
-- 
2.7.4



Re: [PATCH RFC 1/5] x86,fpu: split prev/next task fpu state handling

2016-10-01 Thread Andy Lutomirski
On Oct 1, 2016 1:49 PM,  wrote:
>
> From: Rik van Riel 
>
> Move all handling of the next state FPU state handling into
> switch_fpu_finish, in preparation for more lazily switching
> FPU states.
>
> CR0.TS state is mirrored in a per-cpu variable, instead of
> being passed around in a local variable, because that will
> not be possible later in the series.

This seems reasonable in principle, but IMO it would be less scary if
you rebased onto this:

https://git.kernel.org/cgit/linux/kernel/git/luto/linux.git/log/?h=x86/fpu

Because the amount of testing needed and the amount of code that gets
rearranged would be reduced.  Want to fold those patches into you
series?  I can also just send them in directly, although this is an
awkward time to do so.

--Andy


Re: [PATCH RFC 1/5] x86,fpu: split prev/next task fpu state handling

2016-10-01 Thread Andy Lutomirski
On Oct 1, 2016 1:49 PM,  wrote:
>
> From: Rik van Riel 
>
> Move all handling of the next state FPU state handling into
> switch_fpu_finish, in preparation for more lazily switching
> FPU states.
>
> CR0.TS state is mirrored in a per-cpu variable, instead of
> being passed around in a local variable, because that will
> not be possible later in the series.

This seems reasonable in principle, but IMO it would be less scary if
you rebased onto this:

https://git.kernel.org/cgit/linux/kernel/git/luto/linux.git/log/?h=x86/fpu

Because the amount of testing needed and the amount of code that gets
rearranged would be reduced.  Want to fold those patches into you
series?  I can also just send them in directly, although this is an
awkward time to do so.

--Andy


Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Jes Sorensen
Joe Perches  writes:
> On Sat, 2016-10-01 at 16:32 -0400, Jes Sorensen wrote:
>> Your output shows it moving to the text segment - if it's in a different
>> segment, eg. rodata, you should use output demonstrating that to justify
>> the change.
>
> For size, rodata _is_ text

Well then maybe use something which provides accurate data.

Jes


Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Jes Sorensen
Joe Perches  writes:
> On Sat, 2016-10-01 at 16:32 -0400, Jes Sorensen wrote:
>> Your output shows it moving to the text segment - if it's in a different
>> segment, eg. rodata, you should use output demonstrating that to justify
>> the change.
>
> For size, rodata _is_ text

Well then maybe use something which provides accurate data.

Jes


cris-linux-objcopy: error: the input file 'arch/cris/boot/rescue/rescue.o' has no sections

2016-10-01 Thread kbuild test robot
Hi Joe,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: cb984d101b30eb7478d32df56a0023e4603cba7f compiler-gcc: integrate the 
various compiler-gcc[345].h files
date:   1 year, 3 months ago
config: cris-alldefconfig (attached as .config)
compiler: cris-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout cb984d101b30eb7478d32df56a0023e4603cba7f
# save the attached .config to linux build tree
make.cross ARCH=cris 

All errors (new ones prefixed by >>):

>> cris-linux-objcopy: error: the input file 'arch/cris/boot/rescue/rescue.o' 
>> has no sections

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


.config.gz
Description: application/gzip


cris-linux-objcopy: error: the input file 'arch/cris/boot/rescue/rescue.o' has no sections

2016-10-01 Thread kbuild test robot
Hi Joe,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: cb984d101b30eb7478d32df56a0023e4603cba7f compiler-gcc: integrate the 
various compiler-gcc[345].h files
date:   1 year, 3 months ago
config: cris-alldefconfig (attached as .config)
compiler: cris-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout cb984d101b30eb7478d32df56a0023e4603cba7f
# save the attached .config to linux build tree
make.cross ARCH=cris 

All errors (new ones prefixed by >>):

>> cris-linux-objcopy: error: the input file 'arch/cris/boot/rescue/rescue.o' 
>> has no sections

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


.config.gz
Description: application/gzip


Re: [PATCH] fs: btrfs: Use ktime_get_real_ts for root ctime

2016-10-01 Thread David Sterba
On Sat, Oct 01, 2016 at 10:23:34AM -0700, Deepa Dinamani wrote:
> btrfs_root_item maintains the ctime for root updates.
> This is not part of vfs_inode.
> 
> Since current_time() uses struct inode* as an argument
> as Linus suggested, this cannot be used to update root
> times unless, we modify the signature to use inode.
> 
> Since btrfs uses nanosecond time granularity, it can also
> use ktime_get_real_ts directly to obtain timestamp for
> the root. It is necessary to use the timespec time api
> here because the same btrfs_set_stack_timespec_*() apis
> are used for vfs inode times as well. These can be
> transitioned to using timespec64 when btrfs internally
> changes to use timespec64 as well.
> 
> Signed-off-by: Deepa Dinamani 
> Cc: Chris Mason 
> Cc: David Sterba 

Acked-by: David Sterba 

> Cc: Josef Bacik 
> Cc: linux-bt...@vger.kernel.org
> ---
> Changes from previous version:
> * Separated from the current_time() api series.
> * Moved ktime_get_real_ts() outside of spin lock.
> 
> fs/btrfs/root-tree.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
> index 0912960..17e5a5f 100644
> --- a/fs/btrfs/root-tree.c
> +++ b/fs/btrfs/root-tree.c
> @@ -505,8 +505,9 @@ void btrfs_update_root_times(struct btrfs_trans_handle 
> *trans,
>struct btrfs_root *root)
>  {
>   struct btrfs_root_item *item = >root_item;
> - struct timespec ct = current_fs_time(root->fs_info->sb);
> + struct timespec ct;
>  
> + ktime_get_real_ts();
>   spin_lock(>root_item_lock);
>   btrfs_set_root_ctransid(item, trans->transid);
>   btrfs_set_stack_timespec_sec(>ctime, ct.tv_sec);
> -- 
> 2.7.4
> 
> 


Re: [PATCH] fs: btrfs: Use ktime_get_real_ts for root ctime

2016-10-01 Thread David Sterba
On Sat, Oct 01, 2016 at 10:23:34AM -0700, Deepa Dinamani wrote:
> btrfs_root_item maintains the ctime for root updates.
> This is not part of vfs_inode.
> 
> Since current_time() uses struct inode* as an argument
> as Linus suggested, this cannot be used to update root
> times unless, we modify the signature to use inode.
> 
> Since btrfs uses nanosecond time granularity, it can also
> use ktime_get_real_ts directly to obtain timestamp for
> the root. It is necessary to use the timespec time api
> here because the same btrfs_set_stack_timespec_*() apis
> are used for vfs inode times as well. These can be
> transitioned to using timespec64 when btrfs internally
> changes to use timespec64 as well.
> 
> Signed-off-by: Deepa Dinamani 
> Cc: Chris Mason 
> Cc: David Sterba 

Acked-by: David Sterba 

> Cc: Josef Bacik 
> Cc: linux-bt...@vger.kernel.org
> ---
> Changes from previous version:
> * Separated from the current_time() api series.
> * Moved ktime_get_real_ts() outside of spin lock.
> 
> fs/btrfs/root-tree.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
> index 0912960..17e5a5f 100644
> --- a/fs/btrfs/root-tree.c
> +++ b/fs/btrfs/root-tree.c
> @@ -505,8 +505,9 @@ void btrfs_update_root_times(struct btrfs_trans_handle 
> *trans,
>struct btrfs_root *root)
>  {
>   struct btrfs_root_item *item = >root_item;
> - struct timespec ct = current_fs_time(root->fs_info->sb);
> + struct timespec ct;
>  
> + ktime_get_real_ts();
>   spin_lock(>root_item_lock);
>   btrfs_set_root_ctransid(item, trans->transid);
>   btrfs_set_stack_timespec_sec(>ctime, ct.tv_sec);
> -- 
> 2.7.4
> 
> 


[PATCH] usb: xhci: add support for performing fake doorbell

2016-10-01 Thread Rafał Miłecki
From: Rafał Miłecki 

Broadcom's Northstar XHCI controllers seem to need a special start
procedure to work correctly. There isn't any official documentation on
this, the problem is that controller doesn't detect any connected
devices with default setup. Moreover connecting USB device to controller
that doesn't run properly can cause SoC's watchdog issues.

A workaround that was successfully tested on multiple devices is to
perform a fake doorbell. This patch adds code for doing that and a DT
binding enabling it.

Signed-off-by: Rafał Miłecki 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |  2 +
 drivers/usb/host/xhci-plat.c   |  6 +++
 drivers/usb/host/xhci.c| 63 --
 drivers/usb/host/xhci.h|  1 +
 4 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 966885c..ce01b7f 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -26,6 +26,8 @@ Required properties:
 Optional properties:
   - clocks: reference to a clock
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
+  - usb3-fake-doorbell: determines if controller requires a fake doorbell when
+   starting it
 
 Example:
usb@f0931000 {
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9..c26dc77 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -56,12 +56,18 @@ static int xhci_priv_init_quirk(struct usb_hcd *hcd)
 
 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
+   struct platform_device  *pdev = to_platform_device(dev);
+   struct device_node  *node = pdev->dev.of_node;
+
/*
 * As of now platform drivers don't provide MSI support so we ensure
 * here that the generic code does not try to make a pci_dev from our
 * dev struct in order to setup MSI
 */
xhci->quirks |= XHCI_PLAT;
+
+   if (node && of_property_read_bool(node, "usb3-fake-doorbell"))
+   xhci->quirks |= XHCI_FAKE_DOORBELL;
 }
 
 /* called during probe() after chip reset completes */
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1a4ca02..c77035e9b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -153,6 +153,49 @@ static int xhci_start(struct xhci_hcd *xhci)
return ret;
 }
 
+/**
+ * xhci_fake_doorbell - Perform a fake doorbell on a specified slot
+ *
+ * Some controllers require a fake doorbell to start correctly. Without that
+ * they simply don't detect any devices.
+ */
+static int xhci_fake_doorbell(struct xhci_hcd *xhci, int slot_id)
+{
+   u32 temp;
+
+   /* Alloc a virt device for that slot */
+   if (!xhci_alloc_virt_device(xhci, slot_id, NULL, GFP_NOIO)) {
+   xhci_warn(xhci, "Could not allocate xHCI USB device data 
structures\n");
+   return -ENOMEM;
+   }
+
+   /* Ring fake doorbell for slot_id ep 0 */
+   xhci_ring_ep_doorbell(xhci, slot_id, 0, 0);
+   usleep_range(1000, 1500);
+
+   /* Read the status to check if HSE is set or not */
+   temp = readl(>op_regs->status);
+
+   /* Clear HSE if set */
+   if (temp & STS_FATAL) {
+   xhci_dbg(xhci, "HSE problem detected, status: 0x%08x\n", temp);
+   temp &= ~0x1fff;
+   temp |= STS_FATAL;
+   writel(temp, >op_regs->status);
+   usleep_range(1000, 1500);
+   readl(>op_regs->status);
+   }
+
+   /* Free virt device */
+   xhci_free_virt_device(xhci, slot_id);
+
+   /* We're done if controller is already running */
+   if (readl(>op_regs->command) & CMD_RUN)
+   return 0;
+
+   return xhci_start(xhci);
+}
+
 /*
  * Reset a halted HC.
  *
@@ -565,10 +608,20 @@ int xhci_init(struct usb_hcd *hcd)
 
 static int xhci_run_finished(struct xhci_hcd *xhci)
 {
-   if (xhci_start(xhci)) {
-   xhci_halt(xhci);
-   return -ENODEV;
+   int err;
+
+   err = xhci_start(xhci);
+   if (err) {
+   err = -ENODEV;
+   goto err_halt;
+   }
+
+   if (xhci->quirks & XHCI_FAKE_DOORBELL) {
+   err = xhci_fake_doorbell(xhci, 1);
+   if (err)
+   goto err_halt;
}
+
xhci->shared_hcd->state = HC_STATE_RUNNING;
xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
 
@@ -578,6 +631,10 @@ static int xhci_run_finished(struct xhci_hcd *xhci)
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB3 roothub");
return 0;
+
+err_halt:
+   xhci_halt(xhci);
+   return err;
 }
 
 /*
diff --git a/drivers/usb/host/xhci.h 

[PATCH] usb: xhci: add support for performing fake doorbell

2016-10-01 Thread Rafał Miłecki
From: Rafał Miłecki 

Broadcom's Northstar XHCI controllers seem to need a special start
procedure to work correctly. There isn't any official documentation on
this, the problem is that controller doesn't detect any connected
devices with default setup. Moreover connecting USB device to controller
that doesn't run properly can cause SoC's watchdog issues.

A workaround that was successfully tested on multiple devices is to
perform a fake doorbell. This patch adds code for doing that and a DT
binding enabling it.

Signed-off-by: Rafał Miłecki 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |  2 +
 drivers/usb/host/xhci-plat.c   |  6 +++
 drivers/usb/host/xhci.c| 63 --
 drivers/usb/host/xhci.h|  1 +
 4 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 966885c..ce01b7f 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -26,6 +26,8 @@ Required properties:
 Optional properties:
   - clocks: reference to a clock
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
+  - usb3-fake-doorbell: determines if controller requires a fake doorbell when
+   starting it
 
 Example:
usb@f0931000 {
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9..c26dc77 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -56,12 +56,18 @@ static int xhci_priv_init_quirk(struct usb_hcd *hcd)
 
 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
+   struct platform_device  *pdev = to_platform_device(dev);
+   struct device_node  *node = pdev->dev.of_node;
+
/*
 * As of now platform drivers don't provide MSI support so we ensure
 * here that the generic code does not try to make a pci_dev from our
 * dev struct in order to setup MSI
 */
xhci->quirks |= XHCI_PLAT;
+
+   if (node && of_property_read_bool(node, "usb3-fake-doorbell"))
+   xhci->quirks |= XHCI_FAKE_DOORBELL;
 }
 
 /* called during probe() after chip reset completes */
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1a4ca02..c77035e9b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -153,6 +153,49 @@ static int xhci_start(struct xhci_hcd *xhci)
return ret;
 }
 
+/**
+ * xhci_fake_doorbell - Perform a fake doorbell on a specified slot
+ *
+ * Some controllers require a fake doorbell to start correctly. Without that
+ * they simply don't detect any devices.
+ */
+static int xhci_fake_doorbell(struct xhci_hcd *xhci, int slot_id)
+{
+   u32 temp;
+
+   /* Alloc a virt device for that slot */
+   if (!xhci_alloc_virt_device(xhci, slot_id, NULL, GFP_NOIO)) {
+   xhci_warn(xhci, "Could not allocate xHCI USB device data 
structures\n");
+   return -ENOMEM;
+   }
+
+   /* Ring fake doorbell for slot_id ep 0 */
+   xhci_ring_ep_doorbell(xhci, slot_id, 0, 0);
+   usleep_range(1000, 1500);
+
+   /* Read the status to check if HSE is set or not */
+   temp = readl(>op_regs->status);
+
+   /* Clear HSE if set */
+   if (temp & STS_FATAL) {
+   xhci_dbg(xhci, "HSE problem detected, status: 0x%08x\n", temp);
+   temp &= ~0x1fff;
+   temp |= STS_FATAL;
+   writel(temp, >op_regs->status);
+   usleep_range(1000, 1500);
+   readl(>op_regs->status);
+   }
+
+   /* Free virt device */
+   xhci_free_virt_device(xhci, slot_id);
+
+   /* We're done if controller is already running */
+   if (readl(>op_regs->command) & CMD_RUN)
+   return 0;
+
+   return xhci_start(xhci);
+}
+
 /*
  * Reset a halted HC.
  *
@@ -565,10 +608,20 @@ int xhci_init(struct usb_hcd *hcd)
 
 static int xhci_run_finished(struct xhci_hcd *xhci)
 {
-   if (xhci_start(xhci)) {
-   xhci_halt(xhci);
-   return -ENODEV;
+   int err;
+
+   err = xhci_start(xhci);
+   if (err) {
+   err = -ENODEV;
+   goto err_halt;
+   }
+
+   if (xhci->quirks & XHCI_FAKE_DOORBELL) {
+   err = xhci_fake_doorbell(xhci, 1);
+   if (err)
+   goto err_halt;
}
+
xhci->shared_hcd->state = HC_STATE_RUNNING;
xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
 
@@ -578,6 +631,10 @@ static int xhci_run_finished(struct xhci_hcd *xhci)
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB3 roothub");
return 0;
+
+err_halt:
+   xhci_halt(xhci);
+   return err;
 }
 
 /*
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index b2c1dc5..52d7498 

Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Joe Perches
On Sat, 2016-10-01 at 16:32 -0400, Jes Sorensen wrote:
> Your output shows it moving to the text segment - if it's in a different
> segment, eg. rodata, you should use output demonstrating that to justify
> the change.

For size, rodata _is_ text


Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Joe Perches
On Sat, 2016-10-01 at 16:32 -0400, Jes Sorensen wrote:
> Your output shows it moving to the text segment - if it's in a different
> segment, eg. rodata, you should use output demonstrating that to justify
> the change.

For size, rodata _is_ text


Re: [PATCH] Coccinelle: limit memdup_user transformation to GFP_KERNEL case

2016-10-01 Thread Michal Marek
Dne 21.9.2016 v 17:48 Julia Lawall napsal(a):
> Memdup_user encapsulates a memory allocation with the flag GFP_KERNEL, so
> only allow this flag in the original code.
> 
> Signed-off-by: Julia Lawall 

Applied to kbuild.git#misc.

Thanks,
Michal



Re: [PATCH] Coccinelle: pm_runtime: ensure relevance of pm_runtime reports

2016-10-01 Thread Michal Marek
Dne 22.9.2016 v 10:28 Julia Lawall napsal(a):
> pm_runtime.cocci starts with one rule that searches for a variety of
> functions calls, followed by various rules that report errors.  Previously,
> the only connection between the first rule and the rest was to check that
> the first rule had matched somewhere.  Change the rules to propagate a
> position from the first rule to the others, to make sure that the sites
> reported on are the same as the sites that were identified as having the
> relevant functions.
> 
> Signed-off-by: Julia Lawall 

Applied to kbuild.git#misc.

Thanks,
Michal



Re: [PATCH] Coccinelle: limit memdup_user transformation to GFP_KERNEL case

2016-10-01 Thread Michal Marek
Dne 21.9.2016 v 17:48 Julia Lawall napsal(a):
> Memdup_user encapsulates a memory allocation with the flag GFP_KERNEL, so
> only allow this flag in the original code.
> 
> Signed-off-by: Julia Lawall 

Applied to kbuild.git#misc.

Thanks,
Michal



Re: [PATCH] Coccinelle: pm_runtime: ensure relevance of pm_runtime reports

2016-10-01 Thread Michal Marek
Dne 22.9.2016 v 10:28 Julia Lawall napsal(a):
> pm_runtime.cocci starts with one rule that searches for a variety of
> functions calls, followed by various rules that report errors.  Previously,
> the only connection between the first rule and the rest was to check that
> the first rule had matched somewhere.  Change the rules to propagate a
> position from the first rule to the others, to make sure that the sites
> reported on are the same as the sites that were identified as having the
> relevant functions.
> 
> Signed-off-by: Julia Lawall 

Applied to kbuild.git#misc.

Thanks,
Michal



[PATCH] [media] : Removing warnings caught by checkpatch.pl

2016-10-01 Thread Harman Kalra
Removing warnings caught by checkpatch.pl

Signed-off-by: Harman Kalra 
---
 drivers/staging/media/omap4iss/iss_video.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/omap4iss/iss_video.c 
b/drivers/staging/media/omap4iss/iss_video.c
index c16927a..7cc1691 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -297,8 +297,8 @@ static void iss_video_pix_to_mbus(const struct 
v4l2_pix_format *pix,
  */

 static int iss_video_queue_setup(struct vb2_queue *vq,
-unsigned int *count, unsigned int *num_planes,
-unsigned int sizes[], struct device 
*alloc_devs[])
+   unsigned int *count, unsigned int *num_planes,
+   unsigned int sizes[], struct device *alloc_devs[])
 {
struct iss_video_fh *vfh = vb2_get_drv_priv(vq);
struct iss_video *video = vfh->video;
@@ -678,8 +678,8 @@ void omap4iss_video_cancel_stream(struct iss_video *video)
if (subdev == NULL)
return -EINVAL;

-   /* Try the get selection operation first and fallback to get format if 
not
-* implemented.
+   /* Try the get selection operation first and
+* fallback to get format if not implemented.
 */
sdsel.pad = pad;
ret = v4l2_subdev_call(subdev, pad, get_selection, NULL, );
--
1.7.9.5



[PATCH] [media] : Removing warnings caught by checkpatch.pl

2016-10-01 Thread Harman Kalra
Removing warnings caught by checkpatch.pl

Signed-off-by: Harman Kalra 
---
 drivers/staging/media/omap4iss/iss_video.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/omap4iss/iss_video.c 
b/drivers/staging/media/omap4iss/iss_video.c
index c16927a..7cc1691 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -297,8 +297,8 @@ static void iss_video_pix_to_mbus(const struct 
v4l2_pix_format *pix,
  */

 static int iss_video_queue_setup(struct vb2_queue *vq,
-unsigned int *count, unsigned int *num_planes,
-unsigned int sizes[], struct device 
*alloc_devs[])
+   unsigned int *count, unsigned int *num_planes,
+   unsigned int sizes[], struct device *alloc_devs[])
 {
struct iss_video_fh *vfh = vb2_get_drv_priv(vq);
struct iss_video *video = vfh->video;
@@ -678,8 +678,8 @@ void omap4iss_video_cancel_stream(struct iss_video *video)
if (subdev == NULL)
return -EINVAL;

-   /* Try the get selection operation first and fallback to get format if 
not
-* implemented.
+   /* Try the get selection operation first and
+* fallback to get format if not implemented.
 */
sdsel.pad = pad;
ret = v4l2_subdev_call(subdev, pad, get_selection, NULL, );
--
1.7.9.5



[PATCH 01/15 v2] UBIFS: improve function-level documentation

2016-10-01 Thread Julia Lawall
Fix various inconsistencies in the documentation associated with various
functions.

In the case of fs/ubifs/lprops.c, the second parameter of
ubifs_get_lp_stats was renamed from st to lst in commit 84abf972ccff
("UBIFS: add re-mount debugging checks")

In the case of fs/ubifs/lpt_commit.c, the excess variables have never
existed in the associated functions since the code was introduced into the
kernel.

The others appear to be straightforward typos.

Issues detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
v2: improve reference to earlier commit

 fs/ubifs/file.c   |2 +-
 fs/ubifs/gc.c |2 +-
 fs/ubifs/lprops.c |2 +-
 fs/ubifs/lpt_commit.c |4 +---
 fs/ubifs/replay.c |2 +-
 5 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index b0a6a53..629c719 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1397,7 +1397,7 @@ int ubifs_update_time(struct inode *inode, struct 
timespec *time,
 #endif

 /**
- * update_ctime - update mtime and ctime of an inode.
+ * update_mctime - update mtime and ctime of an inode.
  * @inode: inode to update
  *
  * This function updates mtime and ctime of the inode if it is not equivalent 
to
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 821b348..e845c64 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -113,7 +113,7 @@ static int switch_gc_head(struct ubifs_info *c)
  * data_nodes_cmp - compare 2 data nodes.
  * @priv: UBIFS file-system description object
  * @a: first data node
- * @a: second data node
+ * @b: second data node
  *
  * This function compares data nodes @a and @b. Returns %1 if @a has greater
  * inode or block number, and %-1 otherwise.
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index a0011aa..6c3a1ab 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -636,7 +636,7 @@ const struct ubifs_lprops *ubifs_change_lp(struct 
ubifs_info *c,
 /**
  * ubifs_get_lp_stats - get lprops statistics.
  * @c: UBIFS file-system description object
- * @st: return statistics
+ * @lst: return statistics
  */
 void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst)
 {
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index ce89bdc..235654c 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -34,7 +34,6 @@

 /**
  * first_dirty_cnode - find first dirty cnode.
- * @c: UBIFS file-system description object
  * @nnode: nnode at which to start
  *
  * This function returns the first dirty cnode or %NULL if there is not one.
@@ -1623,7 +1622,6 @@ static int dbg_is_node_dirty(struct ubifs_info *c, int 
node_type, int lnum,
  * dbg_check_ltab_lnum - check the ltab for a LPT LEB number.
  * @c: the UBIFS file-system description object
  * @lnum: LEB number where node was written
- * @offs: offset where node was written
  *
  * This function returns %0 on success and a negative error code on failure.
  */
@@ -1870,7 +1868,7 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int 
len)
 }

 /**
- * ubifs_dump_lpt_leb - dump an LPT LEB.
+ * dump_lpt_leb - dump an LPT LEB.
  * @c: UBIFS file-system description object
  * @lnum: LEB number to dump
  *
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index 3ca4540..fb0f44c 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -267,7 +267,7 @@ static int apply_replay_entry(struct ubifs_info *c, struct 
replay_entry *r)
  * replay_entries_cmp - compare 2 replay entries.
  * @priv: UBIFS file-system description object
  * @a: first replay entry
- * @a: second replay entry
+ * @b: second replay entry
  *
  * This is a comparios function for 'list_sort()' which compares 2 replay
  * entries @a and @b by comparing their sequence numer.  Returns %1 if @a has



[PATCH 01/15 v2] UBIFS: improve function-level documentation

2016-10-01 Thread Julia Lawall
Fix various inconsistencies in the documentation associated with various
functions.

In the case of fs/ubifs/lprops.c, the second parameter of
ubifs_get_lp_stats was renamed from st to lst in commit 84abf972ccff
("UBIFS: add re-mount debugging checks")

In the case of fs/ubifs/lpt_commit.c, the excess variables have never
existed in the associated functions since the code was introduced into the
kernel.

The others appear to be straightforward typos.

Issues detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
v2: improve reference to earlier commit

 fs/ubifs/file.c   |2 +-
 fs/ubifs/gc.c |2 +-
 fs/ubifs/lprops.c |2 +-
 fs/ubifs/lpt_commit.c |4 +---
 fs/ubifs/replay.c |2 +-
 5 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index b0a6a53..629c719 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1397,7 +1397,7 @@ int ubifs_update_time(struct inode *inode, struct 
timespec *time,
 #endif

 /**
- * update_ctime - update mtime and ctime of an inode.
+ * update_mctime - update mtime and ctime of an inode.
  * @inode: inode to update
  *
  * This function updates mtime and ctime of the inode if it is not equivalent 
to
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 821b348..e845c64 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -113,7 +113,7 @@ static int switch_gc_head(struct ubifs_info *c)
  * data_nodes_cmp - compare 2 data nodes.
  * @priv: UBIFS file-system description object
  * @a: first data node
- * @a: second data node
+ * @b: second data node
  *
  * This function compares data nodes @a and @b. Returns %1 if @a has greater
  * inode or block number, and %-1 otherwise.
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index a0011aa..6c3a1ab 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -636,7 +636,7 @@ const struct ubifs_lprops *ubifs_change_lp(struct 
ubifs_info *c,
 /**
  * ubifs_get_lp_stats - get lprops statistics.
  * @c: UBIFS file-system description object
- * @st: return statistics
+ * @lst: return statistics
  */
 void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst)
 {
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index ce89bdc..235654c 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -34,7 +34,6 @@

 /**
  * first_dirty_cnode - find first dirty cnode.
- * @c: UBIFS file-system description object
  * @nnode: nnode at which to start
  *
  * This function returns the first dirty cnode or %NULL if there is not one.
@@ -1623,7 +1622,6 @@ static int dbg_is_node_dirty(struct ubifs_info *c, int 
node_type, int lnum,
  * dbg_check_ltab_lnum - check the ltab for a LPT LEB number.
  * @c: the UBIFS file-system description object
  * @lnum: LEB number where node was written
- * @offs: offset where node was written
  *
  * This function returns %0 on success and a negative error code on failure.
  */
@@ -1870,7 +1868,7 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int 
len)
 }

 /**
- * ubifs_dump_lpt_leb - dump an LPT LEB.
+ * dump_lpt_leb - dump an LPT LEB.
  * @c: UBIFS file-system description object
  * @lnum: LEB number to dump
  *
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index 3ca4540..fb0f44c 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -267,7 +267,7 @@ static int apply_replay_entry(struct ubifs_info *c, struct 
replay_entry *r)
  * replay_entries_cmp - compare 2 replay entries.
  * @priv: UBIFS file-system description object
  * @a: first replay entry
- * @a: second replay entry
+ * @b: second replay entry
  *
  * This is a comparios function for 'list_sort()' which compares 2 replay
  * entries @a and @b by comparing their sequence numer.  Returns %1 if @a has



[PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread riel
From: Rik van Riel 

Delay the loading of FPU registers until a process switches back to
userspace. This allows us to skip FPU saving & restoring for kernel
threads, the idle task, and tasks that are spinning in kernel space.

It also allows us to not repeatedly save & restore the userspace FPU
context on repeated invocations of kernel_fpu_start & kernel_fpu_end.

Not overwriting the FPU state of a task unless we need to also allows
us to be be lazier about restoring it, in a future patch.

Signed-off-by: Rik van Riel 
---
 arch/x86/entry/common.c |  4 
 arch/x86/include/asm/fpu/api.h  |  5 +
 arch/x86/include/asm/fpu/internal.h | 44 +
 arch/x86/include/asm/thread_info.h  |  4 +++-
 arch/x86/kernel/fpu/core.c  | 17 --
 arch/x86/kernel/process.c   | 35 +
 arch/x86/kernel/process_32.c|  5 ++---
 arch/x86/kernel/process_64.c|  5 ++---
 8 files changed, 71 insertions(+), 48 deletions(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 1433f6b4607d..a69bbefa3408 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CREATE_TRACE_POINTS
 #include 
@@ -197,6 +198,9 @@ __visible inline void prepare_exit_to_usermode(struct 
pt_regs *regs)
if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
exit_to_usermode_loop(regs, cached_flags);
 
+   if (unlikely(test_and_clear_thread_flag(TIF_LOAD_FPU)))
+   switch_fpu_return();
+
 #ifdef CONFIG_COMPAT
/*
 * Compat syscalls set TS_COMPAT.  Make sure we clear it before
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index 1429a7c736db..edd7dc7ae4f7 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -37,6 +37,11 @@ extern int  irq_ts_save(void);
 extern void irq_ts_restore(int TS_state);
 
 /*
+ * Set up the userspace FPU context before returning to userspace.
+ */
+extern void switch_fpu_return(void);
+
+/*
  * Query the presence of one or more xfeatures. Works on any legacy CPU as 
well.
  *
  * If 'feature_name' is set then put a human-readable description of
diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index 79e1cee9f3b0..b5accb35e434 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * High level FPU state handling functions:
@@ -576,13 +577,17 @@ static inline void fpregs_deactivate(struct fpu *fpu)
 /*
  * FPU state switching for scheduling.
  *
- * This is a two-stage process:
+ * This is a three-stage process:
  *
  *  - switch_fpu_prepare() saves the old state.
  *This is done within the context of the old process.
  *
- *  - switch_fpu_finish() restores the new state
- *and flips CR0.TS as necessary.
+ *  - switch_fpu_finish() sets TIF_LOAD_CPU, causing FPU state to
+ *be loaded when the new process returns to userspace.
+ *This is done with current_task pointing to the new process.
+ *
+ *  - switch_fpu_return() restores the new state and flips CR0.TS as
+ *necessary. This only runs if the process returns to userspace.
  */
 static inline void
 switch_fpu_prepare(struct fpu *old_fpu, int cpu)
@@ -605,38 +610,9 @@ switch_fpu_prepare(struct fpu *old_fpu, int cpu)
 /*
  * Misc helper functions:
  */
-
-/*
- * Set up the userspace FPU context for the new task.
- */
-static inline void switch_fpu_finish(struct fpu *new_fpu)
+static inline void switch_fpu_finish(void)
 {
-   bool preload;
-   /*
-* If the task has used the math, pre-load the FPU on xsave processors
-* or if the past 5 consecutive context-switches used math.
-*/
-   preload = static_cpu_has(X86_FEATURE_FPU) &&
- new_fpu->fpstate_active &&
- (use_eager_fpu() || new_fpu->counter > 5);
-
-   if (preload) {
-   prefetch(_fpu->state);
-   new_fpu->counter++;
-   __fpregs_activate(new_fpu);
-   trace_x86_fpu_regs_activated(new_fpu);
-
-   /* Don't change CR0.TS if we just switch! */
-   if (!__this_cpu_read(fpu_active)) {
-   __fpregs_activate_hw();
-   __this_cpu_write(fpu_active, true);
-   }
-
-   copy_kernel_to_fpregs(_fpu->state);
-   } else if (__this_cpu_read(fpu_active)) {
-   __this_cpu_write(fpu_active, false);
-   __fpregs_deactivate_hw();
-   }
+   set_thread_flag(TIF_LOAD_FPU);
 }
 
 /*
diff --git a/arch/x86/include/asm/thread_info.h 
b/arch/x86/include/asm/thread_info.h
index 8b7c8d8e0852..401e9c3e6039 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -106,6 

[PATCH RFC 4/5] x86,fpu: lazily skip FPU restore when still loaded

2016-10-01 Thread riel
From: Rik van Riel 

When the FPU register set has not been touched by anybody else,
we can lazily skip the restore.

Intel has a number of clever optimizations to reduce the FPU
restore overhead, but those optimizations do not work across
the guest/host virtualization boundary, and even on bare metal
it should be faster to skip the restore entirely.

This code is still BROKEN. I am not yet sure why.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/fpu/internal.h | 13 +
 arch/x86/kernel/process.c   |  3 +++
 arch/x86/kvm/x86.c  |  8 +++-
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index b5accb35e434..f69960e9aea1 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -575,6 +575,19 @@ static inline void fpregs_deactivate(struct fpu *fpu)
 }
 
 /*
+ * Check whether an FPU's register set is still loaded in the CPU.
+ */
+static inline bool fpu_lazy_skip_restore(struct fpu *fpu)
+{
+   bool still_loaded = (fpu->fpstate_active &&
+fpu->last_cpu == raw_smp_processor_id() &&
+__this_cpu_read(fpu_fpregs_owner_ctx) == fpu);
+
+   fpu->fpregs_active = still_loaded;
+   return still_loaded;
+}
+
+/*
  * FPU state switching for scheduling.
  *
  * This is a three-stage process:
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 087413be39cf..6b72415e400f 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -208,6 +208,9 @@ void switch_fpu_return(void)
  (use_eager_fpu() || fpu->counter > 5);
 
if (preload) {
+   if (fpu_lazy_skip_restore(fpu))
+   return;
+
prefetch(>state);
fpu->counter++;
__fpregs_activate(fpu);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 55c82d066d3a..16ebcd12edf7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7346,7 +7346,12 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
 
vcpu->guest_fpu_loaded = 1;
__kernel_fpu_begin(fpu);
-   __copy_kernel_to_fpregs(>state);
+
+   if (!fpu_lazy_skip_restore(fpu)) {
+   fpu->last_cpu = raw_smp_processor_id();
+   __copy_kernel_to_fpregs(>state);
+   }
+
trace_kvm_fpu(1);
 }
 
@@ -7358,6 +7363,7 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
}
 
vcpu->guest_fpu_loaded = 0;
+   vcpu->arch.guest_fpu.fpregs_active = 0;
copy_fpregs_to_fpstate(>arch.guest_fpu);
__kernel_fpu_end();
++vcpu->stat.fpu_reload;
-- 
2.7.4



[PATCH RFC 4/5] x86,fpu: lazily skip FPU restore when still loaded

2016-10-01 Thread riel
From: Rik van Riel 

When the FPU register set has not been touched by anybody else,
we can lazily skip the restore.

Intel has a number of clever optimizations to reduce the FPU
restore overhead, but those optimizations do not work across
the guest/host virtualization boundary, and even on bare metal
it should be faster to skip the restore entirely.

This code is still BROKEN. I am not yet sure why.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/fpu/internal.h | 13 +
 arch/x86/kernel/process.c   |  3 +++
 arch/x86/kvm/x86.c  |  8 +++-
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index b5accb35e434..f69960e9aea1 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -575,6 +575,19 @@ static inline void fpregs_deactivate(struct fpu *fpu)
 }
 
 /*
+ * Check whether an FPU's register set is still loaded in the CPU.
+ */
+static inline bool fpu_lazy_skip_restore(struct fpu *fpu)
+{
+   bool still_loaded = (fpu->fpstate_active &&
+fpu->last_cpu == raw_smp_processor_id() &&
+__this_cpu_read(fpu_fpregs_owner_ctx) == fpu);
+
+   fpu->fpregs_active = still_loaded;
+   return still_loaded;
+}
+
+/*
  * FPU state switching for scheduling.
  *
  * This is a three-stage process:
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 087413be39cf..6b72415e400f 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -208,6 +208,9 @@ void switch_fpu_return(void)
  (use_eager_fpu() || fpu->counter > 5);
 
if (preload) {
+   if (fpu_lazy_skip_restore(fpu))
+   return;
+
prefetch(>state);
fpu->counter++;
__fpregs_activate(fpu);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 55c82d066d3a..16ebcd12edf7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7346,7 +7346,12 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
 
vcpu->guest_fpu_loaded = 1;
__kernel_fpu_begin(fpu);
-   __copy_kernel_to_fpregs(>state);
+
+   if (!fpu_lazy_skip_restore(fpu)) {
+   fpu->last_cpu = raw_smp_processor_id();
+   __copy_kernel_to_fpregs(>state);
+   }
+
trace_kvm_fpu(1);
 }
 
@@ -7358,6 +7363,7 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
}
 
vcpu->guest_fpu_loaded = 0;
+   vcpu->arch.guest_fpu.fpregs_active = 0;
copy_fpregs_to_fpstate(>arch.guest_fpu);
__kernel_fpu_end();
++vcpu->stat.fpu_reload;
-- 
2.7.4



[PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread riel
From: Rik van Riel 

Delay the loading of FPU registers until a process switches back to
userspace. This allows us to skip FPU saving & restoring for kernel
threads, the idle task, and tasks that are spinning in kernel space.

It also allows us to not repeatedly save & restore the userspace FPU
context on repeated invocations of kernel_fpu_start & kernel_fpu_end.

Not overwriting the FPU state of a task unless we need to also allows
us to be be lazier about restoring it, in a future patch.

Signed-off-by: Rik van Riel 
---
 arch/x86/entry/common.c |  4 
 arch/x86/include/asm/fpu/api.h  |  5 +
 arch/x86/include/asm/fpu/internal.h | 44 +
 arch/x86/include/asm/thread_info.h  |  4 +++-
 arch/x86/kernel/fpu/core.c  | 17 --
 arch/x86/kernel/process.c   | 35 +
 arch/x86/kernel/process_32.c|  5 ++---
 arch/x86/kernel/process_64.c|  5 ++---
 8 files changed, 71 insertions(+), 48 deletions(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 1433f6b4607d..a69bbefa3408 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CREATE_TRACE_POINTS
 #include 
@@ -197,6 +198,9 @@ __visible inline void prepare_exit_to_usermode(struct 
pt_regs *regs)
if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
exit_to_usermode_loop(regs, cached_flags);
 
+   if (unlikely(test_and_clear_thread_flag(TIF_LOAD_FPU)))
+   switch_fpu_return();
+
 #ifdef CONFIG_COMPAT
/*
 * Compat syscalls set TS_COMPAT.  Make sure we clear it before
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index 1429a7c736db..edd7dc7ae4f7 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -37,6 +37,11 @@ extern int  irq_ts_save(void);
 extern void irq_ts_restore(int TS_state);
 
 /*
+ * Set up the userspace FPU context before returning to userspace.
+ */
+extern void switch_fpu_return(void);
+
+/*
  * Query the presence of one or more xfeatures. Works on any legacy CPU as 
well.
  *
  * If 'feature_name' is set then put a human-readable description of
diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index 79e1cee9f3b0..b5accb35e434 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * High level FPU state handling functions:
@@ -576,13 +577,17 @@ static inline void fpregs_deactivate(struct fpu *fpu)
 /*
  * FPU state switching for scheduling.
  *
- * This is a two-stage process:
+ * This is a three-stage process:
  *
  *  - switch_fpu_prepare() saves the old state.
  *This is done within the context of the old process.
  *
- *  - switch_fpu_finish() restores the new state
- *and flips CR0.TS as necessary.
+ *  - switch_fpu_finish() sets TIF_LOAD_CPU, causing FPU state to
+ *be loaded when the new process returns to userspace.
+ *This is done with current_task pointing to the new process.
+ *
+ *  - switch_fpu_return() restores the new state and flips CR0.TS as
+ *necessary. This only runs if the process returns to userspace.
  */
 static inline void
 switch_fpu_prepare(struct fpu *old_fpu, int cpu)
@@ -605,38 +610,9 @@ switch_fpu_prepare(struct fpu *old_fpu, int cpu)
 /*
  * Misc helper functions:
  */
-
-/*
- * Set up the userspace FPU context for the new task.
- */
-static inline void switch_fpu_finish(struct fpu *new_fpu)
+static inline void switch_fpu_finish(void)
 {
-   bool preload;
-   /*
-* If the task has used the math, pre-load the FPU on xsave processors
-* or if the past 5 consecutive context-switches used math.
-*/
-   preload = static_cpu_has(X86_FEATURE_FPU) &&
- new_fpu->fpstate_active &&
- (use_eager_fpu() || new_fpu->counter > 5);
-
-   if (preload) {
-   prefetch(_fpu->state);
-   new_fpu->counter++;
-   __fpregs_activate(new_fpu);
-   trace_x86_fpu_regs_activated(new_fpu);
-
-   /* Don't change CR0.TS if we just switch! */
-   if (!__this_cpu_read(fpu_active)) {
-   __fpregs_activate_hw();
-   __this_cpu_write(fpu_active, true);
-   }
-
-   copy_kernel_to_fpregs(_fpu->state);
-   } else if (__this_cpu_read(fpu_active)) {
-   __this_cpu_write(fpu_active, false);
-   __fpregs_deactivate_hw();
-   }
+   set_thread_flag(TIF_LOAD_FPU);
 }
 
 /*
diff --git a/arch/x86/include/asm/thread_info.h 
b/arch/x86/include/asm/thread_info.h
index 8b7c8d8e0852..401e9c3e6039 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -106,6 +106,7 @@ struct thread_info {
 

[PATCH 14/15 v2] irqchip/metag-ext: improve function-level documentation

2016-10-01 Thread Julia Lawall
Drop the variable irq which ceased to be a parameter in commit bd0b9ac405e1
("genirq: Remove irq argument from irq flow handlers")

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 
Acked-by: James Hogan 

---
v2: correct commit reference, independent of the rest of the series

 drivers/irqchip/irq-metag-ext.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/irqchip/irq-metag-ext.c b/drivers/irqchip/irq-metag-ext.c
index 8c38b3d..0cdd923 100644
--- a/drivers/irqchip/irq-metag-ext.c
+++ b/drivers/irqchip/irq-metag-ext.c
@@ -436,7 +436,6 @@ static int meta_intc_irq_set_type(struct irq_data *data, 
unsigned int flow_type)

 /**
  * meta_intc_irq_demux() - external irq de-multiplexer
- * @irq:   the virtual interrupt number
  * @desc:  the interrupt description structure for this irq
  *
  * The cpu receives an interrupt on TR2 when a SoC interrupt has occurred. It 
is



[PATCH RFC 3/5] x86,fpu: add kernel fpu argument to __kernel_fpu_begin

2016-10-01 Thread riel
From: Rik van Riel 

Most kernel FPU contexts are transient, but a KVM VCPU context
persists.  Add a kernel FPU argument to __kernel_fpu_begin, so
we can know whether or not the KVM VCPU context got clobbered
by another kernel FPU context.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/efi.h | 2 +-
 arch/x86/include/asm/fpu/api.h | 2 +-
 arch/x86/kernel/fpu/core.c | 6 +++---
 arch/x86/kvm/x86.c | 8 ++--
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index d0bb76d81402..603d2cdd6b82 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -71,7 +71,7 @@ struct efi_scratch {
 ({ \
efi_sync_low_kernel_mappings(); \
preempt_disable();  \
-   __kernel_fpu_begin();   \
+   __kernel_fpu_begin(NULL);   \
\
if (efi_scratch.use_pgd) {  \
efi_scratch.prev_cr3 = read_cr3();  \
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index edd7dc7ae4f7..f6704edf9904 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -20,7 +20,7 @@
  * All other cases use kernel_fpu_begin/end() which disable preemption
  * during kernel FPU usage.
  */
-extern void __kernel_fpu_begin(void);
+extern void __kernel_fpu_begin(struct fpu *fpu);
 extern void __kernel_fpu_end(void);
 extern void kernel_fpu_begin(void);
 extern void kernel_fpu_end(void);
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index c4350f188be1..537eb65b6ae6 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -110,7 +110,7 @@ bool irq_fpu_usable(void)
 }
 EXPORT_SYMBOL(irq_fpu_usable);
 
-void __kernel_fpu_begin(void)
+void __kernel_fpu_begin(struct fpu *kernelfpu)
 {
struct fpu *fpu = >thread.fpu;
 
@@ -118,7 +118,7 @@ void __kernel_fpu_begin(void)
 
kernel_fpu_disable();
 
-   this_cpu_write(fpu_fpregs_owner_ctx, NULL);
+   this_cpu_write(fpu_fpregs_owner_ctx, kernelfpu);
 
if (fpu->fpregs_active) {
/*
@@ -150,7 +150,7 @@ EXPORT_SYMBOL(__kernel_fpu_end);
 void kernel_fpu_begin(void)
 {
preempt_disable();
-   __kernel_fpu_begin();
+   __kernel_fpu_begin(NULL);
 }
 EXPORT_SYMBOL_GPL(kernel_fpu_begin);
 
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 699f8726539a..55c82d066d3a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7332,6 +7332,8 @@ static void fx_init(struct kvm_vcpu *vcpu)
 
 void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
 {
+   struct fpu *fpu;
+
if (vcpu->guest_fpu_loaded)
return;
 
@@ -7340,9 +7342,11 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
 * and assume host would use all available bits.
 * Guest xcr0 would be loaded later.
 */
+   fpu = >arch.guest_fpu;
+
vcpu->guest_fpu_loaded = 1;
-   __kernel_fpu_begin();
-   __copy_kernel_to_fpregs(>arch.guest_fpu.state);
+   __kernel_fpu_begin(fpu);
+   __copy_kernel_to_fpregs(>state);
trace_kvm_fpu(1);
 }
 
-- 
2.7.4



[PATCH RFC 1/5] x86,fpu: split prev/next task fpu state handling

2016-10-01 Thread riel
From: Rik van Riel 

Move all handling of the next state FPU state handling into
switch_fpu_finish, in preparation for more lazily switching
FPU states.

CR0.TS state is mirrored in a per-cpu variable, instead of
being passed around in a local variable, because that will
not be possible later in the series.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/fpu/internal.h | 78 -
 arch/x86/kernel/fpu/core.c  |  1 +
 arch/x86/kernel/process_32.c|  5 +--
 arch/x86/kernel/process_64.c|  5 +--
 4 files changed, 39 insertions(+), 50 deletions(-)

diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index 2737366ea583..79e1cee9f3b0 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -482,6 +482,7 @@ extern int copy_fpstate_to_sigframe(void __user *buf, void 
__user *fp, int size)
  */
 
 DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
+DECLARE_PER_CPU(bool, fpu_active);
 
 /*
  * Must be run with preemption disabled: this clears the fpu_fpregs_owner_ctx,
@@ -577,28 +578,15 @@ static inline void fpregs_deactivate(struct fpu *fpu)
  *
  * This is a two-stage process:
  *
- *  - switch_fpu_prepare() saves the old state and
- *sets the new state of the CR0.TS bit. This is
- *done within the context of the old process.
+ *  - switch_fpu_prepare() saves the old state.
+ *This is done within the context of the old process.
  *
- *  - switch_fpu_finish() restores the new state as
- *necessary.
+ *  - switch_fpu_finish() restores the new state
+ *and flips CR0.TS as necessary.
  */
-typedef struct { int preload; } fpu_switch_t;
-
-static inline fpu_switch_t
-switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
+static inline void
+switch_fpu_prepare(struct fpu *old_fpu, int cpu)
 {
-   fpu_switch_t fpu;
-
-   /*
-* If the task has used the math, pre-load the FPU on xsave processors
-* or if the past 5 consecutive context-switches used math.
-*/
-   fpu.preload = static_cpu_has(X86_FEATURE_FPU) &&
- new_fpu->fpstate_active &&
- (use_eager_fpu() || new_fpu->counter > 5);
-
if (old_fpu->fpregs_active) {
if (!copy_fpregs_to_fpstate(old_fpu))
old_fpu->last_cpu = -1;
@@ -608,29 +596,10 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu 
*new_fpu, int cpu)
/* But leave fpu_fpregs_owner_ctx! */
old_fpu->fpregs_active = 0;
trace_x86_fpu_regs_deactivated(old_fpu);
-
-   /* Don't change CR0.TS if we just switch! */
-   if (fpu.preload) {
-   new_fpu->counter++;
-   __fpregs_activate(new_fpu);
-   trace_x86_fpu_regs_activated(new_fpu);
-   prefetch(_fpu->state);
-   } else {
-   __fpregs_deactivate_hw();
-   }
} else {
old_fpu->counter = 0;
old_fpu->last_cpu = -1;
-   if (fpu.preload) {
-   new_fpu->counter++;
-   if (fpu_want_lazy_restore(new_fpu, cpu))
-   fpu.preload = 0;
-   else
-   prefetch(_fpu->state);
-   fpregs_activate(new_fpu);
-   }
}
-   return fpu;
 }
 
 /*
@@ -638,15 +607,36 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu 
*new_fpu, int cpu)
  */
 
 /*
- * By the time this gets called, we've already cleared CR0.TS and
- * given the process the FPU if we are going to preload the FPU
- * state - all we need to do is to conditionally restore the register
- * state itself.
+ * Set up the userspace FPU context for the new task.
  */
-static inline void switch_fpu_finish(struct fpu *new_fpu, fpu_switch_t 
fpu_switch)
+static inline void switch_fpu_finish(struct fpu *new_fpu)
 {
-   if (fpu_switch.preload)
+   bool preload;
+   /*
+* If the task has used the math, pre-load the FPU on xsave processors
+* or if the past 5 consecutive context-switches used math.
+*/
+   preload = static_cpu_has(X86_FEATURE_FPU) &&
+ new_fpu->fpstate_active &&
+ (use_eager_fpu() || new_fpu->counter > 5);
+
+   if (preload) {
+   prefetch(_fpu->state);
+   new_fpu->counter++;
+   __fpregs_activate(new_fpu);
+   trace_x86_fpu_regs_activated(new_fpu);
+
+   /* Don't change CR0.TS if we just switch! */
+   if (!__this_cpu_read(fpu_active)) {
+   __fpregs_activate_hw();
+   __this_cpu_write(fpu_active, true);
+   }
+
copy_kernel_to_fpregs(_fpu->state);
+   } else if 

[PATCH 14/15 v2] irqchip/metag-ext: improve function-level documentation

2016-10-01 Thread Julia Lawall
Drop the variable irq which ceased to be a parameter in commit bd0b9ac405e1
("genirq: Remove irq argument from irq flow handlers")

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 
Acked-by: James Hogan 

---
v2: correct commit reference, independent of the rest of the series

 drivers/irqchip/irq-metag-ext.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/irqchip/irq-metag-ext.c b/drivers/irqchip/irq-metag-ext.c
index 8c38b3d..0cdd923 100644
--- a/drivers/irqchip/irq-metag-ext.c
+++ b/drivers/irqchip/irq-metag-ext.c
@@ -436,7 +436,6 @@ static int meta_intc_irq_set_type(struct irq_data *data, 
unsigned int flow_type)

 /**
  * meta_intc_irq_demux() - external irq de-multiplexer
- * @irq:   the virtual interrupt number
  * @desc:  the interrupt description structure for this irq
  *
  * The cpu receives an interrupt on TR2 when a SoC interrupt has occurred. It 
is



[PATCH RFC 3/5] x86,fpu: add kernel fpu argument to __kernel_fpu_begin

2016-10-01 Thread riel
From: Rik van Riel 

Most kernel FPU contexts are transient, but a KVM VCPU context
persists.  Add a kernel FPU argument to __kernel_fpu_begin, so
we can know whether or not the KVM VCPU context got clobbered
by another kernel FPU context.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/efi.h | 2 +-
 arch/x86/include/asm/fpu/api.h | 2 +-
 arch/x86/kernel/fpu/core.c | 6 +++---
 arch/x86/kvm/x86.c | 8 ++--
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index d0bb76d81402..603d2cdd6b82 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -71,7 +71,7 @@ struct efi_scratch {
 ({ \
efi_sync_low_kernel_mappings(); \
preempt_disable();  \
-   __kernel_fpu_begin();   \
+   __kernel_fpu_begin(NULL);   \
\
if (efi_scratch.use_pgd) {  \
efi_scratch.prev_cr3 = read_cr3();  \
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index edd7dc7ae4f7..f6704edf9904 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -20,7 +20,7 @@
  * All other cases use kernel_fpu_begin/end() which disable preemption
  * during kernel FPU usage.
  */
-extern void __kernel_fpu_begin(void);
+extern void __kernel_fpu_begin(struct fpu *fpu);
 extern void __kernel_fpu_end(void);
 extern void kernel_fpu_begin(void);
 extern void kernel_fpu_end(void);
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index c4350f188be1..537eb65b6ae6 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -110,7 +110,7 @@ bool irq_fpu_usable(void)
 }
 EXPORT_SYMBOL(irq_fpu_usable);
 
-void __kernel_fpu_begin(void)
+void __kernel_fpu_begin(struct fpu *kernelfpu)
 {
struct fpu *fpu = >thread.fpu;
 
@@ -118,7 +118,7 @@ void __kernel_fpu_begin(void)
 
kernel_fpu_disable();
 
-   this_cpu_write(fpu_fpregs_owner_ctx, NULL);
+   this_cpu_write(fpu_fpregs_owner_ctx, kernelfpu);
 
if (fpu->fpregs_active) {
/*
@@ -150,7 +150,7 @@ EXPORT_SYMBOL(__kernel_fpu_end);
 void kernel_fpu_begin(void)
 {
preempt_disable();
-   __kernel_fpu_begin();
+   __kernel_fpu_begin(NULL);
 }
 EXPORT_SYMBOL_GPL(kernel_fpu_begin);
 
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 699f8726539a..55c82d066d3a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7332,6 +7332,8 @@ static void fx_init(struct kvm_vcpu *vcpu)
 
 void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
 {
+   struct fpu *fpu;
+
if (vcpu->guest_fpu_loaded)
return;
 
@@ -7340,9 +7342,11 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
 * and assume host would use all available bits.
 * Guest xcr0 would be loaded later.
 */
+   fpu = >arch.guest_fpu;
+
vcpu->guest_fpu_loaded = 1;
-   __kernel_fpu_begin();
-   __copy_kernel_to_fpregs(>arch.guest_fpu.state);
+   __kernel_fpu_begin(fpu);
+   __copy_kernel_to_fpregs(>state);
trace_kvm_fpu(1);
 }
 
-- 
2.7.4



[PATCH RFC 1/5] x86,fpu: split prev/next task fpu state handling

2016-10-01 Thread riel
From: Rik van Riel 

Move all handling of the next state FPU state handling into
switch_fpu_finish, in preparation for more lazily switching
FPU states.

CR0.TS state is mirrored in a per-cpu variable, instead of
being passed around in a local variable, because that will
not be possible later in the series.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/fpu/internal.h | 78 -
 arch/x86/kernel/fpu/core.c  |  1 +
 arch/x86/kernel/process_32.c|  5 +--
 arch/x86/kernel/process_64.c|  5 +--
 4 files changed, 39 insertions(+), 50 deletions(-)

diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index 2737366ea583..79e1cee9f3b0 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -482,6 +482,7 @@ extern int copy_fpstate_to_sigframe(void __user *buf, void 
__user *fp, int size)
  */
 
 DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
+DECLARE_PER_CPU(bool, fpu_active);
 
 /*
  * Must be run with preemption disabled: this clears the fpu_fpregs_owner_ctx,
@@ -577,28 +578,15 @@ static inline void fpregs_deactivate(struct fpu *fpu)
  *
  * This is a two-stage process:
  *
- *  - switch_fpu_prepare() saves the old state and
- *sets the new state of the CR0.TS bit. This is
- *done within the context of the old process.
+ *  - switch_fpu_prepare() saves the old state.
+ *This is done within the context of the old process.
  *
- *  - switch_fpu_finish() restores the new state as
- *necessary.
+ *  - switch_fpu_finish() restores the new state
+ *and flips CR0.TS as necessary.
  */
-typedef struct { int preload; } fpu_switch_t;
-
-static inline fpu_switch_t
-switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
+static inline void
+switch_fpu_prepare(struct fpu *old_fpu, int cpu)
 {
-   fpu_switch_t fpu;
-
-   /*
-* If the task has used the math, pre-load the FPU on xsave processors
-* or if the past 5 consecutive context-switches used math.
-*/
-   fpu.preload = static_cpu_has(X86_FEATURE_FPU) &&
- new_fpu->fpstate_active &&
- (use_eager_fpu() || new_fpu->counter > 5);
-
if (old_fpu->fpregs_active) {
if (!copy_fpregs_to_fpstate(old_fpu))
old_fpu->last_cpu = -1;
@@ -608,29 +596,10 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu 
*new_fpu, int cpu)
/* But leave fpu_fpregs_owner_ctx! */
old_fpu->fpregs_active = 0;
trace_x86_fpu_regs_deactivated(old_fpu);
-
-   /* Don't change CR0.TS if we just switch! */
-   if (fpu.preload) {
-   new_fpu->counter++;
-   __fpregs_activate(new_fpu);
-   trace_x86_fpu_regs_activated(new_fpu);
-   prefetch(_fpu->state);
-   } else {
-   __fpregs_deactivate_hw();
-   }
} else {
old_fpu->counter = 0;
old_fpu->last_cpu = -1;
-   if (fpu.preload) {
-   new_fpu->counter++;
-   if (fpu_want_lazy_restore(new_fpu, cpu))
-   fpu.preload = 0;
-   else
-   prefetch(_fpu->state);
-   fpregs_activate(new_fpu);
-   }
}
-   return fpu;
 }
 
 /*
@@ -638,15 +607,36 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu 
*new_fpu, int cpu)
  */
 
 /*
- * By the time this gets called, we've already cleared CR0.TS and
- * given the process the FPU if we are going to preload the FPU
- * state - all we need to do is to conditionally restore the register
- * state itself.
+ * Set up the userspace FPU context for the new task.
  */
-static inline void switch_fpu_finish(struct fpu *new_fpu, fpu_switch_t 
fpu_switch)
+static inline void switch_fpu_finish(struct fpu *new_fpu)
 {
-   if (fpu_switch.preload)
+   bool preload;
+   /*
+* If the task has used the math, pre-load the FPU on xsave processors
+* or if the past 5 consecutive context-switches used math.
+*/
+   preload = static_cpu_has(X86_FEATURE_FPU) &&
+ new_fpu->fpstate_active &&
+ (use_eager_fpu() || new_fpu->counter > 5);
+
+   if (preload) {
+   prefetch(_fpu->state);
+   new_fpu->counter++;
+   __fpregs_activate(new_fpu);
+   trace_x86_fpu_regs_activated(new_fpu);
+
+   /* Don't change CR0.TS if we just switch! */
+   if (!__this_cpu_read(fpu_active)) {
+   __fpregs_activate_hw();
+   __this_cpu_write(fpu_active, true);
+   }
+
copy_kernel_to_fpregs(_fpu->state);
+   } else if (__this_cpu_read(fpu_active)) {
+   

[PATCH RFC 5/5] x86,fpu: kinda sorta fix up signal path

2016-10-01 Thread riel
From: Rik van Riel 

Need to ensure that the FPU save code and the lazy restore code
do not use invalid kernel or floating point register state and
copy it over to the other location.

I am pretty sure this is incomplete.

Signed-off-by: Rik van Riel 
---
 arch/x86/kernel/fpu/core.c   | 1 +
 arch/x86/kernel/fpu/signal.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 537eb65b6ae6..fa59cc741fa5 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -314,6 +314,7 @@ void fpu__activate_curr(struct fpu *fpu)
trace_x86_fpu_activate_state(fpu);
/* Safe to do for the current task: */
fpu->fpstate_active = 1;
+   fpu->last_cpu = -1;
}
 }
 EXPORT_SYMBOL_GPL(fpu__activate_curr);
diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index a184c210efba..89f882983da7 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -171,6 +171,10 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user 
*buf_fx, int size)
(struct _fpstate_32 __user *) buf) ? -1 : 1;
 
if (fpregs_active() || using_compacted_format()) {
+   /* Compacted format, but the FP state is not loaded yet. */
+   if (unlikely(!fpu_lazy_skip_restore(>thread.fpu)))
+   copy_kernel_to_fpregs(>thread.fpu.state);
+
/* Save the live register state to the user directly. */
if (copy_fpregs_to_sigframe(buf_fx))
return -1;
-- 
2.7.4



[PATCH RFC 0/5] x86,fpu: make FPU context switching much lazier

2016-10-01 Thread riel
This series is an attempt at making the x86 FPU context switching
code much lazier.  By only reloading the FPU context when a task
switches to user mode, we can avoid switching FPU context for tasks
that spin in kernel mode, and avoid reloading the FPU context for
tasks that get interrupted by a kernel thread or briefly go idle.

It also allows us to skip restoring the userspace FPU context when
exiting a KVM guest.

This series is still BROKEN.  The first 3 patches seem to work
fine in my tests (but should not, due to missing signal path
code), while the 4th test makes it easier to trigger bugs.

I am posting this to ask about obvious issues people may see,
ideas on what direction I should take this series in, and to
avoid code conflicts with Andy's plans wrt. lazy fpu mode.



[PATCH RFC 5/5] x86,fpu: kinda sorta fix up signal path

2016-10-01 Thread riel
From: Rik van Riel 

Need to ensure that the FPU save code and the lazy restore code
do not use invalid kernel or floating point register state and
copy it over to the other location.

I am pretty sure this is incomplete.

Signed-off-by: Rik van Riel 
---
 arch/x86/kernel/fpu/core.c   | 1 +
 arch/x86/kernel/fpu/signal.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 537eb65b6ae6..fa59cc741fa5 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -314,6 +314,7 @@ void fpu__activate_curr(struct fpu *fpu)
trace_x86_fpu_activate_state(fpu);
/* Safe to do for the current task: */
fpu->fpstate_active = 1;
+   fpu->last_cpu = -1;
}
 }
 EXPORT_SYMBOL_GPL(fpu__activate_curr);
diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index a184c210efba..89f882983da7 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -171,6 +171,10 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user 
*buf_fx, int size)
(struct _fpstate_32 __user *) buf) ? -1 : 1;
 
if (fpregs_active() || using_compacted_format()) {
+   /* Compacted format, but the FP state is not loaded yet. */
+   if (unlikely(!fpu_lazy_skip_restore(>thread.fpu)))
+   copy_kernel_to_fpregs(>thread.fpu.state);
+
/* Save the live register state to the user directly. */
if (copy_fpregs_to_sigframe(buf_fx))
return -1;
-- 
2.7.4



[PATCH RFC 0/5] x86,fpu: make FPU context switching much lazier

2016-10-01 Thread riel
This series is an attempt at making the x86 FPU context switching
code much lazier.  By only reloading the FPU context when a task
switches to user mode, we can avoid switching FPU context for tasks
that spin in kernel mode, and avoid reloading the FPU context for
tasks that get interrupted by a kernel thread or briefly go idle.

It also allows us to skip restoring the userspace FPU context when
exiting a KVM guest.

This series is still BROKEN.  The first 3 patches seem to work
fine in my tests (but should not, due to missing signal path
code), while the 4th test makes it easier to trigger bugs.

I am posting this to ask about obvious issues people may see,
ideas on what direction I should take this series in, and to
avoid code conflicts with Andy's plans wrt. lazy fpu mode.



Re: [PATCH 0/2] Moving runnable code from Documentation (last 2 patches)

2016-10-01 Thread Michal Marek
Dne 1.10.2016 v 09:10 Jonathan Corbet napsal(a):
> On Fri, 30 Sep 2016 07:57:51 -0600
> Shuah Khan  wrote:
> 
>>> This patch series contains the last 2 patches to complete moving runnable
>>> code from Documentation to selftests, samples, and tools.
>>>
>>> The first patch moves blackfin gptimers-example to samples and removes
>>> CONFIG_BUILD_DOCSRC.
>>>
>>> The second one updates 00-INDEX files under Documentation to reflect the
>>> move of runnable code from Documentation.
>>>
>>> Shuah Khan (2):
>>>   samples: move blackfin gptimers-example from Documentation
>>>   Doc: update 00-INDEX files to reflect the runnable code move
>>>   
>>
>> Hi Jon and Michal,
>>
>> Do these patches look good to you? I can get these into 4.9-rc1
>> with your Ack.
> 
> Seems good to me.
> 
> Acked-by: Jonathan Corbet 

Likewise,

Acked-by: Michal Marek 

Michal



Re: [PATCH 0/2] Moving runnable code from Documentation (last 2 patches)

2016-10-01 Thread Michal Marek
Dne 1.10.2016 v 09:10 Jonathan Corbet napsal(a):
> On Fri, 30 Sep 2016 07:57:51 -0600
> Shuah Khan  wrote:
> 
>>> This patch series contains the last 2 patches to complete moving runnable
>>> code from Documentation to selftests, samples, and tools.
>>>
>>> The first patch moves blackfin gptimers-example to samples and removes
>>> CONFIG_BUILD_DOCSRC.
>>>
>>> The second one updates 00-INDEX files under Documentation to reflect the
>>> move of runnable code from Documentation.
>>>
>>> Shuah Khan (2):
>>>   samples: move blackfin gptimers-example from Documentation
>>>   Doc: update 00-INDEX files to reflect the runnable code move
>>>   
>>
>> Hi Jon and Michal,
>>
>> Do these patches look good to you? I can get these into 4.9-rc1
>> with your Ack.
> 
> Seems good to me.
> 
> Acked-by: Jonathan Corbet 

Likewise,

Acked-by: Michal Marek 

Michal



Re: [PATCH] Input: synaptics-rmi4 - Fix error handling in I2C transport driver

2016-10-01 Thread Guenter Roeck

On 10/01/2016 12:04 PM, Dmitry Torokhov wrote:

On Sat, Oct 01, 2016 at 10:27:42AM -0700, Andrew Duggan wrote:



On Fri, Sep 30, 2016, at 08:44 PM, Guenter Roeck wrote:

On 09/30/2016 04:02 PM, Dmitry Torokhov wrote:

On Fri, Sep 30, 2016 at 03:54:03PM -0700, Dmitry Torokhov wrote:

On Thu, Sep 29, 2016 at 10:55:40AM -0700, Bjorn Andersson wrote:

On Wed 28 Sep 17:37 PDT 2016, Guenter Roeck wrote:


Instantiating the rmi4 I2C transport driver without interrupts assigned
(for example using manual i2c instantiation from the command line)
caused the driver to fail to load, but it does not clean up its
regulator or transport device registrations. Result is a crash at a later
time, for example when rebooting the system.

Fixes: 946c8432aab0 ("Input: synaptics-rmi4 - support regulator supplies")


Sorry for that.


Fixes: fdf51604f104 ("Input: synaptics-rmi4 - add I2C transport driver")
Cc: Bjorn Andersson 


Reviewed-by: Bjorn Andersson 


Applied, thank you.


I take it back. rmi_i2c_init_irq() uses devm* so this whole thing mixes
up devm* and manual unregistering and unwind order is completely
broken.


Oops ...


1. Why do we register interrupt from transport drivers and not make it
part of rmi_register_transport_device()?


Not all RMI devices will have access to interrupts (ie HID and SMBus).
The same goes for regulators. Here is a reference to a previous
discussion regarding both:
https://lkml.org/lkml/2016/5/9/1055


Yeah, I am wondering if we should not revisit this and have SMBus (and
possibly HID) actually provide us with an interrupt.

In the meantime we can just ignore interrupt value if it is set to 0.



I have another follow-up patch doing that (I have a test setup which
doesn't support interrupts); I just wasn't sure if there was interest,
so I did not yet send it out. I'll be happy to do that, though I would
prefer to keep it separate (it isn't a bug fix, after all).

Thanks,
Guenter



Re: [PATCH] Input: synaptics-rmi4 - Fix error handling in I2C transport driver

2016-10-01 Thread Guenter Roeck

On 10/01/2016 12:04 PM, Dmitry Torokhov wrote:

On Sat, Oct 01, 2016 at 10:27:42AM -0700, Andrew Duggan wrote:



On Fri, Sep 30, 2016, at 08:44 PM, Guenter Roeck wrote:

On 09/30/2016 04:02 PM, Dmitry Torokhov wrote:

On Fri, Sep 30, 2016 at 03:54:03PM -0700, Dmitry Torokhov wrote:

On Thu, Sep 29, 2016 at 10:55:40AM -0700, Bjorn Andersson wrote:

On Wed 28 Sep 17:37 PDT 2016, Guenter Roeck wrote:


Instantiating the rmi4 I2C transport driver without interrupts assigned
(for example using manual i2c instantiation from the command line)
caused the driver to fail to load, but it does not clean up its
regulator or transport device registrations. Result is a crash at a later
time, for example when rebooting the system.

Fixes: 946c8432aab0 ("Input: synaptics-rmi4 - support regulator supplies")


Sorry for that.


Fixes: fdf51604f104 ("Input: synaptics-rmi4 - add I2C transport driver")
Cc: Bjorn Andersson 


Reviewed-by: Bjorn Andersson 


Applied, thank you.


I take it back. rmi_i2c_init_irq() uses devm* so this whole thing mixes
up devm* and manual unregistering and unwind order is completely
broken.


Oops ...


1. Why do we register interrupt from transport drivers and not make it
part of rmi_register_transport_device()?


Not all RMI devices will have access to interrupts (ie HID and SMBus).
The same goes for regulators. Here is a reference to a previous
discussion regarding both:
https://lkml.org/lkml/2016/5/9/1055


Yeah, I am wondering if we should not revisit this and have SMBus (and
possibly HID) actually provide us with an interrupt.

In the meantime we can just ignore interrupt value if it is set to 0.



I have another follow-up patch doing that (I have a test setup which
doesn't support interrupts); I just wasn't sure if there was interest,
so I did not yet send it out. I'll be happy to do that, though I would
prefer to keep it separate (it isn't a bug fix, after all).

Thanks,
Guenter



Re: [PATCH 00/15] improve function-level documentation

2016-10-01 Thread Julia Lawall


On Sat, 1 Oct 2016, Joe Perches wrote:

> On Sat, 2016-10-01 at 21:46 +0200, Julia Lawall wrote:
> > These patches fix cases where the documentation above a function definition
> > is not consistent with the function header.  Issues are detected using the
> > semantic patch below (http://coccinelle.lip6.fr/).  Basically, the semantic
> > patch parses a file to find comments, then matches each function header,
> > and checks that the name and parameter list in the function header are
> > compatible with the comment that preceeds it most closely.
>
> Hi Julia.
>
> Would it be possible for a semantic patch to scan for
> function definitions where the types do not have
> identifiers and update the definitions to match the
> declarations?
>
> For instance, given:
>
> 
> int foo(int);
>
> 
> int foo(int bar)
> {
>   return baz;
> }
>
> Could coccinelle output:
>
> diff a/some.h b/some.h
> []
> -int foo(int);
> +int foo(int bar);

The following seems to work:

@r@
identifier f;
position p;
type T, t;
parameter list[n] ps;
@@

T f@p(ps,t,...);

@s@
identifier r.f,x;
type r.T, r.t;
parameter list[r.n] ps;
@@

T f(ps,t x,...) { ... }

@@
identifier r.f, s.x;
position r.p;
type r.T, r.t;
parameter list[r.n] ps;
@@

T f@p(ps,t
+ x
  ,...);

After letting it run for a few minutes without making any effort to
include .h files, I get over 2700 changed lines.

julia


Re: [PATCH 00/15] improve function-level documentation

2016-10-01 Thread Julia Lawall


On Sat, 1 Oct 2016, Joe Perches wrote:

> On Sat, 2016-10-01 at 21:46 +0200, Julia Lawall wrote:
> > These patches fix cases where the documentation above a function definition
> > is not consistent with the function header.  Issues are detected using the
> > semantic patch below (http://coccinelle.lip6.fr/).  Basically, the semantic
> > patch parses a file to find comments, then matches each function header,
> > and checks that the name and parameter list in the function header are
> > compatible with the comment that preceeds it most closely.
>
> Hi Julia.
>
> Would it be possible for a semantic patch to scan for
> function definitions where the types do not have
> identifiers and update the definitions to match the
> declarations?
>
> For instance, given:
>
> 
> int foo(int);
>
> 
> int foo(int bar)
> {
>   return baz;
> }
>
> Could coccinelle output:
>
> diff a/some.h b/some.h
> []
> -int foo(int);
> +int foo(int bar);

The following seems to work:

@r@
identifier f;
position p;
type T, t;
parameter list[n] ps;
@@

T f@p(ps,t,...);

@s@
identifier r.f,x;
type r.T, r.t;
parameter list[r.n] ps;
@@

T f(ps,t x,...) { ... }

@@
identifier r.f, s.x;
position r.p;
type r.T, r.t;
parameter list[r.n] ps;
@@

T f@p(ps,t
+ x
  ,...);

After letting it run for a few minutes without making any effort to
include .h files, I get over 2700 changed lines.

julia


Re: [PATCH 14/15] irqchip/metag-ext: improve function-level documentation

2016-10-01 Thread James Hogan
Hi Julia,

On 1 October 2016 at 20:46, Julia Lawall  wrote:
> Drop the variable irq which ceased to be a parameter in bd0b9ac4.

I think 12 nibbles of the hash is recommended now due to collisions,
as is quoting the subject line, e.g. commit bd0b9ac405e1 ("genirq:
Remove irq argument from irq flow handlers").

>
> Issue detected using Coccinelle (http://coccinelle.lip6.fr/)
>
> Signed-off-by: Julia Lawall 

Acked-by: James Hogan 

Thanks
James

>
> ---
>  drivers/irqchip/irq-metag-ext.c |1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/irqchip/irq-metag-ext.c b/drivers/irqchip/irq-metag-ext.c
> index 8c38b3d..0cdd923 100644
> --- a/drivers/irqchip/irq-metag-ext.c
> +++ b/drivers/irqchip/irq-metag-ext.c
> @@ -436,7 +436,6 @@ static int meta_intc_irq_set_type(struct irq_data *data, 
> unsigned int flow_type)
>
>  /**
>   * meta_intc_irq_demux() - external irq de-multiplexer
> - * @irq:   the virtual interrupt number
>   * @desc:  the interrupt description structure for this irq
>   *
>   * The cpu receives an interrupt on TR2 when a SoC interrupt has occurred. 
> It is
>


Re: [PATCH 14/15] irqchip/metag-ext: improve function-level documentation

2016-10-01 Thread James Hogan
Hi Julia,

On 1 October 2016 at 20:46, Julia Lawall  wrote:
> Drop the variable irq which ceased to be a parameter in bd0b9ac4.

I think 12 nibbles of the hash is recommended now due to collisions,
as is quoting the subject line, e.g. commit bd0b9ac405e1 ("genirq:
Remove irq argument from irq flow handlers").

>
> Issue detected using Coccinelle (http://coccinelle.lip6.fr/)
>
> Signed-off-by: Julia Lawall 

Acked-by: James Hogan 

Thanks
James

>
> ---
>  drivers/irqchip/irq-metag-ext.c |1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/irqchip/irq-metag-ext.c b/drivers/irqchip/irq-metag-ext.c
> index 8c38b3d..0cdd923 100644
> --- a/drivers/irqchip/irq-metag-ext.c
> +++ b/drivers/irqchip/irq-metag-ext.c
> @@ -436,7 +436,6 @@ static int meta_intc_irq_set_type(struct irq_data *data, 
> unsigned int flow_type)
>
>  /**
>   * meta_intc_irq_demux() - external irq de-multiplexer
> - * @irq:   the virtual interrupt number
>   * @desc:  the interrupt description structure for this irq
>   *
>   * The cpu receives an interrupt on TR2 when a SoC interrupt has occurred. 
> It is
>


Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Jes Sorensen
Joe Perches  writes:
> On Sat, 2016-10-01 at 14:53 -0400, Jes Sorensen wrote:
>> Joe Perches  writes:
>> > Make the init arrays const to reduce data.
>> > $ size drivers/net/wireless/realtek/rtl8xxxu/built-in.o*
>> > (allyesconfig: x86-32)
>> >    text   data bss dec hex filename
>> >   80107 13651 58 93816 16e78
>> > drivers/net/wireless/realtek/rtl8xxxu/built-in.o.new
>> >   65303 28435 58 93796 16e64
>> > drivers/net/wireless/realtek/rtl8xxxu/built-in.o.old
>> In total you grow the kernel by 20 bytes. You reduce the data segment
>> substantially while growing the text segment instead.
>
> No, not really.   The alignment boundaries move a bit for
> this particular compilation.  It could go the other way for
> a different compiler version or set of CONFIG options.
>
> What's important is multiple pages of .data move to .rodata.

Your output shows it moving to the text segment - if it's in a different
segment, eg. rodata, you should use output demonstrating that to justify
the change.

Jes


Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Jes Sorensen
Joe Perches  writes:
> On Sat, 2016-10-01 at 14:53 -0400, Jes Sorensen wrote:
>> Joe Perches  writes:
>> > Make the init arrays const to reduce data.
>> > $ size drivers/net/wireless/realtek/rtl8xxxu/built-in.o*
>> > (allyesconfig: x86-32)
>> >    text   data bss dec hex filename
>> >   80107 13651 58 93816 16e78
>> > drivers/net/wireless/realtek/rtl8xxxu/built-in.o.new
>> >   65303 28435 58 93796 16e64
>> > drivers/net/wireless/realtek/rtl8xxxu/built-in.o.old
>> In total you grow the kernel by 20 bytes. You reduce the data segment
>> substantially while growing the text segment instead.
>
> No, not really.   The alignment boundaries move a bit for
> this particular compilation.  It could go the other way for
> a different compiler version or set of CONFIG options.
>
> What's important is multiple pages of .data move to .rodata.

Your output shows it moving to the text segment - if it's in a different
segment, eg. rodata, you should use output demonstrating that to justify
the change.

Jes


Re:Humanitarian Services.

2016-10-01 Thread Mrs. Kimberly Hills
I am Mrs. Kimberly Hills the wife of late Engineer William Hills We has been 
married for years before his 

sudden death although we were childless. I have been diagnosed with cancer and 
I have been battling with the 

sickness when my late lovely husband was alive.

My Husband left the sum of US $3.800 million United States Dollars in a 
fix/suspense account in one of the 

prime bank  in Cote d'Ivoire. Recently, my Doctor told me that I would not 
exceed more than five more months 

due to cancer problem. The one that disturbs me most is my blood pressure 
sickness. Having known my condition 

I decided to seek for your kind assistance to transfer this fund into your 
account and you will use it to 

train my adopted daughter who is 16yrs. You will take her as your God child and 
brought her up in a good and 

decent manner with what my late husband left behind.

I will give you more details about me and how I inherited all as soon as I 
receive your reply because I do not 

want to state all here until I see your reply, desire and commitment. Please 
can you treat this as 

confidential and keep it as a secret for security reasons between both of us.

My Best Regards.

Mrs. Kimberly Hills


Re:Humanitarian Services.

2016-10-01 Thread Mrs. Kimberly Hills
I am Mrs. Kimberly Hills the wife of late Engineer William Hills We has been 
married for years before his 

sudden death although we were childless. I have been diagnosed with cancer and 
I have been battling with the 

sickness when my late lovely husband was alive.

My Husband left the sum of US $3.800 million United States Dollars in a 
fix/suspense account in one of the 

prime bank  in Cote d'Ivoire. Recently, my Doctor told me that I would not 
exceed more than five more months 

due to cancer problem. The one that disturbs me most is my blood pressure 
sickness. Having known my condition 

I decided to seek for your kind assistance to transfer this fund into your 
account and you will use it to 

train my adopted daughter who is 16yrs. You will take her as your God child and 
brought her up in a good and 

decent manner with what my late husband left behind.

I will give you more details about me and how I inherited all as soon as I 
receive your reply because I do not 

want to state all here until I see your reply, desire and commitment. Please 
can you treat this as 

confidential and keep it as a secret for security reasons between both of us.

My Best Regards.

Mrs. Kimberly Hills


Re: [PATCH 00/15] improve function-level documentation

2016-10-01 Thread Joe Perches
On Sat, 2016-10-01 at 21:46 +0200, Julia Lawall wrote:
> These patches fix cases where the documentation above a function definition
> is not consistent with the function header.  Issues are detected using the
> semantic patch below (http://coccinelle.lip6.fr/).  Basically, the semantic
> patch parses a file to find comments, then matches each function header,
> and checks that the name and parameter list in the function header are
> compatible with the comment that preceeds it most closely.

Hi Julia.

Would it be possible for a semantic patch to scan for
function definitions where the types do not have
identifiers and update the definitions to match the
declarations?

For instance, given:


int foo(int);


int foo(int bar)
{
return baz;
}

Could coccinelle output:

diff a/some.h b/some.h
[]
-int foo(int);
+int foo(int bar);


Re: [PATCH 00/15] improve function-level documentation

2016-10-01 Thread Joe Perches
On Sat, 2016-10-01 at 21:46 +0200, Julia Lawall wrote:
> These patches fix cases where the documentation above a function definition
> is not consistent with the function header.  Issues are detected using the
> semantic patch below (http://coccinelle.lip6.fr/).  Basically, the semantic
> patch parses a file to find comments, then matches each function header,
> and checks that the name and parameter list in the function header are
> compatible with the comment that preceeds it most closely.

Hi Julia.

Would it be possible for a semantic patch to scan for
function definitions where the types do not have
identifiers and update the definitions to match the
declarations?

For instance, given:


int foo(int);


int foo(int bar)
{
return baz;
}

Could coccinelle output:

diff a/some.h b/some.h
[]
-int foo(int);
+int foo(int bar);


  1   2   3   4   >