Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp58585rdb; Mon, 22 Jan 2024 11:51:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFE1vY3YrPIBQhn/qY8zxfhGdnLxMQFN+6KcFN1Zu+lu1ogvhcknCL4MzuCw/NjPt08w4q4 X-Received: by 2002:a17:906:e949:b0:a2c:3596:b0c1 with SMTP id jw9-20020a170906e94900b00a2c3596b0c1mr2418568ejb.75.1705953084992; Mon, 22 Jan 2024 11:51:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705953084; cv=pass; d=google.com; s=arc-20160816; b=rkExFzhWsTy60FcJy12Q002QcTrPU6EpA4buIRZA+4+4zEnExvhrnCDPgJuSRDdAUp hquSnctyc2ujZyvhB1pKcSYwzrayic6D+tI9DbXmDAUwaKD6uq73e0giMA/GdioXhVhS R72La526argjS0VB7EL4afe4YMQw9XkWpJzA3n4xipWV4/WPQtYYKEQUXUWo6bTiURmP Ypnadusfo+TZ7ErKn1oHfTbX9uHYV1gXzj/stL91PQaXYC1kaPu7LEmyN2aDLOwn3c/Q oBPMTIKfV53pBe1P1tCCoL/9xQqrwXyYxmKluWfh0WZtaJhIYnBVIuuW0s0J+vQ2EIDb EU1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=UmmFjd1D1SG8gXESzpiPv0tTaSblIwyR7+CuwIgKAtU=; fh=SxXdazs7ZYVoVyiE5qs+7V62WVKWRx8bK4ecvddWN1o=; b=0xA4AOCa2I3nk7D7R/wGkdqk0tdzfczGUUoobrOLWk/JvcAsAhchfNc4y2LyL7vN0b faOEwTMexV358H+RuvzWBzX27lzCgKOVT1xwAvlEE93DA5QxgdBDd7PyVjd/vD0FWFAN Mim3FuHqJ+NJPccE4dXTdee76ZntV8C3hqJGt5vtAIG3xFpjTG8HEapptOWbYoKr6nAe ETmUkcfY36zvlP1K35ADu5R7jRw6HMlhIPf+aH3h/3qYuChn+x0Tcvd9trEqLs7udqmC IZGQefjSvinl/AoGQznndtX9AHwjQseCJVjhapGBcb8Xa4BfsC4EaJv2Kfljg6DDYfgh 8yPQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Mb5uGjqO; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-34086-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34086-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kh4-20020a170906f80400b00a30601731ffsi976366ejb.751.2024.01.22.11.51.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 11:51:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34086-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Mb5uGjqO; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-34086-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34086-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 28DCF1F27821 for ; Mon, 22 Jan 2024 19:51:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46164405D4; Mon, 22 Jan 2024 19:49:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Mb5uGjqO" Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 C4D523FE53 for ; Mon, 22 Jan 2024 19:49:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705952986; cv=none; b=tHIgoShvFA8LOG67RFU9hvabcWDYFidGmp0v4qcBZFizWKDiG9GfA3qdVjRoKuaewuJ0cavXTnGxNY+SMj5TIZIKGU+DpsKdqlPJE+2eGK1RBhOGfzlQgcPLwtFCDbJTHbpXRDSh6LwS52KdSCiSSJlsnllKtUknjl/fTbdkD2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705952986; c=relaxed/simple; bh=N5/02QQcKOFzVJAx5+uukXGNVlRapVJpelm/ZexGgDw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=r2qkc8wyIXhdmrHwhERbbqCJWX6tYBdQ8OUBnPof592pt3A8yx7PXUuVmRXipc8brF7A7DfdJ/npwSUocIw111cM+pJEmELhPAhLypQ1b3G6C9daLilIztGAJH60LuQiYE81QQKmkkZ8ZuYaTa1UR+SjpIb6uZyqTKsRrErMH14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Mb5uGjqO; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5100409e31eso209928e87.1 for ; Mon, 22 Jan 2024 11:49:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705952983; x=1706557783; 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=UmmFjd1D1SG8gXESzpiPv0tTaSblIwyR7+CuwIgKAtU=; b=Mb5uGjqOLdxeckGf5S77ezdfQss2r2XWpnVhWJDJixZI6Yz/KxFHSMdBc3pAhEx7Rn 4vWveEbjRalqBTfWdAQmue5GrwIQemU3FzrVxvLYJ4a+LGI3qUzBZUiiK38XUXNKvipJ lNT5Wip/hPA0VLDhwVhHkFz3VYzY+0SdtBmfNMM9ZViq1DtN33F1lWqvhY/keD/1/WLN y/jRfJp7LM4pgvXn67umRfStj/F8aZoNgyLQiNO4YcD8fCGuALNIa9ppumSTb0SE1nHq pw34AY0g6FjPHfOcgkJVWgOtrHNzRFO9rpYrO+dB9IKgBCjMAvyoCzBLrTqZXbiWa1QC lnVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705952983; x=1706557783; 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=UmmFjd1D1SG8gXESzpiPv0tTaSblIwyR7+CuwIgKAtU=; b=NZ/KFqfCsEC+dshLk87fPy90ALrX5me5LW4GW2IlLqTIYBdVD1EKqjWMaI/jb9BW9C YEtmIgYO1fVnfcRUwx3w+TCDBMI26ucPnG4FWdLm/8yddsxXK+N64IlodaUua2ojvC7Q Rw+v8LwZPxU9ZhqUto7ZbyS/fn8WtK0myiNXkY4tpCLR7XY0o64y36u+suqnfpSbay6t LWroonfiytKjUHd6gVrl6csfAN7mcMqshqI6SbHo/YszvKXDVCSjd0L3BBqXN6dMhBhU 8XGp1C9xGo2uO3UhB/jeQJqqKFb9Oh31zhdvTqFODITbzJR+jQhs4EUxnZLugpb15vke ko+w== X-Gm-Message-State: AOJu0YyhNCQIF/sjvCID6CZ6zFvfp9GONG6rIYw5Btr9OKr7oFlSoq8v 4J/iAqVwBBQpYbI6pYyxs1PfVC/rztua5PiOn5bOBkDRmBjjb8jiV9eaefj7DiWc/1ojcOVVTt+ z76U9V0ue7easu/mlTXIKJ6k/VA4z8LAE7vfL X-Received: by 2002:a05:6512:e9b:b0:50e:8106:9e86 with SMTP id bi27-20020a0565120e9b00b0050e81069e86mr2770324lfb.43.1705952982619; Mon, 22 Jan 2024 11:49:42 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240117-b4-zswap-lock-optimize-v2-0-b5cc55479090@bytedance.com> <20240117-b4-zswap-lock-optimize-v2-2-b5cc55479090@bytedance.com> In-Reply-To: <20240117-b4-zswap-lock-optimize-v2-2-b5cc55479090@bytedance.com> From: Yosry Ahmed Date: Mon, 22 Jan 2024 11:49:05 -0800 Message-ID: Subject: Re: [PATCH v2 2/2] mm/zswap: split zswap rb-tree To: Chengming Zhou Cc: Andrew Morton , Nhat Pham , Chris Li , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Johannes Weiner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 19, 2024 at 3:22=E2=80=AFAM 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 buil= d > 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. > > 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