From patchwork Fri Mar 1 15:54:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Rulin" X-Patchwork-Id: 13578640 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 3164AC5475B for ; Fri, 1 Mar 2024 15:51:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 947A56B007E; Fri, 1 Mar 2024 10:51:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D1386B0080; Fri, 1 Mar 2024 10:51:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74A016B0081; Fri, 1 Mar 2024 10:51:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 623836B007E for ; Fri, 1 Mar 2024 10:51:22 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 31DE9A131A for ; Fri, 1 Mar 2024 15:51:22 +0000 (UTC) X-FDA: 81848909604.10.EB5874A Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by imf08.hostedemail.com (Postfix) with ESMTP id E4EA2160008 for ; Fri, 1 Mar 2024 15:51:19 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JyxyQ4NT; spf=pass (imf08.hostedemail.com: domain of rulin.huang@intel.com designates 192.198.163.17 as permitted sender) smtp.mailfrom=rulin.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709308280; 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:dkim-signature; bh=HbWnNzMjtf2Vwcxy/2U7UhLSFEOCGsArj12phpWpojo=; b=qlpEAqmQ/w55TjJjfjRsvjzP4qe8LjmiT+Rwu889/WLMisP3GsXn36/W9vpj/32/Lc2BaN HU/EMGMlmXvQOTMJZBpR90Wg4HK+xAOfwk+jyd2qZPHIy4Zhn5TOp7Gx8fSvVddk1AY35T r+EK+DBTAQsQ1KgKK4yay2XC1M2ZmC0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709308280; a=rsa-sha256; cv=none; b=TnnU8+xMhSKJGI2lTYPIssOcSaf+banKt3CiH980b18hDzxHfhkHdm0/JrkZWqsRt8/B1H aLKaUp6BAY3f76C64vwJjOs6slOFdha1bH5gUIEOwq749I9ZybegYihCRR2Nk7Sl/F6uhO xXopOXTrnpcaJrWLLDcf56hwk6YDbCI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JyxyQ4NT; spf=pass (imf08.hostedemail.com: domain of rulin.huang@intel.com designates 192.198.163.17 as permitted sender) smtp.mailfrom=rulin.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709308280; x=1740844280; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=d6MyUCxfd8VWHve1C20bkt0ftD6ke8XNB2uL/3fRcT8=; b=JyxyQ4NTzAitTOpNyWEdr1CCYaeR1cEhQ/L1+ahc4teBSjBvkfwqzYCg fduxh43hM1lF7jl5gxktKEOrkrdpzNj1/Tl3gk5TUbmjm8t0dKRD39SAM KNIyh2RD0GgAixC4jpyEqxJ8HWCsvEA4MAXxNWUFOl5Wor6azvTx2pvcW Ch2o391tHozOOu1QFF4HDAwLVWTtPbrg8gXsykfpp9zlbkul51+l5cMnN uZXOJIaiCaRDEzrIz6DzE8rBASbhGUP5D6AOPi5u/v3qrg+zrs+p1K1Th HAOUP/6i0OHVJDB6tkZu9S3JFLzriQfX2fwBUDfT9iQGbFMdYbSqrJEZm w==; X-IronPort-AV: E=McAfee;i="6600,9927,11000"; a="3700829" X-IronPort-AV: E=Sophos;i="6.06,196,1705392000"; d="scan'208";a="3700829" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 07:51:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,196,1705392000"; d="scan'208";a="8370177" Received: from linux-pnp-server-09.sh.intel.com ([10.239.176.190]) by fmviesa008.fm.intel.com with ESMTP; 01 Mar 2024 07:51:15 -0800 From: rulinhuang To: urezki@gmail.com, bhe@redhat.com Cc: akpm@linux-foundation.org, colin.king@intel.com, hch@infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, lstoakes@gmail.com, rulin.huang@intel.com, tianyou.li@intel.com, tim.c.chen@intel.com, wangyang.guo@intel.com, zhiguo.zhou@intel.com Subject: [PATCH v7 0/2] mm/vmalloc: lock contention optimization under multi-threading Date: Fri, 1 Mar 2024 10:54:15 -0500 Message-ID: <20240301155417.1852290-1-rulin.huang@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: E4EA2160008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 5cb6kar7xfjr69om9sahywsd8xksp5to X-HE-Tag: 1709308279-587521 X-HE-Meta: U2FsdGVkX1/PvPQw4rDYL7mJLZNZDHIATlT2YElqbsnINJpaMCQnt8l17lHPTP6BCW4A924+seMlMI2C2QQqG5lz5RSw7HEbx6k1tNGAbNn5G6DRb3ZI1JFaw5YT8dDiTgwJnMbNA8mooB4hFrsRu36EDzctQgR7mFGqhVvvv+C69D5L/e36dMYZgH1HkwulsooYVclHrW7BF+QHKnC7CBTz0gNEce+n3hgOCnkgW4vTA5hfTKfqIAe519a2Ans6+bapuw2ylgB1R6cPXjFUqCjL3ATQ+2L6rzk/mzhcduOlxXhJYtOyp7HpZ1sbLfyFbiqMkSFYyoVFAhlVHcjOvX9qioTuW+FGrwXujaUeQyv/zZVh6TloHT5Kz3A2WkxEMs3C8h5jiSAhQjJGspG6xUHBB1du3C+I6Bk9J+p4TJgPI7OEAMXp7eD14l+iZIcKEBWoxlz+htljcPN1mUuMvcbKWBwZvFVw20Ckyfl6iuyyrVeIReQxDk6gdjMyc4bvUjxYX7/gLcaqLoIHsNXE141jjZs+Ih4yhH9wGEHfUVoh8IZYQ/uBotlAJT8c49iEpnyzjzVZ90VAJ9bSPeZwd9pDP3gbmaJIZuuMtHLYEKawhkujm1eofzaJ6NP9jUGqQGgjPalSj98Hv993b9GgLyGbBtEXTdu7z7TfqX78le387hpwhb1s40p8l1WqvzPDvjnUae2mf2dqnFkHpz0Zxtq9XNXPoboTbAOx099ypx50DrmJsyjCgLzSYLErYcr42xKaUVVYgRp5qqPlYwbkqye72uY8a9hzwOITn4iCLNSDQsiutBeZKaoxGsfaD2ndWRq3ZuQylcvwE8ErPZXymEsAmtTWlU+soNsBRybWNYbxOHbJy8GU32pSvfqYLAO6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.030566, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, This version has the rearrangement of macros from the previous one. We are not sure whether we have completely moved these macros and their corresponding helper to the correct position. Could you please help to check whether they are correct? ~ 1. Motivation When allocating a new memory area where the mapping address range is known, it is observed that the vmap_node->busy.lock is acquired twice but one of the acquisitions is actually unnecessary. 2. Design Among the two acquisitions, the first one occurs in the alloc_vmap_area() function when inserting the vm area into the vm mapping red-black tree, and the second one occurs in the setup_vmalloc_vm() function when updating the properties of the vm, such as flags and address, etc. Combine these two operations together in alloc_vmap_area(), which improves scalability when the vmap_node->busy.lock is contended. By doing so, the need to acquire the lock twice can also be eliminated to once. 3. Test results With the above change, tested on intel sapphire rapids platform(224 vcpu), a 4% performance improvement is gained on stress-ng/pthread(https://github.com/ColinIanKing/stress-ng), which is the stress test of thread creations. rulinhuang [v1] https://lore.kernel.org/all/20240207033059.1565623-1-rulin.huang@intel.com/ [v2] https://lore.kernel.org/all/20240220090521.3316345-1-rulin.huang@intel.com/ [v3] https://lore.kernel.org/all/20240221032905.11392-1-rulin.huang@intel.com/ [v4] https://lore.kernel.org/all/20240222120536.216166-1-rulin.huang@intel.com/ [v5] https://lore.kernel.org/all/20240223130318.112198-2-rulin.huang@intel.com/ [v6] https://lore.kernel.org/lkml/aa8f0413-d055-4b49-bcd3-401e93e01c6d@intel.com/ rulinhuang (2): mm/vmalloc: Moved macros with no functional change happened mm/vmalloc: Eliminated the lock contention from twice to once mm/vmalloc.c | 314 +++++++++++++++++++++++++-------------------------- 1 file changed, 155 insertions(+), 159 deletions(-) base-commit: 10c2cf5fe97647d68ee89b1f921e982e71519f20