From patchwork Mon Oct 14 03:58:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bibo mao X-Patchwork-Id: 13834136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B5BFCF259D for ; Mon, 14 Oct 2024 03:59:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A670B6B0083; Sun, 13 Oct 2024 23:59:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CA476B0089; Sun, 13 Oct 2024 23:59:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 758EE6B0088; Sun, 13 Oct 2024 23:59:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4B8376B0083 for ; Sun, 13 Oct 2024 23:59:03 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 332E3AB1E4 for ; Mon, 14 Oct 2024 03:58:48 +0000 (UTC) X-FDA: 82670851914.13.537343A Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by imf01.hostedemail.com (Postfix) with ESMTP id 5347040010 for ; Mon, 14 Oct 2024 03:58:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of maobibo@loongson.cn designates 114.242.206.163 as permitted sender) smtp.mailfrom=maobibo@loongson.cn; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728878199; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=kJf0bhlzRwFJdD6ttbRFo0QxETGkwmAfI75yB+TvWTY=; b=Nh+WQK6Ko3ipL2VpFs7Fru/V/F26JAxdRR1d68c8qhwYJM0OLH9kx4aLHAQkPseoiUXS/V bxBAmkfEmnmFWwx8w0EdVRyAKidhibkL2DddebkX841Wqgq+mBATXXLnQY9cTAr9ua3/Iw wTf6fbqo303V41Ke0TRFWYkkQ7svlXc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728878199; a=rsa-sha256; cv=none; b=6TOFhg+omeElV1WC5EwsDFG1ARkxNO0/Y3b/BHe/JHs0HyrrJP7mo4x7NFXpn5px260UlO R8WWMFjicu3dp+zTwKefTX+gK10lMjQSOarUuK2o1GZmjDHNJcPuSfmdKoI0Ejxmgpua47 7T6Q/pCAaM6oC+rrXloIphCo3aDDomY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of maobibo@loongson.cn designates 114.242.206.163 as permitted sender) smtp.mailfrom=maobibo@loongson.cn; dmarc=none Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8CxLOsAlwxncwIaAA--.37530S3; Mon, 14 Oct 2024 11:58:56 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by front1 (Coremail) with SMTP id qMiowMBxXuT_lgxnc6EoAA--.1717S2; Mon, 14 Oct 2024 11:58:56 +0800 (CST) From: Bibo Mao To: Huacai Chen , Andrey Ryabinin , Andrew Morton Cc: David Hildenbrand , Barry Song , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Subject: [PATCH v2 0/3] LoongArch: Fix vmalloc test issue Date: Mon, 14 Oct 2024 11:58:52 +0800 Message-Id: <20241014035855.1119220-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-CM-TRANSID: qMiowMBxXuT_lgxnc6EoAA--.1717S2 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Stat-Signature: i8wmyxbo3yedscaju14er17niko7kb65 X-Rspamd-Queue-Id: 5347040010 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728878334-179071 X-HE-Meta: U2FsdGVkX1+ZSss82wWTNHJy4AgVry9srOyjV8V8mTPxazKloUAP+Kd5QJm7sktjOVLVbdWjS89DltbYxGTD5cYuYFsrspzmS7wLwdHZh6PIQpY19KsKjQMbqWpRJRydS025sR+wc4Gj1iaBThHyGDsc5R7zQ/+JF6nsq9TpkMbktlVVdOIKX/zBjBUY8QvOpN6nHyHzETklTVRQEtxB0pBJdDtRlmCvt1FctfrOq0KdNRyedlnwRBL7yK2uh1mbjHo+epnrBT7u7AtIYuAsgEHVplakp6ZSExYp3IQqjeYq77HHB9p8K1/Gtc1uPcnUuhd+bziJtp66l7/M+T0mqIkqSLirM1RskDbx5pmulGMSAaqqEHx3o6/QVJj5qJFxSqXKHT057wDlOfhrzblbSaU2c35nvKpiXpg5RIZLF+wzpFPKZ0iBGed/2KcDPt0DoB3rNMlusnQS920v4YKNXBGy1CR1fyUjsGvtLIuQ5G1BcVa6L+X71+YeECGuPvw+ZNn+4Kd3l8GYAmE4Tlcvf9v0JUA3aTS/CrgUwwhwLeKlJAEWrYOwJCpsk3e7rmrD0O/EdZCCS5yHSNU7zeOZsXiBabR3s3Ly/r0lDTchsiHT18gH0mL2pOWjOwna47InelWksY7AxXsCsMuR/egJLa2aQ+7YXTchloHVzKi0PI+9bSnuNPQlpMBvn2cE5wRcyppNT/jO6rtLPjzuvPgX8LH/1U7fhJ9+7Ho6cpfkASBACPM6TxkNg83K30mtSCOWm1x/YdotaKDypoXAbO8pEfD+A3fT9Wp3pOgMW54zqqyBakc6ToFu0IxQBm/upY80dl6g4Bf2LM6Uk0waQw/AJ5RL7Wbj0mZn+bzsdmWwKWsG8xMIzH9fECSLraiGJYemaAwDDCERIBYgOyf+t9dT0iwUh4J61w1ROPFpUqBE+PYeH/Xj15gYV+kiNA8ahgxBmvlJx2YD2EWBTQLHw6w th2njPNx PUhPX4RC5ndmjcer/seF1z4TqsTDh8mV/LhZ88zFvr82y7aW1S3ljMHHwtIRL8oAXOcZIfr3wxeleRISMa33+zIcuYv8gh+0UipRGeQUoTJQh+Vk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On LoongArch 3C5000 Dual-Way machine, there are 32 CPUs and 128G RAM, there are some errors with run vmalloc test with command like this insmod test_vmalloc.ko nr_threads=32 run_test_mask=0x3af Here is part of error message and summary test report for failed cases: WARNING: CPU: 13 PID: 1457 at mm/vmalloc.c:503 vmap_small_pages_range_noflush+0x388/0x510 CPU: 13 UID: 0 PID: 1457 Comm: vmalloc_test/15 Not tainted 6.12.0-rc2+ #93 Trying to vfree() nonexistent vm area (000000004dec9ced) WARNING: CPU: 3 PID: 1444 at mm/vmalloc.c:3345 vfree+0x1e8/0x4c8 CPU: 3 UID: 0 PID: 1444 Comm: vmalloc_test/2 Trying to vfree() bad address (00000000fc7c9da5) WARNING: CPU: 10 PID: 1552 at mm/vmalloc.c:3210 remove_vm_area+0x88/0x98 CPU: 10 UID: 0 PID: 1552 Comm: kworker/u144:3 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: random_size_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: random_size_align_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: kvfree_rcu_2_arg_vmalloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: random_size_align_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: fix_size_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: random_size_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: random_size_align_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: random_size_align_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: kvfree_rcu_2_arg_vmalloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: random_size_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: kvfree_rcu_1_arg_vmalloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: fix_size_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 Summary: long_busy_list_alloc_test passed: 0 failed: 1 repeat: 1 loops: 1000000 The mainly problem is that function set_pte() and pte_free() is not atomic, since these functions need modify two consecutive pte entries for kernel space area to assure that both pte entries with PAGE_GLOBAL bit set. And there is contension problem between them. With this patchset, vmalloc test case passes to run with command insmod test_vmalloc.ko nr_threads=32 run_test_mask=0x3af --- v1 ... v2: 1. Solve compile warning issue by declaring function kernel_pte_init() in header file include/linux/mm.h 2. Add kernel_pte_init() in function zero_pmd_populate() called by file mm/kasan/init.c 3. Merge the first two patches into one since both these two patches set pte entry with PAGE_GLOBAL in different modules 4. Remove amotic operation with pte_clear(), using generic read and clear operation, vmalloc test pass to run also 5. refresh some comments description --- Bibo Mao (3): LoongArch: Set initial pte entry with PAGE_GLOBAL for kernel space LoongArch: Add barrier between set_pte and memory access LoongArch: Remove pte buddy set with set_pte and pte_clear function arch/loongarch/include/asm/cacheflush.h | 14 +++++++++- arch/loongarch/include/asm/pgalloc.h | 13 +++++++++ arch/loongarch/include/asm/pgtable.h | 36 +++++-------------------- arch/loongarch/mm/init.c | 4 ++- arch/loongarch/mm/kasan_init.c | 4 ++- arch/loongarch/mm/pgtable.c | 22 +++++++++++++++ include/linux/mm.h | 1 + mm/kasan/init.c | 8 +++++- mm/sparse-vmemmap.c | 5 ++++ 9 files changed, 73 insertions(+), 34 deletions(-) base-commit: 6485cf5ea253d40d507cd71253c9568c5470cd27