Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp936774lqa; Sun, 28 Apr 2024 10:27:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXUKDXKMeKCgfQf0VQ/fCD7hlLf2YkB5wRhKoUA5OecDYliVIeXWcrppWNox1BThGhqmOYk+iIkEf/tT42LMdhSvzrgP2q8t+XCuLenXA== X-Google-Smtp-Source: AGHT+IEuFQ4a2KwX8hsR5RGofSHaRQN4A8wdwl8HQVzeJQlsVP1okIsUIIPZx/DOJL3tHl/Hbc82 X-Received: by 2002:a05:6214:1d2c:b0:6a0:a7a9:4ad4 with SMTP id f12-20020a0562141d2c00b006a0a7a94ad4mr12264518qvd.7.1714325223917; Sun, 28 Apr 2024 10:27:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714325223; cv=pass; d=google.com; s=arc-20160816; b=X/n+gf98bbmsmCSkT+lBv+0ExFSqTpxajZcfO2BWNWE7v1JVyWaRr/obcLpt/dRb/I RTshlLQYtB7E3zhpQ3oYX/i9gi9A/NhsJ5JmiZqZH4e9CGn9l6bu78w3v0a9NlSzr3MI ZBThO8/yVQnFJOXXaVYzFJgjTMaxKti6Hz+kBlOeNaekbF1POP4AKdChSAePybtCnOX+ dZHjddR54cBfRMlya0aO+S+QU0UN9PBuAi8gbmuYkhYGxmHv7phlcDjm03tGkv5ALqKH xsRzM8fJMxOn7vZjynwjYnb1BLNoLgqBOQLzAE+DM7V4Qnycg4W3Np4Pu459HbQmTeIg X6IQ== 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=W1Zv6mQsCHZ8zhEVzImNSRAt5duGo/EBKFX00U4AVrY=; fh=AeH1ldKKRpuWL9oxyRYn6MHnY5FbPbwBLg/Ihno/w7s=; b=G6H20x+03P4793uXNlItaYaJTCHVv9xOjFiPX7n12NsW75BAMaGD1hY/3QT8LaBL5+ TJocd9XtvqFW/zS4lnY1HzhnXYNGTtZzRE5sUCHg4WYjvBMzY7ESlDAVqF4kYwMKzTQj qrZjNKqYiZq8CHnVbvWFcMKcr8n8m4P0qio0gpDInsM0g2IIraVx5lplvU3VEaoFWG9u adLBpNcvKaIhIJdqrUBbyEiRAn81qv4UPDKQMak/V87mC9FSW1Shm3oy2YrFbOizFf3M hOWVYYquk+G/yq2zCQsO70aYEscjUXeIVxFOthiit4OvjHOAXP3c8A+Ye0XAQnkN9ddk cydA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W317A/ho"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161526-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161526-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 9-20020a05621420e900b006a0b9059758si4088495qvk.276.2024.04.28.10.27.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 10:27:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161526-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W317A/ho"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161526-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161526-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9E1731C209BC for ; Sun, 28 Apr 2024 17:27:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4C7374402; Sun, 28 Apr 2024 17:26:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W317A/ho" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC04631A81; Sun, 28 Apr 2024 17:26:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714325206; cv=none; b=IpQwaHu/G6t6Ft5GekTNlGRdyCiL6bjRTWy+BNsk2ySsQGITq2n2SWdh95lK0elmzXWZCPDmib/GxFA2P1Z472oXiG65GhiLu5LAbZ5GQBYeoouo9XLZckza+hJJbgVYt+NBFvWT5RkvesLpc4BMBYs0k6FZhxfXOCm1PHY+xPc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714325206; c=relaxed/simple; bh=NZBB+ghwJcuayzIp9bDWsCN8O4KXLge43NacmZc8NQc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Di2SK5mcigO266KGbQc/jD2Z6pbLQzeUAHLQB2EiW5yFG43AbaGy8tZS4VowyVrllTLVzUwNIlovH6ZRRulL1JDWvqS6vDu2wUSO9omOuSu58amfAhaI5fLwQrTt1rEjB4cZ+s+R1u8GUV6X30jG6zDcsCfUkMU5kqrfKSepqq0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W317A/ho; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C07CC113CC; Sun, 28 Apr 2024 17:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714325206; bh=NZBB+ghwJcuayzIp9bDWsCN8O4KXLge43NacmZc8NQc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=W317A/hoX8B+KiUST+7/pu2WuTHJo52zMGPXrI7lYfc0FC8+TjED96YPfgydfYdWo x1e+paLmPebdJCp3cnujaVvv446sPJmLGkD3wnqwH5ecX3Oy4/vdnk2XTVUCQDXk0b I0GvuAQx7CdrTXftLMoiDPTsxg4XFC7eDhry1D1vIkoZ642PnBrRgrflOAovuIu7ek CWT16uXtDdbetE0WqMVk0A48apjdLMhscN1YZlJxSx6b0JN35x5eWTLiaLhxlyRS4g Pfe+UmQPPAXzR8h3NOzMhcwwyklvkKSHWZKJlOmC+MLBl+BePfnqsEtZwGd+oF7rhR VvMR/fWeoq4Ow== Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5196fe87775so4142722e87.3; Sun, 28 Apr 2024 10:26:46 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXMpHKpPgUgnyuiWPK9QLn4BXRxmJtavy76KMG9rSzkTmGBAhbzDk/C3OWRz6VgOyNLuc3cj+CyKmFZjd0/fZ2PbyPCmHOOmAy/Tn/u1WgIBtkl+WbXS5cLowpProK/XTjdSVuiJ5HXAgEgTw== X-Gm-Message-State: AOJu0YwIVS8CHdc0Lyah+aWZt0i4iIDb09bg8R6DPa/cR8pn5G7o9QxI kYpM1eysKSiq56In0pGKQ50io5t5LGWWqRDd1dmBcntDXBYthx9FjIxzFcUG7qGCZWxGhVN4VKY bJuhYo7SgIhB0pQ44AntwDwMyEw== X-Received: by 2002:ac2:55a2:0:b0:51b:f78d:c189 with SMTP id y2-20020ac255a2000000b0051bf78dc189mr3486644lfg.14.1714325205084; Sun, 28 Apr 2024 10:26:45 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240417160842.76665-1-ryncsn@gmail.com> <87zftlx25p.fsf@yhuang6-desk2.ccr.corp.intel.com> <87o79zsdku.fsf@yhuang6-desk2.ccr.corp.intel.com> <87bk5uqoem.fsf@yhuang6-desk2.ccr.corp.intel.com> <871q6qqiiy.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: <871q6qqiiy.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Chris Li Date: Sun, 28 Apr 2024 10:26:33 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/8] mm/swap: optimize swap cache search space To: "Huang, Ying" Cc: Matthew Wilcox , Kairui Song , linux-mm@kvack.org, Kairui Song , Andrew Morton , Barry Song , Ryan Roberts , Neil Brown , Minchan Kim , Hugh Dickins , David Hildenbrand , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Apr 27, 2024 at 8:23=E2=80=AFPM Huang, Ying = wrote: > > Chris Li writes: > > > On Sat, Apr 27, 2024 at 6:16=E2=80=AFPM Huang, Ying wrote: > >> > >> Chris Li writes: > > Free the shadow swap entry will just set the pointer to NULL. > > Are you concerned that the memory allocated for the pointer is not > > free to the system after the shadow swap entry is free? > > > > It will be subject to fragmentation on the free swap entry. > > In that regard, xarray is also subject to fragmentation. It will not > > free the internal node if the node has one xa_index not freed. Even if > > the xarray node is freed to slab, at slab level there is fragmentation > > as well, the backing page might not free to the system. > > Sorry my words were confusing. What I wanted to say is that the xarray > node may be freed. Somehow I get that is what you mean :-) My previous reply still applies here. The xarray node freeing will be subject to the fragmentation at slab level. The actual backing page might not release to the kernel after the node freeing. > > >> And, in current design, only swap_map[] is allocated if the swap space > >> isn't used. That needs to be considered too. > > > > I am aware of that. I want to make the swap_map[] not static allocated > > any more either. > > Yes. That's possible. Of course there will be a price to pay for that. The current swap_map is only 1 byte per entry. That swap map count size per swap entry is going to be hard to beat in the alternatives. Hopefully find the trade off in other places. > > > The swap_map static allocation forces the rest of the swap data > > structure to have other means to sparsely allocate their data > > structure, repeating the fragmentation elsewhere, in different > > ways.That is also the one major source of the pain point hacking on > > the swap code. The data structure is spread into too many different > > places. > > Look forward to more details to compare :-) Sure. When I make more progress I will post it. Chris