Commit Graph

1149366 Commits

Author SHA1 Message Date
Treehugger Robot
33ab98b39d Merge "Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-6.1.y' into android14-6.1" into android14-6.1 2023-05-05 17:01:10 +00:00
Junki Min
d1e1986638 ANDROID: ABI: Update DRM symbol for Exynos SoC
Update symbols for Exynos DRM

78 function symbol(s) added
  'struct dma_buf_attachment* dma_buf_dynamic_attach(struct dma_buf*, struct device*, const struct dma_buf_attach_ops*, void*)'
  'void dma_buf_move_notify(struct dma_buf*)'
  'int dma_buf_pin(struct dma_buf_attachment*)'
  'void dma_buf_unpin(struct dma_buf_attachment*)'
  'struct dma_fence* dma_fence_chain_walk(struct dma_fence*)'
  'struct dma_fence* dma_fence_get_stub()'
  'long dma_fence_wait_any_timeout(struct dma_fence**, uint32_t, bool, long, uint32_t*)'
  'int dma_resv_get_fences(struct dma_resv*, enum dma_resv_usage, unsigned int*, struct dma_fence***)'
  'void drm_connector_attach_dp_subconnector_property(struct drm_connector*)'
  'int drm_crtc_helper_set_config(struct drm_mode_set*, struct drm_modeset_acquire_ctx*)'
  'bool drm_crtc_helper_set_mode(struct drm_crtc*, struct drm_display_mode*, int, int, struct drm_framebuffer*)'
  'int drm_crtc_init(struct drm_device*, struct drm_crtc*, const struct drm_crtc_funcs*)'
  'int drm_edid_header_is_valid(const void*)'
  'struct dma_buf* drm_gem_prime_export(struct drm_gem_object*, int)'
  'int drm_helper_connector_dpms(struct drm_connector*, int)'
  'void drm_helper_disable_unused_functions(struct drm_device*)'
  'int drm_helper_force_disable_all(struct drm_device*)'
  'bool drm_kms_helper_is_poll_worker()'
  'int drm_mode_create_scaling_mode_property(struct drm_device*)'
  'int drm_prime_sg_to_dma_addr_array(struct sg_table*, dma_addr_t*, int)'
  'int drm_syncobj_create(struct drm_syncobj**, uint32_t, struct dma_fence*)'
  'int drm_syncobj_get_fd(struct drm_syncobj*, int*)'
  'int drm_syncobj_get_handle(struct drm_file*, struct drm_syncobj*, u32*)'
  'int i2c_bit_add_bus(struct i2c_adapter*)'
  'int mmu_interval_notifier_insert(struct mmu_interval_notifier*, struct mm_struct*, unsigned long, unsigned long, const struct mmu_interval_notifier_ops*)'
  'void mmu_interval_notifier_remove(struct mmu_interval_notifier*)'
  'unsigned long mmu_interval_read_begin(struct mmu_interval_notifier*)'
  'void mmu_notifier_synchronize()'
  'void pci_assign_unassigned_bus_resources(struct pci_bus*)'
  'struct resource* pci_bus_resource_n(const struct pci_bus*, int)'
  'int pci_enable_atomic_ops_to_root(struct pci_dev*, u32)'
  'void* pci_map_rom(struct pci_dev*, size_t*)'
  'int pci_msix_vec_count(struct pci_dev*)'
  'void pci_release_resource(struct pci_dev*, int)'
  'int pci_resize_resource(struct pci_dev*, int, int)'
  'void pci_unmap_rom(struct pci_dev*, void*)'
  'u32 pcie_bandwidth_available(struct pci_dev*, struct pci_dev**, enum pci_bus_speed*, enum pcie_link_width*)'
  'enum pci_bus_speed pcie_get_speed_cap(struct pci_dev*)'
  'bool ttm_bo_eviction_valuable(struct ttm_buffer_object*, const struct ttm_place*)'
  'int ttm_bo_init_reserved(struct ttm_device*, struct ttm_buffer_object*, enum ttm_bo_type, struct ttm_placement*, uint32_t, struct ttm_operation_ctx*, struct sg_table*, struct dma_resv*, void(*)(struct ttm_buffer_object*))'
  'int ttm_bo_kmap(struct ttm_buffer_object*, unsigned long, unsigned long, struct ttm_bo_kmap_obj*)'
  'void ttm_bo_kunmap(struct ttm_bo_kmap_obj*)'
  'int ttm_bo_lock_delayed_workqueue(struct ttm_device*)'
  'int ttm_bo_mem_space(struct ttm_buffer_object*, struct ttm_placement*, struct ttm_resource**, struct ttm_operation_ctx*)'
  'int ttm_bo_mmap_obj(struct vm_area_struct*, struct ttm_buffer_object*)'
  'int ttm_bo_move_accel_cleanup(struct ttm_buffer_object*, struct dma_fence*, bool, bool, struct ttm_resource*)'
  'int ttm_bo_move_memcpy(struct ttm_buffer_object*, struct ttm_operation_ctx*, struct ttm_resource*)'
  'void ttm_bo_move_to_lru_tail(struct ttm_buffer_object*)'
  'void ttm_bo_pin(struct ttm_buffer_object*)'
  'void ttm_bo_put(struct ttm_buffer_object*)'
  'void ttm_bo_set_bulk_move(struct ttm_buffer_object*, struct ttm_lru_bulk_move*)'
  'void ttm_bo_unlock_delayed_workqueue(struct ttm_device*, int)'
  'void ttm_bo_unpin(struct ttm_buffer_object*)'
  'int ttm_bo_validate(struct ttm_buffer_object*, struct ttm_placement*, struct ttm_operation_ctx*)'
  'int ttm_bo_vm_access(struct vm_area_struct*, unsigned long, void*, int, int)'
  'void ttm_bo_vm_close(struct vm_area_struct*)'
  'vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault*, pgprot_t)'
  'vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault*, pgprot_t, unsigned long)'
  'void ttm_bo_vm_open(struct vm_area_struct*)'
  'vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object*, struct vm_fault*)'
  'void ttm_device_fini(struct ttm_device*)'
  'int ttm_device_init(struct ttm_device*, struct ttm_device_funcs*, struct device*, struct address_space*, struct drm_vma_offset_manager*, bool, bool)'
  'void ttm_eu_backoff_reservation(struct ww_acquire_ctx*, struct list_head*)'
  'int ttm_eu_reserve_buffers(struct ww_acquire_ctx*, struct list_head*, bool, struct list_head*)'
  'void ttm_lru_bulk_move_tail(struct ttm_lru_bulk_move*)'
  'int ttm_pool_alloc(struct ttm_pool*, struct ttm_tt*, struct ttm_operation_ctx*)'
  'int ttm_pool_debugfs(struct ttm_pool*, struct seq_file*)'
  'void ttm_pool_free(struct ttm_pool*, struct ttm_tt*)'
  'int ttm_range_man_fini_nocheck(struct ttm_device*, unsigned int)'
  'int ttm_range_man_init_nocheck(struct ttm_device*, unsigned int, bool, unsigned long)'
  'void ttm_resource_fini(struct ttm_resource_manager*, struct ttm_resource*)'
  'void ttm_resource_free(struct ttm_buffer_object*, struct ttm_resource**)'
  'void ttm_resource_init(struct ttm_buffer_object*, const struct ttm_place*, struct ttm_resource*)'
  'int ttm_resource_manager_evict_all(struct ttm_device*, struct ttm_resource_manager*)'
  'void ttm_resource_manager_init(struct ttm_resource_manager*, struct ttm_device*, uint64_t)'
  'uint64_t ttm_resource_manager_usage(struct ttm_resource_manager*)'
  'int ttm_sg_tt_init(struct ttm_tt*, struct ttm_buffer_object*, uint32_t, enum ttm_caching)'
  'void ttm_tt_fini(struct ttm_tt*)'

3 variable symbol(s) added
  'const struct dma_fence_ops dma_fence_chain_ops'
  'const struct kernel_param_ops param_ops_hexint'
  'struct ttm_global ttm_glob'

Bug: 280531400
Change-Id: Ie5dc1265b27d731af85014da897b35e4a3adeb26
Signed-off-by: Junki Min <joonki.min@samsung.com>
2023-05-05 08:01:51 +00:00
Jaegeuk Kim
a90747aabd Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-6.1.y' into android14-6.1
* aosp/upstream-f2fs-stable-linux-6.1.y:
  fscrypt: destroy keyring after security_sb_delete()
  fscrypt: optimize fscrypt_initialize()
  fscrypt: use WARN_ON_ONCE instead of WARN_ON
  fscrypt: new helper function - fscrypt_prepare_lookup_partial()
  fscrypt: check for NULL keyring in fscrypt_put_master_key_activeref()
  fscrypt: improve fscrypt_destroy_keyring() documentation

Bug: 273795759
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Change-Id: I32f5ac5bae203c62f8b1e00dd66c21046ab55014
2023-05-04 16:50:47 -07:00
Eric Biggers
ed1265d585 fscrypt: destroy keyring after security_sb_delete()
fscrypt_destroy_keyring() must be called after all potentially-encrypted
inodes were evicted; otherwise it cannot safely destroy the keyring.
Since inodes that are in-use by the Landlock LSM don't get evicted until
security_sb_delete(), this means that fscrypt_destroy_keyring() must be
called *after* security_sb_delete().

This fixes a WARN_ON followed by a NULL dereference, only possible if
Landlock was being used on encrypted files.

Fixes: d7e7b9af10 ("fscrypt: stop using keyrings subsystem for fscrypt_master_key")
Cc: stable@vger.kernel.org
Reported-by: syzbot+93e495f6a4f748827c88@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/00000000000044651705f6ca1e30@google.com
Reviewed-by: Christian Brauner <brauner@kernel.org>
Link: https://lore.kernel.org/r/20230313221231.272498-2-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-05-04 10:49:24 -07:00
Alistair Delva
d749a663c6 ANDROID: GKI: Increase max 8250 uarts
Some boards need more than the default maximum of 4 uarts. This has no
impact unless 8250.nr_uarts is specified on the cmdline to increase
the number of runtime uarts from the GKI default of 0.

Bug: 280015873
Signed-off-by: Alistair Delva <adelva@google.com>
Change-Id: I5ba4e1dcce4f4e01b7d306fa3ab05319768eef00
2023-05-04 16:37:09 +00:00
Junki Min
d849bc1a59 ANDROID: ABI: Update Audio symbol for Exynos SoC
Update symbols for audio

14 function symbol(s) added
  'void _dev_alert(const struct device*, const char*, ...)'
  'int dapm_pinctrl_event(struct snd_soc_dapm_widget*, struct snd_kcontrol*, int)'
  'char* kvasprintf(gfp_t, const char*, va_list)'
  'void snd_device_free(struct snd_card*, void*)'
  'void snd_soc_component_async_complete(struct snd_soc_component*)'
  'int snd_soc_component_update_bits_async(struct snd_soc_component*, unsigned int, unsigned int, unsigned int)'
  'int snd_soc_dai_set_tristate(struct snd_soc_dai*, int)'
  'int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context*, const char*)'
  'struct snd_soc_dapm_widget* snd_soc_dapm_new_control(struct snd_soc_dapm_context*, const struct snd_soc_dapm_widget*)'
  'int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context*, const struct snd_soc_dapm_route*, int)'
  'struct snd_soc_dai* snd_soc_find_dai_with_mutex(const struct snd_soc_dai_link_component*)'
  'int snd_soc_get_xr_sx(struct snd_kcontrol*, struct snd_ctl_elem_value*)'
  'void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link*)'
  'int snd_soc_put_xr_sx(struct snd_kcontrol*, struct snd_ctl_elem_value*)'

Bug: 280531400
Change-Id: I7e0821d230e80fa0d93d471102c00a87abb9231f
Signed-off-by: Junki Min <joonki.min@samsung.com>
2023-05-04 11:12:09 +09:00
Asutosh Das
2a3df922b5 UPSTREAM: ufs: mcq: qcom: Fix passing zero to PTR_ERR
Fix an error case in ufs_qcom_mcq_config_resource(), where the
return value is set to 0 before passing it to PTR_ERR.

This led to Smatch warning:
drivers/ufs/host/ufs-qcom.c:1455 ufs_qcom_mcq_config_resource() warn:
passing zero to 'PTR_ERR'

Fixes: c263b4ef73 ("scsi: ufs: core: mcq: Configure resource regions")
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
https://lore.kernel.org/r/94ca99b327af634799ce5f25d0112c28cd00970d.1677721072.git.quic_asutoshd@quicinc.com
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Bug: 279870970
Change-Id: I680f80a0ba6f72e2d3fde9d7bcf2d1d29d686133
(cherry picked from commit c8be073bd2)
Signed-off-by: Xiaosen He <quic_xiaosenh@quicinc.com>
2023-05-03 20:55:57 +00:00
Asutosh Das
2928fad502 UPSTREAM: ufs: mcq: qcom: Clean the return path of ufs_qcom_mcq_config_resource
Smatch static checker reported:
drivers/ufs/host/ufs-qcom.c:1469
ufs_qcom_mcq_config_resource() info: returning a literal zero is
cleaner

Fix the above warning by returning in place instead of a jump to a
label.
Also remove the usage of devm_kfree() as it's unnecessary in this
function.

Fixes: c263b4ef73 ("scsi: ufs: core: mcq: Configure resource regions")
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Link: https://lore.kernel.org/r/3ebd2582af74b81ef7b57149f57c6a3bf0963953.1677721229.git.quic_asutoshd@quicinc.com
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Bug: 279870970
Change-Id: I77d5e09fef772590be1ae98b57a0fdbabe969c52
(cherry picked from commit c9507eab9f)
Signed-off-by: Xiaosen He <quic_xiaosenh@quicinc.com>
2023-05-03 20:55:57 +00:00
Junki Min
3e2abdc34c ANDROID: Update symbol list for Exynos SoC
13 function symbol(s) added
  'int __pkvm_register_el2_call(unsigned long)'
  'int __traceiter_ipi_exit(void*, const char*)'
  'int __traceiter_rwmmio_post_read(void*, unsigned long, unsigned long, u64, u8, const volatile void*)'
  'int __traceiter_rwmmio_read(void*, unsigned long, unsigned long, u8, const volatile void*)'
  'int __traceiter_rwmmio_write(void*, unsigned long, unsigned long, u64, u8, volatile void*)'
  'int __traceiter_workqueue_execute_end(void*, struct work_struct*, work_func_t)'
  'struct cpuidle_driver* cpuidle_get_cpu_driver(struct cpuidle_device*)'
  'u64 int_pow(u64, unsigned int)'
  'int of_add_property(struct device_node*, struct property*)'
  'void* pwm_get_chip_data(struct pwm_device*)'
  'int pwm_set_chip_data(struct pwm_device*, void*)'
  'void refresh_frequency_limits(struct cpufreq_policy*)'
  'int smp_call_function_any(const struct cpumask*, smp_call_func_t, void*, int)'

5 variable symbol(s) added
  'struct tracepoint __tracepoint_ipi_exit'
  'struct tracepoint __tracepoint_rwmmio_post_read'
  'struct tracepoint __tracepoint_rwmmio_read'
  'struct tracepoint __tracepoint_rwmmio_write'
  'struct tracepoint __tracepoint_workqueue_execute_end'

Bug: 280531400
Change-Id: I3260d624aa35a51fccf2c62aef918eea05629e49
Signed-off-by: Junki Min <joonki.min@samsung.com>
2023-05-03 17:56:54 +09:00
Sudarshan Rajagopalan
dd29657536 FROMLIST: ANDROID: GKI: psi: remove 500ms min window size limitation for triggers
Current 500ms min window size for psi triggers limits polling interval
to 50ms to prevent polling threads from using too much cpu bandwidth by
polling too frequently. However the number of cgroups with triggers is
unlimited, so this protection can be defeated by creating multiple
cgroups with psi triggers (triggers in each cgroup are served by a single
"psimon" kernel thread).
Instead of limiting min polling period, which also limits the latency of
psi events, it's better to limit psi trigger creation to authorized users
only, like we do for system-wide psi triggers (/proc/pressure/* files can
be written only by processes with CAP_SYS_RESOURCE capability). This also
makes access rules for cgroup psi files consistent with system-wide ones.
Add a CAP_SYS_RESOURCE capability check for cgroup psi file writers and
remove the psi window min size limitation.

Bug: 269247660
Change-Id: I8876aa306cf2ba5acdf4daa5a5eff0665537bfeb
Suggested-by: Sudarshan Rajagopalan <quic_sudaraja@quicinc.com>
Link: https://lore.kernel.org/all/20230303011346.3342233-1-surenb@google.com/
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Sudarshan Rajagopalan <quic_sudaraja@quicinc.com>
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
2023-05-02 23:08:35 +00:00
Peifeng Li
9957ea75b7 ANDROID: uid_sys_stat: split the global lock uid_lock to the fine-grained
locks for each hlist in hash_table.

Hash_table in uid_sys_stat is protected by a global lock named id_lock,
which causes some lock competition issue. Actually, uid_lock can be split to
several file-grained locks for each hlist in hash_table, which avoid
the unnecessary lock competition when get different-uid process info.

Bug: 278138377
Signed-off-by: Peifeng Li <lipeifeng@oppo.com>
Change-Id: I04c564ce42b62d8cfb9ed29e99f310ba76244763
2023-05-02 22:39:28 +00:00
Suren Baghdasaryan
5586278c0f ANDROID: uid_sys_stats: defer process_notifier work if uid_lock is contended
process_notifier() is called every time a process exits. When multiple
processes exit roughly at the same time, the uid_lock taken from inside
of process_notifier() will create contention which slows down process
exit. Defer stats accounting in such case to avoid lock contention.

Bug: 261537194
Change-Id: Ia1e9a451eab39eb0dda7eb175bfd71c67f3e0a58
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2023-05-02 22:39:28 +00:00
Will McVicker
092ae9d343 ANDROID: Add symbols for pkvm module support
6 function symbol(s) added
  'int __pkvm_load_el2_module(struct module*, unsigned long*)'
  'int pkvm_iommu_driver_init(u64, void*, size_t)'
  'int pkvm_iommu_finalize(int)'
  'int pkvm_iommu_register(struct device*, u64, phys_addr_t, size_t,
                           struct device*, u8)'
  'int pkvm_iommu_resume(struct device*)'
  'int pkvm_iommu_suspend(struct device*)'

Bug: 279090118
Change-Id: Ic09dacdcc460ab22802ddc655c34aa0b24932364
Signed-off-by: Will McVicker <willmcvicker@google.com>
2023-05-02 21:38:36 +00:00
Chris Goldsworthy
41af44f9dd ANDROID: abi_gki_aarch64_qcom: Add dma_resv iterator symbols
Add dma_resv_iter_first and dma_resv_iter_next to
abi_gki_aarch64_qcom. These symbols were already added to the KMI as a
part of commit b38e72d30c ("ANDROID: Add initial symbols list for
db845c").

Bug: 199236943
Change-Id: Ib5222cf342c3e119e424c3c13c062c9d867c7884
Signed-off-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
2023-05-02 17:42:28 +00:00
Ulises Mendez Martinez
943d0dd4cf ANDROID: Unnest MAKE_GOALS from build configs
* This is in preparation for migrating these
as `kernel_build` attributes. i.e. these will
be removed as a follow-up.

Bug: 236012223
Signed-off-by: Ulises Mendez Martinez <umendez@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:ccc4fb8185b50958354d8d511823491030988131)
Merged-In: I168c44fd76f9f2732caf8f5c00bec4ed8c96ee65
Change-Id: I168c44fd76f9f2732caf8f5c00bec4ed8c96ee65
2023-05-02 13:37:21 +00:00
Isaac J. Manjarres
0f690b56fe ANDROID: iommu/dma: Add support for DMA_ATTR_SYS_CACHE_NWA
IOMMU_SYS_CACHE_NWA allows buffers for non-coherent devices to be
mapped with the correct memory attributes so that the buffers can be
cached in the system cache, with a no write allocate cache policy.
However, this property is only usable by drivers that invoke the IOMMU
API directly; it is not usable by drivers that use the DMA API.

Thus, introduce DMA_ATTR_SYS_CACHE_NWA, so that drivers for
non-coherent devices that use the DMA API can use it to specify if
they want a buffer to be cached in the system cache.

Bug: 189339242
Change-Id: Ic812a1fb144a58deb4279c2bf121fc6cc4c3b208
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
2023-05-01 21:16:31 -07:00
Isaac J. Manjarres
ed46a5c09b ANDROID: iommu/dma: Add support for DMA_ATTR_SYS_CACHE
IOMMU_SYS_CACHE allows buffers for non-coherent devices to be mapped
with the correct memory attributes so that the buffers can be cached
in the system cache. However, this property is only usable by drivers
that invoke the IOMMU API directly; it is not usable by drivers that
use the DMA API.

Thus, introduce DMA_ATTR_SYS_CACHE, so that drivers for non-coherent
devices that use the DMA API can use it to specify if they want a
buffer to be cached in the system cache.

Bug: 189339242
Change-Id: I849d7a3f36b689afd2f6ee400507223fd6395158
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
2023-05-01 21:16:30 -07:00
Patrick Daly
6985c9f4e3 ANDROID: iommu/io-pgtable-arm: Add IOMMU_SYS_CACHE/_NWA
Add IOMMU_SYS_CACHE and IOMMU_SYS_CACHE_NWA for device mappings.
IOMMU_SYS_CACHE, used by itself, allows device accesses to be cached
in the system cache (if present). IOMMU_SYS_CACHE_NWA, used by itself,
allows device accesses to be cached in the system cache with a
no-write allocate policy.

On systems in which devices can also snoop the CPU caches (i.e.
IO-coherency is present), IOMMU_SYS_CACHE_NWA and IOMMU_SYS_CACHE can
be combined with IOMMU_CACHE (with IOMMU_SYS_CACHE + IOMMU_CACHE being
a no-op).

Bug: 189339242
Change-Id: Ic91616a148f39fead008a5b87a54ffd781fee734
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
Signed-off-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
2023-05-01 21:05:15 -07:00
Isaac J. Manjarres
179d0bd36c ANDROID: arm64: Add support for system cache memory type
Non-coherent devices on systems that support a system or
last level cache may want to request that allocations be
cached in the system cache. For memory that is allocated
by the kernel, and used for DMA with devices, the memory
attributes used for CPU access should match the memory
attributes that will be used for device access.

The memory attributes that need to be programmed into
the MAIR for system cache usage are:

0xf4 - Normal memory, outer write back read/write allocate,
inner non-cacheable.

There is currently no support for this memory attribute for
CPU mappings, so add it.

Bug: 189339242
Change-Id: I3abc7becd408f20ac5499cbbe3c6c6f53f784107
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
2023-05-01 20:12:50 -07:00
Weizhao Ouyang
1e9d08f986 ANDROID: fuse-bpf: Fix bpf_test_xattr testcase error
Skipped selinux xattr checking.

Bug: 279996548
Test: fuse_test compiles and passes
Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
(cherry picked from https://android-review.googlesource.com/q/commit:dbfbd63968743deaf9854df8952874d00c2d3755)
Merged-In: I56ac1d5fe3865310a99c091e9688e70aa515e96f
Change-Id: I56ac1d5fe3865310a99c091e9688e70aa515e96f
2023-05-01 22:47:49 +00:00
Paul Lawrence
bb9c6d4116 ANDROID: fuse-bpf: Simplify and fix setting bpf program
Fix case when an existing bpf prog is being removed
Tidy up code

Bug: 279363668
Test: Boots, can copy file to /sdcardfs/Android/data, fuse_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:64366661e8a9a6d691e5ab6499872d495aed5266)
Merged-In: If0e682f43cbeb62764a7a2be543b90cb974b0aa0
Change-Id: If0e682f43cbeb62764a7a2be543b90cb974b0aa0
2023-05-01 16:07:26 +00:00
wang qiankun
f138bad25e ANDROID: GKI: update the ABI symbol list
INFO: ABI DIFFERENCES HAVE BEEN DETECTED!
INFO: 1 function symbol(s) added
  'int __traceiter_android_vh_map_util_freq(void*, unsigned long, unsigned long, unsigned long, unsigned long*, struct cpufreq_policy*, bool*)'

1 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_map_util_freq'

Bug: 277846574

Change-Id: I0adf7600e9b9c85dee67b2cfe71c335c537e69f6
Signed-off-by: wang qiankun <wangqiankun3@xiaomi.corp-partner.google.com>
2023-05-01 00:46:51 +00:00
Yun Hsiang
b77eeebb3c ANDROID: schedutil: add vendor hook for adjusting util to freq calculation
Currently, the frequency is calculated by max freq * 1.25 * util / max cap.
Add a vendor hook to adjust the frequency when the calculation
overestimate.

android_vh_map_util_freq
	adjust util to freq calculation

Bug: 177845439

Signed-off-by: Yun Hsiang <yun.hsiang@mediatek.com>
Change-Id: I9aa9079f00af7d3380b19f2fe21b75cddd107d15
(cherry picked from commit 3122e3ec9672036384304fdeaa1b1815f60ba817)
(cherry picked from commit a2d89d4f3a)
2023-04-29 09:02:05 +00:00
Peter Collingbourne
f46afe0c21 BACKPORT: FROMLIST: arm64: Also reset KASAN tag if page is not PG_mte_tagged
Consider the following sequence of events:

1) A page in a PROT_READ|PROT_WRITE VMA is faulted.
2) Page migration allocates a page with the KASAN allocator,
   causing it to receive a non-match-all tag, and uses it
   to replace the page faulted in 1.
3) The program uses mprotect() to enable PROT_MTE on the page faulted in 1.

As a result of step 3, we are left with a non-match-all tag for a page
with tags accessible to userspace, which can lead to the same kind of
tag check faults that commit e74a684680 ("arm64: Reset KASAN tag in
copy_highpage with HW tags only") intended to fix.

The general invariant that we have for pages in a VMA with VM_MTE_ALLOWED
is that they cannot have a non-match-all tag. As a result of step 2, the
invariant is broken. This means that the fix in the referenced commit
was incomplete and we also need to reset the tag for pages without
PG_mte_tagged.

Fixes: e5b8d92189 ("arm64: mte: reset the page tag in page->flags")
Cc: <stable@vger.kernel.org> # 5.15
Link: https://linux-review.googlesource.com/id/I7409cdd41acbcb215c2a7417c1e50d37b875beff
Link: https://lore.kernel.org/all/20230420210945.2313627-1-pcc@google.com/
Signed-off-by: Peter Collingbourne <pcc@google.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Bug: 263910115
Change-Id: I7409cdd41acbcb215c2a7417c1e50d37b875beff
[pcc: fixed merge conflict]
2023-04-29 08:53:48 +00:00
Peter Collingbourne
a3ac1df945 FROMLIST: arm64: mte: Do not set PG_mte_tagged if tags were not initialized
The mte_sync_page_tags() function sets PG_mte_tagged if it initializes
page tags. Then we return to mte_sync_tags(), which sets PG_mte_tagged
again. At best, this is redundant. However, it is possible for
mte_sync_page_tags() to return without having initialized tags for the
page, i.e. in the case where check_swap is true (non-compound page),
is_swap_pte(old_pte) is false and pte_is_tagged is false. So at worst,
we set PG_mte_tagged on a page with uninitialized tags. This can happen
if, for example, page migration causes a PTE for an untagged page to
be replaced. If the userspace program subsequently uses mprotect() to
enable PROT_MTE for that page, the uninitialized tags will be exposed
to userspace.

Fix it by removing the redundant call to set_page_mte_tagged().

Fixes: e059853d14 ("arm64: mte: Fix/clarify the PG_mte_tagged semantics")
Signed-off-by: Peter Collingbourne <pcc@google.com>
Cc: <stable@vger.kernel.org> # 6.1
Link: https://linux-review.googlesource.com/id/Ib02d004d435b2ed87603b858ef7480f7b1463052
Link: https://lore.kernel.org/all/20230420214327.2357985-1-pcc@google.com/
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Bug: 263910115
Change-Id: Ib02d004d435b2ed87603b858ef7480f7b1463052
2023-04-28 16:35:48 -07:00
Ramji Jiyani
fbb735239d ANDROID: GKI: Convert USB network adpaters to modules
Converts these config items from built-in to GKI protected
modules:

CONFIG_USB_NET_DRIVERS
CONFIG_USB_USBNET
CONFIG_USB_RTL8150
CONFIG_USB_RTL8152
CONFIG_USB_NET_AX8817X
CONFIG_USB_NET_AX88179_178A
CONFIG_USB_NET_CDCETHER
CONFIG_USB_NET_CDC_EEM
CONFIG_USB_NET_CDC_NCM
CONFIG_USB_NET_AQC111
CONFIG_USB_RTL8153_ECM

Bug: 232431151
Bug: 279972445
Test: TH
Change-Id: I8a6e34be1ed86a8ea1d44e6721954fb5888e1fa4
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-04-28 20:29:07 +00:00
Keir Fraser
8fa3f9cfd9 ANDROID: KVM: arm64: Prevent kmemleak from accessing EL2 module sections
Since these are unmapped from EL1, kmemleak will crash if it accesses
them.

Bug: 275004094
Signed-off-by: Keir Fraser <keirf@google.com>
Change-Id: Ieb15033c2dc21e6437a3a3c91a8b36e8dda31e98
2023-04-28 14:50:28 +00:00
Will Deacon
417e986b54 ANDROID: KVM: arm64: Move addr_is_allowed_memory() check into host callback
Since host stage-2 mappings are created lazily, we cannot rely on the
pte in order to recover the target physical address when checking a
host-initiated memory transition.

Instead, move the addr_is_allowed_memory() check into the host callback
function where it is passed the physical address directly from the
walker.

Bug: 279739439
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I84bdc43eded79f1f5e5a489dbc0874604491e5c8
2023-04-28 12:15:58 +01:00
Paul Lawrence
f880802e17 ANDROID: fuse-bpf: Make fuse_test compile and pass
Remove ARRAY_SIZE definition
Uncomment FUSE_CANONICAL_PATH responses

Bug: 279912034
Test: fuse_test compiles and passes
Change-Id: I511bc0466a552261428347b1cf9f23f1088213e0
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2023-04-27 22:58:17 +00:00
Eric Biggers
8ad55edd66 fscrypt: optimize fscrypt_initialize()
fscrypt_initialize() is a "one-time init" function that is called
whenever the key is set up for any inode on any filesystem.  Make it
implement "one-time init" more efficiently by not taking a global mutex
in the "already initialized case" and doing fewer pointer dereferences.

Link: https://lore.kernel.org/r/20230406181245.36091-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-04-27 13:18:55 -07:00
Eric Biggers
fea2e54241 fscrypt: use WARN_ON_ONCE instead of WARN_ON
As per Linus's suggestion
(https://lore.kernel.org/r/CAHk-=whefxRGyNGzCzG6BVeM=5vnvgb-XhSeFJVxJyAxAF8XRA@mail.gmail.com),
use WARN_ON_ONCE instead of WARN_ON.  This barely adds any extra
overhead, and it makes it so that if any of these ever becomes reachable
(they shouldn't, but that's the point), the logs can't be flooded.

Link: https://lore.kernel.org/r/20230320233943.73600-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-04-27 13:18:54 -07:00
Luís Henriques
b2a951ceb6 fscrypt: new helper function - fscrypt_prepare_lookup_partial()
This patch introduces a new helper function which can be used both in
lookups and in atomic_open operations by filesystems that want to handle
filename encryption and no-key dentries themselves.

The reason for this function to be used in atomic open is that this
operation can act as a lookup if handed a dentry that is negative.  And in
this case we may need to set DCACHE_NOKEY_NAME.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
[ebiggers: improved the function comment, and moved the function to just
           below __fscrypt_prepare_lookup()]
Link: https://lore.kernel.org/r/20230320220149.21863-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-04-27 13:18:54 -07:00
Jishnu Prakash
30151e7f47 ANDROID: abi_gki_aarch64_qcom: Add missing symbol to QCOM list
Add the following symbol for qpnp-smb5 driver.

1 function symbol(s) added
  'ktime_t alarm_expires_remaining(const struct alarm*)'

Bug: 279705107
Change-Id: I179eb3a46a9b8f95a4a191fc99a4fdd1758efe8e
Signed-off-by: Jishnu Prakash <quic_jprakash@quicinc.com>
2023-04-27 18:00:52 +00:00
Eric Biggers
8d038b99ae fscrypt: check for NULL keyring in fscrypt_put_master_key_activeref()
It is a bug for fscrypt_put_master_key_activeref() to see a NULL
keyring.  But it used to be possible due to the bug, now fixed, where
fscrypt_destroy_keyring() was called before security_sb_delete().  To be
consistent with how fscrypt_destroy_keyring() uses WARN_ON for the same
issue, WARN and leak the fscrypt_master_key if the keyring is NULL
instead of dereferencing the NULL pointer.

This is a robustness improvement, not a fix.

Link: https://lore.kernel.org/r/20230313221231.272498-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-04-27 09:12:18 -07:00
Eric Biggers
16866ef2e9 fscrypt: improve fscrypt_destroy_keyring() documentation
Document that fscrypt_destroy_keyring() must be called after all
potentially-encrypted inodes have been evicted.

Link: https://lore.kernel.org/r/20230313221231.272498-3-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-04-27 09:12:14 -07:00
Treehugger Robot
7c8f5422fc Merge "Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-6.1.y' into android14-6.1" into android14-6.1 2023-04-27 15:58:44 +00:00
Matthias Maennich
ad2322e23d ANDROID: Update ABI representation
c82ae97ea1 ("ANDROID: ABI: Update QCOM symbol list for display
drivers") lost the race with 7b05b74b3b ("ANDROID: 4/26/2023 KMI
update") and hence the CRCs in the representation are wrong. Fix that.

function symbol '__poll_t v4l2_m2m_poll(struct file*, struct v4l2_m2m_ctx*, struct poll_table_struct*)' changed
  CRC changed from 0x66202a46 to 0x927a7513

function symbol 'int v4l2_m2m_querybuf(struct file*, struct v4l2_m2m_ctx*, struct v4l2_buffer*)' changed
  CRC changed from 0x477bda98 to 0x9040fcee

function symbol 'int v4l2_m2m_reqbufs(struct file*, struct v4l2_m2m_ctx*, struct v4l2_requestbuffers*)' changed
  CRC changed from 0x1b578a39 to 0x55e0e942

... 1 omitted; 4 symbols have only CRC changes

Fixes: c82ae97ea1 ("ANDROID: ABI: Update QCOM symbol list for display drivers")
Change-Id: I19c76907ed62c6f91e61df65920ee58216492fff
Signed-off-by: Matthias Maennich <maennich@google.com>
2023-04-27 14:01:04 +01:00
Mahadevan
c82ae97ea1 ANDROID: ABI: Update QCOM symbol list for display drivers
Add V4L2 driver symbols to QCOM abi list which are used by display
drivers.

4 function symbol(s) added
  '__poll_t v4l2_m2m_poll(struct file*, struct v4l2_m2m_ctx*, struct poll_table_struct*)'
  'int v4l2_m2m_querybuf(struct file*, struct v4l2_m2m_ctx*, struct v4l2_buffer*)'
  'int v4l2_m2m_reqbufs(struct file*, struct v4l2_m2m_ctx*, struct v4l2_requestbuffers*)'
  'int v4l2_m2m_streamon(struct file*, struct v4l2_m2m_ctx*, enum v4l2_buf_type)'

Bug: 279390325
Change-Id: If87cc42f8d1f5f9e2445e31ec3b660025be5335b
Signed-off-by: Mahadevan <quic_mahap@quicinc.com>
2023-04-27 12:25:55 +00:00
Quentin Perret
e29f2abc1c ANDROID: KVM: arm64: Prevent kmemleak from accessing .hyp.data
We've recently added a .data section for the hypervisor, which kmemleak
is eager to parse. This clearly doesn't go well, so add the section to
kmemleak's block list.

Bug: 232768943
Bug: 235903024
Change-Id: Ib1ee0009ce05bf7b0ba5d53fc8ca0429ec592102
Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 275004094
Signed-off-by: Keir Fraser <keirf@google.com>
2023-04-27 09:29:24 +00:00
Jaegeuk Kim
8db3d6ac04 Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-6.1.y' into android14-6.1
* aosp/upstream-f2fs-stable-linux-6.1.y:
  f2fs: remove unnessary comment in __may_age_extent_tree
  f2fs: allocate node blocks for atomic write block replacement
  f2fs: use cow inode data when updating atomic write
  f2fs: remove power-of-two limitation of zoned device
  f2fs: allocate trace path buffer from names_cache
  f2fs: add has_enough_free_secs()
  f2fs: relax sanity check if checkpoint is corrupted
  f2fs: refactor f2fs_gc to call checkpoint in urgent condition
  f2fs: remove folio_detach_private() in .invalidate_folio and .release_folio
  f2fs: remove bulk remove_proc_entry() and unnecessary kobject_del()
  f2fs: support iopoll method
  f2fs: remove batched_trim_sections node description
  f2fs: fix to check return value of inc_valid_block_count()
  f2fs: fix to check return value of f2fs_do_truncate_blocks()
  f2fs: fix passing relative address when discard zones
  f2fs: fix potential corruption when moving a directory
  f2fs: add radix_tree_preload_end in error case
  f2fs: fix to recover quota data correctly
  f2fs: fix to check readonly condition correctly
  docs: f2fs: Correct instruction to disable checkpoint
  f2fs: fix to keep consistent i_gc_rwsem lock order
  f2fs: fix to drop all dirty pages during umount() if cp_error is set
  f2fs: fix to avoid use-after-free for cached IPU bio
  f2fs: remove unneeded in-memory i_crtime copy
  f2fs: use f2fs_hw_is_readonly() instead of bdev_read_only()
  f2fs: use common implementation of file type
  f2fs: merge lz4hc_compress_pages() to lz4_compress_pages()
  f2fs: convert to use sysfs_emit
  f2fs: set default compress option only when sb_has_compression
  f2fs: Fix system crash due to lack of free space in LFS
  f2fs: remove struct victim_selection default_v_ops
  f2fs: fix null pointer panic in tracepoint in __replace_atomic_write_block
  f2fs: fix iostat lock protection
  f2fs: fix align check for npo2
  f2fs: add compression feature check for all compress mount opt
  f2fs: convert is_extension_exist() to return bool type
  f2fs: fix scheduling while atomic in decompression path
  f2fs: preserve direct write semantics when buffering is forced
  f2fs: compress: fix to call f2fs_wait_on_page_writeback() in f2fs_write_raw_pages()
  f2fs: remove else in f2fs_write_cache_pages()
  f2fs: apply zone capacity to all zone type
  f2fs: fix to handle filemap_fdatawrite() error in f2fs_ioc_decompress_file/f2fs_ioc_compress_file
  f2fs: convert to MAX_SBI_FLAG instead of 32 in stat_show()
  f2fs: Fix discard bug on zoned block devices with 2MiB zone size
  f2fs: remove entire rb_entry sharing
  f2fs: factor out discard_cmd usage from general rb_tree use
  f2fs: factor out victim_entry usage from general rb_tree use
  f2fs: fix uninitialized skipped_gc_rwsem
  f2fs: handle dqget error in f2fs_transfer_project_quota()
  f2fs: convert to use bitmap API
  f2fs: export compress_percent and compress_watermark entries
  f2fs: make f2fs_sync_inode_meta() static
  f2fs: Fix f2fs_truncate_partial_nodes ftrace event

Bug: 273795759
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I260f4009b3bb6a0ffca20488d0ad0e41e92fb9d2
2023-04-26 17:04:43 -07:00
Carlos Llamas
7b05b74b3b ANDROID: 4/26/2023 KMI update
Set KMI_GENERATION=5 for 4/26 KMI update

4 function symbol(s) added
  'int __traceiter_android_rvh_set_gfp_zone_flags(void*, unsigned int*)'
  'int __traceiter_android_rvh_set_readahead_gfp_mask(void*, unsigned int*)'
  'int __traceiter_android_vh_kswapd_per_node(void*, int, bool*, bool)'
  'int kswapd(void*)'

3 variable symbol(s) added
  'struct tracepoint __tracepoint_android_rvh_set_gfp_zone_flags'
  'struct tracepoint __tracepoint_android_rvh_set_readahead_gfp_mask'
  'struct tracepoint __tracepoint_android_vh_kswapd_per_node'

function symbol 'struct block_device* I_BDEV(struct inode*)' changed
  CRC changed from 0xbf847796 to 0xbc7aa1fb

function symbol 'void __ClearPageMovable(struct page*)' changed
  CRC changed from 0xd312e35b to 0x3607cc69

function symbol 'void __SetPageMovable(struct page*, const struct movable_operations*)' changed
  CRC changed from 0x9c92af65 to 0x44efe80c

... 4301 omitted; 4304 symbols have only CRC changes

type 'struct request' changed
  byte size changed from 280 to 304
  member 'struct { struct io_cq* icq; void* priv[2]; } elv' was added
  member 'struct { unsigned int seq; struct list_head list; rq_end_io_fn* saved_end_io; } flush' was added
  member 'union { struct { struct io_cq* icq; void* priv[2]; } elv; struct { unsigned int seq; struct list_head list; rq_end_io_fn* saved_end_io; } flush; }' was removed
  3 members ('union { struct __call_single_data csd; u64 fifo_time; }' .. 'void* end_io_data') changed
    offset changed by 192

type 'struct super_block' changed
  member 'int cleancache_poolid' was added
  14 members ('struct shrinker s_shrink' .. 'int s_stack_depth') changed
    offset changed by 64

type 'struct pglist_data' changed
  byte size changed from 9088 to 9216
  member 'struct task_struct* mkswapd[16]' was added
  18 members ('int kswapd_order' .. 'atomic_long_t vm_stat[42]') changed
    offset changed by 1024

type 'struct netns_ipv6' changed
  member 'struct list_head mr6_tables' was added
  member 'struct fib_rules_ops* mr6_rules_ops' was added
  member 'struct mr_table* mrt6' was removed
  8 members ('atomic_t dev_addr_genid' .. 'struct ioam6_pernet_data* ioam6_data') changed
    offset changed by 128

type 'struct fscrypt_operations' changed
  byte size changed from 104 to 136
  member 'u64 android_oem_data1[4]' was added

type 'struct dma_heap_ops' changed
  byte size changed from 8 to 16
  member 'long(* get_pool_size)(struct dma_heap*)' was added

type 'struct per_cpu_pages' changed
  byte size changed from 256 to 320
  member changed from 'struct list_head lists[13]' to 'struct list_head lists[17]'
    type changed from 'struct list_head[13]' to 'struct list_head[17]'
      number of elements changed from 13 to 17

Bug: 279074305
Change-Id: I21b301a1a4a761e935ff5679d143c2614e533ad6
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2023-04-26 17:14:41 +00:00
Chris Goldsworthy
342be123fd ANDROID: mm: Create hooks for ZONE_MOVABLE allocs
Create a vendor hook inside of gfp_zone() to modify which allocations
get to enter ZONE_MOVABLE, by zeroing out __GFP_HIGHMEM inside of the
trace hook based on certain conditions.

Separately, create a trace hook in the readahead path to affect the
behavior of the tracehook in gfp_zone().

In 5.15, we had set_skip_swapcache_flags trace-hook in do_swap_page()
but commit ac26e9c7b809 ("ANDROID: cma: allow to use CMA in swap-in path")
added __GFP_CMA explicitly, so the set_skip_swapcache_flags trace hook
is no longer needed.

Note:	To comply with vendor hook guidlines, avoid including types.h in
	trace/hooks/mm.h and use unsigned int for gfp_t.

Bug: 158645321
Change-Id: Idfa6b0b06b1b819d706c847e702bc94ddf7aa55a
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
Signed-off-by: Sukadev Bhattiprolu <quic_sukadev@quicinc.com>
2023-04-26 17:01:52 +00:00
Vinayak Menon
31f15608bb ANDROID: zram: allow zram to allocate CMA pages
Though zram pages are movable, they aren't allowed to enter
MIGRATE_CMA pageblocks. zram is not seen to pin pages for
long which can cause an issue. Moreover allowing zram to
pick CMA pages can be helpful in cases seen where zram order
0 alloc fails when there are lots of free cma pages, resulting
in kswapd or direct reclaim not making enough progress.

Bug: 158645321
Link: https://lore.kernel.org/linux-mm/4c77bb100706b714213ff840d827a48e40ac9177.1604282969.git.cgoldswo@codeaurora.org/
Change-Id: I31f4a21781cdb31982a768daa59e9546d7667b08
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
[isaacm@codeaurora.org: Resolve trivial merge conflicts]
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
Signed-off-by: Sukadev Bhattiprolu <quic_sukadev@quicinc.com>
2023-04-26 17:01:52 +00:00
Chris Goldsworthy
433445e9a1 ANDROID: mm: add cma pcp list
Add a PCP list for __GFP_CMA allocations so as not to deprive
MIGRATE_MOVABLE allocations quick access to pages on their PCP
lists.

Bug: 158645321
Change-Id: I9831eed113ec9e851b4f651755205ac9cf23b9be
Signed-off-by: Liam Mark <lmark@codeaurora.org>
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
[isaacm@codeaurora.org: Resolve merge conflicts related to new mm
features]
Signed-off-by: Isaac J. Manjarres <isaacm@quicinc.com>
quic_sukadev@quicinc.com: Resolve merge conflicts due to earlier patch
dropping gfp_flags;drop BUILD_BUG_ON related to MIGRATETYPE_HIGHATOMIC
since its value changed.
Signed-off-by: Sukadev Bhattiprolu <quic_sukadev@quicinc.com>
2023-04-26 17:01:52 +00:00
Heesub Shin
f60c5572d2 ANDROID: cma: redirect page allocation to CMA
CMA pages are designed to be used as fallback for movable allocations
and cannot be used for non-movable allocations. If CMA pages are
utilized poorly, non-movable allocations may end up getting starved if
all regular movable pages are allocated and the only pages left are
CMA. Always using CMA pages first creates unacceptable performance
problems. As a midway alternative, use CMA pages for certain
userspace allocations. The userspace pages can be migrated or dropped
quickly which giving decent utilization.

Additionally, add a fall-backs for failed CMA allocations in rmqueue()
and __rmqueue_pcplist() (the latter addition being driven by a report
by the kernel test robot); these fallbacks were dealt with differently
in the original version of the patch as the rmqueue() call chain has
changed).

Bug: 158645321
Link: https://lore.kernel.org/lkml/cover.1604282969.git.cgoldswo@codeaurora.org/
Change-Id: Iad46f0405b416e29ae788f82b79c9953513a9c9d
Reported-by: kernel test robot <rong.a.chen@intel.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
[cgoldswo@codeaurora.org: Place in bugfixes; remove cma_alloc zone flag]
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
[isaacm@codeaurora.org: Resolve merge conflicts to account for new mm
features]
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
[quic_sukadev@quicinc.com: dropped unused gfp_flags parameter to
__rmqueue_pcplist(), resolved some conflicts]
Signed-off-by: Sukadev Bhattiprolu <quic_sukadev@quicinc.com>
2023-04-26 17:01:52 +00:00
Eric Biggers
81569f07df ANDROID: GKI: fscrypt: add OEM data to struct fscrypt_operations
'struct fscrypt_operations' shouldn't really be part of the KMI, as
there's no reason for loadable modules to use it.  However, due to the
way MODVERSIONS calculates symbol CRCs by recursively dereferencing
structures, changes to 'struct fscrypt_operations' affect the CRCs of
KMI functions exported from certain core kernel files such as
fs/dcache.c.  That brings it in-scope for the KMI freeze.

There is an OEM who wants to add fields to this struct, so add an
ANDROID_OEM_DATA_ARRAY for them to use.

Bug: 173475629
Change-Id: Idfc76884fce8a5fcc0837cd9363695d5428b1624
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: j7093.jung <j7093.jung@samsung.com>
2023-04-26 17:01:51 +00:00
Mostafa Saleh
90b95f6a81 ANDROID: KVM: arm64: iommu: Pass device specific flags to hypervisor
We need to pass some device specific flags that are detected from EL1
(as built-in sync device) to the hypervisor. The flags are defined
by the driver but hosted in the main iommu struct.

As we use SMCCC1.1 we only have 7 args, which were already used, so
mem_size is removed as it really not needed as all page donations
are 1 page. so passing the base address is enough.

Bug: 255266847
Change-Id: I14e6d2573d7a822334455999aa9fd6f01ac97450
Signed-off-by: Mostafa Saleh <smostafa@google.com>
2023-04-26 17:01:51 +00:00
Vijayanand Jitta
98d9ae3046 ANDROID: abi_gki_aarch64_qcom: Update qcom abi symbol list
Update qcom abi symbol list required for multiple kswapd.

Symbols added:
   kswapd
   __traceiter_android_vh_kswapd_per_node
   __tracepoint_android_vh_kswapd_per_node

Bug: 201263306
Change-Id: Ie945059158784a97570fadb31a9939ac365c3c71
Signed-off-by: Vijayanand Jitta <quic_vjitta@quicinc.com>
2023-04-26 17:01:51 +00:00
Charan Teja Reddy
88153d9a99 ANDROID: vmscan: Support multiple kswapd threads per node
Page replacement is handled in the Linux Kernel in one of two ways:

1) Asynchronously via kswapd
2) Synchronously, via direct reclaim

At page allocation time the allocating task is immediately given a page
from the zone free list allowing it to go right back to work doing
whatever it was doing; Probably directly or indirectly executing business
logic.

Just prior to satisfying the allocation, free pages is checked to see if
it has reached the zone low watermark and if so, kswapd is awakened.
Kswapd will start scanning pages looking for inactive pages to evict to
make room for new page allocations. The work of kswapd allows tasks to
continue allocating memory from their respective zone free list without
incurring any delay.

When the demand for free pages exceeds the rate that kswapd tasks can
supply them, page allocation works differently. Once the allocating task
finds that the number of free pages is at or below the zone min watermark,
the task will no longer pull pages from the free list. Instead, the task
will run the same CPU-bound routines as kswapd to satisfy its own
allocation by scanning and evicting pages. This is called a direct reclaim.

The time spent performing a direct reclaim can be substantial, often
taking tens to hundreds of milliseconds for small order0 allocations to
half a second or more for order9 huge-page allocations. In fact, kswapd is
not actually required on a linux system. It exists for the sole purpose of
optimizing performance by preventing direct reclaims.

When memory shortfall is sufficient to trigger direct reclaims, they can
occur in any task that is running on the system. A single aggressive
memory allocating task can set the stage for collateral damage to occur in
small tasks that rarely allocate additional memory. Consider the impact of
injecting an additional 100ms of latency when nscd allocates memory to
facilitate caching of a DNS query.

The presence of direct reclaims 10 years ago was a fairly reliable
indicator that too much was being asked of a Linux system. Kswapd was
likely wasting time scanning pages that were ineligible for eviction.
Adding RAM or reducing the working set size would usually make the problem
go away. Since then hardware has evolved to bring a new struggle for
kswapd. Storage speeds have increased by orders of magnitude while CPU
clock speeds stayed the same or even slowed down in exchange for more
cores per package. This presents a throughput problem for a single
threaded kswapd that will get worse with each generation of new hardware.

Test Details

NOTE: The tests below were run with shadow entries disabled. See the
associated patch and cover letter for details

The tests below were designed with the assumption that a kswapd bottleneck
is best demonstrated using filesystem reads. This way, the inactive list
will be full of clean pages, simplifying the analysis and allowing kswapd
to achieve the highest possible steal rate. Maximum steal rates for kswapd
are likely to be the same or lower for any other mix of page types on the
system.

Tests were run on a 2U Oracle X7-2L with 52 Intel Xeon Skylake 2GHz cores,
756GB of RAM and 8 x 3.6 TB NVMe Solid State Disk drives. Each drive has
an XFS file system mounted separately as /d0 through /d7. SSD drives
require multiple concurrent streams to show their potential, so I created
eleven 250GB zero-filled files on each drive so that I could test with
parallel reads.

The test script runs in multiple stages. At each stage, the number of dd
tasks run concurrently is increased by 2. I did not include all of the
test output for brevity.

During each stage dd tasks are launched to read from each drive in a round
robin fashion until the specified number of tasks for the stage has been
reached. Then iostat, vmstat and top are started in the background with 10
second intervals. After five minutes, all of the dd tasks are killed and
the iostat, vmstat and top output is parsed in order to report the
following:

CPU consumption
- sy - aggregate kernel mode CPU consumption from vmstat output. The value
       doesn't tend to fluctuate much so I just grab the highest value.
       Each sample is averaged over 10 seconds
- dd_cpu - for all of the dd tasks averaged across the top samples since
           there is a lot of variation.

Throughput
- in Kbytes
- Command is iostat -x -d 10 -g total

This first test performs reads using O_DIRECT in order to show the maximum
throughput that can be obtained using these drives. It also demonstrates
how rapidly throughput scales as the number of dd tasks are increased.

The dd command for this test looks like this:

Command Used: dd iflag=direct if=/d${i}/$n of=/dev/null bs=4M

Test #1: Direct IO
dd sy dd_cpu throughput
6  0  2.33   14726026.40
10 1  2.95   19954974.80
16 1  2.63   24419689.30
22 1  2.63   25430303.20
28 1  2.91   26026513.20
34 1  2.53   26178618.00
40 1  2.18   26239229.20
46 1  1.91   26250550.40
52 1  1.69   26251845.60
58 1  1.54   26253205.60
64 1  1.43   26253780.80
70 1  1.31   26254154.80
76 1  1.21   26253660.80
82 1  1.12   26254214.80
88 1  1.07   26253770.00
90 1  1.04   26252406.40

Throughput was close to peak with only 22 dd tasks. Very little system CPU
was consumed as expected as the drives DMA directly into the user address
space when using direct IO.

In this next test, the iflag=direct option is removed and we only run the
test until the pgscan_kswapd from /proc/vmstat starts to increment. At
that point metrics are parsed and reported and the pagecache contents are
dropped prior to the next test. Lather, rinse, repeat.

Test #2: standard file system IO, no page replacement
dd sy dd_cpu throughput
6  2  28.78  5134316.40
10 3  31.40  8051218.40
16 5  34.73  11438106.80
22 7  33.65  14140596.40
28 8  31.24  16393455.20
34 10 29.88  18219463.60
40 11 28.33  19644159.60
46 11 25.05  20802497.60
52 13 26.92  22092370.00
58 13 23.29  22884881.20
64 14 23.12  23452248.80
70 15 22.40  23916468.00
76 16 22.06  24328737.20
82 17 20.97  24718693.20
88 16 18.57  25149404.40
90 16 18.31  25245565.60

Each read has to pause after the buffer in kernel space is populated while
those pages are added to the pagecache and copied into the user address
space. For this reason, more parallel streams are required to achieve peak
throughput. The copy operation consumes substantially more CPU than direct
IO as expected.

The next test measures throughput after kswapd starts running. This is the
same test only we wait for kswapd to wake up before we start collecting
metrics. The script actually keeps track of a few things that were not
mentioned earlier. It tracks direct reclaims and page scans by watching
the metrics in /proc/vmstat. CPU consumption for kswapd is tracked the
same way it is tracked for dd.

Since the test is 100% reads, you can assume that the page steal rate for
kswapd and direct reclaims is almost identical to the scan rate.

Test #3: 1 kswapd thread per node
dd sy dd_cpu kswapd0 kswapd1 throughput  dr    pgscan_kswapd pgscan_direct
10 4  26.07  28.56   27.03   7355924.40  0     459316976     0
16 7  34.94  69.33   69.66   10867895.20 0     872661643     0
22 10 36.03  93.99   99.33   13130613.60 489   1037654473    11268334
28 10 30.34  95.90   98.60   14601509.60 671   1182591373    15429142
34 14 34.77  97.50   99.23   16468012.00 10850 1069005644    249839515
40 17 36.32  91.49   97.11   17335987.60 18903 975417728     434467710
46 19 38.40  90.54   91.61   17705394.40 25369 855737040     582427973
52 22 40.88  83.97   83.70   17607680.40 31250 709532935     724282458
58 25 40.89  82.19   80.14   17976905.60 35060 657796473     804117540
64 28 41.77  73.49   75.20   18001910.00 39073 561813658     895289337
70 33 45.51  63.78   64.39   17061897.20 44523 379465571     1020726436
76 36 46.95  57.96   60.32   16964459.60 47717 291299464     1093172384
82 39 47.16  55.43   56.16   16949956.00 49479 247071062     1134163008
88 42 47.41  53.75   47.62   16930911.20 51521 195449924     1180442208
90 43 47.18  51.40   50.59   16864428.00 51618 190758156     1183203901

In the previous test where kswapd was not involved, the system-wide kernel
mode CPU consumption with 90 dd tasks was 16%. In this test CPU consumption
with 90 tasks is at 43%. With 52 cores, and two kswapd tasks (one per NUMA
node), kswapd can only be responsible for a little over 4% of the increase.
The rest is likely caused by 51,618 direct reclaims that scanned 1.2
billion pages over the five minute time period of the test.

Same test, more kswapd tasks:

Test #4: 4 kswapd threads per node
dd sy dd_cpu kswapd0 kswapd1 throughput  dr    pgscan_kswapd pgscan_direct
10 5  27.09  16.65   14.17   7842605.60  0     459105291     0
16 10 37.12  26.02   24.85   11352920.40 15    920527796     358515
22 11 36.94  37.13   35.82   13771869.60 0     1132169011     0
28 13 35.23  48.43   46.86   16089746.00 0     1312902070     0
34 15 33.37  53.02   55.69   18314856.40 0     1476169080     0
40 19 35.90  69.60   64.41   19836126.80 0     1629999149     0
46 22 36.82  88.55   57.20   20740216.40 0     1708478106     0
52 24 34.38  93.76   68.34   21758352.00 0     1794055559     0
58 24 30.51  79.20   82.33   22735594.00 0     1872794397     0
64 26 30.21  97.12   76.73   23302203.60 176   1916593721     4206821
70 33 32.92  92.91   92.87   23776588.00 3575  1817685086     85574159
76 37 31.62  91.20   89.83   24308196.80 4752  1812262569     113981763
82 29 25.53  93.23   92.33   24802791.20 306   2032093122     7350704
88 43 37.12  76.18   77.01   25145694.40 20310 1253204719     487048202
90 42 38.56  73.90   74.57   22516787.60 22774 1193637495     545463615

By increasing the number of kswapd threads, throughput increased by ~50%
while kernel mode CPU utilization decreased or stayed the same, likely due
to a decrease in the number of parallel tasks at any given time doing page
replacement.

Signed-off-by: Buddy Lumpkin <buddy.lumpkin@oracle.com>
Bug: 201263306
Link: https://lore.kernel.org/lkml/1522661062-39745-1-git-send-email-buddy.lumpkin@oracle.com
[charante@codeaurora.org]: Changes made to select number of kswapds through uapi
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
[quic_vjitta@quicinc.com]: Changes made to move multiple kswapd threads logic to vendor hooks
Signed-off-by: Vijayanand Jitta <quic_vjitta@quicinc.com>
(cherry picked from commit 0d61a651e4)

Change-Id: I8425cab7f40cbeaf65af0ea118c1a9ac7da0930e
[quic_vjitta@quicinc.com]: Resolved minor merge conflicts
Signed-off-by: Vijayanand Jitta <quic_vjitta@quicinc.com>
2023-04-26 17:01:51 +00:00
Vijayanand Jitta
d167f5b990 ANDROID: mm: Export kswapd function
To support multiple kswap threads vendor modules need
access to kswapd function. So, export it.

Bug: 201263306
Change-Id: I442612710835f39836a295e9d1936f86826ab960
Signed-off-by: Vijayanand Jitta <quic_vjitta@quicinc.com>
(cherry picked from commit 12972dd7bf)
2023-04-26 17:01:51 +00:00