Re: [4.2.0-rc1-00201-g59c3cb5] Regression: kernel NULL pointer dereference

2015-07-12 Thread Maarten Lankhorst
Op 12-07-15 om 18:52 schreef Linus Torvalds:
> On Sun, Jul 12, 2015 at 1:03 AM, Jörg Otte  wrote:
>> BUG: unable to handle kernel NULL pointer dereference at 0009
>> IP: [] 0xbd3447bb
> Ugh. Please enable KALLSYMS to get sane symbols.
>
> But yes, "crtc_state->base.active" is at offset 9 from "crtc_state",
> so it's pretty clearly just that change frm
>
> -   if (intel_crtc->active) {
> +   if (crtc_state->base.active) {
>
> and "crtc_state" is NULL.
>
> And the code very much knows that crtc_state can be NULL, since it's
> initialized with
>
> crtc_state = state->base.state ?
> intel_atomic_get_crtc_state(state->base.state,
> intel_crtc) : NULL;
>
> Tssk. Daniel? Should I just revert that commit dec4f799d0a4
> ("drm/i915: Use crtc_state->active in primary check_plane func") for
> now, or is there a better fix? Like just checking crtc_state for NULL?
>
> Linus
More symbols would be nice.

With the transitional helpers when crtc_state == NULL you don't want to update 
the scalers or funny things happen.
Fix is probably something like this:

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index ba9321998a41..830e07b23a15 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13276,7 +13276,7 @@ intel_check_primary_plane(struct drm_plane *plane,
if (ret)
return ret;
 
-   if (crtc_state->base.active) {
+   if (crtc_state ? crtc_state->base.active || crtc->state->active) {
struct intel_plane_state *old_state =
to_intel_plane_state(plane->state);
 

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


[GIT] Networking

2015-07-12 Thread David Miller

1) Missing list head init in bluetooth hidp session creation, from
   Tedd Ho-Jeong An.

2) Don't leak SKB in bridge netfilter error paths, from Florian
   Westphal.

3) ipv6 netdevice private leak in netfilter bridging, fixed
   by Julien Grall.

4) Fix regression in IP over hamradio bpq encapsulation, from Ralf
   Baechle.

5) Fix race between rhashtable resize events and table walks, from
   Phil Sutter.

6) Missing validation of IFLA_VF_INFO netlink attributes, fix from
   Daniel Borkmann.

7) Missing security layer socket state initialization in tipc code,
   from Stephen Smalley.

8) Fix shared IRQ handling in boomerang 3c59x interrupt handler, from
   Denyx Vlasenko.

9) Missing minor_idr destroy on module unload on macvtap driver, from
   Johannes Thumshirn.

10) Various pktgen kernel thread races, from Oleg Nesterov.

11) Fix races that can cause packets to be processed in the backlog
even after a device attached to that SKB has been fully
unregistered.  From Julian Anastasov.

12) bcmgenet driver doesn't account packet drops vs. errors properly,
fix from Petri Gynther.

13) Array index validation and off by one fix in DSA layer from
Florian Fainelli.

Please pull, thanks a lot!

The following changes since commit a611fb75d0517fce65f588cde94f80bb4052c6b2:

  Merge tag 'module-misc-v4.1-rc8' of 
git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux (2015-07-02 11:07:27 
-0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 

for you to fetch changes up to cee9f6d0186a586c8023bc91c8a4cf8a088855e5:

  Merge tag 'linux-can-fixes-for-4.2-20150712' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can (2015-07-12 
22:24:01 -0700)


Andrew Lunn (1):
  net: fec: Ensure clocks are enabled while using mdio bus

Andy Gospodarek (1):
  ipv4: add support for linkdown sysctl to netconf

Angga (1):
  ipv6: Make MLD packets to only be processed locally

Bernhard Thaler (1):
  netfilter: bridge: fix CONFIG_NF_DEFRAG_IPV4/6 related warnings/errors

Daniel Borkmann (1):
  rtnetlink: verify IFLA_VF_INFO attributes before passing them to driver

Daniel Pieczko (3):
  sfc: refactor code in efx_ef10_set_mac_address()
  sfc: add legacy method for changing a PF's MAC address
  sfc: suppress handled MCDI failures when changing the MAC address

David S. Miller (7):
  Merge branch 'for-upstream' of 
git://git.kernel.org/.../bluetooth/bluetooth
  Merge branch 'sfc-set-mac'
  Merge git://git.kernel.org/.../pablo/nf
  Merge branch 'pktgen-races'
  Merge branch 'netdev_unregister_races'
  Merge branch 'dsa-of-parsing-fixes'
  Merge tag 'linux-can-fixes-for-4.2-20150712' of 
git://git.kernel.org/.../mkl/linux-can

Denys Vlasenko (1):
  3c59x: Fix shared IRQ handling

Enrico Mioso (2):
  cdc_ncm: Add support for moving NDP to end of NCM frame
  cdc_ncm: update specs URL

Eric Dumazet (3):
  net_sched: gen_estimator: extend pps limit
  net: graceful exit from netif_alloc_netdev_queues()
  bridge: fix potential crash in __netdev_pick_tx()

Eric W. Biederman (1):
  netfilter: nf_queue: Don't recompute the hook_list head

Florian Fainelli (2):
  net: dsa: Test array index before use
  net: dsa: Fix off-by-one in switch address parsing

Florian Westphal (2):
  netfilter: arptables: use percpu jumpstack
  netfilter: bridge: don't leak skb in error paths

Govindarajulu Varadarajan (1):
  enic: fix issues in enic_poll

Hariprasad Shenai (1):
  cxgb4: Fix incorrect sequence numbers shown in devlog

J.D. Schroeder (1):
  can: c_can: Fix default pinmux glitch at init

Johannes Thumshirn (1):
  macvtap: Destroy minor_idr on module_exit

Julian Anastasov (2):
  net: do not process device backlog during unregistration
  net: call rcu_read_lock early in process_backlog

Julien Grall (1):
  netfilter: bridge: Use __in6_dev_get rather than in6_dev_get in 
br_validate_ipv6

Krzysztof Kozlowski (1):
  net: axienet: Fix devm_ioremap_resource return value check

Lendacky, Thomas (1):
  amd-xgbe: Fix DMA API debug warning

Markus Elfring (3):
  net-ipv6: Delete an unnecessary check before the function call 
"free_percpu"
  net-RDS: Delete an unnecessary check before the function call "module_put"
  netlink: Delete an unnecessary check before the function call "module_put"

Masanari Iida (1):
  Doc: z8530book: Fix typo in API-z8530-sync-txdma-open.html

Mazhar Rana (1):
  bonding: "primary_reselect" with "failure" is not working properly

Mugunthan V N (2):
  drivers: net: cpsw: fix crash while accessing second slave ethernet 
interface
  drivers: net: cpsw: fix disabling of tx interrupt in rx isr

Neil Horman (1):
  vmxnet3: prevent receive getting out of sequence on napi poll

Nicol

Re: [PATCH 28/39] bpf tools: Load a program with different instances using preprocessor

2015-07-12 Thread Wangnan (F)



On 2015/7/9 20:35, Wang Nan wrote:

In this patch, caller of libbpf is able to control the loaded programs
by installing a preprocessor callback for a BPF program. With
preprocessor, different instances can be created from one BPF program.

This patch will be used by perf to generate different prologue for
different 'struct probe_trace_event' instances matched by one
'struct perf_probe_event'.

bpf_program__set_prep() is added to support this feature. Caller
should pass libbpf the number of instances should be created and a
preprocessor function which will be called when doing real loading.
The callback should return instructions arrays for each instances.

fd field in bpf_programs is replaced by instance, which has an nr field
and fds array. bpf_program__nth_fd() is introduced for read fd of
instances. Old interface bpf_program__fd() is reimplemented by
returning the first fd.

Signed-off-by: Wang Nan 
Signed-off-by: He Kuang 
---
  tools/lib/bpf/libbpf.c | 138 +
  tools/lib/bpf/libbpf.h |  22 
  2 files changed, 151 insertions(+), 9 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b37aab1..6fcd042 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -98,7 +98,11 @@ struct bpf_program {
} *reloc_desc;
int nr_reloc;
  
-	int fd;

+   struct {
+   int nr;
+   int *fds;
+   } instance;
+   bpf_program_prep_t preprocessor;
  
  	struct bpf_object *obj;

void *priv;
@@ -152,10 +156,19 @@ struct bpf_object {
  
  static void bpf_program__unload(struct bpf_program *prog)

  {
+   int i;
+
if (!prog)
return;
  
-	zclose(prog->fd);

+   if (prog->instance.nr < 0)
+   pr_warning("Internal error when unloading: instance is %d\n",
+  prog->instance.nr);
+   else
+   for (i = 0; i < prog->instance.nr; i++)
+   zclose(prog->instance.fds[i]);
+   prog->instance.nr = -1;
+   zfree(>instance.fds);
  }
  
  static void bpf_program__clear(struct bpf_program *prog)

@@ -206,7 +219,8 @@ __bpf_program__new(void *data, size_t size, char *name, int 
idx,
memcpy(prog->insns, data,
   prog->insns_cnt * sizeof(struct bpf_insn));
prog->idx = idx;
-   prog->fd = -1;
+   prog->instance.fds = NULL;
+   prog->instance.nr = -1;
  
  	return 0;

  errout:
@@ -798,13 +812,71 @@ static int
  bpf_program__load(struct bpf_program *prog,
  char *license, u32 kern_version)
  {
-   int err, fd;
+   int err = 0, fd, i;
+
+   if (prog->instance.nr < 0 || !prog->instance.fds) {
+   if (prog->preprocessor) {
+   pr_warning("Internal error: can't load program '%s'\n",
+  prog->section_name);
+   return -EINVAL;
+   }
  
-	err = load_program(prog->insns, prog->insns_cnt,

-  license, kern_version, );
-   if (!err)
-   prog->fd = fd;
+   prog->instance.fds = malloc(sizeof(int));
+   if (prog->instance.fds) {


I lost a '!' here. Should be:

+ if (!prog->instance.fds) {
...

My github tree has updated. Please check:

  https://github.com/WangNan0/linux.git perf/ebpf-for-acme



+   pr_warning("No enough memory for fds\n");
+   return -ENOMEM;
+   }
+   prog->instance.nr = 1;
+   prog->instance.fds[0] = -1;
+   }
+
+   if (!prog->preprocessor) {
+   if (prog->instance.nr != 1)
+   pr_warning("Program '%s' inconsistent: nr(%d) not 1\n",
+  prog->section_name, prog->instance.nr);
+
+   err = load_program(prog->insns, prog->insns_cnt,
+  license, kern_version, );
+   if (!err)
+   prog->instance.fds[0] = fd;
+   goto out;
+   }
+
+   for (i = 0; i < prog->instance.nr; i++) {
+   struct bpf_prog_prep_result result;
+   bpf_program_prep_t preprocessor = prog->preprocessor;
+
+   bzero(, sizeof(result));
+   err = preprocessor(prog, i, prog->insns,
+  prog->insns_cnt, );
+   if (err) {
+   pr_warning("Preprocessing %dth instance of program '%s' 
failed\n",
+   i, prog->section_name);
+   goto out;
+   }
+
+   if (!result.new_insn_ptr || !result.new_insn_cnt) {
+   pr_debug("Skip loading %dth instance of program '%s'\n",
+   i, prog->section_name);
+   prog->instance.fds[i] = -1;
+   continue;
+   }
+
+   err = 

Re: [PATCH v3 0/3] Fixes for MT8173 PLLs

2015-07-12 Thread Sascha Hauer
On Fri, Jul 10, 2015 at 04:39:31PM +0800, James Liao wrote:
> Title changed. Previous title is "Add MT8173 MMPLL change rate support"
> and can be found in [1].
> 
> This patchset contains some fixes for changing rate of PLLs, especially
> for MMPLL.
> 
> The first 2 patches are common fixes for PLLs, and the last patch is a
> fix to support MT8173 MMPLL changing rate because its frequency setting
> is different from other PLLs.
> 
> changes since v2:
> - Rebase to 4.2-rc1.
> - Split fixes of PLL setting calculation to a separeted patch.
> 
> changes since v1:
> - Add a separated patch for mtk_pll_set_rate_regs().
> - Use a structure array to describe a div_table.
> - Limit max frequency to div_table[0].
> - Minor changes such as static and comments.
> 
> [1] https://lkml.org/lkml/2015/7/8/265
> 
> James Liao (3):
>   clk: mediatek: Fix PLL registers setting flow
>   clk: mediatek: Fix calculation of PLL rate settings
>   clk: mediatek: Add MT8173 MMPLL change rate support

Acked-by: Sascha Hauer 

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC 3/3] arm64: ftrace: mcount() should not create a stack frame

2015-07-12 Thread AKASHI Takahiro
Ftrace's stack tracer on arm64 returns wrong information about call stacks:

DepthSize   Location(50 entries)
-   
  0) 5256   0   notifier_call_chain+0x30/0x94
  1) 5256   0   ftrace_call+0x0/0x4
  2) 5256   0   notifier_call_chain+0x2c/0x94
  3) 5256   0   raw_notifier_call_chain+0x34/0x44
  4) 5256   0   timekeeping_update.constprop.9+0xb8/0x114
  5) 5256   0   update_wall_time+0x408/0x6dc

The instrumented function, notifier_call_chain(), appears twice.

On x86 (and other arch's), mcount (or ftrace_call) does not create a new
stack frame. This will eventually result in not listing the instrumented
function in save_stack_call() because the function's returned address does
not appear as saved lr in the stack. Stack tracer, instead, explicitly adds
this skipped function at the top of the list later in check_stack().
That is why it is listed twice on arm64 as shown above.

This patch modifies arm64 function tracer not to create a stack frame at
mcount() in order to fix this issue.

Signed-off-by: AKASHI Takahiro 
---
 arch/arm64/kernel/entry-ftrace.S |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/kernel/entry-ftrace.S b/arch/arm64/kernel/entry-ftrace.S
index 08cafc5..c74fa12 100644
--- a/arch/arm64/kernel/entry-ftrace.S
+++ b/arch/arm64/kernel/entry-ftrace.S
@@ -26,9 +26,11 @@
  * as long as the kernel is compiled without -fomit-frame-pointer.
  * (or CONFIG_FRAME_POINTER, this is forced on arm64)
  *
+ * We don't update a frame pointer here as ftrace, in special stack tracer,
+ * assumes not. If we did, the instrumented function would be listed twice.
  * stack layout after mcount_enter in _mcount():
  *
- * current sp/fp =>  0:+-+
+ * current sp=>  0:+-+
  * in _mcount()| x29 | -> instrumented function's fp
  * +-+
  * | x30 | -> _mcount()'s lr (= instrumented function's pc)
@@ -47,7 +49,6 @@
 
.macro mcount_enter
stp x29, x30, [sp, #-16]!
-   mov x29, sp
.endm
 
.macro mcount_exit
@@ -61,7 +62,7 @@
 
/* for instrumented function's parent */
.macro mcount_get_parent_fp reg
-   ldr \reg, [x29]
+   ldr \reg, [sp]
ldr \reg, [\reg]
.endm
 
@@ -71,18 +72,18 @@
.endm
 
.macro mcount_get_pc reg
-   ldr \reg, [x29, #8]
+   ldr \reg, [sp, #8]
mcount_adjust_addr  \reg, \reg
.endm
 
.macro mcount_get_lr reg
-   ldr \reg, [x29]
+   ldr \reg, [sp]
ldr \reg, [\reg, #8]
mcount_adjust_addr  \reg, \reg
.endm
 
.macro mcount_get_lr_addr reg
-   ldr \reg, [x29]
+   ldr \reg, [sp]
add \reg, \reg, #8
.endm
 
@@ -205,7 +206,7 @@ ENDPROC(ftrace_graph_caller)
  */
 ENTRY(return_to_handler)
str x0, [sp, #-16]!
-   mov x0, x29 // parent's fp
+   mov x0, sp  // parent's fp
bl  ftrace_return_to_handler// addr = ftrace_return_to_hander(fp);
mov x30, x0 // restore the original return address
ldr x0, [sp], #16
-- 
1.7.9.5

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


[RFC 0/3] arm64: ftrace: fix incorrect output from stack tracer

2015-07-12 Thread AKASHI Takahiro
As reported in the thread below[1], the output from stack tracer using
ftrace on arm64 seems to be incorrect due to different reasons. Each
problem is described and fixed repsectively in the following patches.
Please see the commit messages for the details.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/354126.html

If the patch[1/3], which adds "#ifdef CONFIG_ARM64" to generic ftrace code,
is not acceptable, we will have to introduce an arch-dependent function,
ie. arch_check_stack().

Even with those patches, we see another issue that the values in 'Size'
field are *inaccurate*. This is simply because we have no way to estimate
the value of stack pointer at each function from the content of stack.
Thus the function's reported stack size does not include its own local
variables, but includes *its child's* ones.
See more details below.

In my opinion, we cannot fix this issue unless analyzing the function's
first instruction, ie. "stp x29, x30, [sp, #xx]!".

* How does stack tracer identify each function's stack size?

Take an example, func-0 calls func-1 and func-1 calls func-2.
The stack layout looks like the below:
("p" is a temp variable in check_stack().)

sp2 +---+ <- func-2's stackframe
|   |
|   |
fp2 +---+
|  fp1  |
+---+ <-- p1 (*p1 == stack_dump_trace[i] == lr1)
|  lr1  |
+---+
|   |
|  func-2's local variables
|   |
sp1 +---+ <- func-1(lr1)'s stackframe
|   | (stack_dump_index[i] = top - p1)
|  func-1's dynamic local variables
|   |
fp1 +---+
|  fp0  |
+---+ <-- p0 (*p0 == stack_dump_trace[i+1] == lr0)
|  lr0  |
+---+
|   |
|  func-1's local variables
|   |
sp0 +---+ <- func-0(lr0)'s stackframe
|   | (stack_dump_index[i+1] = top - p0)
|   |
*---+ top

Stack tracer records the stack height of func-1 (== stack_dump_trace[i]):
stack_dump_index[i] =  - 
in check_stack() by searching for func-1's return address (lr1)
and eventually calculates func-1's stack size by:
stack_dump_index[i] - stack_dump_index[i+1]
=> (top - p1) - (top - p0)
=> p1 - p0

On x86, this calculation is correct because x86's call instruction pushes
the return address to the stack and jump into the child(func-2) function,
thus the func-1's stack pointer is "p1" where *p1 is equal to
stack_dump_trace[i]. But this is not true on arm64.

AKASHI Takahiro (3):
  ftrace: adjust a function's pc to search for in check_stack() for
arm64
  arm64: refactor save_stack_trace()
  arm64: ftrace: mcount() should not create a stack frame

 arch/arm64/kernel/entry-ftrace.S |   15 ---
 arch/arm64/kernel/stacktrace.c   |   31 +++
 kernel/trace/trace_stack.c   |4 
 3 files changed, 35 insertions(+), 15 deletions(-)

-- 
1.7.9.5

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


[RFC 2/3] arm64: refactor save_stack_trace()

2015-07-12 Thread AKASHI Takahiro
Ftrace's stack tracer on arm64 returns wrong information about call stacks:

DepthSize   Location(50 entries)
-   
  0) 5256   0   notifier_call_chain+0x30/0x94
  1) 5256   0   ftrace_call+0x0/0x4
  2) 5256   0   notifier_call_chain+0x2c/0x94
  3) 5256   0   raw_notifier_call_chain+0x34/0x44
  4) 5256   0   timekeeping_update.constprop.9+0xb8/0x114
  5) 5256   0   update_wall_time+0x408/0x6dc

One of tracer functions, ftrace_call (or mcount), is unexpectedly listed.
The *bare* stack dump returned by save_stack_trace() is:
save_stack_trace_tsk()
save_stack_trace()
stack_trace_call()
ftrace_ops_no_ops()
ftrace_call()
notifier_call_chain()
raw_notifier_call_chain()
...

On arm64, save_stack_trace() calls save_stack_trace_tsk() and this will
result in putting additional stack frame in the returned list.
This behavior, however, conflicts with  stack stracer's assumption
that the number of functions to be skiped as part of tracer is 4, from
save_stack_trace() to mcount(), if ftrace_ops_list_func() is used.
The value is hard coded in check_patch().

This patch refactors save_stack_trace() and save_stack_trace_tsk() in order
to reduce the stack depth by making the common code inlined.

Signed-off-by: AKASHI Takahiro 
---
 arch/arm64/kernel/stacktrace.c |   31 +++
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index 407991b..978c923 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -97,34 +97,49 @@ static int save_trace(struct stackframe *frame, void *d)
return trace->nr_entries >= trace->max_entries;
 }
 
-void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
+static inline void __save_stack_trace(struct stackframe *frame,
+   struct stack_trace *trace, int no_sched)
 {
struct stack_trace_data data;
-   struct stackframe frame;
 
data.trace = trace;
data.skip = trace->skip;
+   data.no_sched_functions = no_sched;
+
+   walk_stackframe(frame, save_trace, );
+   if (trace->nr_entries < trace->max_entries)
+   trace->entries[trace->nr_entries++] = ULONG_MAX;
+}
+
+void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
+{
+   struct stackframe frame;
+   int no_sched;
 
if (tsk != current) {
-   data.no_sched_functions = 1;
+   no_sched = 1;
frame.fp = thread_saved_fp(tsk);
frame.sp = thread_saved_sp(tsk);
frame.pc = thread_saved_pc(tsk);
} else {
-   data.no_sched_functions = 0;
+   no_sched = 0;
frame.fp = (unsigned long)__builtin_frame_address(0);
frame.sp = current_stack_pointer;
frame.pc = (unsigned long)save_stack_trace_tsk;
}
 
-   walk_stackframe(, save_trace, );
-   if (trace->nr_entries < trace->max_entries)
-   trace->entries[trace->nr_entries++] = ULONG_MAX;
+   __save_stack_trace(, trace, no_sched);
 }
 
 void save_stack_trace(struct stack_trace *trace)
 {
-   save_stack_trace_tsk(current, trace);
+   struct stackframe frame;
+
+   frame.fp = (unsigned long)__builtin_frame_address(0);
+   frame.sp = current_stack_pointer;
+   frame.pc = (unsigned long)save_stack_trace_tsk;
+
+   __save_stack_trace(, trace, 0);
 }
 EXPORT_SYMBOL_GPL(save_stack_trace);
 #endif
-- 
1.7.9.5

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


[RFC 1/3] ftrace: adjust a function's pc to search for in check_stack() for arm64

2015-07-12 Thread AKASHI Takahiro
Ftace's stack tracer on arm64 returns wrong information about call stacks:

DepthSize   Location(50 entries)
-   
  0) 5256   0   notifier_call_chain+0x30/0x94
  1) 5256   0   ftrace_call+0x0/0x4
  2) 5256   0   notifier_call_chain+0x2c/0x94
  3) 5256   0   raw_notifier_call_chain+0x34/0x44
  4) 5256   0   timekeeping_update.constprop.9+0xb8/0x114
  5) 5256   0   update_wall_time+0x408/0x6dc

Most of 'Size' fields are unexpectedly zero.

This is because stack tracer fails to recognize each function's stack frame
in check_stack(). Stack tracer searches for a function's pc in the stack
based on the list returned by save_stack_trace(), but save_stack_trace() on
arm64 does not return the exact return address saved in a stack frame, but
a value decrmented by 4 (which means a branch instruction's address).
This behavior was introduced by
commit e306dfd06fcb ("ARM64: unwind: Fix PC calculation")

So the matching doesn't succeed in most cases.

This problem can be fixed either by
a) reverting the commit above
b) adding an arm64-specific hack to check_patch()

This patch does b).

Signed-off-by: AKASHI Takahiro 
---
 kernel/trace/trace_stack.c |4 
 1 file changed, 4 insertions(+)

diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 3f34496..7086fc3 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -143,7 +143,11 @@ check_stack(unsigned long ip, unsigned long *stack)
p = start;
 
for (; p < top && i < max_stack_trace.nr_entries; p++) {
+#ifdef CONFIG_ARM64
+   if (*p == (stack_dump_trace[i] + 4)) {
+#else
if (*p == stack_dump_trace[i]) {
+#endif
this_size = stack_dump_index[i++] =
(top - p) * sizeof(unsigned long);
found = 1;
-- 
1.7.9.5

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


Re: [PATCH v5 00/11] simplify block layer based on immutable biovecs

2015-07-12 Thread Ming Lin
On Mon, 2015-07-06 at 00:11 -0700, m...@kernel.org wrote:
> Hi Mike,
> 
> On Wed, 2015-06-10 at 17:46 -0400, Mike Snitzer wrote:
> > I've been busy getting DM changes for the 4.2 merge window finalized.
> > As such I haven't connected with others on the team to discuss this
> > issue.
> > 
> > I'll see if we can make time in the next 2 days.  But I also have
> > RHEL-specific kernel deadlines I'm coming up against.
> > 
> > Seems late to be staging this extensive a change for 4.2... are you
> > pushing for this code to land in the 4.2 merge window?  Or do we have
> > time to work this further and target the 4.3 merge?
> > 
> 
> 4.2-rc1 was out.
> Would you have time to work together for 4.3 merge? 

Ping ...

What can I do to move forward?

This patchset not only simplify block layer a lot, it's also a
prerequisite of the direct IO rewrite patches, which I saw 40%
performance improvement for null_blk and 10% improvement for NVMe
drives. I have been fixing bugs for the direct IO patches. I'll post it
once it passes xfstests.

Mike,
Can I have your ACK? Or do you have other test plan?

Thanks,
Ming

> 
> Fio test results(4.1-rc4/rc7) showed no performance regressions
> for HW/SW RAID6 and DM stripe tests.
> http://minggr.net/pub/20150608/fio_results/summary.log
> 
> v5:
>   - rebase on top of 4.2-rc1
>   - reorder patch 6,7
>   - add NeilBrown's ACKs
>   - fix memory leak: free "bio_split" bioset in blk_release_queue()
> 
> v4:
>   - rebase on top of 4.1-rc4
>   - use BIO_POOL_SIZE instead of number 4 for bioset_create()
>   - call blk_queue_split() in blk_mq_make_request()
>   - call blk_queue_split() in zram_make_request()
>   - add patch "block: remove bio_get_nr_vecs()"
>   - remove split code in blkdev_issue_discard()
>   - drop patch "md/raid10: make sync_request_write() call bio_copy_data()".
> NeilBrown queued it.
>   - drop patch "block: allow __blk_queue_bounce() to handle bios larger than 
> BIO_MAX_PAGES".
> Will send it seperately
> 
> v3:
>   - rebase on top of 4.1-rc2
>   - support for QUEUE_FLAG_SG_GAPS
>   - update commit logs of patch 2&4
>   - split bio for chunk_aligned_read
> 
> v2: https://lkml.org/lkml/2015/4/28/28
> v1: https://lkml.org/lkml/2014/12/22/128
> 
> This is the 5th attempt of simplifying block layer based on immutable
> biovecs. Immutable biovecs, implemented by Kent Overstreet, have been
> available in mainline since v3.14. Its original goal was actually making
> generic_make_request() accept arbitrarily sized bios, and pushing the
> splitting down to the drivers or wherever it's required. See also
> discussions in the past, [1] [2] [3].
> 
> This will bring not only performance improvements, but also a great amount
> of reduction in code complexity all over the block layer. Performance gain
> is possible due to the fact that bio_add_page() does not have to check
> unnecesary conditions such as queue limits or if biovecs are mergeable.
> Those will be delegated to the driver level. Kent already said that he
> actually benchmarked the impact of this with fio on a micron p320h, which
> showed definitely a positive impact.
> 
> Moreover, this patchset also allows a lot of code to be deleted, mainly
> because of removal of merge_bvec_fn() callbacks. We have been aware that
> it has been always a delicate issue for stacking block drivers (e.g. md
> and bcache) to handle merging bio consistently. This simplication will
> help every individual block driver avoid having such an issue.
> 
> Patches are against 4.2-rc1. These are also available in my git repo at:
> 
>   
> https://git.kernel.org/cgit/linux/kernel/git/mlin/linux.git/log/?h=block-generic-req
>   git://git.kernel.org/pub/scm/linux/kernel/git/mlin/linux.git 
> block-generic-req
> 
> This patchset is a prerequisite of other consecutive patchsets, e.g.
> multipage biovecs, rewriting plugging, or rewriting direct-IO, which are
> excluded this time. That means, this patchset should not bring any
> regression to end-users.
> 
> Comments are welcome.
> Ming
> 
> [1] https://lkml.org/lkml/2014/11/23/263
> [2] https://lkml.org/lkml/2013/11/25/732
> [3] https://lkml.org/lkml/2014/2/26/618
> 
> Dongsu Park (1):
>   Documentation: update notes in biovecs about arbitrarily sized bios
> 
> Kent Overstreet (8):
>   block: make generic_make_request handle arbitrarily sized bios
>   block: simplify bio_add_page()
>   bcache: remove driver private bio splitting code
>   btrfs: remove bio splitting and merge_bvec_fn() calls
>   md/raid5: get rid of bio_fits_rdev()
>   block: kill merge_bvec_fn() completely
>   fs: use helper bio_add_page() instead of open coding on bi_io_vec
>   block: remove bio_get_nr_vecs()
> 
> Ming Lin (2):
>   block: remove split code in blkdev_issue_discard
>   md/raid5: split bio for chunk_aligned_read
> 
>  Documentation/block/biovecs.txt |  10 +-
>  block/bio.c | 152 
> ++--
>  

Re: [RFC v2 PATCH 0/8] mm: mirrored memory support for page buddy allocations

2015-07-12 Thread Xishi Qiu
On 2015/6/30 19:53, Mel Gorman wrote:

> On Tue, Jun 30, 2015 at 12:46:54PM +0200, Ingo Molnar wrote:
>>
>> * Mel Gorman  wrote:
>>
>>> [...]
>>>
>>> Basically, overall I feel this series is the wrong approach but not knowing 
>>> who 
>>> the users are making is much harder to judge. I strongly suspect that if 
>>> mirrored memory is to be properly used then it needs to be available before 
>>> the 
>>> page allocator is even active. Once active, there needs to be controlled 
>>> access 
>>> for allocation requests that are really critical to mirror and not just all 
>>> kernel allocations. None of that would use a MIGRATE_TYPE approach. It 
>>> would be 
>>> alterations to the bootmem allocator and access to an explicit reserve that 
>>> is 
>>> not accounted for as "free memory" and accessed via an explicit GFP flag.
>>
>> So I think the main goal is to avoid kernel crashes when a #MC memory fault 
>> arrives on a piece of memory that is owned by the kernel.
>>
> 
> Sounds logical. In that case, bootmem awareness would be crucial.
> Enabling support in just the page allocator is too late.
> 
>> In that sense 'protecting' all kernel allocations is natural: we don't know 
>> how to 
>> recover from faults that affect kernel memory.
>>
> 
> It potentially uses all mirrored memory on memory that does not need that
> sort of guarantee. For example, if there was a MC on memory backing the
> inode cache then potentially that is recoverable as long as the inodes
> were not dirty. That's a minor detail as the kernel could later protect
> only MIGRATE_UNMOVABLE requests instead of all kernel allocations if fatal
> MC in kernel space could be distinguished from non-fatal checks.
> 
> Bootmem awareness is much more important either way. If that was addressed
> then potentially a MIGRATE_UNMOVABLE_MIRROR type could be created that
> is only used for MIGRATE_UNMOVABLE allocations and never for user-space.
> That misses MIGRATE_RECLAIMABLE so if that is required then we need
> something else that both preserves fragmentation avoidance and avoid
> introducing loads of new migratetypes.
> 
> Reclaim-related issues could be partially avoided by forbidding use from
> userspace and accounting for the size of MIGRATE_UNMOVABLE_MIRROR during
> watermark checks.
> 
>> We do know how to recover from faults that affect user-space memory alone.
>>
>> So if a mechanism is in place that prioritizes 3 groups of allocators:
>>
>>   - non-recoverable memory (kernel allocations mostly)
>>
> 
> So bootmem at the very least followed by MIGRATE_UNMOVABLE requests whether
> they are accounted for by zones of MIGRATE_TYPES.
> 
>>   - high priority user memory (critical apps that must never fail)
>>
> 
> This one is problematic with a MIGRATE_TYPE-based approach such as the one in
> this series. If a high priority requires memory and MIGRATE_MIRROR is full
> then some of it must be reclaimed. With a MIGRATE_TYPE approach, the kernel
> may reclaim a lot of unnecessary memory trying to free some MIGRATE_MIRROR
> memory with no guarantee of success. It'll look like unnecessary thrashing
> from userspace but difficult to diagnose as reclaim stats are per-zone based.
> Dealing with this needs either a zone-based approach or a lot of surgery
> to reclaim (similar to what the node-based LRU series does actually when
> it skips pages when the caller requires lowmem pages).
> 

Hi Mel,

Thank you for your comment. Sorry for replying late and some of it is not
very understanding for me.

If fatal memory faults in kernel space could be distinguished from non-fatal,
we can use only MIGRATE_UNMOVABLE_MIRROR, if can't, use two types for
MIGRATE_RECLAIMABLE and MIGRATE_UNMOVABLE, right?

Reclaim-related issues is similar to CMA in zone_watermark_ok(), right?

If we protect high priority user memory, use a new mirrored zone may be
better, right?

How about use a flag(e.g. GFP_MIRROR) to in kernel space allocation?
Can we use it to sort kernel space allocation? And it can also called by 
user space via madvise and mmap.

Thanks,
Xishi Qiu


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


Re: [PATCH 2/4] dt-bindings: soc: Add documentation for the MediaTek SCPSYS unit

2015-07-12 Thread Daniel Kurtz
On Wed, Jun 24, 2015 at 2:17 PM, Sascha Hauer  wrote:
> This adds documentation for the MediaTek SCPSYS unit found in MT8173 SoCs.
>
> Signed-off-by: Sascha Hauer 
> ---
>  .../devicetree/bindings/soc/mediatek/scpsys.txt| 41 
> ++
>  1 file changed, 41 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
>
> diff --git a/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt 
> b/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
> new file mode 100644
> index 000..c051114
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
> @@ -0,0 +1,41 @@
> +MediaTek SCPSYS
> +===
> +
> +The System Control Processor System (SCPSYS) has several power management
> +related tasks in the system. The tasks include thermal measurement, dynamic
> +voltage frequency scaling (DVFS), interrupt filter and lowlevel sleep 
> control.
> +The System Power Manager (SPM) inside the SCPSYS is for the MTCMOS power
> +domain control.
> +
> +The driver implements the Generic PM domain bindings described in
> +power/power_domain.txt. It provides the power domains defined in
> +include/dt-bindings/power/mt8173-power.h.
> +
> +Required properties:
> +- compatible: Must be "mediatek,mt8173-scpsys"
> +- #power-domain-cells: Must be 1
> +- reg: Address range of the SCPSYS unit
> +- infracfg: must contain a phandle to the infracfg controller
> +- clock, clock-names: clocks according to the common clock binding.
> +  The clocks needed "mm" and "mfg". These are the
> + clocks which hardware needs to be enabled before
> + enabling certain power domains.
> +
> +Example:
> +
> +   scpsys: scpsys@10006000 {

Perhaps it is too late, and/or too pedantic, but, since this node
defines a PM domain provider as defined in [0], shouldn't its node
have been the more generic:

  scpsys: power-controller@10006000

[0] /Documentation/devicetree/bindings/power/power_domain.txt

> +   #power-domain-cells = <1>;
> +   compatible = "mediatek,mt8173-scpsys";
> +   reg = <0 0x10006000 0 0x1000>;
> +   infracfg = <>;
> +   clocks = <>,
> +< CLK_TOP_MM_SEL>;
> +   clock-names = "mfg", "mm";
> +   };
> +
> +Example consumer:
> +
> +   afe: mt8173-afe-pcm@1122 {
> +   compatible = "mediatek,mt8173-afe-pcm";
> +   power-domains = < MT8173_POWER_DOMAIN_AUDIO>;
> +   };
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/7] tty: core: Add tty_debug() for printk(KERN_DEBUG) messages

2015-07-12 Thread Peter Hurley
On 07/13/2015 12:30 AM, Joe Perches wrote:
> On Mon, 2015-07-13 at 00:25 -0400, Peter Hurley wrote:
>> On 07/12/2015 11:47 PM, Joe Perches wrote:
>>> On Sun, 2015-07-12 at 22:49 -0400, Peter Hurley wrote:
 Introduce tty_debug() macro to output uniform debug information for
 tty core debug messages (function name and tty name).
>>> []
 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
>>> []
 @@ -768,7 +768,7 @@ static void do_tty_hangup(struct work_struct *work)
  void tty_hangup(struct tty_struct *tty)
  {
  #ifdef TTY_DEBUG_HANGUP
 -  printk(KERN_DEBUG "%s hangup...\n", tty_name(tty));
 +  tty_debug(tty, "\n");
>>>
>>> Why drop the "hangup..." ?
>>
>> tty_debug() prints the function name; in this case, tty_hangup().
> 
> maybe that #ifdef/#endif block could/should be removed

The #ifdef/#endif block is removed in the follow-on patch 3/7;
replaced with tty_debug_hangup().

> and the function tracer used to track this instead.

One of the advantages of the single macro site of tty_debug is that
I can blow in trace_printk() instead when necessary. But still leave
mainline as printk's.

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


Re: [RFC PATCH v4 3/3] bpf: Introduce function for outputing data to perf event

2015-07-12 Thread He Kuang

hi, Alexei

On 2015/7/11 6:10, Alexei Starovoitov wrote:

On 7/10/15 3:03 AM, He Kuang wrote:

There're scenarios that we need an eBPF program to record not only
kprobe point args, but also the PMU counters, time latencies or the
number of cache misses between two probe points and other information
when the probe point is entered.

This patch adds a new trace event to establish infrastruction for bpf to
output data to perf. Userspace perf tools can detect and use this event
as using the existing tracepoint events.

New bpf trace event entry in debugfs:

  /sys/kernel/debug/tracing/events/bpf/bpf_output_data

Userspace perf tools detect the new tracepoint event as:

  bpf:bpf_output_data  [Tracepoint event]


Nice! This approach looks cleanest so far.


+TRACE_EVENT(bpf_output_data,
+
+TP_PROTO(u64 *src, int len),
+
+TP_ARGS(src, len),
+
+TP_STRUCT__entry(
+__dynamic_array(u64,buf,len)
+),
+
+TP_fast_assign(
+memcpy(__get_dynamic_array(buf), src, len * sizeof(u64));


may be make it 'u8' array? The extra multiply and...


OK

So the output of three u64 integers (e.g. 0x2060572485, 0x20667b0ff2,
0x623eb6d) will be this:

  dd 994 [000] 139.158180: bpf:bpf_output_data: 85 24 57 60 20 00 00 00
  f2 0f 7b 66 20 00 00 00 6d eb 23 06 00 00 00 00

And users are not restricted to u64 type elements. I'll change that.




+static u64 bpf_output_trace_data(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
+{
+void *src = (void *) (long) r1;
+int size = (int) r2;
+
+trace_bpf_output_data(src, size / sizeof(u64));


.. and this silent round down could be confusing to use.
With array of u8, the program can push any structured data into it
and let user space interpret it.




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


Re: [PATCH 2/7] tty: core: Add tty_debug() for printk(KERN_DEBUG) messages

2015-07-12 Thread Joe Perches
On Mon, 2015-07-13 at 00:25 -0400, Peter Hurley wrote:
> On 07/12/2015 11:47 PM, Joe Perches wrote:
> > On Sun, 2015-07-12 at 22:49 -0400, Peter Hurley wrote:
> >> Introduce tty_debug() macro to output uniform debug information for
> >> tty core debug messages (function name and tty name).
> > []
> >> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> > []
> >> @@ -768,7 +768,7 @@ static void do_tty_hangup(struct work_struct *work)
> >>  void tty_hangup(struct tty_struct *tty)
> >>  {
> >>  #ifdef TTY_DEBUG_HANGUP
> >> -  printk(KERN_DEBUG "%s hangup...\n", tty_name(tty));
> >> +  tty_debug(tty, "\n");
> > 
> > Why drop the "hangup..." ?
> 
> tty_debug() prints the function name; in this case, tty_hangup().

maybe that #ifdef/#endif block could/should be removed
and the function tracer used to track this instead.

cheers, Joe

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


Re: [PATCH 2/7] tty: core: Add tty_debug() for printk(KERN_DEBUG) messages

2015-07-12 Thread Peter Hurley
On 07/12/2015 11:47 PM, Joe Perches wrote:
> On Sun, 2015-07-12 at 22:49 -0400, Peter Hurley wrote:
>> Introduce tty_debug() macro to output uniform debug information for
>> tty core debug messages (function name and tty name).
> []
>> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> []
>> @@ -768,7 +768,7 @@ static void do_tty_hangup(struct work_struct *work)
>>  void tty_hangup(struct tty_struct *tty)
>>  {
>>  #ifdef TTY_DEBUG_HANGUP
>> -printk(KERN_DEBUG "%s hangup...\n", tty_name(tty));
>> +tty_debug(tty, "\n");
> 
> Why drop the "hangup..." ?

tty_debug() prints the function name; in this case, tty_hangup().


>> diff --git a/include/linux/tty.h b/include/linux/tty.h
> []
>> +#define tty_debug(tty, f, args...)  \
>> +do {\
>> +printk(KERN_DEBUG "%s: %s: " f, __func__,   \
>> +   tty_name(tty), ##args);  \
>> +} while (0)
> 
> Single statement macros don't need do {} while (0)

Ah, yep. Old hold-over from when tty_name() needed a temp buffer.


> #define fmt, ... 
> using fmt, ##__VA_ARGS__
> 
> is more common.

Ok.

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


[PATCH v3 00/10] hugetlbfs: add fallocate support

2015-07-12 Thread Mike Kravetz
Only change in this revision is the fix to the self-discovered
issue in region_chg().  Functional and stress tests passing.
Full changelog below.

As suggested during the RFC process, tests have been proposed to
libhugetlbfs as described at:
http://librelist.com/browser//libhugetlbfs/2015/6/25/patch-tests-add-tests-for-fallocate-system-call/
fallocate(2) man page modifications are also necessary to specify
that fallocate for hugetlbfs only operates on whole pages.  This
change will be submitted once the code has stabilized and been
proposed for merging.

hugetlbfs is used today by applications that want a high degree of
control over huge page usage.  Often, large hugetlbfs files are used
to map a large number huge pages into the application processes.
The applications know when page ranges within these large files will
no longer be used, and ideally would like to release them back to
the subpool or global pools for other uses.  The fallocate() system
call provides an interface for preallocation and hole punching within
files.  This patch set adds fallocate functionality to hugetlbfs.

v3:
  Fixed issue with region_chg to recheck if there are sufficient
  entries in the cache after acquiring lock.
v2:
  Fixed leak in resv_map_release discovered by Hillf Danton.
  Used LONG_MAX as indicator of truncate function for region_del.
v1:
  Add a cache of region descriptors to the resv_map for use by
region_add in case hole punch deletes entries necessary for
a successful operation.
RFC v4:
  Removed alloc_huge_page/hugetlb_reserve_pages race patches as already
in mmotm
  Moved hugetlb_fix_reserve_counts in series as suggested by Naoya Horiguchi
  Inline'ed hugetlb_fault_mutex routines as suggested by Davidlohr Bueso and
existing code changed to use new interfaces as suggested by Naoya
  fallocate preallocation code cleaned up and made simpler
  Modified alloc_huge_page to handle special case where allocation is
for a hole punched area with spool reserves
RFC v3:
  Folded in patch for alloc_huge_page/hugetlb_reserve_pages race
in current code
  fallocate allocation and hole punch is synchronized with page
faults via existing mutex table
   hole punch uses existing hugetlb_vmtruncate_list instead of more
generic unmap_mapping_range for unmapping
   Error handling for the case when region_del() fauils
RFC v2:
  Addressed alignment and error handling issues noticed by Hillf Danton
  New region_del() routine for region tracking/resv_map of ranges
  Fixed several issues found during more extensive testing
  Error handling in region_del() when kmalloc() fails stills needs
to be addressed
  madvise remove support remains

Mike Kravetz (10):
  mm/hugetlb: add cache of descriptors to resv_map for region_add
  mm/hugetlb: add region_del() to delete a specific range of entries
  mm/hugetlb: expose hugetlb fault mutex for use by fallocate
  hugetlbfs: hugetlb_vmtruncate_list() needs to take a range to delete
  hugetlbfs: truncate_hugepages() takes a range of pages
  mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch
  mm/hugetlb: alloc_huge_page handle areas hole punched by fallocate
  hugetlbfs: New huge_add_to_page_cache helper routine
  hugetlbfs: add hugetlbfs_fallocate()
  mm: madvise allow remove operation for hugetlbfs

 fs/hugetlbfs/inode.c| 281 +---
 include/linux/hugetlb.h |  17 +-
 mm/hugetlb.c| 423 ++--
 mm/madvise.c|   2 +-
 4 files changed, 619 insertions(+), 104 deletions(-)

-- 
2.1.0

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


[PATCH v3 02/10] mm/hugetlb: add region_del() to delete a specific range of entries

2015-07-12 Thread Mike Kravetz
fallocate hole punch will want to remove a specific range of pages.
The existing region_truncate() routine deletes all region/reserve
map entries after a specified offset.  region_del() will provide
this same functionality if the end of region is specified as LONG_MAX.
Hence, region_del() can replace region_truncate().

Unlike region_truncate(), region_del() can return an error in the
rare case where it can not allocate memory for a region descriptor.
This ONLY happens in the case where an existing region must be split.
Current callers passing LONG_MAX as end of range will never experience
this error and do not need to deal with error handling.  Future
callers of region_del() (such as fallocate hole punch) will need to
handle this error.

Signed-off-by: Mike Kravetz 
---
 mm/hugetlb.c | 99 
 1 file changed, 73 insertions(+), 26 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 241d16d..a5c8b3c 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -461,43 +461,90 @@ static void region_abort(struct resv_map *resv, long f, 
long t)
 }
 
 /*
- * Truncate the reserve map at index 'end'.  Modify/truncate any
- * region which contains end.  Delete any regions past end.
- * Return the number of huge pages removed from the map.
+ * Delete the specified range [f, t) from the reserve map.  If the
+ * t parameter is LONG_MAX, this indicates that ALL regions after f
+ * should be deleted.  Locate the regions which intersect [f, t)
+ * and either trim, delete or split the existing regions.
+ *
+ * Returns the number of huge pages deleted from the reserve map.
+ * In the normal case, the return value is zero or more.  In the
+ * case where a region must be split, a new region descriptor must
+ * be allocated.  If the allocation fails, -ENOMEM will be returned.
+ * NOTE: If the parameter t == LONG_MAX, then we will never split
+ * a region and possibly return -ENOMEM.  Callers specifying
+ * t == LONG_MAX do not need to check for -ENOMEM error.
  */
-static long region_truncate(struct resv_map *resv, long end)
+static long region_del(struct resv_map *resv, long f, long t)
 {
struct list_head *head = >regions;
struct file_region *rg, *trg;
-   long chg = 0;
+   struct file_region *nrg = NULL;
+   long del = 0;
 
+retry:
spin_lock(>lock);
-   /* Locate the region we are either in or before. */
-   list_for_each_entry(rg, head, link)
-   if (end <= rg->to)
+   list_for_each_entry_safe(rg, trg, head, link) {
+   if (rg->to <= f)
+   continue;
+   if (rg->from >= t)
break;
-   if (>link == head)
-   goto out;
 
-   /* If we are in the middle of a region then adjust it. */
-   if (end > rg->from) {
-   chg = rg->to - end;
-   rg->to = end;
-   rg = list_entry(rg->link.next, typeof(*rg), link);
-   }
+   if (f > rg->from && t < rg->to) { /* Must split region */
+   /*
+* Check for an entry in the cache before dropping
+* lock and attempting allocation.
+*/
+   if (!nrg &&
+   resv->rgn_cache_count > resv->adds_in_progress) {
+   nrg = list_first_entry(>rgn_cache,
+   struct file_region,
+   link);
+   list_del(>link);
+   resv->rgn_cache_count--;
+   }
 
-   /* Drop any remaining regions. */
-   list_for_each_entry_safe(rg, trg, rg->link.prev, link) {
-   if (>link == head)
+   if (!nrg) {
+   spin_unlock(>lock);
+   nrg = kmalloc(sizeof(*nrg), GFP_KERNEL);
+   if (!nrg)
+   return -ENOMEM;
+   goto retry;
+   }
+
+   del += t - f;
+
+   /* New entry for end of split region */
+   nrg->from = t;
+   nrg->to = rg->to;
+   INIT_LIST_HEAD(>link);
+
+   /* Original entry is trimmed */
+   rg->to = f;
+
+   list_add(>link, >link);
+   nrg = NULL;
break;
-   chg += rg->to - rg->from;
-   list_del(>link);
-   kfree(rg);
+   }
+
+   if (f <= rg->from && t >= rg->to) { /* Remove entire region */
+   del += rg->to - rg->from;
+   list_del(>link);
+   kfree(rg);
+   continue;
+   }
+

[PATCH v3 01/10] mm/hugetlb: add cache of descriptors to resv_map for region_add

2015-07-12 Thread Mike Kravetz
fallocate hole punch will want to remove a specific range of
pages.  When pages are removed, their associated entries in
the region/reserve map will also be removed.  This will break
an assumption in the region_chg/region_add calling sequence.
If a new region descriptor must be allocated, it is done as
part of the region_chg processing.  In this way, region_add
can not fail because it does not need to attempt an allocation.

To prepare for fallocate hole punch, create a "cache" of
descriptors that can be used by region_add if necessary.
region_chg will ensure there are sufficient entries in the
cache.  It will be necessary to track the number of in progress
add operations to know a sufficient number of descriptors
reside in the cache.  A new routine region_abort is added to
adjust this in progress count when add operations are aborted.
vma_abort_reservation is also added for callers creating
reservations with vma_needs_reservation/vma_commit_reservation.

Signed-off-by: Mike Kravetz 
---
 include/linux/hugetlb.h |   3 +
 mm/hugetlb.c| 169 ++--
 2 files changed, 153 insertions(+), 19 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index d891f94..667cf44 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -35,6 +35,9 @@ struct resv_map {
struct kref refs;
spinlock_t lock;
struct list_head regions;
+   long adds_in_progress;
+   struct list_head rgn_cache;
+   long rgn_cache_count;
 };
 extern struct resv_map *resv_map_alloc(void);
 void resv_map_release(struct kref *ref);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a8c3087..241d16d 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -240,11 +240,14 @@ struct file_region {
 
 /*
  * Add the huge page range represented by [f, t) to the reserve
- * map.  Existing regions will be expanded to accommodate the
- * specified range.  We know only existing regions need to be
- * expanded, because region_add is only called after region_chg
- * with the same range.  If a new file_region structure must
- * be allocated, it is done in region_chg.
+ * map.  In the normal case, existing regions will be expanded
+ * to accommodate the specified range.  Sufficient regions should
+ * exist for expansion due to the previous call to region_chg
+ * with the same range.  However, it is possible that region_del
+ * could have been called after region_chg and modifed the map
+ * in such a way that no region exists to be expanded.  In this
+ * case, pull a region descriptor from the cache associated with
+ * the map and use that for the new range.
  *
  * Return the number of new huge pages added to the map.  This
  * number is greater than or equal to zero.
@@ -261,6 +264,27 @@ static long region_add(struct resv_map *resv, long f, long 
t)
if (f <= rg->to)
break;
 
+   if (>link == head || t < rg->from) {
+   /*
+* No region exists which can be expanded to include the
+* specified range.  Pull a region descriptor from the
+* cache, and use it for this range.
+*/
+   VM_BUG_ON(!resv->rgn_cache_count);
+
+   resv->rgn_cache_count--;
+   nrg = list_first_entry(>rgn_cache, struct file_region,
+   link);
+   list_del(>link);
+
+   nrg->from = f;
+   nrg->to = t;
+   list_add(>link, rg->link.prev);
+
+   add += t - f;
+   goto out_locked;
+   }
+
/* Round our left edge to the current segment if it encloses us. */
if (f > rg->from)
f = rg->from;
@@ -294,6 +318,8 @@ static long region_add(struct resv_map *resv, long f, long 
t)
add += t - nrg->to; /* Added to end of region */
nrg->to = t;
 
+out_locked:
+   resv->adds_in_progress--;
spin_unlock(>lock);
VM_BUG_ON(add < 0);
return add;
@@ -312,11 +338,16 @@ static long region_add(struct resv_map *resv, long f, 
long t)
  * so that the subsequent region_add call will have all the
  * regions it needs and will not fail.
  *
+ * Upon entry, region_chg will also examine the cache of
+ * region descriptors associated with the map.  If there
+ * not enough descriptors cached, one will be allocated
+ * for the in progress add operation.
+ *
  * Returns the number of huge pages that need to be added
  * to the existing reservation map for the range [f, t).
  * This number is greater or equal to zero.  -ENOMEM is
- * returned if a new file_region structure is needed and can
- * not be allocated.
+ * returned if a new file_region structure or cache entry
+ * is needed and can not be allocated.
  */
 static long region_chg(struct resv_map *resv, long f, long t)
 {
@@ -326,6 +357,31 @@ static long region_chg(struct resv_map *resv, long f, long 
t)
 
 retry:

[PATCH v3 05/10] hugetlbfs: truncate_hugepages() takes a range of pages

2015-07-12 Thread Mike Kravetz
Modify truncate_hugepages() to take a range of pages (start, end)
instead of simply start. If an end value of LLONG_MAX is passed,
the current "truncate" functionality is maintained. Existing
callers are modified to pass LLONG_MAX as end of range. By keying
off end == LLONG_MAX, the routine behaves differently for truncate
and hole punch.  Page removal is now synchronized with page
allocation via faults by using the fault mutex table. The hole
punch case can experience the rare region_del error and must
handle accordingly.

Add the routine hugetlb_fix_reserve_counts to fix up reserve counts
in the case where region_del returns an error.

Since the routine handles more than just the truncate case, it is
renamed to remove_inode_hugepages().  To be consistent, the routine
truncate_huge_page() is renamed remove_huge_page().

Downstream of remove_inode_hugepages(), the routine
hugetlb_unreserve_pages() is also modified to take a range of pages.
hugetlb_unreserve_pages is modified to detect an error from
region_del and pass it back to the caller.

Signed-off-by: Mike Kravetz 
---
 fs/hugetlbfs/inode.c| 98 -
 include/linux/hugetlb.h |  4 +-
 mm/hugetlb.c| 40 ++--
 3 files changed, 128 insertions(+), 14 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index ed40f56..a974e4b 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -293,26 +293,61 @@ static int hugetlbfs_write_end(struct file *file, struct 
address_space *mapping,
return -EINVAL;
 }
 
-static void truncate_huge_page(struct page *page)
+static void remove_huge_page(struct page *page)
 {
ClearPageDirty(page);
ClearPageUptodate(page);
delete_from_page_cache(page);
 }
 
-static void truncate_hugepages(struct inode *inode, loff_t lstart)
+
+/*
+ * remove_inode_hugepages handles two distinct cases: truncation and hole
+ * punch.  There are subtle differences in operation for each case.
+
+ * truncation is indicated by end of range being LLONG_MAX
+ * In this case, we first scan the range and release found pages.
+ * After releasing pages, hugetlb_unreserve_pages cleans up region/reserv
+ * maps and global counts.
+ * hole punch is indicated if end is not LLONG_MAX
+ * In the hole punch case we scan the range and release found pages.
+ * Only when releasing a page is the associated region/reserv map
+ * deleted.  The region/reserv map for ranges without associated
+ * pages are not modified.
+ * Note: If the passed end of range value is beyond the end of file, but
+ * not LLONG_MAX this routine still performs a hole punch operation.
+ */
+static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
+  loff_t lend)
 {
struct hstate *h = hstate_inode(inode);
struct address_space *mapping = >i_data;
const pgoff_t start = lstart >> huge_page_shift(h);
+   const pgoff_t end = lend >> huge_page_shift(h);
+   struct vm_area_struct pseudo_vma;
struct pagevec pvec;
pgoff_t next;
int i, freed = 0;
+   long lookup_nr = PAGEVEC_SIZE;
+   bool truncate_op = (lend == LLONG_MAX);
 
+   memset(_vma, 0, sizeof(struct vm_area_struct));
+   pseudo_vma.vm_flags = (VM_HUGETLB | VM_MAYSHARE | VM_SHARED);
pagevec_init(, 0);
next = start;
-   while (1) {
-   if (!pagevec_lookup(, mapping, next, PAGEVEC_SIZE)) {
+   while (next < end) {
+   /*
+* Make sure to never grab more pages that we
+* might possibly need.
+*/
+   if (end - next < lookup_nr)
+   lookup_nr = end - next;
+
+   /*
+* This pagevec_lookup() may return pages past 'end',
+* so we must check for page->index > end.
+*/
+   if (!pagevec_lookup(, mapping, next, lookup_nr)) {
if (next == start)
break;
next = start;
@@ -321,26 +356,69 @@ static void truncate_hugepages(struct inode *inode, 
loff_t lstart)
 
for (i = 0; i < pagevec_count(); ++i) {
struct page *page = pvec.pages[i];
+   u32 hash;
+
+   hash = hugetlb_fault_mutex_hash(h, current->mm,
+   _vma,
+   mapping, next, 0);
+   mutex_lock(_fault_mutex_table[hash]);
 
lock_page(page);
+   if (page->index >= end) {
+   unlock_page(page);
+   mutex_unlock(_fault_mutex_table[hash]);
+   next = end; /* we are done */
+   break;
+   }
+
+ 

[PATCH v3 10/10] mm: madvise allow remove operation for hugetlbfs

2015-07-12 Thread Mike Kravetz
Now that we have hole punching support for hugetlbfs, we can
also support the MADV_REMOVE interface to it.

Signed-off-by: Dave Hansen 
Signed-off-by: Mike Kravetz 
---
 mm/madvise.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index 70ce0d4..a235367 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -468,7 +468,7 @@ static long madvise_remove(struct vm_area_struct *vma,
 
*prev = NULL;   /* tell sys_madvise we drop mmap_sem */
 
-   if (vma->vm_flags & (VM_LOCKED | VM_HUGETLB))
+   if (vma->vm_flags & VM_LOCKED)
return -EINVAL;
 
f = vma->vm_file;
-- 
2.1.0

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


[PATCH v3 04/10] hugetlbfs: hugetlb_vmtruncate_list() needs to take a range to delete

2015-07-12 Thread Mike Kravetz
fallocate hole punch will want to unmap a specific range of pages.
Modify the existing hugetlb_vmtruncate_list() routine to take a
start/end range.  If end is 0, this indicates all pages after start
should be unmapped.  This is the same as the existing truncate
functionality.  Modify existing callers to add 0 as end of range.

Since the routine will be used in hole punch as well as truncate
operations, it is more appropriately renamed to hugetlb_vmdelete_list().

Signed-off-by: Mike Kravetz 
---
 fs/hugetlbfs/inode.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 0cf74df..ed40f56 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -349,11 +349,15 @@ static void hugetlbfs_evict_inode(struct inode *inode)
 }
 
 static inline void
-hugetlb_vmtruncate_list(struct rb_root *root, pgoff_t pgoff)
+hugetlb_vmdelete_list(struct rb_root *root, pgoff_t start, pgoff_t end)
 {
struct vm_area_struct *vma;
 
-   vma_interval_tree_foreach(vma, root, pgoff, ULONG_MAX) {
+   /*
+* end == 0 indicates that the entire range after
+* start should be unmapped.
+*/
+   vma_interval_tree_foreach(vma, root, start, end ? end : ULONG_MAX) {
unsigned long v_offset;
 
/*
@@ -362,13 +366,20 @@ hugetlb_vmtruncate_list(struct rb_root *root, pgoff_t 
pgoff)
 * which overlap the truncated area starting at pgoff,
 * and no vma on a 32-bit arch can span beyond the 4GB.
 */
-   if (vma->vm_pgoff < pgoff)
-   v_offset = (pgoff - vma->vm_pgoff) << PAGE_SHIFT;
+   if (vma->vm_pgoff < start)
+   v_offset = (start - vma->vm_pgoff) << PAGE_SHIFT;
else
v_offset = 0;
 
-   unmap_hugepage_range(vma, vma->vm_start + v_offset,
-vma->vm_end, NULL);
+   if (end) {
+   end = ((end - start) << PAGE_SHIFT) +
+  vma->vm_start + v_offset;
+   if (end > vma->vm_end)
+   end = vma->vm_end;
+   } else
+   end = vma->vm_end;
+
+   unmap_hugepage_range(vma, vma->vm_start + v_offset, end, NULL);
}
 }
 
@@ -384,7 +395,7 @@ static int hugetlb_vmtruncate(struct inode *inode, loff_t 
offset)
i_size_write(inode, offset);
i_mmap_lock_write(mapping);
if (!RB_EMPTY_ROOT(>i_mmap))
-   hugetlb_vmtruncate_list(>i_mmap, pgoff);
+   hugetlb_vmdelete_list(>i_mmap, pgoff, 0);
i_mmap_unlock_write(mapping);
truncate_hugepages(inode, offset);
return 0;
-- 
2.1.0

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


[PATCH v3 06/10] mm/hugetlb: vma_has_reserves() needs to handle fallocate hole punch

2015-07-12 Thread Mike Kravetz
In vma_has_reserves(), the current assumption is that reserves are
always present for shared mappings.  However, this will not be the
case with fallocate hole punch.  When punching a hole, the present
page will be deleted as well as the region/reserve map entry (and
hence any reservation).  vma_has_reserves is passed "chg" which
indicates whether or not a region/reserve map is present.  Use
this to determine if reserves are actually present or were removed
via hole punch.

Signed-off-by: Mike Kravetz 
---
 mm/hugetlb.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index def39e3..f72cb96 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -801,9 +801,19 @@ static int vma_has_reserves(struct vm_area_struct *vma, 
long chg)
return 0;
}
 
-   /* Shared mappings always use reserves */
-   if (vma->vm_flags & VM_MAYSHARE)
-   return 1;
+   if (vma->vm_flags & VM_MAYSHARE) {
+   /*
+* We know VM_NORESERVE is not set.  Therefore, there SHOULD
+* be a region map for all pages.  The only situation where
+* there is no region map is if a hole was punched via
+* fallocate.  In this case, there really are no reverves to
+* use.  This situation is indicated if chg != 0.
+*/
+   if (chg)
+   return 0;
+   else
+   return 1;
+   }
 
/*
 * Only the process that called mmap() has reserves for
-- 
2.1.0

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


[PATCH v3 08/10] hugetlbfs: New huge_add_to_page_cache helper routine

2015-07-12 Thread Mike Kravetz
Currently, there is  only a single place where hugetlbfs pages are
added to the page cache.  The new fallocate code be adding a second
one, so break the functionality out into its own helper.

Signed-off-by: Dave Hansen 
Signed-off-by: Mike Kravetz 
---
 include/linux/hugetlb.h |  2 ++
 mm/hugetlb.c| 27 ++-
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index e7825c9..657ef26 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -333,6 +333,8 @@ struct huge_bootmem_page {
 struct page *alloc_huge_page_node(struct hstate *h, int nid);
 struct page *alloc_huge_page_noerr(struct vm_area_struct *vma,
unsigned long addr, int avoid_reserve);
+int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
+   pgoff_t idx);
 
 /* arch callback */
 int __init alloc_bootmem_huge_page(struct hstate *h);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 5a2ee06..aedc5e7 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3374,6 +3374,23 @@ static bool hugetlbfs_pagecache_present(struct hstate *h,
return page != NULL;
 }
 
+int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
+  pgoff_t idx)
+{
+   struct inode *inode = mapping->host;
+   struct hstate *h = hstate_inode(inode);
+   int err = add_to_page_cache(page, mapping, idx, GFP_KERNEL);
+
+   if (err)
+   return err;
+   ClearPagePrivate(page);
+
+   spin_lock(>i_lock);
+   inode->i_blocks += blocks_per_huge_page(h);
+   spin_unlock(>i_lock);
+   return 0;
+}
+
 static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
   struct address_space *mapping, pgoff_t idx,
   unsigned long address, pte_t *ptep, unsigned int 
flags)
@@ -3421,21 +3438,13 @@ retry:
set_page_huge_active(page);
 
if (vma->vm_flags & VM_MAYSHARE) {
-   int err;
-   struct inode *inode = mapping->host;
-
-   err = add_to_page_cache(page, mapping, idx, GFP_KERNEL);
+   int err = huge_add_to_page_cache(page, mapping, idx);
if (err) {
put_page(page);
if (err == -EEXIST)
goto retry;
goto out;
}
-   ClearPagePrivate(page);
-
-   spin_lock(>i_lock);
-   inode->i_blocks += blocks_per_huge_page(h);
-   spin_unlock(>i_lock);
} else {
lock_page(page);
if (unlikely(anon_vma_prepare(vma))) {
-- 
2.1.0

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


[PATCH v3 09/10] hugetlbfs: add hugetlbfs_fallocate()

2015-07-12 Thread Mike Kravetz
This is based on the shmem version, but it has diverged quite
a bit.  We have no swap to worry about, nor the new file sealing.
Add synchronication via the fault mutex table to coordinate
page faults,  fallocate allocation and fallocate hole punch.

What this allows us to do is move physical memory in and out of
a hugetlbfs file without having it mapped.  This also gives us
the ability to support MADV_REMOVE since it is currently
implemented using fallocate().  MADV_REMOVE lets madvise() remove
pages from the middle of a hugetlbfs file, which wasn't possible
before.

hugetlbfs fallocate only operates on whole huge pages.

Based-on code-by: Dave Hansen 
Signed-off-by: Mike Kravetz 
---
 fs/hugetlbfs/inode.c| 158 +++-
 include/linux/hugetlb.h |   3 +
 mm/hugetlb.c|   2 +-
 3 files changed, 161 insertions(+), 2 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index a974e4b..6e565a4 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include/* remove ASAP */
+#include 
 #include 
 #include 
 #include 
@@ -479,6 +480,160 @@ static int hugetlb_vmtruncate(struct inode *inode, loff_t 
offset)
return 0;
 }
 
+static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t 
len)
+{
+   struct hstate *h = hstate_inode(inode);
+   loff_t hpage_size = huge_page_size(h);
+   loff_t hole_start, hole_end;
+
+   /*
+* For hole punch round up the beginning offset of the hole and
+* round down the end.
+*/
+   hole_start = round_up(offset, hpage_size);
+   hole_end = round_down(offset + len, hpage_size);
+
+   if (hole_end > hole_start) {
+   struct address_space *mapping = inode->i_mapping;
+
+   mutex_lock(>i_mutex);
+   i_mmap_lock_write(mapping);
+   if (!RB_EMPTY_ROOT(>i_mmap))
+   hugetlb_vmdelete_list(>i_mmap,
+   hole_start >> PAGE_SHIFT,
+   hole_end  >> PAGE_SHIFT);
+   i_mmap_unlock_write(mapping);
+   remove_inode_hugepages(inode, hole_start, hole_end);
+   mutex_unlock(>i_mutex);
+   }
+
+   return 0;
+}
+
+static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
+   loff_t len)
+{
+   struct inode *inode = file_inode(file);
+   struct address_space *mapping = inode->i_mapping;
+   struct hstate *h = hstate_inode(inode);
+   struct vm_area_struct pseudo_vma;
+   struct mm_struct *mm = current->mm;
+   loff_t hpage_size = huge_page_size(h);
+   unsigned long hpage_shift = huge_page_shift(h);
+   pgoff_t start, index, end;
+   int error;
+   u32 hash;
+
+   if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
+   return -EOPNOTSUPP;
+
+   if (mode & FALLOC_FL_PUNCH_HOLE)
+   return hugetlbfs_punch_hole(inode, offset, len);
+
+   /*
+* Default preallocate case.
+* For this range, start is rounded down and end is rounded up
+* as well as being converted to page offsets.
+*/
+   start = offset >> hpage_shift;
+   end = (offset + len + hpage_size - 1) >> hpage_shift;
+
+   mutex_lock(>i_mutex);
+
+   /* We need to check rlimit even when FALLOC_FL_KEEP_SIZE */
+   error = inode_newsize_ok(inode, offset + len);
+   if (error)
+   goto out;
+
+   /*
+* Initialize a pseudo vma that just contains the policy used
+* when allocating the huge pages.  The actual policy field
+* (vm_policy) is determined based on the index in the loop below.
+*/
+   memset(_vma, 0, sizeof(struct vm_area_struct));
+   pseudo_vma.vm_flags = (VM_HUGETLB | VM_MAYSHARE | VM_SHARED);
+   pseudo_vma.vm_file = file;
+
+   for (index = start; index < end; index++) {
+   /*
+* This is supposed to be the vaddr where the page is being
+* faulted in, but we have no vaddr here.
+*/
+   struct page *page;
+   unsigned long addr;
+   int avoid_reserve = 0;
+
+   cond_resched();
+
+   /*
+* fallocate(2) manpage permits EINTR; we may have been
+* interrupted because we are using up too much memory.
+*/
+   if (signal_pending(current)) {
+   error = -EINTR;
+   break;
+   }
+
+   /* Get policy based on index */
+   pseudo_vma.vm_policy =
+   mpol_shared_policy_lookup(_I(inode)->policy,
+   index);
+
+   /* addr is the offset within the file (zero based) */
+   

[PATCH v3 03/10] mm/hugetlb: expose hugetlb fault mutex for use by fallocate

2015-07-12 Thread Mike Kravetz
hugetlb page faults are currently synchronized by the table of
mutexes (htlb_fault_mutex_table).  fallocate code will need to
synchronize with the page fault code when it allocates or
deletes pages.  Expose interfaces so that fallocate operations
can be synchronized with page faults.  Minor name changes to
be more consistent with other global hugetlb symbols.

Signed-off-by: Mike Kravetz 
---
 include/linux/hugetlb.h |  5 +
 mm/hugetlb.c| 20 ++--
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 667cf44..933da39 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -88,6 +88,11 @@ int dequeue_hwpoisoned_huge_page(struct page *page);
 bool isolate_huge_page(struct page *page, struct list_head *list);
 void putback_active_hugepage(struct page *page);
 void free_huge_page(struct page *page);
+extern struct mutex *hugetlb_fault_mutex_table;
+u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
+   struct vm_area_struct *vma,
+   struct address_space *mapping,
+   pgoff_t idx, unsigned long address);
 
 #ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
 pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a5c8b3c..52c2801 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -64,7 +64,7 @@ DEFINE_SPINLOCK(hugetlb_lock);
  * prevent spurious OOMs when the hugepage pool is fully utilized.
  */
 static int num_fault_mutexes;
-static struct mutex *htlb_fault_mutex_table cacheline_aligned_in_smp;
+struct mutex *hugetlb_fault_mutex_table cacheline_aligned_in_smp;
 
 /* Forward declaration */
 static int hugetlb_acct_memory(struct hstate *h, long delta);
@@ -2482,7 +2482,7 @@ static void __exit hugetlb_exit(void)
}
 
kobject_put(hugepages_kobj);
-   kfree(htlb_fault_mutex_table);
+   kfree(hugetlb_fault_mutex_table);
 }
 module_exit(hugetlb_exit);
 
@@ -2515,12 +2515,12 @@ static int __init hugetlb_init(void)
 #else
num_fault_mutexes = 1;
 #endif
-   htlb_fault_mutex_table =
+   hugetlb_fault_mutex_table =
kmalloc(sizeof(struct mutex) * num_fault_mutexes, GFP_KERNEL);
-   BUG_ON(!htlb_fault_mutex_table);
+   BUG_ON(!hugetlb_fault_mutex_table);
 
for (i = 0; i < num_fault_mutexes; i++)
-   mutex_init(_fault_mutex_table[i]);
+   mutex_init(_fault_mutex_table[i]);
return 0;
 }
 module_init(hugetlb_init);
@@ -3454,7 +3454,7 @@ backout_unlocked:
 }
 
 #ifdef CONFIG_SMP
-static u32 fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
+u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
struct vm_area_struct *vma,
struct address_space *mapping,
pgoff_t idx, unsigned long address)
@@ -3479,7 +3479,7 @@ static u32 fault_mutex_hash(struct hstate *h, struct 
mm_struct *mm,
  * For uniprocesor systems we always use a single mutex, so just
  * return 0 and avoid the hashing overhead.
  */
-static u32 fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
+u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
struct vm_area_struct *vma,
struct address_space *mapping,
pgoff_t idx, unsigned long address)
@@ -3527,8 +3527,8 @@ int hugetlb_fault(struct mm_struct *mm, struct 
vm_area_struct *vma,
 * get spurious allocation failures if two CPUs race to instantiate
 * the same page in the page cache.
 */
-   hash = fault_mutex_hash(h, mm, vma, mapping, idx, address);
-   mutex_lock(_fault_mutex_table[hash]);
+   hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, idx, address);
+   mutex_lock(_fault_mutex_table[hash]);
 
entry = huge_ptep_get(ptep);
if (huge_pte_none(entry)) {
@@ -3613,7 +3613,7 @@ out_ptl:
put_page(pagecache_page);
}
 out_mutex:
-   mutex_unlock(_fault_mutex_table[hash]);
+   mutex_unlock(_fault_mutex_table[hash]);
/*
 * Generally it's safe to hold refcount during waiting page lock. But
 * here we just wait to defer the next page fault to avoid busy loop and
-- 
2.1.0

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


[PATCH v3 07/10] mm/hugetlb: alloc_huge_page handle areas hole punched by fallocate

2015-07-12 Thread Mike Kravetz
Areas hole punched by fallocate will not have entries in the
region/reserve map.  However, shared mappings with min_size subpool
reservations may still have reserved pages.  alloc_huge_page needs
to handle this special case and do the proper accounting.

Signed-off-by: Mike Kravetz 
---
 mm/hugetlb.c | 54 +++---
 1 file changed, 39 insertions(+), 15 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f72cb96..5a2ee06 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1732,34 +1732,58 @@ static struct page *alloc_huge_page(struct 
vm_area_struct *vma,
struct hugepage_subpool *spool = subpool_vma(vma);
struct hstate *h = hstate_vma(vma);
struct page *page;
-   long chg, commit;
+   long map_chg, map_commit;
+   long gbl_chg;
int ret, idx;
struct hugetlb_cgroup *h_cg;
 
idx = hstate_index(h);
/*
-* Processes that did not create the mapping will have no
-* reserves and will not have accounted against subpool
-* limit. Check that the subpool limit can be made before
-* satisfying the allocation MAP_NORESERVE mappings may also
-* need pages and subpool limit allocated allocated if no reserve
-* mapping overlaps.
+* Examine the region/reserve map to determine if the process
+* has a reservation for the page to be allocated.  A return
+* code of zero indicates a reservation exists (no change).
 */
-   chg = vma_needs_reservation(h, vma, addr);
-   if (chg < 0)
+   map_chg = gbl_chg = vma_needs_reservation(h, vma, addr);
+   if (map_chg < 0)
return ERR_PTR(-ENOMEM);
-   if (chg || avoid_reserve)
-   if (hugepage_subpool_get_pages(spool, 1) < 0) {
+
+   /*
+* Processes that did not create the mapping will have no
+* reserves as indicated by the region/reserve map. Check
+* that the allocation will not exceed the subpool limit.
+* Allocations for MAP_NORESERVE mappings also need to be
+* checked against any subpool limit.
+*/
+   if (map_chg || avoid_reserve) {
+   gbl_chg = hugepage_subpool_get_pages(spool, 1);
+   if (gbl_chg < 0) {
vma_abort_reservation(h, vma, addr);
return ERR_PTR(-ENOSPC);
}
 
+   /*
+* Even though there was no reservation in the region/reserve
+* map, there could be reservations associated with the
+* subpool that can be used.  This would be indicated if the
+* return value of hugepage_subpool_get_pages() is zero.
+* However, if avoid_reserve is specified we still avoid even
+* the subpool reservations.
+*/
+   if (avoid_reserve)
+   gbl_chg = 1;
+   }
+
ret = hugetlb_cgroup_charge_cgroup(idx, pages_per_huge_page(h), _cg);
if (ret)
goto out_subpool_put;
 
spin_lock(_lock);
-   page = dequeue_huge_page_vma(h, vma, addr, avoid_reserve, chg);
+   /*
+* glb_chg is passed to indicate whether or not a page must be taken
+* from the global free pool (global change).  gbl_chg == 0 indicates
+* a reservation exists for the allocation.
+*/
+   page = dequeue_huge_page_vma(h, vma, addr, avoid_reserve, gbl_chg);
if (!page) {
spin_unlock(_lock);
page = alloc_buddy_huge_page(h, NUMA_NO_NODE);
@@ -1775,8 +1799,8 @@ static struct page *alloc_huge_page(struct vm_area_struct 
*vma,
 
set_page_private(page, (unsigned long)spool);
 
-   commit = vma_commit_reservation(h, vma, addr);
-   if (unlikely(chg > commit)) {
+   map_commit = vma_commit_reservation(h, vma, addr);
+   if (unlikely(map_chg > map_commit)) {
/*
 * The page was added to the reservation map between
 * vma_needs_reservation and vma_commit_reservation.
@@ -1796,7 +1820,7 @@ static struct page *alloc_huge_page(struct vm_area_struct 
*vma,
 out_uncharge_cgroup:
hugetlb_cgroup_uncharge_cgroup(idx, pages_per_huge_page(h), h_cg);
 out_subpool_put:
-   if (chg || avoid_reserve)
+   if (map_chg || avoid_reserve)
hugepage_subpool_put_pages(spool, 1);
vma_abort_reservation(h, vma, addr);
return ERR_PTR(-ENOSPC);
-- 
2.1.0

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


Re: [PATCH v2 2/6] soc: Mediatek: Add SCPSYS CPU power domain driver

2015-07-12 Thread Scott Shu

For some platform, the code for controlling CPU power is located in
arch/arm/mach-. (i.e., mach-hisi and mach-qcom). The framework is
clear and easy to maintain. In addition, the code will be called in
very early stage during system boot up.Is the platform driver ready for
the moment?


On Fri, 2015-07-10 at 16:31 +0200, Matthias Brugger wrote:
> On Friday, July 10, 2015 02:04:05 PM Scott Shu wrote:
> > This adds a CPU power domain driver for the Mediatek SCPSYS unit on
> > MT6580.
> > 
> > Signed-off-by: Scott Shu 
> > ---
> >  arch/arm/mach-mediatek/Makefile  |   2 +-
> >  arch/arm/mach-mediatek/generic.h |  23 
> >  arch/arm/mach-mediatek/hotplug.c | 267
> > +++ 3 files changed, 291 insertions(+),
> > 1 deletion(-)
> >  create mode 100644 arch/arm/mach-mediatek/generic.h
> >  create mode 100644 arch/arm/mach-mediatek/hotplug.c
> > 
> > diff --git a/arch/arm/mach-mediatek/Makefile
> > b/arch/arm/mach-mediatek/Makefile index 2116460..b2e4ef5 100644
> > --- a/arch/arm/mach-mediatek/Makefile
> > +++ b/arch/arm/mach-mediatek/Makefile
> > @@ -1,4 +1,4 @@
> >  ifeq ($(CONFIG_SMP),y)
> > -obj-$(CONFIG_ARCH_MEDIATEK) += platsmp.o
> > +obj-$(CONFIG_ARCH_MEDIATEK) += platsmp.o hotplug.o
> >  endif
> >  obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
> > diff --git a/arch/arm/mach-mediatek/generic.h
> > b/arch/arm/mach-mediatek/generic.h new file mode 100644
> > index 000..376f183
> > --- /dev/null
> > +++ b/arch/arm/mach-mediatek/generic.h
> > @@ -0,0 +1,23 @@
> > +/*
> > + * Copyright (c) 2015 Mediatek Inc.
> > + * Author: Scott Shu 
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +#ifndef __MACH_GENERIC_H
> > +#define __MACH_GENERIC_H
> > +
> > +#include 
> > +
> > +int spm_cpu_mtcmos_init(void);
> > +int spm_cpu_mtcmos_on(int cpu);
> > +int spm_cpu_mtcmos_off(int cpu, bool wfi);
> > +
> > +#endif
> > diff --git a/arch/arm/mach-mediatek/hotplug.c
> > b/arch/arm/mach-mediatek/hotplug.c new file mode 100644
> > index 000..bd97f2e
> > --- /dev/null
> > +++ b/arch/arm/mach-mediatek/hotplug.c
> > @@ -0,0 +1,267 @@
> > +/*
> > + * Copyright (c) 2015 Mediatek Inc.
> > + * Author: Scott Shu 
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/* SCPSYS registers */
> > +#define SPM_POWERON_CONFIG_SET 0x
> > +
> > +#define SPM_CA7_CPU0_PWR_CON   0x0200
> > +#define SPM_CA7_CPU1_PWR_CON   0x0218
> > +#define SPM_CA7_CPU2_PWR_CON   0x021c
> > +#define SPM_CA7_CPU3_PWR_CON   0x0220
> > +
> > +#define SPM_CA7_CPU0_L1_PDN0x025c
> > +#define SPM_CA7_CPU1_L1_PDN0x0264
> > +#define SPM_CA7_CPU2_L1_PDN0x026c
> > +#define SPM_CA7_CPU3_L1_PDN0x0274
> > +
> > +#define SPM_PWR_STATUS 0x060c
> > +#define SPM_PWR_STATUS_2ND 0x0610
> > +#define SPM_SLEEP_TIMER_STA0x0720
> > +
> > +/* bit definition in SPM_CA7_CPUx_PWR_CON */
> > +#define SRAM_ISOINT_B  BIT(6)
> > +#define SRAM_CKISO BIT(5)
> > +#define PWR_CLK_DISBIT(4)
> > +#define PWR_ON_2ND BIT(3)
> > +#define PWR_ON BIT(2)
> > +#define PWR_ISOBIT(1)
> > +#define PWR_RST_B  BIT(0)
> > +
> > +/* bit definition in SPM_CA7_CPUx_L1_PDN */
> > +#define L1_PDN_ACK BIT(8)
> > +#define L1_PDN BIT(0)
> > +
> > +#define MT6580_MAX_CPUS4
> > +
> > +static DEFINE_SPINLOCK(spm_cpu_lock);
> > +
> > +void __iomem *spm_cpu_base;
> > +
> > +u32 spm_cpu_pwr_con[MT6580_MAX_CPUS] = {
> > +   SPM_CA7_CPU0_PWR_CON,
> > +   SPM_CA7_CPU1_PWR_CON,
> > +   SPM_CA7_CPU2_PWR_CON,
> > +   SPM_CA7_CPU3_PWR_CON,
> > +};
> > +
> > +u32 spm_cpu_l1_pdn[MT6580_MAX_CPUS] = {
> > +   SPM_CA7_CPU0_L1_PDN,
> > +   SPM_CA7_CPU1_L1_PDN,
> > +   SPM_CA7_CPU2_L1_PDN,
> > +   SPM_CA7_CPU3_L1_PDN,
> > +};
> > +
> > +#define SPM_REGWR_EN   BIT(0)
> > +#define 

linux-next: Tree for Jul 13

2015-07-12 Thread Stephen Rothwell
Hi all,

Changes since 20150710:

*crickets*

Non-merge commits (relative to Linus' tree): 1433
 1334 files changed, 78369 insertions(+), 21954 deletions(-)



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

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

Below is a summary of the state of the merge.

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

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

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

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

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

$ git checkout master
$ git reset --hard stable
Merging origin/master (bc0195aad0da Linux 4.2-rc2)
Merging fixes/master (c7e9ad7da219 Merge branch 'perf-urgent-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip)
Merging kbuild-current/rc-fixes (c517d838eb7d Linux 4.0-rc1)
Merging arc-current/for-curr (e4140819dadc ARC: signal handling robustify)
Merging arm-current/fixes (11b8b25ce4f8 ARM: fix lockdep unannotated irqs-off 
warning)
Merging m68k-current/for-linus (1214c525484c m68k: Use for_each_sg())
Merging metag-fixes/fixes (0164a711c97b metag: Fix ioremap_wc/ioremap_cached 
build errors)
Merging mips-fixes/mips-fixes (1795cd9b3a91 Linux 3.16-rc5)
Merging powerpc-fixes/fixes (2c069a118fe1 cxl: Check if afu is not null in 
cxl_slbia)
Merging powerpc-merge-mpe/fixes (a8956a7b7232 powerpc/powernv: Fix opal-elog 
interrupt handler)
Merging powerpc-merge-benh/merge (c517d838eb7d Linux 4.0-rc1)
Merging sparc/master (4a10a91756ef Merge branch 'upstream' of 
git://git.infradead.org/users/pcmoore/audit)
Merging net/master (2ee94014d9bd net: switchdev: don't abort unsupported 
operations)
Merging ipsec/master (31a418986a58 xen: netback: read hotplug script once at 
start of day.)
Merging sound-current/for-linus (d1f15e06b2af ALSA: hda - Fix a wrong busy 
check in alt PCM open)
Merging pci-current/for-linus (552bc94ebeeb PCI: Preserve resource size during 
alignment reordering)
Merging wireless-drivers/master (7865598ec24a ath9k_hw: fix device ID check for 
AR956x)
Merging driver-core.current/driver-core-linus (d770e558e219 Linux 4.2-rc1)
Merging tty.current/tty-linus (d770e558e219 Linux 4.2-rc1)
Merging usb.current/usb-linus (d4669bb1427c Merge tag 'fixes-for-v4.2-rc2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus)
Merging usb-gadget-fixes/fixes (b2e2c94b878b usb: gadget: f_midi: fix error 
recovery path)
Merging usb-serial-fixes/usb-linus (d23f47d4927f USB: serial: Destroy 
serial_minors IDR on module exit)
Merging staging.current/staging-linus (cbe4f4434ded staging:lustre: remove 
irq.h from socklnd.h)
Merging char-misc.current/char-misc-linus (d770e558e219 Linux 4.2-rc1)
Merging input-current/for-linus (dbf3c370862d Revert "Input: synaptics - 
allocate 3 slots to keep stability in image sensors")
Merging crypto-current/master (030f4e968741 crypto: nx - Fix reentrancy bugs)
Merging ide/master (d681f1166919 ide: remove deprecated use of pci api)
Merging devicetree-current/devicetree/merge (f76502aa9140 of/dynamic: Fix test 
for PPC_PSERIES)
Merging rr-fixes/fixes (758556bdc1c8 module: Fix load_module() error path)
Merging vfio-fixes/for-linus (db7d4d7f4021 vfio: Fix runaway interruptible 
timeout)
Merging kselftest-fixes/fixes (d770e558e219 Linux 4.2-rc1)
Merging backlight-fixes/for-backlight-fixes (68feaca0b13e backlight: pwm: 
Handle EPROBE_DEFER while requesting the PWM)
Merging drm-intel-fixes/for-linux-next-fixes (b52b374eb348 drm/i915: avoid 
leaking DMA mappings)
Merging asm-generic/master (643165c8bbc8 Merge tag 'uaccess_for_upstream' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost into asm-generic)
Merging arc/for-next (b631788ab42e ARC: slightly refactor macros for boot 

Re: [PATCH v3 0/9] regulator: Merge max77843 into max77693

2015-07-12 Thread Krzysztof Kozłowski
2015-07-08 20:00 GMT+09:00 Krzysztof Kozlowski :
> Dear Mark,
>
>
> The patchset merges max77843 regulator driver into max77693.
>
> It touches multiple subsystems so I think the best way would be to
> merge it through one tree. I already got acks from extcon, input
> mfd and power maintainers.
>
> If there are no objections then everything could go through regulator
> tree.

The rebasing was insufficient. A new driver was recently added -
leds-nax77693 which I did not update. I will post an fixed version.

Krzysztof

>
>
> Changes since v2
> 
> 1. Rebase on v4.2-rc1.
> 2. Add acks: Chanwoo Choi, Dmitry Torokhov, Lee Jones. Thanks!
>
>
> Changes since v1
> 
> 1. Drop patch "regulator: max77693: Use core code for charger's
>is_enabled" because Mark Brown picked it up.
> 2. Patch 2: remove some more old IRQ extcon stuff (suggested by Chanwoo
>Choi).
> 3. Patch 6: minor fixes over defines (suggested by Lee Jones).
> 4. Send last patch, previously it slipped during "git send-email".
> 5. Add acks obtained for v1. I still need more of them.
>
>
> Rationale
> =
> The recently added max77843 regulator driver is very similar to
> its older brother: the max77693. Both devices provide two safeouts
> and a charger.
>
> The main difference is in charger's output capabilities and related
> registry values.
>
> With some code additions the max77693 regulator driver can support both
> chipsets. This reduces overall code duplication and is a first step
> toward integrating other drivers for these devices. I plan to merge
> also input/haptic drivers.
>
>
> Patchset description
> 
> Patches 1-2 do various cleanup.
> Patch 3 prepares max77694 regulator driver for supporting different
> devices.
> Patch 4 switches max77693 drivers to common state container.
> Patch 5 updates max77843 drivers to common state container.
> Patches 6-7 do final cleanup before merging.
> Patches 8-9 do the merge of max77843 regulator into max77693.
>
>
> Dependencies
> 
> Everything is bisectable but next patches depend on previous ones.
> So probably the easiest way would be picking picked up by one
> maintainer.
>
>
> Best regards,
> Krzysztof
>
> Krzysztof Kozlowski (9):
>   mfd/extcon: max77693: Remove unused extern declarations and
> max77693_dev members
>   mfd: max77693: Store I2C device type as enum and add default unknown
>   regulator: max77693: Support different register configurations
>   extcon/input/mfd/power/regulator: max77693: Move state container to
> common header
>   extcon/input/mfd/regulator: max77843: Switch to common max77693 state
> container
>   mfd/extcon: max77693: Rename defines to allow inclusion with max77843
>   mfd/extcon: max77843: Rename defines to allow inclusion with max77693
>   regulator: max77693: Add support for MAX77843 device
>   regulator: Remove the max77843 driver
>
>  drivers/extcon/extcon-max77693.c |  94 +++-
>  drivers/extcon/extcon-max77843.c |  66 +++-
>  drivers/input/misc/max77693-haptic.c |   1 +
>  drivers/input/misc/max77843-haptic.c |   3 +-
>  drivers/mfd/max77693.c   |  31 +++---
>  drivers/mfd/max77843.c   |  20 ++--
>  drivers/power/max77693_charger.c |   1 +
>  drivers/regulator/Kconfig|  16 +--
>  drivers/regulator/Makefile   |   1 -
>  drivers/regulator/max77693.c | 161 
>  drivers/regulator/max77843.c | 201 
> ---
>  include/linux/mfd/max77693-common.h  |  49 +
>  include/linux/mfd/max77693-private.h | 134 +--
>  include/linux/mfd/max77843-private.h | 174 ++
>  14 files changed, 432 insertions(+), 520 deletions(-)
>  delete mode 100644 drivers/regulator/max77843.c
>  create mode 100644 include/linux/mfd/max77693-common.h
>
> --
> 2.1.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH 4/4] vhost: Add cgroup-aware creation of worker threads

2015-07-12 Thread Bandan Das
With the help of the cgroup function to compare groups introduced
in the previous patch, this changes worker creation policy.
If the new device belongs to different cgroups than any of the
devices we are currently serving, we end up creating a new worker
thread even if we haven't reached the devs_per_worker threshold

Signed-off-by: Bandan Das 
---
 drivers/vhost/vhost.c | 47 +++
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 6a5d4c0..dc0fa37 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -261,12 +261,6 @@ static int vhost_worker(void *data)
use_mm(dev->mm);
}
 
-   /* TODO: Consider a more elegant solution */
-   if (worker->owner != dev->owner) {
-   /* Should check for return value */
-   cgroup_attach_task_all(dev->owner, current);
-   worker->owner = dev->owner;
-   }
work->fn(work);
if (need_resched())
schedule();
@@ -278,6 +272,36 @@ static int vhost_worker(void *data)
return 0;
 }
 
+struct vhost_attach_cgroups_struct {
+   struct vhost_work work;
+   struct task_struct *owner;
+   int ret;
+};
+
+static void vhost_attach_cgroups_work(struct vhost_work *work)
+{
+   struct vhost_attach_cgroups_struct *s;
+
+   s = container_of(work, struct vhost_attach_cgroups_struct, work);
+   s->ret = cgroup_attach_task_all(s->owner, current);
+}
+
+static void vhost_attach_cgroups(struct vhost_dev *dev,
+   struct vhost_worker *worker)
+{
+   struct vhost_attach_cgroups_struct attach;
+
+   attach.owner = dev->owner;
+   vhost_work_init(dev, , vhost_attach_cgroups_work);
+   vhost_work_queue(worker, );
+   vhost_work_flush(worker, );
+
+   if (!attach.ret)
+   worker->owner = dev->owner;
+
+   dev->err = attach.ret;
+}
+
 static void vhost_create_worker(struct vhost_dev *dev)
 {
struct vhost_worker *worker;
@@ -300,8 +324,14 @@ static void vhost_create_worker(struct vhost_dev *dev)
 
spin_lock_init(>work_lock);
INIT_LIST_HEAD(>work_list);
+
+   /* attach to the cgroups of the process that created us */
+   vhost_attach_cgroups(dev, worker);
+   if (dev->err)
+   goto therror;
+   worker->owner = dev->owner;
+
list_add(>node, >workers);
-   worker->owner = NULL;
worker->num_devices++;
total_vhost_workers++;
dev->worker = worker;
@@ -320,7 +350,8 @@ static int vhost_dev_assign_worker(struct vhost_dev *dev)
 
mutex_lock(_pool->pool_lock);
list_for_each_entry(worker, _pool->workers, node) {
-   if (worker->num_devices < devs_per_worker) {
+   if (worker->num_devices < devs_per_worker &&
+   (!cgroup_match_groups(dev->owner, worker->owner))) {
dev->worker = worker;
dev->worker_assigned = true;
worker->num_devices++;
-- 
2.4.3

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


Re: [Patch V5 13/16] xen: add explicit memblock_reserve() calls for special pages

2015-07-12 Thread Juergen Gross

On 07/10/2015 03:36 PM, Konrad Rzeszutek Wilk wrote:

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 1982617..c28f7f7 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2084,6 +2084,19 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, 
unsigned long max_pfn)
  }
  #endif/* CONFIG_X86_64 */

+void __init xen_reserve_special_pages(void)
+{
+   phys_addr_t paddr;
+
+   memblock_reserve(__pa(xen_start_info), PAGE_SIZE);
+   if (!xen_initial_domain()) {
+   paddr = PFN_PHYS(mfn_to_pfn(xen_start_info->store_mfn));
+   memblock_reserve(paddr, PAGE_SIZE);
+   paddr = PFN_PHYS(mfn_to_pfn(xen_start_info->console.domU.mfn));
+   memblock_reserve(paddr, PAGE_SIZE);
+   }


I believe we can start an MiniOS as the 'dom0' (so first domain), and then
Linux right after as the 'dom1' (semi-dom0?). In which case XenStore would
be actually available.


And this dom1 would still be the "initial domain" (SIF_INITDOMAIN set)?

I couldn't spot other Xen usage of this flag as the one in the
hypervisor when constructing the "real" initial domain.


Is there an way to figure out whether these mfns are valid and just
piggyback on that?


For store_mfn: yes (it's initialized to 0 by the hypervisor).

The console mfn: no, as the console info is a union which will hold
different information in case of the initial domain.


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


Crypto Fixes for 4.2

2015-07-12 Thread Herbert Xu
Hi Linus:

This push fixes a duplicate dma_unmap_sg call in omap-des and
reentrancy bugs in the powerpc nx driver which may cause bogus
output or worse memory corruption.


Please pull from

git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git


Herbert Xu (1):
  crypto: nx - Fix reentrancy bugs

Vutla, Lokesh (1):
  crypto: omap-des - Fix unmapping of dma channels

 drivers/crypto/nx/nx-aes-ccm.c  |6 ++--
 drivers/crypto/nx/nx-aes-ctr.c  |7 ++--
 drivers/crypto/nx/nx-aes-gcm.c  |   17 ++
 drivers/crypto/nx/nx-aes-xcbc.c |   70 ---
 drivers/crypto/nx/nx-sha256.c   |   43 +---
 drivers/crypto/nx/nx-sha512.c   |   44 +---
 drivers/crypto/nx/nx.c  |3 ++
 drivers/crypto/nx/nx.h  |   14 ++--
 drivers/crypto/omap-des.c   |3 --
 9 files changed, 125 insertions(+), 82 deletions(-)

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH 3/4] cgroup: Introduce a function to compare cgroups

2015-07-12 Thread Bandan Das
This function takes two tasks and iterates through all
hierarchies to check if they belong to the same cgroups.
It ignores the check for default hierarchies or for
hierarchies with no subsystems attached. This function
will be used by the next patch to add rudimentary cgroup support
with vhost workers.

Signed-off-by: Bandan Das 
---
 include/linux/cgroup.h |  1 +
 kernel/cgroup.c| 40 
 2 files changed, 41 insertions(+)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index b9cb94c..606fb5b 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -933,6 +933,7 @@ void css_task_iter_start(struct cgroup_subsys_state *css,
 struct task_struct *css_task_iter_next(struct css_task_iter *it);
 void css_task_iter_end(struct css_task_iter *it);
 
+int cgroup_match_groups(struct task_struct *tsk1, struct task_struct *tsk2);
 int cgroup_attach_task_all(struct task_struct *from, struct task_struct *);
 int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from);
 
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 469dd54..ba4121e 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2465,6 +2465,46 @@ out_unlock_cgroup:
 }
 
 /**
+ * cgroup_match_groups - check if tsk1 and tsk2 belong to
+ * same cgroups in all hierarchies
+ * Returns 0 on success
+ */
+int cgroup_match_groups(struct task_struct *tsk1, struct task_struct *tsk2)
+{
+   struct cgroup_root *root;
+   int retval = 0;
+
+   WARN_ON(!tsk1 || !tsk2);
+
+   mutex_lock(_mutex);
+   for_each_root(root) {
+   struct cgroup *cg_tsk1;
+   struct cgroup *cg_tsk2;
+
+   /* Default hierarchy */
+   if (root == _dfl_root)
+   continue;
+   /* No subsystems attached */
+   if (!root->subsys_mask)
+   continue;
+
+   down_read(_set_rwsem);
+   cg_tsk1 = task_cgroup_from_root(tsk1, root);
+   cg_tsk2 = task_cgroup_from_root(tsk2, root);
+   up_read(_set_rwsem);
+
+   if (cg_tsk1 != cg_tsk2) {
+   retval = 1;
+   break;
+   }
+   }
+   mutex_unlock(_mutex);
+
+   return retval;
+}
+EXPORT_SYMBOL_GPL(cgroup_match_groups);
+
+/**
  * cgroup_attach_task_all - attach task 'tsk' to all cgroups of task 'from'
  * @from: attach to all cgroups of a given task
  * @tsk: the task to be attached
-- 
2.4.3

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


[RFC PATCH 2/4] vhost: Limit the number of devices served by a single worker thread

2015-07-12 Thread Bandan Das
When the number of devices increase, the universal thread model
(introduced in the preceding patch) may end up being the bottleneck.
Moreover, a single worker thread also forces us to change cgroups
based on the device we are serving.

We introduce a worker pool struct that starts with one worker
thread and we keep adding more threads when the numbers of devs
reaches a certain threshold. The default value is set at 7 but is
not based on any empirical data. The value can also be changed by
the user with the devs_per_worker module parameter.

Note that this patch doesn't change how cgroups work. We still
keep moving around the worker thread to the cgroups of the
device we are serving at the moment.

Signed-off-by: Razya Ladelsky 
Signed-off-by: Bandan Das 
---
 drivers/vhost/net.c   |   6 +--
 drivers/vhost/scsi.c  |   3 +-
 drivers/vhost/vhost.c | 135 +-
 drivers/vhost/vhost.h |  13 -
 4 files changed, 128 insertions(+), 29 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 7d137a4..7bfa019 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -705,7 +705,8 @@ static int vhost_net_open(struct inode *inode, struct file 
*f)
n->vqs[i].vhost_hlen = 0;
n->vqs[i].sock_hlen = 0;
}
-   vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
+   if (vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX))
+   return dev->err;
 
vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, POLLOUT, dev);
vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, POLLIN, dev);
@@ -801,9 +802,6 @@ static int vhost_net_release(struct inode *inode, struct 
file *f)
sockfd_put(rx_sock);
/* Make sure no callbacks are outstanding */
synchronize_rcu_bh();
-   /* We do an extra flush before freeing memory,
-* since jobs can re-queue themselves. */
-   vhost_net_flush(n);
kfree(n->dev.vqs);
kvfree(n);
return 0;
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 6c42936..97de2db 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -1601,7 +1601,8 @@ static int vhost_scsi_open(struct inode *inode, struct 
file *f)
vqs[i] = >vqs[i].vq;
vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
}
-   vhost_dev_init(>dev, vqs, VHOST_SCSI_MAX_VQ);
+   if (vhost_dev_init(>dev, vqs, VHOST_SCSI_MAX_VQ))
+   return vs->dev.err;
 
vhost_scsi_init_inflight(vs, NULL);
 
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 951c96b..6a5d4c0 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -27,11 +27,19 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vhost.h"
 
-/* Just one worker thread to service all devices */
-static struct vhost_worker *worker;
+static int __read_mostly devs_per_worker = 7;
+module_param(devs_per_worker, int, S_IRUGO);
+MODULE_PARM_DESC(devs_per_worker, "Setup the number of devices being served by 
a worker thread");
+
+/* Only used to give a unique id to a vhost thread at the moment */
+static unsigned int total_vhost_workers;
+
+/* Pool of vhost threads */
+static struct vhost_pool *vhost_pool;
 
 enum {
VHOST_MEMORY_MAX_NREGIONS = 64,
@@ -270,6 +278,63 @@ static int vhost_worker(void *data)
return 0;
 }
 
+static void vhost_create_worker(struct vhost_dev *dev)
+{
+   struct vhost_worker *worker;
+   struct vhost_pool *pool = vhost_pool;
+
+   worker = kzalloc(sizeof(*worker), GFP_KERNEL);
+   if (!worker) {
+   dev->err = -ENOMEM;
+   return;
+   }
+
+   worker->thread = kthread_create(vhost_worker,
+   worker,
+   "vhost-%d",
+   total_vhost_workers);
+   if (IS_ERR(worker->thread)) {
+   dev->err = PTR_ERR(worker->thread);
+   goto therror;
+   }
+
+   spin_lock_init(>work_lock);
+   INIT_LIST_HEAD(>work_list);
+   list_add(>node, >workers);
+   worker->owner = NULL;
+   worker->num_devices++;
+   total_vhost_workers++;
+   dev->worker = worker;
+   dev->worker_assigned = true;
+   return;
+
+therror:
+   if (worker->thread)
+   kthread_stop(worker->thread);
+   kfree(worker);
+}
+
+static int vhost_dev_assign_worker(struct vhost_dev *dev)
+{
+   struct vhost_worker *worker;
+
+   mutex_lock(_pool->pool_lock);
+   list_for_each_entry(worker, _pool->workers, node) {
+   if (worker->num_devices < devs_per_worker) {
+   dev->worker = worker;
+   dev->worker_assigned = true;
+   worker->num_devices++;
+   break;
+   }
+   }
+   if (!dev->worker_assigned)
+   /* create a new worker */
+   

[RFC PATCH 1/4] vhost: Introduce a universal thread to serve all users

2015-07-12 Thread Bandan Das
vhost threads are per-device, but in most cases a single thread
is enough. This change creates a single thread that is used to
serve all guests.

However, this complicates cgroups associations. The current policy
is to attach the per-device thread to all cgroups of the parent process
that the device is associated it. This is no longer possible if we
have a single thread. So, we end up moving the thread around to
cgroups of whichever device that needs servicing. This is a very
inefficient protocol but seems to be the only way to integrate
cgroups support.

Signed-off-by: Razya Ladelsky 
Signed-off-by: Bandan Das 
---
 drivers/vhost/scsi.c  |  15 +++--
 drivers/vhost/vhost.c | 150 --
 drivers/vhost/vhost.h |  19 +--
 3 files changed, 97 insertions(+), 87 deletions(-)

diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index ea32b38..6c42936 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -535,7 +535,7 @@ static void vhost_scsi_complete_cmd(struct vhost_scsi_cmd 
*cmd)
 
llist_add(>tvc_completion_list, >vs_completion_list);
 
-   vhost_work_queue(>dev, >vs_completion_work);
+   vhost_work_queue(vs->dev.worker, >vs_completion_work);
 }
 
 static int vhost_scsi_queue_data_in(struct se_cmd *se_cmd)
@@ -1282,7 +1282,7 @@ vhost_scsi_send_evt(struct vhost_scsi *vs,
}
 
llist_add(>list, >vs_event_list);
-   vhost_work_queue(>dev, >vs_event_work);
+   vhost_work_queue(vs->dev.worker, >vs_event_work);
 }
 
 static void vhost_scsi_evt_handle_kick(struct vhost_work *work)
@@ -1335,8 +1335,8 @@ static void vhost_scsi_flush(struct vhost_scsi *vs)
/* Flush both the vhost poll and vhost work */
for (i = 0; i < VHOST_SCSI_MAX_VQ; i++)
vhost_scsi_flush_vq(vs, i);
-   vhost_work_flush(>dev, >vs_completion_work);
-   vhost_work_flush(>dev, >vs_event_work);
+   vhost_work_flush(vs->dev.worker, >vs_completion_work);
+   vhost_work_flush(vs->dev.worker, >vs_event_work);
 
/* Wait for all reqs issued before the flush to be finished */
for (i = 0; i < VHOST_SCSI_MAX_VQ; i++)
@@ -1584,8 +1584,11 @@ static int vhost_scsi_open(struct inode *inode, struct 
file *f)
if (!vqs)
goto err_vqs;
 
-   vhost_work_init(>vs_completion_work, vhost_scsi_complete_cmd_work);
-   vhost_work_init(>vs_event_work, vhost_scsi_evt_work);
+   vhost_work_init(>dev, >vs_completion_work,
+   vhost_scsi_complete_cmd_work);
+
+   vhost_work_init(>dev, >vs_event_work,
+   vhost_scsi_evt_work);
 
vs->vs_events_nr = 0;
vs->vs_events_missed = false;
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 2ee2826..951c96b 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -11,6 +11,8 @@
  * Generic code for virtio server in host kernel.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -28,6 +30,9 @@
 
 #include "vhost.h"
 
+/* Just one worker thread to service all devices */
+static struct vhost_worker *worker;
+
 enum {
VHOST_MEMORY_MAX_NREGIONS = 64,
VHOST_MEMORY_F_LOG = 0x1,
@@ -58,13 +63,15 @@ static int vhost_poll_wakeup(wait_queue_t *wait, unsigned 
mode, int sync,
return 0;
 }
 
-void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn)
+void vhost_work_init(struct vhost_dev *dev,
+struct vhost_work *work, vhost_work_fn_t fn)
 {
INIT_LIST_HEAD(>node);
work->fn = fn;
init_waitqueue_head(>done);
work->flushing = 0;
work->queue_seq = work->done_seq = 0;
+   work->dev = dev;
 }
 EXPORT_SYMBOL_GPL(vhost_work_init);
 
@@ -78,7 +85,7 @@ void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t 
fn,
poll->dev = dev;
poll->wqh = NULL;
 
-   vhost_work_init(>work, fn);
+   vhost_work_init(dev, >work, fn);
 }
 EXPORT_SYMBOL_GPL(vhost_poll_init);
 
@@ -116,30 +123,30 @@ void vhost_poll_stop(struct vhost_poll *poll)
 }
 EXPORT_SYMBOL_GPL(vhost_poll_stop);
 
-static bool vhost_work_seq_done(struct vhost_dev *dev, struct vhost_work *work,
-   unsigned seq)
+static bool vhost_work_seq_done(struct vhost_worker *worker,
+   struct vhost_work *work, unsigned seq)
 {
int left;
 
-   spin_lock_irq(>work_lock);
+   spin_lock_irq(>work_lock);
left = seq - work->done_seq;
-   spin_unlock_irq(>work_lock);
+   spin_unlock_irq(>work_lock);
return left <= 0;
 }
 
-void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work)
+void vhost_work_flush(struct vhost_worker *worker, struct vhost_work *work)
 {
unsigned seq;
int flushing;
 
-   spin_lock_irq(>work_lock);
+   spin_lock_irq(>work_lock);
seq = work->queue_seq;
work->flushing++;
-   spin_unlock_irq(>work_lock);
-   

[RFC PATCH 0/4] Shared vhost design

2015-07-12 Thread Bandan Das
Hello,

There have been discussions on improving the current vhost design. The first
attempt, to my knowledge was Shirley Ma's patch to create a dedicated vhost
worker per cgroup.

http://comments.gmane.org/gmane.linux.network/224730

Later, I posted a cmwq based approach for performance comparisions
http://comments.gmane.org/gmane.linux.network/286858

More recently was the Elvis work that was presented in KVM Forum 2013
http://www.linux-kvm.org/images/a/a3/Kvm-forum-2013-elvis.pdf

The Elvis patches rely on common vhost thread design for scalability
along with polling for performance. Since there are two major changes
being proposed, we decided to split up the work. The first (this RFC),
proposing a re-design of the vhost threading model and the second part
(not posted yet) to focus more on improving performance. 

I am posting this with the hope that we can have a meaningful discussion
on the proposed new architecture. We have run some tests to show that the new
design is scalable and in terms of performance, is comparable to the current
stable design. 

Test Setup:
The testing is based on the setup described in the Elvis proposal.
The initial tests are just an aggregate of Netperf STREAM and MAERTS but
as we progress, I am happy to run more tests. The hosts are two identical
16 core Haswell systems with point to point network links. For the first 10 
runs,
with n=1 upto n=10 guests running in parallel, I booted the target system with 
nr_cpus=8
and mem=12G. The purpose was to do a comparision of resource utilization
and how it affects performance. Finally, with the number of guests set at 14,
I didn't limit the number of CPUs booted on the host or limit memory seen by
the kernel but boot the kernel with isolcpus=14,15 that will be used to run
the vhost threads. The guests are pinned to cpus 0-13 and based on which
cpu the guest is running on, the corresponding I/O thread is either pinned
to cpu 14 or 15.

Results
# X axis is number of guests
# Y axis is netperf number
# nr_cpus=8 and mem=12G
#Number of Guests#Baseline#ELVIS
11119.3   .0
21135.6   1130.2
31135.5   1131.6
41136.0   1127.1
51118.6   1129.3
61123.4   1129.8
71128.7   1135.4
81129.9   1137.5
91130.6   1135.1
10   1129.3   1138.9
14*  1173.8   1216.9

#* Last run with the vCPU and I/O thread(s) pinned, no CPU/memory limit imposed.
#  I/O thread runs on CPU 14 or 15 depending on which guest it's serving

There's a simple graph at
http://people.redhat.com/~bdas/elvis/data/results.png
that shows how task affinity results in a jump and even without it,
as the number of guests increase, the shared vhost design performs
slightly better.

Observations:
1. In terms of "stock" performance, the results are comparable.
2. However, with a tuned setup, even without polling, we see an improvement
with the new design.
3. Making the new design simulate old behavior would be a matter of setting
the number of guests per vhost threads to 1.
4. Maybe, setting a per guest limit on the work being done by a specific vhost
thread is needed for it to be fair.
5. cgroup associations needs to be figured out. I just slightly hacked the
current cgroup association mechanism to work with the new model. Ccing cgroups
for input/comments.

Many thanks to Razya Ladelsky and Eyal Moscovici, IBM for the initial
patches, the helpful testing suggestions and discussions.

Bandan Das (4):
  vhost: Introduce a universal thread to serve all users
  vhost: Limit the number of devices served by a single worker thread
  cgroup: Introduce a function to compare cgroups
  vhost: Add cgroup-aware creation of worker threads

 drivers/vhost/net.c|   6 +-
 drivers/vhost/scsi.c   |  18 ++--
 drivers/vhost/vhost.c  | 272 +++--
 drivers/vhost/vhost.h  |  32 +-
 include/linux/cgroup.h |   1 +
 kernel/cgroup.c|  40 
 6 files changed, 275 insertions(+), 94 deletions(-)

-- 
2.4.3

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


Re: [PATCH 2/7] tty: core: Add tty_debug() for printk(KERN_DEBUG) messages

2015-07-12 Thread Joe Perches
On Sun, 2015-07-12 at 22:49 -0400, Peter Hurley wrote:
> Introduce tty_debug() macro to output uniform debug information for
> tty core debug messages (function name and tty name).
[]
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
[]
> @@ -768,7 +768,7 @@ static void do_tty_hangup(struct work_struct *work)
>  void tty_hangup(struct tty_struct *tty)
>  {
>  #ifdef TTY_DEBUG_HANGUP
> - printk(KERN_DEBUG "%s hangup...\n", tty_name(tty));
> + tty_debug(tty, "\n");

Why drop the "hangup..." ?

> diff --git a/include/linux/tty.h b/include/linux/tty.h
[]
> +#define tty_debug(tty, f, args...)   \
> + do {\
> + printk(KERN_DEBUG "%s: %s: " f, __func__,   \
> +tty_name(tty), ##args);  \
> + } while (0)

Single statement macros don't need do {} while (0)

#define fmt, ... 
using fmt, ##__VA_ARGS__

is more common.

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


[PATCH] Doc: pps: Fix file name in pps.txt

2015-07-12 Thread Masanari Iida
This patch fix a file name of example code.

Signed-off-by: Masanari Iida 
---
 Documentation/pps/pps.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/pps/pps.txt b/Documentation/pps/pps.txt
index c508cce..7cb7264 100644
--- a/Documentation/pps/pps.txt
+++ b/Documentation/pps/pps.txt
@@ -125,7 +125,7 @@ The same function may also run the defined echo function
 (pps_ktimer_echo(), passing to it the "ptr" pointer) if the user
 asked for that... etc..
 
-Please see the file drivers/pps/clients/ktimer.c for example code.
+Please see the file drivers/pps/clients/pps-ktimer.c for example code.
 
 
 SYSFS support
-- 
2.5.0.rc1

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


Re: [PATCH v3 5/5] arm64: dts: mt8173: Add subsystem clock controller device nodes

2015-07-12 Thread James Liao
Hi Daniel,

On Fri, 2015-07-10 at 23:02 +0800, Daniel Kurtz wrote:
> > diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > index a2f63e4..9d74ce5 100644
> > --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > @@ -227,6 +227,36 @@
> > clocks = <_clk>;
> > status = "disabled";
> > };
> > +
> > +   mmsys: mmsys@1400 {
> 
> I think we agreed previously that these should all be
> clock-controller@.
> 
You're right. I'll change it in next patch.


Best regards,

James

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


Re: [PATCH v3 05/11] usb: hcd.h: Add OTG to HCD interface

2015-07-12 Thread Peter Chen
On Wed, Jul 08, 2015 at 01:19:31PM +0300, Roger Quadros wrote:
> The OTG core will use struct otg_hcd_ops to
> add/remove the HCD controller.
> 
> The main purpose of this interface is to avoid directly
> calling usb_add/remove_hcd() from the OTG core as they
> wouldn't be defined in the built-in symbol table if
> CONFIG_USB is m.
> 

Like patch 4, Would you let the OTG depends on HCD?
OTG needs dual-role, it is reasonable.

Peter

> Signed-off-by: Roger Quadros 
> ---
>  include/linux/usb/hcd.h | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
> index c9aa779..4108288 100644
> --- a/include/linux/usb/hcd.h
> +++ b/include/linux/usb/hcd.h
> @@ -386,6 +386,20 @@ struct hc_driver {
>  
>  };
>  
> +/**
> + * struct otg_hcd_ops - Interface between OTG core and HCD
> + *
> + * Provided by the HCD core to allow the OTG core to start/stop the HCD
> + *
> + * @add: function to add the HCD
> + * @remove: function to remove the HCD
> + */
> +struct otg_hcd_ops {
> + int (*add)(struct usb_hcd *hcd,
> +unsigned int irqnum, unsigned long irqflags);
> + void (*remove)(struct usb_hcd *hcd);
> +};
> +
>  static inline int hcd_giveback_urb_in_bh(struct usb_hcd *hcd)
>  {
>   return hcd->driver->flags & HCD_BH;
> -- 
> 2.1.4
> 

-- 

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


Re: [PATCH v2] net: dsa: mv88e6xxx: add write access to debugfs regs file

2015-07-12 Thread David Miller
From: Vivien Didelot 
Date: Sun, 12 Jul 2015 21:39:30 -0400 (EDT)

> I hardly see how this debug interface can be made generic to other
> DSA drivers, since the format of hardware tables or some registers
> seem very specific to the switch chip.

You feel this way because you are focusing on register values and not what
those values represent.

Ie. could you export the values in those registers in a generic format
that other devices could convert their register values to as well?

Stop focusing so tightly on the exact thing you've implemented and
consider things on a much higher level.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 07/11] usb: otg: add OTG core

2015-07-12 Thread Peter Chen
On Wed, Jul 08, 2015 at 01:19:33PM +0300, Roger Quadros wrote:
> The OTG core instantiates the OTG Finite State Machine
> per OTG controller and manages starting/stopping the
> host and gadget controllers based on the bus state.
> 
> It provides APIs for the following tasks
> 
> - Registering an OTG capable controller
> - Registering Host and Gadget controllers to OTG core
> - Providing inputs to and kicking the OTG state machine
> 
> Signed-off-by: Roger Quadros 
> ---
>  MAINTAINERS  |   4 +-
>  drivers/usb/Kconfig  |   2 +-
>  drivers/usb/Makefile |   1 +
>  drivers/usb/common/Makefile  |   3 +-
>  drivers/usb/common/usb-otg.c | 768 
> +++
>  drivers/usb/common/usb-otg.h |  71 
>  drivers/usb/core/Kconfig |  11 +-
>  include/linux/usb/otg.h  |  91 -
>  8 files changed, 930 insertions(+), 21 deletions(-)
>  create mode 100644 drivers/usb/common/usb-otg.c
>  create mode 100644 drivers/usb/common/usb-otg.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 8133cef..b21278e 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -10640,12 +10640,14 @@ S:  Maintained
>  F:   Documentation/usb/ohci.txt
>  F:   drivers/usb/host/ohci*
>  
> -USB OTG FSM (Finite State Machine)
> +USB OTG/DRD core and FSM (Finite State Machine)
>  M:   Peter Chen 
> +M:   Roger Quadros 
>  T:   git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git
>  L:   linux-...@vger.kernel.org
>  S:   Maintained
>  F:   drivers/usb/common/usb-otg-fsm.c
> +F:   drivers/usb/common/usb-otg.c
>  
>  USB OVER IP DRIVER
>  M:   Valentina Manea 
> diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
> index 8ed451d..5b625e2 100644
> --- a/drivers/usb/Kconfig
> +++ b/drivers/usb/Kconfig
> @@ -32,7 +32,7 @@ if USB_SUPPORT
>  config USB_COMMON
>   tristate
>   default y
> - depends on USB || USB_GADGET
> + depends on USB || USB_GADGET || USB_OTG
>  

USB_OTG can depends on USB || UB_GADGET?

>  config USB_ARCH_HAS_HCD
>   def_bool y
> diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
> index d8926c6..769d13b 100644
> --- a/drivers/usb/Makefile
> +++ b/drivers/usb/Makefile
> @@ -60,5 +60,6 @@ obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/
>  obj-$(CONFIG_USB_GADGET) += gadget/
>  
>  obj-$(CONFIG_USB_COMMON) += common/
> +obj-$(CONFIG_USB_OTG)+= common/
>  

The comment like above.

>  obj-$(CONFIG_USBIP_CORE) += usbip/
> diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
> index 6bbb3ec..730d928 100644
> --- a/drivers/usb/common/Makefile
> +++ b/drivers/usb/common/Makefile
> @@ -6,5 +6,6 @@ obj-$(CONFIG_USB_COMMON)+= usb-common.o
>  usb-common-y   += common.o
>  usb-common-$(CONFIG_USB_LED_TRIG) += led.o
>  
> -obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
>  obj-$(CONFIG_USB_ULPI_BUS)   += ulpi.o
> +usbotg-y := usb-otg.o usb-otg-fsm.o
> +obj-$(CONFIG_USB_OTG)+= usbotg.o
> diff --git a/drivers/usb/common/usb-otg.c b/drivers/usb/common/usb-otg.c
> new file mode 100644
> index 000..0379034
> --- /dev/null
> +++ b/drivers/usb/common/usb-otg.c
> @@ -0,0 +1,768 @@
> +/**
> + * drivers/usb/common/usb-otg.c - USB OTG core
> + *
> + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
> + * Author: Roger Quadros 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include/* enum usb_otg_state */
> +#include 
> +#include 
> +
> +#include "usb-otg.h"
> +
> +/* to link timer with callback data */
> +struct otg_timer {
> + struct hrtimer timer;
> + ktime_t timeout;
> + /* callback data */
> + int *timeout_bit;
> + struct otg_data *otgd;
> +};
> +
> +struct otg_hcd {
> + struct usb_hcd *hcd;
> + unsigned int irqnum;
> + unsigned long irqflags;
> + struct otg_hcd_ops *ops;
> +};
> +
> +struct otg_data {
> + struct device *dev; /* HCD & GCD's parent device */
> +
> + struct otg_fsm fsm;
> + /* HCD, GCD and usb_otg_state are present in otg_fsm->otg
> +  * HCD is bus_to_hcd(fsm->otg->host)
> +  * GCD is fsm->otg->gadget
> +  */
> + struct otg_fsm_ops fsm_ops; /* private copy for override */
> + struct usb_otg otg; /* allocator for fsm->otg */
> +
> + struct otg_hcd primary_hcd;
> + struct otg_hcd shared_hcd;
> +
> + struct otg_gadget_ops *gadget_ops; /* interface to gadget f/w */
> +
> + /* saved hooks to OTG device */
> + int 

Re: [3/3] IRQ: Print "unexpected IRQ" messages consistently across architectures

2015-07-12 Thread Michael Ellerman
On Sun, 2015-12-07 at 22:02:11 UTC, Bjorn Helgaas wrote:
> Many architectures use a variant of "unexpected IRQ trap at vector %x" to
> log unexpected IRQs.  This is confusing because (a) it prints the Linux IRQ
> number, but "vector" more often refers to a CPU vector number, and (b) it
> prints the IRQ number in hex with no base indication, while Linux IRQ
> numbers are usually printed in decimal.
> 
> Print the same text ("unexpected IRQ %d") across all architectures.
> 
> No functional change other than the output text.

There's already a fallback version in asm-generic, so shouldn't you instead
just delete all the versions that are identical to that?

eg. on powerpc we have:

>  static inline void ack_bad_irq(unsigned int irq)
>  {
> - printk(KERN_CRIT "unexpected IRQ trap at vector %02x\n", irq);
> + printk(KERN_CRIT "unexpected IRQ %d\n", irq);
>  }

And the generic version is:

>  #ifndef ack_bad_irq
>  static inline void ack_bad_irq(unsigned int irq)
>  {
> - printk(KERN_CRIT "unexpected IRQ trap at vector %02x\n", irq);
> + printk(KERN_CRIT "unexpected IRQ %d\n", irq);
>  }
>  #endif

So we can just delete the powerpc version?

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


linux-next: build warning after merge of the sound-asoc tree

2015-07-12 Thread Stephen Rothwell
Hi all,

After merging the sound-asoc tree, today's linux-next build (powerpc
allyesconfig) produced this warning:

warning: (SND_SOC_ALL_CODECS) selects SND_SOC_STI_SAS which has unmet direct 
dependencies (SOUND && !M68K && !UML && SND && SND_SOC && SND_SOC_STI)

Introduced by commit

  32a726b2e089 ("ASoC: sti-sas: Add sti platform codec")

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


pgpOycbWXuY8L.pgp
Description: OpenPGP digital signature


Re: [PATCH v3 04/11] otg-fsm: move usb_bus_start_enum into otg-fsm->ops

2015-07-12 Thread Peter Chen
On Wed, Jul 08, 2015 at 01:19:30PM +0300, Roger Quadros wrote:
> This is to prevent missing symbol build error if OTG is
> enabled (built-in) and HCD core (CONFIG_USB) is module.
> 

We may let the OTG-DRD/OTG-FSM depends on CONFIG_USB to fix it.

Peter

> Signed-off-by: Roger Quadros 
> ---
>  drivers/usb/common/usb-otg-fsm.c | 6 --
>  drivers/usb/phy/phy-fsl-usb.c| 2 ++
>  include/linux/usb/otg-fsm.h  | 1 +
>  3 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/common/usb-otg-fsm.c 
> b/drivers/usb/common/usb-otg-fsm.c
> index 1873eb3..156fd25 100644
> --- a/drivers/usb/common/usb-otg-fsm.c
> +++ b/drivers/usb/common/usb-otg-fsm.c
> @@ -166,8 +166,10 @@ static int otg_set_state(struct otg_fsm *fsm, enum 
> usb_otg_state new_state)
>   otg_loc_conn(fsm, 0);
>   otg_loc_sof(fsm, 1);
>   otg_set_protocol(fsm, PROTO_HOST);
> - usb_bus_start_enum(fsm->otg->host,
> - fsm->otg->host->otg_port);
> + if (fsm->ops->start_enum) {
> + fsm->ops->start_enum(fsm->otg->host,
> +  fsm->otg->host->otg_port);
> + }
>   break;
>   case OTG_STATE_A_IDLE:
>   otg_drv_vbus(fsm, 0);
> diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
> index ee3f2c2..19541ed 100644
> --- a/drivers/usb/phy/phy-fsl-usb.c
> +++ b/drivers/usb/phy/phy-fsl-usb.c
> @@ -783,6 +783,8 @@ static struct otg_fsm_ops fsl_otg_ops = {
>  
>   .start_host = fsl_otg_start_host,
>   .start_gadget = fsl_otg_start_gadget,
> +
> + .start_enum = usb_bus_start_enum,
>  };
>  
>  /* Initialize the global variable fsl_otg_dev and request IRQ for OTG */
> diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h
> index c631dde..22d8baa 100644
> --- a/include/linux/usb/otg-fsm.h
> +++ b/include/linux/usb/otg-fsm.h
> @@ -198,6 +198,7 @@ struct otg_fsm_ops {
>   void(*del_timer)(struct otg_fsm *fsm, enum otg_fsm_timer timer);
>   int (*start_host)(struct otg_fsm *fsm, int on);
>   int (*start_gadget)(struct otg_fsm *fsm, int on);
> + int (*start_enum)(struct usb_bus *bus, unsigned port_num);
>  };
>  
>  
> -- 
> 2.1.4
> 

-- 

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


Re: [PATCH 1/2] power: reset: at91: add sama5d3 reset function

2015-07-12 Thread Josh Wu

On 7/11/2015 12:12 AM, Nicolas Ferre wrote:

Le 10/07/2015 14:31, Maxime Ripard a écrit :

On Fri, Jul 10, 2015 at 02:09:07PM +0200, Alexandre Belloni wrote:

Hi,

On 10/07/2015 at 15:56:52 +0800, Josh Wu wrote :

I would agree with Maxime. Currently all latest chip reset function is
compatible with the atmel,sama5d3-rstc.
So check compatible string is enough for now.
But of cause if we have other incompatible reset in future with new chip,
the structure like you said is needed.

We managed to avoid using of_machine_is_compatible() in all the at91
drivers. I'd like to keep it that way. It was painful enough to remove
all those cpu_is_at91xxx calls.

That's your call...


Also, using it is trying to match strings and will result in longer boot
times.

Have you looked at the implementation of of_match_device? If that's
really a concern to you, you should actually avoid it.

I agree: let's keep it simple and use of_match_device().


Ok. I will keep it as it is now:  use the (match->data != 
sama5d3_restart) for the condition.


About the of_match_device(), I prefer to keep not changing the code and 
still use of_match_node().
Since of_match_device() is a wrapper for the of_match_node(). And 
dev->of_node and at91_reset_of_match is valid, so we can just use 
of_match_node() directly.


Is it sound okay for us?

Best Regards,
Josh Wu



Bye,


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


Re: [PATCH v2 01/13] ARM: kill off set_irq_flags usage

2015-07-12 Thread Shawn Guo
On Sun, Jul 12, 2015 at 09:26:39AM -0500, Rob Herring wrote:
> set_irq_flags is ARM specific with custom flags which have genirq
> equivalents. Convert drivers to use the genirq interfaces directly, so we
> can kill off set_irq_flags. The translation of flags is as follows:
> 
> IRQF_VALID -> !IRQ_NOREQUEST
> IRQF_PROBE -> !IRQ_NOPROBE
> IRQF_NOAUTOEN -> IRQ_NOAUTOEN
> 
> For IRQs managed by an irqdomain, the irqdomain core code handles clearing
> and setting IRQ_NOREQUEST already, so there is no need to do this in
> .map() functions and we can simply remove the set_irq_flags calls. Some
> users also set IRQ_NOPROBE and this has been maintained although it is not
> clear that is really needed. There appears to be a great deal of blind
> copy and paste of this code.
> 
> Signed-off-by: Rob Herring 
> Cc: Russell King 
> Cc: Sekhar Nori 
> Cc: Kevin Hilman 
> Cc: Jason Cooper 
> Cc: Andrew Lunn 
> Cc: Sebastian Hesselbarth 
> Cc: Gregory Clement 
> Acked-by: Hans Ulli Kroll 
> Cc: Shawn Guo 
> Cc: Sascha Hauer 
> Cc: Imre Kaloz 
> Acked-by: Krzysztof Halasa 
> Cc: Greg Ungerer 
> Cc: Roland Stigge 
> Cc: Tony Lindgren 
> Cc: Daniel Mack 
> Cc: Haojian Zhuang 
> Cc: Robert Jarzmik 
> Cc: Simtec Linux Team 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Acked-by: Wan ZongShun 
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-o...@vger.kernel.org
> Cc: linux-samsung-...@vger.kernel.org
> Tested-by: Kevin Hilman 
> ---
...
>  arch/arm/mach-imx/3ds_debugboard.c   |  2 +-
>  arch/arm/mach-imx/mach-mx31ads.c |  2 +-

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


Re: [PATCH v3 03/11] usb: otg-fsm: Prevent build warning "VDBG" redefined

2015-07-12 Thread Peter Chen
On Wed, Jul 08, 2015 at 01:19:29PM +0300, Roger Quadros wrote:
> If usb/otg-fsm.h and usb/composite.h are included together
> then it results in the build warning [1].
> 
> Prevent that by using dev_vdbg() instead.
> 
> Also get rid of MPC_LOC which doesn't seem to be used
> by anyone.
> 
> [1] - warning fixed by this patch:
> 
>In file included from drivers/usb/dwc3/core.h:33,
> from drivers/usb/dwc3/ep0.c:33:
>include/linux/usb/otg-fsm.h:30:1: warning: "VDBG" redefined
>In file included from drivers/usb/dwc3/ep0.c:31:
>include/linux/usb/composite.h:615:1: warning: this is the location
>   of the previous definition
> 
> Signed-off-by: Roger Quadros 
> ---
>  drivers/usb/chipidea/otg_fsm.c   |  1 +
>  drivers/usb/common/usb-otg-fsm.c | 12 +++-
>  drivers/usb/phy/phy-fsl-usb.c|  1 +
>  include/linux/usb/otg-fsm.h  | 19 ---
>  4 files changed, 13 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> index 19d655a..6e67f94 100644
> --- a/drivers/usb/chipidea/otg_fsm.c
> +++ b/drivers/usb/chipidea/otg_fsm.c
> @@ -777,6 +777,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
>   ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
>   ci->fsm.otg->state = OTG_STATE_UNDEFINED;
>   ci->fsm.ops = _otg_ops;
> + ci->fsm.dev = ci->dev;
>  
>   mutex_init(>fsm.lock);
>  
> diff --git a/drivers/usb/common/usb-otg-fsm.c 
> b/drivers/usb/common/usb-otg-fsm.c
> index 42c6376..1873eb3 100644
> --- a/drivers/usb/common/usb-otg-fsm.c
> +++ b/drivers/usb/common/usb-otg-fsm.c
> @@ -36,8 +36,9 @@ static int otg_set_protocol(struct otg_fsm *fsm, int 
> protocol)
>   int ret = 0;
>  
>   if (fsm->protocol != protocol) {
> - VDBG("Changing role fsm->protocol= %d; new protocol= %d\n",
> - fsm->protocol, protocol);
> + dev_vdbg(fsm->dev,
> +  "Changing role fsm->protocol= %d; new protocol= %d\n",
> +  fsm->protocol, protocol);
>   /* stop old protocol */
>   if (fsm->protocol == PROTO_HOST)
>   ret = otg_start_host(fsm, 0);
> @@ -124,7 +125,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum 
> usb_otg_state new_state)
>   fsm->state_changed = 1;
>   if (fsm->otg->state == new_state)
>   return 0;
> - VDBG("Set state: %s\n", usb_otg_state_string(new_state));
> + dev_vdbg(fsm->dev, "Set state: %s\n", usb_otg_state_string(new_state));
>   otg_leave_state(fsm, fsm->otg->state);
>   switch (new_state) {
>   case OTG_STATE_B_IDLE:
> @@ -251,7 +252,7 @@ int otg_statemachine(struct otg_fsm *fsm)
>  
>   switch (state) {
>   case OTG_STATE_UNDEFINED:
> - VDBG("fsm->id = %d\n", fsm->id);
> + dev_vdbg(fsm->dev, "fsm->id = %d\n", fsm->id);
>   if (fsm->id)
>   otg_set_state(fsm, OTG_STATE_B_IDLE);
>   else
> @@ -359,7 +360,8 @@ int otg_statemachine(struct otg_fsm *fsm)
>   }
>   mutex_unlock(>lock);
>  
> - VDBG("quit statemachine, changed = %d\n", fsm->state_changed);
> + dev_vdbg(fsm->dev, "quit statemachine, changed = %d\n",
> +  fsm->state_changed);
>   return fsm->state_changed;
>  }
>  EXPORT_SYMBOL_GPL(otg_statemachine);
> diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
> index 94eb292..ee3f2c2 100644
> --- a/drivers/usb/phy/phy-fsl-usb.c
> +++ b/drivers/usb/phy/phy-fsl-usb.c
> @@ -817,6 +817,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
>  
>   /* Set OTG state machine operations */
>   fsl_otg_tc->fsm.ops = _otg_ops;
> + fsl_otg_tc->fsm.dev = >dev;
>  
>   /* initialize the otg structure */
>   fsl_otg_tc->phy.label = DRIVER_DESC;
> diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h
> index 243274f..c631dde 100644
> --- a/include/linux/usb/otg-fsm.h
> +++ b/include/linux/usb/otg-fsm.h
> @@ -18,24 +18,10 @@
>  #ifndef __LINUX_USB_OTG_FSM_H
>  #define __LINUX_USB_OTG_FSM_H
>  
> +#include 
>  #include 
>  #include 
>  
> -#undef VERBOSE
> -
> -#ifdef VERBOSE
> -#define VDBG(fmt, args...) pr_debug("[%s]  " fmt , \
> -  __func__, ## args)
> -#else
> -#define VDBG(stuff...)   do {} while (0)
> -#endif
> -
> -#ifdef VERBOSE
> -#define MPC_LOC printk("Current Location [%s]:[%d]\n", __FILE__, __LINE__)
> -#else
> -#define MPC_LOC do {} while (0)
> -#endif
> -
>  #define PROTO_UNDEF  (0)
>  #define PROTO_HOST   (1)
>  #define PROTO_GADGET (2)
> @@ -195,6 +181,9 @@ struct otg_fsm {
>   int protocol;
>   struct mutex lock;
>   bool state_changed;
> +
> + /* for debug prints */
> + struct device *dev;
>  };
>  
>  struct otg_fsm_ops {
> -- 
> 2.1.4
> 

Acked-by: Peter Chen 

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the 

Re: [PATCH 2/2] ASoC: Drop owner assignment from platform_driver

2015-07-12 Thread Koro Chen
On Fri, 2015-07-10 at 14:30 +0900, Krzysztof Kozlowski wrote:
> platform_driver does not need to set an owner because
> platform_driver_register() will set it.
> 
> Signed-off-by: Krzysztof Kozlowski 
> 

Acked-by: Koro Chen 

Thank you!


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


[PATCH 1/7] tty: core: Improve debug message content

2015-07-12 Thread Peter Hurley
Output the function name, tty name, and invariant failure (if applicable).
Add the tty count to the tty_open() message. Fix the disassociate_ctty()
message, which printed the NULL pointer and the wrong message.

Signed-off-by: Peter Hurley 
---
 drivers/tty/tty_io.c | 29 -
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 57fc6ee..2d9811a 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -524,7 +524,8 @@ static void __proc_set_tty(struct tty_struct *tty)
spin_unlock_irqrestore(>ctrl_lock, flags);
tty->session = get_pid(task_session(current));
if (current->signal->tty) {
-   printk(KERN_DEBUG "tty not NULL!!\n");
+   printk(KERN_DEBUG "%s: %s: current tty %s not NULL!!\n",
+  __func__, tty->name, current->signal->tty->name);
tty_kref_put(current->signal->tty);
}
put_pid(current->signal->tty_old_pgrp);
@@ -922,8 +923,7 @@ void disassociate_ctty(int on_exit)
tty_kref_put(tty);
} else {
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "error attempted to write to tty [0x%p]"
-  " = NULL", tty);
+   printk(KERN_DEBUG "%s: no current tty\n", __func__);
 #endif
}
 
@@ -1705,8 +1705,8 @@ static int tty_release_checks(struct tty_struct *tty, int 
idx)
 {
 #ifdef TTY_PARANOIA_CHECK
if (idx < 0 || idx >= tty->driver->num) {
-   printk(KERN_DEBUG "%s: bad idx when trying to free (%s)\n",
-   __func__, tty->name);
+   printk(KERN_DEBUG "%s: %s: bad idx %d\n",
+   __func__, tty->name, idx);
return -1;
}
 
@@ -1715,20 +1715,22 @@ static int tty_release_checks(struct tty_struct *tty, 
int idx)
return 0;
 
if (tty != tty->driver->ttys[idx]) {
-   printk(KERN_DEBUG "%s: driver.table[%d] not tty for (%s)\n",
-   __func__, idx, tty->name);
+   printk(KERN_DEBUG "%s: %s: bad driver table[%d] = %p\n",
+  __func__, tty->name, idx, tty->driver->ttys[idx]);
return -1;
}
if (tty->driver->other) {
struct tty_struct *o_tty = tty->link;
 
if (o_tty != tty->driver->other->ttys[idx]) {
-   printk(KERN_DEBUG "%s: other->table[%d] not o_tty for 
(%s)\n",
-   __func__, idx, tty->name);
+   printk(KERN_DEBUG "%s: %s: bad other table[%d] = %p\n",
+  __func__, tty->name, idx,
+  tty->driver->other->ttys[idx]);
return -1;
}
if (o_tty->link != tty) {
-   printk(KERN_DEBUG "%s: bad pty pointers\n", __func__);
+   printk(KERN_DEBUG "%s: %s: bad link = %p\n",
+  __func__, tty->name, o_tty->link);
return -1;
}
}
@@ -2099,7 +2101,8 @@ retry_open:
tty->driver->subtype == PTY_TYPE_MASTER)
noctty = 1;
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "%s: opening %s...\n", __func__, tty->name);
+   printk(KERN_DEBUG "%s: %s: (tty count=%d)\n", __func__, tty->name,
+  tty->count);
 #endif
if (tty->ops->open)
retval = tty->ops->open(tty, filp);
@@ -2109,8 +2112,8 @@ retry_open:
 
if (retval) {
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "%s: error %d in opening %s...\n", __func__,
-   retval, tty->name);
+   printk(KERN_DEBUG "%s: %s: error %d, releasing...\n", __func__,
+  tty->name, retval);
 #endif
tty_unlock(tty); /* need to call tty_release without BTM */
tty_release(inode, filp);
-- 
2.4.5

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


[PATCH 3/7] tty: Replace #ifdef TTY_DEBUG_HANGUP with tty_debug_hangup()

2015-07-12 Thread Peter Hurley
Add tty_debug_hangup() macro which uses tty_debug to print the
debug message; remove inlined #ifdefs.

Signed-off-by: Peter Hurley 
---
 drivers/tty/tty_io.c | 47 ++-
 1 file changed, 18 insertions(+), 29 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 6de2c36..acd6988 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -106,6 +106,11 @@
 #include 
 
 #undef TTY_DEBUG_HANGUP
+#ifdef TTY_DEBUG_HANGUP
+# define tty_debug_hangup(tty, f, args...) tty_debug(tty, f, ##args)
+#else
+# define tty_debug_hangup(tty, f, args...) do { } while (0)
+#endif
 
 #define TTY_PARANOIA_CHECK 1
 #define CHECK_TTY_COUNT 1
@@ -767,9 +772,7 @@ static void do_tty_hangup(struct work_struct *work)
 
 void tty_hangup(struct tty_struct *tty)
 {
-#ifdef TTY_DEBUG_HANGUP
-   tty_debug(tty, "\n");
-#endif
+   tty_debug_hangup(tty, "\n");
schedule_work(>hangup_work);
 }
 
@@ -786,9 +789,7 @@ EXPORT_SYMBOL(tty_hangup);
 
 void tty_vhangup(struct tty_struct *tty)
 {
-#ifdef TTY_DEBUG_HANGUP
-   tty_debug(tty, "\n")
-#endif
+   tty_debug_hangup(tty, "\n");
__tty_hangup(tty, 0);
 }
 
@@ -825,9 +826,7 @@ void tty_vhangup_self(void)
 
 static void tty_vhangup_session(struct tty_struct *tty)
 {
-#ifdef TTY_DEBUG_HANGUP
-   tty_debug(tty, "\n");
-#endif
+   tty_debug_hangup(tty, "\n");
__tty_hangup(tty, 1);
 }
 
@@ -921,11 +920,8 @@ void disassociate_ctty(int on_exit)
tty->pgrp = NULL;
spin_unlock_irqrestore(>ctrl_lock, flags);
tty_kref_put(tty);
-   } else {
-#ifdef TTY_DEBUG_HANGUP
-   tty_debug(tty, "no current tty\n");
-#endif
-   }
+   } else
+   tty_debug_hangup(tty, "no current tty\n");
 
spin_unlock_irq(>sighand->siglock);
/* Now clear signal->tty under the lock */
@@ -1781,9 +1777,7 @@ int tty_release(struct inode *inode, struct file *filp)
return 0;
}
 
-#ifdef TTY_DEBUG_HANGUP
-   tty_debug(tty, "(tty count=%d)...\n", tty->count);
-#endif
+   tty_debug_hangup(tty, "(tty count=%d)...\n", tty->count);
 
if (tty->ops->close)
tty->ops->close(tty, filp);
@@ -1893,9 +1887,7 @@ int tty_release(struct inode *inode, struct file *filp)
if (!final)
return 0;
 
-#ifdef TTY_DEBUG_HANGUP
-   tty_debug(tty, "final close\n");
-#endif
+   tty_debug_hangup(tty, "final close\n");
/*
 * Ask the line discipline code to release its structures
 */
@@ -1904,9 +1896,7 @@ int tty_release(struct inode *inode, struct file *filp)
/* Wait for pending work before tty destruction commmences */
tty_flush_works(tty);
 
-#ifdef TTY_DEBUG_HANGUP
-   tty_debug(tty, "freeing structure...\n");
-#endif
+   tty_debug_hangup(tty, "freeing structure...\n");
/*
 * The release_tty function takes care of the details of clearing
 * the slots and preserving the termios structure. The tty_unlock_pair
@@ -2095,9 +2085,9 @@ retry_open:
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
tty->driver->subtype == PTY_TYPE_MASTER)
noctty = 1;
-#ifdef TTY_DEBUG_HANGUP
-   tty_debug(tty, "(tty count=%d)\n", tty->count);
-#endif
+
+   tty_debug_hangup(tty, "(tty count=%d)\n", tty->count);
+
if (tty->ops->open)
retval = tty->ops->open(tty, filp);
else
@@ -2105,9 +2095,8 @@ retry_open:
filp->f_flags = saved_flags;
 
if (retval) {
-#ifdef TTY_DEBUG_HANGUP
-   tty_debug(tty, "error %d, releasing...\n", retval);
-#endif
+   tty_debug_hangup(tty, "error %d, releasing...\n", retval);
+
tty_unlock(tty); /* need to call tty_release without BTM */
tty_release(inode, filp);
if (retval != -ERESTARTSYS)
-- 
2.4.5

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


[PATCH 6/7] tty: core: Improve ldisc debug messages

2015-07-12 Thread Peter Hurley
Add debug messages for ldisc open and close, and remove
"closing ldisc" message from tty_ldisc_release(), because a
close message is now printed for both ldiscs; always print ldisc
pointer first so ldisc changes are easier to identify.

Signed-off-by: Peter Hurley 
---
 drivers/tty/tty_ldisc.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 8191680..71750cb 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -447,6 +447,8 @@ static int tty_ldisc_open(struct tty_struct *tty, struct 
tty_ldisc *ld)
ret = ld->ops->open(tty);
if (ret)
clear_bit(TTY_LDISC_OPEN, >flags);
+
+   tty_ldisc_debug(tty, "%p: opened\n", tty->ldisc);
return ret;
}
return 0;
@@ -467,6 +469,7 @@ static void tty_ldisc_close(struct tty_struct *tty, struct 
tty_ldisc *ld)
clear_bit(TTY_LDISC_OPEN, >flags);
if (ld->ops->close)
ld->ops->close(tty);
+   tty_ldisc_debug(tty, "%p: closed\n", tty->ldisc);
 }
 
 /**
@@ -660,7 +663,7 @@ void tty_ldisc_hangup(struct tty_struct *tty)
int reset = tty->driver->flags & TTY_DRIVER_RESET_TERMIOS;
int err = 0;
 
-   tty_ldisc_debug(tty, "closing ldisc: %p\n", tty->ldisc);
+   tty_ldisc_debug(tty, "%p: closing\n", tty->ldisc);
 
ld = tty_ldisc_ref(tty);
if (ld != NULL) {
@@ -710,7 +713,7 @@ void tty_ldisc_hangup(struct tty_struct *tty)
if (reset)
tty_reset_termios(tty);
 
-   tty_ldisc_debug(tty, "re-opened ldisc: %p\n", tty->ldisc);
+   tty_ldisc_debug(tty, "%p: re-opened\n", tty->ldisc);
 }
 
 /**
@@ -774,8 +777,6 @@ void tty_ldisc_release(struct tty_struct *tty)
 * it does not race with the set_ldisc code path.
 */
 
-   tty_ldisc_debug(tty, "closing ldisc: %p\n", tty->ldisc);
-
tty_ldisc_lock_pair(tty, o_tty);
tty_ldisc_kill(tty);
if (o_tty)
@@ -785,7 +786,7 @@ void tty_ldisc_release(struct tty_struct *tty)
/* And the memory resources remaining (buffers, termios) will be
   disposed of when the kref hits zero */
 
-   tty_ldisc_debug(tty, "ldisc closed\n");
+   tty_ldisc_debug(tty, "released\n");
 }
 
 /**
-- 
2.4.5

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


[PATCH 0/7] tty core debug patches

2015-07-12 Thread Peter Hurley
Hi Greg,

This patchset replaces the printk(KERN_DEBUG) uses in the tty core
with a common tty_debug(tty, ...) base macro, folding in the common
elements of tty name and function name.

The many inline #ifdef TTY_SOME_DEBUG_FLAG printk's are replaced
with macro equivalents which reduce to tty_debug().

Several important improvements include:
* patch 1/7 adds the tty count to the tty_open() message
* patch 6/7 improve the ldisc messages to aid in state debugging
* patch 7/7 adds pmtx open (which helps clarify when the master was opened)

An important outcome of a single tty_debug() macro is that it can
be trivially changed to use a different debug facility than console;
for example, for some of my torture tests using the ftrace facility
is much less intrusive. I would expect that to remain a local change though.

Regards,

Peter Hurley (7):
  tty: core: Improve debug message content
  tty: core: Add tty_debug() for printk(KERN_DEBUG) messages
  tty: Replace #ifdef TTY_DEBUG_HANGUP with tty_debug_hangup()
  tty: Use tty_debug() for tty_ldisc_debug()
  tty: Replace inline #ifdef TTY_DEBUG_WAIT_UNTIL_SENT
  tty: core: Improve ldisc debug messages
  pty: Add debug message for ptmx open

 drivers/tty/pty.c   |  8 ++
 drivers/tty/tty_io.c| 67 +++--
 drivers/tty/tty_ioctl.c | 11 +---
 drivers/tty/tty_ldisc.c | 15 ++-
 include/linux/tty.h |  6 +
 5 files changed, 55 insertions(+), 52 deletions(-)

-- 
2.4.5

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


[PATCH 7/7] pty: Add debug message for ptmx open

2015-07-12 Thread Peter Hurley
Opens of /dev/ptmx don't use tty_open() so debug messages are
not printed for those opens; print a debug message with the
open count (which must always be 1) if TTY_DEBUG_HANGUP is defined.

NB: Each tty core source file undefs support for debug messages.
The relevant source file must be patched/edited to enable these
messages.

Signed-off-by: Peter Hurley 
---
 drivers/tty/pty.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 4d5e840..4d5937c 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -26,6 +26,12 @@
 #include 
 #include 
 
+#undef TTY_DEBUG_HANGUP
+#ifdef TTY_DEBUG_HANGUP
+# define tty_debug_hangup(tty, f, args...) tty_debug(tty, f, ##args)
+#else
+# define tty_debug_hangup(tty, f, args...) do {} while (0)
+#endif
 
 #ifdef CONFIG_UNIX98_PTYS
 static struct tty_driver *ptm_driver;
@@ -779,6 +785,8 @@ static int ptmx_open(struct inode *inode, struct file *filp)
if (retval)
goto err_release;
 
+   tty_debug_hangup(tty, "(tty count=%d)\n", tty->count);
+
tty_unlock(tty);
return 0;
 err_release:
-- 
2.4.5

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


[PATCH 4/7] tty: Use tty_debug() for tty_ldisc_debug()

2015-07-12 Thread Peter Hurley
Replace tty_ldisc_debug() macro definition; substitute with equivalent
tty_debug() invocation.

Signed-off-by: Peter Hurley 
---
 drivers/tty/tty_ldisc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index c07fb5d..8191680 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -22,9 +22,7 @@
 #undef LDISC_DEBUG_HANGUP
 
 #ifdef LDISC_DEBUG_HANGUP
-#define tty_ldisc_debug(tty, f, args...) ({  \
-   printk(KERN_DEBUG "%s: %s: " f, __func__, tty_name(tty), ##args); \
-})
+#define tty_ldisc_debug(tty, f, args...)   tty_debug(tty, f, ##args)
 #else
 #define tty_ldisc_debug(tty, f, args...)
 #endif
-- 
2.4.5

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


[PATCH 5/7] tty: Replace inline #ifdef TTY_DEBUG_WAIT_UNTIL_SENT

2015-07-12 Thread Peter Hurley
Add tty_debug_wait_until_sent() macro which uses tty_debug() to print
the debug message; remove inlined #ifdef.

Signed-off-by: Peter Hurley 
---
 drivers/tty/tty_ioctl.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index 5232fb6..9c5aebf 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -26,6 +26,12 @@
 
 #undef TTY_DEBUG_WAIT_UNTIL_SENT
 
+#ifdef TTY_DEBUG_WAIT_UNTIL_SENT
+# define tty_debug_wait_until_sent(tty, f, args...)tty_debug(tty, f, 
##args)
+#else
+# define tty_debug_wait_until_sent(tty, f, args...)do {} while (0)
+#endif
+
 #undef DEBUG
 
 /*
@@ -210,9 +216,8 @@ int tty_unthrottle_safe(struct tty_struct *tty)
 
 void tty_wait_until_sent(struct tty_struct *tty, long timeout)
 {
-#ifdef TTY_DEBUG_WAIT_UNTIL_SENT
-   printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty));
-#endif
+   tty_debug_wait_until_sent(tty, "\n");
+
if (!timeout)
timeout = MAX_SCHEDULE_TIMEOUT;
 
-- 
2.4.5

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


[PATCH 2/7] tty: core: Add tty_debug() for printk(KERN_DEBUG) messages

2015-07-12 Thread Peter Hurley
Introduce tty_debug() macro to output uniform debug information for
tty core debug messages (function name and tty name).

Note: printk(KERN_DEBUG) is retained here over pr_debug() since
messages can be enabled in non-DEBUG builds.

Signed-off-by: Peter Hurley 
---
 drivers/tty/tty_io.c | 41 +
 include/linux/tty.h  |  6 ++
 2 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 2d9811a..6de2c36 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -524,8 +524,8 @@ static void __proc_set_tty(struct tty_struct *tty)
spin_unlock_irqrestore(>ctrl_lock, flags);
tty->session = get_pid(task_session(current));
if (current->signal->tty) {
-   printk(KERN_DEBUG "%s: %s: current tty %s not NULL!!\n",
-  __func__, tty->name, current->signal->tty->name);
+   tty_debug(tty, "current tty %s not NULL!!\n",
+ current->signal->tty->name);
tty_kref_put(current->signal->tty);
}
put_pid(current->signal->tty_old_pgrp);
@@ -768,7 +768,7 @@ static void do_tty_hangup(struct work_struct *work)
 void tty_hangup(struct tty_struct *tty)
 {
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "%s hangup...\n", tty_name(tty));
+   tty_debug(tty, "\n");
 #endif
schedule_work(>hangup_work);
 }
@@ -787,7 +787,7 @@ EXPORT_SYMBOL(tty_hangup);
 void tty_vhangup(struct tty_struct *tty)
 {
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty));
+   tty_debug(tty, "\n")
 #endif
__tty_hangup(tty, 0);
 }
@@ -826,7 +826,7 @@ void tty_vhangup_self(void)
 static void tty_vhangup_session(struct tty_struct *tty)
 {
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "%s vhangup session...\n", tty_name(tty));
+   tty_debug(tty, "\n");
 #endif
__tty_hangup(tty, 1);
 }
@@ -923,7 +923,7 @@ void disassociate_ctty(int on_exit)
tty_kref_put(tty);
} else {
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "%s: no current tty\n", __func__);
+   tty_debug(tty, "no current tty\n");
 #endif
}
 
@@ -1705,8 +1705,7 @@ static int tty_release_checks(struct tty_struct *tty, int 
idx)
 {
 #ifdef TTY_PARANOIA_CHECK
if (idx < 0 || idx >= tty->driver->num) {
-   printk(KERN_DEBUG "%s: %s: bad idx %d\n",
-   __func__, tty->name, idx);
+   tty_debug(tty, "bad idx %d\n", idx);
return -1;
}
 
@@ -1715,22 +1714,20 @@ static int tty_release_checks(struct tty_struct *tty, 
int idx)
return 0;
 
if (tty != tty->driver->ttys[idx]) {
-   printk(KERN_DEBUG "%s: %s: bad driver table[%d] = %p\n",
-  __func__, tty->name, idx, tty->driver->ttys[idx]);
+   tty_debug(tty, "bad driver table[%d] = %p\n",
+ idx, tty->driver->ttys[idx]);
return -1;
}
if (tty->driver->other) {
struct tty_struct *o_tty = tty->link;
 
if (o_tty != tty->driver->other->ttys[idx]) {
-   printk(KERN_DEBUG "%s: %s: bad other table[%d] = %p\n",
-  __func__, tty->name, idx,
-  tty->driver->other->ttys[idx]);
+   tty_debug(tty, "bad other table[%d] = %p\n",
+ idx, tty->driver->other->ttys[idx]);
return -1;
}
if (o_tty->link != tty) {
-   printk(KERN_DEBUG "%s: %s: bad link = %p\n",
-  __func__, tty->name, o_tty->link);
+   tty_debug(tty, "bad link = %p\n", o_tty->link);
return -1;
}
}
@@ -1785,8 +1782,7 @@ int tty_release(struct inode *inode, struct file *filp)
}
 
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "%s: %s (tty count=%d)...\n", __func__,
-   tty_name(tty), tty->count);
+   tty_debug(tty, "(tty count=%d)...\n", tty->count);
 #endif
 
if (tty->ops->close)
@@ -1898,7 +1894,7 @@ int tty_release(struct inode *inode, struct file *filp)
return 0;
 
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "%s: %s: final close\n", __func__, tty_name(tty));
+   tty_debug(tty, "final close\n");
 #endif
/*
 * Ask the line discipline code to release its structures
@@ -1909,8 +1905,7 @@ int tty_release(struct inode *inode, struct file *filp)
tty_flush_works(tty);
 
 #ifdef TTY_DEBUG_HANGUP
-   printk(KERN_DEBUG "%s: %s: freeing structure...\n", __func__,
-  tty_name(tty));
+   tty_debug(tty, "freeing structure...\n");
 #endif
/*
 * The release_tty function takes care of the details of clearing
@@ -2101,8 +2096,7 @@ retry_open:
   

Darlehen anbieten

2015-07-12 Thread SUN EAST FEDERAL CREDIT UNION



hallo

Gruß von SUN EAST Federal Credit Union, wir sind gut etabliert und genehmigt UK 
Darlehen Unternehmen, im Laufe der Jahre haben wir ein gutes Verständnis für 
Ihre Bedürfnisse und individuellen Anforderungen entwickelt. wir uns 
verpflichtet, unseren Kunden fair zu behandeln und bieten einen Service, der 
professionell und freundlich ist, wir sind in einer einzigartigen Position, um 
alle Arten von Krediten für alle Personen so niedrig wie 1.5% Zinsen bieten, so 
dass, wenn Sie irgendwelche finanzielle Schwierigkeiten haben und Sie das 
Darlehen benötigen, kontaktieren Sie uns bitte, wenn Sie interessiert Unsere 
E-Mail sind: sunea...@gmail.com

* Ihr vollständiger Name:
* Ihre Land und Wohnadresse:
* Telefonnummer:
* Darlehensbetrag benötigt:
* Dauer:
* Zweck:
* Geschlecht und Alter:
* Beruf:

Wir erwarten Ihre Antwort in Bezug auf die gefüllte Form, obwohl unsere E-Mails.
Danke für deine Antwort.

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


Re: [PATCH v3 02/11] usb: otg-fsm: support multiple instances

2015-07-12 Thread Peter Chen
On Fri, Jul 10, 2015 at 04:06:43PM +0800, Li Jun wrote:
> On Wed, Jul 08, 2015 at 01:19:28PM +0300, Roger Quadros wrote:
> > Move the state_changed variable into struct otg_fsm
> > so that we can support multiple instances.
> > 
> I am not sure if multiple instances may happen since OTG protocol requires
> only one OTG port can be equipped on OTG device.
> 

It is ok the software can support more than spec requires, the user can
only use one and the spec may change in future :)

> Li Jun
>  
> > Signed-off-by: Roger Quadros 
> > ---
> >  drivers/usb/common/usb-otg-fsm.c | 10 --
> >  include/linux/usb/otg-fsm.h  |  1 +
> >  2 files changed, 5 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/usb/common/usb-otg-fsm.c 
> > b/drivers/usb/common/usb-otg-fsm.c
> > index 61d538a..42c6376 100644
> > --- a/drivers/usb/common/usb-otg-fsm.c
> > +++ b/drivers/usb/common/usb-otg-fsm.c
> > @@ -61,8 +61,6 @@ static int otg_set_protocol(struct otg_fsm *fsm, int 
> > protocol)
> > return 0;
> >  }
> >  
> > -static int state_changed;
> > -
> >  /* Called when leaving a state.  Do state clean up jobs here */
> >  static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state 
> > old_state)
> >  {
> > @@ -123,7 +121,7 @@ static void otg_leave_state(struct otg_fsm *fsm, enum 
> > usb_otg_state old_state)
> >  /* Called when entering a state */
> >  static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
> >  {
> > -   state_changed = 1;
> > +   fsm->state_changed = 1;
> > if (fsm->otg->state == new_state)
> > return 0;
> 
> "fsm->state_changed = 1;" should be put here, I think.
> 

Yes, seems it is the problem at current code.

> Li Jun
> 
> > VDBG("Set state: %s\n", usb_otg_state_string(new_state));
> > @@ -248,7 +246,7 @@ int otg_statemachine(struct otg_fsm *fsm)
> > mutex_lock(>lock);
> >  
> > state = fsm->otg->state;
> > -   state_changed = 0;
> > +   fsm->state_changed = 0;
> > /* State machine state change judgement */
> >  
> > switch (state) {
> > @@ -361,7 +359,7 @@ int otg_statemachine(struct otg_fsm *fsm)
> > }
> > mutex_unlock(>lock);
> >  
> > -   VDBG("quit statemachine, changed = %d\n", state_changed);
> > -   return state_changed;
> > +   VDBG("quit statemachine, changed = %d\n", fsm->state_changed);
> > +   return fsm->state_changed;
> >  }
> >  EXPORT_SYMBOL_GPL(otg_statemachine);
> > diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h
> > index ca508c2..243274f 100644
> > --- a/include/linux/usb/otg-fsm.h
> > +++ b/include/linux/usb/otg-fsm.h
> > @@ -194,6 +194,7 @@ struct otg_fsm {
> > /* Current usb protocol used: 0:undefine; 1:host; 2:client */
> > int protocol;
> > struct mutex lock;
> > +   bool state_changed;
> >  };
> >  
> >  struct otg_fsm_ops {
> > -- 
> > 2.1.4
> > 

-- 

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


Darlehen anbieten

2015-07-12 Thread SUN EAST FEDERAL CREDIT UNION



hallo

Gruß von SUN EAST Federal Credit Union, wir sind gut etabliert und genehmigt UK 
Darlehen Unternehmen, im Laufe der Jahre haben wir ein gutes Verständnis für 
Ihre Bedürfnisse und individuellen Anforderungen entwickelt. wir uns 
verpflichtet, unseren Kunden fair zu behandeln und bieten einen Service, der 
professionell und freundlich ist, wir sind in einer einzigartigen Position, um 
alle Arten von Krediten für alle Personen so niedrig wie 1.5% Zinsen bieten, so 
dass, wenn Sie irgendwelche finanzielle Schwierigkeiten haben und Sie das 
Darlehen benötigen, kontaktieren Sie uns bitte, wenn Sie interessiert Unsere 
E-Mail sind: sunea...@gmail.com

* Ihr vollständiger Name:
* Ihre Land und Wohnadresse:
* Telefonnummer:
* Darlehensbetrag benötigt:
* Dauer:
* Zweck:
* Geschlecht und Alter:
* Beruf:

Wir erwarten Ihre Antwort in Bezug auf die gefüllte Form, obwohl unsere E-Mails.
Danke für deine Antwort.

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


Re: [PATCH 25/45] clk: socfpga: Remove clk.h include

2015-07-12 Thread Viresh Kumar
On 10-07-15, 16:33, Stephen Boyd wrote:
> Clock provider drivers generally shouldn't include clk.h because
> it's the consumer API. Remove the include here because this is a
> provider driver.
> 
> Cc: Viresh Kumar 
> Signed-off-by: Stephen Boyd 
> ---
>  drivers/clk/spear/spear1310_clock.c | 1 -
>  drivers/clk/spear/spear1340_clock.c | 1 -
>  drivers/clk/spear/spear3xx_clock.c  | 1 -
>  drivers/clk/spear/spear6xx_clock.c  | 1 -
>  4 files changed, 4 deletions(-)

I hope you have compiled it :)

Acked-by: Viresh Kumar 

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


[PATCH 2/3] [PATCH 2/3] kexec: split kexec_load syscall from kexec core code

2015-07-12 Thread dyoung
Now there's two kexec load syscall, one is kexec_load another is
kexec_file_load, kexec_file_load has been splited as kernel/kexec_file.c.
In this patch I split kexec_load syscall code to kernel/kexec.c.

And add a new kconfig option KEXEC_CORE, so we can disable kexec_load
and use kexec_file_load only, or vice verse.

The original requirement is from Tedso, he want kexec kernel signature being
checked with CONFIG_KEXEC_VERIFY_SIG enabled. But kexec-tools use kexec_load
syscall can bypass the checking.

Vivek Goyal proposed to create a common kconfig option so user can compile
in only one syscall for loading kexec kernel. KEXEC/KEXEC_FILE selects
KEXEC_CORE so that old config files still work.

Because there's general code need CONFIG_KEXEC_CORE, so I updated all the
architecture Kconfig with a new option KEXEC_CORE, and let KEXEC selects
KEXEC_CORE in arch Kconfig. Also updated general kernel code with
to kexec_load syscall.

Signed-off-by: Dave Young 
---
 arch/arm/Kconfig  |4 +
 arch/ia64/Kconfig |4 +
 arch/m68k/Kconfig |4 +
 arch/mips/Kconfig |4 +
 arch/powerpc/Kconfig  |4 +
 arch/sh/Kconfig   |4 +
 arch/tile/Kconfig |4 +
 arch/x86/Kconfig  |6 +-
 arch/x86/boot/header.S|2 +-
 arch/x86/include/asm/kdebug.h |2 +-
 arch/x86/kernel/Makefile  |4 +-
 arch/x86/kernel/kvmclock.c|4 +-
 arch/x86/kernel/reboot.c  |4 +-
 arch/x86/kernel/setup.c   |2 +-
 arch/x86/kernel/vmlinux.lds.S |2 +-
 arch/x86/kvm/vmx.c|8 +-
 arch/x86/platform/efi/efi.c   |4 +-
 arch/x86/platform/uv/uv_nmi.c |6 +-
 drivers/firmware/efi/Kconfig  |2 +-
 drivers/pci/pci-driver.c  |2 +-
 include/linux/kexec.h |   12 +-
 init/initramfs.c  |4 +-
 kernel/Makefile   |1 +
 kernel/events/core.c  |2 +-
 kernel/kexec.c| 1578 +---
 kernel/kexec_core.c   | 1594 +
 kernel/ksysfs.c   |6 +-
 kernel/printk/printk.c|2 +-
 kernel/reboot.c   |2 +-
 kernel/sysctl.c   |2 +-
 30 files changed, 1668 insertions(+), 1611 deletions(-)
 create mode 100644 kernel/kexec_core.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1c50210..20c48b3 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
  be linked for and stored to.  This address is dependent on your
  own flash usage.
 
+config KEXEC_CORE
+   bool
+
 config KEXEC
bool "Kexec system call (EXPERIMENTAL)"
depends on (!SMP || PM_SLEEP_SMP)
depends on !CPU_V7M
+   select KEXEC_CORE
help
  kexec is a system call that implements the ability to shutdown your
  current kernel, and to start another kernel.  It is like a reboot
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 42a91a7..7db8fb7 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -515,9 +515,13 @@ config IA64_HP_AML_NFW
 
 source "drivers/sn/Kconfig"
 
+config KEXEC_CORE
+   bool
+
 config KEXEC
bool "kexec system call"
depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
+   select KEXEC_CORE
help
  kexec is a system call that implements the ability to shutdown your
  current kernel, and to start another kernel.  It is like a reboot
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 2dd8f63..875c518 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -92,9 +92,13 @@ config MMU_SUN3
bool
depends on MMU && !MMU_MOTOROLA && !MMU_COLDFIRE
 
+config KEXEC_CORE
+   bool
+
 config KEXEC
bool "kexec system call"
depends on M68KCLASSIC
+   select KEXEC_CORE
help
  kexec is a system call that implements the ability to shutdown your
  current kernel, and to start another kernel.  It is like a reboot
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 2a14585..0084fb6 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2594,8 +2594,12 @@ config SCHED_HRTICK
 
 source "kernel/Kconfig.preempt"
 
+config KEXEC_CORE
+   bool
+
 config KEXEC
bool "Kexec system call"
+   select KEXEC_CORE
help
  kexec is a system call that implements the ability to shutdown your
  current kernel, and to start another kernel.  It is like a reboot
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5ef2711..68d6674 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -412,9 +412,13 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
default "y" if PPC_POWERNV
select ARCH_SUPPORTS_MEMORY_FAILURE
 
+config KEXEC_CORE
+   bool
+
 config KEXEC
bool "kexec system call"
depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
+   

Re: [PATCH] cpufreq: integrator: fixed coding style issues

2015-07-12 Thread Viresh Kumar
On 10-07-15, 14:42, Cristian Ardelean wrote:
> Fixed coding style issues found by checkpatch.pl tool. Changed
> space indentation to tab, removed unneccesary braces, removed
> space between MODULE macros and parentheses.
> 
> REMARKS: failed to 'make' this file with error message
> 'fatal error: asm/mach-types.h: No such file or directory'.
> 
> Signed-off-by: Cristian Ardelean 
> ---
>  drivers/cpufreq/integrator-cpufreq.c |   18 --
>  1 file changed, 8 insertions(+), 10 deletions(-)

Acked-by: Viresh Kumar 

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


[PATCH 1/3] [PATCH 1/3] kexec: split kexec_file syscall code to kexec_file.c

2015-07-12 Thread dyoung
Split kexec_file syscall related code to another file kernel/kexec_file.c
so that the #ifdef CONFIG_KEXEC_FILE in kexec.c can be dropped.

Sharing variables and functions are moved to kernel/kexec_internal.h per
suggestion from Vivek and Petr.

Signed-off-by: Dave Young 
---
 kernel/Makefile |1 +
 kernel/kexec.c  | 1055 +--
 kernel/kexec_file.c | 1044 ++
 kernel/kexec_internal.h |   22 +
 4 files changed, 1077 insertions(+), 1045 deletions(-)
 create mode 100644 kernel/kexec_file.c
 create mode 100644 kernel/kexec_internal.h

diff --git a/kernel/Makefile b/kernel/Makefile
index 43c4c92..f178fe4 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_MODULE_SIG) += module_signing.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
 obj-$(CONFIG_KEXEC) += kexec.o
+obj-$(CONFIG_KEXEC_FILE) += kexec_file.o
 obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
 obj-$(CONFIG_COMPAT) += compat.o
 obj-$(CONFIG_CGROUPS) += cgroup.o
diff --git a/kernel/kexec.c b/kernel/kexec.c
index a785c10..641b2db 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -31,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -44,6 +43,9 @@
 
 #include 
 #include 
+#include "kexec_internal.h"
+
+DEFINE_MUTEX(kexec_mutex);
 
 /* Per cpu memory for storing cpu states in case of system crash. */
 note_buf_t __percpu *crash_notes;
@@ -57,16 +59,6 @@ size_t vmcoreinfo_max_size = sizeof(vmcoreinfo_data);
 /* Flag to indicate we are going to kexec a new kernel */
 bool kexec_in_progress = false;
 
-/*
- * Declare these symbols weak so that if architecture provides a purgatory,
- * these will be overridden.
- */
-char __weak kexec_purgatory[0];
-size_t __weak kexec_purgatory_size = 0;
-
-#ifdef CONFIG_KEXEC_FILE
-static int kexec_calculate_store_digests(struct kimage *image);
-#endif
 
 /* Location of the reserved area for the crash kernel */
 struct resource crashk_res = {
@@ -146,8 +138,6 @@ int kexec_should_crash(struct task_struct *p)
  */
 #define KIMAGE_NO_DEST (-1UL)
 
-static int kimage_is_destination_range(struct kimage *image,
-  unsigned long start, unsigned long end);
 static struct page *kimage_alloc_page(struct kimage *image,
   gfp_t gfp_mask,
   unsigned long dest);
@@ -169,7 +159,7 @@ static int copy_user_segment_list(struct kimage *image,
return ret;
 }
 
-static int sanity_check_segment_list(struct kimage *image)
+int sanity_check_segment_list(struct kimage *image)
 {
int result, i;
unsigned long nr_segments = image->nr_segments;
@@ -259,7 +249,7 @@ static int sanity_check_segment_list(struct kimage *image)
return 0;
 }
 
-static struct kimage *do_kimage_alloc_init(void)
+struct kimage *do_kimage_alloc_init(void)
 {
struct kimage *image;
 
@@ -286,8 +276,6 @@ static struct kimage *do_kimage_alloc_init(void)
return image;
 }
 
-static void kimage_free_page_list(struct list_head *list);
-
 static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
 unsigned long nr_segments,
 struct kexec_segment __user *segments,
@@ -354,283 +342,7 @@ out_free_image:
return ret;
 }
 
-#ifdef CONFIG_KEXEC_FILE
-static int copy_file_from_fd(int fd, void **buf, unsigned long *buf_len)
-{
-   struct fd f = fdget(fd);
-   int ret;
-   struct kstat stat;
-   loff_t pos;
-   ssize_t bytes = 0;
-
-   if (!f.file)
-   return -EBADF;
-
-   ret = vfs_getattr(>f_path, );
-   if (ret)
-   goto out;
-
-   if (stat.size > INT_MAX) {
-   ret = -EFBIG;
-   goto out;
-   }
-
-   /* Don't hand 0 to vmalloc, it whines. */
-   if (stat.size == 0) {
-   ret = -EINVAL;
-   goto out;
-   }
-
-   *buf = vmalloc(stat.size);
-   if (!*buf) {
-   ret = -ENOMEM;
-   goto out;
-   }
-
-   pos = 0;
-   while (pos < stat.size) {
-   bytes = kernel_read(f.file, pos, (char *)(*buf) + pos,
-   stat.size - pos);
-   if (bytes < 0) {
-   vfree(*buf);
-   ret = bytes;
-   goto out;
-   }
-
-   if (bytes == 0)
-   break;
-   pos += bytes;
-   }
-
-   if (pos != stat.size) {
-   ret = -EBADF;
-   vfree(*buf);
-   goto out;
-   }
-
-   *buf_len = pos;
-out:
-   fdput(f);
-   return ret;
-}
-
-/* Architectures can provide this probe function */
-int __weak arch_kexec_kernel_image_probe(struct kimage *image, void *buf,
-

Re: [RFC] freeing unlinked file indefinitely delayed

2015-07-12 Thread Ian Kent
On Sun, 2015-07-12 at 16:17 +0100, Al Viro wrote:
> On Thu, Jul 09, 2015 at 07:26:44PM +0800, Ian Kent wrote:
> > > But the dentrys that will most likely face summary execution will be
> > > hashed, such as was the case on that 2.6.32 kernel at dput().
> > > 
> > > Doesn't that mean that something dropped the dentry after the dput(),
> > > that will now also free the dentry, that took the refcount to 0?
> > 
> > Oh wait, think I get it now ... perhaps it's prune_one_dentry() doing
> > it ...
> 
> What, unhashing?  Yes, it does.

Yep, that was what I was thinking at the time.

> 
> A bit of context - the breakage that had first pointed in direction of
> this bug had been a deadlock with dcache shrinker run on frozen fs was
> stumbling across a hashed dentry with zero refcount *and* zero link count
> of its inode, triggering its eviction, final iput(), inode freeing and
> deadlock on attempt to do sb_start_intwrite() there; figuring out how could
> such a dentry appear in the first place had uncovered this fun.  Which
>   a) is a bug in its own right and
>   b) happens in mainline as well.

I get all of that, and it sure does look like these things should be
treated as unhashed.

My puzzle is the life cycle of DCACHE_DISCONNECTED dentrys, which is
mostly unrelated.

Not to worry, this isn't the first time I've been defeated trying to
work it out.

The only way I can see disconnected dentrys created (possibly unhashed,
and maybe not materialized) is via nfs and nfsd, beside the usage
mentioned here of course.

There must be some indirection I'm missing wrt. export_operations
usage 

Ian

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


Re: [PATCH v3 01/11] usb: otg-fsm: Add documentation for struct otg_fsm

2015-07-12 Thread Peter Chen
On Wed, Jul 08, 2015 at 01:19:27PM +0300, Roger Quadros wrote:
> struct otg_fsm is the interface to the OTG state machine.
> 
> Document the input, output and internal state variables.
> Definations are taken from Table 7-2 and Table 7-4 of
> the USB OTG & EH Specification Rev.2.0
> 
> Re-arrange some of the members as per use case for more
> clarity.
> 
> Signed-off-by: Roger Quadros 
> ---
>  include/linux/usb/otg-fsm.h | 89 
> +
>  1 file changed, 82 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h
> index f728f18..ca508c2 100644
> --- a/include/linux/usb/otg-fsm.h
> +++ b/include/linux/usb/otg-fsm.h
> @@ -59,37 +59,112 @@ enum otg_fsm_timer {
>   NUM_OTG_FSM_TIMERS,
>  };
>  
> -/* OTG state machine according to the OTG spec */
> +/**
> + * struct otg_fsm - OTG state machine according to the OTG spec
> + *
> + * OTG hardware Inputs
> + *
> + *   Common inputs for A and B device
> + * @id:  TRUE for B-device, FALSE for A-device.
> + * @adp_change: TRUE when current ADP measurement (n) value, compared to the
> + *   ADP measurement taken at n-2, differs by more than CADP_THR
> + * @power_up:TRUE when the OTG device first powers up its USB system 
> and
> + *   ADP measurement taken if ADP capable
> + *
> + *   A-Device state inputs
> + * @a_srp_det:   TRUE if the A-device detects SRP
> + * @a_vbus_vld:  TRUE when VBUS voltage is in regulation
> + * @b_conn:  TRUE if the A-device detects connection from the B-device
> + * @a_bus_resume: TRUE when the B-device detects that the A-device is 
> signaling
> + * a resume (K state)
> + *   B-Device state inputs
> + * @a_bus_suspend: TRUE when the B-device detects that the A-device has put 
> the
> + *   bus into suspend
> + * @a_conn:  TRUE if the B-device detects a connection from the A-device
> + * @b_se0_srp:   TRUE when the line has been at SE0 for more than the 
> minimum
> + *   time before generating SRP
> + * @b_ssend_srp: TRUE when the VBUS has been below VOTG_SESS_VLD for more 
> than
> + *the minimum time before generating SRP
> + * @b_sess_vld:  TRUE when the B-device detects that the voltage on VBUS 
> is
> + *   above VOTG_SESS_VLD
> + * @test_device: TRUE when the B-device switches to B-Host and detects an OTG
> + *   test device. This must be set by host/hub driver
> + *
> + *   Application inputs (A-Device)
> + * @a_bus_drop:  TRUE when A-device application needs to power down the 
> bus
> + * @a_bus_req:   TRUE when A-device application wants to use the bus.
> + *   FALSE to suspend the bus
> + *
> + *   Application inputs (B-Device)
> + * @b_bus_req:   TRUE during the time that the Application running on the
> + *   B-device wants to use the bus
> + *
> + *   Auxilary inputs (OTG v1.3 only. Obsolete now.)
> + * @a_sess_vld:  TRUE if the A-device detects that VBUS is above 
> VA_SESS_VLD
> + * @b_bus_suspend: TRUE when the A-device detects that the B-device has put
> + *   the bus into suspend
> + * @b_bus_resume: TRUE when the A-device detects that the B-device is 
> signaling
> + *resume on the bus
> + *
> + * OTG Output status. Read only for users. updated by otg_ops() helpers

updated by OTG FSM helpers defined in this file

Only one tiny comment, others are ok.

Acked-by: Peter Chen 

-- 

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


[PATCH 3/3] [PATCH 3/3] kexec-x86-kdebug-h-drop-useless-macro

2015-07-12 Thread dyoung
in_crash_kexec is only useful for kdump, it will not be used without
CONFIG_KEXEC_CORE, thus remove the #else section

Signed-off-by: Dave Young 
---
 arch/x86/include/asm/kdebug.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/x86/include/asm/kdebug.h b/arch/x86/include/asm/kdebug.h
index b130d59..ad83f6d 100644
--- a/arch/x86/include/asm/kdebug.h
+++ b/arch/x86/include/asm/kdebug.h
@@ -31,9 +31,6 @@ extern unsigned long oops_begin(void);
 extern void oops_end(unsigned long, struct pt_regs *, int signr);
 #ifdef CONFIG_KEXEC_CORE
 extern int in_crash_kexec;
-#else
-/* no crash dump is ever in progress if no crash kernel can be kexec'd */
-#define in_crash_kexec 0
 #endif
 
 #endif /* _ASM_X86_KDEBUG_H */
-- 
1.8.3.1



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


[PATCH 0/3] kexec: refactor CONFIG_KEXEC/CONFIG_KEXEC_FILE Kconfig

2015-07-12 Thread dyoung
Previously Theodore Ts'o brought up an issue about kexec_load syscall bypassing
signature verification:
https://lkml.org/lkml/2015/6/14/280

Because we have two kexec load syscall, one kexec_load, another kexec_file_load,
the latter one was introduced by Vivek Goyal, it is mainly for supporting UEFI
secure boot. kexec_file_load verifies kernel signature, but even if with
CONFIG_KEXEC_VERIFY_SIG=y and CONFIG_KEXEC_FILE=y, kexec-tools still can use
old syscall and bypass signature verification.

KEXEC_FILE can also be used without UEFI, so kexec can always verify kernel
signature for security purpose. 

The suggestion in above thread is add a new Kconfig option for kexec common
code, here I use KEXEC_CORE, KEXEC and KEXEC_FILE select KEXEC_CORE so one can
compile only KEXEC_FILE without old kexec_load syscall.

There's checkpatch warnings and errors, I would like to send furthuer cleanup
patches after this series. Please let me know if you have other suggestions.
checkpatch errors are for cases such as assign a value to static variables.

PATCH 3/3 can be sort out from the series if people do not like. It is a
cleanup for a macro.

Below is the diffstat of the patches:
---
 arch/arm/Kconfig  |4 
 arch/ia64/Kconfig |4 
 arch/m68k/Kconfig |4 
 arch/mips/Kconfig |4 
 arch/powerpc/Kconfig  |4 
 arch/sh/Kconfig   |4 
 arch/tile/Kconfig |4 
 arch/x86/Kconfig  |6 
 arch/x86/boot/header.S|2 
 arch/x86/include/asm/kdebug.h |5 
 arch/x86/kernel/Makefile  |4 
 arch/x86/kernel/kvmclock.c|4 
 arch/x86/kernel/reboot.c  |4 
 arch/x86/kernel/setup.c   |2 
 arch/x86/kernel/vmlinux.lds.S |2 
 arch/x86/kvm/vmx.c|8 
 arch/x86/platform/efi/efi.c   |4 
 arch/x86/platform/uv/uv_nmi.c |6 
 drivers/firmware/efi/Kconfig  |2 
 drivers/pci/pci-driver.c  |2 
 include/linux/kexec.h |   12 
 init/initramfs.c  |4 
 kernel/Makefile   |2 
 kernel/events/core.c  |2 
 kernel/kexec.c| 2633 --
 kernel/kexec_core.c   | 1594 +
 kernel/kexec_file.c   | 1044 
 kernel/kexec_internal.h   |   22 
 kernel/ksysfs.c   |6 
 kernel/printk/printk.c|2 
 kernel/reboot.c   |2 
 kernel/sysctl.c   |2 
 32 files changed, 2745 insertions(+), 2659 deletions(-)

Thanks
Dave

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


Re: [PATCH V2] acpi-cpufreq: Fix an acpi perf unregister issue

2015-07-12 Thread Viresh Kumar
On 10-07-15, 14:36, Pan Xinhui wrote:
> 
> As policy->cpu may not be same in acpi_cpufreq_cpu_init and
> acpi_cpufreq_cpu_exit. There is a risk that we use different *cpu* to
> un/register acpi performance. So acpi_processor_unregister_performance
> may not be able to do the cleanup work. That causes a memory leak. And
> if there will be another acpi_processor_register_performance call, it
> may also fail thanks to the internal check of pr->performace.
> 
> So we add a field *acpi_perf_cpu* to fix this issue.
> 
> Signed-off-by: Pan Xinhui 
> ---
> Change from V1:
>   comments update
> ---
>  drivers/cpufreq/acpi-cpufreq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

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


RE: [RFC] genalloc:add an gen_pool_alloc_align func to genalloc

2015-07-12 Thread Zhao Qiang


> -Original Message-
> From: Laura Abbott [mailto:labb...@redhat.com]
> Sent: Friday, July 10, 2015 5:51 AM
> To: Zhao Qiang-B45475; lau...@codeaurora.org
> Cc: linux-kernel@vger.kernel.org; linuxppc-...@lists.ozlabs.org;
> a...@linux-foundation.org; o...@lixom.net; catalin.mari...@arm.com; Wood
> Scott-B07421; Xie Xiaobo-R63061
> Subject: Re: [RFC] genalloc:add an gen_pool_alloc_align func to genalloc
> 
> On 07/09/2015 12:47 AM, Zhao Qiang wrote:
> > Bytes alignment is required to manage some special ram, so add
> > gen_pool_alloc_align func to genalloc.
> > rename gen_pool_alloc to gen_pool_alloc_align with a align parameter,
> > then provide gen_pool_alloc to call gen_pool_alloc_align with align =
> > 1 Byte.
> >
> > Signed-off-by: Zhao Qiang 
> > ---
> > FSL's IP block QE require this function to manage muram.
> > QE supported only PowerPC, and its code was put under arch/powerpc
> > directory, using arch/powerpc/lib/rheap.c to manage muram.
> > Now it support both arm(ls1021,ls1043,ls2085 and such on) and powerpc,
> > the code need to move from arch/powerpc to public direcory, Scott wood
> > hopes to use genalloc to manage the muram, after discussing with
> > scott, we decide to add gen_pool_alloc_align to meet the requirement
> > for bytes-alignment.
> 
> gen_pool supports custom allocation algorithms. I thought this was
> discussed previously and the conclusion was that if you wanted alignment
> you should use custom allocation algorithms. I'm failing at finding any
> thread discussing it though.
> 
> Perhaps another option would be to add another runtime argument to
> gen_pool where you could pass the alignment to your custom allocation
> function. This way alignment isn't inherently coded into any of the
> algorithms.
> 
> >
> >   include/linux/genalloc.h | 10 +++---
> >   lib/genalloc.c   | 38 ++
> >   2 files changed, 37 insertions(+), 11 deletions(-)
> >
> > diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h index
> > 1ccaab4..65fdf14 100644
> > --- a/include/linux/genalloc.h
> > +++ b/include/linux/genalloc.h
> > @@ -96,6 +96,8 @@ static inline int gen_pool_add(struct gen_pool *pool,
> unsigned long addr,
> >   }
> >   extern void gen_pool_destroy(struct gen_pool *);
> >   extern unsigned long gen_pool_alloc(struct gen_pool *, size_t);
> > +extern unsigned long gen_pool_alloc_align(struct gen_pool *, size_t,
> > +   unsigned long align);
> >   extern void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size,
> > dma_addr_t *dma);
> >   extern void gen_pool_free(struct gen_pool *, unsigned long, size_t);
> > @@ -108,14 +110,16 @@ extern void gen_pool_set_algo(struct gen_pool
> *pool, genpool_algo_t algo,
> > void *data);
> >
> >   extern unsigned long gen_pool_first_fit(unsigned long *map, unsigned
> long size,
> > -   unsigned long start, unsigned int nr, void *data);
> > +   unsigned long start, unsigned int nr, void *data,
> > +   unsigned long align_mask);
> >
> >   extern unsigned long gen_pool_first_fit_order_align(unsigned long
> *map,
> > unsigned long size, unsigned long start, unsigned int nr,
> > -   void *data);
> > +   void *data, unsigned long align_mask);
> >
> >   extern unsigned long gen_pool_best_fit(unsigned long *map, unsigned
> long size,
> > -   unsigned long start, unsigned int nr, void *data);
> > +   unsigned long start, unsigned int nr, void *data,
> > +   unsigned long align_mask);
> >
> >   extern struct gen_pool *devm_gen_pool_create(struct device *dev,
> > int min_alloc_order, int nid);
> > diff --git a/lib/genalloc.c b/lib/genalloc.c index d214866..dd63448
> > 100644
> > --- a/lib/genalloc.c
> > +++ b/lib/genalloc.c
> > @@ -258,19 +258,22 @@ void gen_pool_destroy(struct gen_pool *pool)
> >   EXPORT_SYMBOL(gen_pool_destroy);
> >
> >   /**
> > - * gen_pool_alloc - allocate special memory from the pool
> > + * gen_pool_alloc_align - allocate special memory from the pool
> >* @pool: pool to allocate from
> >* @size: number of bytes to allocate from the pool
> > + * @align: number of bytes to align
> >*
> >* Allocate the requested number of bytes from the specified pool.
> >* Uses the pool allocation function (with first-fit algorithm by
> default).
> >* Can not be used in NMI handler on architectures without
> >* NMI-safe cmpxchg implementation.
> >*/
> > -unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size)
> > +unsigned long gen_pool_alloc_align(struct gen_pool *pool, size_t size,
> > +   unsigned long align)
> >   {
> > struct gen_pool_chunk *chunk;
> > unsigned long addr = 0;
> > +   unsigned long align_mask;
> > int order = pool->min_alloc_order;
> > int nbits, start_bit = 0, end_bit, remain;
> >
> > @@ -281,6 +284,7 @@ unsigned long gen_pool_alloc(struct gen_pool *pool,
> size_t size)
> > if (size 

Re: [PATCH v2] net: dsa: mv88e6xxx: add write access to debugfs regs file

2015-07-12 Thread Vivien Didelot
Hi David,

On Jul 11, 2015, at 10:08 PM, David da...@davemloft.net wrote:

> From: Vivien Didelot 
> Date: Sat, 11 Jul 2015 14:36:12 -0400 (EDT)
> 
>> In the meantime, this is really useful for development. i.e. ensuring a good
>> switchdev/DSA interaction without being able to read and write directly the
>> hardware VLAN table, is a bit a PITA. A dynamic debugfs looked appropriate.
> 
> For "development" you can hack the driver, add tracepoints, or use
> another mechanism anyone hacking the kernel (which by definition
> someone doing "development" is doing) can do.
> 
> I do not buy any of your arguments, and you really miss the grand
> opportunity to export the knobs and values in a way which are going
> to:
> 
> 1) Be useful to users
> 
> 2) Be usable by any similar DSA driver, not just _yours_

I hardly see how this debug interface can be made generic to other DSA drivers,
since the format of hardware tables or some registers seem very specific to the
switch chip.

> So please stop this myopic narrow thinking when you add facilities for
> development or export values.  Think of the big picture and long term,
> not just your personal perceived immediate needs of today.

I understand. So it looks like the only reasonable solution here is to revert
this support for the debugfs interface.

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


Re: V4.1-RC build error after commit 77a3c6f

2015-07-12 Thread Larry Finger

On 07/12/2015 06:10 PM, Laurent Pinchart wrote:

Hi Larry,

Thank you for the report.

On Saturday 11 July 2015 16:27:36 Larry Finger wrote:

Beginning with the commit in the subject, I get the following build error:

CC [M]  drivers/media/v4l2-core/videobuf2-core.o
drivers/media/v4l2-core/videobuf2-core.c: In function
‘vb2_warn_zero_bytesused’: drivers/media/v4l2-core/videobuf2-core.c:1253:2:
error: implicit declaration of function ‘__WARN’
[-Werror=implicit-function-declaration]
__WARN();
^
cc1: some warnings being treated as errors

My .config is attached.


Indeed, __WARN isn't defined when CONFIG_BUG isn't set. My bad :-/

I've send a patch to fix this (you've been CC'ed), could you please review it
?

And I've just noticed that I forgot to add your Reported-by: tag, please feel
free to add it to the review.


I added my "Acked-by:" for the __WARN to WARN_ON part. In addition, the rest 
looks good.


I do not need a Reported-by to be added. I'm a volunteer, thus it does not 
matter how many times my name is mentioned. Another one will never increase my 
remuneration.


I have also submitted a patch to make certain that __WARN is defined even when 
CONFIG_DEBUG is not defined. It may not be accepted, but if it does, no one else 
will be caught this way.


Larry


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


[PATCH v2] serial: core: Fix crashes while echoing when closing

2015-07-12 Thread Peter Hurley
While closing, new rx data may be received after the input buffers
have been flushed but before stop_rx() halts receiving [1]. The
new data might not be processed by flush_to_ldisc() until after
uart_shutdown() and normal input processing is re-enabled (ie.,
tty->closing = 0). The race is outlined below:

CPU 0 | CPU 1
  |
uart_close()  |
   tty_port_close_start() |
  tty->closing = 1|
  tty_ldisc_flush()   |
  | => IRQ
  |   while (LSR & data ready)
  |  uart_insert_char()
  |   tty_flip_buffer_push()
  | <= EOI
   stop_rx()  |   .
   uart_shutdown()|   .
  free xmit.buf   |   .
   tty_port_tty_set(NULL) |   .
   tty->closing = 0   |   .
  | flush_to_ldisc()
  |   n_tty_receive_buf_common()
  |  __receive_buf()
  | ...
  | commit_echoes()
  |uart_flush_chars()
  |   __uart_start()
  | ** OOPS on port.tty deref **
   tty_ldisc_flush()  |

Input processing must be prevented from echoing (tty->closing = 1)
until _after_ the input buffers have been flushed again at the end
of uart_close().

[1] In fact, some input may actually be buffered _after_ stop_rx()
since the rx interrupt may have already triggered but not yet been
handled when stop_rx() disables rx interrupts.

Fixes: 2e758910832d ("serial: core: Flush ldisc after dropping port
mutex in uart_close()")
Reported-by: Robert Elliott 
Signed-off-by: Peter Hurley 
---

v2: Fixed Robert Elliott's email address

 drivers/tty/serial/serial_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 7ae1592..f368520 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1418,7 +1418,7 @@ static void uart_close(struct tty_struct *tty, struct 
file *filp)
mutex_lock(>mutex);
uart_shutdown(tty, state);
tty_port_tty_set(port, NULL);
-   tty->closing = 0;
+
spin_lock_irqsave(>lock, flags);
 
if (port->blocked_open) {
@@ -1444,6 +1444,7 @@ static void uart_close(struct tty_struct *tty, struct 
file *filp)
mutex_unlock(>mutex);
 
tty_ldisc_flush(tty);
+   tty->closing = 0;
 }
 
 static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
-- 
2.4.5

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


Re: [PATCH v2] sched: let __sched_period() use rq's nr_running

2015-07-12 Thread Byungchul Park
On Fri, Jul 10, 2015 at 02:31:10PM +0100, Morten Rasmussen wrote:
> On Fri, Jul 10, 2015 at 05:11:30PM +0900, byungchul.p...@lge.com wrote:
> > From: Byungchul Park 
> > 
> > __sched_period() returns a period which a rq can have. the period has to be
> > stretched by the number of task *the rq has*, when nr_running > nr_latency.
> > otherwise, task slice can be very smaller than sysctl_sched_min_granularity
> > depending on the position of tg hierarchy when CONFIG_FAIR_GROUP_SCHED.
> > 
> > Signed-off-by: Byungchul Park 
> > ---
> >  kernel/sched/fair.c |2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 09456fc..8ae7aeb 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -635,7 +635,7 @@ static u64 __sched_period(unsigned long nr_running)
> >   */
> >  static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
> >  {
> > -   u64 slice = __sched_period(cfs_rq->nr_running + !se->on_rq);
> > +   u64 slice = __sched_period(rq_of(cfs_rq)->nr_running + !se->on_rq);

hello,

> 
> This would stretch the period to fit rq->cfs.h_nr_running (which is
> equal to rq.nr_running), but I still think that the slice may be smaller
> than sched_min_granularity for low priority tasks since the slice is

yes, i also think the slice may be smaller than sched_min_granularity for 
low priority tasks, while the slice may be larger than sched_min_granularity
for high priority tasks. and as you may know, the slice is already scaled 
by priority in sched_slice().

in order to scale the slice properly in sched_slice(), __sched_period()
should return rq wide period. or i think we should change other code
assuming that variables like sysctl_sched_min_granularity are comparable
to a task execution time which is independant with position of cgroup
hierarch. for example, see check_preempt_tick()..

> scaled by priority.
> 
> Also, I'm not sure if we want to enforce sched_slice >=
> sched_min_granularity, it would mean that tasks inside task groups can
> stretch the overall period and increase latency for non-grouped tasks.

we don't need to enforce sched_slice >= sched_min_granularity. i am just 
saying that rq wide period should be stretched with rq wide nr_number with
which sched_slice() calculate actual task's slice later. 

and i agree with that it makes latency increase for non-grouped tasks.
to prevent it, IMHO, we need to fix how to calculate it. however, when 
getting *rq wide* period, stretching with local cfq's nr_number looks weird.

what do you think?

thank you,
byungchul

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


[PATCH 2/2] tty: buffers: Move hidden buffer index advance into outer loop

2015-07-12 Thread Peter Hurley
The advance of the 'read' buffer index belongs in the outer
flip buffer consume loop, with the other buffer index arithmetic.

No functional change.

Signed-off-by: Peter Hurley 
---
 drivers/tty/tty_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 25ba5af..5a3fa89 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -444,7 +444,6 @@ receive_buf(struct tty_struct *tty, struct tty_buffer 
*head, int count)
if (count)
disc->ops->receive_buf(tty, p, f, count);
}
-   head->read += count;
return count;
 }
 
@@ -506,6 +505,7 @@ static void flush_to_ldisc(struct work_struct *work)
count = receive_buf(tty, head, count);
if (!count)
break;
+   head->read += count;
}
 
mutex_unlock(>lock);
-- 
2.4.5

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


[PATCH 1/2] tty: Replace smp_rmb/smp_wmb with smp_load_acquire/smp_store_release

2015-07-12 Thread Peter Hurley
Clarify flip buffer producer/consumer operation; the use of
smp_load_acquire() and smp_store_release() more clearly indicates
which memory access requires a barrier.

Signed-off-by: Peter Hurley 
---
 drivers/tty/tty_buffer.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 4cf263d..25ba5af 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -291,12 +291,11 @@ static int __tty_buffer_request_room(struct tty_port 
*port, size_t size,
n->flags = flags;
buf->tail = n;
b->commit = b->used;
-   /* paired w/ barrier in flush_to_ldisc(); ensures the
+   /* paired w/ acquire in flush_to_ldisc(); ensures the
 * latest commit value can be read before the head is
 * advanced to the next buffer
 */
-   smp_wmb();
-   b->next = n;
+   smp_store_release(>next, n);
} else if (change)
size = 0;
else
@@ -488,12 +487,11 @@ static void flush_to_ldisc(struct work_struct *work)
if (atomic_read(>priority))
break;
 
-   next = head->next;
-   /* paired w/ barrier in __tty_buffer_request_room();
+   /* paired w/ release in __tty_buffer_request_room();
 * ensures commit value read is not stale if the head
 * is advancing to the next buffer
 */
-   smp_rmb();
+   next = smp_load_acquire(>next);
count = head->commit - head->read;
if (!count) {
if (next == NULL) {
-- 
2.4.5

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


[PATCH] tty: vt: Fix !TASK_RUNNING diagnostic warning from paste_selection()

2015-07-12 Thread Peter Hurley
Pasting text with gpm on a VC produced warning [1]. Reset task state
to TASK_RUNNING in the paste_selection() loop, if the loop did not
sleep.

[1]
WARNING: CPU: 6 PID: 1960 at 
/home/peter/src/kernels/mainline/kernel/sched/core.c:7286 
__might_sleep+0x7f/0x90()
do not call blocking ops when !TASK_RUNNING; state=1 set at 
[] paste_selection+0x9e/0x1a0
Modules linked in: btrfs xor raid6_pq ufs qnx4 hfsplus hfs minix ntfs msdos jfs 
xfs libcrc32c .
CPU: 6 PID: 1960 Comm: gpm Not tainted 4.1.0-rc7+tty-xeon+debug #rc7+tty
Hardware name: Dell Inc. Precision WorkStation T5400  /0RW203, BIOS A11 
04/30/2012
 81c9c0a0 8802b0fd3ac8 8185778a 0001
 8802b0fd3b18 8802b0fd3b08 8108039a 82ae8510
 81c9ce00 0015  
Call Trace:
 [] dump_stack+0x4f/0x7b
 [] warn_slowpath_common+0x8a/0xc0
 [] warn_slowpath_fmt+0x46/0x50
 [] ? __lock_acquire+0xe2d/0x13a0
 [] ? paste_selection+0x9e/0x1a0
 [] ? paste_selection+0x9e/0x1a0
 [] __might_sleep+0x7f/0x90
 [] down_read+0x2a/0xa0
 [] ? sched_clock_cpu+0xb8/0xe0
 [] n_tty_receive_buf_common+0x4c/0xba0
 [] ? mark_held_locks+0x75/0xa0
 [] ? _raw_spin_unlock_irqrestore+0x65/0x80
 [] ? get_parent_ip+0x11/0x50
 [] n_tty_receive_buf2+0x14/0x20
 [] paste_selection+0x157/0x1a0
 [] ? wake_up_state+0x20/0x20
 [] tioclinux+0xb8/0x2c0
 [] vt_ioctl+0xaee/0x11a0
 [] ? sched_clock_local+0x25/0x90
 [] ? vtime_account_user+0x91/0xa0
 [] tty_ioctl+0x20c/0xe20
 [] ? vtime_account_user+0x91/0xa0
 [] ? get_parent_ip+0x11/0x50
 [] ? preempt_count_sub+0x49/0x50
 [] ? context_tracking_exit+0x5c/0x290
 [] ? context_tracking_exit+0x5c/0x290
 [] do_vfs_ioctl+0x318/0x570
 [] ? trace_hardirqs_on+0xd/0x10
 [] ? trace_hardirqs_on_caller+0x115/0x1e0
 [] ? __fget_light+0x6c/0xa0
 [] SyS_ioctl+0x81/0xa0
 [] system_call_fastpath+0x16/0x7a

Signed-off-by: Peter Hurley 
---
 drivers/tty/vt/selection.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index ea27804..939c4b6 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -356,6 +356,7 @@ int paste_selection(struct tty_struct *tty)
schedule();
continue;
}
+  __set_current_state(TASK_RUNNING);
count = sel_buffer_lth - pasted;
count = tty_ldisc_receive_buf(ld, sel_buffer + pasted, NULL,
  count);
-- 
2.4.5

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


Re: [PATCH] DocBook: Avoid stdout junk with no man pages to compress

2015-07-12 Thread Ulf Magnusson
On Sun, Jul 12, 2015 at 04:36:53PM -0700, Jim Davis wrote:
> On Sun, Jul 12, 2015 at 2:59 PM, Ulf Magnusson  
> wrote:
> > gzip would run as 'gzip -f' when no uncompressed man pages were found,
> > making it compress the (empty) stdin to stdout.
> 
> > --- a/Documentation/DocBook/Makefile
> > +++ b/Documentation/DocBook/Makefile
> > @@ -56,7 +56,7 @@ htmldocs: $(HTML)
> >
> >  MAN := $(patsubst %.xml, %.9, $(BOOKS))
> >  mandocs: $(MAN)
> > -   find $(obj)/man -name '*.9' | xargs gzip -f
> > +   find $(obj)/man -name '*.9' -exec gzip -f {} \;
> >
> >  installmandocs: mandocs
> > mkdir -p /usr/local/man/man9/
> 
> That does get rid of the binary burp, but 'xargs gzip -f'  has been in
> the Makefile since January, and gzipping '\n' just started recently.
> So what's changed?
> 

No idea. I just assumed it had been broken since then, since the version
before d56fcf299fb4 (DocBook: Do not exceed argument list limit) looked
for *.9 files before running gzip:

mandocs: $(MAN)
$(if $(wildcard $(obj)/man/*.9),gzip -f $(obj)/man/*.9)

> It looks like, for whatever reason, make installmandocs always ends up
> rerunning mandocs -- there's now a 'GEN  Documentation
> Docbook//v4l2.xml' printed, and that extra mandocs invocation is where
> the problematic second invocation of find is coming from.  I won't
> pretend to understand the Makefile flow to guess at why that's
> happening, but obviously 'make mandocs; make installmandocs' shouldn't
> need to regenerate things already generated.

I won't pretend to understand the Makefile flow either. Guess it might
be worth looking into v4l2.xml as well then. Could be some directory
shenanigans going on judging from the '//'.

> 
> In any event,
> 
> Tested-by: Jim Davis 
> 
> Jim

I just noticed the commit message only mentions the alternative
solutions and not the implemented solution. Could send a v2 that fixes
that, but I'll wait for more comments first.

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


[PATCH] serial: core: Fix crashes while echoing when closing

2015-07-12 Thread Peter Hurley
While closing, new rx data may be received after the input buffers
have been flushed but before stop_rx() halts receiving [1]. The
new data might not be processed by flush_to_ldisc() until after
uart_shutdown() and normal input processing is re-enabled (ie.,
tty->closing = 0). The race is outlined below:

CPU 0 | CPU 1
  |
uart_close()  |
   tty_port_close_start() |
  tty->closing = 1|
  tty_ldisc_flush()   |
  | => IRQ
  |   while (LSR & data ready)
  |  uart_insert_char()
  |   tty_flip_buffer_push()
  | <= EOI
   stop_rx()  |   .
   uart_shutdown()|   .
  free xmit.buf   |   .
   tty_port_tty_set(NULL) |   .
   tty->closing = 0   |   .
  | flush_to_ldisc()
  |   n_tty_receive_buf_common()
  |  __receive_buf()
  | ...
  | commit_echoes()
  |uart_flush_chars()
  |   __uart_start()
  | ** OOPS on port.tty deref **
   tty_ldisc_flush()  |

Input processing must be prevented from echoing (tty->closing = 1)
until _after_ the input buffers have been flushed again at the end
of uart_close().

[1] In fact, some input may actually be buffered _after_ stop_rx()
since the rx interrupt may have already triggered but not yet been
handled when stop_rx() disables rx interrupts.

Fixes: 2e758910832d ("serial: core: Flush ldisc after dropping port
mutex in uart_close()")
Reported-by: Robert Elliot 

Signed-off-by: Peter Hurley 
---
 drivers/tty/serial/serial_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 7ae1592..f368520 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1418,7 +1418,7 @@ static void uart_close(struct tty_struct *tty, struct 
file *filp)
mutex_lock(>mutex);
uart_shutdown(tty, state);
tty_port_tty_set(port, NULL);
-   tty->closing = 0;
+
spin_lock_irqsave(>lock, flags);
 
if (port->blocked_open) {
@@ -1444,6 +1444,7 @@ static void uart_close(struct tty_struct *tty, struct 
file *filp)
mutex_unlock(>mutex);
 
tty_ldisc_flush(tty);
+   tty->closing = 0;
 }
 
 static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
-- 
2.4.5

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


Re: [PATCH v4] tty: add missing rcu_read_lock for task_pgrp

2015-07-12 Thread Peter Hurley
On 07/12/2015 06:51 PM, Patrick Donnelly wrote:
> task_pgrp requires an rcu or tasklist lock to be obtained if the returned pid
> is to be dereferenced, which kill_pgrp does. Obtain an RCU lock for the
> duration of use.

Reviewed-by: Peter Hurley 

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


Re: [PATCH] Explicitly declare the role "base_r"

2015-07-12 Thread Paul Moore
On Tue, Jul 7, 2015 at 5:10 PM, Laurent Bigonville  wrote:
> From: Laurent Bigonville 
>
> This fixes the compilation of policy generated by mdp with the recent
> version of checkpolicy.
>
> Signed-off-by: Laurent Bigonville 
> ---
>  scripts/selinux/mdp/mdp.c | 1 +
>  1 file changed, 1 insertion(+)

Merged into selinux#next, thank you.

> diff --git a/scripts/selinux/mdp/mdp.c b/scripts/selinux/mdp/mdp.c
> index 62b34ce..e10beb1 100644
> --- a/scripts/selinux/mdp/mdp.c
> +++ b/scripts/selinux/mdp/mdp.c
> @@ -98,6 +98,7 @@ int main(int argc, char *argv[])
>
> /* types, roles, and allows */
> fprintf(fout, "type base_t;\n");
> +   fprintf(fout, "role base_r;\n");
> fprintf(fout, "role base_r types { base_t };\n");
> for (i = 0; secclass_map[i].name; i++)
> fprintf(fout, "allow base_t base_t:%s *;\n",
> --
> 2.1.4

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


[GIT PULL] final init.h --> module.h code relocation

2015-07-12 Thread Paul Gortmaker
With the release of 4.2-rc2 done, we should not be seeing any new
code added that gets upset by this small code move, and we've banked
yet another complete week of testing with this move in place on top
of 4.2-rc1 via linux-next to ensure that remained true.

Given that, I'd like to put it in now so that people formulating
new work for 4.3-rc1 will be exposed to the ever so slightly
stricter (but sensible) requirements wrt. whether they are needing
init.h vs. module.h macros, even if they are not using linux-next.

The diffstat of the move is slightly asymmetrical due to needing to
leave behind a couple #ifdef in the old location and add the same
ones to the new location, but other than that, it is a 1:1 move,
complete with the module_init/exit trailing semicolon that we can't
fix.  That is, until/unless someone does a tree-wide sed fix of all
the approximately 800 currently in tree users relying on it.

Thanks,
Paul.
---

The following changes since commit d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754:

  Linux 4.2-rc1 (2015-07-05 11:01:52 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git 
tags/module-final-v4.2-rc1

for you to fetch changes up to 0fd972a7d91d6e15393c449492a04d94c0b89351:

  module: relocate module_init from init.h to module.h (2015-07-05 23:59:14 
-0400)


final init.h ---> module.h code relocation


Paul Gortmaker (1):
  module: relocate module_init from init.h to module.h

 include/linux/init.h   | 78 --
 include/linux/module.h | 84 ++
 2 files changed, 84 insertions(+), 78 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] DocBook: Avoid stdout junk with no man pages to compress

2015-07-12 Thread Jim Davis
On Sun, Jul 12, 2015 at 2:59 PM, Ulf Magnusson  wrote:
> gzip would run as 'gzip -f' when no uncompressed man pages were found,
> making it compress the (empty) stdin to stdout.

> --- a/Documentation/DocBook/Makefile
> +++ b/Documentation/DocBook/Makefile
> @@ -56,7 +56,7 @@ htmldocs: $(HTML)
>
>  MAN := $(patsubst %.xml, %.9, $(BOOKS))
>  mandocs: $(MAN)
> -   find $(obj)/man -name '*.9' | xargs gzip -f
> +   find $(obj)/man -name '*.9' -exec gzip -f {} \;
>
>  installmandocs: mandocs
> mkdir -p /usr/local/man/man9/

That does get rid of the binary burp, but 'xargs gzip -f'  has been in
the Makefile since January, and gzipping '\n' just started recently.
So what's changed?

It looks like, for whatever reason, make installmandocs always ends up
rerunning mandocs -- there's now a 'GEN  Documentation
Docbook//v4l2.xml' printed, and that extra mandocs invocation is where
the problematic second invocation of find is coming from.  I won't
pretend to understand the Makefile flow to guess at why that's
happening, but obviously 'make mandocs; make installmandocs' shouldn't
need to regenerate things already generated.

In any event,

Tested-by: Jim Davis 

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


[GIT PULL] tracing: Have branch tracer use recursive field of task struct

2015-07-12 Thread Steven Rostedt

Linus,

Fengguang Wu discovered a crash that happened to be because of the branch
tracer (traces unlikely and likely branches) when enabled with certain
debug options.

What happened was that various debug options like lockdep and DEBUG_PREEMPT
can cause parts of the branch tracer to recurse outside its recursion
protection. In fact, part of its recursion protection used these features
that caused the lockup. This cleans up the code a little and makes the
recursion protection a bit more robust.

Please pull the latest trace-v4.2-rc1-fix tree, which can be found at:


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.2-rc1-fix

Tag SHA1: fc00e43412e3155cb9f23b9ab9ddaa07d1304b22
Head SHA1: 6224beb12e190ff11f3c7d4bf50cb2922878f600


Steven Rostedt (Red Hat) (1):
  tracing: Have branch tracer use recursive field of task struct


 kernel/trace/trace.h|  1 +
 kernel/trace/trace_branch.c | 17 ++---
 2 files changed, 11 insertions(+), 7 deletions(-)
---
commit 6224beb12e190ff11f3c7d4bf50cb2922878f600
Author: Steven Rostedt (Red Hat) 
Date:   Tue Jul 7 15:05:03 2015 -0400

tracing: Have branch tracer use recursive field of task struct

Fengguang Wu's tests triggered a bug in the branch tracer's start up
test when CONFIG_DEBUG_PREEMPT set. This was because that config
adds some debug logic in the per cpu field, which calls back into
the branch tracer.

The branch tracer has its own recursive checks, but uses a per cpu
variable to implement it. If retrieving the per cpu variable calls
back into the branch tracer, you can see how things will break.

Instead of using a per cpu variable, use the trace_recursion field
of the current task struct. Simply set a bit when entering the
branch tracing and clear it when leaving. If the bit is set on
entry, just don't do the tracing.

There's also the case with lockdep, as the local_irq_save() called
before the recursion can also trigger code that can call back into
the function. Changing that to a raw_local_irq_save() will protect
that as well.

This prevents the recursion and the inevitable crash that follows.

Link: http://lkml.kernel.org/r/20150630141803.ga28...@wfg-t540p.sh.intel.com

Cc: sta...@vger.kernel.org # 3.10+
Reported-by: Fengguang Wu 
Tested-by: Fengguang Wu 
Signed-off-by: Steven Rostedt 

diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index f060716b02ae..74bde81601a9 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -444,6 +444,7 @@ enum {
 
TRACE_CONTROL_BIT,
 
+   TRACE_BRANCH_BIT,
 /*
  * Abuse of the trace_recursion.
  * As we need a way to maintain state if we are tracing the function
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index a87b43f49eb4..e2e12ad3186f 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -36,9 +36,12 @@ probe_likely_condition(struct ftrace_branch_data *f, int 
val, int expect)
struct trace_branch *entry;
struct ring_buffer *buffer;
unsigned long flags;
-   int cpu, pc;
+   int pc;
const char *p;
 
+   if (current->trace_recursion & TRACE_BRANCH_BIT)
+   return;
+
/*
 * I would love to save just the ftrace_likely_data pointer, but
 * this code can also be used by modules. Ugly things can happen
@@ -49,10 +52,10 @@ probe_likely_condition(struct ftrace_branch_data *f, int 
val, int expect)
if (unlikely(!tr))
return;
 
-   local_irq_save(flags);
-   cpu = raw_smp_processor_id();
-   data = per_cpu_ptr(tr->trace_buffer.data, cpu);
-   if (atomic_inc_return(>disabled) != 1)
+   raw_local_irq_save(flags);
+   current->trace_recursion |= TRACE_BRANCH_BIT;
+   data = this_cpu_ptr(tr->trace_buffer.data);
+   if (atomic_read(>disabled))
goto out;
 
pc = preempt_count();
@@ -81,8 +84,8 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, 
int expect)
__buffer_unlock_commit(buffer, event);
 
  out:
-   atomic_dec(>disabled);
-   local_irq_restore(flags);
+   current->trace_recursion &= ~TRACE_BRANCH_BIT;
+   raw_local_irq_restore(flags);
 }
 
 static inline
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Linux 4.2-rc2

2015-07-12 Thread Linus Torvalds
Another week, another rc. What can I say? Call me boring, but that's
how this all works.

This is not a particularly big rc, and things have been fairly calm.
We definitely did have some problems in -rc1 that bit people, but they
all seemed to be pretty small, and let's hope that -rc2 ends up having
fewer annoying issues.

The rc2 patch is roughly one third drivers (drm being the bulk of it),
one third architectures (arm, mips and parisc, a smattering of x86)
and one third "misc". That misc pile is mostly filesystems (btrfs) and
some timer updates, and then the perf tool build fix that involved
just making some of the perf tool infrastructure private to the tool
rather than trying to share it with the kernel. The shortlog below
gives more details, but you can also just scan it quickly (it's not
that big) to just get some kind of flavor for what's up.

Go out and get it, and see how it all holds up,

   Linus

---

Adrian Hunter (1):
  x86/tsc: Let high latency PIT fail fast in quick_pit_calibrate()

Al Stone (2):
  ACPI / ARM64: add BAD_MADT_GICC_ENTRY() macro
  ACPI / ARM64 : use the new BAD_MADT_GICC_ENTRY macro

Al Viro (3):
  9p: don't leave a half-initialized inode sitting around
  fix a braino in ovl_d_select_inode()
  freeing unlinked file indefinitely delayed

Alex Deucher (2):
  Revert "Revert "drm/radeon: dont switch vt on suspend""
  drm/radeon: disable vce init on cayman (v2)

Alex Ivanov (1):
  stifb: Implement hardware accelerated copyarea

Alexander Popov (1):
  x86/kasan: Fix KASAN shadow region page tables

Alexander Sverdlin (1):
  MIPS: bootmem: Don't use memory holes for page bitmap

Alistair Popple (1):
  powerpc/powernv: Fix opal-elog interrupt handler

Andrey Ryabinin (5):
  x86/init: Clear 'init_level4_pgt' earlier
  x86/kasan: Flush TLBs after switching CR3
  x86/kasan: Fix boot crash on AMD processors
  x86/kasan: Add message about KASAN being initialized
  x86/kasan: Move KASAN_SHADOW_OFFSET to the arch Kconfig

Anton Blanchard (1):
  powerpc: Add plain English description for alignment exception oopses

Ard Biesheuvel (1):
  arm64: remove another unnecessary libfdt include path

Arnaldo Carvalho de Melo (5):
  tools: Adopt {READ,WRITE_ONCE} from the kernel
  perf tools: Copy rbtree.h from the kernel
  tools: Copy lib/rbtree.c to tools/lib/
  tools: Move rbtree.h from tools/perf/
  tools: Copy rbtree_augmented.h from the kernel

Axel Lin (3):
  nvdimm: Fix return value of nvdimm_bus_init() if class_create() fails
  i2c: xgene-slimpro: Fix missing mbox_free_channel call in probe error path
  i2c: jz4780: Fix return value if probe fails

Catalin Marinas (1):
  arm64: Keep the ARM64 Kconfig selects sorted

Chris Metcalf (1):
  modpost: work correctly with tile coldtext sections

Chris Wilson (1):
  drm/i915: Declare the swizzling unknown for L-shaped configurations

Christian König (3):
  drm/radeon: allways add the VM clear duplicate
  drm/radeon: check if BO_VA is set before adding it to the
invalidation list
  drm/amdgpu: fix timeout calculation

Dan Carpenter (1):
  drm/radeon: fix underflow in r600_cp_dispatch_texture()

Dan Williams (6):
  sparse: fix misplaced __pmem definition
  libnvdimm: smatch cleanups in __nd_ioctl
  nfit: fix smatch "use after null check" report
  tools/testing/nvdimm: mock ioremap_wt
  tools/testing/nvdimm: fix return code for unimplemented commands
  tools/testing/nvdimm: add mock acpi_nfit_flush_address entries
to nfit_test

Daniel Axtens (4):
  powerpc: Set the correct kernel taint on machine check errors.
  cxl: Test the correct mmio space before unmapping
  powerpc/ppc4xx_hsta_msi: Include ppc-pci.h to fix reference to hose_list
  cxl: Check if afu is not null in cxl_slbia

Daniel Thompson (1):
  clk: stm32: Fix out-by-one error path in the index lookup

Daniel Vetter (2):
  drm/i915: Check crtc->active in intel_crtc_disable_planes
  drm/i915: Use crtc_state->active in primary check_plane func

Dave Gerlach (1):
  ARM: dts: am4372: Add emif node

David Dueck (1):
  clk: at91: do not leak resources

Dmitry Torokhov (1):
  Revert "Input: synaptics - allocate 3 slots to keep stability in
image sensors"

Eryu Guan (2):
  ext4: be more strict when migrating to non-extent based file
  ext4: correctly migrate a file with a hole at the beginning

Fabian Frederick (1):
  drm/omap: replace ALIGN(PAGE_SIZE) by PAGE_ALIGN

Filipe Manana (9):
  Btrfs: fix race between balance and unused block group deletion
  Btrfs: use kmem_cache_free when freeing entry in inode cache
  Btrfs: fix race between caching kthread and returning inode to inode cache
  Btrfs: fix crash on close_ctree() if cleaner starts new transaction
  Btrfs: fix fsync data loss after append write
  Btrfs: fix fsync xattr loss in the fast fsync path

Re: [PATCH v2] add stealth mode

2015-07-12 Thread Matteo Croce
2015-07-08 15:32 GMT+02:00 Austin S Hemmelgarn :
> On 2015-07-06 15:44, Matteo Croce wrote:
> Just to name a few that I know of off the top of my head:
> 1. IP packets with any protocol number not supported by your current kernel
> (these return a special ICMP message).

Right, I'll handle them

> 2. SCTP INIT and COOKIE_ECHO chunks when you have SCTP enabled in the
> kernel.

Well, I've never played with SCTP before

> 3. Theoretically, some IGMP messages.
> 4. NDP messages.
> 5. ARP queries looking for the machine's IP addresses.

Yes I know, but it's unlikely to receive this packets from WAN, right?
My flag is intended to be used mostly on WAN interfaces,
machines in LAN should be easily discoverable IMHO

> 6. Certain odd flag combinations on single TCP packets (check the
> documentation for Nmap for more info regarding these), which I believe
> (although I may be reading the code wrong) you aren't accounting for.

I've tried many TCP flags combination with hping3, NUL, SYN/ACK, ACK,
SYN/FIN, etc.
They doesn't get any response when the flag is set

> 7. DAD queries.

Never looked at this packets, are a subset of NDP?

> 8. ICMP address mask queries (which you also don't appear to account for).

It's deprecated and actually it doesn't get any response already

> This is by no means an exhaustive list, but all of them really should be
> addressed if you want to do this properly.
>
>

Thank you,
-- 
Matteo Croce
OpenWrt Developer
  ___ __
 |   |.-.-.-.|  |  |  |..|  |_
 |   -   ||  _  |  -__| ||  |  |  ||   _||   _|
 |___||   __|_|__|__||||__|  ||
  |__| W I R E L E S S   F R E E D O M
 -
 CHAOS CALMER
 -
  * 1 1/2 oz GinShake with a glassful
  * 1/4 oz Triple Sec   of broken ice and pour
  * 3/4 oz Lime Juice   unstrained into a goblet.
  * 1 1/2 oz Orange Juice
  * 1 tsp. Grenadine Syrup
 -
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 8/9] MIPS: Remove "weak" from mips_cdmm_phys_base() declaration

2015-07-12 Thread Bjorn Helgaas
Weak header file declarations are error-prone because they make every
definition weak, and the linker chooses one based on link order (see
10629d711ed7 ("PCI: Remove __weak annotation from pcibios_get_phb_of_node
decl")).

mips_cdmm_phys_base() is defined only in arch/mips/mti-malta/malta-memory.c
so there's no problem with multiple definitions.  But it works better to
have a weak default implementation and allow a strong function to override
it.  Then we don't have to test whether a definition is present, and if
there are ever multiple strong definitions, we get a link error instead of
calling a random definition.

Add a weak mips_cdmm_phys_base() definition and remove the weak annotation
from the declaration in arch/mips/include/asm/cdmm.h.

Signed-off-by: Bjorn Helgaas 
CC: James Hogan 
---
 arch/mips/include/asm/cdmm.h |4 ++--
 drivers/bus/mips_cdmm.c  |   14 +-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/cdmm.h b/arch/mips/include/asm/cdmm.h
index 16e22ce..bece206 100644
--- a/arch/mips/include/asm/cdmm.h
+++ b/arch/mips/include/asm/cdmm.h
@@ -53,7 +53,7 @@ struct mips_cdmm_driver {
  * mips_cdmm_phys_base() - Choose a physical base address for CDMM region.
  *
  * Picking a suitable physical address at which to map the CDMM region is
- * platform specific, so this weak function can be defined by platform code to
+ * platform specific, so this function can be defined by platform code to
  * pick a suitable value if none is configured by the bootloader.
  *
  * This address must be 32kB aligned, and the region occupies a maximum of 32kB
@@ -61,7 +61,7 @@ struct mips_cdmm_driver {
  *
  * Returns:Physical base address for CDMM region, or 0 on failure.
  */
-phys_addr_t __weak mips_cdmm_phys_base(void);
+phys_addr_t mips_cdmm_phys_base(void);
 
 extern struct bus_type mips_cdmm_bustype;
 void __iomem *mips_cdmm_early_probe(unsigned int dev_type);
diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c
index ab3bde1..1c543ef 100644
--- a/drivers/bus/mips_cdmm.c
+++ b/drivers/bus/mips_cdmm.c
@@ -332,6 +332,18 @@ static phys_addr_t mips_cdmm_cur_base(void)
 }
 
 /**
+ * mips_cdmm_phys_base() - Choose a physical base address for CDMM region.
+ *
+ * Picking a suitable physical address at which to map the CDMM region is
+ * platform specific, so this weak function can be overridden by platform
+ * code to pick a suitable value if none is configured by the bootloader.
+ */
+phys_addr_t __weak mips_cdmm_phys_base(void)
+{
+   return 0;
+}
+
+/**
  * mips_cdmm_setup() - Ensure the CDMM bus is initialised and usable.
  * @bus:   Pointer to bus information for current CPU.
  * IS_ERR(bus) is checked, so no need for caller to check.
@@ -368,7 +380,7 @@ static int mips_cdmm_setup(struct mips_cdmm_bus *bus)
if (!bus->phys)
bus->phys = mips_cdmm_cur_base();
/* Otherwise, ask platform code for suggestions */
-   if (!bus->phys && mips_cdmm_phys_base)
+   if (!bus->phys)
bus->phys = mips_cdmm_phys_base();
/* Otherwise, copy what other CPUs have done */
if (!bus->phys)

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


[PATCH 9/9] MIPS: Remove "__weak" definition from arch-specific linkage.h

2015-07-12 Thread Bjorn Helgaas
"__weak" is defined in include/linux/compiler-gcc.h.  We shouldn't need an
arch-specific definition.

Remove the "__weak" definition from arch/mips/include/asm/linkage.h.

Signed-off-by: Bjorn Helgaas 
---
 arch/mips/include/asm/linkage.h |1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/mips/include/asm/linkage.h b/arch/mips/include/asm/linkage.h
index 2767dda..99651b0 100644
--- a/arch/mips/include/asm/linkage.h
+++ b/arch/mips/include/asm/linkage.h
@@ -5,7 +5,6 @@
 #include 
 #endif
 
-#define __weak __attribute__((weak))
 #define cond_syscall(x) asm(".weak\t" #x "\n" #x "\t=\tsys_ni_syscall")
 #define SYSCALL_ALIAS(alias, name) \
asm ( #alias " = " #name "\n\t.globl " #alias)

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


[PATCH 7/9] MIPS: Remove "weak" from get_c0_fdc_int() declaration

2015-07-12 Thread Bjorn Helgaas
Weak header file declarations are error-prone because they make every
definition weak, and the linker chooses one based on link order (see
10629d711ed7 ("PCI: Remove __weak annotation from pcibios_get_phb_of_node
decl")).

get_c0_fdc_int() is defined only in arch/mips/mti-malta/malta-time.c so
there's no problem with multiple definitions.  But it works better to have
a weak default implementation and allow a strong function to override it.
Then we don't have to test whether a definition is present, and if there
are ever multiple strong definitions, we get a link error instead of
calling a random definition.

Add a weak get_c0_fdc_int() definition with the default code and remove the
weak annotation from the declaration.

Signed-off-by: Bjorn Helgaas 
CC: James Hogan 
---
 arch/mips/include/asm/irq.h  |2 +-
 drivers/tty/mips_ejtag_fdc.c |9 ++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h
index f0db99f8..15e0fec 100644
--- a/arch/mips/include/asm/irq.h
+++ b/arch/mips/include/asm/irq.h
@@ -49,7 +49,7 @@ extern int cp0_compare_irq_shift;
 extern int cp0_perfcount_irq;
 extern int cp0_fdc_irq;
 
-extern int __weak get_c0_fdc_int(void);
+extern int get_c0_fdc_int(void);
 
 void arch_trigger_all_cpu_backtrace(bool);
 #define arch_trigger_all_cpu_backtrace arch_trigger_all_cpu_backtrace
diff --git a/drivers/tty/mips_ejtag_fdc.c b/drivers/tty/mips_ejtag_fdc.c
index 358323c..a8c8cfd 100644
--- a/drivers/tty/mips_ejtag_fdc.c
+++ b/drivers/tty/mips_ejtag_fdc.c
@@ -879,6 +879,11 @@ static const struct tty_operations mips_ejtag_fdc_tty_ops 
= {
.chars_in_buffer= mips_ejtag_fdc_tty_chars_in_buffer,
 };
 
+int __weak get_c0_fdc_int(void)
+{
+   return -1;
+}
+
 static int mips_ejtag_fdc_tty_probe(struct mips_cdmm_device *dev)
 {
int ret, nport;
@@ -967,9 +972,7 @@ static int mips_ejtag_fdc_tty_probe(struct mips_cdmm_device 
*dev)
wake_up_process(priv->thread);
 
/* Look for an FDC IRQ */
-   priv->irq = -1;
-   if (get_c0_fdc_int)
-   priv->irq = get_c0_fdc_int();
+   priv->irq = get_c0_fdc_int();
 
/* Try requesting the IRQ */
if (priv->irq >= 0) {

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


[PATCH 6/9] MIPS: Remove "weak" from get_c0_compare_int() declaration

2015-07-12 Thread Bjorn Helgaas
Weak header file declarations are error-prone because they make every
definition weak, and the linker chooses one based on link order (see
10629d711ed7 ("PCI: Remove __weak annotation from pcibios_get_phb_of_node
decl")).

get_c0_compare_int() is defined in several files.  Each definition is weak,
so I assume Kconfig prevents two or more from being included.  The caller
contains default code used when get_c0_compare_int() isn't defined at all.

Add a weak get_c0_compare_int() definition with the default code and remove
the weak annotation from the declaration.

Then the platform implementations will be strong and will override the weak
default.  If multiple platforms are ever configured in, we'll get a link
error instead of calling a random platform's implementation.

Signed-off-by: Bjorn Helgaas 
---
 arch/mips/include/asm/time.h |2 +-
 arch/mips/kernel/cevt-r4k.c  |   11 +++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h
index ce6a7d5..44a9c3a 100644
--- a/arch/mips/include/asm/time.h
+++ b/arch/mips/include/asm/time.h
@@ -51,7 +51,7 @@ extern int get_c0_perfcount_int(void);
 /*
  * Initialize the calling CPU's compare interrupt as clockevent device
  */
-extern unsigned int __weak get_c0_compare_int(void);
+extern unsigned int get_c0_compare_int(void);
 extern int r4k_clockevent_init(void);
 
 static inline int mips_clockevent_init(void)
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index d70c4d8..cc7cc46 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -174,6 +174,11 @@ int c0_compare_int_usable(void)
return 1;
 }
 
+unsigned int __weak get_c0_compare_int(void)
+{
+   return MIPS_CPU_IRQ_BASE + cp0_compare_irq;
+}
+
 int r4k_clockevent_init(void)
 {
unsigned int cpu = smp_processor_id();
@@ -189,11 +194,9 @@ int r4k_clockevent_init(void)
/*
 * With vectored interrupts things are getting platform specific.
 * get_c0_compare_int is a hook to allow a platform to return the
-* interrupt number of it's liking.
+* interrupt number of its liking.
 */
-   irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq;
-   if (get_c0_compare_int)
-   irq = get_c0_compare_int();
+   irq = get_c0_compare_int();
 
cd = _cpu(mips_clockevent_device, cpu);
 

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


[PATCH 5/9] MIPS: Remove "weak" from get_c0_perfcount_int() declaration

2015-07-12 Thread Bjorn Helgaas
Weak header file declarations are error-prone because they make every
definition weak, and the linker chooses one based on link order (see
10629d711ed7 ("PCI: Remove __weak annotation from pcibios_get_phb_of_node
decl")).

get_c0_perfcount_int() is defined in several files.  Every definition is
weak, so I assume Kconfig prevents two or more from being included.  The
callers contain identical default code used when get_c0_perfcount_int()
isn't defined at all.

Add a weak get_c0_perfcount_int() definition with the default code and
remove the weak annotation from the declaration.

Then the platform implementations will be strong and will override the weak
default.  If multiple platforms are ever configured in, we'll get a link
error instead of calling a random platform's implementation.

Signed-off-by: Bjorn Helgaas 
CC: Andrew Bresticker 
---
 arch/mips/include/asm/time.h |2 +-
 arch/mips/kernel/perf_event_mipsxx.c |7 +--
 arch/mips/kernel/time.c  |   10 +-
 arch/mips/oprofile/op_model_mipsxx.c |8 +---
 4 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h
index 8ab2874..ce6a7d5 100644
--- a/arch/mips/include/asm/time.h
+++ b/arch/mips/include/asm/time.h
@@ -46,7 +46,7 @@ extern unsigned int mips_hpt_frequency;
  * so it lives here.
  */
 extern int (*perf_irq)(void);
-extern int __weak get_c0_perfcount_int(void);
+extern int get_c0_perfcount_int(void);
 
 /*
  * Initialize the calling CPU's compare interrupt as clockevent device
diff --git a/arch/mips/kernel/perf_event_mipsxx.c 
b/arch/mips/kernel/perf_event_mipsxx.c
index cc1b6fa..c126b1c 100644
--- a/arch/mips/kernel/perf_event_mipsxx.c
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -1682,12 +1682,7 @@ init_hw_perf_events(void)
counters = counters_total_to_per_cpu(counters);
 #endif
 
-   if (get_c0_perfcount_int)
-   irq = get_c0_perfcount_int();
-   else if (cp0_perfcount_irq >= 0)
-   irq = MIPS_CPU_IRQ_BASE + cp0_perfcount_irq;
-   else
-   irq = -1;
+   irq = get_c0_perfcount_int();
 
mipspmu.map_raw_event = mipsxx_pmu_map_raw_event;
 
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 8d01709..ec7082d 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -55,9 +55,17 @@ static int null_perf_irq(void)
 }
 
 int (*perf_irq)(void) = null_perf_irq;
-
 EXPORT_SYMBOL(perf_irq);
 
+#ifdef MIPS_CPU_IRQ_BASE
+int __weak get_c0_perfcount_int(void)
+{
+   if (cp0_perfcount_irq >= 0)
+   return MIPS_CPU_IRQ_BASE + cp0_perfcount_irq;
+   return -1;
+}
+#endif
+
 /*
  * time_init() - it does the following things.
  *
diff --git a/arch/mips/oprofile/op_model_mipsxx.c 
b/arch/mips/oprofile/op_model_mipsxx.c
index 6a6e2cc..c0cffa9 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -438,13 +438,7 @@ static int __init mipsxx_init(void)
save_perf_irq = perf_irq;
perf_irq = mipsxx_perfcount_handler;
 
-   if (get_c0_perfcount_int)
-   perfcount_irq = get_c0_perfcount_int();
-   else if (cp0_perfcount_irq >= 0)
-   perfcount_irq = MIPS_CPU_IRQ_BASE + cp0_perfcount_irq;
-   else
-   perfcount_irq = -1;
-
+   perfcount_irq = get_c0_perfcount_int();
if (perfcount_irq >= 0)
return request_irq(perfcount_irq, mipsxx_perfcount_int,
   IRQF_PERCPU | IRQF_NOBALANCING |

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


[PATCH 3/9] MIPS: VPE: Exit vpe_release() early if vpe_run() isn't defined

2015-07-12 Thread Bjorn Helgaas
vpe_run() is a weak symbol.  If there's no definition of it, its value is
zero.

If vpe_run is zero, return failure early.  We're going to fail anyway, so
there's no point in getting a VPE and attempting to load it.

Signed-off-by: Bjorn Helgaas 
---
 arch/mips/kernel/vpe.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 11da314..72cae9f 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -821,13 +821,18 @@ static int vpe_release(struct inode *inode, struct file 
*filp)
Elf_Ehdr *hdr;
int ret = 0;
 
+   if (!vpe_run) {
+   pr_warn("VPE loader: ELF load failed.\n");
+   return -ENOEXEC;
+   }
+
v = get_vpe(aprp_cpu_index());
if (v == NULL)
return -ENODEV;
 
hdr = (Elf_Ehdr *) v->pbuffer;
if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) == 0) {
-   if ((vpe_elfload(v) >= 0) && vpe_run) {
+   if (vpe_elfload(v) >= 0) {
vpe_run(v);
} else {
pr_warn("VPE loader: ELF load failed.\n");

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


[PATCH 4/9] MIPS: MT: Remove "weak" from vpe_run() declaration

2015-07-12 Thread Bjorn Helgaas
Weak header file declarations are error-prone because they make every
definition weak, and the linker chooses one based on link order (see
10629d711ed7 ("PCI: Remove __weak annotation from pcibios_get_phb_of_node
decl")).

That's not a problem for vpe_run() because Kconfig ensures there's never
more than one definition:

  - vpe_run() is defined in arch/mips/kernel/vpe-mt.c if
CONFIG_MIPS_VPE_LOADER_MT=y

  - vpe_run() is defined in arch/mips/mti-malta/malta-amon.c if
CONFIG_MIPS_CMP=y

  - CONFIG_MIPS_VPE_LOADER_MT cannot be set if CONFIG_MIPS_CMP=y

But it's simpler to verify correctness if we remove "weak" from the picture
and test the config symbols directly.

Remove "weak" from the vpe_run() declaration and use #if to test whether a
definition should be present.

Signed-off-by: Bjorn Helgaas 
---
 arch/mips/include/asm/vpe.h |2 +-
 arch/mips/kernel/vpe.c  |   10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/mips/include/asm/vpe.h b/arch/mips/include/asm/vpe.h
index 7849f39..80e70db 100644
--- a/arch/mips/include/asm/vpe.h
+++ b/arch/mips/include/asm/vpe.h
@@ -122,7 +122,7 @@ void release_vpe(struct vpe *v);
 void *alloc_progmem(unsigned long len);
 void release_progmem(void *ptr);
 
-int __weak vpe_run(struct vpe *v);
+int vpe_run(struct vpe *v);
 void cleanup_tc(struct tc *tc);
 
 int __init vpe_module_init(void);
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 72cae9f..04539d6 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -817,15 +817,11 @@ static int vpe_open(struct inode *inode, struct file 
*filp)
 
 static int vpe_release(struct inode *inode, struct file *filp)
 {
+#if defined(CONFIG_MIPS_VPE_LOADER_MT) || defined(CONFIG_MIPS_CMP)
struct vpe *v;
Elf_Ehdr *hdr;
int ret = 0;
 
-   if (!vpe_run) {
-   pr_warn("VPE loader: ELF load failed.\n");
-   return -ENOEXEC;
-   }
-
v = get_vpe(aprp_cpu_index());
if (v == NULL)
return -ENODEV;
@@ -855,6 +851,10 @@ static int vpe_release(struct inode *inode, struct file 
*filp)
v->plen = 0;
 
return ret;
+#else
+   pr_warn("VPE loader: ELF load failed.\n");
+   return -ENOEXEC;
+#endif
 }
 
 static ssize_t vpe_write(struct file *file, const char __user *buffer,

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


[PATCH 2/9] MIPS: Remove "weak" from platform_maar_init() declaration

2015-07-12 Thread Bjorn Helgaas
Weak header file declarations are error-prone because they make every
definition weak, and the linker chooses one based on link order (see
10629d711ed7 ("PCI: Remove __weak annotation from pcibios_get_phb_of_node
decl")).

platform_maar_init() is defined in:

  - arch/mips/mm/init.c (where it is marked "weak")
  - arch/mips/mti-malta/malta-memory.c (without annotation)

The "weak" attribute on the platform_maar_init() extern declaration applies
to the platform-specific definition in arch/mips/mti-malta/malta-memory.c,
so both definitions are weak, and which one we get depends on link order.

Remove the "weak" attribute from the declaration.  That makes the malta
definition strong, so it will always be preferred if it is present.

Signed-off-by: Bjorn Helgaas 
CC: linux-m...@linux-mips.org
---
 arch/mips/include/asm/maar.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/maar.h b/arch/mips/include/asm/maar.h
index 6c62b0f..b02891f 100644
--- a/arch/mips/include/asm/maar.h
+++ b/arch/mips/include/asm/maar.h
@@ -26,7 +26,7 @@
  *
  * Return: The number of MAAR pairs configured.
  */
-unsigned __weak platform_maar_init(unsigned num_pairs);
+unsigned platform_maar_init(unsigned num_pairs);
 
 /**
  * write_maar_pair() - write to a pair of MAARs

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


[PATCH 1/9] MIPS: CPC: Remove "weak" from mips_cpc_phys_base() and make it static

2015-07-12 Thread Bjorn Helgaas
There's only one implementation of mips_cpc_phys_base(), and it's only used
within the same file, so it doesn't need to be weak, and it doesn't need an
extern declaration.

Remove the extern mips_cpc_phys_base() declaration and make it static.

Signed-off-by: Bjorn Helgaas 
CC: linux-m...@linux-mips.org
---
 arch/mips/include/asm/mips-cpc.h |   10 --
 arch/mips/kernel/mips-cpc.c  |9 -
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/arch/mips/include/asm/mips-cpc.h b/arch/mips/include/asm/mips-cpc.h
index 1cebe8c..f386f32 100644
--- a/arch/mips/include/asm/mips-cpc.h
+++ b/arch/mips/include/asm/mips-cpc.h
@@ -28,16 +28,6 @@ extern void __iomem *mips_cpc_base;
 extern phys_addr_t mips_cpc_default_phys_base(void);
 
 /**
- * mips_cpc_phys_base - retrieve the physical base address of the CPC
- *
- * This function returns the physical base address of the Cluster Power
- * Controller memory mapped registers, or 0 if no Cluster Power Controller
- * is present. It may be overriden by individual platforms which determine
- * this address in a different way.
- */
-extern phys_addr_t __weak mips_cpc_phys_base(void);
-
-/**
  * mips_cpc_probe - probe for a Cluster Power Controller
  *
  * Attempt to detect the presence of a Cluster Power Controller. Returns 0 if
diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c
index 1196450..7e9ea9b 100644
--- a/arch/mips/kernel/mips-cpc.c
+++ b/arch/mips/kernel/mips-cpc.c
@@ -21,7 +21,14 @@ static DEFINE_PER_CPU_ALIGNED(spinlock_t, cpc_core_lock);
 
 static DEFINE_PER_CPU_ALIGNED(unsigned long, cpc_core_lock_flags);
 
-phys_addr_t __weak mips_cpc_phys_base(void)
+/**
+ * mips_cpc_phys_base - retrieve the physical base address of the CPC
+ *
+ * This function returns the physical base address of the Cluster Power
+ * Controller memory mapped registers, or 0 if no Cluster Power Controller
+ * is present.
+ */
+static phys_addr_t mips_cpc_phys_base(void)
 {
u32 cpc_base;
 

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


[PATCH 0/9] MIPS: Remove "weak" usage

2015-07-12 Thread Bjorn Helgaas
These patches don't fix any problem I'm aware of, but I think they make the
code easier to analyze, and they reduce the likelihood of issues if MIPS
ever builds a multi-platform kernel.

Weak function declarations in header files are hard to use safely because
they make every definition weak.  If the linker sees multiple weak
definitions, it silently chooses one based on link order.  That's not a
very obvious criterion, and it can easily lead to running the wrong
version.

These patches remove the weak attribute from function declarations and 
rework the code to match.  I don't have any of these platforms, so I can't
test them, but my intent is that these should cause no functional change.

---

Bjorn Helgaas (9):
  MIPS: CPC: Remove "weak" from mips_cpc_phys_base() and make it static
  MIPS: Remove "weak" from platform_maar_init() declaration
  MIPS: VPE: Exit vpe_release() early if vpe_run() isn't defined
  MIPS: MT: Remove "weak" from vpe_run() declaration
  MIPS: Remove "weak" from get_c0_perfcount_int() declaration
  MIPS: Remove "weak" from get_c0_compare_int() declaration
  MIPS: Remove "weak" from get_c0_fdc_int() declaration
  MIPS: Remove "weak" from mips_cdmm_phys_base() declaration
  MIPS: Remove "__weak" definition from arch-specific linkage.h


 arch/mips/include/asm/cdmm.h |4 ++--
 arch/mips/include/asm/irq.h  |2 +-
 arch/mips/include/asm/linkage.h  |1 -
 arch/mips/include/asm/maar.h |2 +-
 arch/mips/include/asm/mips-cpc.h |   10 --
 arch/mips/include/asm/time.h |4 ++--
 arch/mips/include/asm/vpe.h  |2 +-
 arch/mips/kernel/cevt-r4k.c  |   11 +++
 arch/mips/kernel/mips-cpc.c  |9 -
 arch/mips/kernel/perf_event_mipsxx.c |7 +--
 arch/mips/kernel/time.c  |   10 +-
 arch/mips/kernel/vpe.c   |7 ++-
 arch/mips/oprofile/op_model_mipsxx.c |8 +---
 drivers/bus/mips_cdmm.c  |   14 +-
 drivers/tty/mips_ejtag_fdc.c |9 ++---
 15 files changed, 58 insertions(+), 42 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: V4.1-RC build error after commit 77a3c6f

2015-07-12 Thread Laurent Pinchart
Hi Larry,

Thank you for the report.

On Saturday 11 July 2015 16:27:36 Larry Finger wrote:
> Beginning with the commit in the subject, I get the following build error:
> 
>CC [M]  drivers/media/v4l2-core/videobuf2-core.o
> drivers/media/v4l2-core/videobuf2-core.c: In function
> ‘vb2_warn_zero_bytesused’: drivers/media/v4l2-core/videobuf2-core.c:1253:2:
> error: implicit declaration of function ‘__WARN’
> [-Werror=implicit-function-declaration]
>__WARN();
>^
> cc1: some warnings being treated as errors
> 
> My .config is attached.

Indeed, __WARN isn't defined when CONFIG_BUG isn't set. My bad :-/

I've send a patch to fix this (you've been CC'ed), could you please review it 
?

And I've just noticed that I forgot to add your Reported-by: tag, please feel 
free to add it to the review.

> This problem has been bisected to the following commit:
> 
> commit 77a3c6fd90c94f635edb00d4a65f485687538791
> Author: Laurent Pinchart 
> Date:   Fri Jun 19 08:50:07 2015 -0300
> 
>  [media] vb2: Don't WARN when v4l2_buffer.bytesused is 0 for multiplanar
> buffers
> 
>  Commit f61bf13b6a07 ("[media] vb2: add allow_zero_bytesused flag to the
> vb2_queue struct") added a WARN_ONCE to catch usage of a deprecated API
> using a zero value for v4l2_buffer.bytesused.
> 
>  However, the condition is checked incorrectly, as the v4L2_buffer
>  bytesused field is supposed to be ignored for multiplanar buffers. This
> results in spurious warnings when using the multiplanar API.
> 
>  Fix it by checking v4l2_buffer.bytesused for uniplanar buffers and
>  v4l2_plane.bytesused for multiplanar buffers.
> 
>  Fixes: f61bf13b6a07 ("[media] vb2: add allow_zero_bytesused flag to the
> vb2_queue struct")
> 
>  Signed-off-by: Laurent Pinchart
>  Cc: sta...@vger.kernel.org #
> for v4.0
>  Signed-off-by: Mauro Carvalho Chehab 
> 
> Thanks,
> 
> Larry

-- 
Regards,

Laurent Pinchart

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


[PATCH v4] tty: add missing rcu_read_lock for task_pgrp

2015-07-12 Thread Patrick Donnelly
task_pgrp requires an rcu or tasklist lock to be obtained if the returned pid
is to be dereferenced, which kill_pgrp does. Obtain an RCU lock for the
duration of use.

Signed-off-by: Patrick Donnelly 
---
 drivers/tty/n_tty.c  | 15 ---
 drivers/tty/tty_io.c | 17 -
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index c9c27f6..de67b2c 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2137,6 +2137,8 @@ extern ssize_t redirected_tty_write(struct file *, const 
char __user *,
 
 static int job_control(struct tty_struct *tty, struct file *file)
 {
+   struct pid *pgrp;
+
/* Job control check -- must be done at start and after
   every sleep (POSIX.1 7.1.1.4). */
/* NOTE: not yet done after every sleep pending a thorough
@@ -2146,18 +2148,25 @@ static int job_control(struct tty_struct *tty, struct 
file *file)
current->signal->tty != tty)
return 0;
 
+   rcu_read_lock();
+   pgrp = task_pgrp(current);
+
spin_lock_irq(>ctrl_lock);
if (!tty->pgrp)
printk(KERN_ERR "n_tty_read: no tty->pgrp!\n");
-   else if (task_pgrp(current) != tty->pgrp) {
+   else if (pgrp != tty->pgrp) {
spin_unlock_irq(>ctrl_lock);
-   if (is_ignored(SIGTTIN) || is_current_pgrp_orphaned())
+   if (is_ignored(SIGTTIN) || is_current_pgrp_orphaned()) {
+   rcu_read_unlock();
return -EIO;
-   kill_pgrp(task_pgrp(current), SIGTTIN, 1);
+   }
+   kill_pgrp(pgrp, SIGTTIN, 1);
+   rcu_read_unlock();
set_thread_flag(TIF_SIGPENDING);
return -ERESTARTSYS;
}
spin_unlock_irq(>ctrl_lock);
+   rcu_read_unlock();
return 0;
 }
 
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 57fc6ee..6bdfb98 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -388,33 +388,40 @@ EXPORT_SYMBOL_GPL(tty_find_polling_driver);
 int tty_check_change(struct tty_struct *tty)
 {
unsigned long flags;
+   struct pid *pgrp;
int ret = 0;
 
if (current->signal->tty != tty)
return 0;
 
+   rcu_read_lock();
+   pgrp = task_pgrp(current);
+
spin_lock_irqsave(>ctrl_lock, flags);
 
if (!tty->pgrp) {
printk(KERN_WARNING "tty_check_change: tty->pgrp == NULL!\n");
goto out_unlock;
}
-   if (task_pgrp(current) == tty->pgrp)
+   if (pgrp == tty->pgrp)
goto out_unlock;
spin_unlock_irqrestore(>ctrl_lock, flags);
+
if (is_ignored(SIGTTOU))
-   goto out;
+   goto out_rcuunlock;
if (is_current_pgrp_orphaned()) {
ret = -EIO;
-   goto out;
+   goto out_rcuunlock;
}
-   kill_pgrp(task_pgrp(current), SIGTTOU, 1);
+   kill_pgrp(pgrp, SIGTTOU, 1);
+   rcu_read_unlock();
set_thread_flag(TIF_SIGPENDING);
ret = -ERESTARTSYS;
-out:
return ret;
 out_unlock:
spin_unlock_irqrestore(>ctrl_lock, flags);
+out_rcuunlock:
+   rcu_read_unlock();
return ret;
 }
 
-- 
Patrick Donnelly

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


Re: [PATCH v3] tty: add missing rcu_read_lock for task_pgrp

2015-07-12 Thread Patrick Donnelly
On Sat, Jul 11, 2015 at 10:05 PM, Peter Hurley  wrote:
> I just realized there's a missing rcu_read_unlock() from this early return.

Nice catch. I'll send a new series out...

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


[PATCH 3/3] IRQ: Print "unexpected IRQ" messages consistently across architectures

2015-07-12 Thread Bjorn Helgaas
Many architectures use a variant of "unexpected IRQ trap at vector %x" to
log unexpected IRQs.  This is confusing because (a) it prints the Linux IRQ
number, but "vector" more often refers to a CPU vector number, and (b) it
prints the IRQ number in hex with no base indication, while Linux IRQ
numbers are usually printed in decimal.

Print the same text ("unexpected IRQ %d") across all architectures.

No functional change other than the output text.

Signed-off-by: Bjorn Helgaas 
---
 arch/alpha/kernel/irq.c|2 +-
 arch/blackfin/kernel/irqchip.c |2 +-
 arch/c6x/kernel/irq.c  |2 +-
 arch/ia64/kernel/irq.c |2 +-
 arch/m68k/include/asm/hardirq.h|2 +-
 arch/mips/kernel/irq.c |2 +-
 arch/mn10300/kernel/irq.c  |2 +-
 arch/parisc/include/asm/hardirq.h  |2 +-
 arch/powerpc/include/asm/hardirq.h |2 +-
 arch/s390/include/asm/hardirq.h|2 +-
 arch/sh/kernel/irq.c   |2 +-
 arch/tile/kernel/irq.c |2 +-
 arch/x86/kernel/irq.c  |2 +-
 include/asm-generic/hardirq.h  |2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c
index 51f2c86..9acdc14 100644
--- a/arch/alpha/kernel/irq.c
+++ b/arch/alpha/kernel/irq.c
@@ -34,7 +34,7 @@ DEFINE_PER_CPU(unsigned long, irq_pmi_count);
 void ack_bad_irq(unsigned int irq)
 {
irq_err_count++;
-   printk(KERN_CRIT "Unexpected IRQ trap at vector %u\n", irq);
+   printk(KERN_CRIT "Unexpected IRQ %d\n", irq);
 }
 
 #ifdef CONFIG_SMP 
diff --git a/arch/blackfin/kernel/irqchip.c b/arch/blackfin/kernel/irqchip.c
index 0ba2576..608741e 100644
--- a/arch/blackfin/kernel/irqchip.c
+++ b/arch/blackfin/kernel/irqchip.c
@@ -20,7 +20,7 @@ static atomic_t irq_err_count;
 void ack_bad_irq(unsigned int irq)
 {
atomic_inc(_err_count);
-   printk(KERN_ERR "IRQ: spurious interrupt %d\n", irq);
+   printk(KERN_ERR "unexpected IRQ %d\n", irq);
 }
 
 static struct irq_desc bad_irq_desc = {
diff --git a/arch/c6x/kernel/irq.c b/arch/c6x/kernel/irq.c
index 247e0eb..cd7fb55 100644
--- a/arch/c6x/kernel/irq.c
+++ b/arch/c6x/kernel/irq.c
@@ -120,7 +120,7 @@ void __init init_IRQ(void)
 
 void ack_bad_irq(int irq)
 {
-   printk(KERN_ERR "IRQ: spurious interrupt %d\n", irq);
+   printk(KERN_ERR "unexpected IRQ %d\n", irq);
irq_err_count++;
 }
 
diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
index 812a1e6..b198c69 100644
--- a/arch/ia64/kernel/irq.c
+++ b/arch/ia64/kernel/irq.c
@@ -31,7 +31,7 @@
  */
 void ack_bad_irq(unsigned int irq)
 {
-   printk(KERN_ERR "Unexpected irq vector 0x%x on CPU %u!\n", irq, 
smp_processor_id());
+   printk(KERN_ERR "unexpected IRQ %d on CPU %u!\n", irq, 
smp_processor_id());
 }
 
 #ifdef CONFIG_IA64_GENERIC
diff --git a/arch/m68k/include/asm/hardirq.h b/arch/m68k/include/asm/hardirq.h
index 6c61852..5f0fe98 100644
--- a/arch/m68k/include/asm/hardirq.h
+++ b/arch/m68k/include/asm/hardirq.h
@@ -9,7 +9,7 @@
 
 static inline void ack_bad_irq(unsigned int irq)
 {
-   pr_crit("unexpected IRQ trap at vector %02x\n", irq);
+   pr_crit("unexpected IRQ %d\n", irq);
 }
 
 /* entry.S is sensitive to the offsets of these fields */
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index 8eb5af8..f6b9ce9 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -31,7 +31,7 @@
  */
 void ack_bad_irq(unsigned int irq)
 {
-   printk("unexpected IRQ # %d\n", irq);
+   printk("unexpected IRQ %d\n", irq);
 }
 
 atomic_t irq_err_count;
diff --git a/arch/mn10300/kernel/irq.c b/arch/mn10300/kernel/irq.c
index 480de70..c7b780d 100644
--- a/arch/mn10300/kernel/irq.c
+++ b/arch/mn10300/kernel/irq.c
@@ -197,7 +197,7 @@ static struct irq_chip mn10300_cpu_pic_edge = {
  */
 void ack_bad_irq(int irq)
 {
-   printk(KERN_WARNING "unexpected IRQ trap at vector %02x\n", irq);
+   printk(KERN_WARNING "unexpected IRQ %d\n", irq);
 }
 
 /*
diff --git a/arch/parisc/include/asm/hardirq.h 
b/arch/parisc/include/asm/hardirq.h
index 9b3bd03..c093c4f 100644
--- a/arch/parisc/include/asm/hardirq.h
+++ b/arch/parisc/include/asm/hardirq.h
@@ -41,6 +41,6 @@ DECLARE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
this_cpu_write(irq_stat.__softirq_pending, (x))
 #define or_softirq_pending(x)  this_cpu_or(irq_stat.__softirq_pending, (x))
 
-#define ack_bad_irq(irq) WARN(1, "unexpected IRQ trap at vector %02x\n", irq)
+#define ack_bad_irq(irq) WARN(1, "unexpected IRQ %d\n", irq)
 
 #endif /* _PARISC_HARDIRQ_H */
diff --git a/arch/powerpc/include/asm/hardirq.h 
b/arch/powerpc/include/asm/hardirq.h
index 8add8b8..aa8ebbb 100644
--- a/arch/powerpc/include/asm/hardirq.h
+++ b/arch/powerpc/include/asm/hardirq.h
@@ -30,7 +30,7 @@ DECLARE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
 
 static inline void ack_bad_irq(unsigned int irq)
 {
-   printk(KERN_CRIT "unexpected IRQ trap at 

  1   2   3   4   5   6   >