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 C9249C636D3 for ; Thu, 2 Feb 2023 23:25:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D4C06B0071; Thu, 2 Feb 2023 18:25:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 384F36B0073; Thu, 2 Feb 2023 18:25:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24CE96B0074; Thu, 2 Feb 2023 18:25:06 -0500 (EST) 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 171646B0071 for ; Thu, 2 Feb 2023 18:25:06 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E551D40520 for ; Thu, 2 Feb 2023 23:25:05 +0000 (UTC) X-FDA: 80423934570.27.3258885 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 33B491C0006 for ; Thu, 2 Feb 2023 23:25:04 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=ReneXY26; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675380304; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cFwPWWVa+Pe2v5uHYqVTosyvMn0hC8SZ/Ay0H25eQsI=; b=5KhMc0yHNaXE976uEONEcmeXpkZCQHy0eqAS04q2z4MbCe5tVN6Q105bsQ48LNJ4mb6+eD AwPWgDJZjam5zOzG4KpiVmSznlJpya2QHZSYmRyI8XhIrSd5m3QRTtYgTJ7/VnPNBTG8dj KCRIk1kJT7SDdN3WbVoe9wnQ0SIhlUE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=ReneXY26; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675380304; a=rsa-sha256; cv=none; b=zpa4i08RJJcxefGE2jebMEBRD2OAuysD2SUKw5j/wZTyhO6L7vfZuUqVvbtaHrCnzGSYh6 aRYhAgrBPKDVH7P4qP9djKBxyy1cIQJvHtU+T/rrD3enE8nNsPvxT37mxWYcOT8QL+TKux 3cDM2+EW88rw2Zrpt4JflIMK1CXqJWA= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1FD8361CFD; Thu, 2 Feb 2023 23:25:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 467ACC433D2; Thu, 2 Feb 2023 23:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1675380302; bh=p6iGgW+S3so5tfsC9Yq/DTYA9eV8RMMsa/ZHihwLc9s=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ReneXY26xWv6cvGo9Uc9bLyavSQJVlF9mcn7BzXyImSKlGY8UouFUaos0rW5PE9qf HhgE3/IEikRj9Y6/qqHBd7eCKPVk77stMXQpZdQ/+gUbpIwR7Za5j0QISj7rCLtU1L 0HM1pVpMxaLmq0+HzIovbAZtUc3aSItpkZw2VeFw= Date: Thu, 2 Feb 2023 15:25:01 -0800 From: Andrew Morton To: Alexander Halbuer Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vlastimil Babka , Mel Gorman Subject: Re: [PATCH] mm: reduce lock contention of pcp buffer refill Message-Id: <20230202152501.297639031e96baad35cdab17@linux-foundation.org> In-Reply-To: <20230201162549.68384-1-halbuer@sra.uni-hannover.de> References: <20230201162549.68384-1-halbuer@sra.uni-hannover.de> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 33B491C0006 X-Stat-Signature: 9g318b8hnehisjqfzy9zqctqjs3w545o X-Rspam-User: X-HE-Tag: 1675380304-965560 X-HE-Meta: U2FsdGVkX19ovsrm/5EdKpHXqR564MoIZ8zUf5PPND4ZZ1CN7v+JzBn2fR8hTosuY8OP6+OySnLdVv0hBh7FUMdXw1ZIVkNn0O8EI2jKDHguXu/hVz89CjhpygaWE5G/iTBPoRlaMrEqgTP+JwEkJHR5HxTj0uagcdR6DYLIoSpGhrYGIME3XR9xVLlgShFJDGOVDqTFITsFApMnB4/qT5xHMyYsUkAaXTs15YuOkzukDoLu7pxtkLS/3dMewm1QwgUrfhq5yDBwMW4rAx9F96JF7f2BQOlT1/SvK+qcybmXRE429CcBwD+k956QX806bamures7a1XIpXdhyR37YXEr+edeGRtbHMXqveCaZYXHtaaJc2qTK1Q4xdli73+xI6vWkT8fDkU+k4klB9/c+UturuDeXRB8K1BlgRlPSKjp1wvV3qfNmZUQ5SxhsP1SH5aIJF52mN54tnIR5J/40W5ANMxG5ZQPD/eQoqAmF66qpd2T1T+K3qIBzm48jolHxMzB8HW8D963zayewVJn//yBAwcq9rpx3FOwzf8fmIpMXyri/IzwYg7sULaIWt1W9URINZ7ncHuZXOtR381ipWCxMoxNZ7ZqMP2VlVD69SdA0XS5CCc9uc0nBNOQ4fC4M+YDlH5U2a5iP03vMbGds+ecEXyYOyu1dgAJEn5UFiMFNqTM51o/sNlCeKJyFuu29vnFR7KE1MGZpu/qa7SMig5e9IQdHYcex/iovv1TsIXk57p5hfjwJIleik9bu5FcxSnHO60IwrQHDZ2Ew0XA3Z0uwmEK5Z2BBTH4gLmqDcbaQErq54ZyEhZ5bFS2lrZL1MmAgRF8FwmPLSefggrqEi2IOWHTG2PEcNw/Q3SwsOKySosRFwJfWE1joPu+r/wyzfNcpE/PDqkUag94UXkf12FfxEmv9AKsF/QjwfNb1MZ/Ptz9BJuPwwzxMOzGLsZbR2BTRzgA9WtMJoig30G mLZ9oR/b lb025IlFSdJMXXzm3EB+TVPZN4SnpqOpYGaX98rpPQPLdXXxisRS5b0pF8k0Ut3qoiot1lEDINBGuZa5cu9ahDLYQtJruwHBT+wC14ZTNBHNLl/DpeVM4+bs67X3EbErkIqdTXkWrtAVNhgjuqStY8z+ZDnk+hZ2aVmWJfeY67CoV8l2P3m4GK2aa2KBtIA4tMNZ9l3MUX9YsoOoGctfXDCeY4pzZHXbvKMjeMY38hnAcg1bdIgxSK/rfUTIb6XCeI3+EIg6wRC8V2vZm+fytsoSTxCPZx5Vm6AXLc8o/CDE1mkJVDHsFfpRsKmsYv6TMUJg6nx2ewvPVXLHhTNYO5EWWWw== 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: On Wed, 1 Feb 2023 17:25:49 +0100 Alexander Halbuer wrote: > The `rmqueue_bulk` function batches the allocation of multiple elements to > refill the per-CPU buffers into a single hold of the zone lock. Each > element is allocated and checked using the `check_pcp_refill` function. > The check touches every related struct page which is especially expensive > for higher order allocations (huge pages). This patch reduces the time > holding the lock by moving the check out of the critical section similar > to the `rmqueue_buddy` function which allocates a single element. > Measurements of parallel allocation-heavy workloads show a reduction of > the average huge page allocation latency of 50 percent for two cores and > nearly 90 percent for 24 cores. Sounds nice. Were you able to test how much benefit we get by simply removing the check_new_pages() call from rmqueue_bulk()? Vlastimil, I find this quite confusing: #ifdef CONFIG_DEBUG_VM /* * With DEBUG_VM enabled, order-0 pages are checked for expected state when * being allocated from pcp lists. With debug_pagealloc also enabled, they are * also checked when pcp lists are refilled from the free lists. */ static inline bool check_pcp_refill(struct page *page, unsigned int order) { if (debug_pagealloc_enabled_static()) return check_new_pages(page, order); else return false; } static inline bool check_new_pcp(struct page *page, unsigned int order) { return check_new_pages(page, order); } #else /* * With DEBUG_VM disabled, free order-0 pages are checked for expected state * when pcp lists are being refilled from the free lists. With debug_pagealloc * enabled, they are also checked when being allocated from the pcp lists. */ static inline bool check_pcp_refill(struct page *page, unsigned int order) { return check_new_pages(page, order); } static inline bool check_new_pcp(struct page *page, unsigned int order) { if (debug_pagealloc_enabled_static()) return check_new_pages(page, order); else return false; } #endif /* CONFIG_DEBUG_VM */ and the 4462b32c9285b5 changelog is a struggle to follow. Why are we performing *any* checks when CONFIG_DEBUG_VM=n and when debug_pagealloc_enabled is false? Anyway, these checks sounds quite costly so let's revisit their desirability?