Unverified Commit f3ff7ed6 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!252 hulk backport patchs for ascend feature

Merge Pull Request from: @zhangjian210 
 
This patchset aims to backport patches from hulk about Ascend, It includes some patches as follow:

Sharepool Bugfix:
1 clean static check warning
2 Fix add group failed with errno 28
3 Fix some pages will not be freed when alloc some pages using sharepool, 
  and return error on the first allocation failed whithout releasing the pages 
  allocated before.
4 Fixing for can't alloc memory from CDM node using CPU-set
5 Fixing for since the current condition ignores the cpuset enforcement by adding
  __GFP_THISNODEi to the gfp_mask, this will result in allocations that    
  specify __GFP_THISNODE and non-cdm nodes not subject to cpuset restrictions.

Gic Bugfix:
1 Fixing for when enable CONFIG_ASCEND_INIT_ALL_GICR, the cpu num is too large for
  its_inc_lpi_count()

Boot parameter:
1 Add ascend_enable_all parameter for enabling all ascend feature

Export symbols:
pm_autosleep_set_state
free_workqueue_attrs
alloc_workqueue_attrs
apply_workqueue_attrs
oom_type_notifier_call
map_kernel_range
__get_vm_area_caller
__vmalloc_node_range 
 
Link:https://gitee.com/openeuler/kernel/pulls/252

 
Reviewed-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents 0fd6bc1b 4e018573
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1729,7 +1729,7 @@ static void cpu_enable_e0pd(struct arm64_cpu_capabilities const *cap)
#endif /* CONFIG_ARM64_E0PD */

#ifdef CONFIG_ARM64_PSEUDO_NMI
static bool enable_pseudo_nmi;
bool enable_pseudo_nmi;

static int __init early_enable_pseudo_nmi(char *p)
{
+36 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@
#include <linux/hugetlb.h>
#include <linux/acpi_iort.h>
#include <linux/pin_mem.h>
#include <linux/suspend.h>
#include <linux/nmi.h>

#include <asm/boot.h>
#include <asm/fixmap.h>
@@ -724,3 +726,37 @@ void dump_mem_limit(void)
		pr_emerg("Memory Limit: none\n");
	}
}

void ascend_enable_all_features(void)
{
	if (IS_ENABLED(CONFIG_ASCEND_DVPP_MMAP))
		enable_mmap_dvpp = 1;

#ifdef CONFIG_ASCEND_CHARGE_MIGRATE_HUGEPAGES
	extern int enable_charge_mighp;

	enable_charge_mighp = 1;
#endif

#ifdef CONFIG_SUSPEND
	mem_sleep_current = PM_SUSPEND_ON;
#endif

#ifdef CONFIG_ARM64_PSEUDO_NMI
	extern bool enable_pseudo_nmi;

	enable_pseudo_nmi = true;
#endif

#ifdef CONFIG_CORELOCKUP_DETECTOR
	enable_corelockup_detector = true;
#endif
}

static int __init ascend_enable_setup(char *__unused)
{
	ascend_enable_all_features();

	return 0;
}
early_param("ascend_enable_all", ascend_enable_setup);
+10 −0
Original line number Diff line number Diff line
@@ -1543,6 +1543,11 @@ static __maybe_unused u32 its_read_lpi_count(struct irq_data *d, int cpu)

static void its_inc_lpi_count(struct irq_data *d, int cpu)
{
#ifdef CONFIG_ASCEND_INIT_ALL_GICR
	if (cpu >= nr_cpu_ids)
		return;
#endif

	if (irqd_affinity_is_managed(d))
		atomic_inc(&per_cpu_ptr(&cpu_lpi_count, cpu)->managed);
	else
@@ -1551,6 +1556,11 @@ static void its_inc_lpi_count(struct irq_data *d, int cpu)

static void its_dec_lpi_count(struct irq_data *d, int cpu)
{
#ifdef CONFIG_ASCEND_INIT_ALL_GICR
	if (cpu >= nr_cpu_ids)
		return;
#endif

	if (irqd_affinity_is_managed(d))
		atomic_dec(&per_cpu_ptr(&cpu_lpi_count, cpu)->managed);
	else
+14 −14
Original line number Diff line number Diff line
@@ -249,9 +249,9 @@ static inline void sp_init_mm(struct mm_struct *mm)
/*
 * Those interfaces are exported for modules
 */
extern int mg_sp_group_add_task(int pid, unsigned long prot, int spg_id);
extern int mg_sp_group_del_task(int pid, int spg_id);
extern int mg_sp_group_id_by_pid(int pid, int *spg_ids, int *num);
extern int mg_sp_group_add_task(int tgid, unsigned long prot, int spg_id);
extern int mg_sp_group_del_task(int tgid, int spg_id);
extern int mg_sp_group_id_by_pid(int tgid, int *spg_ids, int *num);
extern int proc_sp_group_state(struct seq_file *m, struct pid_namespace *ns,
			struct pid *pid, struct task_struct *task);

@@ -259,8 +259,8 @@ extern void *mg_sp_alloc(unsigned long size, unsigned long sp_flags, int spg_id)
extern int mg_sp_free(unsigned long addr, int id);

extern void *mg_sp_make_share_k2u(unsigned long kva, unsigned long size,
			unsigned long sp_flags, int pid, int spg_id);
extern void *mg_sp_make_share_u2k(unsigned long uva, unsigned long size, int pid);
			unsigned long sp_flags, int tgid, int spg_id);
extern void *mg_sp_make_share_u2k(unsigned long uva, unsigned long size, int tgid);
extern int mg_sp_unshare(unsigned long va, unsigned long size, int spg_id);

extern int mg_sp_walk_page_range(unsigned long uva, unsigned long size,
@@ -271,14 +271,14 @@ extern void mg_sp_walk_page_free(struct sp_walk_data *sp_walk_data);
extern int sp_register_notifier(struct notifier_block *nb);
extern int sp_unregister_notifier(struct notifier_block *nb);

extern bool mg_sp_config_dvpp_range(size_t start, size_t size, int device_id, int pid);
extern bool mg_sp_config_dvpp_range(size_t start, size_t size, int device_id, int tgid);

extern bool mg_is_sharepool_addr(unsigned long addr);

extern int mg_sp_id_of_current(void);

extern void sp_area_drop(struct vm_area_struct *vma);
extern int sp_group_exit(struct mm_struct *mm);
extern int sp_group_exit(void);
extern void sp_group_post_exit(struct mm_struct *mm);
vm_fault_t sharepool_no_page(struct mm_struct *mm,
			     struct vm_area_struct *vma,
@@ -321,17 +321,17 @@ static inline bool is_vmalloc_sharepool(unsigned long vm_flags)

#else /* CONFIG_ASCEND_SHARE_POOL */

static inline int mg_sp_group_add_task(int pid, unsigned long prot, int spg_id)
static inline int mg_sp_group_add_task(int tgid, unsigned long prot, int spg_id)
{
	return -EPERM;
}

static inline int mg_sp_group_del_task(int pid, int spg_id)
static inline int mg_sp_group_del_task(int tgid, int spg_id)
{
	return -EPERM;
}

static inline int sp_group_exit(struct mm_struct *mm)
static inline int sp_group_exit(void)
{
	return 0;
}
@@ -340,7 +340,7 @@ static inline void sp_group_post_exit(struct mm_struct *mm)
{
}

static inline int mg_sp_group_id_by_pid(int pid, int *spg_ids, int *num)
static inline int mg_sp_group_id_by_pid(int tgid, int *spg_ids, int *num)
{
	return -EPERM;
}
@@ -362,12 +362,12 @@ static inline int mg_sp_free(unsigned long addr, int id)
}

static inline void *mg_sp_make_share_k2u(unsigned long kva, unsigned long size,
			unsigned long sp_flags, int pid, int spg_id)
			unsigned long sp_flags, int tgid, int spg_id)
{
	return NULL;
}

static inline void *mg_sp_make_share_u2k(unsigned long uva, unsigned long size, int pid)
static inline void *mg_sp_make_share_u2k(unsigned long uva, unsigned long size, int tgid)
{
	return NULL;
}
@@ -410,7 +410,7 @@ static inline int sp_unregister_notifier(struct notifier_block *nb)
	return -EPERM;
}

static inline bool mg_sp_config_dvpp_range(size_t start, size_t size, int device_id, int pid)
static inline bool mg_sp_config_dvpp_range(size_t start, size_t size, int device_id, int tgid)
{
	return false;
}
+8 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@
#include <linux/rcuwait.h>
#include <linux/compat.h>
#include <linux/io_uring.h>
#include <linux/share_pool.h>

#include <linux/uaccess.h>
#include <asm/unistd.h>
@@ -795,6 +796,13 @@ void __noreturn do_exit(long code)
	tsk->exit_code = code;
	taskstats_exit(tsk, group_dead);

	/*
	 * sp_group_exit must be executed before exit_mm,
	 * otherwise it will cause mm leakage.
	 */
	if (group_dead)
		sp_group_exit();

	exit_mm();

	if (group_dead)
Loading