From patchwork Thu Oct 10 03:50:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bibo mao X-Patchwork-Id: 13829444 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 8EDE8CF0433 for ; Thu, 10 Oct 2024 03:50:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49ECA6B0088; Wed, 9 Oct 2024 23:50:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45D226B0089; Wed, 9 Oct 2024 23:50:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F00A6B008A; Wed, 9 Oct 2024 23:50:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 12E306B0088 for ; Wed, 9 Oct 2024 23:50:57 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3B7B9A1B4F for ; Thu, 10 Oct 2024 03:50:51 +0000 (UTC) X-FDA: 82656316512.10.A80C2DA Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by imf19.hostedemail.com (Postfix) with ESMTP id B05311A0006 for ; Thu, 10 Oct 2024 03:50:53 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.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=1728532118; 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=SY+h6Ni7p6nx6T0SONPCF3V0fwnPtdpc12KhvEyP5Mk=; b=DgbrTqQBbVfZIt2ShDbAixz4xMA/CDZ9Xn7pBYbMtpG4GP/XNH51TSW8pH9Yxss9y63qBI pz63btIVEb6lz+IQgJAkZ5geaCyeA8m0+CK88VX7aVC2UfEFEsQPfiN9zee9GcuGIRIWFR u7d84JhNE8lVmbH7aA8Ht5VsYMPEGEs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728532118; a=rsa-sha256; cv=none; b=0b1IpkLbeoLCfidY3Om4ilMnn8EVMG06xuAthGC5Med/2dSTV/H1eLyALGdpUmxPdcMtX8 BAqlv+Co2bblFf7HTuPxDh0Bb6K8y7VfWbzujCe21Q5OTsMpq4Xf1FHe3HKMN2T1MK8TVC 0AVKzRoGpKvfuNIn7JnvPFqIb0rvtA0= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.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 _____8BxVekZTwdnvbsRAA--.25393S3; Thu, 10 Oct 2024 11:50:49 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by front1 (Coremail) with SMTP id qMiowMDx7tUZTwdnFP8hAA--.52915S2; Thu, 10 Oct 2024 11:50:49 +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 0/4] LoongArch: Fix vmalloc test issue Date: Thu, 10 Oct 2024 11:50:44 +0800 Message-Id: <20241010035048.3422527-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-CM-TRANSID: qMiowMDx7tUZTwdnFP8hAA--.52915S2 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B05311A0006 X-Stat-Signature: pditjkjemjyxhgbdnbjod89ei78pjt4b X-HE-Tag: 1728532253-529777 X-HE-Meta: U2FsdGVkX1/5R9Y0GO2xQHbrI5lnH6AV9yx2SYqSuQrCVGxe08uvrLe8PAH0HOdZ6wdVxwwZLj6Rrm9sGijyooZnXavwQ45y+yQL/eGe0qB++ycNAKB49UEik63QohlOZUa6ZOQaj2XizjbYxN2Quz3M86xzJFk8P4/FoO3vZ490VYxxplbQuzhAiKb3qmuNTJJYxFerazokfVd8WgR+9wP6ic8MA9/oS+3vh1SMpmCQccnWNpQmG6eiMC71r2E84dnME7NcQhh8z5LQmzdwDZHhICSU80lvKfebf7oj+mHTP+epBi07k/DcFJcDa+TQfPPkOvv7KLIVfQnIQ/bJRIySixzTpbyKZLxa8z5ZbwuXvJocNphTko1yP0jlXBJkXN7s5Z5hUEFbRKKz0buZiIoRj/M2pTok5z5lCfN+3684FYl7RAiUr1fDZrZutm5VyjPuXBI7f/e6eHRJ/wNbS3yceo5qntnW/5ufLh14Pis4U+CwD2iJ5PP3467deZt/5fPZalJQHHSGamYPLlaELbDop/DqMhxKzM77zP1Asu4hE5F8pEKrveh/j6t1bXqJcVzzTwuKkYkNaFG91fnn96uxrDpT7tzz2x1PiyRjxvd8mObCFxKYNiVSu4zMQephAotXNMh2QQ8meMiJGKq1Fc2F5cBfRpX+gUeHh6IXTS7lJ+KzrMjtkqdRkAMi4+/5BCg6OpSJHib5oUmBVXpvMkoKa2ko7o4KmjZ4BYtc0YUaYUXmGQc4+LI/PEr1eWDKpf77V27LKnp+F/tJKpHbO1Dk4QMe5B3QJvnNbZk0X+5fZQw3GgbmTC1O2TYKNoyumpUPqEPRDuFoR/V81JdnbRm+vhtjgfMQrxLg/3L2SgzwAmGVe7A9HfTrjc/55TdNSPV7FoKEpiCD00dBOjpfgSH/D139taouj/SsqKk1/r2ZBTnohc5lDPKLpN202/yekAs6Ens65boMBX0XsQY ZmZb2B7D Y1TQhEyqNu/U3X3cGi6C8oZoLbUj3VJW0a3WjmYOQd2G9Jw3Aj9aPfWD3YarCnjheW5FddGMG/XBmUsUMW8iLYJgJMpEfP1HaqeL6nNrMr5J1ifg= 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, 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 The mainly problem is that function set_pte() and pte_free() is atomic, there is contension between them. Since these functions need modify two consecutive pte entries for kernel space area, to assure that both pte entries with PAGE_GLOBAL bit set. With this patchset, vmalloc test case passes to run with command insmod test_vmalloc.ko nr_threads=32 run_test_mask=0x3af Bibo Mao (4): LoongArch: Set pte entry with PAGE_GLOBAL for kernel space mm/sparse-vmemmap: set pte_init when vmemmap is created LoongArch: Add barrier between set_pte and memory access LoongArch: Use atomic operation 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 | 45 +++++++++---------------- arch/loongarch/mm/init.c | 4 ++- arch/loongarch/mm/kasan_init.c | 4 ++- arch/loongarch/mm/pgtable.c | 22 ++++++++++++ mm/sparse-vmemmap.c | 5 +++ 7 files changed, 75 insertions(+), 32 deletions(-) base-commit: 87d6aab2389e5ce0197d8257d5f8ee965a67c4cd