Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2653786rwd; Fri, 2 Jun 2023 12:33:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ60VYNor+KcBGAEMeynSHciRE8ihuLphTsnAGT/hVMFT/cPqJDU38bXJLtXEuITsgDpuvax X-Received: by 2002:a17:902:e886:b0:1b0:378e:2768 with SMTP id w6-20020a170902e88600b001b0378e2768mr1063452plg.7.1685734395148; Fri, 02 Jun 2023 12:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685734395; cv=none; d=google.com; s=arc-20160816; b=DVeTo/sj+ackjaA9oTETpJKKaMGmf41KqjbsAAPnE4X9oG38ZTxZrzb2TYx8dmjSjy w5e+rZB7v6UvTUiWx04OmhFsCVNx28HUdO4srpHQ07tviSfH8ADbmySD/l+mN5MJvq/v GLQoV53Hu9KgLcyr28Ak0zappHG/MWPda890dR7DYYubSIGWWB2XYBksRtmKIHrDivIf XFh6Iqbbr1AifhxOitKnpIZszyynEWZhlm0Ibej0RXl7fIK+7W5Sy1KC1F+pt97iMn4I XWEOTgBryEiC8Vhv9eGeDGyr7h/g5evMPMy8N1+GGaD/L6+gbH6QNFKxAUb/ztoFzBap UwMQ== 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=S+zVaic1GYalhazjonwvqWVXcN3YQJs5sFWND9LHSfk=; b=Tqymsp1+KCY3Bszih2KU5T7bHRYd/MLC8oF4HEy72fsrCUNPLrL13qJQMT9jT1QHSD sLQSkNxqRydN7YNcWvPHeRj2Yt7IT0/2NT/xI+kl/U3JsmS9XVTpvygc2PueArl0puf6 adqxWjd2/oVvJ2HH/kisF9zTrO6gCgdREUAry1I+fxTJEbOBYziS6cOwqxdrnnnlaNOY q2ceXzEzD9kZfRMxiDlXGbUCj/zqMM3D/US/a3ejKpuNVO+OcMwzhi1OXNFrKk9o01is MqozLBTJo1UY7rkp8+N22p0+9YLFZiU/rlhjs/O1xMCrdtxac/sl7ysKIAjW8CHO+wcg ppBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Pj/77ddP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mg20-20020a17090b371400b0024e1a6c7f82si1485311pjb.80.2023.06.02.12.32.59; Fri, 02 Jun 2023 12:33:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Pj/77ddP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237074AbjFBTPK (ORCPT + 99 others); Fri, 2 Jun 2023 15:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236219AbjFBTPH (ORCPT ); Fri, 2 Jun 2023 15:15:07 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34DE11BC for ; Fri, 2 Jun 2023 12:15:06 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-97454836448so251773566b.2 for ; Fri, 02 Jun 2023 12:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685733304; x=1688325304; 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=S+zVaic1GYalhazjonwvqWVXcN3YQJs5sFWND9LHSfk=; b=Pj/77ddPJUp8RnziITQUQC9CUJWdzIBNHUj/0ISSuJWXChzcHQcFLki4m75O0VUkYe KRUGWENDQDpJJBIhcMnEMftJLi64dIpzIg8MCMlUSxW+77l8X7x2CqsXWe6UkqDu04vE lCDug+HBs/Gssm1dy0XmFMkWFrcK/MN2oJVdFEf0Yo0mkyaQGypsk2Ojhn3J44Abx+vd lvldOpS4ECrlpr/JOKnLSJjfQ0tk8AZPWrBu0MaOWdRk6EG7M5aH9zAPvKiQKT2yOT7s RNVKoRcETgVATY0dJCyTwWUlS4wUS/nnz9f+8D2oA88pUBrF8dVlSMRBrgHHjVHBSaCj usPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685733304; x=1688325304; 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=S+zVaic1GYalhazjonwvqWVXcN3YQJs5sFWND9LHSfk=; b=XBR9caRmx8bSou4g66Wrr3A6vFqlfJ5AKX7HCkh1z6J1Beckr4TwRT/SQqRU2vtyr3 fm7zvcLieIgju7BjnB7DcHftBlvgLdwonheLRIuivS6E/bQyHm65Q8PTb85eUgLAFA9v k2mvTuwcx407oNJiWqUHstgQfoE+d79o0xCyzUho1ItfTszLXTkWKioEXGaqsIxgjuyr b0gFCCTvJRn4wzQlLq05Vf2lehpZgoB/A1hbITwXhnbL0m/VGibHEK9aF67vevlxk6kZ YHSK8OqRfzEKGqsYc8IwfLX1y3BlaMfqi2XDoat3Fxr61G2idvHwYK8WpfDIDpw92RRQ MjFA== X-Gm-Message-State: AC+VfDzL/y9iqoq23OzT0yYzNfl73dhI2qo6f8kvZ0ZIi8cTJ7nQKpMQ YyIcJjSSfBMepIJbP5T7FYKrCEc1Hdq+vbikGlQGCw== X-Received: by 2002:a17:907:1c82:b0:976:8fdd:9046 with SMTP id nb2-20020a1709071c8200b009768fdd9046mr711987ejc.12.1685733304541; Fri, 02 Jun 2023 12:15:04 -0700 (PDT) MIME-Version: 1.0 References: <20230531022911.1168524-1-yosryahmed@google.com> <20230601155825.GF102494@cmpxchg.org> <20230602164942.GA215355@cmpxchg.org> <20230602183410.GB215355@cmpxchg.org> In-Reply-To: <20230602183410.GB215355@cmpxchg.org> From: Yosry Ahmed Date: Fri, 2 Jun 2023 12:14:28 -0700 Message-ID: Subject: Re: [PATCH] mm: zswap: multiple zpool support To: Johannes Weiner Cc: Sergey Senozhatsky , Minchan Kim , Konrad Rzeszutek Wilk , Andrew Morton , Seth Jennings , Dan Streetman , Vitaly Wool , Nhat Pham , Domenico Cerasuolo , Yu Zhao , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 2, 2023 at 11:34=E2=80=AFAM Johannes Weiner wrote: > > On Fri, Jun 02, 2023 at 09:59:20AM -0700, Yosry Ahmed wrote: > > On Fri, Jun 2, 2023 at 9:49=E2=80=AFAM Johannes Weiner wrote: > > > Again, what about the zswap_tree.lock and swap_info_struct.lock? > > > They're the same scope unless you use multiple swap files. Would it > > > make sense to tie pools to trees, so that using multiple swapfiles fo= r > > > concurrency purposes also implies this optimization? > > > > Yeah, using multiple swapfiles helps with those locks, but it doesn't > > help with the zpool lock. > > > > I am reluctant to take this path because I am trying to get rid of > > zswap's dependency on swapfiles to begin with, and have it act as its > > own standalone swapping backend. If I am successful, then having one > > zpool per zswap_tree is just a temporary fix. > > What about making the pools per-cpu? > > This would scale nicely with the machine size. And we commonly deal > with for_each_cpu() loops and per-cpu data structures, so have good > developer intuition about what's reasonable to squeeze into those. > > It would eliminate the lock contention, for everybody, right away, and > without asking questions. > > It would open the door to all kinds of locking optimizations on top. The page can get swapped out on one cpu and swapped in on another, no? We will need to store which zpool the page is stored in in its zswap entry, and potentially grab percpu locks from other cpus in the swap in path. The lock contention would probably be less, but certainly not eliminated. Did I misunderstand?