Commit Graph

1055919 Commits

Author SHA1 Message Date
Maulik Shah c1993b4cbc ANDROID: Update symbols list and ABI for qcom
Whitelist pm_suspend_target_state and pm_suspend_global_flags.
Update ABI representation accordingly.

Leaf changes summary: 1 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added
function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added
variable

1 Added variable:

  [A] 'suspend_state_t pm_suspend_target_state'

Bug: 234543638
Change-Id: I597a230326572c68fbf60370f39e29f551cf15a7
Signed-off-by: Maulik Shah <quic_mkshah@quicinc.com>
2022-06-06 14:15:27 +00:00
James_Lin 03b512f716 UPSTREAM: media: uvcvideo: Add UVC_GUID_FORMAT_H265
This patch aims to add UVC_GUID_FORMAT_H265
High Efficiency Video Coding (HEVC), also known as H.265 and MPEG-H Part 2.
They describe the same video encoding method.
So for handling their behavior is the same.
However, when external camera device describes this encoding method,
some use hevc, some use h265.
There is no uniform specification to describe this encoding method.
So if an external camera device use h265 to describe this encoding method,
driver will not recognize it.
Therefore, this patch is to enable driver to read HEVC/H265
and convert it to V4L2_PIX_FMT_HEVC.

Signed-off-by: James_Lin <Ping-lei.Lin@mediatek.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

Bug: 235045181
(cherry picked from commit be938c70e292731f81226917fc214683e66da577)
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
Change-Id: Ib9a78c2aa900abdd37b08351d56a3815b55ec7f4
2022-06-06 10:15:13 +00:00
Liujie Xie d1b6bd094b ANDROID: vendor_hooks: Add hook in shrink_node_memcgs
Add vendor hook in shrink_node_memcgs to adjust whether
to skip memory reclamation of memcg.

Bug: 226482420
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: I925856353e63c5a821027de4f8476c833e21b982
2022-06-03 19:57:21 +00:00
Wesley Cheng 120823bf95 UPSTREAM: usb: dwc3: gadget: Change to dev_dbg() when queuing to inactive gadget/ep
Since function drivers will still be active until dwc3_disconnect_gadget()
is called, some applications will continue to queue packets to DWC3
gadget.  This can lead to a flood of messages regarding failed ep queue,
as the endpoint is in the process of being disabled.  Change the log
level to debug, so that it can be enabled when debugging issues.

Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Link: https://lore.kernel.org/r/20211018192647.32121-1-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry picked from commit b851f7c7b8fd5365e447bb60e1e18eb6de628507)
Bug: 203763122
Change-Id: I5120890fa12f707ae54da551db9aab02dded0063
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
2022-06-03 16:21:56 +00:00
Yunxian He 7bfb6542ae ANDROID: Add several symbol lists for unisoc
Leaf changes summary: 6 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 6 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

6 Added functions:

  [A] 'function int phy_pm_runtime_get_sync(phy*)'
  [A] 'function int phy_pm_runtime_put_sync(phy*)'
  [A] 'function int usb_add_gadget(usb_gadget*)'
  [A] 'function void usb_del_gadget(usb_gadget*)'
  [A] 'function usb_ssp_rate usb_get_maximum_ssp_rate(device*)'
  [A] 'function void usb_initialize_gadget(device*, usb_gadget*, void (device*)*)'

Bug: 234533625
Change-Id: Ide5cdd80eb8aae4f80dd3f2e3560416082eec174
Signed-off-by: Yunxian He <yunxian.he@unisoc.com>
2022-06-03 14:01:13 +00:00
Bart Van Assche 78d6de7863 ANDROID: Fix the CONFIG_ANDROID_VENDOR_OEM_DATA=n build
Scripts like
https://github.com/bvanassche/build-scsi-drivers/blob/main/build-scsi-drivers
do not set CONFIG_ANDROID_VENDOR_OEM_DATA. Hence this patch that
unbreaks the CONFIG_ANDROID_VENDOR_OEM_DATA=n build.

Fixes: 291dfda577 ("ANDROID: init_task: Init android vendor and oem data")
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: Ic8223e69495fce7e2d0531313856ea5ed21659b7
2022-06-02 16:42:57 -07:00
Venkata Rao Kakani 45a91f3011 ANDROID: abi_gki_aarch64_qcom: Add kobject_get
Add kobject_get to android/abi_gki_aarch64_qcom required by QCOM driver
to create fille in /sys/kernel directory.

Bug: 234545455
Change-Id: I5bd314ee93087c2db9b1c21000506f93d66aadf0
Signed-off-by: Venkata Rao Kakani <quic_vkakani@quicinc.com>
2022-06-02 15:51:11 -07:00
Todd Kjos 842137671f Revert "ANDROID: GKI: Add ANDROID_OEM_DATA in struct request_queue"
This reverts commit f4e36db507.

Breaks KMI, should not have merged

Change-Id: I30a885047459a39c487e8a070ea160b26d03e2fb
2022-06-02 14:50:57 -07:00
Todd Kjos 443c11e0b1 Revert "ANDROID: GKI: Add ANDROID_OEM_DATA in struct blk_mq_ctx"
This reverts commit 7f6e518e43.

Breaks KMI, should not have merged

Change-Id: I23d7a9d9d9506a98c916c22a6e3b9fbe38b914c7
2022-06-02 14:50:51 -07:00
Todd Kjos b982f17e13 Revert "ANDROID: GKI: Add ANDROID_OEM_DATA in struct blk_mq_tags"
This reverts commit 9123d4dfe5.

Breaks KMI, should not have merged

Change-Id: I957881d95f583e02563e93934be3e74cbf2c87a9
2022-06-02 14:50:46 -07:00
Todd Kjos 3062974bf9 Revert "ANDROID: GKI: enable CONFIG_BLK_CGROUP_IOCOST"
This reverts commit aa0e7ec774.

Breaks KMI, should not have been merged

Change-Id: I2ac15184b9a4819131a247a3cabe9d819f3ff1fa
2022-06-02 14:50:37 -07:00
Georgi Djakov f0b29dd9e3 ANDROID: lib: Export show_mem() for vendor module usage
There are debugging modules that monitor the memory usage of tasks
and report memory parameters in some situations (such as OOM).

Bug: 189595202
Bug: 234407991
Change-Id: I6cc405b0f4cbe1706857fc3b2f8da83ea981818d
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
2022-06-02 14:37:19 -07:00
Liujie Xie 50e4cd9df7 ANDROID: vendor_hooks: Add hooks for memory when debug
Add vendors hooks for recording memory used

Bug: 182443489
Bug: 234407991
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: I62d8bb2b6650d8b187b433f97eb833ef0b784df1
2022-06-02 14:37:19 -07:00
Jiewen Wang 5a70133feb ANDROID: vendor_hooks: Add hook in try_to_unmap_one()
Add hook in try_to_unmap_one() to trace this function for debug memory
swap bugs.

Bug: 198385827
Change-Id: I1fdbe60e09bb491b949e06a07133710453ecca03
Signed-off-by: Jiewen Wang <jiewen.wang@vivo.com>
(cherry picked from commit 955f917251d8ff9c04cf0404e35bf6be5e3666c5)
2022-06-02 20:45:07 +00:00
Jiewen Wang 73c9d4a9d5 ANDROID: vendor_hooks: Add hook in mmap_region()
Add hook in mmap_region() to record the vma and address information
of monitored processes.

Bug: 198385827
Change-Id: I0bde29113b47ca7f4a9f5d42a54188e791ca3b7e
Signed-off-by: Jiewen Wang <jiewen.wang@vivo.com>
(cherry picked from commit 878e0caa773151b8a9445f24d3e059d0ece5566d)
2022-06-02 20:45:01 +00:00
Sami Tolvanen caaafb7005 FROMGIT: cfi: Fix __cfi_slowpath_diag RCU usage with cpuidle
RCU_NONIDLE usage during __cfi_slowpath_diag can result in an invalid
RCU state in the cpuidle code path:

  WARNING: CPU: 1 PID: 0 at kernel/rcu/tree.c:613 rcu_eqs_enter+0xe4/0x138
  ...
  Call trace:
    rcu_eqs_enter+0xe4/0x138
    rcu_idle_enter+0xa8/0x100
    cpuidle_enter_state+0x154/0x3a8
    cpuidle_enter+0x3c/0x58
    do_idle.llvm.6590768638138871020+0x1f4/0x2ec
    cpu_startup_entry+0x28/0x2c
    secondary_start_kernel+0x1b8/0x220
    __secondary_switched+0x94/0x98

Instead, call rcu_irq_enter/exit to wake up RCU only when needed and
disable interrupts for the entire CFI shadow/module check when we do.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Link: https://lore.kernel.org/r/20220531175910.890307-1-samitolvanen@google.com
Fixes: cf68fffb66 ("add support for Clang CFI")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
(cherry picked from commit e1d3373352077f3be9cc1c8adb5fd59d0aa96e7a
https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
for-next/hardening)

Bug: 230582614
Bug: 231734842
Bug: 233021097
Change-Id: I78cc7ece46e3d8fc6699bcd7a0d8d6074b6a05fe
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2022-06-02 20:21:48 +00:00
Patrick Daly 49ad57e915 ANDROID: mm/memory_hotplug: Don't special case memory_block_size_bytes
If add_memory_subsection() is called with a size of
memory_block_size_bytes, it calls into add_memory(), which declares
the region as system ram, and adds it to the buddy allocator. This
is inconsistent with the behavior of add_memory_subsection() for
other sizes, for which it does not add the memory to buddy and
instead reserves it for the caller's private use.

Bug: 210008865
Fixes: 417ac617ea5e ("ANDROID: mm/memory_hotplug: implement {add/remove}_memory_subsection")
Change-Id: Iefb69b0b4e96af670d0e65c325a9538d14b460e3
Signed-off-by: Patrick Daly <quic_pdaly@quicinc.com>
2022-06-02 19:38:29 +00:00
Sachin Gupta 6b6c4a7373 ANDROID: abi_gki_aarch64_qcom: Add android_vh_ufs_clock_scaling
Add android_vh_ufs_clock_scaling symbol so that vendor module can
use to influence UFS clock scaling policy.

Leaf changes summary: 2 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added
function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added
variable

1 Added function:

  [A] 'function int __traceiter_android_vh_ufs_clock_scaling(void*,
ufs_hba*, bool*, bool*, bool*)'

1 Added variable:

  [A] 'tracepoint __tracepoint_android_vh_ufs_clock_scaling'

Bug: 234112523
Change-Id: I78bacfa36f6a54f83db99d4c565c317abecde034
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Signed-off-by: Sachin Gupta <quic_sachgupt@quicinc.com>
2022-06-02 18:55:42 +00:00
Sachin Gupta 3ff9481aad ANDROID: scsi: ufs: Add hook to influence the UFS clock scaling policy
Add a vendor hook in ufshcd_devfreq_target() to allow vendor modules to
influence the UFS clock scaling policy.

Bug: 234112523

Change-Id: I64b9b77661fffc6cc96fa610985483e6cfc6542b
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Signed-off-by: Sachin Gupta <quic_sachgupt@quicinc.com>
2022-06-02 18:55:36 +00:00
Ian Chen 442d3a107b ANDROID: Update symbol list for mtk
1. Generated with:
  BUILD_CONFIG=common/build.config.gki.aarch64 build/build_abi.sh --update

Leaf changes summary: 1 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

1 Added function:

  [A] 'function long long unsigned int task_sched_runtime(task_struct*)'

Bug: 233862809
Signed-off-by: Ian-Y Chen <ian-y.chen@mediatek.com>
Change-Id: I711c36e26eed20560a48802bca3b665cf3092f45
2022-06-02 18:40:21 +00:00
Poting Chen f85e3d9101 ANDROID: scheduler: export task_sched_runtime
For power and performance monitoring, need to known tasks' runtime for
loading estimation.

But now, other modules can't get task_scehd_runtime.

Export task_sched_runtime to let other modules get task_scehd_runtime.

Bug: 233862809
Signed-off-by: Poting Chen <poting.chen@mediatek.com>
Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
Change-Id: Ida5caf8ed0a32954fc0b0ed950f163c7ca493fef
(cherry picked from commit fdc8f778e23dfb41b58f87edccf419eb53627ea3)
2022-06-02 18:40:14 +00:00
Yang Yang aa0e7ec774 ANDROID: GKI: enable CONFIG_BLK_CGROUP_IOCOST
Enable CONFIG_BLK_CGROUP_IOCOST to help control IO resources.

Bug: 188749221
Bug: 233781098

Change-Id: I611b3ff5929d0a998fa6241967887803636b7588
Signed-off-by: Yang Yang <yang.yang@vivo.com>
(cherry picked from commit 19316b4889f88088e9ffc94817d36be5639ca348)
2022-06-02 18:17:00 +00:00
Yang Yang 9123d4dfe5 ANDROID: GKI: Add ANDROID_OEM_DATA in struct blk_mq_tags
Add ANDROID_OEM_DATA for implement of oem gki

Bug: 188749221
Bug: 233781098

Change-Id: I1feba2334aa34e3bc46eb9d0217118485405beb4
Signed-off-by: Yang Yang <yang.yang@vivo.com>
(cherry picked from commit 1f23e139ad237c5172716f351e846a3e4b955388)
2022-06-02 18:16:49 +00:00
Yang Yang 7f6e518e43 ANDROID: GKI: Add ANDROID_OEM_DATA in struct blk_mq_ctx
Add ANDROID_OEM_DATA for implement of oem gki

Bug: 188749221
Bug: 233781098

Change-Id: Ide8378a898de01a34d8ca3c34472844cd4ffa71c
Signed-off-by: Yang Yang <yang.yang@vivo.com>
(cherry picked from commit 5b388812e812b0824216a1b4e254fb1195665e22)
2022-06-02 18:16:42 +00:00
Yang Yang f4e36db507 ANDROID: GKI: Add ANDROID_OEM_DATA in struct request_queue
Add ANDROID_OEM_DATA for implement of oem gki

Bug: 188749221
Bug: 233781098

Change-Id: I96b1c690fda172d0c490e944557a674a37620742
Signed-off-by: Yang Yang <yang.yang@vivo.com>
(cherry picked from commit 3a0675c6ca5365dfd42098820815a2ca865b2b4f)
2022-06-02 18:16:34 +00:00
Lecopzer Chen 7e54032750 ANDROID: Update mtktv symbol list
no new symbol in GKI, so simply sync the using list

Bug: 234577947
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
Change-Id: I46cdccaddf2881f3e640ba71f30084191bb82f86
2022-06-02 17:29:45 +00:00
Gokul krishna Krishnakumar c6b53b7aac ANDROID: abi_gki_aarch64_qcom: Update qcom abi symbol list
Functions changes summary: 0 Removed, 0 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

Bug: 231322691
Change-Id: I02f808e003e28503cd06c51b44b6dab219ca151e
Signed-off-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
2022-06-02 17:18:30 +00:00
Vignesh Saravanaperumal 3c55aa6ffe ANDROID: GKI: add vendor padding variable in struct skb_shared_info
Some vendors want to add things to 'struct skb_shared_info', so give
them an array to place their data.

Bug: 171013716
Signed-off-by: Vignesh Saravanaperumal <vignesh1.s@samsung.com>
Change-Id: Ia0024e3e8de89f4ef335fa26208ec6c45abafb22
2022-06-02 15:57:34 +00:00
Venkata Rao Kakani f45d12df24 ANDROID: GKI: Enable DM_INIT
Enable DM_INIT to support dm-mod.create kernel commandline
parameter.

Bug: 233690306
Change-Id: Ibdc75cd7740040f52b8742d36e431e0db849290b
Signed-off-by: Venkata Rao Kakani <quic_vkakani@quicinc.com>
2022-06-02 15:56:21 +00:00
Manaf Meethalavalappu Pallikunhi 149474c544 FROMLIST: power_supply: Use of-thermal cdev registration API
With thermal frameworks of-thermal interface, thermal zone parameters can
be defined in devicetree. This includes cooling device mitigation levels
for a thermal zone. To take advantage of this, cooling device should use
the thermal_of_cooling_device_register API to register a cooling device.

Use thermal_of_cooling_device_register API to register the power supply
cooling device. This enables power supply cooling device be included in the
thermal zone parameter in devicetree.

Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>

Bug: 211709650
Link: https://lore.kernel.org/linux-pm/1640162489-7847-2-git-send-email-quic_manafm@quicinc.com/
Change-Id: Ie0d527543adb8590ec52df96bf3e4d0f1f022d0a
Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
(cherry picked from commit 2a2327c4e8ac335069586354b280031105b9980e)
2022-06-02 15:55:21 +00:00
Maria Yu 291dfda577 ANDROID: init_task: Init android vendor and oem data
Without initialization, it will be random data and hard for
vendor hook to decide.

Bug: 207739506
Change-Id: I278772d87eea38c03a40d4f0bef20ac8644e2ecd
Signed-off-by: Maria Yu <quic_aiquny@quicinc.com>
(cherry picked from commit 898e7ec950c168e37ce8c27f6ca1d2cdea66b078)
2022-06-02 15:24:50 +00:00
Patrick Daly afd403d142 ANDROID: qcom: Add flush_delayed_fput to ABI
When a kernel thread calls dma_buf_put() to release the last reference
to a dma-buf, fput_many() defers calling the release callback to a
workqueue. This means that if the same kernel thread later calls
dma_heap_buffer_alloc(), it has no guarantee that the memory from the
prior free is available, leading to random failures. As a short-term
workaround, call flush_delayed_fput() to ensure the free completes
synchronously.

Leaf changes summary: 1 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

1 Added function:

  [A] 'function void flush_delayed_fput()'

Bug: 210598057
Change-Id: Id936aa0bcd410b23b12f4b922b676aa61a358b4c
Signed-off-by: Patrick Daly <quic_pdaly@quicinc.com>
2022-06-02 15:23:12 +00:00
tuhailong 6976d861b5 ANDROID: GKI: build damon reclaim
To enable it, echo 1 > /sys/module/damon_reclaim/parameters/enable

Bug: 228223814
Signed-off-by: tuhailong <tuhailong@oppo.com>
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Ibb0701b6dd83070c6fbc8c96fdac3bc839821377
2022-06-01 15:26:13 -07:00
Hailong Tu 11bc7e6f8e FROMLIST: mm/damon/reclaim: Fix the timer always stays active
The timer stays active even if the reclaim mechanism is never enabled.
It is unnecessary overhead can be completely avoided by using module_param_cb() for enabled flag.

Link: https://lore.kernel.org/all/20220421125910.1052459-1-tuhailong@gmail.com/

Bug: 228223814
Signed-off-by: Hailong Tu <tuhailong@oppo.com>
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: I77591e41ce424ce16a4a5c70e7a86cdae996a354
2022-06-01 15:26:12 -07:00
Jakub Kicinski 71da156123 BACKPORT: treewide: Add missing includes masked by cgroup -> bpf dependency
cgroup.h (therefore swap.h, therefore half of the universe)
includes bpf.h which in turn includes module.h and slab.h.
Since we're about to get rid of that dependency we need
to clean things up.

v2: drop the cpu.h include from cacheinfo.h, it's not necessary
and it makes riscv sensitive to ordering of include files.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Krzysztof Wilczyński <kw@linux.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Acked-by: SeongJae Park <sj@kernel.org>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/all/20211120035253.72074-1-kuba@kernel.org/  # v1
Link: https://lore.kernel.org/all/20211120165528.197359-1-kuba@kernel.org/ # cacheinfo discussion
Link: https://lore.kernel.org/bpf/20211202203400.1208663-1-kuba@kernel.org

(cherry picked from commit 8581fd402a0cf80b5298e3b225e7a7bd8f110e69)

Dropped all the changes except for the ones made in mm/damon/vaddr.c

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Ib64ecbe4e06f192ed576af77e03e6b49d538bac9
2022-06-01 15:26:12 -07:00
Xin Hao caffd17b02 UPSTREAM: mm/damon: modify damon_rand() macro to static inline function
damon_rand() cannot be implemented as a macro.

Example:
	damon_rand(a++, b);

The value of 'a' will be incremented twice, This is obviously
unreasonable, So there fix it.

Link: https://lkml.kernel.org/r/110ffcd4e420c86c42b41ce2bc9f0fe6a4f32cd3.1638795127.git.xhao@linux.alibaba.com
Fixes: b9a6ac4e4e ("mm/damon: adaptively adjust regions")
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
Reported-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 234d68732b6c135087bdebfa0630a43ae8c27758)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Idcc316e6f582959254111fb160d04875d235c306
2022-06-01 15:26:12 -07:00
Xin Hao 802a5dc657 UPSTREAM: mm/damon: add 'age' of region tracepoint support
In Damon, we can get age information by analyzing the nr_access change,
But short time sampling is not effective, we have to obtain enough data
for analysis through long time trace, this also means that we need to
consume more cpu resources and storage space.

Now the region add a new 'age' variable, we only need to get the change of
age value through a little time trace, for example, age has been
increasing to 141, but nr_access shows a value of 0 at the same time,
Through this,we can conclude that the region has a very low nr_access
value for a long time.

Link: https://lkml.kernel.org/r/b9def1262af95e0dc1d0caea447886434db01161.1636989871.git.xhao@linux.alibaba.com
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit c46b0bb6a735db0b6140e12e750b5acb1b032982)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: I39aeea71756f5af6f270efe9d5653815c905af46
2022-06-01 15:26:12 -07:00
SeongJae Park 7019f96d3f UPSTREAM: mm/damon: hide kernel pointer from tracepoint event
DAMON's virtual address spaces monitoring primitive uses 'struct pid *'
of the target process as its monitoring target id.  The kernel address
is exposed as-is to the user space via the DAMON tracepoint,
'damon_aggregated'.

Though primarily only privileged users are allowed to access that, it
would be better to avoid unnecessarily exposing kernel pointers so.
Because the trace result is only required to be able to distinguish each
target, we aren't need to use the pointer as-is.

This makes the tracepoint to use the index of the target in the
context's targets list as its id in the tracepoint, to hide the kernel
space address.

Link: https://lkml.kernel.org/r/20211229131016.23641-5-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 76fd0285b447991267e838842c0be7395eb454bb)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Iee4a6f56cf9bf5f61fb95f438dfc3316c10198e5
2022-06-01 15:26:12 -07:00
SeongJae Park c5bf6f61a3 UPSTREAM: mm/damon/vaddr: hide kernel pointer from damon_va_three_regions() failure log
The failure log message for 'damon_va_three_regions()' prints the target
id, which is a 'struct pid' pointer in the case.  To avoid exposing the
kernel pointer via the log, this makes the log to use the index of the
target in the context's targets list instead.

Link: https://lkml.kernel.org/r/20211229131016.23641-4-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 962fe7a6b1b2f9deb1b31b3344afa3b11afdf7ab)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: I6b9b09a9b7024630f05ec41db030006d63f47ce1
2022-06-01 15:26:12 -07:00
SeongJae Park d7cbb8dc2a UPSTREAM: mm/damon/vaddr: use pr_debug() for damon_va_three_regions() failure logging
Failure of 'damon_va_three_regions()' is logged using 'pr_err()'.  But,
the function can fail in legal situations.  To avoid making users be
surprised and to keep the kernel clean, this makes the log to be printed
using 'pr_debug()'.

Link: https://lkml.kernel.org/r/20211229131016.23641-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 251403f19aab6a122f4dcfb14149814e85564202)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: I0a2c08d856d0067af6af7a008e89f63fa5fac381
2022-06-01 15:26:11 -07:00
SeongJae Park 2d1227b126 UPSTREAM: mm/damon/dbgfs: remove an unnecessary variable
Patch series "mm/damon: Hide unnecessary information disclosures".

DAMON is exposing some unnecessary information including kernel pointer
in kernel log and tracepoint.  This patchset hides such information.
The first patch is only for a trivial cleanup, though.

This patch (of 4):

This commit removes a unnecessarily used variable in
dbgfs_target_ids_write().

Link: https://lkml.kernel.org/r/20211229131016.23641-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20211229131016.23641-2-sj@kernel.org
Fixes: 4bc05954d0 ("mm/damon: implement a debugfs-based user space interface")
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 70b8480812d0a3930049a44820a1fa149b090c10)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: I774c900de92780ae9ebf09f01c0b0536eb43f822
2022-06-01 15:26:11 -07:00
Guoqing Jiang 2861a7ee7f UPSTREAM: mm/damon: move the implementation of damon_insert_region to damon.h
Usually, inline function is declared static since it should sit between
storage and type.  And implement it in a header file if used by multiple
files.

And this change also fixes compile issue when backport damon to 5.10.

  mm/damon/vaddr.c: In function `damon_va_evenly_split_region':
  ./include/linux/damon.h:425:13: error: inlining failed in call to `always_inline' `damon_insert_region': function body not available
  425 | inline void damon_insert_region(struct damon_region *r,
      | ^~~~~~~~~~~~~~~~~~~
  mm/damon/vaddr.c:86:3: note: called from here
  86 | damon_insert_region(n, r, next, t);
     | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link: https://lkml.kernel.org/r/20211223085703.6142-1-guoqing.jiang@linux.dev
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 2cd4b8e10cc31eadb5b10b1d73b3f28156f3776c)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Iaa05318092b8e98bfbfc72a8c5df2cb6de97d224
2022-06-01 15:26:11 -07:00
Baolin Wang 508a322b77 UPSTREAM: mm/damon: add access checking for hugetlb pages
The process's VMAs can be mapped by hugetlb page, but now the DAMON did
not implement the access checking for hugetlb pte, so we can not get the
actual access count like below if a process VMAs were mapped by hugetlb.

  damon_aggregated: target_id=18446614368406014464 nr_regions=12 4194304-5476352: 0 545
  damon_aggregated: target_id=18446614368406014464 nr_regions=12 140662370467840-140662372970496: 0 545
  damon_aggregated: target_id=18446614368406014464 nr_regions=12 140662372970496-140662375460864: 0 545
  damon_aggregated: target_id=18446614368406014464 nr_regions=12 140662375460864-140662377951232: 0 545
  damon_aggregated: target_id=18446614368406014464 nr_regions=12 140662377951232-140662380449792: 0 545
  damon_aggregated: target_id=18446614368406014464 nr_regions=12 140662380449792-140662382944256: 0 545
  ......

Thus this patch adds hugetlb access checking support, with this patch we
can see below VMA mapped by hugetlb access count.

  damon_aggregated: target_id=18446613056935405824 nr_regions=12 140296486649856-140296489914368: 1 3
  damon_aggregated: target_id=18446613056935405824 nr_regions=12 140296489914368-140296492978176: 1 3
  damon_aggregated: target_id=18446613056935405824 nr_regions=12 140296492978176-140296495439872: 1 3
  damon_aggregated: target_id=18446613056935405824 nr_regions=12 140296495439872-140296498311168: 1 3
  damon_aggregated: target_id=18446613056935405824 nr_regions=12 140296498311168-140296501198848: 1 3
  damon_aggregated: target_id=18446613056935405824 nr_regions=12 140296501198848-140296504320000: 1 3
  damon_aggregated: target_id=18446613056935405824 nr_regions=12 140296504320000-140296507568128: 1 2
  ......

[baolin.wang@linux.alibaba.com: fix unused var warning]
  Link: https://lkml.kernel.org/r/1aaf9c11-0d8e-b92d-5c92-46e50a6e8d4e@linux.alibaba.com
[baolin.wang@linux.alibaba.com: v3]
  Link: https://lkml.kernel.org/r/486927ecaaaecf2e3a7fbe0378ec6e1c58b50747.1640852276.git.baolin.wang@linux.alibaba.com

Link: https://lkml.kernel.org/r/6afcbd1fda5f9c7c24f320d26a98188c727ceec3.1639623751.git.baolin.wang@linux.alibaba.com
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 49f4203aae06ba9d67b500c90339b262b0a52637)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Id7c86f5c0344efef150b3b27f662b696263947ed
2022-06-01 15:26:11 -07:00
SeongJae Park 6fdce9a014 UPSTREAM: mm/damon/dbgfs: support all DAMOS stats
Currently, DAMON debugfs interface is not supporting DAMON-based
Operation Schemes (DAMOS) stats for schemes successfully applied regions
and time/space quota limit exceeds.  This adds the support.

Link: https://lkml.kernel.org/r/20211210150016.35349-6-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 3a619fdb8de8a3ecd4200e7d183d2c8ceb32289e)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Ide3cfaff1b63e053ece5a8746a463fb87ef6c607
2022-06-01 15:26:11 -07:00
SeongJae Park 86a0f3958c UPSTREAM: mm/damon/reclaim: provide reclamation statistics
This implements new DAMON_RECLAIM parameters for statistics reporting.
Those can be used for understanding how DAMON_RECLAIM is working, and
for tuning the other parameters.

Link: https://lkml.kernel.org/r/20211210150016.35349-4-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 60e52e7c46a127bca5ddd48b89002564f3862063)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: I721bdacb3b2d8b41154296f5dbf8ef48c5dd0744
2022-06-01 15:26:11 -07:00
SeongJae Park 168c5dc29f UPSTREAM: mm/damon/schemes: account how many times quota limit has exceeded
If the time/space quotas of a given DAMON-based operation scheme is too
small, the scheme could show unexpectedly slow progress.  However, there
is no good way to notice the case in runtime.  This commit extends the
DAMOS stat to provide how many times the quota limits exceeded so that
the users can easily notice the case and tune the scheme.

Link: https://lkml.kernel.org/r/20211210150016.35349-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 6268eac34ca30af7f6313504d556ec7fcd295621)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: I36184dc51917810c81ac8d576b144e33a4454dc1
2022-06-01 15:26:10 -07:00
SeongJae Park 9818aed77f UPSTREAM: mm/damon/schemes: account scheme actions that successfully applied
Patch series "mm/damon/schemes: Extend stats for better online analysis and tuning".

To help online access pattern analysis and tuning of DAMON-based
Operation Schemes (DAMOS), DAMOS provides simple statistics for each
scheme.  Introduction of DAMOS time/space quota further made the tuning
easier by making the risk management easier.  However, that also made
understanding of the working schemes a little bit more difficult.

For an example, progress of a given scheme can now be throttled by not
only the aggressiveness of the target access pattern, but also the
time/space quotas.  So, when a scheme is showing unexpectedly slow
progress, it's difficult to know by what the progress of the scheme is
throttled, with currently provided statistics.

This patchset extends the statistics to contain some metrics that can be
helpful for such online schemes analysis and tuning (patches 1-2),
exports those to users (patches 3 and 5), and add documents (patches 4
and 6).

This patch (of 6):

DAMON-based operation schemes (DAMOS) stats provide only the number and
the amount of regions that the action of the scheme has tried to be
applied.  Because the action could be failed for some reasons, the
currently provided information is sometimes not useful or convenient
enough for schemes profiling and tuning.  To improve this situation,
this commit extends the DAMOS stats to provide the number and the amount
of regions that the action has successfully applied.

Link: https://lkml.kernel.org/r/20211210150016.35349-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20211210150016.35349-2-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 0e92c2ee9f459542c5384d9cfab24873c3dd6398)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Iddfe9257cb99091404202576a1addc5cc340cb8b
2022-06-01 15:26:10 -07:00
SeongJae Park 82b9795ec7 UPSTREAM: mm/damon: convert macro functions to static inline functions
Patch series "mm/damon: Misc cleanups".

This patchset contains miscellaneous cleanups for DAMON's macro
functions and documentation.

This patch (of 6):

This commit converts macro functions in DAMON to static inline functions,
for better type checking, code documentation, etc[1].

[1] https://lore.kernel.org/linux-mm/20211202151213.6ec830863342220da4141bc5@linux-foundation.org/

Link: https://lkml.kernel.org/r/20211209131806.19317-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20211209131806.19317-2-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 88f86dcfa454784f7de550966c60fc78a3e95d6d)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Id1e4e08a844b49cf3572cb3ac02158f5c1909ea2
2022-06-01 15:26:10 -07:00
Xin Hao f92ba978fa UPSTREAM: mm/damon: move damon_rand() definition into damon.h
damon_rand() is called in three files:damon/core.c, damon/ paddr.c,
damon/vaddr.c, i think there is no need to redefine this twice, So move
it to damon.h will be a good choice.

Link: https://lkml.kernel.org/r/20211202075859.51341-1-xhao@linux.alibaba.com
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 9b2a38d6ef25c1748e3964b0ff30a89e4ed26583)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: Ib7be3062385fac4b422faa86705968aa39095a72
2022-06-01 15:26:10 -07:00
Xin Hao 6e04c85054 UPSTREAM: mm/damon/schemes: add the validity judgment of thresholds
In dbgfs "schemes" interface, i do some test like this:
    # cd /sys/kernel/debug/damon
    # echo "2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3" > schemes
    # cat schemes
    # 2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3 0 0

There have some unreasonable places, i set the valules of these variables
"<min_sz, max_sz> <min_nr_a, max_nr_a>, <min_age, max_age>, <wmarks.high,
wmarks.mid, wmarks.low>" as "<2, 1>, <2, 1>, <10, 1>, <1, 2, 3>.

So there add a validity judgment for these thresholds value.

Link: https://lkml.kernel.org/r/d78360e52158d786fcbf20bc62c96785742e76d3.1637239568.git.xhao@linux.alibaba.com
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit c89ae63eb0662b6c9f82dbfad3ef010239b8c1b1)

Bug: 228223814
Signed-off-by: zhijun wan <wanzhijun@oppo.com>
Change-Id: I2b23124b95ebeac935f28f9632dccaeabace4533
2022-06-01 15:26:10 -07:00