From: Charan Teja Kalla <quic_charante(a)quicinc.com>
mainline inclusion
from mainline-v6.8-rc1
commit 5ec8e8ea8b7783fab150cf86404fc38cb4db8800
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I97NHX
CVE: CVE-2023-52489
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?…
------------------------------------------------------
The below race is observed on a PFN which falls into the device memory
region with the system memory configuration where PFN's are such that
[ZONE_NORMAL ZONE_DEVICE ZONE_NORMAL]. Since normal zone start and end
pfn contains the device memory PFN's as well, the compaction triggered
will try on the device memory PFN's too though they end up in NOP(because
pfn_to_online_page() returns NULL for ZONE_DEVICE memory sections). When
from other core, the section mappings are being removed for the
ZONE_DEVICE region, that the PFN in question belongs to, on which
compaction is currently being operated is resulting into the kernel crash
with CONFIG_SPASEMEM_VMEMAP enabled. The crash logs can be seen at [1].
compact_zone() memunmap_pages
------------- ---------------
__pageblock_pfn_to_page
......
(a)pfn_valid():
valid_section()//return true
(b)__remove_pages()->
sparse_remove_section()->
section_deactivate():
[Free the array ms->usage and set
ms->usage = NULL]
pfn_section_valid()
[Access ms->usage which
is NULL]
NOTE: From the above it can be said that the race is reduced to between
the pfn_valid()/pfn_section_valid() and the section deactivate with
SPASEMEM_VMEMAP enabled.
The commit b943f045a9af("mm/sparse: fix kernel crash with
pfn_section_valid check") tried to address the same problem by clearing
the SECTION_HAS_MEM_MAP with the expectation of valid_section() returns
false thus ms->usage is not accessed.
Fix this issue by the below steps:
a) Clear SECTION_HAS_MEM_MAP before freeing the ->usage.
b) RCU protected read side critical section will either return NULL
when SECTION_HAS_MEM_MAP is cleared or can successfully access ->usage.
c) Free the ->usage with kfree_rcu() and set ms->usage = NULL. No
attempt will be made to access ->usage after this as the
SECTION_HAS_MEM_MAP is cleared thus valid_section() return false.
Thanks to David/Pavan for their inputs on this patch.
[1] https://lore.kernel.org/linux-mm/994410bb-89aa-d987-1f50-f514903c55aa@quici…
On Snapdragon SoC, with the mentioned memory configuration of PFN's as
[ZONE_NORMAL ZONE_DEVICE ZONE_NORMAL], we are able to see bunch of
issues daily while testing on a device farm.
For this particular issue below is the log. Though the below log is
not directly pointing to the pfn_section_valid(){ ms->usage;}, when we
loaded this dump on T32 lauterbach tool, it is pointing.
[ 540.578056] Unable to handle kernel NULL pointer dereference at
virtual address 0000000000000000
[ 540.578068] Mem abort info:
[ 540.578070] ESR = 0x0000000096000005
[ 540.578073] EC = 0x25: DABT (current EL), IL = 32 bits
[ 540.578077] SET = 0, FnV = 0
[ 540.578080] EA = 0, S1PTW = 0
[ 540.578082] FSC = 0x05: level 1 translation fault
[ 540.578085] Data abort info:
[ 540.578086] ISV = 0, ISS = 0x00000005
[ 540.578088] CM = 0, WnR = 0
[ 540.579431] pstate: 82400005 (Nzcv daif +PAN -UAO +TCO -DIT -SSBSBTYPE=--)
[ 540.579436] pc : __pageblock_pfn_to_page+0x6c/0x14c
[ 540.579454] lr : compact_zone+0x994/0x1058
[ 540.579460] sp : ffffffc03579b510
[ 540.579463] x29: ffffffc03579b510 x28: 0000000000235800 x27:000000000000000c
[ 540.579470] x26: 0000000000235c00 x25: 0000000000000068 x24:ffffffc03579b640
[ 540.579477] x23: 0000000000000001 x22: ffffffc03579b660 x21:0000000000000000
[ 540.579483] x20: 0000000000235bff x19: ffffffdebf7e3940 x18:ffffffdebf66d140
[ 540.579489] x17: 00000000739ba063 x16: 00000000739ba063 x15:00000000009f4bff
[ 540.579495] x14: 0000008000000000 x13: 0000000000000000 x12:0000000000000001
[ 540.579501] x11: 0000000000000000 x10: 0000000000000000 x9 :ffffff897d2cd440
[ 540.579507] x8 : 0000000000000000 x7 : 0000000000000000 x6 :ffffffc03579b5b4
[ 540.579512] x5 : 0000000000027f25 x4 : ffffffc03579b5b8 x3 :0000000000000001
[ 540.579518] x2 : ffffffdebf7e3940 x1 : 0000000000235c00 x0 :0000000000235800
[ 540.579524] Call trace:
[ 540.579527] __pageblock_pfn_to_page+0x6c/0x14c
[ 540.579533] compact_zone+0x994/0x1058
[ 540.579536] try_to_compact_pages+0x128/0x378
[ 540.579540] __alloc_pages_direct_compact+0x80/0x2b0
[ 540.579544] __alloc_pages_slowpath+0x5c0/0xe10
[ 540.579547] __alloc_pages+0x250/0x2d0
[ 540.579550] __iommu_dma_alloc_noncontiguous+0x13c/0x3fc
[ 540.579561] iommu_dma_alloc+0xa0/0x320
[ 540.579565] dma_alloc_attrs+0xd4/0x108
[quic_charante(a)quicinc.com: use kfree_rcu() in place of synchronize_rcu(), per David]
Link: https://lkml.kernel.org/r/1698403778-20938-1-git-send-email-quic_charante@q…
Link: https://lkml.kernel.org/r/1697202267-23600-1-git-send-email-quic_charante@q…
Fixes: f46edbd1b151 ("mm/sparsemem: add helpers track active portions of a section at boot")
Signed-off-by: Charan Teja Kalla <quic_charante(a)quicinc.com>
Cc: Aneesh Kumar K.V <aneesh.kumar(a)linux.ibm.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: David Hildenbrand <david(a)redhat.com>
Cc: Mel Gorman <mgorman(a)techsingularity.net>
Cc: Oscar Salvador <osalvador(a)suse.de>
Cc: Vlastimil Babka <vbabka(a)suse.cz>
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
Conflicts:
include/linux/mmzone.h
Signed-off-by: ZhangPeng <zhangpeng362(a)huawei.com>
---
include/linux/mmzone.h | 15 ++++++++++++---
mm/sparse.c | 17 +++++++++--------
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 0a70b4bdd236..187389530dd0 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1226,6 +1226,7 @@ static inline unsigned long section_nr_to_pfn(unsigned long sec)
#define SUBSECTION_ALIGN_DOWN(pfn) ((pfn) & PAGE_SUBSECTION_MASK)
struct mem_section_usage {
+ struct rcu_head rcu;
#ifdef CONFIG_SPARSEMEM_VMEMMAP
DECLARE_BITMAP(subsection_map, SUBSECTIONS_PER_SECTION);
#endif
@@ -1391,7 +1392,7 @@ static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn)
{
int idx = subsection_map_index(pfn);
- return test_bit(idx, ms->usage->subsection_map);
+ return test_bit(idx, READ_ONCE(ms->usage)->subsection_map);
}
#else
static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn)
@@ -1404,17 +1405,25 @@ static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn)
static inline int pfn_valid(unsigned long pfn)
{
struct mem_section *ms;
+ int ret;
if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
return 0;
ms = __nr_to_section(pfn_to_section_nr(pfn));
- if (!valid_section(ms))
+ rcu_read_lock();
+ if (!valid_section(ms)) {
+ rcu_read_unlock();
return 0;
+ }
+
/*
* Traditionally early sections always returned pfn_valid() for
* the entire section-sized span.
*/
- return early_section(ms) || pfn_section_valid(ms, pfn);
+ ret = early_section(ms) || pfn_section_valid(ms, pfn);
+ rcu_read_unlock();
+
+ return ret;
}
#endif
diff --git a/mm/sparse.c b/mm/sparse.c
index d92a29000d66..45b3571091a8 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -809,6 +809,13 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages,
if (empty) {
unsigned long section_nr = pfn_to_section_nr(pfn);
+ /*
+ * Mark the section invalid so that valid_section()
+ * return false. This prevents code from dereferencing
+ * ms->usage array.
+ */
+ ms->section_mem_map &= ~SECTION_HAS_MEM_MAP;
+
/*
* When removing an early section, the usage map is kept (as the
* usage maps of other sections fall into the same page). It
@@ -817,16 +824,10 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages,
* was allocated during boot.
*/
if (!PageReserved(virt_to_page(ms->usage))) {
- kfree(ms->usage);
- ms->usage = NULL;
+ kfree_rcu(ms->usage, rcu);
+ WRITE_ONCE(ms->usage, NULL);
}
memmap = sparse_decode_mem_map(ms->section_mem_map, section_nr);
- /*
- * Mark the section invalid so that valid_section()
- * return false. This prevents code from dereferencing
- * ms->usage array.
- */
- ms->section_mem_map &= ~SECTION_HAS_MEM_MAP;
}
/*
--
2.25.1
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 5c41e48598c428d3e38e9ce985a698070deb979b
commit: 713cfd2684fa5ea08b144d92b9858b932c0f1705 [20703/21864] sched: Introduce smart grid scheduling strategy for cfs
config: x86_64-randconfig-r111-20240313 (https://download.01.org/0day-ci/archive/20240315/202403150202.LRmQdyUB-lkp@…)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240315/202403150202.LRmQdyUB-lkp@…)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403150202.LRmQdyUB-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
kernel/sched/core.c:133:6: sparse: sparse: symbol 'account_irqtime_to_task' was not declared. Should it be static?
kernel/sched/core.c:1646:17: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/core.c:1646:17: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/core.c:1646:17: sparse: struct sched_domain *
kernel/sched/core.c:1830:27: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/core.c:1830:27: sparse: struct task_struct [noderef] __rcu *
kernel/sched/core.c:1830:27: sparse: struct task_struct *
kernel/sched/core.c:3508:17: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/core.c:3508:17: sparse: struct task_struct [noderef] __rcu *
kernel/sched/core.c:3508:17: sparse: struct task_struct *
kernel/sched/core.c:5501:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/core.c:5501:9: sparse: struct task_struct [noderef] __rcu *
kernel/sched/core.c:5501:9: sparse: struct task_struct *
kernel/sched/core.c:6699:11: sparse: sparse: symbol 'min_cfs_quota_period' was not declared. Should it be static?
kernel/sched/core.c:6779:5: sparse: sparse: symbol 'tg_set_cfs_quota' was not declared. Should it be static?
kernel/sched/core.c:6794:6: sparse: sparse: symbol 'tg_get_cfs_quota' was not declared. Should it be static?
kernel/sched/core.c:6807:5: sparse: sparse: symbol 'tg_set_cfs_period' was not declared. Should it be static?
kernel/sched/core.c:6820:6: sparse: sparse: symbol 'tg_get_cfs_period' was not declared. Should it be static?
>> kernel/sched/core.c:6988:5: sparse: sparse: symbol 'tg_set_dynamic_affinity_mode' was not declared. Should it be static?
>> kernel/sched/core.c:7025:5: sparse: sparse: symbol 'tg_set_affinity_period' was not declared. Should it be static?
>> kernel/sched/core.c:7036:5: sparse: sparse: symbol 'tg_get_affinity_period' was not declared. Should it be static?
In file included from kernel/sched/core.c:8:
In file included from kernel/sched/sched.h:52:
In file included from include/linux/migrate.h:6:
In file included from include/linux/mempolicy.h:16:
include/linux/pagemap.h:425:21: warning: cast from 'int (*)(struct file *, struct page *)' to 'filler_t *' (aka 'int (*)(void *, struct page *)') converts to incompatible function type [-Wcast-function-type-strict]
425 | filler_t *filler = (filler_t *)mapping->a_ops->readpage;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from kernel/sched/core.c:8:
kernel/sched/sched.h:1249:15: warning: cast from 'void (*)(struct rq *)' to 'void (*)(struct callback_head *)' converts to incompatible function type [-Wcast-function-type-strict]
1249 | head->func = (void (*)(struct callback_head *))func;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sched/core.c:1587:6: warning: no previous prototype for function 'sched_set_stop_task' [-Wmissing-prototypes]
1587 | void sched_set_stop_task(int cpu, struct task_struct *stop)
| ^
kernel/sched/core.c:1587:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
1587 | void sched_set_stop_task(int cpu, struct task_struct *stop)
| ^
| static
kernel/sched/core.c:2741:10: warning: cast from 'void (*)(struct callback_head *)' to 'void (*)(struct rq *)' converts to incompatible function type [-Wcast-function-type-strict]
2741 | func = (void (*)(struct rq *))head->func;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sched/core.c:3771:35: warning: no previous prototype for function 'preempt_schedule_irq' [-Wmissing-prototypes]
3771 | asmlinkage __visible void __sched preempt_schedule_irq(void)
| ^
kernel/sched/core.c:3771:22: note: declare 'static' if the function is not intended to be used outside of this translation unit
3771 | asmlinkage __visible void __sched preempt_schedule_irq(void)
| ^
| static
kernel/sched/core.c:6779:5: warning: no previous prototype for function 'tg_set_cfs_quota' [-Wmissing-prototypes]
6779 | int tg_set_cfs_quota(struct task_group *tg, long cfs_quota_us)
| ^
kernel/sched/core.c:6779:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
6779 | int tg_set_cfs_quota(struct task_group *tg, long cfs_quota_us)
| ^
| static
kernel/sched/core.c:6794:6: warning: no previous prototype for function 'tg_get_cfs_quota' [-Wmissing-prototypes]
6794 | long tg_get_cfs_quota(struct task_group *tg)
| ^
kernel/sched/core.c:6794:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
6794 | long tg_get_cfs_quota(struct task_group *tg)
| ^
| static
kernel/sched/core.c:6807:5: warning: no previous prototype for function 'tg_set_cfs_period' [-Wmissing-prototypes]
6807 | int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
| ^
kernel/sched/core.c:6807:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
6807 | int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
| ^
| static
kernel/sched/core.c:6820:6: warning: no previous prototype for function 'tg_get_cfs_period' [-Wmissing-prototypes]
6820 | long tg_get_cfs_period(struct task_group *tg)
| ^
kernel/sched/core.c:6820:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
6820 | long tg_get_cfs_period(struct task_group *tg)
| ^
| static
kernel/sched/core.c:6988:5: warning: no previous prototype for function 'tg_set_dynamic_affinity_mode' [-Wmissing-prototypes]
6988 | int tg_set_dynamic_affinity_mode(struct task_group *tg, u64 mode)
| ^
kernel/sched/core.c:6988:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
6988 | int tg_set_dynamic_affinity_mode(struct task_group *tg, u64 mode)
| ^
| static
kernel/sched/core.c:7025:5: warning: no previous prototype for function 'tg_set_affinity_period' [-Wmissing-prototypes]
7025 | int tg_set_affinity_period(struct task_group *tg, u64 period_ms)
| ^
kernel/sched/core.c:7025:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
7025 | int tg_set_affinity_period(struct task_group *tg, u64 period_ms)
| ^
| static
kernel/sched/core.c:7036:5: warning: no previous prototype for function 'tg_get_affinity_period' [-Wmissing-prototypes]
7036 | u64 tg_get_affinity_period(struct task_group *tg)
| ^
kernel/sched/core.c:7036:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
7036 | u64 tg_get_affinity_period(struct task_group *tg)
| ^
| static
In file included from kernel/sched/core.c:8:
In file included from kernel/sched/sched.h:52:
In file included from include/linux/migrate.h:6:
include/linux/mempolicy.h:329:13: warning: unused function '__do_mbind' [-Wunused-function]
329 | static long __do_mbind(unsigned long start, unsigned long len,
| ^~~~~~~~~~
13 warnings generated.
--
kernel/sched/fair.c:47:14: sparse: sparse: symbol 'normalized_sysctl_sched_latency' was not declared. Should it be static?
kernel/sched/fair.c:68:14: sparse: sparse: symbol 'normalized_sysctl_sched_min_granularity' was not declared. Should it be static?
kernel/sched/fair.c:91:14: sparse: sparse: symbol 'normalized_sysctl_sched_wakeup_granularity' was not declared. Should it be static?
kernel/sched/fair.c:141:14: sparse: sparse: symbol 'capacity_margin' was not declared. Should it be static?
kernel/sched/fair.c:6933:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:6933:14: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:6933:14: sparse: struct sched_domain *
kernel/sched/fair.c:3682:6: sparse: sparse: symbol 'sync_entity_load_avg' was not declared. Should it be static?
kernel/sched/fair.c:3695:6: sparse: sparse: symbol 'remove_entity_load_avg' was not declared. Should it be static?
kernel/sched/fair.c:10761:22: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:10761:22: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:10761:22: sparse: struct sched_domain *
kernel/sched/fair.c:10775:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:10775:9: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:10775:9: sparse: struct sched_domain *
kernel/sched/fair.c:3870:25: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:3870:25: sparse: struct sparsemask [noderef] __rcu *
kernel/sched/fair.c:3870:25: sparse: struct sparsemask *
kernel/sched/fair.c:3887:25: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:3887:25: sparse: struct sparsemask [noderef] __rcu *
kernel/sched/fair.c:3887:25: sparse: struct sparsemask *
kernel/sched/fair.c:10985:25: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:10985:25: sparse: struct sparsemask [noderef] __rcu *
kernel/sched/fair.c:10985:25: sparse: struct sparsemask *
>> kernel/sched/fair.c:5566:6: sparse: sparse: symbol 'free_affinity_domains' was not declared. Should it be static?
kernel/sched/fair.c:5610:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:5610:9: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:5610:9: sparse: struct sched_domain *
kernel/sched/fair.c:5632:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:5632:9: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:5632:9: sparse: struct sched_domain *
kernel/sched/fair.c:6821:19: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:6821:19: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:6821:19: sparse: struct sched_domain *
kernel/sched/fair.c:7258:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:7258:9: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:7258:9: sparse: struct sched_domain *
kernel/sched/fair.c:10126:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:10126:9: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:10126:9: sparse: struct sched_domain *
kernel/sched/fair.c:10204:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:10204:9: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:10204:9: sparse: struct sched_domain *
kernel/sched/fair.c:6688:15: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:6688:15: sparse: struct sched_domain_shared [noderef] __rcu *
kernel/sched/fair.c:6688:15: sparse: struct sched_domain_shared *
kernel/sched/fair.c:6679:15: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:6679:15: sparse: struct sched_domain_shared [noderef] __rcu *
kernel/sched/fair.c:6679:15: sparse: struct sched_domain_shared *
kernel/sched/fair.c:6688:15: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:6688:15: sparse: struct sched_domain_shared [noderef] __rcu *
kernel/sched/fair.c:6688:15: sparse: struct sched_domain_shared *
kernel/sched/fair.c:6679:15: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:6679:15: sparse: struct sched_domain_shared [noderef] __rcu *
kernel/sched/fair.c:6679:15: sparse: struct sched_domain_shared *
kernel/sched/fair.c:6660:17: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:6660:17: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:6660:17: sparse: struct sched_domain *
kernel/sched/fair.c:10294:16: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/fair.c:10294:16: sparse: struct sched_domain [noderef] __rcu *
kernel/sched/fair.c:10294:16: sparse: struct sched_domain *
In file included from kernel/sched/fair.c:23:
In file included from kernel/sched/sched.h:52:
In file included from include/linux/migrate.h:6:
In file included from include/linux/mempolicy.h:16:
include/linux/pagemap.h:425:21: warning: cast from 'int (*)(struct file *, struct page *)' to 'filler_t *' (aka 'int (*)(void *, struct page *)') converts to incompatible function type [-Wcast-function-type-strict]
425 | filler_t *filler = (filler_t *)mapping->a_ops->readpage;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from kernel/sched/fair.c:23:
kernel/sched/sched.h:1249:15: warning: cast from 'void (*)(struct rq *)' to 'void (*)(struct callback_head *)' converts to incompatible function type [-Wcast-function-type-strict]
1249 | head->func = (void (*)(struct callback_head *))func;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c:3682:6: warning: no previous prototype for function 'sync_entity_load_avg' [-Wmissing-prototypes]
3682 | void sync_entity_load_avg(struct sched_entity *se)
| ^
kernel/sched/fair.c:3682:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
3682 | void sync_entity_load_avg(struct sched_entity *se)
| ^
| static
kernel/sched/fair.c:3695:6: warning: no previous prototype for function 'remove_entity_load_avg' [-Wmissing-prototypes]
3695 | void remove_entity_load_avg(struct sched_entity *se)
| ^
kernel/sched/fair.c:3695:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
3695 | void remove_entity_load_avg(struct sched_entity *se)
| ^
| static
kernel/sched/fair.c:5566:6: warning: no previous prototype for function 'free_affinity_domains' [-Wmissing-prototypes]
5566 | void free_affinity_domains(struct affinity_domain *ad)
| ^
kernel/sched/fair.c:5566:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
5566 | void free_affinity_domains(struct affinity_domain *ad)
| ^
| static
kernel/sched/fair.c:8613:7: warning: variable 'done' set but not used [-Wunused-but-set-variable]
8613 | bool done = true;
| ^
In file included from kernel/sched/fair.c:23:
In file included from kernel/sched/sched.h:52:
In file included from include/linux/migrate.h:6:
include/linux/mempolicy.h:329:13: warning: unused function '__do_mbind' [-Wunused-function]
329 | static long __do_mbind(unsigned long start, unsigned long len,
| ^~~~~~~~~~
7 warnings generated.
vim +/tg_set_dynamic_affinity_mode +6988 kernel/sched/core.c
6986
6987 #ifdef CONFIG_QOS_SCHED_SMART_GRID
> 6988 int tg_set_dynamic_affinity_mode(struct task_group *tg, u64 mode)
6989 {
6990 struct auto_affinity *auto_affi = tg->auto_affinity;
6991 int ret = 0;
6992
6993 raw_spin_lock_irq(&auto_affi->lock);
6994
6995 /* auto mode*/
6996 if (mode == 1) {
6997 start_auto_affinity(auto_affi);
6998 } else if (mode == 0) {
6999 stop_auto_affinity(auto_affi);
7000 } else {
7001 raw_spin_unlock_irq(&auto_affi->lock);
7002 return -EINVAL;
7003 }
7004
7005 auto_affi->mode = mode;
7006 raw_spin_unlock_irq(&auto_affi->lock);
7007
7008 return ret;
7009 }
7010
7011 static u64 cpu_affinity_mode_read_u64(struct cgroup_subsys_state *css,
7012 struct cftype *cft)
7013 {
7014 struct task_group *tg = css_tg(css);
7015
7016 return tg->auto_affinity->mode;
7017 }
7018
7019 static int cpu_affinity_mode_write_u64(struct cgroup_subsys_state *css,
7020 struct cftype *cftype, u64 mode)
7021 {
7022 return tg_set_dynamic_affinity_mode(css_tg(css), mode);
7023 }
7024
> 7025 int tg_set_affinity_period(struct task_group *tg, u64 period_ms)
7026 {
7027 if (period_ms > U64_MAX / NSEC_PER_MSEC)
7028 return -EINVAL;
7029
7030 raw_spin_lock_irq(&tg->auto_affinity->lock);
7031 tg->auto_affinity->period = ms_to_ktime(period_ms);
7032 raw_spin_unlock_irq(&tg->auto_affinity->lock);
7033 return 0;
7034 }
7035
> 7036 u64 tg_get_affinity_period(struct task_group *tg)
7037 {
7038 return ktime_to_ms(tg->auto_affinity->period);
7039 }
7040
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki