Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp315802rdb; Mon, 22 Jan 2024 23:46:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEN2qKkXHaZtjTjrk2tknwdeJWT+8JO/hvek9MEDXgkxPD2e9oZWUr4GBvjXTEJXRx+inVo X-Received: by 2002:a2e:740b:0:b0:2cd:3227:130c with SMTP id p11-20020a2e740b000000b002cd3227130cmr2565424ljc.95.1705996001214; Mon, 22 Jan 2024 23:46:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705996001; cv=pass; d=google.com; s=arc-20160816; b=Dg97Hl26Pswvys3e2AqidQ5N3rT4+439w+SVdTGwm7Qe6tomWlEmT48rWKX2129f4W PRvHLRy5Us5BFfm5N4myJxjYP/8CyhxLOA0yCaiMB7NTWdDxGcCMI7b+N5g6nCLHagj/ 3+yZnJJGA+T7ERWSF2VGpJPK9eEnLMMhtsG90dSGBczAszG9eoTg8oXWSUOq7l8ZzshH F854KBzbrImNYqz6FiyRspPFOiBPzLAAqsJHTVkAvqQTC3fnyDiFZaO1N5XD3IfeY4Vx S0r/MJSm3sVNwjkFJ880I5yJZ5tBbJHMfgonAhdn82rIcfafg4RgaBhGXG8Ccw/zg7mI 17Tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=jicH4Sl95+680VziAGp6RFmScRJlie55hSPce6vSEjk=; fh=uYEXVF74CdFQ8qh6gYuB9bBhW3pSNoNW3hpSEO2WWho=; b=b8vjAHgCNIhMJv+pvUfM7H6N8WsSzCw0rCL4eqwG8K1uKzErT1PzyIwGy1Flh9dJgE bSzkMLSokWH8e76omCPru+5prMjNq2y91PBILFrfRSXwTsajORHFjoFZjl5CFtqBFTOw EAd90EmEV5yFsdIQNi6qcl92xHxZ5IvC7vE1xO1A97PdspJfHX7k77COOUh/QZEWwkD5 GjXTOJf0e1U8+9UD5MpUjAGTwOlppaNVBGJrvNroqVzxOnqvJyo/nkB2EXjxq+T66+A6 9WDzmhK+IsDSUl31RnMPBCamk1BIeiIrUF7EL7GcpdVGCqyQHM56NM6pBaQxUQwrHgXe Y1gA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=ZPs6vU17; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-34844-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34844-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bf16-20020a0564021a5000b0055a4d0e3a77si4773567edb.266.2024.01.22.23.46.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 23:46:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34844-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=ZPs6vU17; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-34844-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34844-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E88A41F23D89 for ; Tue, 23 Jan 2024 07:46:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66E2452F82; Tue, 23 Jan 2024 07:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="ZPs6vU17" Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65EC22AE91 for ; Tue, 23 Jan 2024 07:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705995993; cv=none; b=P80VsOOwrzkTz44z53Nj72EreQ8CsdELBq5texmj3hrf1cxxyI+yZlDVmfwP6uoHieFrhmfL/zQ/zkWjfet3LgWRaIJThaWFa53oGYkLcyGucnbOn8a7/WXTxqKD02JkZoab0uAZn45TlJ1c3wiuZfS7v2isuHrSCm3nuRkJcLc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705995993; c=relaxed/simple; bh=hoPao9tbGJ9KjiTRhQfBNtRT2yMUls7NC9FEvroT+Rc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jFbpGwu2ob70LstnWT1oQS7PjL6yZVrX3ICRboAehPskN0bDIFqqyoc1mDa8Qn2c8bp/R6hsVQkWOXpKWBc8Y1BokLpLkNODs9iyLtqyrQhfX6IbOIUUoH/gUjJ1N7y+0QYhHtSjn94xw7xMVSMMe9vr6lT6zkEehAbZ9b4duGo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=ZPs6vU17; arc=none smtp.client-ip=209.85.210.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6ddf1e88e51so3109490a34.0 for ; Mon, 22 Jan 2024 23:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1705995990; x=1706600790; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=jicH4Sl95+680VziAGp6RFmScRJlie55hSPce6vSEjk=; b=ZPs6vU17sXmArMIb7vx6PrKPwmAxjoIghVpjvZPd2nD10KYeycw/gyIrcZeddMpi6O rwhZnZSiGd3qPwogS/OT71mJDbdTTzBNreR3LvjXlltLaldKh5iX4Ats7Df7ABKT6a37 qLhO4ryAowlzzTkGF/JDJczUPK3z+IXm1TZ2GvL0npRKptNbz6eSKrGmKwfinHxf/4gZ Oefd9zWxgfYRduCZ7SC/gmP8h3yzJa3E2qr63xMbOYMd5rT/OTnu6t99ut6kG7Wg/jKH Id4nleOJ1/+0PUKeEVcDj0o5eo1faUXx+Fo//atTke/KJo6oQ+njAPUvlS6FkS+mpktP v7yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705995990; x=1706600790; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jicH4Sl95+680VziAGp6RFmScRJlie55hSPce6vSEjk=; b=P9pNVT0q4Ag+LsMs5aO4j4Ha8DoOiQyT/367rHaYMSJt6YRkPe3nAXtJOFarw/xRNi b81t4UKSoPnZL5pSQUshWzFtHljrrxcZUXSsgY1P4tkc77ZAh4Pp6K+kUcjD54dtotDN ioc4maRcz1n9nSLAV8RQ2OwI8udQhZjnQaNvu7Hinldwzj9SGVnD5XxJpMVw+APA25zW 1rm3DVpS3AYar57BSMia8jLdltIHRJU5DO0LWWcl67SsS5znLF3DXnQ7pRC2ERBSyLu4 m1RGTlJTvIVppzM6zDjYvRlIJlJRWD/QC7DXCx4MwXd0KH+M9PuiuMahorqd/ILgxBDi ZhFg== X-Gm-Message-State: AOJu0Yxo7AdSGUGRJA70qmZ+VjjBtbHwKu+63B+Ibp2lrLtgiLiQh6oJ ZmR/eZ885k17u0XDegq8HutyOvWZDs9X3fvKXsOAhhPKKZzIppf3WsqOfqTPKnA= X-Received: by 2002:a05:6358:281a:b0:176:5e4:cb8d with SMTP id k26-20020a056358281a00b0017605e4cb8dmr4210665rwb.51.1705995990275; Mon, 22 Jan 2024 23:46:30 -0800 (PST) Received: from [10.254.236.83] ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id h20-20020a62b414000000b006d9a9727a8esm11199033pfn.178.2024.01.22.23.46.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jan 2024 23:46:29 -0800 (PST) Message-ID: <572bfa89-83c3-45ed-abc6-d71b9519813c@bytedance.com> Date: Tue, 23 Jan 2024 15:46:25 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] mm/zswap: split zswap rb-tree Content-Language: en-US To: Yosry Ahmed Cc: Andrew Morton , Nhat Pham , Chris Li , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Johannes Weiner References: <20240117-b4-zswap-lock-optimize-v2-0-b5cc55479090@bytedance.com> <20240117-b4-zswap-lock-optimize-v2-2-b5cc55479090@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2024/1/23 03:49, Yosry Ahmed wrote: > On Fri, Jan 19, 2024 at 3:22 AM Chengming Zhou > wrote: >> >> Each swapfile has one rb-tree to search the mapping of swp_entry_t to >> zswap_entry, that use a spinlock to protect, which can cause heavy lock >> contention if multiple tasks zswap_store/load concurrently. >> >> Optimize the scalability problem by splitting the zswap rb-tree into >> multiple rb-trees, each corresponds to SWAP_ADDRESS_SPACE_PAGES (64M), >> just like we did in the swap cache address_space splitting. >> >> Although this method can't solve the spinlock contention completely, it >> can mitigate much of that contention. Below is the results of kernel build >> in tmpfs with zswap shrinker enabled: >> >> linux-next zswap-lock-optimize >> real 1m9.181s 1m3.820s >> user 17m44.036s 17m40.100s >> sys 7m37.297s 4m54.622s >> >> So there are clearly improvements. > > If/when you respin this, can you mention that testing was done with a > single swapfile? I assume the improvements will be less with multiple > swapfiles as lock contention should be better. > Ok. Not sure how much improvement, may do some tests later. >> >> Acked-by: Johannes Weiner >> Acked-by: Nhat Pham > > I think the diff in zswap_swapoff() should be much simpler with the > tree(s) cleanup removed. Otherwise LGTM. > > Acked-by: Yosry Ahmed Right, thanks!