deliverable/linux.git
8 years agomm, thp: use list_first_entry_or_null()
Geliang Tang [Thu, 14 Jan 2016 23:19:32 +0000 (15:19 -0800)] 
mm, thp: use list_first_entry_or_null()

Simplify the code with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@163.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm, procfs: breakdown RSS for anon, shmem and file in /proc/pid/status
Jerome Marchand [Thu, 14 Jan 2016 23:19:29 +0000 (15:19 -0800)] 
mm, procfs: breakdown RSS for anon, shmem and file in /proc/pid/status

There are several shortcomings with the accounting of shared memory
(SysV shm, shared anonymous mapping, mapping of a tmpfs file).  The
values in /proc/<pid>/status and <...>/statm don't allow to distinguish
between shmem memory and a shared mapping to a regular file, even though
theirs implication on memory usage are quite different: during reclaim,
file mapping can be dropped or written back on disk, while shmem needs a
place in swap.

Also, to distinguish the memory occupied by anonymous and file mappings,
one has to read the /proc/pid/statm file, which has a field for the file
mappings (again, including shmem) and total memory occupied by these
mappings (i.e.  equivalent to VmRSS in the <...>/status file.  Getting
the value for anonymous mappings only is thus not exactly user-friendly
(the statm file is intended to be rather efficiently machine-readable).

To address both of these shortcomings, this patch adds a breakdown of
VmRSS in /proc/<pid>/status via new fields RssAnon, RssFile and
RssShmem, making use of the previous preparatory patch.  These fields
tell the user the memory occupied by private anonymous pages, mapped
regular files and shmem, respectively.  Other existing fields in /status
and /statm files are left without change.  The /statm file can be
extended in the future, if there's a need for that.

Example (part of) /proc/pid/status output including the new Rss* fields:

VmPeak:  2001008 kB
VmSize:  2001004 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:      5108 kB
VmRSS:      5108 kB
RssAnon:              92 kB
RssFile:            1324 kB
RssShmem:           3692 kB
VmData:      192 kB
VmStk:       136 kB
VmExe:         4 kB
VmLib:      1784 kB
VmPTE:      3928 kB
VmPMD:        20 kB
VmSwap:        0 kB
HugetlbPages:          0 kB

[vbabka@suse.cz: forward-porting, tweak changelog]
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm, shmem: add internal shmem resident memory accounting
Jerome Marchand [Thu, 14 Jan 2016 23:19:26 +0000 (15:19 -0800)] 
mm, shmem: add internal shmem resident memory accounting

Currently looking at /proc/<pid>/status or statm, there is no way to
distinguish shmem pages from pages mapped to a regular file (shmem pages
are mapped to /dev/zero), even though their implication in actual memory
use is quite different.

The internal accounting currently counts shmem pages together with
regular files.  As a preparation to extend the userspace interfaces,
this patch adds MM_SHMEMPAGES counter to mm_rss_stat to account for
shmem pages separately from MM_FILEPAGES.  The next patch will expose it
to userspace - this patch doesn't change the exported values yet, by
adding up MM_SHMEMPAGES to MM_FILEPAGES at places where MM_FILEPAGES was
used before.  The only user-visible change after this patch is the OOM
killer message that separates the reported "shmem-rss" from "file-rss".

[vbabka@suse.cz: forward-porting, tweak changelog]
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm, proc: reduce cost of /proc/pid/smaps for unpopulated shmem mappings
Vlastimil Babka [Thu, 14 Jan 2016 23:19:23 +0000 (15:19 -0800)] 
mm, proc: reduce cost of /proc/pid/smaps for unpopulated shmem mappings

Following the previous patch, further reduction of /proc/pid/smaps cost
is possible for private writable shmem mappings with unpopulated areas
where the page walk invokes the .pte_hole function.  We can use radix
tree iterator for each such area instead of calling find_get_entry() in
a loop.  This is possible at the extra maintenance cost of introducing
another shmem function shmem_partial_swap_usage().

To demonstrate the diference, I have measured this on a process that
creates a private writable 2GB mapping of a partially swapped out
/dev/shm/file (which cannot employ the optimizations from the prvious
patch) and doesn't populate it at all.  I time how long does it take to
cat /proc/pid/smaps of this process 100 times.

Before this patch:

real    0m3.831s
user    0m0.180s
sys     0m3.212s

After this patch:

real    0m1.176s
user    0m0.180s
sys     0m0.684s

The time is similar to the case where a radix tree iterator is employed
on the whole mapping.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm, proc: reduce cost of /proc/pid/smaps for shmem mappings
Vlastimil Babka [Thu, 14 Jan 2016 23:19:20 +0000 (15:19 -0800)] 
mm, proc: reduce cost of /proc/pid/smaps for shmem mappings

The previous patch has improved swap accounting for shmem mapping, which
however made /proc/pid/smaps more expensive for shmem mappings, as we
consult the radix tree for each pte_none entry, so the overal complexity
is O(n*log(n)).

We can reduce this significantly for mappings that cannot contain COWed
pages, because then we can either use the statistics tha shmem object
itself tracks (if the mapping contains the whole object, or the swap
usage of the whole object is zero), or use the radix tree iterator,
which is much more effective than repeated find_get_entry() calls.

This patch therefore introduces a function shmem_swap_usage(vma) and
makes /proc/pid/smaps use it when possible.  Only for writable private
mappings of shmem objects (i.e.  tmpfs files) with the shmem object
itself (partially) swapped outwe have to resort to the find_get_entry()
approach.

Hopefully such mappings are relatively uncommon.

To demonstrate the diference, I have measured this on a process that
creates a 2GB mapping and dirties single pages with a stride of 2MB, and
time how long does it take to cat /proc/pid/smaps of this process 100
times.

Private writable mapping of a /dev/shm/file (the most complex case):

real    0m3.831s
user    0m0.180s
sys     0m3.212s

Shared mapping of an almost full mapping of a partially swapped /dev/shm/file
(which needs to employ the radix tree iterator).

real    0m1.351s
user    0m0.096s
sys     0m0.768s

Same, but with /dev/shm/file not swapped (so no radix tree walk needed)

real    0m0.935s
user    0m0.128s
sys     0m0.344s

Private anonymous mapping:

real    0m0.949s
user    0m0.116s
sys     0m0.348s

The cost is now much closer to the private anonymous mapping case, unless
the shmem mapping is private and writable.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm, proc: account for shmem swap in /proc/pid/smaps
Vlastimil Babka [Thu, 14 Jan 2016 23:19:17 +0000 (15:19 -0800)] 
mm, proc: account for shmem swap in /proc/pid/smaps

Currently, /proc/pid/smaps will always show "Swap: 0 kB" for
shmem-backed mappings, even if the mapped portion does contain pages
that were swapped out.  This is because unlike private anonymous
mappings, shmem does not change pte to swap entry, but pte_none when
swapping the page out.  In the smaps page walk, such page thus looks
like it was never faulted in.

This patch changes smaps_pte_entry() to determine the swap status for
such pte_none entries for shmem mappings, similarly to how
mincore_page() does it.  Swapped out shmem pages are thus accounted for.
For private mappings of tmpfs files that COWed some of the pages, swaped
out status of the original shmem pages is naturally ignored.  If some of
the private copies was also swapped out, they are accounted via their
page table swap entries, so the resulting reported swap usage is then a
sum of both swapped out private copies, and swapped out shmem pages that
were not COWed.  No double accounting can thus happen.

The accounting is arguably still not as precise as for private anonymous
mappings, since now we will count also pages that the process in
question never accessed, but another process populated them and then let
them become swapped out.  I believe it is still less confusing and
subtle than not showing any swap usage by shmem mappings at all.
Swapped out counter might of interest of users who would like to prevent
from future swapins during performance critical operation and pre-fault
them at their convenience.  Especially for larger swapped out regions
the cost of swapin is much higher than a fresh page allocation.  So a
differentiation between pte_none vs.  swapped out is important for those
usecases.

One downside of this patch is that it makes /proc/pid/smaps more
expensive for shmem mappings, as we consult the radix tree for each
pte_none entry, so the overal complexity is O(n*log(n)).  I have
measured this on a process that creates a 2GB mapping and dirties single
pages with a stride of 2MB, and time how long does it take to cat
/proc/pid/smaps of this process 100 times.

Private anonymous mapping:

real    0m0.949s
user    0m0.116s
sys     0m0.348s

Mapping of a /dev/shm/file:

real    0m3.831s
user    0m0.180s
sys     0m3.212s

The difference is rather substantial, so the next patch will reduce the
cost for shared or read-only mappings.

In a less controlled experiment, I've gathered pids of processes on my
desktop that have either '/dev/shm/*' or 'SYSV*' in smaps.  This
included the Chrome browser and some KDE processes.  Again, I've run cat
/proc/pid/smaps on each 100 times.

Before this patch:

real    0m9.050s
user    0m0.518s
sys     0m8.066s

After this patch:

real    0m9.221s
user    0m0.541s
sys     0m8.187s

This suggests low impact on average systems.

Note that this patch doesn't attempt to adjust the SwapPss field for
shmem mappings, which would need extra work to determine who else could
have the pages mapped.  Thus the value stays zero except for COWed
swapped out pages in a shmem mapping, which are accounted as usual.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm, documentation: clarify /proc/pid/status VmSwap limitations for shmem
Vlastimil Babka [Thu, 14 Jan 2016 23:19:14 +0000 (15:19 -0800)] 
mm, documentation: clarify /proc/pid/status VmSwap limitations for shmem

This series is based on Jerome Marchand's [1] so let me quote the first
paragraph from there:

There are several shortcomings with the accounting of shared memory
(sysV shm, shared anonymous mapping, mapping to a tmpfs file).  The
values in /proc/<pid>/status and statm don't allow to distinguish
between shmem memory and a shared mapping to a regular file, even though
their implications on memory usage are quite different: at reclaim, file
mapping can be dropped or written back on disk while shmem needs a place
in swap.  As for shmem pages that are swapped-out or in swap cache, they
aren't accounted at all.

The original motivation for myself is that a customer found (IMHO
rightfully) confusing that e.g.  top output for process swap usage is
unreliable with respect to swapped out shmem pages, which are not
accounted for.

The fundamental difference between private anonymous and shmem pages is
that the latter has PTE's converted to pte_none, and not swapents.  As
such, they are not accounted to the number of swapents visible e.g.  in
/proc/pid/status VmSwap row.  It might be theoretically possible to use
swapents when swapping out shmem (without extra cost, as one has to
change all mappers anyway), and on swap in only convert the swapent for
the faulting process, leaving swapents in other processes until they
also fault (so again no extra cost).  But I don't know how many
assumptions this would break, and it would be too disruptive change for
a relatively small benefit.

Instead, my approach is to document the limitation of VmSwap, and
provide means to determine the swap usage for shmem areas for those who
are interested and willing to pay the price, using /proc/pid/smaps.
Because outside of ipcs, I don't think it's possible to currently to
determine the usage at all.  The previous patchset [1] did introduce new
shmem-specific fields into smaps output, and functions to determine the
values.  I take a simpler approach, noting that smaps output already has
a "Swap: X kB" line, where currently X == 0 always for shmem areas.  I
think we can just consider this a bug and provide the proper value by
consulting the radix tree, as e.g.  mincore_page() does.  In the patch
changelog I explain why this is also not perfect (and cannot be without
swapents), but still arguably much better than showing a 0.

The last two patches are adapted from Jerome's patchset and provide a
VmRSS breakdown to RssAnon, RssFile and RssShm in /proc/pid/status.
Hugh noted that this is a welcome addition, and I agree that it might
help e.g.  debugging process memory usage at albeit non-zero, but still
rather low cost of extra per-mm counter and some page flag checks.

[1] http://lwn.net/Articles/611966/

This patch (of 6):

The documentation for /proc/pid/status does not mention that the value
of VmSwap counts only swapped out anonymous private pages, and not
swapped out pages of the underlying shmem objects (for shmem mappings).
This is not obvious, so document this limitation.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/mmzone.c: memmap_valid_within() can be boolean
Yaowei Bai [Thu, 14 Jan 2016 23:19:11 +0000 (15:19 -0800)] 
mm/mmzone.c: memmap_valid_within() can be boolean

Make memmap_valid_within return bool due to this particular function
only using either one or zero as its return value.

No functional change.

Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/vmalloc.c: use list_{next,first}_entry
Geliang Tang [Thu, 14 Jan 2016 23:19:08 +0000 (15:19 -0800)] 
mm/vmalloc.c: use list_{next,first}_entry

To make the intention clearer, use list_{next,first}_entry instead of
list_entry.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/page_alloc.c: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim
Michal Hocko [Thu, 14 Jan 2016 23:19:05 +0000 (15:19 -0800)] 
mm/page_alloc.c: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim

__alloc_pages_slowpath is looping over ALLOC_NO_WATERMARKS requests if
__GFP_NOFAIL is requested.  This is fragile because we are basically
relying on somebody else to make the reclaim (be it the direct reclaim
or OOM killer) for us.  The caller might be holding resources (e.g.
locks) which block other other reclaimers from making any progress for
example.  Remove the retry loop and rely on __alloc_pages_slowpath to
invoke all allowed reclaim steps and retry logic.

We have to be careful about __GFP_NOFAIL allocations from the
PF_MEMALLOC context even though this is a very bad idea to begin with
because no progress can be gurateed at all.  We shouldn't break the
__GFP_NOFAIL semantic here though.  It could be argued that this is
essentially GFP_NOWAIT context which we do not support but PF_MEMALLOC
is much harder to check for existing users because they might happen
deep down the code path performed much later after setting the flag so
we cannot really rule out there is no kernel path triggering this
combination.

Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/page_alloc.c: get rid of __alloc_pages_high_priority()
Michal Hocko [Thu, 14 Jan 2016 23:19:03 +0000 (15:19 -0800)] 
mm/page_alloc.c: get rid of __alloc_pages_high_priority()

__alloc_pages_high_priority doesn't do anything special other than it
calls get_page_from_freelist and loops around GFP_NOFAIL allocation
until it succeeds.  It would be better if the first part was done in
__alloc_pages_slowpath where we modify the zonelist because this would
be easier to read and understand.  Opencoding the function into its only
caller allows to simplify it a bit as well.

This patch doesn't introduce any functional changes.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/zonelist: enumerate zonelists array index
Yaowei Bai [Thu, 14 Jan 2016 23:19:00 +0000 (15:19 -0800)] 
mm/zonelist: enumerate zonelists array index

Hardcoding index to zonelists array in gfp_zonelist() is not a good
idea, let's enumerate it to improve readability.

No functional change.

[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: fix CONFIG_NUMA=n build]
[n-horiguchi@ah.jp.nec.com: fix warning in comparing enumerator]
Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoinclude/linux/mmzone.h: remove unused is_unevictable_lru()
Yaowei Bai [Thu, 14 Jan 2016 23:18:57 +0000 (15:18 -0800)] 
include/linux/mmzone.h: remove unused is_unevictable_lru()

Since commit a0b8cab3b9b2 ("mm: remove lru parameter from
__pagevec_lru_add and remove parts of pagevec API") there's no
user of this function anymore, so remove it.

Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/memblock.c: memblock_is_memory()/reserved() can be boolean
Yaowei Bai [Thu, 14 Jan 2016 23:18:54 +0000 (15:18 -0800)] 
mm/memblock.c: memblock_is_memory()/reserved() can be boolean

Make memblock_is_memory() and memblock_is_reserved return bool to
improve readability due to these particular functions only using either
one or zero as their return value.

No functional change.

Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoinclude/linux/hugetlb.h: is_file_hugepages() can be boolean
Yaowei Bai [Thu, 14 Jan 2016 23:18:51 +0000 (15:18 -0800)] 
include/linux/hugetlb.h: is_file_hugepages() can be boolean

Make is_file_hugepages() return bool to improve readability due to this
particular function only using either one or zero as its return value.

This patch also removed the if condition to make is_file_hugepages
return directly.

No functional change.

Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm: change mm_vmscan_lru_shrink_inactive() proto types
yalin wang [Thu, 14 Jan 2016 23:18:48 +0000 (15:18 -0800)] 
mm: change mm_vmscan_lru_shrink_inactive() proto types

Move node_id zone_idx shrink flags into trace function, so thay we don't
need caculate these args if the trace is disabled, and will make this
function have less arguments.

Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/cma: always check which page caused allocation failure
Joonsoo Kim [Thu, 14 Jan 2016 23:18:45 +0000 (15:18 -0800)] 
mm/cma: always check which page caused allocation failure

Now, we have tracepoint in test_pages_isolated() to notify pfn which
cannot be isolated.  But, in alloc_contig_range(), some error path
doesn't call test_pages_isolated() so it's still hard to know exact pfn
that causes allocation failure.

This patch change this situation by calling test_pages_isolated() in
almost error path.  In allocation failure case, some overhead is added
by this change, but, allocation failure is really rare event so it would
not matter.

In fatal signal pending case, we don't call test_pages_isolated()
because this failure is intentional one.

There was a bogus outer_start problem due to unchecked buddy order and
this patch also fix it.  Before this patch, it didn't matter, because
end result is same thing.  But, after this patch, tracepoint will report
failed pfn so it should be accurate.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/page_isolation.c: add new tracepoint, test_pages_isolated
Joonsoo Kim [Thu, 14 Jan 2016 23:18:42 +0000 (15:18 -0800)] 
mm/page_isolation.c: add new tracepoint, test_pages_isolated

cma allocation should be guranteeded to succeed.  But sometimes it can
fail in the current implementation.  To track down the problem, we need
to know which page is problematic and this new tracepoint will report
it.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/page_isolation.c: return last tested pfn rather than failure indicator
Joonsoo Kim [Thu, 14 Jan 2016 23:18:39 +0000 (15:18 -0800)] 
mm/page_isolation.c: return last tested pfn rather than failure indicator

This is preparation step to report test failed pfn in new tracepoint to
analyze cma allocation failure problem.  There is no functional change
in this patch.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Minchan Kim <minchan@kernel.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/mempolicy.c: convert the shared_policy lock to a rwlock
Nathan Zimmer [Thu, 14 Jan 2016 23:18:36 +0000 (15:18 -0800)] 
mm/mempolicy.c: convert the shared_policy lock to a rwlock

When running the SPECint_rate gcc on some very large boxes it was
noticed that the system was spending lots of time in
mpol_shared_policy_lookup().  The gamess benchmark can also show it and
is what I mostly used to chase down the issue since the setup for that I
found to be easier.

To be clear the binaries were on tmpfs because of disk I/O requirements.
We then used text replication to avoid icache misses and having all the
copies banging on the memory where the instruction code resides.  This
results in us hitting a bottleneck in mpol_shared_policy_lookup() since
lookup is serialised by the shared_policy lock.

I have only reproduced this on very large (3k+ cores) boxes.  The
problem starts showing up at just a few hundred ranks getting worse
until it threatens to livelock once it gets large enough.  For example
on the gamess benchmark at 128 ranks this area consumes only ~1% of
time, at 512 ranks it consumes nearly 13%, and at 2k ranks it is over
90%.

To alleviate the contention in this area I converted the spinlock to an
rwlock.  This allows a large number of lookups to happen simultaneously.
The results were quite good reducing this consumtion at max ranks to
around 2%.

[akpm@linux-foundation.org: tidy up code comments]
Signed-off-by: Nathan Zimmer <nzimmer@sgi.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Nadia Yvette Chambers <nyc@holomorphy.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm: add PHYS_PFN, use it in __phys_to_pfn()
Chen Gang [Thu, 14 Jan 2016 23:18:33 +0000 (15:18 -0800)] 
mm: add PHYS_PFN, use it in __phys_to_pfn()

__phys_to_pfn and __pfn_to_phys are symmetric, PHYS_PFN and PFN_PHYS are
semmetric:

 - y = (phys_addr_t)x << PAGE_SHIFT

 - y >> PAGE_SHIFT = (phys_add_t)x

 - (unsigned long)(y >> PAGE_SHIFT) = x

[akpm@linux-foundation.org: use macro arg name `x']
[arnd@arndb.de: include linux/pfn.h for PHYS_PFN definition]
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/vmscan.c: change trace_mm_vmscan_writepage() proto type
yalin wang [Thu, 14 Jan 2016 23:18:30 +0000 (15:18 -0800)] 
mm/vmscan.c: change trace_mm_vmscan_writepage() proto type

Move trace_reclaim_flags() into trace function, so that we don't need
caculate these flags if the trace is disabled.

Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/mmap.c: remove redundant local variables for may_expand_vm()
Chen Gang [Thu, 14 Jan 2016 23:18:27 +0000 (15:18 -0800)] 
mm/mmap.c: remove redundant local variables for may_expand_vm()

Simplify may_expand_vm().

[akpm@linux-foundation.org: further simplification, per Naoya Horiguchi]
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/mlock.c: drop unneeded initialization in munlock_vma_pages_range()
Alexey Klimov [Thu, 14 Jan 2016 23:18:24 +0000 (15:18 -0800)] 
mm/mlock.c: drop unneeded initialization in munlock_vma_pages_range()

Before usage page pointer initialized by NULL is reinitialized by
follow_page_mask().  Drop useless init of page pointer in the beginning
of loop.

Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agokmemcg: account certain kmem allocations to memcg
Vladimir Davydov [Thu, 14 Jan 2016 23:18:21 +0000 (15:18 -0800)] 
kmemcg: account certain kmem allocations to memcg

Mark those kmem allocations that are known to be easily triggered from
userspace as __GFP_ACCOUNT/SLAB_ACCOUNT, which makes them accounted to
memcg.  For the list, see below:

 - threadinfo
 - task_struct
 - task_delay_info
 - pid
 - cred
 - mm_struct
 - vm_area_struct and vm_region (nommu)
 - anon_vma and anon_vma_chain
 - signal_struct
 - sighand_struct
 - fs_struct
 - files_struct
 - fdtable and fdtable->full_fds_bits
 - dentry and external_name
 - inode for all filesystems. This is the most tedious part, because
   most filesystems overwrite the alloc_inode method.

The list is far from complete, so feel free to add more objects.
Nevertheless, it should be close to "account everything" approach and
keep most workloads within bounds.  Malevolent users will be able to
breach the limit, but this was possible even with the former "account
everything" approach (simply because it did not account everything in
fact).

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Greg Thelen <gthelen@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agovmalloc: allow to account vmalloc to memcg
Vladimir Davydov [Thu, 14 Jan 2016 23:18:18 +0000 (15:18 -0800)] 
vmalloc: allow to account vmalloc to memcg

Make vmalloc family functions allocate vmalloc area pages with
alloc_kmem_pages so that if __GFP_ACCOUNT is set they will be accounted
to memcg.  This is needed, at least, to account alloc_fdmem allocations.

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Greg Thelen <gthelen@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoslab: add SLAB_ACCOUNT flag
Vladimir Davydov [Thu, 14 Jan 2016 23:18:15 +0000 (15:18 -0800)] 
slab: add SLAB_ACCOUNT flag

Currently, if we want to account all objects of a particular kmem cache,
we have to pass __GFP_ACCOUNT to each kmem_cache_alloc call, which is
inconvenient.  This patch introduces SLAB_ACCOUNT flag which if passed
to kmem_cache_create will force accounting for every allocation from
this cache even if __GFP_ACCOUNT is not passed.

This patch does not make any of the existing caches use this flag - it
will be done later in the series.

Note, a cache with SLAB_ACCOUNT cannot be merged with a cache w/o
SLAB_ACCOUNT, because merged caches share the same kmem_cache struct and
hence cannot have different sets of SLAB_* flags.  Thus using this flag
will probably reduce the number of merged slabs even if kmem accounting
is not used (only compiled in).

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Suggested-by: Tejun Heo <tj@kernel.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomemcg: only account kmem allocations marked as __GFP_ACCOUNT
Vladimir Davydov [Thu, 14 Jan 2016 23:18:12 +0000 (15:18 -0800)] 
memcg: only account kmem allocations marked as __GFP_ACCOUNT

Black-list kmem accounting policy (aka __GFP_NOACCOUNT) turned out to be
fragile and difficult to maintain, because there seem to be many more
allocations that should not be accounted than those that should be.
Besides, false accounting an allocation might result in much worse
consequences than not accounting at all, namely increased memory
consumption due to pinned dead kmem caches.

So this patch switches kmem accounting to the white-policy: now only
those kmem allocations that are marked as __GFP_ACCOUNT are accounted to
memcg.  Currently, no kmem allocations are marked like this.  The
following patches will mark several kmem allocations that are known to
be easily triggered from userspace and therefore should be accounted to
memcg.

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Greg Thelen <gthelen@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoRevert "gfp: add __GFP_NOACCOUNT"
Vladimir Davydov [Thu, 14 Jan 2016 23:18:08 +0000 (15:18 -0800)] 
Revert "gfp: add __GFP_NOACCOUNT"

This reverts commit 8f4fc071b192 ("gfp: add __GFP_NOACCOUNT").

Black-list kmem accounting policy (aka __GFP_NOACCOUNT) turned out to be
fragile and difficult to maintain, because there seem to be many more
allocations that should not be accounted than those that should be.
Besides, false accounting an allocation might result in much worse
consequences than not accounting at all, namely increased memory
consumption due to pinned dead kmem caches.

So it was decided to switch to the white-list policy.  This patch
reverts bits introducing the black-list policy.  The white-list policy
will be introduced later in the series.

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Greg Thelen <gthelen@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoRevert "kernfs: do not account ino_ida allocations to memcg"
Vladimir Davydov [Thu, 14 Jan 2016 23:18:05 +0000 (15:18 -0800)] 
Revert "kernfs: do not account ino_ida allocations to memcg"

Currently, all kmem allocations (namely every kmem_cache_alloc, kmalloc,
alloc_kmem_pages call) are accounted to memory cgroup automatically.
Callers have to explicitly opt out if they don't want/need accounting
for some reason.  Such a design decision leads to several problems:

 - kmalloc users are highly sensitive to failures, many of them
   implicitly rely on the fact that kmalloc never fails, while memcg
   makes failures quite plausible.

 - A lot of objects are shared among different containers by design.
   Accounting such objects to one of containers is just unfair.
   Moreover, it might lead to pinning a dead memcg along with its kmem
   caches, which aren't tiny, which might result in noticeable increase
   in memory consumption for no apparent reason in the long run.

 - There are tons of short-lived objects. Accounting them to memcg will
   only result in slight noise and won't change the overall picture, but
   we still have to pay accounting overhead.

For more info, see

 - http://lkml.kernel.org/r/20151105144002.GB15111%40dhcp22.suse.cz
 - http://lkml.kernel.org/r/20151106090555.GK29259@esperanza

Therefore this patchset switches to the white list policy.  Now kmalloc
users have to explicitly opt in by passing __GFP_ACCOUNT flag.

Currently, the list of accounted objects is quite limited and only
includes those allocations that (1) are known to be easily triggered
from userspace and (2) can fail gracefully (for the full list see patch
no.  6) and it still misses many object types.  However, accounting only
those objects should be a satisfactory approximation of the behavior we
used to have for most sane workloads.

This patch (of 6):

Revert 499611ed451508a42d1d7d ("kernfs: do not account ino_ida allocations
to memcg").

Black-list kmem accounting policy (aka __GFP_NOACCOUNT) turned out to be
fragile and difficult to maintain, because there seem to be many more
allocations that should not be accounted than those that should be.
Besides, false accounting an allocation might result in much worse
consequences than not accounting at all, namely increased memory
consumption due to pinned dead kmem caches.

So it was decided to switch to the white-list policy.  This patch reverts
bits introducing the black-list policy.  The white-list policy will be
introduced later in the series.

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Greg Thelen <gthelen@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/slab.c: add a helper function get_first_slab
Geliang Tang [Thu, 14 Jan 2016 23:18:02 +0000 (15:18 -0800)] 
mm/slab.c: add a helper function get_first_slab

Add a new helper function get_first_slab() that get the first slab from
a kmem_cache_node.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Acked-by: Christoph Lameter <cl@linux.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/slab.c: use list_for_each_entry in cache_flusharray
Geliang Tang [Thu, 14 Jan 2016 23:17:59 +0000 (15:17 -0800)] 
mm/slab.c: use list_for_each_entry in cache_flusharray

Simplify the code with list_for_each_entry().

Signed-off-by: Geliang Tang <geliangtang@163.com>
Acked-by: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomm/slab.c use list_first_entry_or_null()
Geliang Tang [Thu, 14 Jan 2016 23:17:56 +0000 (15:17 -0800)] 
mm/slab.c use list_first_entry_or_null()

Simplify the code with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@163.com>
Acked-by: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoinclude/linux/dcache.h: remove semicolons from HASH_LEN_DECLARE
Andrew Morton [Thu, 14 Jan 2016 23:17:53 +0000 (15:17 -0800)] 
include/linux/dcache.h: remove semicolons from HASH_LEN_DECLARE

A little cleanup - the invocation site provdes the semicolon.

Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2/dlm: cleanup redunant lksb flags in dlmcommon.h
Joseph Qi [Thu, 14 Jan 2016 23:17:50 +0000 (15:17 -0800)] 
ocfs2/dlm: cleanup redunant lksb flags in dlmcommon.h

lksb flags are defined both in dlmapi.h and dlmcommon.h.  So clean them
up from dlmcommon.h.

Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Jiufei Xue <xuejiufei@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2: dlm: remove redundant code
Junxiao Bi [Thu, 14 Jan 2016 23:17:47 +0000 (15:17 -0800)] 
ocfs2: dlm: remove redundant code

Found this when do patch review, remove to make it clear and save a
little cpu time.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <joseph.qi@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2: access orphan dinode before delete entry in ocfs2_orphan_del
Joseph Qi [Thu, 14 Jan 2016 23:17:44 +0000 (15:17 -0800)] 
ocfs2: access orphan dinode before delete entry in ocfs2_orphan_del

In ocfs2_orphan_del, currently it finds and deletes entry first, and
then access orphan dir dinode.  This will have a problem once
ocfs2_journal_access_di fails.  In this case, entry will be removed from
orphan dir, but in deed the inode hasn't been deleted successfully.  In
other words, the file is missing but not actually deleted.  So we should
access orphan dinode first like unlink and rename.

Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Jiufei Xue <xuejiufei@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2/dlm: do not insert a new mle when another process is already migrating
xuejiufei [Thu, 14 Jan 2016 23:17:41 +0000 (15:17 -0800)] 
ocfs2/dlm: do not insert a new mle when another process is already migrating

When two processes are migrating the same lockres,
dlm_add_migration_mle() return -EEXIST, but insert a new mle in hash
list.  dlm_migrate_lockres() will detach the old mle and free the new
one which is already in hash list, that will destroy the list.

Signed-off-by: Jiufei Xue <xuejiufei@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2/dlm: ignore cleaning the migration mle that is inuse
xuejiufei [Thu, 14 Jan 2016 23:17:38 +0000 (15:17 -0800)] 
ocfs2/dlm: ignore cleaning the migration mle that is inuse

We have found that migration source will trigger a BUG that the refcount
of mle is already zero before put when the target is down during
migration.  The situation is as follows:

dlm_migrate_lockres
  dlm_add_migration_mle
  dlm_mark_lockres_migrating
  dlm_get_mle_inuse
  <<<<<< Now the refcount of the mle is 2.
  dlm_send_one_lockres and wait for the target to become the
  new master.
  <<<<<< o2hb detect the target down and clean the migration
  mle. Now the refcount is 1.

dlm_migrate_lockres woken, and put the mle twice when found the target
goes down which trigger the BUG with the following message:

  "ERROR: bad mle: ".

Signed-off-by: Jiufei Xue <xuejiufei@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2: do not lock/unlock() inode DLM lock
Goldwyn Rodrigues [Thu, 14 Jan 2016 23:17:35 +0000 (15:17 -0800)] 
ocfs2: do not lock/unlock() inode DLM lock

DLM does not cache locks.  So, blocking lock and unlock will only make
the performance worse where contention over the locks is high.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <joseph.qi@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2: fix slot overwritten if storage link down during mount
jiangyiwen [Thu, 14 Jan 2016 23:17:33 +0000 (15:17 -0800)] 
ocfs2: fix slot overwritten if storage link down during mount

The following case will lead to slot overwritten.

N1                               N2
mount ocfs2 volume, find and
allocate slot 0, then set
osb->slot_num to 0, begin to
write slot info to disk
                                 mount ocfs2 volume, wait for super lock
write block fail because of
storage link down, unlock
super lock
                                 got super lock and also allocate slot 0
                                 then unlock super lock

mount fail and then dismount,
since osb->slot_num is 0, try to
put invalid slot to disk. And it
will succeed if storage link
restores.
                                 N2 slot info is now overwritten

Once another node say N3 mount, it will find and allocate slot 0 again,
which will lead to mount hung because journal has already been locked by
N2.  so when write slot info failed, invalidate slot in advance to avoid
overwrite slot.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Yiwen Jiang <jiangyiwen@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2/dlm: return appropriate value when dlm_grab() returns NULL
Xue jiufei [Thu, 14 Jan 2016 23:17:29 +0000 (15:17 -0800)] 
ocfs2/dlm: return appropriate value when dlm_grab() returns NULL

dlm_grab() may return NULL when the node is doing unmount.  When doing
code review, we found that some dlm handlers may return error to caller
when dlm_grab() returns NULL and make caller BUG or other problems.
Here is an example:

Node 1                                 Node 2
receives migration message
from node 3, and send
migrate request to others
                                     start unmounting

                                     receives migrate request
                                     from node 1 and call
                                     dlm_migrate_request_handler()

                                     unmount thread unregisters
                                     domain handlers and removes
                                     dlm_context from dlm_domains

                                     dlm_migrate_request_handlers()
                                     returns -EINVAL to node 1
Exit migration neither clearing the
migration state nor sending
assert master message to node 3 which
cause node 3 hung.

Signed-off-by: Jiufei Xue <xuejiufei@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2: clean up redundant NULL check before iput
Joseph Qi [Thu, 14 Jan 2016 23:17:27 +0000 (15:17 -0800)] 
ocfs2: clean up redundant NULL check before iput

Since iput will take care the NULL check itself, NULL check before
calling it is redundant.  So clean them up.

Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2/dlm: wait until DLM_LOCK_RES_SETREF_INPROG is cleared in dlm_deref_lockres_worker
jiangyiwen [Thu, 14 Jan 2016 23:17:23 +0000 (15:17 -0800)] 
ocfs2/dlm: wait until DLM_LOCK_RES_SETREF_INPROG is cleared in dlm_deref_lockres_worker

Commit f3f854648de6 ("ocfs2_dlm: Ensure correct ordering of set/clear
refmap bit on lockres") still exists a race which can't ensure the
ordering is exactly correct.

Node1               Node2                    Node3
umount, migrate
lockres to Node2
                    migrate finished,
                    send migrate request
                    to Node3
                                              received migrate request,
                                              create a migration_mle,
                                              respond to Node2.
                    set DLM_LOCK_RES_SETREF_INPROG
                    and send assert master to
                    Node3
                                              delete migration_mle in
                                              assert_master_handler,
                                              Node3 umount without response
                                              dlm_thread purge
                                              this lockres, send drop
                                              deref message to Node2
                    found the flag of
                    DLM_LOCK_RES_SETREF_INPROG
                    is set, dispatch
                    dlm_deref_lockres_worker to
                    clear refmap, but in function of
                    dlm_deref_lockres_worker,
                    only if node in refmap it wait
                    DLM_LOCK_RES_SETREF_INPROG
                    to be cleared. So worker is
                    done successfully

                                              purge lockres, send
                                              assert master response
                                              to Node1, and finish umount
                    set Node3 in refmap, and it
                    won't be cleared forever, thus
                    lead to umount hung

so wait until DLM_LOCK_RES_SETREF_INPROG is cleared in
dlm_deref_lockres_worker.

Signed-off-by: Yiwen Jiang <jiangyiwen@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2: constify ocfs2_extent_tree_operations structures
Julia Lawall [Thu, 14 Jan 2016 23:17:21 +0000 (15:17 -0800)] 
ocfs2: constify ocfs2_extent_tree_operations structures

The ocfs2_extent_tree_operations structures are never modified, so
declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2/dlm: fix a race between purge and migration
Xue jiufei [Thu, 14 Jan 2016 23:17:18 +0000 (15:17 -0800)] 
ocfs2/dlm: fix a race between purge and migration

We found a race between purge and migration when doing code review.
Node A put lockres to purgelist before receiving the migrate message
from node B which is the master.  Node A call dlm_mig_lockres_handler to
handle this message.

dlm_mig_lockres_handler
  dlm_lookup_lockres
  >>>>>> race window, dlm_run_purge_list may run and send
         deref message to master, waiting the response
  spin_lock(&res->spinlock);
  res->state |= DLM_LOCK_RES_MIGRATING;
  spin_unlock(&res->spinlock);
  dlm_mig_lockres_handler returns

  >>>>>> dlm_thread receives the response from master for the deref
  message and triggers the BUG because the lockres has the state
  DLM_LOCK_RES_MIGRATING with the following message:

dlm_purge_lockres:209 ERROR: 6633EB681FA7474A9C280A4E1A836F0F: res
M0000000000000000030c0300000000 in use after deref

Signed-off-by: Jiufei Xue <xuejiufei@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2: o2hb: increase unsteady iterations
Junxiao Bi [Thu, 14 Jan 2016 23:17:15 +0000 (15:17 -0800)] 
ocfs2: o2hb: increase unsteady iterations

When run multiple xattr test of ocfs2-test on a three-nodes cluster,
mount failed sometimes with the following message.

  o2hb: Unable to stabilize heartbeart on region D18B775E758D4D80837E8CF3D086AD4A (xvdb)

Stabilize heartbeat depends on the timing order to mount ocfs2 from
cluster nodes and how fast the tcp connections are established.  So
increase unsteady interations to leave more time for it.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2: return non-zero st_blocks for inline data
John Haxby [Thu, 14 Jan 2016 23:17:12 +0000 (15:17 -0800)] 
ocfs2: return non-zero st_blocks for inline data

Some versions of tar assume that files with st_blocks == 0 do not
contain any data and will skip reading them entirely.  See also commit
9206c561554c ("ext4: return non-zero st_blocks for inline data").

Signed-off-by: John Haxby <john.haxby@oracle.com>
Reviewed-by: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Acked-by: Gang He <ghe@suse.com>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoocfs2: optimize bad declarations and redundant assignment
Norton.Zhu [Thu, 14 Jan 2016 23:17:09 +0000 (15:17 -0800)] 
ocfs2: optimize bad declarations and redundant assignment

In ocfs2_parse_options,

a) it's better to declare variables(small size) outside of while loop;

b) 'option' will be set by match_int, 'option = 0;' makes no sense, if
   match_int failed, it just goto bail and return.

Signed-off-by: Norton.Zhu <norton.zhu@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Gang He <ghe@suse.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Acked-by: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agologfs: fix logfs build errors and dependencies
Arnd Bergmann [Thu, 14 Jan 2016 23:17:05 +0000 (15:17 -0800)] 
logfs: fix logfs build errors and dependencies

Fix build errors that happen when CONFIG_LOGFS=y and CONFIG_MTD=m:

  fs/built-in.o: In function `logfs_mount':
  super.c:(.text+0x92a6f): undefined reference to `logfs_get_sb_mtd'
  fs/built-in.o: In function `logfs_get_sb_bdev':
  (.text+0x93530): undefined reference to `logfs_get_sb_mtd'

This patch avoids the error by changing the dependencies of logfs in a
way that we can no longer configure logfs as built-in when the MTD core
is a loadable module, while leaving the dependency to require at least
one of MTD or BLOCK to be enabled.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Peter Chen <peter.chen@freescale.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Joern Engel <joern@logfs.org>
Cc: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agomodpost: don't add a trailing wildcard for OF module aliases
Javier Martinez Canillas [Thu, 14 Jan 2016 23:17:02 +0000 (15:17 -0800)] 
modpost: don't add a trailing wildcard for OF module aliases

Commit ac551828993e ("modpost: i2c aliases need no trailing wildcard")
removed the wildcard at the end of the I2C module aliases because I2C
devices have no IDs so the aliases are just arbitrary device names.

This is also true for OF modaliases since a compatible string is used to
define a specific IP hardware block.  So the modalias should match a
specific compatible string and not attempt to match a compatible string
whose name matches the beginning of another one.

For example, the following driver module:

  $ modinfo cros_ec_keyb | grep alias
  alias:          platform:cros-ec-keyb
  alias:          of:N*T*Cgoogle,cros-ec-keyb*

will be tried to be loaded for an alias of:N*T*Cgoogle,cros-ec-keyb-v2
but there could be a different driver that supports the device for that
compatible string so it's better to remove the trailing wildcard for OF.

Also, remove the word "always" from the add_wildcard() function comment
since that was carried from the time where a wildcard was always added
at the end of the module alias for all the devices.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Suggested-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agofsnotify: destroy marks with call_srcu instead of dedicated thread
Jeff Layton [Thu, 14 Jan 2016 23:16:59 +0000 (15:16 -0800)] 
fsnotify: destroy marks with call_srcu instead of dedicated thread

At the time that this code was originally written, call_srcu didn't
exist, so this thread was required to ensure that we waited for that
SRCU grace period to settle before finally freeing the object.

It does exist now however and we can much more efficiently use call_srcu
to handle this.  That also allows us to potentially use srcu_barrier to
ensure that they are all of the callbacks have run before proceeding.
In order to conserve space, we union the rcu_head with the g_list.

This will be necessary for nfsd which will allocate marks from a
dedicated slabcache.  We have to be able to ensure that all of the
objects are destroyed before destroying the cache.  That's fairly

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Cc: Eric Paris <eparis@parisplace.org>
Reviewed-by: Jan Kara <jack@suse.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agofs/notify/inode_mark.c: use list_next_entry in fsnotify_unmount_inodes
Geliang Tang [Thu, 14 Jan 2016 23:16:56 +0000 (15:16 -0800)] 
fs/notify/inode_mark.c: use list_next_entry in fsnotify_unmount_inodes

To make the intention clearer, use list_next_entry instead of
list_entry.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoscripts/bloat-o-meter: fix python3 syntax error
Sergey Senozhatsky [Thu, 14 Jan 2016 23:16:53 +0000 (15:16 -0800)] 
scripts/bloat-o-meter: fix python3 syntax error

In Python3+ print is a function so the old syntax is not correct
anymore:

  $ ./scripts/bloat-o-meter vmlinux.o vmlinux.o.old
    File "./scripts/bloat-o-meter", line 61
      print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
                                                                     ^
  SyntaxError: invalid syntax

Fix by calling print as a function.

Tested on python 2.7.11, 3.5.1

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agodma-debug: switch check from _text to _stext
Laura Abbott [Thu, 14 Jan 2016 23:16:50 +0000 (15:16 -0800)] 
dma-debug: switch check from _text to _stext

In include/asm-generic/sections.h:

  /*
   * Usage guidelines:
   * _text, _data: architecture specific, don't use them in
   * arch-independent code
   * [_stext, _etext]: contains .text.* sections, may also contain
   * .rodata.*
   *                   and/or .init.* sections

_text is not guaranteed across architectures.  Architectures such as ARM
may reuse parts which are not actually text and erroneously trigger a bug.
Switch to using _stext which is guaranteed to contain text sections.

Came out of https://lkml.kernel.org/g/<567B1176.4000106@redhat.com>

Signed-off-by: Laura Abbott <labbott@fedoraproject.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agom32r: fix m32104ut_defconfig build fail
Sudip Mukherjee [Thu, 14 Jan 2016 23:16:47 +0000 (15:16 -0800)] 
m32r: fix m32104ut_defconfig build fail

The build of m32104ut_defconfig for m32r arch was failing for long long
time with the error:

  ERROR: "memory_start" [fs/udf/udf.ko] undefined!
  ERROR: "memory_end" [fs/udf/udf.ko] undefined!
  ERROR: "memory_end" [drivers/scsi/sg.ko] undefined!
  ERROR: "memory_start" [drivers/scsi/sg.ko] undefined!
  ERROR: "memory_end" [drivers/i2c/i2c-dev.ko] undefined!
  ERROR: "memory_start" [drivers/i2c/i2c-dev.ko] undefined!

As done in other architectures export the symbols to fix the error.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 years agoMake sure that highmem pages are not added to symlink page cache
Al Viro [Thu, 14 Jan 2016 22:52:59 +0000 (17:52 -0500)] 
Make sure that highmem pages are not added to symlink page cache

inode_nohighmem() is sufficient to make sure that page_get_link()
won't try to allocate a highmem page.  Moreover, it is sufficient
to make sure that page_symlink/__page_symlink won't do the same
thing.  However, any filesystem that manually preseeds the symlink's
page cache upon symlink(2) needs to make sure that the page it
inserts there won't be a highmem one.

Fortunately, only nfs and shmem have run afoul of that...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
8 years agonfsd: add new io class tracepoint
Jeff Layton [Tue, 17 Nov 2015 11:52:23 +0000 (06:52 -0500)] 
nfsd: add new io class tracepoint

Add some new tracepoints in the nfsd read/write codepaths. The idea
is that this will give us the ability to measure how long each phase of
a read or write operation takes.

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
8 years agosparc64: Fix numa node distance initialization
Nitin Gupta [Wed, 6 Jan 2016 06:35:35 +0000 (22:35 -0800)] 
sparc64: Fix numa node distance initialization

Orabug: 22495713

Currently, NUMA node distance matrix is initialized only
when a machine descriptor (MD) exists. However, sun4u
machines (e.g. Sun Blade 2500) do not have an MD and thus
distance values were left uninitialized. The initialization
is now moved such that it happens on both sun4u and sun4v.

Signed-off-by: Nitin Gupta <nitin.m.gupta@oracle.com>
Tested-by: Mikael Pettersson <mikpelinux@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agofsl/fman: Delete one function call "put_device" in dtsec_config()
Markus Elfring [Thu, 14 Jan 2016 14:46:28 +0000 (15:46 +0100)] 
fsl/fman: Delete one function call "put_device" in dtsec_config()

The Coccinelle semantic patch script "deref_null.cocci" pointed a problem
out in the implementation of the function "dtsec_config".

A null pointer was assigned to the data structure member "tbiphy" of the
variable "dtsec" if a matching device was not found.
A call of the function "put_device" was unnecessary then because
a previous call of the function "get_device" was not triggered.
Thus remove the function call "put_device" after the printing of the
desired error message.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoMerge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Thu, 14 Jan 2016 19:57:22 +0000 (11:57 -0800)] 
Merge branch 'x86-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull x86 fixes from Ingo Molnar:
 "Misc changes:
   - fix lguest bug
   - fix /proc/meminfo output on certain configs
   - fix pvclock bug
   - fix reboot on certain iMacs by adding new reboot quirk
   - fix bootup crash
   - fix FPU boot line option parsing
   - add more x86 self-tests
   - small cleanups, documentation improvements, etc"

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/cpu/amd: Remove an unneeded condition in srat_detect_node()
  x86/vdso/pvclock: Protect STABLE check with the seqcount
  x86/mm: Improve switch_mm() barrier comments
  selftests/x86: Test __kernel_sigreturn and __kernel_rt_sigreturn
  x86/reboot/quirks: Add iMac10,1 to pci_reboot_dmi_table[]
  lguest: Map switcher text R/O
  x86/boot: Hide local labels in verify_cpu()
  x86/fpu: Disable AVX when eagerfpu is off
  x86/fpu: Disable MPX when eagerfpu is off
  x86/fpu: Disable XGETBV1 when no XSAVE
  x86/fpu: Fix early FPU command-line parsing
  x86/mm: Use PAGE_ALIGNED instead of IS_ALIGNED
  selftests/x86: Disable the ldt_gdt_64 test for now
  x86/mm/pat: Make split_page_count() check for empty levels to fix /proc/meminfo output
  x86/boot: Double BOOT_HEAP_SIZE to 64KB
  x86/mm: Add barriers and document switch_mm()-vs-flush synchronization

8 years agoMerge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Thu, 14 Jan 2016 19:45:56 +0000 (11:45 -0800)] 
Merge branch 'timers-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull timer fixes from Ingo Molnar:
 "Three clocksource driver fixes"

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  clocksource/drivers/vt8500: Increase the minimum delta
  clocksource/drivers/fsl_ftm_timer: Fix CLKSRC_MMIO dependency
  clocksource/drivers: Fix dependencies for !HAS_IOMEM archs

8 years agoMerge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Thu, 14 Jan 2016 19:39:09 +0000 (11:39 -0800)] 
Merge branch 'perf-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull perf fixes from Ingo Molnar:
 "Tooling fixes, the biggest patch is one that decouples the kernel's
  list.h from tooling list.h"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (23 commits)
  perf tools: Fallback to srcdir/Documentation/tips.txt
  perf ui/tui: Print helpline message as is
  perf tools: Set and pass DOCDIR to builtin-report.c
  perf tools: Add file_only config option to strlist
  perf tools: Add more usage tips
  perf record: Add --buildid-all option
  tools subcmd: Add missing NORETURN define for parse-options.h
  tools: Fix formatting of the "make -C tools" help message
  tools: Make list.h self-sufficient
  perf tools: Fix mmap2 event allocation in synthesize code
  perf stat: Fix recort_usage typo
  perf test: Reset err after using it hold errcode in hist testcases
  perf test: Fix false TEST_OK result for 'perf test hist'
  tools build: Add BPF feature check to test-all
  perf bpf: Fix build breakage due to libbpf
  tools: Move Makefile.arch from perf/config to tools/scripts
  perf tools: Fix PowerPC native building
  perf tools: Fix phony build target for build-test
  perf tools: Add -lutil in python lib list for broken python-config
  perf tools: Add missing sources to perf's MANIFEST
  ...

8 years agoMerge branch 'i2c/for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Linus Torvalds [Thu, 14 Jan 2016 19:25:37 +0000 (11:25 -0800)] 
Merge branch 'i2c/for-4.5' of git://git./linux/kernel/git/wsa/linux

Pull i2c updates from Wolfram Sang:
 "Quite some driver updates:
   - piix4 can now handle multiplexed adapters
   - brcmstb, xlr, eg20t, designware drivers support more SoCs
   - emev2 gained i2c slave support
   - img-scb and rcar got bigger refactoring to remove issues
   - lots of common driver updates

  i2c core changes:
   - new quirk flag when an adapter does not support clock stretching,
     so clients can be configured to avoid that if possible
   - added a helper function to retrieve timing parameters from firmware
     (with rcar being the first user)
   - "multi-master" DT binding added so drivers can adapt to this
     setting (like disabling PM to keep arbitration working)
   - RuntimePM for the logical adapter device is now always enabled by
     the core to ensure propagation from childs to the parent (the HW
     device)
   - new macro builtin_i2c_driver to reduce boilerplate"

* 'i2c/for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (70 commits)
  i2c: create builtin_i2c_driver to avoid registration boilerplate
  i2c: imx: fix i2c resource leak with dma transfer
  dt-bindings: i2c: eeprom: add another EEPROM device
  dt-bindings: move I2C eeprom descriptions to the proper file
  i2c: designware: Do not require clock when SSCN and FFCN are provided
  DT: i2c: trivial-devices: Add Epson RX8010 and MPL3115
  i2c: s3c2410: remove superfluous runtime PM calls
  i2c: always enable RuntimePM for the adapter device
  i2c: designware: retry transfer on transient failure
  i2c: ibm_iic: rename i2c_timings struct due to clash with generic version
  i2c: designware: Add support for AMD Seattle I2C
  i2c: imx: Remove unneeded comments
  i2c: st: use to_platform_device()
  i2c: designware: use to_pci_dev()
  i2c: brcmstb: Adding support for CM and DSL SoCs
  i2c: mediatek: fix i2c multi transfer issue in high speed mode
  i2c: imx: improve code readability
  i2c: imx: Improve message log when DMA is not used
  i2c: imx: add runtime pm support to improve the performance
  i2c: imx: init bus recovery info before adding i2c adapter
  ...

8 years agoMerge tag 'devicetree-for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/robh...
Linus Torvalds [Thu, 14 Jan 2016 19:13:28 +0000 (11:13 -0800)] 
Merge tag 'devicetree-for-4.5' of git://git./linux/kernel/git/robh/linux

Pull DeviceTree updates from Rob Herring:

 - Rework and export the changeset API to make it available to users
   other than DT overlays

 - ARM secure devices binding

 - OCTEON USB binding

 - Clean-up of various SRAM binding docs

 - Various other binding doc updates

* tag 'devicetree-for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (21 commits)
  drivers/of: Export OF changeset functions
  Fix documentation for adp1653 DT
  ARM: psci: Fix indentation in DT bindings
  of/platform: export of_default_bus_match_table
  of/unittest: Show broken behaviour in the platform bus
  of: fix declaration of of_io_request_and_map
  of/address: replace printk(KERN_ERR ...) with pr_err(...)
  of/irq: optimize device node matching loop in of_irq_init()
  dt-bindings: tda998x: Document the required 'port' node.
  net/macb: bindings doc: Merge cdns-emac to macb
  dt-bindings: Misc fix for the ATH79 DDR controllers
  dt-bindings: Misc fix for the ATH79 MISC interrupt controllers
  Documentation: dt: Add bindings for Secure-only devices
  dt-bindings: ARM: add arm,cortex-a72 compatible string
  ASoC: Atmel: ClassD: add GCK's parent clock in DT binding
  DT: add Olimex to vendor prefixes
  Documentation: fsl-quadspi: Add fsl,ls1021-qspi compatible string
  Documentation/devicetree: document OCTEON USB bindings
  usb: misc: usb3503: Describe better how to bind clock to the hub
  dt-bindings: Consolidate SRAM bindings from all vendors
  ...

8 years agoMerge tag 'mfd-for-linus-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
Linus Torvalds [Thu, 14 Jan 2016 18:53:15 +0000 (10:53 -0800)] 
Merge tag 'mfd-for-linus-4.5' of git://git./linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "New Device Support:
   - Add support for s2mps15; sec-core
   - Add support for Lewisburg; lpc_ich
   - Add support for cs47l24 and wm1831; arizona

  New Functionality:
   - Allow user to select syscon register width; syscon

  Fix-ups:
   - Lots of Checkpatch fixes
   - Rename -pmic/-regulator; s2mps11
   - Build driver components into a single module; wm8994-*
   - Better handing of IRQ during suspend/resume; as3722
   - Constify things; da903x
   - Remove unused code; ab8500-core
   - Improve error handing; qcom_rpm
   - Simplify code: wm831x-otp, sta2x11-mfd
   - Improve locking; cros_ec_spi
   - Fix incorrect DT binding filename reference; arizona, palmas,
     snps-dwapb-gpio, wm8994

  Bug Fixes:
   - Fix broken SYSFS 'show ID' call; wm831x-otp
   - Protect reads from non-existent registers; qcom-spmi-pmic
   - Repair build warnings; as3722
   - Fix IRQ request ordering; arizona-irq
   - Ensure return value is boolean; ucb1x00-core, tps65010, tc6393xb,
     htc-egpio, dm355evm_msp, asic3"

* tag 'mfd-for-linus-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (58 commits)
  mfd: davinci_voicecodec: Remove pointless 'out of memory' error message
  mfd: da9052-irq: Fix trivial 'space before comma' error
  mfd: da9052-i2c: Fix tabbing/whitespace issue
  mfd: da903x: Fix white space and split string issues
  mfd: cs5535-mfd: Add missing line spacing and make local array static
  mfd: cros_ec_spi: Repair comparison ordering issue
  mfd: cros_ec_i2c: Fix trivial 'tabs before spaces' whitespace issue.
  mfd: asic3: Fix a plethora of Checkpatch errors and warnings
  mfd: as3711: Repair OOM and 'line over 80 chars' formatting warnings
  mfd: arizona-i2c: Add blank line formatting after declaration
  mfd: arizona-core: msleep() is unreliable for anything <20ms use usleep_range() instead
  mfd: adp5520: Some trivial 'no space before tab' fixes
  mfd: ab8500-sysctrl: Fix Constify, printk => pr_info and formatting issues
  mfd: ab8500-gpadc: Squash a whole bunch of Checkpatch warnings and one error
  mfd: ab8500-debugfs: Clean-up non-conforming commenting and print formatting
  mfd: ab8500-core: Fix many warnings reported by Checkpatch
  mfd: ab2100-otp: Remove pointless 'out of memory' error message
  mfd: ab3100-core.c: Fix multiple warnings reported by Checkpatch
  mfd: aat2870-core: Remove unnecessary 'out of memory' message
  mfd: 88pm860x-core: Fix commenting and declaration spacing
  ...

8 years agoMerge tag 'for-v4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power...
Linus Torvalds [Thu, 14 Jan 2016 18:45:11 +0000 (10:45 -0800)] 
Merge tag 'for-v4.5' of git://git./linux/kernel/git/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:
 "I have mostly fixes in the power-supply tree for the 4.5 kernel.  I
  should mention, that the top-most commit has not been in next, but
  it's a fix changing only a single register offset.

  Summary:

   - uncouple CONFIG_POWER_RESET from CONFIG_POWER_SUPPLY

   - misc fixes"

* tag 'for-v4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power: bq27xxx_battery: Fix bq27541 AveragePower register address
  power: test_power: correctly handle empty writes
  power: generic-adc-battery: use to_delayed_work
  power: isp1704_charger: Fix isp1704_write() definition
  power: bq27xxx: fix register numbers of bq27500
  power: bq27xxx: fix reading for bq27000 and bq27010
  power: Fix unmet dependency on POWER_SUPPLY by POWER_RESET by uncoupling them
  power: bq27xxx_battery: Reorganize I2C into a module
  power: bq27xxx: don't fill system log by missing battery
  power: max8903_charger: set IRQF_ONESHOT if no primary handler is specified
  power/reset: at91-reset: add missing of_node_put
  power: ds2782_battery: constify ds278x_battery_ops structure
  power: bq2415x_charger: Delete unnecessary checks before the function call "of_node_put"

8 years agoMerge tag 'hsi-for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi
Linus Torvalds [Thu, 14 Jan 2016 18:40:16 +0000 (10:40 -0800)] 
Merge tag 'hsi-for-4.5' of git://git./linux/kernel/git/sre/linux-hsi

Pull HSI updates from Sebastian Reichel:
 "Misc fixes"

* tag 'hsi-for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi:
  HSI: omap_ssi_port: fix handling of_get_named_gpio result
  HSI: omap_ssi: fix handling ida_simple_get result
  HSI: Remove struct hsi_client private fields from kernel-doc

8 years agoMerge tag 'backlight-for-linus-4.5' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Thu, 14 Jan 2016 18:34:33 +0000 (10:34 -0800)] 
Merge tag 'backlight-for-linus-4.5' of git://git./linux/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
  Fix-ups:
   - Take heed of GPIO default-on requests; gpio_backlight
   - Enable DT probing; tps65217_bl

  Bug Fixes:
   - Free resources in error path; pwm_bl
   - Fix uninitialised variable warning; adp8860_bl, adp8870_bl
   - Protect unconditional DT look-ups from non-DT platforms; pwm_bl
   - Fix backlight flicker; pwm_bl

* tag 'backlight-for-linus-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
  backlight: pwm_bl: Free PWM requested by legacy API on error path
  backlight: adp8860: Fix another uninitialized variable use
  backlight: gpio-backlight: Use default-on on GPIO request
  backlight: pwm_bl: Fix broken PWM backlight for non-dt platforms
  backlight: tps65217_bl: Add MODULE_DEVICE_TABLE
  backlight: pwm_bl: Avoid backlight flicker when probed from DT
  backlight: adp88x0: Fix uninitialized variable use

8 years agosparc64: fix incorrect sign extension in sys_sparc64_personality
Dmitry V. Levin [Sat, 26 Dec 2015 23:13:27 +0000 (02:13 +0300)] 
sparc64: fix incorrect sign extension in sys_sparc64_personality

The value returned by sys_personality has type "long int".
It is saved to a variable of type "int", which is not a problem
yet because the type of task_struct->pesonality is "unsigned int".
The problem is the sign extension from "int" to "long int"
that happens on return from sys_sparc64_personality.

For example, a userspace call personality((unsigned) -EINVAL) will
result to any subsequent personality call, including absolutely
harmless read-only personality(0xffffffff) call, failing with
errno set to EINVAL.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoMerge branches 'for-4.4/upstream-fixes', 'for-4.5/async-suspend', 'for-4.5/container...
Jiri Kosina [Thu, 14 Jan 2016 15:11:06 +0000 (16:11 +0100)] 
Merge branches 'for-4.4/upstream-fixes', 'for-4.5/async-suspend', 'for-4.5/container-of-cleanups', 'for-4.5/core', 'for-4.5/i2c-hid', 'for-4.5/logitech', 'for-4.5/multitouch', 'for-4.5/sony', 'for-4.5/upstream' and 'for-4.5/wacom' into for-linus

8 years agox86/cpu/amd: Remove an unneeded condition in srat_detect_node()
Dan Carpenter [Wed, 13 Jan 2016 12:39:40 +0000 (15:39 +0300)] 
x86/cpu/amd: Remove an unneeded condition in srat_detect_node()

Originally we calculated ht_nodeid as "ht_nodeid = apicid -
boot_cpu_id;" so presumably it could be negative.

But after commit:

  01aaea1afbcd ('x86: introduce initial apicid')

we use c->initial_apicid which is an unsigned short and thus always >= 0.

It causes a static checker warning to test for impossible
conditions so let's remove it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Hector Marco-Gisbert <hecmargi@upv.es>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Link: http://lkml.kernel.org/r/20160113123940.GE19993@mwanda
Signed-off-by: Ingo Molnar <mingo@kernel.org>
8 years agomfd: davinci_voicecodec: Remove pointless 'out of memory' error message
Lee Jones [Wed, 28 Oct 2015 16:54:29 +0000 (16:54 +0000)] 
mfd: davinci_voicecodec: Remove pointless 'out of memory' error message

WARNING: Possible unnecessary 'out of memory' message
+       if (!davinci_vc) {
+               dev_dbg(&pdev->dev,

total: 0 errors, 1 warnings, 154 lines checked

Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: da9052-irq: Fix trivial 'space before comma' error
Lee Jones [Wed, 28 Oct 2015 16:53:04 +0000 (16:53 +0000)] 
mfd: da9052-irq: Fix trivial 'space before comma' error

ERROR: space prohibited before that ',' (ctx:WxW)
+       da9052_free_irq(da9052, DA9052_IRQ_ADC_EOM , da9052);

total: 1 errors, 0 warnings, 290 lines checked

Cc: Support Opensource <support.opensource@diasemi.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: da9052-i2c: Fix tabbing/whitespace issue
Lee Jones [Wed, 28 Oct 2015 16:51:11 +0000 (16:51 +0000)] 
mfd: da9052-i2c: Fix tabbing/whitespace issue

WARNING: suspect code indent for conditional statements (8, 24)
+       if (!i2c_safe_reg(reg))
+                       return regmap_read(da9052->regmap,

total: 0 errors, 1 warnings, 226 lines checked

Cc: Support Opensource <support.opensource@diasemi.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: da903x: Fix white space and split string issues
Lee Jones [Wed, 28 Oct 2015 16:47:00 +0000 (16:47 +0000)] 
mfd: da903x: Fix white space and split string issues

While we're at it, let's also match the MODULE_LICENSE with the header.

WARNING: please, no space before tabs
+ * ^IMike Rapoport <mike@compulab.co.il>$

WARNING: please, no space before tabs
+ * ^IEric Miao <eric.miao@marvell.com>$

WARNING: quoted string split across lines
+MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"
+             "Mike Rapoport <mike@compulab.co.il>");

total: 0 errors, 3 warnings, 574 lines checked

Cc: Support Opensource <support.opensource@diasemi.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: cs5535-mfd: Add missing line spacing and make local array static
Lee Jones [Wed, 28 Oct 2015 16:44:58 +0000 (16:44 +0000)] 
mfd: cs5535-mfd: Add missing line spacing and make local array static

WARNING: Missing a blank line after declarations
+       struct resource *res;
+       res = platform_get_resource(pdev, IORESOURCE_IO, 0);

WARNING: char * array declaration might be better as static const
+       const char *acpi_clones[] = { "olpc-xo1-pm-acpi", "olpc-xo1-sci-acpi" };

total: 0 errors, 2 warnings, 192 lines checked

Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: cros_ec_spi: Repair comparison ordering issue
Lee Jones [Wed, 28 Oct 2015 16:42:45 +0000 (16:42 +0000)] 
mfd: cros_ec_spi: Repair comparison ordering issue

WARNING: Comparisons should place the constant on the right side of the test
+       BUG_ON(EC_MSG_PREAMBLE_COUNT > ec_dev->din_size);

WARNING: Comparisons should place the constant on the right side of the test
+       BUG_ON(EC_MSG_PREAMBLE_COUNT > ec_dev->din_size);

total: 0 errors, 2 warnings, 731 lines checked

Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: cros_ec_i2c: Fix trivial 'tabs before spaces' whitespace issue.
Lee Jones [Wed, 28 Oct 2015 16:02:48 +0000 (16:02 +0000)] 
mfd: cros_ec_i2c: Fix trivial 'tabs before spaces' whitespace issue.

ERROR: code indent should use tabs where possible
+ ^Iec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL);$

WARNING: please, no space before tabs
+ ^Iec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL);$

WARNING: please, no spaces at the start of a line
+ ^Iec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL);$

total: 1 errors, 2 warnings, 366 lines checked

Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: asic3: Fix a plethora of Checkpatch errors and warnings
Lee Jones [Wed, 28 Oct 2015 14:11:23 +0000 (14:11 +0000)] 
mfd: asic3: Fix a plethora of Checkpatch errors and warnings

ERROR: Macros with complex values should be enclosed in parentheses
+#define INIT_CDEX(_name, _rate)        \
+       [ASIC3_CLOCK_##_name] = {               \
+               .cdex = CLOCK_CDEX_##_name,     \
+               .rate = _rate,                  \
+       }

WARNING: line over 80 characters
+                                                           ASIC3_GPIO_INT_STATUS);

WARNING: void function return statements are not generally useful
+       return;
+}

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+       msleep(1);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+       msleep(1);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+       msleep(1);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+       msleep(1);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+       msleep(1);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+       msleep(1);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+               msleep(1);
WARNING: line over 80 characters
+               asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) +

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then p
r_err(...  to printk(KERN_ERR ...
+               printk(KERN_ERR "kzalloc failed\n");

WARNING: Possible unnecessary 'out of memory' message
+       if (asic == NULL) {
+               printk(KERN_ERR "kzalloc failed\n");

WARNING: Missing a blank line after declarations
+       int retval = 0;
+       retval = platform_driver_probe(&asic3_device_driver, asic3_probe);

total: 1 errors, 13 warnings, 1081 lines checked

Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: as3711: Repair OOM and 'line over 80 chars' formatting warnings
Lee Jones [Wed, 28 Oct 2015 13:57:44 +0000 (13:57 +0000)] 
mfd: as3711: Repair OOM and 'line over 80 chars' formatting warnings

WARNING: Possible unnecessary 'out of memory' message
+               if (!pdata) {
+                       dev_err(&client->dev, "Failed to allocate pdata\n");

WARNING: Possible unnecessary 'out of memory' message
+       if (!as3711) {
+               dev_err(&client->dev, "Memory allocation failed\n");

WARNING: line over 80 characters
+               dev_err(&client->dev, "regmap initialization failed: %d\n", ret);

WARNING: line over 80 characters
+       /* We can reuse as3711_subdevs[], it will be copied in mfd_add_devices() */

WARNING: line over 80 characters
+               as3711_subdevs[AS3711_REGULATOR].platform_data = &pdata->regulator;

WARNING: line over 80 characters
+               as3711_subdevs[AS3711_REGULATOR].pdata_size = sizeof(pdata->regulator);

WARNING: line over 80 characters
+               as3711_subdevs[AS3711_BACKLIGHT].platform_data = &pdata->backlight;

WARNING: line over 80 characters
+               as3711_subdevs[AS3711_BACKLIGHT].pdata_size = sizeof(pdata->backlight);

total: 0 errors, 8 warnings, 236 lines checked

Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: arizona-i2c: Add blank line formatting after declaration
Lee Jones [Wed, 28 Oct 2015 13:54:07 +0000 (13:54 +0000)] 
mfd: arizona-i2c: Add blank line formatting after declaration

WARNING: Missing a blank line after declarations
+       struct arizona *arizona = dev_get_drvdata(&i2c->dev);
+       arizona_dev_exit(arizona);

total: 0 errors, 1 warnings, 120 lines checked

Cc: patches@opensource.wolfsonmicro.com
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: arizona-core: msleep() is unreliable for anything <20ms use usleep_range() instead
Lee Jones [Wed, 28 Oct 2015 12:42:30 +0000 (12:42 +0000)] 
mfd: arizona-core: msleep() is unreliable for anything <20ms use usleep_range() instead

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+               msleep(1);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+                       msleep(5);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+               msleep(1);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+               msleep(1);

total: 0 errors, 4 warnings, 1407 lines checked

Cc: patches@opensource.wolfsonmicro.com
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: adp5520: Some trivial 'no space before tab' fixes
Lee Jones [Wed, 28 Oct 2015 12:21:12 +0000 (12:21 +0000)] 
mfd: adp5520: Some trivial 'no space before tab' fixes

WARNING: please, no space before tabs
+ * ^IMike Rapoport <mike@compulab.co.il>$

WARNING: please, no space before tabs
+ * ^IEric Miao <eric.miao@marvell.com>$

WARNING: please, no space before tabs
+^I.id_table ^I= adp5520_id,$

total: 0 errors, 3 warnings, 365 lines checked

Cc: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: ab8500-sysctrl: Fix Constify, printk => pr_info and formatting issues
Lee Jones [Wed, 28 Oct 2015 11:11:05 +0000 (11:11 +0000)] 
mfd: ab8500-sysctrl: Fix Constify, printk => pr_info and formatting issues

WARNING: char * array declaration might be better as static const
+       static char *pss[] = {"ab8500_ac", "pm2301", "ab8500_usb"};

WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then
 pr_info(...  to printk(KERN_INFO ...
+                       printk(KERN_INFO

WARNING: quoted string split across lines
+                              "Charger \"%s\" is connected with known battery."
+                              " Rebooting.\n",

WARNING: quoted string split across lines
+                                       "unable to set sysClkReq%dRfClkBuf: "
+                                       "%d\n", j + 1, ret);

total: 0 errors, 4 warnings, 199 lines checked

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: ab8500-gpadc: Squash a whole bunch of Checkpatch warnings and one error
Lee Jones [Wed, 28 Oct 2015 10:32:10 +0000 (10:32 +0000)] 
mfd: ab8500-gpadc: Squash a whole bunch of Checkpatch warnings and one error

WARNING: line over 80 characters
+#define ADC_CH_IBAT_MIN                        (-6000) /* mA range measured by ADC for ib
t*/

WARNING: line over 80 characters
+#define ADC_CH_IBAT_MIN_V              (-60)   /* mV range measured by ADC for ibat*/

WARNING: suspect code indent for conditional statements (16, 20)
+               if (!strcmp(name, dev_name(gpadc->dev)))
+                   return gpadc;

WARNING: suspect code indent for conditional statements (0, 16)
+if (ad_value < 0) {
+               dev_err(gpadc->dev, "GPADC raw value failed ch: %d\n",

WARNING: quoted string split across lines
+               dev_err(gpadc->dev, "GPADC to voltage conversion failed ch:"
+                       " %d AD: 0x%x\n", channel, ad_value);

WARNING: Missing a blank line after declarations
+       int raw_data;
+       raw_data = ab8500_gpadc_double_read_raw(gpadc, channel,

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+               msleep(10);

ERROR: else should follow close brace '}'
+       }
+       else

WARNING: line over 80 characters
+                       delay_max = 10000; /* large range to optimise sleep mode */

WARNING: line over 80 characters
+                       gpadc->cal_data[ADC_INPUT_IBAT].gain = V_gain * V2A_gain;

WARNING: line over 80 characters
+       gpadc = devm_kzalloc(&pdev->dev, sizeof(struct ab8500_gpadc), GFP_KERNEL);

WARNING: Possible unnecessary 'out of memory' message
+       if (!gpadc) {
+               dev_err(&pdev->dev, "Error: No memory\n");

WARNING: space prohibited before semicolon
+       return ;

WARNING: void function return statements are not generally useful
+       return ;
+}

WARNING: quoted string split across lines
+MODULE_AUTHOR("Arun R Murthy, Daniel Willerud, Johan Palsson,"
+               "M'boumba Cedric Madianga");

total: 1 errors, 14 warnings, 1089 lines checked

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: ab8500-debugfs: Clean-up non-conforming commenting and print formatting
Lee Jones [Wed, 28 Oct 2015 09:27:32 +0000 (09:27 +0000)] 
mfd: ab8500-debugfs: Clean-up non-conforming commenting and print formatting

WARNING: Block comments use a trailing */ on a separate line
+                        * not be accessed from here */

WARNING: Block comments use a trailing */ on a separate line
+                        * not be accessed from here */

WARNING: Block comments use a trailing */ on a separate line
+                                * the output is wanted in any case */

WARNING: Consecutive strings are generally better as a single string
+               "  addr=0x%08X, mask=0x%X, shift=%d" "value=0x%X\n",

total: 0 errors, 4 warnings, 3331 lines checked

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: ab8500-core: Fix many warnings reported by Checkpatch
Lee Jones [Wed, 28 Oct 2015 09:15:02 +0000 (09:15 +0000)] 
mfd: ab8500-core: Fix many warnings reported by Checkpatch

WARNING: Block comments use a trailing */ on a separate line
+        * */

WARNING: Block comments use a trailing */ on a separate line
+        * bank on higher 8 bits and reg in lower */

WARNING: Block comments use a trailing */ on a separate line
+        * bank on higher 8 bits and reg in lower */

WARNING: suspect code indent for conditional statements (8, 24)
+       if (unlikely(*offset == 17))
+                       *offset = 24;

WARNING: suspect code indent for conditional statements (8, 24)
+       if (unlikely(*offset == 16))
+                       *offset = 25;

WARNING: suspect code indent for conditional statements (8, 24)
+       if ((i == 3) && (*offset >= 24))
+                       *offset += 2;

WARNING: ENOSYS means 'invalid syscall nr' and nothing else
+               return -ENOSYS;

WARNING: static const char * array should probably be static const char * const
+       static const char *switch_off_status[] = {

WARNING: static const char * array should probably be static const char * const
+       static const char *turn_on_status[] = {

total: 0 errors, 9 warnings, 1867 lines checked

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: ab2100-otp: Remove pointless 'out of memory' error message
Lee Jones [Wed, 28 Oct 2015 09:08:22 +0000 (09:08 +0000)] 
mfd: ab2100-otp: Remove pointless 'out of memory' error message

WARNING: Possible unnecessary 'out of memory' message
+       if (!otp) {
+               dev_err(&pdev->dev, "could not allocate AB3100 OTP device\n");

total: 0 errors, 1 warnings, 250 lines checked

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: ab3100-core.c: Fix multiple warnings reported by Checkpatch
Lee Jones [Tue, 27 Oct 2015 16:19:31 +0000 (16:19 +0000)] 
mfd: ab3100-core.c: Fix multiple warnings reported by Checkpatch

WARNING: Missing a blank line after declarations
+       struct ab3100 *ab3100 = dev_get_drvdata(dev->parent);
+       if (!ab3100->startup_events_read)

WARNING: Possible unnecessary 'out of memory' message
+       if (!ab3100) {
+               dev_err(&client->dev, "could not allocate AB3100 device\n");

WARNING: else is not generally useful after a break or return
+                               break;
+                       } else {

total: 0 errors, 3 warnings, 996 lines checked

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: aat2870-core: Remove unnecessary 'out of memory' message
Lee Jones [Tue, 27 Oct 2015 16:14:06 +0000 (16:14 +0000)] 
mfd: aat2870-core: Remove unnecessary 'out of memory' message

WARNING: Possible unnecessary 'out of memory' message
+       if (!aat2870) {
+               dev_err(&client->dev,

total: 0 errors, 1 warnings, 524 lines checked

Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: 88pm860x-core: Fix commenting and declaration spacing
Lee Jones [Tue, 27 Oct 2015 16:12:21 +0000 (16:12 +0000)] 
mfd: 88pm860x-core: Fix commenting and declaration spacing

Checkpatch output:

WARNING: Block comments use a trailing */ on a separate line
+        * - turn off */

WARNING: Missing a blank line after declarations
+       int ret;
+       ret = i2c_add_driver(&pm860x_driver);

total: 0 errors, 2 warnings, 1283 lines checked

Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: arizona: Add device tree binding documentation for new clock driver
Charles Keepax [Fri, 8 Jan 2016 11:29:42 +0000 (11:29 +0000)] 
mfd: arizona: Add device tree binding documentation for new clock driver

Specify the device tree binding for the input clocks to Arizona devices.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: Use to_i2c_client() instead of open-coding it
Geliang Tang [Mon, 28 Dec 2015 15:00:14 +0000 (23:00 +0800)] 
mfd: Use to_i2c_client() instead of open-coding it

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agodt-bindings: regulator/mfd: Reorganize S2MPA01 bindings
Krzysztof Kozlowski [Fri, 4 Dec 2015 01:10:05 +0000 (10:10 +0900)] 
dt-bindings: regulator/mfd: Reorganize S2MPA01 bindings

The mfd/s2mpa01.txt duplicates some of the information about bindings
with old mfd/s2mps11.txt. Now common part exists entirely in
mfd/samsung,sec-core.txt so:
 - add company prefix to file name (regulator/samsung,s2mpa01.txt),
 - remove duplicated information,
 - reorganize the contents to match style of
   regulator/samsung,s2mps11.txt.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agodt-bindings: regulator/mfd: Reorganize S5M8767 bindings
Krzysztof Kozlowski [Fri, 4 Dec 2015 01:10:04 +0000 (10:10 +0900)] 
dt-bindings: regulator/mfd: Reorganize S5M8767 bindings

The regulator/s5m8767-regulator.txt duplicates some of the information
about bindings with old mfd/s2mps11.txt. Now common part exists entirely
in mfd/samsung,sec-core.txt so:
 - add company prefix to file name (regulator/samsung,s5m8767.txt),
 - remove duplicated information,
 - reorganize the contents to match style of
   regulator/samsung,s2mps11.txt.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agodt-bindings: regulator/clock/mfd: Reorganize S2MPS-family bindings
Krzysztof Kozlowski [Fri, 4 Dec 2015 01:10:03 +0000 (10:10 +0900)] 
dt-bindings: regulator/clock/mfd: Reorganize S2MPS-family bindings

Bindings for Samsung S2M and S5M family PMICs are in mess. They are
spread over different files and subdirectories in a non-consistent way.
The devices and respective drivers for them share a lot in common so
everything could be organized in a more readable way.

Reorganize the S2MPS11/13/14/15 Device Tree bindings to match the
drivers for this family of devices:
 - move mfd/s2mps11.txt to mfd/samsung,sec-core.txt for the main MFD
   driver (common for entire family),
 - split clock block to clock/samsung,s2mps11.txt,
 - split regulator block to regulator/samsung,s2mps11.txt.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: asic3: Be sure to clamp return value
Linus Walleij [Tue, 22 Dec 2015 14:47:05 +0000 (15:47 +0100)] 
mfd: asic3: Be sure to clamp return value

As we want gpio_chip .get() calls to be able to return negative
error codes and propagate to drivers, we need to go over all
drivers and make sure their return values are clamped to [0,1].
We do this by using the ret = !!(val) design pattern.

Cc: Paul Parsons <lost.distance@yahoo.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: dm355evm_mps: Be sure to clamp return value
Linus Walleij [Tue, 22 Dec 2015 14:47:31 +0000 (15:47 +0100)] 
mfd: dm355evm_mps: Be sure to clamp return value

As we want gpio_chip .get() calls to be able to return negative
error codes and propagate to drivers, we need to go over all
drivers and make sure their return values are clamped to [0,1].
We do this by using the ret = !!(val) design pattern.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
8 years agomfd: htc-egpio: Be sure to clamp return value
Linus Walleij [Tue, 22 Dec 2015 14:47:39 +0000 (15:47 +0100)] 
mfd: htc-egpio: Be sure to clamp return value

As we want gpio_chip .get() calls to be able to return negative
error codes and propagate to drivers, we need to go over all
drivers and make sure their return values are clamped to [0,1].
We do this by using the ret = !!(val) design pattern.

Cc: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
This page took 0.061838 seconds and 5 git commands to generate.