From mboxrd@z Thu Jan 1 00:00:00 1970 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 E2B0AC02198 for ; Mon, 10 Feb 2025 09:15:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 593A66B007B; Mon, 10 Feb 2025 04:15:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 51BE76B0083; Mon, 10 Feb 2025 04:15:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 397896B0085; Mon, 10 Feb 2025 04:15:22 -0500 (EST) 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 1A0616B007B for ; Mon, 10 Feb 2025 04:15:22 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CB1121A0871 for ; Mon, 10 Feb 2025 09:15:21 +0000 (UTC) X-FDA: 83103476442.08.79D7E9A Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf08.hostedemail.com (Postfix) with ESMTP id 7B80616000A for ; Mon, 10 Feb 2025 09:15:19 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=KMazZUZN; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=FOCRfSHf; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=KMazZUZN; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=FOCRfSHf; spf=pass (imf08.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739178919; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NT6Y3qhRyAsyFJFpCq4OSd5s89jdYk1Kn+n0Tiyzstk=; b=jeeF5GQ78NLIusyLgTx4xXGuoLm+tjM7Qe9sNfBWWU+0bSoAeAlq8hx26PfHaTaX7A9cOy wZ6MCl66pZlhvbJPGRrtw3rG74D52cthlHTQ+k+eJSV2+aiHcje0lz9gTT6z9iFhMe4EKW Q9UqUj5Pq6oBHz+wm7I2GrBD+q8izWM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=KMazZUZN; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=FOCRfSHf; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=KMazZUZN; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=FOCRfSHf; spf=pass (imf08.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739178919; a=rsa-sha256; cv=none; b=aPi2Q7KahOJ8cbit5wPdPvWQkXRbetBacG4P9m264bAKztfgkkQ+fuYK50CYv17sAOXmMt 0td/8wKQE5JNnpkkVnQvpi23D8SzR2KXnUUfRXkG+S8uwQTiUhuBkQoxNH/oCKtxh3Lmq4 75UfAJcx96+TxMdoEL6Uigo53ZPYdjM= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BD1581F37E; Mon, 10 Feb 2025 09:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1739178917; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NT6Y3qhRyAsyFJFpCq4OSd5s89jdYk1Kn+n0Tiyzstk=; b=KMazZUZN7HSxDbhwbrEaucHWQ2L5akigIUdGTXqXKFrs3M1DAOw07L1LKKfy/FA+9mJUIf ZP/Xgu+mZjxhex/lFLkiyJfXWIuzPW5hHjtxjixzbIfy26Yhe8ys0DSrPZSU33cQq4bIyN YF1oWbqu5z62lXEgYbwEPe3Kh4W3Q8M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1739178917; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NT6Y3qhRyAsyFJFpCq4OSd5s89jdYk1Kn+n0Tiyzstk=; b=FOCRfSHfSOVWf/2dCM3dw6Xd7xrFVZb8XEl56VGhAsc3CC8m3l7YknJwK4sbFBvvDqgrHw HSFPk3n6HixjMvAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1739178917; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NT6Y3qhRyAsyFJFpCq4OSd5s89jdYk1Kn+n0Tiyzstk=; b=KMazZUZN7HSxDbhwbrEaucHWQ2L5akigIUdGTXqXKFrs3M1DAOw07L1LKKfy/FA+9mJUIf ZP/Xgu+mZjxhex/lFLkiyJfXWIuzPW5hHjtxjixzbIfy26Yhe8ys0DSrPZSU33cQq4bIyN YF1oWbqu5z62lXEgYbwEPe3Kh4W3Q8M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1739178917; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NT6Y3qhRyAsyFJFpCq4OSd5s89jdYk1Kn+n0Tiyzstk=; b=FOCRfSHfSOVWf/2dCM3dw6Xd7xrFVZb8XEl56VGhAsc3CC8m3l7YknJwK4sbFBvvDqgrHw HSFPk3n6HixjMvAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3CD1013A62; Mon, 10 Feb 2025 09:15:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SvIWDKXDqWclMgAAD6G6ig (envelope-from ); Mon, 10 Feb 2025 09:15:17 +0000 Date: Mon, 10 Feb 2025 10:15:07 +0100 From: Oscar Salvador To: yangge1116@126.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, 21cnbao@gmail.com, david@redhat.com, baolin.wang@linux.alibaba.com, aisheng.dong@nxp.com, liuzixing@hygon.cn Subject: Re: [PATCH V2] mm/cma: using per-CMA locks to improve concurrent allocation performance Message-ID: References: <1739152566-744-1-git-send-email-yangge1116@126.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1739152566-744-1-git-send-email-yangge1116@126.com> X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7B80616000A X-Stat-Signature: ebdtcjc7e88cxsk7rp1m6sbuxgm9xi6k X-HE-Tag: 1739178919-53684 X-HE-Meta: U2FsdGVkX18N5ZJiATrS+g7nig1Q0I3MkVjaIK0LJdQkR67BY5tweFG7pCOW4pG24sfIAej0MwlIqDshRXv4XjS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ebjN0nq0EhFn98aI2IPU9hOMrYzcn0gxR4vebHV2q+LJDLPzlq5i2UJZuX5TLG1Omlej4aIIICHXli05jv2ijl9WLIIpDNy7NFZiAvq0i20BYTAPPGUa+Z/7rxW7AeXYN0PZy0uFn2Q4v/hU 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 Mon, Feb 10, 2025 at 09:56:06AM +0800, yangge1116@126.com wrote: > From: yangge > > For different CMAs, concurrent allocation of CMA memory ideally should not > require synchronization using locks. Currently, a global cma_mutex lock is > employed to synchronize all CMA allocations, which can impact the > performance of concurrent allocations across different CMAs. > > To test the performance impact, follow these steps: > 1. Boot the kernel with the command line argument hugetlb_cma=30G to > allocate a 30GB CMA area specifically for huge page allocations. (note: > on my machine, which has 3 nodes, each node is initialized with 10G of > CMA) > 2. Use the dd command with parameters if=/dev/zero of=/dev/shm/file bs=1G > count=30 to fully utilize the CMA area by writing zeroes to a file in > /dev/shm. > 3. Open three terminals and execute the following commands simultaneously: > (Note: Each of these commands attempts to allocate 10GB [2621440 * 4KB > pages] of CMA memory.) > On Terminal 1: time echo 2621440 > /sys/kernel/debug/cma/hugetlb1/alloc > On Terminal 2: time echo 2621440 > /sys/kernel/debug/cma/hugetlb2/alloc > On Terminal 3: time echo 2621440 > /sys/kernel/debug/cma/hugetlb3/alloc > > We attempt to allocate pages through the CMA debug interface and use the > time command to measure the duration of each allocation. > Performance comparison: > Without this patch With this patch > Terminal1 ~7s ~7s > Terminal2 ~14s ~8s > Terminal3 ~21s ~7s > > To slove problem above, we could use per-CMA locks to improve concurrent > allocation performance. This would allow each CMA to be managed > independently, reducing the need for a global lock and thus improving > scalability and performance. > > Signed-off-by: yangge Reviewed-by: Oscar Salvador -- Oscar Salvador SUSE Labs