Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1133817rdb; Wed, 6 Dec 2023 09:24:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHS2E5MbcBOnuchFjbu1eW1UGILpMkT9JNrOwdVdAvMeONX1Zbs6yaUJ5mtXaAK5lKahgWI X-Received: by 2002:a17:903:22d2:b0:1d0:6d5d:5e4d with SMTP id y18-20020a17090322d200b001d06d5d5e4dmr961211plg.59.1701883493722; Wed, 06 Dec 2023 09:24:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701883493; cv=none; d=google.com; s=arc-20160816; b=HLy/rQt48EY22LzZK42ysgD7xh9h3rcV8+KJ3n0khNsSN2eLy9sYGlDDaPmHBeHU5b auLSO0im/9iF9l/t+QGxedIgqCHdsWgOEDRkVvB8dNLQmOKvn/O6lI2wibXK59R/0471 5M0MnenRVfjqWjcSDdwALi2in3Lc8gjioUPN2HXuMl0neAxLRRXSIe/2WzkELaX6NT6H gyHebbZbGLsKbYIHDuMXsgANCrsOXzqo4RBYd5qlE3IXhSxUly2mfjpZqexiIEbFCF5q yQpiP5nC1yDzhHqUW0h7kna0/8dinA4uUCB9OgaAIWnMdoAzZ7xYB04RLAlFxtbTQSw5 n7MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=YFtw+JoIilNzXGrK1+eC18U9vk6uZG0kOBjgadIHka0=; fh=QthZMIyCv0iyIzv3aQBa06eb9XDHMRZhXwz8B3xSL4g=; b=xG+MibdXXj3fm0hTOl1OOornszv4H8Kii4QjNwwSkYQ9LhXMGiF7p6gRr+S+U9Vb0Q opY0W/3XT5baV79rCdtPPbS8wt9k7EQm9w/0pfUev1jFv9Quk0B7rsITJJp+31zP+Utf End4V0qdxm6JVVRDBZKOJGf4P4cRnPxLQk/RUfQt2FmtHgs2vPD7Z2b3WLDfm9JVCn3I x6NlQMovRPXGvadNp2kzCvhJHtA+49zOLG2NxM3nU5mU4H1DPO5YWg8/GpkFNB4BG8rm oFtk00Q1UfzB0d0VxNrSBQQRn/N7n+tCptF+U6TBzmLxGEZYRwckUhTS2XLZQIeLY2U9 i9Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MnejqmE5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id s22-20020a170902b19600b001cff290413bsi99286plr.390.2023.12.06.09.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 09:24:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MnejqmE5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B742A8080D68; Wed, 6 Dec 2023 09:24:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378234AbjLFRYh (ORCPT + 99 others); Wed, 6 Dec 2023 12:24:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbjLFRYg (ORCPT ); Wed, 6 Dec 2023 12:24:36 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D84584 for ; Wed, 6 Dec 2023 09:24:43 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7b3905b1b86so377635139f.3 for ; Wed, 06 Dec 2023 09:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701883482; x=1702488282; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YFtw+JoIilNzXGrK1+eC18U9vk6uZG0kOBjgadIHka0=; b=MnejqmE5jBPm6sWmE608gloSJO4EShWcmsUSzBtgQvR8LOxXX2ctJ33TDvKkjCj/Ua E6Z2pawZpE/iQCOy+xFnuOHjRfULnuq0HuveKvGmaYwan4p1vjPwsV1MJvMFCWrC7fRt x2urupDDM2scNO5yNeXMIlMEsmf2MMHY+/b5IXzJNBO6WjLSKoLYE5LfOSm+IXcxzqVS rzdmJMPs7w9+Iw3Rudxapr0dwfeq5dACX/CMVQNGtEjxU1XmNGhAePj+z5qaS4vDEt/E g4QxUPA8OYAwN5JMIYc5vQxKwrb07MHMbtDI0efmlq+5bzCAXemt1lax227z3xX/FAUr daPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701883482; x=1702488282; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YFtw+JoIilNzXGrK1+eC18U9vk6uZG0kOBjgadIHka0=; b=wYUxfGIoYl2r1GEyadSdeCDS0z3DIlu4zkKfuKIqQHHl2YuxfTYtd9i9ea7wRKjEZi C5pvrEhgRtq0hrKVdBPqh0XIrGN888kiPJXc3smaugtlQkUajLA3/06zQ+gTiFSX5IRU yvYh9T5HdB5msb5AeU3tIbb2pG3mrFXV98OrX1g9q0lth4MNJLaI6VCyTrhMk/CtgCca fL0tRPkl/2n5miUyMYEJj/7bXGmjLU6iNLaIaRcSFWlUiprvuubpL+e9YgtcME/Xy2Tc vclQDXcmYzO/wQt1NCo3FVBevi7PiEwqo+2BhfcE0tvs27zyCTOtcw6XZiJtZwrZaCUL FPbw== X-Gm-Message-State: AOJu0YyPBUhj8k1TbWoH36YP4OXREbycBJamnS5DjvvgJju40lCNm3/k hbCIYnzYq3pQgGDnzQwaYjbFNIi8JdJDagR+9+c= X-Received: by 2002:a05:6602:29ca:b0:7b3:95d6:62df with SMTP id z10-20020a05660229ca00b007b395d662dfmr1830560ioq.21.1701883482412; Wed, 06 Dec 2023 09:24:42 -0800 (PST) MIME-Version: 1.0 References: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> In-Reply-To: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> From: Nhat Pham Date: Wed, 6 Dec 2023 09:24:31 -0800 Message-ID: Subject: Re: [PATCH 0/7] mm/zswap: optimize the scalability of zswap rb-tree To: Chengming Zhou Cc: Vitaly Wool , Johannes Weiner , Michal Hocko , Seth Jennings , Dan Streetman , Andrew Morton , Yosry Ahmed , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Li Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 06 Dec 2023 09:24:50 -0800 (PST) + Chris Li Chris, I vaguely remember from our last conversation that you have some concurrent efforts to use xarray here right? On Wed, Dec 6, 2023 at 1:46=E2=80=AFAM Chengming Zhou wrote: > > Hi everyone, > > This patch series is based on the linux-next 20231205, which depends on > the "workload-specific and memory pressure-driven zswap writeback" series > from Nhat Pham. > > When testing the zswap performance by using kernel build -j32 in a tmpfs > directory, I found the scalability of zswap rb-tree is not good, which > is protected by the only spinlock. That would cause heavy lock contention > if multiple tasks zswap_store/load concurrently. > > So a simple solution is to split the only one zswap rb-tree into multiple > rb-trees, each corresponds to SWAP_ADDRESS_SPACE_PAGES (64M). This idea i= s > from the commit 4b3ef9daa4fc ("mm/swap: split swap cache into 64MB trunks= "). > > Although this method can't solve the spinlock contention completely, it > can mitigate much of that contention. > > Another problem when testing the zswap using our default zsmalloc is that > zswap_load() and zswap_writeback_entry() have to malloc a temporary memor= y > to support !zpool_can_sleep_mapped(). > > Optimize it by reusing the percpu crypto_acomp_ctx->dstmem, which is also > used by zswap_store() and protected by the same percpu crypto_acomp_ctx->= mutex. > > Thanks for review and comment! > > To: Andrew Morton > To: Seth Jennings > To: Dan Streetman > To: Vitaly Wool > To: Nhat Pham > To: Johannes Weiner > To: Yosry Ahmed > To: Michal Hocko > Cc: linux-kernel@vger.kernel.org > Cc: linux-mm@kvack.org > Signed-off-by: Chengming Zhou > > --- > Chengming Zhou (7): > mm/zswap: make sure each swapfile always have zswap rb-tree > mm/zswap: split zswap rb-tree > mm/zswap: reuse dstmem when decompress > mm/zswap: change dstmem size to one page > mm/zswap: refactor out __zswap_load() > mm/zswap: cleanup zswap_load() > mm/zswap: cleanup zswap_reclaim_entry() > > include/linux/zswap.h | 4 +- > mm/swapfile.c | 10 ++- > mm/zswap.c | 233 +++++++++++++++++++++-----------------------= ------ > 3 files changed, 106 insertions(+), 141 deletions(-) > --- > base-commit: 0f5f12ac05f36f117e793656c3f560625e927f1b > change-id: 20231206-zswap-lock-optimize-06f45683b02b > > Best regards, > -- > Chengming Zhou