Snap for 10064630 from 38b5a811e8 to android14-6.1-keystone-qcom-release

Change-Id: I625ce351310d936e589a3f9195d6254e6b6a555c
This commit is contained in:
Android Build Coastguard Worker 2023-05-04 07:15:39 +00:00
commit 98d56a589f
24 changed files with 479 additions and 103 deletions

View File

@ -322136,6 +322136,15 @@ function {
parameter_id: 0x33d0e528
parameter_id: 0xc9082b19
}
function {
id: 0x9b6e7eee
return_type_id: 0x6720d32f
parameter_id: 0x18bd6530
parameter_id: 0x33756485
parameter_id: 0x33756485
parameter_id: 0x33756485
parameter_id: 0x064d6086
}
function {
id: 0x9b6eb620
return_type_id: 0x6720d32f
@ -328545,6 +328554,12 @@ function {
parameter_id: 0x6720d32f
parameter_id: 0x6720d32f
}
function {
id: 0x9f5021bd
return_type_id: 0x6720d32f
parameter_id: 0x0b27dc43
parameter_id: 0x064d6086
}
function {
id: 0x9f5327f4
return_type_id: 0x6720d32f
@ -328679,6 +328694,16 @@ function {
parameter_id: 0x0beab59b
parameter_id: 0x054f691a
}
function {
id: 0x9f72f53e
return_type_id: 0x6720d32f
parameter_id: 0x0258f96e
parameter_id: 0x92233392
parameter_id: 0xbdd18903
parameter_id: 0xf435685e
parameter_id: 0x0258f96e
parameter_id: 0x295c7202
}
function {
id: 0x9f7a4e49
return_type_id: 0x6720d32f
@ -330449,6 +330474,13 @@ function {
parameter_id: 0x4585663f
parameter_id: 0x6d7f5ff6
}
function {
id: 0xb957d705
return_type_id: 0x6720d32f
parameter_id: 0x92233392
parameter_id: 0x18bd6530
parameter_id: 0xf435685e
}
function {
id: 0xb9640b60
return_type_id: 0x064d6086
@ -335967,6 +335999,15 @@ elf_symbol {
type_id: 0x92df7dfb
full_name: "__phy_modify"
}
elf_symbol {
id: 0xd9bec400
name: "__pkvm_load_el2_module"
is_defined: true
symbol_type: FUNCTION
crc: 0xd1d2c552
type_id: 0x9f5021bd
full_name: "__pkvm_load_el2_module"
}
elf_symbol {
id: 0x430bd907
name: "__platform_driver_probe"
@ -337947,6 +337988,15 @@ elf_symbol {
type_id: 0x9a36ff29
full_name: "__traceiter_android_vh_kswapd_per_node"
}
elf_symbol {
id: 0x61ea12b8
name: "__traceiter_android_vh_map_util_freq"
is_defined: true
symbol_type: FUNCTION
crc: 0xf7d7ec49
type_id: 0x9b6e7eee
full_name: "__traceiter_android_vh_map_util_freq"
}
elf_symbol {
id: 0xe17999f4
name: "__traceiter_android_vh_mutex_wait_finish"
@ -339837,6 +339887,15 @@ elf_symbol {
type_id: 0x18ccbd2c
full_name: "__tracepoint_android_vh_kswapd_per_node"
}
elf_symbol {
id: 0x00a5fe5e
name: "__tracepoint_android_vh_map_util_freq"
is_defined: true
symbol_type: OBJECT
crc: 0xf9624317
type_id: 0x18ccbd2c
full_name: "__tracepoint_android_vh_map_util_freq"
}
elf_symbol {
id: 0x76e879b6
name: "__tracepoint_android_vh_mutex_wait_finish"
@ -372017,6 +372076,51 @@ elf_symbol {
type_id: 0x9cd82046
full_name: "pktgen_xfrm_outer_mode_output"
}
elf_symbol {
id: 0x9e86d87a
name: "pkvm_iommu_driver_init"
is_defined: true
symbol_type: FUNCTION
crc: 0xf04a072e
type_id: 0xb957d705
full_name: "pkvm_iommu_driver_init"
}
elf_symbol {
id: 0x6f7172e0
name: "pkvm_iommu_finalize"
is_defined: true
symbol_type: FUNCTION
crc: 0xbc2fdabc
type_id: 0x8448d7e4
full_name: "pkvm_iommu_finalize"
}
elf_symbol {
id: 0xa74e4e73
name: "pkvm_iommu_register"
is_defined: true
symbol_type: FUNCTION
crc: 0x7dbf092d
type_id: 0x9f72f53e
full_name: "pkvm_iommu_register"
}
elf_symbol {
id: 0x508c3717
name: "pkvm_iommu_resume"
is_defined: true
symbol_type: FUNCTION
crc: 0x19a525d9
type_id: 0x9d16dd74
full_name: "pkvm_iommu_resume"
}
elf_symbol {
id: 0xe5abcddf
name: "pkvm_iommu_suspend"
is_defined: true
symbol_type: FUNCTION
crc: 0x976a4802
type_id: 0x9d16dd74
full_name: "pkvm_iommu_suspend"
}
elf_symbol {
id: 0xb30e2978
name: "platform_bus"
@ -391094,6 +391198,10 @@ symbols {
key: "__phy_modify"
value: 0x28bdd181
}
symbol {
key: "__pkvm_load_el2_module"
value: 0xd9bec400
}
symbol {
key: "__platform_driver_probe"
value: 0x430bd907
@ -391974,6 +392082,10 @@ symbols {
key: "__traceiter_android_vh_kswapd_per_node"
value: 0x18fde973
}
symbol {
key: "__traceiter_android_vh_map_util_freq"
value: 0x61ea12b8
}
symbol {
key: "__traceiter_android_vh_mutex_wait_finish"
value: 0xe17999f4
@ -392814,6 +392926,10 @@ symbols {
key: "__tracepoint_android_vh_kswapd_per_node"
value: 0x586a06d1
}
symbol {
key: "__tracepoint_android_vh_map_util_freq"
value: 0x00a5fe5e
}
symbol {
key: "__tracepoint_android_vh_mutex_wait_finish"
value: 0x76e879b6
@ -407114,6 +407230,26 @@ symbols {
key: "pktgen_xfrm_outer_mode_output"
value: 0xac156dd0
}
symbol {
key: "pkvm_iommu_driver_init"
value: 0x9e86d87a
}
symbol {
key: "pkvm_iommu_finalize"
value: 0x6f7172e0
}
symbol {
key: "pkvm_iommu_register"
value: 0xa74e4e73
}
symbol {
key: "pkvm_iommu_resume"
value: 0x508c3717
}
symbol {
key: "pkvm_iommu_suspend"
value: 0xe5abcddf
}
symbol {
key: "platform_bus"
value: 0xb30e2978

View File

@ -31,6 +31,7 @@
argv_split
arm64_use_ng_mappings
__arm_smccc_smc
__arm_smccc_sve_check
async_schedule_node_domain
async_synchronize_full_domain
atomic_notifier_call_chain
@ -1381,6 +1382,12 @@
pin_user_pages_fast
pin_user_pages_remote
pktgen_xfrm_outer_mode_output
pkvm_iommu_driver_init
pkvm_iommu_finalize
pkvm_iommu_register
pkvm_iommu_resume
pkvm_iommu_suspend
__pkvm_load_el2_module
platform_bus_type
platform_device_add
platform_device_add_data

View File

@ -889,6 +889,8 @@
dma_resv_fini
dma_resv_get_singleton
dma_resv_init
dma_resv_iter_first
dma_resv_iter_next
dma_resv_wait_timeout
dma_set_coherent_mask
dma_set_mask

View File

@ -110,10 +110,6 @@
__traceiter_android_vh_free_task
__tracepoint_android_vh_free_task
jiffies_64
__traceiter_android_rvh_after_enqueue_task
__traceiter_android_rvh_after_dequeue_task
__tracepoint_android_rvh_after_enqueue_task
__tracepoint_android_rvh_after_dequeue_task
__traceiter_android_rvh_check_preempt_tick
__traceiter_android_rvh_dequeue_entity
__traceiter_android_rvh_enqueue_entity
@ -129,3 +125,11 @@
wakeup_sources_read_unlock
wakeup_sources_walk_start
wakeup_sources_walk_next
#required by migt.ko
__traceiter_android_rvh_after_enqueue_task
__traceiter_android_rvh_after_dequeue_task
__traceiter_android_vh_map_util_freq
__tracepoint_android_rvh_after_enqueue_task
__tracepoint_android_rvh_after_dequeue_task
__tracepoint_android_vh_map_util_freq

View File

@ -142,6 +142,7 @@
#define MT_NORMAL_NC 2
#define MT_DEVICE_nGnRnE 3
#define MT_DEVICE_nGnRE 4
#define MT_NORMAL_iNC_oWB 5
/*
* Memory types for Stage-2 translation

View File

@ -583,6 +583,15 @@ static inline void set_pud_at(struct mm_struct *mm, unsigned long addr,
__pgprot_modify(prot, PTE_ATTRINDX_MASK, \
PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN)
/*
* Mark the prot value as outer cacheable and inner non-cacheable. Non-coherent
* devices on a system with support for a system or last level cache use these
* attributes to cache allocations in the system cache.
*/
#define pgprot_syscached(prot) \
__pgprot_modify(prot, PTE_ATTRINDX_MASK, \
PTE_ATTRINDX(MT_NORMAL_iNC_oWB) | PTE_PXN | PTE_UXN)
#define __HAVE_PHYS_MEM_ACCESS_PROT
struct file;
extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,

View File

@ -663,6 +663,7 @@
#define MAIR_ATTR_NORMAL_TAGGED UL(0xf0)
#define MAIR_ATTR_NORMAL UL(0xff)
#define MAIR_ATTR_MASK UL(0xff)
#define MAIR_ATTR_NORMAL_iNC_oWB UL(0xf4)
/* Position the attr at the correct index */
#define MAIR_ATTRIDX(attr, idx) ((attr) << ((idx) * 8))

View File

@ -68,7 +68,8 @@
MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRE, MT_DEVICE_nGnRE) | \
MAIR_ATTRIDX(MAIR_ATTR_NORMAL_NC, MT_NORMAL_NC) | \
MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL) | \
MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL_TAGGED))
MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL_TAGGED) | \
MAIR_ATTRIDX(MAIR_ATTR_NORMAL_iNC_oWB, MT_NORMAL_iNC_oWB))
#ifdef CONFIG_CPU_PM
/**

View File

@ -9,7 +9,11 @@ POST_DEFCONFIG_CMDS="rm ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/${DEFCONFIG
# needed for DT overlay support
DTC_FLAGS="-@"
MAKE_GOALS="${MAKE_GOALS}
MAKE_GOALS="
Image
modules
Image.lz4
Image.gz
dtbs
"

View File

@ -2,7 +2,9 @@
. ${ROOT_DIR}/${KERNEL_DIR}/build.config.aarch64
. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki
MAKE_GOALS="${MAKE_GOALS}
MAKE_GOALS="
Image
modules
Image.lz4
Image.gz
"

View File

@ -2,7 +2,9 @@
. ${ROOT_DIR}/${KERNEL_DIR}/build.config.riscv64
. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki
MAKE_GOALS="${MAKE_GOALS}
MAKE_GOALS="
Image
modules
Image.lz4
Image.gz
"

View File

@ -12,7 +12,9 @@ POST_DEFCONFIG_CMDS="rm ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/${DEFCONFIG
DTS_EXT_DIR=common-modules/virtual-device
DTC_INCLUDE=${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/boot/dts/rockchip
MAKE_GOALS="${MAKE_GOALS}
MAKE_GOALS="
Image
modules
rk3399-rock-pi-4b.dtb
"

View File

@ -613,6 +613,10 @@ static int dma_info_to_prot(enum dma_data_direction dir, bool coherent,
if (attrs & DMA_ATTR_PRIVILEGED)
prot |= IOMMU_PRIV;
if (attrs & DMA_ATTR_SYS_CACHE)
prot |= IOMMU_SYS_CACHE;
if (attrs & DMA_ATTR_SYS_CACHE_NWA)
prot |= IOMMU_SYS_CACHE_NWA;
switch (dir) {
case DMA_BIDIRECTIONAL:

View File

@ -118,10 +118,14 @@
#define ARM_LPAE_MAIR_ATTR_NC 0x44
#define ARM_LPAE_MAIR_ATTR_INC_OWBRWA 0xf4
#define ARM_LPAE_MAIR_ATTR_WBRWA 0xff
#define ARM_LPAE_MAIR_ATTR_INC_OWBRANWA 0xe4ULL
#define ARM_LPAE_MAIR_ATTR_IWBRWA_OWBRANWA 0xefULL
#define ARM_LPAE_MAIR_ATTR_IDX_NC 0
#define ARM_LPAE_MAIR_ATTR_IDX_CACHE 1
#define ARM_LPAE_MAIR_ATTR_IDX_DEV 2
#define ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE 3
#define ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE_NWA 4
#define ARM_LPAE_MAIR_ATTR_IDX_ICACHE_OCACHE_NWA 5
#define ARM_MALI_LPAE_TTBR_ADRMODE_TABLE (3u << 0)
#define ARM_MALI_LPAE_TTBR_READ_INNER BIT(2)
@ -433,9 +437,19 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,
if (prot & IOMMU_MMIO)
pte |= (ARM_LPAE_MAIR_ATTR_IDX_DEV
<< ARM_LPAE_PTE_ATTRINDX_SHIFT);
else if ((prot & IOMMU_CACHE) && (prot & IOMMU_SYS_CACHE_NWA))
pte |= (ARM_LPAE_MAIR_ATTR_IDX_ICACHE_OCACHE_NWA
<< ARM_LPAE_PTE_ATTRINDX_SHIFT);
/* IOMMU_CACHE + IOMMU_SYS_CACHE equivalent to IOMMU_CACHE */
else if (prot & IOMMU_CACHE)
pte |= (ARM_LPAE_MAIR_ATTR_IDX_CACHE
<< ARM_LPAE_PTE_ATTRINDX_SHIFT);
else if (prot & IOMMU_SYS_CACHE)
pte |= (ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE
<< ARM_LPAE_PTE_ATTRINDX_SHIFT);
else if (prot & IOMMU_SYS_CACHE_NWA)
pte |= (ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE_NWA
<< ARM_LPAE_PTE_ATTRINDX_SHIFT);
}
/*
@ -891,7 +905,11 @@ arm_64_lpae_alloc_pgtable_s1(struct io_pgtable_cfg *cfg, void *cookie)
(ARM_LPAE_MAIR_ATTR_DEVICE
<< ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_DEV)) |
(ARM_LPAE_MAIR_ATTR_INC_OWBRWA
<< ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE));
<< ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE)) |
(ARM_LPAE_MAIR_ATTR_INC_OWBRANWA
<< ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE_NWA)) |
(ARM_LPAE_MAIR_ATTR_IWBRWA_OWBRANWA
<< ARM_LPAE_MAIR_ATTR_SHIFT(ARM_LPAE_MAIR_ATTR_IDX_ICACHE_OCACHE_NWA));
cfg->arm_lpae_s1_cfg.mair = reg;

View File

@ -28,11 +28,14 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
#define UID_HASH_BITS 10
#define UID_HASH_NUMS (1 << UID_HASH_BITS)
DECLARE_HASHTABLE(hash_table, UID_HASH_BITS);
/*
* uid_lock[bkt] ensure consistency of hash_table[bkt]
*/
struct rt_mutex uid_lock[UID_HASH_NUMS];
static DEFINE_RT_MUTEX(uid_lock);
static struct proc_dir_entry *cpu_parent;
static struct proc_dir_entry *io_parent;
static struct proc_dir_entry *proc_parent;
@ -77,12 +80,38 @@ struct uid_entry {
#endif
};
static u64 compute_write_bytes(struct task_struct *task)
static inline void lock_uid(uid_t uid)
{
if (task->ioac.write_bytes <= task->ioac.cancelled_write_bytes)
rt_mutex_lock(&uid_lock[hash_min(uid, HASH_BITS(hash_table))]);
}
static inline void unlock_uid(uid_t uid)
{
rt_mutex_unlock(&uid_lock[hash_min(uid, HASH_BITS(hash_table))]);
}
static inline int trylock_uid(uid_t uid)
{
return rt_mutex_trylock(
&uid_lock[hash_min(uid, HASH_BITS(hash_table))]);
}
static inline void lock_uid_by_bkt(u32 bkt)
{
rt_mutex_lock(&uid_lock[bkt]);
}
static inline void unlock_uid_by_bkt(u32 bkt)
{
rt_mutex_unlock(&uid_lock[bkt]);
}
static u64 compute_write_bytes(struct task_io_accounting *ioac)
{
if (ioac->write_bytes <= ioac->cancelled_write_bytes)
return 0;
return task->ioac.write_bytes - task->ioac.cancelled_write_bytes;
return ioac->write_bytes - ioac->cancelled_write_bytes;
}
static void compute_io_bucket_stats(struct io_stats *io_bucket,
@ -239,17 +268,16 @@ static void set_io_uid_tasks_zero(struct uid_entry *uid_entry)
}
}
static void add_uid_tasks_io_stats(struct uid_entry *uid_entry,
struct task_struct *task, int slot)
static void add_uid_tasks_io_stats(struct task_entry *task_entry,
struct task_io_accounting *ioac, int slot)
{
struct task_entry *task_entry = find_or_register_task(uid_entry, task);
struct io_stats *task_io_slot = &task_entry->io[slot];
task_io_slot->read_bytes += task->ioac.read_bytes;
task_io_slot->write_bytes += compute_write_bytes(task);
task_io_slot->rchar += task->ioac.rchar;
task_io_slot->wchar += task->ioac.wchar;
task_io_slot->fsync += task->ioac.syscfs;
task_io_slot->read_bytes += ioac->read_bytes;
task_io_slot->write_bytes += compute_write_bytes(ioac);
task_io_slot->rchar += ioac->rchar;
task_io_slot->wchar += ioac->wchar;
task_io_slot->fsync += ioac->syscfs;
}
static void compute_io_uid_tasks(struct uid_entry *uid_entry)
@ -290,8 +318,6 @@ static void show_io_uid_tasks(struct seq_file *m, struct uid_entry *uid_entry)
#else
static void remove_uid_tasks(struct uid_entry *uid_entry) {};
static void set_io_uid_tasks_zero(struct uid_entry *uid_entry) {};
static void add_uid_tasks_io_stats(struct uid_entry *uid_entry,
struct task_struct *task, int slot) {};
static void compute_io_uid_tasks(struct uid_entry *uid_entry) {};
static void show_io_uid_tasks(struct seq_file *m,
struct uid_entry *uid_entry) {}
@ -335,24 +361,29 @@ static int uid_cputime_show(struct seq_file *m, void *v)
struct user_namespace *user_ns = current_user_ns();
u64 utime;
u64 stime;
unsigned long bkt;
u32 bkt;
uid_t uid;
rt_mutex_lock(&uid_lock);
hash_for_each(hash_table, bkt, uid_entry, hash) {
uid_entry->active_stime = 0;
uid_entry->active_utime = 0;
for (bkt = 0, uid_entry = NULL; uid_entry == NULL &&
bkt < HASH_SIZE(hash_table); bkt++) {
lock_uid_by_bkt(bkt);
hlist_for_each_entry(uid_entry, &hash_table[bkt], hash) {
uid_entry->active_stime = 0;
uid_entry->active_utime = 0;
}
unlock_uid_by_bkt(bkt);
}
rcu_read_lock();
do_each_thread(temp, task) {
uid = from_kuid_munged(user_ns, task_uid(task));
lock_uid(uid);
if (!uid_entry || uid_entry->uid != uid)
uid_entry = find_or_register_uid(uid);
if (!uid_entry) {
rcu_read_unlock();
rt_mutex_unlock(&uid_lock);
unlock_uid(uid);
pr_err("%s: failed to find the uid_entry for uid %d\n",
__func__, uid);
return -ENOMEM;
@ -363,19 +394,24 @@ static int uid_cputime_show(struct seq_file *m, void *v)
uid_entry->active_utime += utime;
uid_entry->active_stime += stime;
}
unlock_uid(uid);
} while_each_thread(temp, task);
rcu_read_unlock();
hash_for_each(hash_table, bkt, uid_entry, hash) {
u64 total_utime = uid_entry->utime +
uid_entry->active_utime;
u64 total_stime = uid_entry->stime +
uid_entry->active_stime;
seq_printf(m, "%d: %llu %llu\n", uid_entry->uid,
ktime_to_us(total_utime), ktime_to_us(total_stime));
for (bkt = 0, uid_entry = NULL; uid_entry == NULL &&
bkt < HASH_SIZE(hash_table); bkt++) {
lock_uid_by_bkt(bkt);
hlist_for_each_entry(uid_entry, &hash_table[bkt], hash) {
u64 total_utime = uid_entry->utime +
uid_entry->active_utime;
u64 total_stime = uid_entry->stime +
uid_entry->active_stime;
seq_printf(m, "%d: %llu %llu\n", uid_entry->uid,
ktime_to_us(total_utime), ktime_to_us(total_stime));
}
unlock_uid_by_bkt(bkt);
}
rt_mutex_unlock(&uid_lock);
return 0;
}
@ -423,9 +459,8 @@ static ssize_t uid_remove_write(struct file *file,
return -EINVAL;
}
rt_mutex_lock(&uid_lock);
for (; uid_start <= uid_end; uid_start++) {
lock_uid(uid_start);
hash_for_each_possible_safe(hash_table, uid_entry, tmp,
hash, (uid_t)uid_start) {
if (uid_start == uid_entry->uid) {
@ -434,9 +469,9 @@ static ssize_t uid_remove_write(struct file *file,
kfree(uid_entry);
}
}
unlock_uid(uid_start);
}
rt_mutex_unlock(&uid_lock);
return count;
}
@ -446,56 +481,79 @@ static const struct proc_ops uid_remove_fops = {
.proc_write = uid_remove_write,
};
static void __add_uid_io_stats(struct uid_entry *uid_entry,
struct task_io_accounting *ioac, int slot)
{
struct io_stats *io_slot = &uid_entry->io[slot];
io_slot->read_bytes += ioac->read_bytes;
io_slot->write_bytes += compute_write_bytes(ioac);
io_slot->rchar += ioac->rchar;
io_slot->wchar += ioac->wchar;
io_slot->fsync += ioac->syscfs;
}
static void add_uid_io_stats(struct uid_entry *uid_entry,
struct task_struct *task, int slot)
{
struct io_stats *io_slot = &uid_entry->io[slot];
struct task_entry *task_entry __maybe_unused;
/* avoid double accounting of dying threads */
if (slot != UID_STATE_DEAD_TASKS && (task->flags & PF_EXITING))
return;
io_slot->read_bytes += task->ioac.read_bytes;
io_slot->write_bytes += compute_write_bytes(task);
io_slot->rchar += task->ioac.rchar;
io_slot->wchar += task->ioac.wchar;
io_slot->fsync += task->ioac.syscfs;
add_uid_tasks_io_stats(uid_entry, task, slot);
#ifdef CONFIG_UID_SYS_STATS_DEBUG
task_entry = find_or_register_task(uid_entry, task);
add_uid_tasks_io_stats(task_entry, &task->ioac, slot);
#endif
__add_uid_io_stats(uid_entry, &task->ioac, slot);
}
static void update_io_stats_all_locked(void)
static void update_io_stats_all(void)
{
struct uid_entry *uid_entry = NULL;
struct task_struct *task, *temp;
struct user_namespace *user_ns = current_user_ns();
unsigned long bkt;
u32 bkt;
uid_t uid;
hash_for_each(hash_table, bkt, uid_entry, hash) {
memset(&uid_entry->io[UID_STATE_TOTAL_CURR], 0,
sizeof(struct io_stats));
set_io_uid_tasks_zero(uid_entry);
for (bkt = 0, uid_entry = NULL; uid_entry == NULL && bkt < HASH_SIZE(hash_table);
bkt++) {
lock_uid_by_bkt(bkt);
hlist_for_each_entry(uid_entry, &hash_table[bkt], hash) {
memset(&uid_entry->io[UID_STATE_TOTAL_CURR], 0,
sizeof(struct io_stats));
set_io_uid_tasks_zero(uid_entry);
}
unlock_uid_by_bkt(bkt);
}
rcu_read_lock();
do_each_thread(temp, task) {
uid = from_kuid_munged(user_ns, task_uid(task));
lock_uid(uid);
if (!uid_entry || uid_entry->uid != uid)
uid_entry = find_or_register_uid(uid);
if (!uid_entry)
if (!uid_entry) {
unlock_uid(uid);
continue;
}
add_uid_io_stats(uid_entry, task, UID_STATE_TOTAL_CURR);
unlock_uid(uid);
} while_each_thread(temp, task);
rcu_read_unlock();
hash_for_each(hash_table, bkt, uid_entry, hash) {
compute_io_bucket_stats(&uid_entry->io[uid_entry->state],
&uid_entry->io[UID_STATE_TOTAL_CURR],
&uid_entry->io[UID_STATE_TOTAL_LAST],
&uid_entry->io[UID_STATE_DEAD_TASKS]);
compute_io_uid_tasks(uid_entry);
for (bkt = 0, uid_entry = NULL; uid_entry == NULL && bkt < HASH_SIZE(hash_table);
bkt++) {
lock_uid_by_bkt(bkt);
hlist_for_each_entry(uid_entry, &hash_table[bkt], hash) {
compute_io_bucket_stats(&uid_entry->io[uid_entry->state],
&uid_entry->io[UID_STATE_TOTAL_CURR],
&uid_entry->io[UID_STATE_TOTAL_LAST],
&uid_entry->io[UID_STATE_DEAD_TASKS]);
compute_io_uid_tasks(uid_entry);
}
unlock_uid_by_bkt(bkt);
}
}
@ -527,14 +585,15 @@ static void update_io_stats_uid_locked(struct uid_entry *uid_entry)
static int uid_io_show(struct seq_file *m, void *v)
{
struct uid_entry *uid_entry;
unsigned long bkt;
u32 bkt;
rt_mutex_lock(&uid_lock);
update_io_stats_all();
for (bkt = 0, uid_entry = NULL; uid_entry == NULL && bkt < HASH_SIZE(hash_table);
bkt++) {
update_io_stats_all_locked();
hash_for_each(hash_table, bkt, uid_entry, hash) {
seq_printf(m, "%d %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
lock_uid_by_bkt(bkt);
hlist_for_each_entry(uid_entry, &hash_table[bkt], hash) {
seq_printf(m, "%d %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
uid_entry->uid,
uid_entry->io[UID_STATE_FOREGROUND].rchar,
uid_entry->io[UID_STATE_FOREGROUND].wchar,
@ -547,10 +606,11 @@ static int uid_io_show(struct seq_file *m, void *v)
uid_entry->io[UID_STATE_FOREGROUND].fsync,
uid_entry->io[UID_STATE_BACKGROUND].fsync);
show_io_uid_tasks(m, uid_entry);
show_io_uid_tasks(m, uid_entry);
}
unlock_uid_by_bkt(bkt);
}
rt_mutex_unlock(&uid_lock);
return 0;
}
@ -594,16 +654,15 @@ static ssize_t uid_procstat_write(struct file *file,
if (state != UID_STATE_BACKGROUND && state != UID_STATE_FOREGROUND)
return -EINVAL;
rt_mutex_lock(&uid_lock);
lock_uid(uid);
uid_entry = find_or_register_uid(uid);
if (!uid_entry) {
rt_mutex_unlock(&uid_lock);
unlock_uid(uid);
return -EINVAL;
}
if (uid_entry->state == state) {
rt_mutex_unlock(&uid_lock);
unlock_uid(uid);
return count;
}
@ -611,7 +670,7 @@ static ssize_t uid_procstat_write(struct file *file,
uid_entry->state = state;
rt_mutex_unlock(&uid_lock);
unlock_uid(uid);
return count;
}
@ -622,6 +681,48 @@ static const struct proc_ops uid_procstat_fops = {
.proc_write = uid_procstat_write,
};
struct update_stats_work {
struct work_struct work;
uid_t uid;
#ifdef CONFIG_UID_SYS_STATS_DEBUG
struct task_struct *task;
#endif
struct task_io_accounting ioac;
u64 utime;
u64 stime;
};
static void update_stats_workfn(struct work_struct *work)
{
struct update_stats_work *usw =
container_of(work, struct update_stats_work, work);
struct uid_entry *uid_entry;
struct task_entry *task_entry __maybe_unused;
lock_uid(usw->uid);
uid_entry = find_uid_entry(usw->uid);
if (!uid_entry)
goto exit;
uid_entry->utime += usw->utime;
uid_entry->stime += usw->stime;
#ifdef CONFIG_UID_SYS_STATS_DEBUG
task_entry = find_task_entry(uid_entry, usw->task);
if (!task_entry)
goto exit;
add_uid_tasks_io_stats(task_entry, &usw->ioac,
UID_STATE_DEAD_TASKS);
#endif
__add_uid_io_stats(uid_entry, &usw->ioac, UID_STATE_DEAD_TASKS);
exit:
unlock_uid(usw->uid);
#ifdef CONFIG_UID_SYS_STATS_DEBUG
put_task_struct(usw->task);
#endif
kfree(usw);
}
static int process_notifier(struct notifier_block *self,
unsigned long cmd, void *v)
{
@ -633,8 +734,28 @@ static int process_notifier(struct notifier_block *self,
if (!task)
return NOTIFY_OK;
rt_mutex_lock(&uid_lock);
uid = from_kuid_munged(current_user_ns(), task_uid(task));
if (!trylock_uid(uid)) {
struct update_stats_work *usw;
usw = kmalloc(sizeof(struct update_stats_work), GFP_KERNEL);
if (usw) {
INIT_WORK(&usw->work, update_stats_workfn);
usw->uid = uid;
#ifdef CONFIG_UID_SYS_STATS_DEBUG
usw->task = get_task_struct(task);
#endif
/*
* Copy task->ioac since task might be destroyed before
* the work is later performed.
*/
usw->ioac = task->ioac;
task_cputime_adjusted(task, &usw->utime, &usw->stime);
schedule_work(&usw->work);
}
return NOTIFY_OK;
}
uid_entry = find_or_register_uid(uid);
if (!uid_entry) {
pr_err("%s: failed to find uid %d\n", __func__, uid);
@ -648,7 +769,7 @@ static int process_notifier(struct notifier_block *self,
add_uid_io_stats(uid_entry, task, UID_STATE_DEAD_TASKS);
exit:
rt_mutex_unlock(&uid_lock);
unlock_uid(uid);
return NOTIFY_OK;
}
@ -656,9 +777,18 @@ static struct notifier_block process_notifier_block = {
.notifier_call = process_notifier,
};
static void init_hash_table_and_lock(void)
{
int i;
hash_init(hash_table);
for (i = 0; i < UID_HASH_NUMS; i++)
rt_mutex_init(&uid_lock[i]);
}
static int __init proc_uid_sys_stats_init(void)
{
hash_init(hash_table);
init_hash_table_and_lock();
cpu_parent = proc_mkdir("uid_cputime", NULL);
if (!cpu_parent) {

View File

@ -1186,39 +1186,36 @@ int fuse_handle_backing(struct fuse_entry_bpf *feb, struct inode **backing_inode
int fuse_handle_bpf_prog(struct fuse_entry_bpf *feb, struct inode *parent,
struct bpf_prog **bpf)
{
struct bpf_prog *new_bpf;
/* Parent isn't presented, but we want to keep
* Don't touch bpf program at all in this case
*/
if (feb->out.bpf_action == FUSE_ACTION_KEEP && !parent)
return 0;
struct bpf_prog *new_bpf = NULL;
switch (feb->out.bpf_action) {
case FUSE_ACTION_KEEP: {
struct fuse_inode *pi = get_fuse_inode(parent);
/* Parent isn't presented, but we want to keep
* Don't touch bpf program at all in this case
*/
if (!parent)
return 0;
new_bpf = pi->bpf;
new_bpf = get_fuse_inode(parent)->bpf;
if (new_bpf)
bpf_prog_inc(new_bpf);
break;
}
case FUSE_ACTION_REMOVE:
new_bpf = NULL;
break;
case FUSE_ACTION_REPLACE: {
struct file *bpf_file = feb->bpf_file;
struct bpf_prog *bpf_prog = ERR_PTR(-EINVAL);
if (bpf_file && !IS_ERR(bpf_file))
bpf_prog = fuse_get_bpf_prog(bpf_file);
if (!bpf_file)
return -EINVAL;
if (IS_ERR(bpf_file))
return PTR_ERR(bpf_file);
if (IS_ERR(bpf_prog))
return PTR_ERR(bpf_prog);
new_bpf = bpf_prog;
new_bpf = fuse_get_bpf_prog(bpf_file);
if (IS_ERR(new_bpf))
return PTR_ERR(new_bpf);
break;
}
@ -1227,11 +1224,14 @@ int fuse_handle_bpf_prog(struct fuse_entry_bpf *feb, struct inode *parent,
}
/* Cannot change existing program */
if (*bpf) {
if (*bpf && new_bpf) {
bpf_prog_put(new_bpf);
return new_bpf == *bpf ? 0 : -EINVAL;
}
if (*bpf)
bpf_prog_put(*bpf);
*bpf = new_bpf;
return 0;
}

View File

@ -291,6 +291,14 @@ void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
#define pgprot_dmacoherent(prot) pgprot_noncached(prot)
#endif
/*
* If there is no system cache pgprot, then fallback to dmacoherent
* pgprot, as the expectation is that the device is not coherent.
*/
#ifndef pgprot_syscached
#define pgprot_syscached(prot) pgprot_dmacoherent(prot)
#endif
pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs);
#else
static inline pgprot_t dma_pgprot(struct device *dev, pgprot_t prot,

View File

@ -61,6 +61,23 @@
*/
#define DMA_ATTR_PRIVILEGED (1UL << 9)
/*
* DMA_ATTR_SYS_CACHE: used to indicate that the buffer should be mapped with
* the correct memory attributes so that it can be cached in the system or last
* level cache. This is useful for buffers that are being mapped for devices
* that are non-coherent, but can use the system cache.
*/
#define DMA_ATTR_SYS_CACHE (1UL << 10)
/*
* DMA_ATTR_SYS_CACHE_NWA: used to indicate that the buffer should be mapped
* with the correct memory attributes so that it can be cached in the system or
* last level cache, with a no write allocate cache policy. This is useful for
* buffers that are being mapped for devices that are non-coherent, but can use
* the system cache.
*/
#define DMA_ATTR_SYS_CACHE_NWA (1UL << 11)
/*
* A dma_addr_t can hold any valid DMA or bus address for the platform. It can
* be given to a device to use as a DMA source or target. It is specific to a

View File

@ -31,6 +31,18 @@
* if the IOMMU page table format is equivalent.
*/
#define IOMMU_PRIV (1 << 5)
/*
* Allow caching in a transparent outer level of cache, also known as
* the last-level or system cache, with a read/write allocation policy.
* Does not depend on IOMMU_CACHE. Incompatible with IOMMU_SYS_CACHE_NWA.
*/
#define IOMMU_SYS_CACHE (1 << 6)
/*
* Allow caching in a transparent outer level of cache, also known as
* the last-level or system cache, with a read allocation policy.
* Does not depend on IOMMU_CACHE. Incompatible with IOMMU_SYS_CACHE.
*/
#define IOMMU_SYS_CACHE_NWA (1 << 7)
struct iommu_ops;
struct iommu_group;

View File

@ -332,6 +332,11 @@ DECLARE_HOOK(android_vh_sched_pelt_multiplier,
TP_PROTO(unsigned int old, unsigned int cur, int *ret),
TP_ARGS(old, cur, ret));
DECLARE_HOOK(android_vh_map_util_freq,
TP_PROTO(unsigned long util, unsigned long freq,
unsigned long cap, unsigned long *next_freq),
TP_ARGS(util, freq, cap, next_freq));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_SCHED_H */

View File

@ -420,6 +420,9 @@ pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs)
if (attrs & DMA_ATTR_WRITE_COMBINE)
return pgprot_writecombine(prot);
#endif
if (attrs & DMA_ATTR_SYS_CACHE ||
attrs & DMA_ATTR_SYS_CACHE_NWA)
return pgprot_syscached(prot);
return pgprot_dmacoherent(prot);
}
#endif /* CONFIG_MMU */

View File

@ -6,6 +6,8 @@
* Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
*/
#include <trace/hooks/sched.h>
#define IOWAIT_BOOST_MIN (SCHED_CAPACITY_SCALE / 8)
struct sugov_tunables {
@ -143,9 +145,14 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,
struct cpufreq_policy *policy = sg_policy->policy;
unsigned int freq = arch_scale_freq_invariant() ?
policy->cpuinfo.max_freq : policy->cur;
unsigned long next_freq = 0;
util = map_util_perf(util);
freq = map_util_freq(util, freq, max);
trace_android_vh_map_util_freq(util, freq, max, &next_freq);
if (next_freq)
freq = next_freq;
else
freq = map_util_freq(util, freq, max);
if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update)
return sg_policy->next_freq;

View File

@ -86,3 +86,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_wake_flags);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_new_ilb);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_energy_efficient_cpu);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_pelt_multiplier);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_map_util_freq);

View File

@ -1023,6 +1023,7 @@ static int bpf_test_xattr(const char *mount_dir)
const size_t xattr_size = sizeof(xattr_value);
char xattr_value_ret[256];
ssize_t xattr_size_ret;
ssize_t xattr_size_ret_se;
int result = TEST_FAILURE;
int fd = -1;
int src_fd = -1;
@ -1053,9 +1054,8 @@ static int bpf_test_xattr(const char *mount_dir)
TESTSYSCALL(s_listxattr(s_path(s(mount_dir), s(file_name)),
xattr_value_ret, sizeof(xattr_value_ret),
&xattr_size_ret));
&xattr_size_ret_se));
TESTEQUAL(bpf_test_trace("listxattr"), 0);
TESTEQUAL(xattr_size_ret, 0);
TESTSYSCALL(s_setxattr(s_path(s(mount_dir), s(file_name)), xattr_name,
xattr_value, xattr_size, 0));
@ -1065,8 +1065,8 @@ static int bpf_test_xattr(const char *mount_dir)
xattr_value_ret, sizeof(xattr_value_ret),
&xattr_size_ret));
TESTEQUAL(bpf_test_trace("listxattr"), 0);
TESTEQUAL(xattr_size_ret, sizeof(xattr_name));
TESTEQUAL(strcmp(xattr_name, xattr_value_ret), 0);
TESTEQUAL(xattr_size_ret - xattr_size_ret_se, sizeof(xattr_name));
TESTEQUAL(strcmp(xattr_name, xattr_value_ret + xattr_size_ret_se), 0);
TESTSYSCALL(s_getxattr(s_path(s(mount_dir), s(file_name)), xattr_name,
xattr_value_ret, sizeof(xattr_value_ret),