Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp809133rdb; Thu, 18 Jan 2024 22:21:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3VkuCJeixrI8Adb1fs7xMgfUaYL8kJQS4tU2MNcrPTpo1Ko73bihhX3A/RPzXugRCdBLf X-Received: by 2002:a17:907:c011:b0:a2e:3af3:a163 with SMTP id ss17-20020a170907c01100b00a2e3af3a163mr1356085ejc.0.1705645279846; Thu, 18 Jan 2024 22:21:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705645279; cv=pass; d=google.com; s=arc-20160816; b=irPwUkm0Sr6QouJ3YRJ7vT2+RqS7IHZHucqQvW0hgeVDp17hIIMA70JGrvMp7i9P9F KOGhLFc/ErVpxzI5zxtPrSd41P1L6HfD5wz/F+zo1b1CTimsyqG5ouQ+m+kUdaUJUGCc /XiOyXiBQ4i4xJqGDGCMiQHNhlidqzFnPkeXOpJmFCyHpDkIy6MpmiDc6wAqzRUAX9qG gL8W7cwUa3aiC3tYbl1dD8yWVV9w4SpOQKh4zqY6toIyROYs+Jh4ZUIhWvCoaDPJvdE+ CpwBc9hDSH+65G1tEIUL1IWDkc3NJGVNfCdFRcBnoOeeyktQ4JAPy0s/vmqC13KQVxBB klmQ== 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=D3VHIi4EcMrxvY3GiWV/JZSeHigZUaqOcO0zANnBCwA=; fh=nvytDj/DRsnKsCDHxOKcD3chd8Gm5RqyL3D4C8iruXc=; b=nx99EFed8DGSwtlFJh5MVJCL6OPxa7ZXzY+lvgaQZbHE5PtQ8gVSBcUy0jgU0laChc 5XO81CNfn3vt8FfKL5ZQArvBwZcgS/6y+nMT10jK9LhpZeC1+GW7ZkFhUDCHBAUxCIN3 CSiGYiGrZmYvvfq0+v7iQShkg/labz2+P3bwqKGILFDjPfEt0xz5CWekIPNaUOkkqnub l2krJu7d7XHl9LKec8xqUVu0rBwzH8p/5C42VqohqyBW22BKDBvOY9OmvCLl/cKYZEaR EJPUQ2LdgMYtbwfWtoBueC4tumvhCiASWxmGp8gOod63wGhyNp1G69vA+inGufEHVXCK 1EKA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=iM3gzWnp; 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-30807-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30807-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 k24-20020a1709062a5800b00a2a0e22d76csi7698467eje.750.2024.01.18.22.21.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 22:21:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30807-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=iM3gzWnp; 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-30807-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30807-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 8FB591F223D7 for ; Fri, 19 Jan 2024 06:21:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3D2363CF; Fri, 19 Jan 2024 06:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="iM3gzWnp" Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 38A325381 for ; Fri, 19 Jan 2024 06:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705645258; cv=none; b=lzOnxdaMiP7PTH7ZSNqtKmYl4j08qBRr9gF51deVHJunPxKOiCPPLaOGdyX27Qux6ZZ+TtrfAS+eQloaP60ZIJUuT2icYA5zS0UOrFzRIOjSxEaYeKEfg5myGyXPsH5qH/htHYWdQrtuK+cSMYG4W6tEYZmv0+NB1zeePavuSHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705645258; c=relaxed/simple; bh=nkyIhW/V0YN44OOpH475TcG8PZRvB9SjnwfgrEEUXm0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=O2eXYkPDI88eNHbRRFXlnSabc5J8N7L5yognyMI+wgL4VP7U6pORknnPkg5WuMdryPa4kABII77NohiIIJAbFlK7xcV4qzAfz5T6VZTt8WusQtyu6yCxi9c5viABE4E0+XXCoH1FF5gVW5kCGxB4BLuaT5hiKjXwxU7ZJ5qJi9k= 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=iM3gzWnp; arc=none smtp.client-ip=209.85.167.181 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-oi1-f181.google.com with SMTP id 5614622812f47-3bd4e6a7cb0so258554b6e.3 for ; Thu, 18 Jan 2024 22:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1705645256; x=1706250056; 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=D3VHIi4EcMrxvY3GiWV/JZSeHigZUaqOcO0zANnBCwA=; b=iM3gzWnpAtVQ+GmG1tDkICMQTBbTobrgee6jcGUJ4lrtGrWhDlraIgtYEG5FXolS+e JD7wEmCJy54axnCGr7VuatjK3ysvBHCPxPQxrn9OS2nxAFVQCCcbg2ktKijVXV/PfVE/ 2Dj2aZkkXhMsigk0pNKFwpKUZ7h8kfmjTNGVWH9lKC5NqWpZmQh5WFxI9bOi6yx3YRzc xBwEIObmoMrmS30b+LvzPv6pINgJZTb/blQQUXXpZJABJLLdCT7GS/cJE1wUAhTFXhsg wNIMBXpnvOcUj/OWJM7rm4lgQ+BRdukYX0wddVyw+rO78FFeCbcc6rXKd5TgUhCwFfU1 lmEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705645256; x=1706250056; 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=D3VHIi4EcMrxvY3GiWV/JZSeHigZUaqOcO0zANnBCwA=; b=e/0xeP0EOUsKwlxkswiToko0bjvguXsuaswz+MX9wqUsILt84UufGNZOGddCaXdblE LZuu/eEovQG+C/Yv3y8xAeR/Kc03L0yPj36tvEqVj+x6KrzO7Mfl8EFJE2kYLKW9niAA 1NzWokLV9wbsF97jftpkMs+JsVFmMLRC6Fsq2TbKeZ+4XhR4GgAe4xOvlYw1ScSSflau Yh0zus1x0Uk90zzBhli26wkV2At8ob3H2sMVjqc0YsbMFeRkvheAv6bYdqyoc0jEt103 ehaeXpzVAUkAkiHravpWf3dIGsrEDBVmX7OmliJUsz+e78F4sCBbwGBtrxRGxG1ySuo3 E9kA== X-Gm-Message-State: AOJu0Yx5BYLwd5URRb7X8M4SbhMtrUp8ez5GtiYHlO+1fUdC7W93yQ/j DXq3d4c52KFAxYFggh26ZlBnXviPvLpSlYQ7TGIknETbAXBVYwy0rptSMoDf8Ec= X-Received: by 2002:a05:6808:2123:b0:3bd:a1bd:a9d9 with SMTP id r35-20020a056808212300b003bda1bda9d9mr1067863oiw.33.1705645256248; Thu, 18 Jan 2024 22:20:56 -0800 (PST) Received: from [10.254.224.1] ([139.177.225.241]) by smtp.gmail.com with ESMTPSA id s17-20020a62e711000000b006daf14dc95asm4417111pfh.142.2024.01.18.22.20.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jan 2024 22:20:55 -0800 (PST) Message-ID: Date: Fri, 19 Jan 2024 14:20:51 +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 2/2] mm/zswap: split zswap rb-tree Content-Language: en-US To: Johannes Weiner Cc: Andrew Morton , Yosry Ahmed , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chris Li , Nhat Pham References: <20240117-b4-zswap-lock-optimize-v1-0-23f6effe5775@bytedance.com> <20240117-b4-zswap-lock-optimize-v1-2-23f6effe5775@bytedance.com> <20240118151123.GH939255@cmpxchg.org> From: Chengming Zhou In-Reply-To: <20240118151123.GH939255@cmpxchg.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2024/1/18 23:11, Johannes Weiner wrote: > 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? Good suggestion, will do. Thanks.