Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1977515rdb; Sun, 24 Dec 2023 10:15:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNRLMRvM7JCgN+gVgnwckWBfF5pg9jFbfxDv3Lz16auGQKdHL5n7vqqvgquu/INVKm+7MK X-Received: by 2002:a05:6300:8089:b0:195:787b:aeb8 with SMTP id ap9-20020a056300808900b00195787baeb8mr2023850pzc.63.1703441740427; Sun, 24 Dec 2023 10:15:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703441740; cv=none; d=google.com; s=arc-20160816; b=XJJIfUN/R2GbW8sz33ONC6TJRpC452/1g+H7hlKAXbZURxbt1JslHx3qiRyCdKKLYF q6iRnwpX3IL123qe4mZHNWooZjDRGOS0tD5s1ZHFo9wV2NRh9sl5rINSwneoUTiwBf4R bTlQTJWlqxBVWkdEv7wzjas5mvdsPQo/ZXEYL4s+rYwU4TXYpSm1QIYlOuNV9wT4iH/Z 4TmlPYJG6qAmHAjW+ssDioGjqqBHq9ZVufEzs/QvBelkteXEb7uWyozoGWgzmwPqI+by axNwTTWn/ohJiAtwYj6P40SPiZ6nVUygsYT/2ootuMlJrYs1rgW1bDxK3qWZ7vtSsLzO NAMg== ARC-Message-Signature: i=1; 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=0d7z7vOHVEJMp4xFAE2JhEDfOOSp2aaVs0okTcN/+1c=; fh=j7xgSoSCNoSFrnk5Yf80InsLB9L/HXk8cvxoj58ZfI4=; b=EqAl0ogMojIkjE8MRTfIt3vg9DHrJOXRmVG41NUNMAZPJpEKQj+QTxFCJDQGnB4DQT vQ2pMMKtcPkpHt7riB/kDg/Nvk1mj+DV5UjYFT1VKudGjBTadxgIzwPH5wqKdHhP8G/H G7ovxaCAFtzNMtLPqKuRYpUtaDygDTvcRAIABtSGnVaIpkaqdrr21Szbrvpu3RtKIxST g2fq2rynBGsPEF0g184M/xf3L6Phsmd9zboa6l0TwTh0Rx6WqV214XMOVksTTLucssvh QBJ5POw0Io1K4v9IZw4Hk0o5skhjfHjKY7KRkJ/77vaiQFLR8YHECtihUFOY2zUI9UsQ kFxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ce4HsjkX; spf=pass (google.com: domain of linux-kernel+bounces-10783-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10783-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c16-20020a630d10000000b005cda3e56f9esi6657309pgl.374.2023.12.24.10.15.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 10:15:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10783-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ce4HsjkX; spf=pass (google.com: domain of linux-kernel+bounces-10783-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10783-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 19367281D8C for ; Sun, 24 Dec 2023 18:15:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 431BAD275; Sun, 24 Dec 2023 18:15:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ce4HsjkX" X-Original-To: linux-kernel@vger.kernel.org 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 6D4792F43 for ; Sun, 24 Dec 2023 18:15:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5670C433B7 for ; Sun, 24 Dec 2023 18:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703441732; bh=eqOb3iB/FSfPM+WPp3VGjSZeorAH0Qt9bX0VFZDl2AU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ce4HsjkX7JIGhzwaHr6JlIK4nz4aPJNLB5r6sTbh/lAWOKkaoGy+/Wj5e3wpGpiuw Hq1XxUAXqBft9Z54xPzKoqkfhaEUuA+jY2HyvRQZ7F7YGXgY2JalbTzJ+RuxOdqdi2 dCcA2ZbDB764iiYOyyy/O7pnVBezMGdruAz4mSANczrCKctpoIUei/4MVcBz9HSi5n /egYgiGZLzqrJK8OgxgLDadOvok95sd6lknh+BYxj9Mnq27kIgE2qJcNvfS5y7SCeO C7Kfq10UClHJsJ85rTETzXIU/XgEDkgfw4MjLsHAN/exPZz5vl8yfnujWJfPAfac/m kB0T1A/f9Xt5Q== Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6d9a795cffbso493755b3a.0 for ; Sun, 24 Dec 2023 10:15:32 -0800 (PST) X-Gm-Message-State: AOJu0YwSYGZJr8kQnHVMK28XfHwSiihzmbIY1rZx5pX+1M5y6iRhOT7D gdmyPSQFpxpIdEqSRnDpwLWDlXUUQOHAS8w4QKSkDaC+cW2j X-Received: by 2002:aa7:8c16:0:b0:6d9:8ddc:37e0 with SMTP id c22-20020aa78c16000000b006d98ddc37e0mr3796818pfd.28.1703441731988; Sun, 24 Dec 2023 10:15:31 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231221-async-free-v1-1-94b277992cb0@kernel.org> <20231222115208.ab4d2aeacdafa4158b14e532@linux-foundation.org> <0a052cb1-a5c5-4bee-5bd5-fd5569765012@google.com> In-Reply-To: <0a052cb1-a5c5-4bee-5bd5-fd5569765012@google.com> From: Chris Li Date: Sun, 24 Dec 2023 10:15:20 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm: swap: async free swap slot cache entries To: David Rientjes Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Wei Xu , Yu Zhao , Greg Thelen , Chun-Tse Shao , Suren Baghdasaryan , Yosry Ahmed , Brain Geffon , Minchan Kim , Michal Hocko , Mel Gorman , Huang Ying , Nhat Pham , Johannes Weiner , Kairui Song , Zhongkun He , Kemeng Shi , Barry Song , Hugh Dickins Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Dec 23, 2023 at 7:01=E2=80=AFPM David Rientjes wrote: > > On Sat, 23 Dec 2023, Chris Li wrote: > > > > How do you quantify the impact of the delayed swap_entry_free()? > > > > > > Since the free and memcg uncharge are now delayed, is there not the > > > possibility that we stay under memory pressure for longer? (Assuming= at > > > least some users are swapping because of memory pressure.) > > > > > > I would assume that since the free and uncharge itself is delayed tha= t in > > > the pathological case we'd actually be swapping *more* until the asyn= c > > > worker can run. > > > > Thanks for raising this interesting question. > > > > First of all, the swap_entry_free() does not impact "memory.current". > > It reduces "memory.swap.current". Technically it is the swap pressure > > not memory pressure that suffers the extra delay. > > > > Secondly, we are talking about delaying up to 64 swap entries for a > > few microseconds. > > What guarantees that the async freeing happens within a few microseconds? Linux kernel typically doesn't provide RT scheduling guarantees. You can change microseconds to milliseconds, my following reasoning still holds. > > > Where the swap slot cache itself delays the freeing > > of the entries for an arbitrary amount of time. It is not freed until > > the cache is full of 64 entries. This delay can be seconds or even > > minutes. Adding a few microseconds of extra delay to existing seconds > > delay really makes no difference from the swap pressure point of view. Let me rephrase it. The swap slots cache itself has arbiturely delayed on freeing the swap slots, the slot is not free until 64 entries are reached. Adding a few milliseconds to the current swap slot freeing delay does not significantly change current behavior from swap pressure point of view. Chris