Commit graph

592135 commits

Author SHA1 Message Date
Sahitya Tummala
d5d9fdf4ca mm/list_lru.c: fix list_lru_count_node() to be race free
list_lru_count_node() iterates over all memcgs to get the total number of
entries on the node but it can race with memcg_drain_all_list_lrus(),
which migrates the entries from a dead cgroup to another.  This can return
incorrect number of entries from list_lru_count_node().

Fix this by keeping track of entries per node and simply return it in
list_lru_count_node().

Change-Id: I19e3b527804e95be75f48ee363c8207c0e7ee2ff
Link: http://lkml.kernel.org/r/1498707555-30525-1-git-send-email-stummala@codeaurora.org
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Alexander Polakov <apolyakov@beget.ru>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Patch-mainline: linux-mm @ 29/06/17, 09:09:15
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2017-07-11 09:30:58 +05:30
Linux Build Service Account
0d2bf7e895 Merge "cnss2: Bypass SMMU stage-1 by default" 2017-07-10 14:09:14 -07:00
Srikanth Rajagopalan
fb87ca54f6 drm/msm/sde: Expose the HDR support capability of the chipset
Expose HDR capability using a property to the userspace.

This will help userspace to decide whether to invoke the HDR library
and pass the relevant parameters to be sent to the sink.

Change-Id: I3c4bf4d6c4e0f0babdf49b3c99baab42dcb2b5c0
Signed-off-by: Srikanth Rajagopalan <rasrik@codeaurora.org>
2017-07-10 12:48:26 -07:00
Amit Blay
232738f76f soc: qcom: SCM front-end over QCPE
This is an implementation of para-virtualized SCM driver.
This driver is the FE. The BE is QCPE running in an hypervisor.
The FE driver forwards SCM calls over HAB to the BE.

Change-Id: I88c269e856b0a6cc20b9ab8bf10110842d90a382
Signed-off-by: Amit Blay <ablay@codeaurora.org>
2017-07-10 08:34:29 -07:00
Charan Teja Reddy
3183420178 ARM: dts: msm: add wlan carveout region for sdm660/sdm630
Add WLAN carveout region of size 1MB. But additional guard of 1MB is
also added due to system limitations.

Change-Id: I1cd38f1ced820132209e31acc55a1321c879a09c
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
2017-07-10 18:34:20 +05:30
Revathi Uddaraju
aea1705077 ASoC: msm: qdsp6v2: Set path type to LIVE_REC in LISTEN passthrough case
ADSP SVA needs LIVE_REC path type for LISTEN pass through mode
for successful loading of SVA App.
Hence set path type to LIVE_REC in LISTEN pass through case.

Change-Id: I4404f2a64f0add62782beab3a5d8d63615d8ac01
Signed-off-by: Revathi Uddaraju <revathiu@codeaurora.org>
2017-07-10 04:03:50 -07:00
Blagovest Kolenichev
4c8daae4af Merge android-4.4@64a73ff (v4.4.76) into msm-4.4
* refs/heads/tmp-64a73ff:
  Linux 4.4.76
  KVM: nVMX: Fix exception injection
  KVM: x86: zero base3 of unusable segments
  KVM: x86/vPMU: fix undefined shift in intel_pmu_refresh()
  KVM: x86: fix emulation of RSM and IRET instructions
  cpufreq: s3c2416: double free on driver init error path
  iommu/amd: Fix incorrect error handling in amd_iommu_bind_pasid()
  iommu: Handle default domain attach failure
  iommu/vt-d: Don't over-free page table directories
  ocfs2: o2hb: revert hb threshold to keep compatible
  x86/mm: Fix flush_tlb_page() on Xen
  x86/mpx: Correctly report do_mpx_bt_fault() failures to user-space
  ARM: 8685/1: ensure memblock-limit is pmd-aligned
  ARM64/ACPI: Fix BAD_MADT_GICC_ENTRY() macro implementation
  sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting
  watchdog: bcm281xx: Fix use of uninitialized spinlock.
  xfrm: Oops on error in pfkey_msg2xfrm_state()
  xfrm: NULL dereference on allocation failure
  xfrm: fix stack access out of bounds with CONFIG_XFRM_SUB_POLICY
  jump label: fix passing kbuild_cflags when checking for asm goto support
  ravb: Fix use-after-free on `ifconfig eth0 down`
  sctp: check af before verify address in sctp_addr_id2transport
  net/mlx4_core: Eliminate warning messages for SRQ_LIMIT under SRIOV
  perf probe: Fix to show correct locations for events on modules
  be2net: fix status check in be_cmd_pmac_add()
  s390/ctl_reg: make __ctl_load a full memory barrier
  swiotlb: ensure that page-sized mappings are page-aligned
  coredump: Ensure proper size of sparse core files
  x86/mpx: Use compatible types in comparison to fix sparse error
  mac80211: initialize SMPS field in HT capabilities
  spi: davinci: use dma_mapping_error()
  scsi: lpfc: avoid double free of resource identifiers
  HID: i2c-hid: Add sleep between POWER ON and RESET
  kernel/panic.c: add missing \n
  ibmveth: Add a proper check for the availability of the checksum features
  vxlan: do not age static remote mac entries
  virtio_net: fix PAGE_SIZE > 64k
  vfio/spapr: fail tce_iommu_attach_group() when iommu_data is null
  drm/amdgpu: check ring being ready before using
  net: dsa: Check return value of phy_connect_direct()
  amd-xgbe: Check xgbe_init() return code
  platform/x86: ideapad-laptop: handle ACPI event 1
  scsi: virtio_scsi: Reject commands when virtqueue is broken
  xen-netfront: Fix Rx stall during network stress and OOM
  swiotlb-xen: update dev_addr after swapping pages
  virtio_console: fix a crash in config_work_handler
  Btrfs: fix truncate down when no_holes feature is enabled
  gianfar: Do not reuse pages from emergency reserve
  powerpc/eeh: Enable IO path on permanent error
  net: bgmac: Remove superflous netif_carrier_on()
  net: bgmac: Start transmit queue in bgmac_open
  net: bgmac: Fix SOF bit checking
  bgmac: Fix reversed test of build_skb() return value.
  mtd: bcm47xxpart: don't fail because of bit-flips
  bgmac: fix a missing check for build_skb
  mtd: bcm47xxpart: limit scanned flash area on BCM47XX (MIPS) only
  MIPS: ralink: fix MT7628 wled_an pinmux gpio
  MIPS: ralink: fix MT7628 pinmux typos
  MIPS: ralink: Fix invalid assignment of SoC type
  MIPS: ralink: fix USB frequency scaling
  MIPS: ralink: MT7688 pinmux fixes
  net: korina: Fix NAPI versus resources freeing
  MIPS: ath79: fix regression in PCI window initialization
  net: mvneta: Fix for_each_present_cpu usage
  ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags
  qla2xxx: Fix erroneous invalid handle message
  scsi: lpfc: Set elsiocb contexts to NULL after freeing it
  scsi: sd: Fix wrong DPOFUA disable in sd_read_cache_type
  KVM: x86: fix fixing of hypercalls
  mm: numa: avoid waiting on freed migrated pages
  block: fix module reference leak on put_disk() call for cgroups throttle
  sysctl: enable strict writes
  usb: gadget: f_fs: Fix possibe deadlock
  drm/vmwgfx: Free hash table allocated by cmdbuf managed res mgr
  ALSA: hda - set input_path bitmap to zero after moving it to new place
  ALSA: hda - Fix endless loop of codec configure
  MIPS: Fix IRQ tracing & lockdep when rescheduling
  MIPS: pm-cps: Drop manual cache-line alignment of ready_count
  MIPS: Avoid accidental raw backtrace
  mm, swap_cgroup: reschedule when neeed in swap_cgroup_swapoff()
  drm/ast: Handle configuration without P2A bridge
  NFSv4: fix a reference leak caused WARNING messages
  netfilter: synproxy: fix conntrackd interaction
  netfilter: xt_TCPMSS: add more sanity tests on tcph->doff
  rtnetlink: add IFLA_GROUP to ifla_policy
  ipv6: Do not leak throw route references
  sfc: provide dummy definitions of vswitch functions
  net: 8021q: Fix one possible panic caused by BUG_ON in free_netdev
  decnet: always not take dst->__refcnt when inserting dst into hash table
  net/mlx5: Wait for FW readiness before initializing command interface
  ipv6: fix calling in6_ifa_hold incorrectly for dad work
  igmp: add a missing spin_lock_init()
  igmp: acquire pmc lock for ip_mc_clear_src()
  net: caif: Fix a sleep-in-atomic bug in cfpkt_create_pfx
  Fix an intermittent pr_emerg warning about lo becoming free.
  af_unix: Add sockaddr length checks before accessing sa_family in bind and connect handlers
  net: Zero ifla_vf_info in rtnl_fill_vfinfo()
  decnet: dn_rtmsg: Improve input length sanitization in dnrmg_receive_user_skb
  net: don't call strlen on non-terminated string in dev_set_alias()
  ipv6: release dst on error in ip6_dst_lookup_tail
  UPSTREAM: selinux: enable genfscon labeling for tracefs

Change-Id: I05ae1d6271769a99ea3817e5066f5ab6511f3254
Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
2017-07-10 03:00:34 -07:00
Akhil P Oommen
54812d339b staging: android: sync: fix list corruption in fence struct
Fence lock is not taken in sync_print_fence() while calling
sync_print_pt() which in turn calls fence_is_signaled() to check the
status of each fence before printing. This creates a race condition
that corrupts fence data structure when another thread calls
fence_is_signaled_locked() on the same fence. Since we don't need to
signal the fence while logging, it can be fixed by simply checking fence
flag status directly instead of calling fence_is_signaled_locked().

Change-Id: I1b4732cf3779a5b75a372e11170b438a4deabe67
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
2017-07-10 15:28:49 +05:30
Sayali Lokhande
b52748d7fc mmc: core: Select HS mode in device first and then in the host
While switching from hs400 to hs200 mode, high speed mode
timing should be selected in the device before changing the
clock frequency in the host. But current implementation,
(mmc_hs400_to_hs200) first updates the frequency in the host
and then updates mode in the device. This is a spec violation.
Hence update the sequence to comply with the spec.

Change-Id: I0694edac9dd005ec68add9cc38bbe6fa4245ed48
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
2017-07-10 02:28:00 -07:00
annamraj
7ef725f4f0 msm: camera: Proper use of snprintf to avoid information leak
Making use of return value of snprintf to avoid information
leak and using pk instead of lx for writing address to buffer.

Change-Id: If54b37c43679613658e270c3b0da499c6d82eecf
Signed-off-by: annamraj <annamraj@codeaurora.org>
2017-07-10 13:34:03 +05:30
Mohammed Javid
b2241f015c msm: ipa: fix wrong usage and cleanup dead code
Couple of code cleanup
  - remove dead code
  - initialize local variables before use
  - validate gsi_ep_cfg_ptr return

Change-Id: Ia2c2a5559fa2c5f89b33cc1ff897df0faa725e7e
Signed-off-by: Mohammed Javid <mjavid@codeaurora.org>
2017-07-10 13:03:36 +05:30
Linux Build Service Account
d6f171ce52 Merge "i2c-msm-v2: Avoid accessing unassigned memory" 2017-07-10 00:04:21 -07:00
Shrey Vijay
9f3114efc5 i2c-msm-v2: Avoid accessing unassigned memory
Memory translation fault occurs when incorrect memory
is accessed. To avoid translation fault, do not access
message memory which is not initialized.

Change-Id: Id5e89350a4bc51021964ee63286ea69040f1b32a
Signed-off-by: Shrey Vijay <shreyv@codeaurora.org>
2017-07-09 22:34:43 -07:00
Ashwanth Goli
68af09edd5 net: rps: reset backlog state when IPI fails.
Changes that reset remote cpu backlog state are removed with the
following commit. Adding them back.
I6e688bf0d09 ("net: rps: send out pending IPI's on CPU hotplug")

Change-Id: I436d1a1f185f0ddc375349e135bbb5d6eb8c5f26
Signed-off-by: Ashwanth Goli <ashwanth@codeaurora.org>
2017-07-10 09:57:47 +05:30
Neeraj Upadhyay
79a6aefd94 power: reset: msm: Restore disabling SDI during reset
This reverts commit b67bb93f56 ("power: reset: Do not
disable SDI during reset"), to restore the original
behavior of disabling SDI during reset.

Change-Id: I6ad0472dc5d766ffea2a942fc226fb742fe44242
Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
2017-07-10 08:23:52 +05:30
Abhinav Kumar
5b678cb82f drm/msm: add input validation before setting HDR infoframe
Move the input validation for the connector's HDR support
before calling the API to set the infoframe rather than within
the API itself.

This helps to avoid redundant checks and logging.

Change-Id: If21562920edb1613a73b5e18ab258a57e46c1d7b
Signed-off-by: Abhinav Kumar <abhinavk@codeaurora.org>
2017-07-09 10:59:31 -07:00
Ghanim Fodi
bb1606be49 msm: ipa3: Verify IPA client id before using it
Verify IPA client ID is valid before using it to
access clients array for logging purposes. In case of
invalid id, do not access the array.

Change-Id: I7af6ee765a6d70d61721ac21b6a92ed53469b05a
CRs-fixed: 2051257
Signed-off-by: Ghanim Fodi <gfodi@codeaurora.org>
2017-07-09 13:24:17 +03:00
Ghanim Fodi
5c8cebfbe5 msm: ipa3: Protect access to ipa3_qmi_ctx variable by lock
ipa3_qmi_ctx is a global variable that may be accessed by
different worker threads. Protect the access to it
using mutex lock so that the access will be always atomic.

Change-Id: Iaf0c95d66817833c8e8123b12e94a7a01ab8df2c
CRs-fixed: 2056414
Signed-off-by: Ghanim Fodi <gfodi@codeaurora.org>
2017-07-09 12:09:11 +03:00
Maya Erez
fc3a244ccb ARM: dts: msm: configure GPIO19 on msm8998 for 11ad refclk3
PMIC GPIO19 is used by 11ad device to control the refclk3,
while switching to slow clock.
Configure GPIO as input, no pull and VIN 1 for 1.8V source.

Change-Id: I89c04d70f1d8eff550b85d4fcb16bf08bf128ca7
Signed-off-by: Maya Erez <merez@codeaurora.org>
2017-07-08 22:29:40 -07:00
Sandeep Panda
07a9d67a5e msm: mdss: do not resynchronize DSI FIFO if during device boot up
For PHY version 0x3, DSI FIFO needs to be resynchronized once DSI
PLL is enabled. But during device boot up if continuous splash is
enabled then we don't need to toggle the FIFO resync bit, since DSI
PLL will be already enabled by UEFI. So avoid toggling FIFO resync
if continuous splash is enabled.

Change-Id: I94f3e0e48799ded8e546f3889b3df0a8af577451
Signed-off-by: Sandeep Panda <spanda@codeaurora.org>
2017-07-09 02:14:34 +05:30
Mohammed Javid
8e5eb432c7 msm:ipa: Fix to incorrect structure access
Accessing of incorrect structure pointer is causing
memory out of bound access, fixed issue by accessing
the correct structure pointer.

Change-Id: I3c2f5f7a97cac854093ef670184d06db4231f5e1
Acked-by: Ashok Vuyyuru <avuyyuru@qti.qualcomm.com>
Signed-off-by: Mohammed Javid <mjavid@codeaurora.org>
2017-07-08 22:56:09 +05:30
Mohammed Javid
bd29388486 ARM: dts: msm: Add IPA dtsi entries for MSM8996 Auto
Add the MSM8996 auto dtsi entries for ipa_hw and rmnet-ipa
for kernel 4.4 upgrade

Change-Id: I4f0855ed6f96e51716e82fb85896b1c8c86f6db4
Acked-by: Ashok Vuyyuru <avuyyuru@qti.qualcomm.com>
Signed-off-by: Mohammed Javid <mjavid@codeaurora.org>
2017-07-08 13:48:38 +05:30
Linux Build Service Account
3ec8bfc9bb Merge "icnss: Use fixed memory region for WLAN MSA0 memory" 2017-07-07 17:45:54 -07:00
Linux Build Service Account
719e5e1640 Merge "msm: mdss: information leak during buffer copy from userspace" 2017-07-07 17:45:53 -07:00
Linux Build Service Account
a142e886a7 Merge "msm: mdss: Increase fbmem buf ref count before use" 2017-07-07 17:45:52 -07:00
Linux Build Service Account
209c402fa5 Merge "mdss: dp: avoid notifying DP connect during AUX timeout cases" 2017-07-07 17:45:51 -07:00
Linux Build Service Account
799bcf26f3 Merge "msm: mdss: Put smmu interface errors under pr_err" 2017-07-07 17:45:50 -07:00
Linux Build Service Account
1a20f4d483 Merge "ARM: dts: msm: Support for adv7533 1024x600P panel resolution on msm8996" 2017-07-07 17:45:49 -07:00
Linux Build Service Account
4669039895 Merge "msm: mdss: Fix possible integer overflow" 2017-07-07 17:45:48 -07:00
Linux Build Service Account
4e9710b652 Merge "soc: qcom: ipc_router_mhi_xprt: Do not defer MHI open and close work" 2017-07-07 17:45:47 -07:00
Jack Pham
ca88ca45eb usb: pd: Add delay before sending Source Capabilities
The PD specification defines tFirstSourceCap as the time before
a source must send its first Source_Capabilities message and
allows this to be up to 250ms. This is advantageous for cases
in which a sink partner is quickly detached (or possibly even
attempting Try.SRC) just after VBUS is turned on and the
unnecessary PD messaging causes the HW to fail to detect the
detach condition right away. Add a delay of 200ms during the
transition from PE_SRC_STARTUP to PE_SRC_SEND_CAPABILITIES.

Change-Id: I13dd31d71b8b93adadb70b113cba28ce5aed6e4e
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2017-07-07 11:12:37 -07:00
Yue Ma
243575bddb cnss2: Bypass SMMU stage-1 by default
Bypass SMMU stage-1 till it is fully supported by WLAN driver and
device.

Change-Id: I186345c20f9b71171bba6acc8c5eaa689e39b51c
CRs-fixed: 2071634
Signed-off-by: Yue Ma <yuem@codeaurora.org>
2017-07-07 09:44:28 -07:00
Yue Ma
abb697f2a1 cnss2: Fix issues when migrating to msm-4.4 kernel
Fix the issues during migrating CNSS2 platform driver to msm-4.4
kernel.

Change-Id: Ifcef708fa9394ad54c92a26a397ec60631e74ef2
CRs-fixed: 2071634
Signed-off-by: Yue Ma <yuem@codeaurora.org>
2017-07-07 09:44:27 -07:00
Yue Ma
5fc7e6650d net: cnss2: Add snapshot of CNSS2 driver
This is a snapshot of the CNSS2 driver and associated files as
of msm-3.18 commit c1bbe6d5e136 ("cnss2: Fix kernel checkpatch
issues").

Change-Id: Ia77d3abe3f86e4dbeac8d55ea2e0120bed480126
CRs-fixed: 2071634
Signed-off-by: Yue Ma <yuem@codeaurora.org>
2017-07-07 09:41:12 -07:00
Linux Build Service Account
77908d9c93 Merge "Revert "ARM: dts: msm: align removed_region with SDM630 memmap"" 2017-07-07 08:32:00 -07:00
Linux Build Service Account
539f7638fa Merge "icnss: Show rejuvenation info in ICNSS stats report" 2017-07-07 08:31:59 -07:00
Linux Build Service Account
fdc05fae43 Merge "pwm: pwm-qpnp: Ignore changing period setting if it's not requested" 2017-07-07 08:31:58 -07:00
Linux Build Service Account
dcfc6b7782 Merge "msm: sensor: Fix to validate the settings size in flash" 2017-07-07 08:31:57 -07:00
Linux Build Service Account
dec5742b2a Merge "msm: camera: Unlock rwlock before returning." 2017-07-07 08:31:56 -07:00
Linux Build Service Account
478a7073f5 Merge "diag: Add proper checks to fix possible out-of-bound issue" 2017-07-07 08:31:55 -07:00
Hardik Kantilal Patel
cc193eec69 icnss: Use fixed memory region for WLAN MSA0 memory
During first time boot up WLAN Platform driver allocate
1 MB MSA0 Memory region. This region may be adjacent to
other regions that also requires access control, due to
that TZ will merge the two sections into one single resource
group. During this Q6 will lose access to memory region causing
a NOC Error. To avoid use fixed memory region for WLAN MSA0
memory.

CRs-Fixed: 2066025
Change-Id: Ie878e010954524bbe48a29d6ad6f2f53848ab25e
Signed-off-by: Hardik Kantilal Patel <hkpatel@codeaurora.org>
2017-07-07 16:55:07 +05:30
Joonsoo Kim
e448e4e545 mm/page_alloc: introduce post allocation processing on page allocator
This patch is motivated from Hugh and Vlastimil's concern [1].

There are two ways to get freepage from the allocator.  One is using
normal memory allocation API and the other is __isolate_free_page()
which is internally used for compaction and pageblock isolation.  Later
usage is rather tricky since it doesn't do whole post allocation
processing done by normal API.

One problematic thing I already know is that poisoned page would not be
checked if it is allocated by __isolate_free_page().  Perhaps, there
would be more.

We could add more debug logic for allocated page in the future and this
separation would cause more problem.  I'd like to fix this situation at
this time.  Solution is simple.  This patch commonize some logic for
newly allocated page and uses it on all sites.  This will solve the
problem.

[1] http://marc.info/?i=alpine.LSU.2.11.1604270029350.7066%40eggly.anvils%3E

Change-Id: I601ec8ce8ee4ab76cd408ff2148dd8c73b959fc2
[iamjoonsoo.kim@lge.com: mm-page_alloc-introduce-post-allocation-processing-on-page-allocator-v3]
  Link: http://lkml.kernel.org/r/1464230275-25791-7-git-send-email-iamjoonsoo.kim@lge.com
  Link: http://lkml.kernel.org/r/1466150259-27727-9-git-send-email-iamjoonsoo.kim@lge.com
Link: http://lkml.kernel.org/r/1464230275-25791-7-git-send-email-iamjoonsoo.kim@lge.com
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Alexander Potapenko <glider@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 46f24fd857b37bb86ddd5d0ac3d194e984dfdf1c
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[guptap@codeaurora.org: resolve trivial merge conflicts]
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
2017-07-07 15:39:34 +05:30
Joonsoo Kim
0db2683327 mm/page_owner: use stackdepot to store stacktrace
Currently, we store each page's allocation stacktrace on corresponding
page_ext structure and it requires a lot of memory.  This causes the
problem that memory tight system doesn't work well if page_owner is
enabled.  Moreover, even with this large memory consumption, we cannot
get full stacktrace because we allocate memory at boot time and just
maintain 8 stacktrace slots to balance memory consumption.  We could
increase it to more but it would make system unusable or change system
behaviour.

To solve the problem, this patch uses stackdepot to store stacktrace.
It obviously provides memory saving but there is a drawback that
stackdepot could fail.

stackdepot allocates memory at runtime so it could fail if system has
not enough memory.  But, most of allocation stack are generated at very
early time and there are much memory at this time.  So, failure would
not happen easily.  And, one failure means that we miss just one page's
allocation stacktrace so it would not be a big problem.  In this patch,
when memory allocation failure happens, we store special stracktrace
handle to the page that is failed to save stacktrace.  With it, user can
guess memory usage properly even if failure happens.

Memory saving looks as following.  (4GB memory system with page_owner)
(before the patch -> after the patch)

static allocation:
92274688 bytes -> 25165824 bytes

dynamic allocation after boot + kernel build:
0 bytes -> 327680 bytes

total:
92274688 bytes -> 25493504 bytes

72% reduction in total.

Note that implementation looks complex than someone would imagine
because there is recursion issue.  stackdepot uses page allocator and
page_owner is called at page allocation.  Using stackdepot in page_owner
could re-call page allcator and then page_owner.  That is a recursion.
To detect and avoid it, whenever we obtain stacktrace, recursion is
checked and page_owner is set to dummy information if found.  Dummy
information means that this page is allocated for page_owner feature
itself (such as stackdepot) and it's understandable behavior for user.

Change-Id: I9f96f1b527836a7577b1818a6a4fde7786e23a3b
[iamjoonsoo.kim@lge.com: mm-page_owner-use-stackdepot-to-store-stacktrace-v3]
  Link: http://lkml.kernel.org/r/1464230275-25791-6-git-send-email-iamjoonsoo.kim@lge.com
  Link: http://lkml.kernel.org/r/1466150259-27727-7-git-send-email-iamjoonsoo.kim@lge.com
Link: http://lkml.kernel.org/r/1464230275-25791-6-git-send-email-iamjoonsoo.kim@lge.com
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Alexander Potapenko <glider@google.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>
Git-commit: f2ca0b55710752588ccff5224a11e6aea43a996a
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[guptap@codeaurora.org: resolve trivial merge conflicts]
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
2017-07-07 15:39:34 +05:30
Sudip Mukherjee
d2d3c7bc7e mm/page_owner: avoid null pointer dereference
We have dereferenced page_ext before checking it.  Lets check it first
and then used it.

Change-Id: I9184110069df51ddcf6eb699cb6ed2320fa09ab0
Fixes: f86e4271978b ("mm: check the return value of lookup_page_ext for all call sites")
Link: http://lkml.kernel.org/r/1465249059-7883-1-git-send-email-sudipm.mukherjee@gmail.com
Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
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>
Git-commit: 8285027fc479949a7a166bc1b26ce57e894878a7
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
2017-07-07 15:39:33 +05:30
Yang Shi
acda305dcb mm: check the return value of lookup_page_ext for all call sites
Per the discussion with Joonsoo Kim [1], we need check the return value
of lookup_page_ext() for all call sites since it might return NULL in
some cases, although it is unlikely, i.e.  memory hotplug.

Tested with ltp with "page_owner=0".

[1] http://lkml.kernel.org/r/20160519002809.GA10245@js1304-P5Q-DELUXE

Change-Id: Ie0c577c1136a7f6f4e0fa2ceacfb007cd5323b8e
[akpm@linux-foundation.org: fix build-breaking typos]
[arnd@arndb.de: fix build problems from lookup_page_ext]
  Link: http://lkml.kernel.org/r/6285269.2CksypHdYp@wuerfel
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/1464023768-31025-1-git-send-email-yang.shi@linaro.org
Signed-off-by: Yang Shi <yang.shi@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
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>
Git-commit: f86e4271978bd93db466d6a95dad4b0fdcdb04f6
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[guptap@codeaurora.org: resolve trivial merge conflicts]
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
2017-07-07 15:39:32 +05:30
Joonsoo Kim
dcaff0c9ae tools/vm/page_owner: increase temporary buffer size
Page owner will be changed to store more deep stacktrace so current
temporary buffer size isn't enough.  Increase it.

Change-Id: Icd12608e87e9a91089c498faf3fc11054d79a87c
Link: http://lkml.kernel.org/r/1464230275-25791-5-git-send-email-iamjoonsoo.kim@lge.com
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Alexander Potapenko <glider@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 371376750fce0abb09b1aa3fd8ae7025813a3488
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
2017-07-07 15:39:32 +05:30
Joonsoo Kim
df3b4bfcf9 mm/page_owner: introduce split_page_owner and replace manual handling
split_page() calls set_page_owner() to set up page_owner to each pages.
But, it has a drawback that head page and the others have different
stacktrace because callsite of set_page_owner() is slightly differnt.
To avoid this problem, this patch copies head page's page_owner to the
others.  It needs to introduce new function, split_page_owner() but it
also remove the other function, get_page_owner_gfp() so looks good to
do.

Change-Id: Ie946ccf7dc1e9eeacb03ac81720c178daa7db21e
Link: http://lkml.kernel.org/r/1464230275-25791-4-git-send-email-iamjoonsoo.kim@lge.com
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Alexander Potapenko <glider@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: a9627bc5e34e79ae80a33241b8a1501cc498e191
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[guptap@codeaurora.org: resolve trivial merge conflicts]
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
2017-07-07 15:39:31 +05:30
Joonsoo Kim
a6ea956ceb lib/stackdepot: avoid to return 0 handle
Recently, we allow to save the stacktrace whose hashed value is 0.  It
causes the problem that stackdepot could return 0 even if in success.
User of stackdepot cannot distinguish whether it is success or not so we
need to solve this problem.  In this patch, 1 bit are added to handle
and make valid handle none 0 by setting this bit.  After that, valid
handle will not be 0 and 0 handle will represent failure correctly.

Change-Id: Id3294c839edd00c36569fb8507de17ff9c89baa9
Fixes: 33334e25769c ("lib/stackdepot.c: allow the stack trace hash to be zero")
Link: http://lkml.kernel.org/r/1462252403-1106-1-git-send-email-iamjoonsoo.kim@lge.com
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 7c31190bcfdbff225950902a9f226e4eb79ca94f
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
2017-07-07 15:39:31 +05:30
Alexander Potapenko
81401ebc90 lib/stackdepot.c: allow the stack trace hash to be zero
Do not bail out from depot_save_stack() if the stack trace has zero hash.
Initially depot_save_stack() silently dropped stack traces with zero
hashes, however there's actually no point in reserving this zero value.

Change-Id: Ie289b59e70633657cafbb794fd05fbe5725ead28
Reported-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Alexander Potapenko <glider@google.com>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 33334e25769c6ad69b983379578f42581d99a2f9
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
2017-07-07 15:39:30 +05:30
Samyukta Mogily
47bfda4635 msm: sensor: Fix to validate the settings size in flash
The size of the settings copied from userspace, is directly checked
in msm_cci_data_queue with CCI_I2C_MAX_WRITE. This might cause
out of bound access in function msm_cci_data_queue as the max size is
MAX_I2C_REG_SET. Hence adding check on the size in flash driver itself.

Change-Id: Ifac358be9f4b4ff60d14c20e02886c2d044e7f52
Signed-off-by: Samyukta Mogily <smogily@codeaurora.org>
2017-07-07 15:39:15 +05:30