| From: Yanfei Xu <yanfei.xu@intel.com> |
| Subject: memory tier: fix deadlock warning while onlining pages |
| Date: Fri, 30 Aug 2024 18:24:47 +0800 |
| |
| Add the mutex_lock/unlock() pair back and exclude the |
| hotplug_memory_notifier() from the locked region, per Ying Huang. |
| |
| Link: https://lkml.kernel.org/r/20240830102447.1445296-1-yanfei.xu@intel.com |
| Fixes: 823430c8e9d9 ("memory tier: consolidate the initialization of memory tiers") |
| Signed-off-by: Yanfei Xu <yanfei.xu@intel.com> |
| Cc: Ho-Ren (Jack) Chuang <horen.chuang@linux.dev> |
| Cc: "Huang, Ying" <ying.huang@intel.com> |
| Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> |
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| --- |
| |
| mm/memory-tiers.c | 2 ++ |
| 1 file changed, 2 insertions(+) |
| |
| --- a/mm/memory-tiers.c~memory-tier-fix-deadlock-warning-while-onlining-pages-v2 |
| +++ a/mm/memory-tiers.c |
| @@ -914,12 +914,14 @@ static int __init memory_tier_init(void) |
| WARN_ON(!node_demotion); |
| #endif |
| |
| + mutex_lock(&memory_tier_lock); |
| /* |
| * For now we can have 4 faster memory tiers with smaller adistance |
| * than default DRAM tier. |
| */ |
| default_dram_type = mt_find_alloc_memory_type(MEMTIER_ADISTANCE_DRAM, |
| &default_memory_types); |
| + mutex_unlock(&memory_tier_lock); |
| if (IS_ERR(default_dram_type)) |
| panic("%s() failed to allocate default DRAM tier\n", __func__); |
| |
| _ |