Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp409347rdb; Thu, 18 Jan 2024 07:11:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFk6r7VuGlHfKopJwJpb9BKrKV+eBCA/IBelKB9UIVZSWjc+4j42DwckfBMx91UXaZX4tYK X-Received: by 2002:a05:6a00:8cb:b0:6d9:8f4f:5526 with SMTP id s11-20020a056a0008cb00b006d98f4f5526mr1028476pfu.36.1705590703806; Thu, 18 Jan 2024 07:11:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705590703; cv=pass; d=google.com; s=arc-20160816; b=ORFuVwMJSRhvt24J3v8tZkP/14OrAjmlP7N9l2wVINlB2Q2J+HjOlQCv8ABmr5cgTy xokhOqP3vkhXP1PUBtFp51o+wG4BRUjeRIF6Dtqh4YmnqYcGhok6d5+5UcLjN5wVYDkt foo62eMVEnHcIoG/OiaQC+tUqSl/OC8Qt++7lPrsS59gyoYDAdW0uK3LKiKuMhmAfrLF Gv8/LsNz4PlpmQUq64Yeo6kMAWxvylnrTPiWTzYN58UqM4fSqlNHwB7RJ376Jc8nSQxd VRSHKpOgujJuD1REliXOPPBRVNQqNfpvLol4KOJhORysc0D6hz0zK90I/p09PPm61CoZ 5Mwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=n+n3702DzjvE8I5kV3B0z7yiCOBGUE0gdpStZqeKioA=; fh=D1cWAJuGNmcJ1YPMTsJ2cSrPLj+UUf07JbtSjsTOM+8=; b=y6dVwXaaiagHr5ZQ3J6x5LDJqVvRzCJLnB40/tMJFVLub0jWmb8rL1umy0YAdJOuIv P25HiWi43O7MShRUbLtK1uCOh6WYWHij/v56+fbgXVGJ4tvRUuO9f340iuxlQhNW0H32 rxotZe9Vf0+HP82VcwkH6KOfCfB8YT53TNQbybrugkPKh7M4IlMcE4BXYPwnDyilgF3P Cr6xH1hOW37ukvgQY741/mWC7eDI2pI4niGVrhcwqpbleSRHxeNLeU/FmciJ/6ZrTJuV 9ZuFT3FNKi8ooAnXU+JCHNQ8oQ/AQb2+mSUhuAgHsUCr3oBPk6GeXpIDoPiaAqLF2pPT 5ItQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b="RCB/Pm0N"; arc=pass (i=1 spf=pass spfdomain=cmpxchg.org dkim=pass dkdomain=cmpxchg-org.20230601.gappssmtp.com dmarc=pass fromdomain=cmpxchg.org); spf=pass (google.com: domain of linux-kernel+bounces-30241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30241-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f22-20020a635556000000b005c1ce3c9617si1495914pgm.901.2024.01.18.07.11.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 07:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b="RCB/Pm0N"; arc=pass (i=1 spf=pass spfdomain=cmpxchg.org dkim=pass dkdomain=cmpxchg-org.20230601.gappssmtp.com dmarc=pass fromdomain=cmpxchg.org); spf=pass (google.com: domain of linux-kernel+bounces-30241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30241-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 21307B230EE for ; Thu, 18 Jan 2024 15:11:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B54CB1E87A; Thu, 18 Jan 2024 15:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b="RCB/Pm0N" Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 E41841E527 for ; Thu, 18 Jan 2024 15:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705590689; cv=none; b=R+CrAHwxTnZxaWimq4G3NFfjAfp1iEJnUGBLoCEtAqVDV0JEz5xYNOTcuHQPCTeikeURR0KfbDeGGceXjyLwm9lezVpt1vOvhTRXedB5pxiyQgj8kBBDUvFlnk0YUBgdTRW85gfKVophE8G1mVGy9nD+HRWmy6q663gSqnaqz7g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705590689; c=relaxed/simple; bh=ggYTZpEmIwOuDJfSBEFPOlRNL9D4+7ikr65MnXHKMc8=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Received:Date: From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=N68X8yrznPLJKn2i9viSDvsIHh1vayJFkbnOE3I0e+nZBmiHTIXC/hn4ody9HY18+MVt7jhlxin86WqlJlxa6R8RhoN4Ym+2R8miNPgoSVMASKrJ6EpE92ffspwxlPfYiJslzJnGB3AdKvTOEfhVXgQJ2/EFAMs7eCZjpFI+ZWk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b=RCB/Pm0N; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6806914dba7so77121706d6.2 for ; Thu, 18 Jan 2024 07:11:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1705590684; x=1706195484; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=n+n3702DzjvE8I5kV3B0z7yiCOBGUE0gdpStZqeKioA=; b=RCB/Pm0NtX/dgCCmRhyd+/Ybokv/Mu9eXUuJMcDM+Q8HMtqYAdPMzefP7t+Buyc3ny 5+BI8PlkWUekcCMScZnSviWwnq7SyQjfg9ZIqvoZOcEzInRWhtoCEv2Cl0BHdXkJk0YI ZbNHZ3JqfZ3tOmCZ4cS6cVFiJZeqjqOtRVzEov60KEhW23IjCyn+Ee2hIDsq9Ph9Rdzh krGcZyVbSbKUEDzS92aDOKJPFtPra8DZUGIKS7ZLLOOx9Px4JluPs4YdmUEAPpL+Otqm XlwV2atfIP9YAM1Zfku7t6DtQ45a46c+p7sDrOZl7ksuSPUFAncpZxUkhiIj7I0dOjbj bWdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705590684; x=1706195484; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=n+n3702DzjvE8I5kV3B0z7yiCOBGUE0gdpStZqeKioA=; b=XuQF0LvihFc3eOL/7mGP9By9kPsGCwgTL4Ne/TeKCSJAhpp+7RBsowNYfHIhSZGMeT 7+1pAodKB6T/pWGiN3H6/+jaGLXxL6pqcTE9czw2Hkx+yYQLIEvAF9EYmfRCGXiizKDk tGrWwHcpWgagNp8CUom3UUcQUVFxkmDt+TKfmZ9Gj8vtJQuTWo48XNA3b0n3lE3Wn3wE 0Y1OtwGd4089JxB6GbPtlgnh8B08RREqhr6gCAHkJquc5e+MOSyncy3SVH0dFij9GzYg PrhpwpSwljG6QhlSbshqYZI4Ryx6OSu8It9IwMqw3WqeNOB5qpkGW0xshBkrPgTbXnR9 ofbw== X-Gm-Message-State: AOJu0YxnmjpES8lFBc+PzpGd6h9r0O02EwKq8b0eUxAny5INb7HzGVHn oop/jE+RnJ+8cYXs80zpezFHjaVKsNg8YqGCS3afmfrZ5AiDG0712/GIUTcJ1JA= X-Received: by 2002:a05:6214:5191:b0:681:7859:8d7f with SMTP id kl17-20020a056214519100b0068178598d7fmr894837qvb.81.1705590684757; Thu, 18 Jan 2024 07:11:24 -0800 (PST) Received: from localhost ([2620:10d:c091:400::5:dd09]) by smtp.gmail.com with ESMTPSA id pd2-20020a056214490200b0068187a62fc0sm993203qvb.90.2024.01.18.07.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 07:11:24 -0800 (PST) Date: Thu, 18 Jan 2024 10:11:23 -0500 From: Johannes Weiner To: Chengming Zhou Cc: Andrew Morton , Yosry Ahmed , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chris Li , Nhat Pham Subject: Re: [PATCH 2/2] mm/zswap: split zswap rb-tree Message-ID: <20240118151123.GH939255@cmpxchg.org> References: <20240117-b4-zswap-lock-optimize-v1-0-23f6effe5775@bytedance.com> <20240117-b4-zswap-lock-optimize-v1-2-23f6effe5775@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240117-b4-zswap-lock-optimize-v1-2-23f6effe5775@bytedance.com> On Wed, Jan 17, 2024 at 09:23:19AM +0000, 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. > > Signed-off-by: Chengming Zhou Acked-by: Johannes Weiner One minor nit: > @@ -265,6 +266,10 @@ static bool zswap_has_pool; > * helpers and fwd declarations > **********************************/ > > +#define swap_zswap_tree(entry) \ > + (&zswap_trees[swp_type(entry)][swp_offset(entry) \ > + >> SWAP_ADDRESS_SPACE_SHIFT]) Make this a static inline function instead?