From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DF4EC46CD3 for ; Sun, 24 Dec 2023 18:15:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C968E8E0002; Sun, 24 Dec 2023 13:15:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C45E38E0001; Sun, 24 Dec 2023 13:15:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0E288E0002; Sun, 24 Dec 2023 13:15:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A081F8E0001 for ; Sun, 24 Dec 2023 13:15:40 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7BEBA1A022C for ; Sun, 24 Dec 2023 18:15:40 +0000 (UTC) X-FDA: 81602514840.13.5BAFB3F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf20.hostedemail.com (Postfix) with ESMTP id DBEB81C002D for ; Sun, 24 Dec 2023 18:15:37 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ce4HsjkX; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703441738; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0d7z7vOHVEJMp4xFAE2JhEDfOOSp2aaVs0okTcN/+1c=; b=xldp37Nt/wfIe7rkdgONQ6OHn1HagUhqoT6ijWOzq1BNoQ1uEJOYfm8ZD3IeUzzNkSAiyJ i/wP89yaJaaT4Ak+0Sp0B2GbY/g5YCVoS1HvLXLcJolezeEU6Ms6EYmcr1bgGfy+8bd32N cpmgiTnY/roCqfF++R0K5Ku3Zssp2TM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ce4HsjkX; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703441738; a=rsa-sha256; cv=none; b=dJFg3VRN6GqmQQp0kLGN7iK9rYSF0KolzxJRo7VQzhvsfYFsFUvpV1DE6nAg3rxBAMiM+b Aph2YH5nTR7VtPYKDOwO22iHJy+lTpVHl98uQy9+5CIFqxFEJQuHQGy+54v2VgMUzG6kk5 br51Me7UWAZOm1gqvhJspR5lDEEAsqA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 96EE9CE0E08 for ; Sun, 24 Dec 2023 18:15:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A86D2C433B6 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-f170.google.com with SMTP id d2e1a72fcca58-6d9344f30caso2218044b3a.1 for ; Sun, 24 Dec 2023 10:15:32 -0800 (PST) X-Gm-Message-State: AOJu0Yxt+tbDfrCPiL4Nn9e71fHxzGlmPyMJENOLFhSShGZo1Ga8/6XG B0cn8S7PWNezgGa0duU8khzTVt2PFFbph9ezVu2hkDQ7Tm8N X-Google-Smtp-Source: AGHT+IHJ6UydbFRiuIig5ov2qQT2o6s3FOHf75u/hCNiHZkXTKwzNnmb1qI7vsTxZ6KFn5Nz2oLXEBNRhgC7bPwK5Ec= 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) 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 X-Rspamd-Queue-Id: DBEB81C002D X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: yqexygsafj8mqepr437gtwhtx977ufyn X-HE-Tag: 1703441737-427486 X-HE-Meta: U2FsdGVkX18xyOcsjKGh5ecdVdndGfQSKySo9Zzyr7rReXjhQmd+HTAMbPxUabksaWswm5wkMgA9JWzOPK9xHTPcTcsXZqCBj3Umy9gCTIKXI69VVh5VBWip4A6opmNtT7AjLKot3V5x2qnmw9z3gPYF88mYMaUp21nsiXHIEjAsI3A71Q75J2sk387JDCLdi9VhDGra6pIb/gikAJb1b26LZetbd7wWcxS3vsawB5uyXYNDGsAXLAZp1dzAlbFtB7LbM8ySDvrBMHnLddw2w2JVXxoV+pj2Px2rXB03ozAYYULLoclZSioNEjSRYdVgBoR97XD9ke82uKz8EB35nj8q4CkV6edV4pdKRVL37DxwZuv8h4/MjKe2q8SMPgYzhkgGpGYj4XLU28ooCEE71VwdC1XcYUnaEV8EAyoVkrMv6WNSidXRgAyJrMX2uUs5TE5LcB6prOHm/NNYd+bTAeYP1eHTG8gRztK3Y6KT9n4CPXqvUmVvCvkwzCTi8lrAkZkMSUcW7NByiStmxs+Csd1pMcxDZFpOLU98HQZ1jLtuvv7noP5NaPI8zcL9VzrPyCuYClVfGMUTMkkXZXrH+uwf4f424fRuYFbnQn8wRDE99DhU/t7yQlQXGW6NiRkb8b2BPNSN3a1eNfmzeUHsTs2xT2lb1+iAFFBhWHsPXvtISgIZKGwX8slMRxPdUzbTsEVBhaE86mIV+6Eax9jXmA0A5DcDVWb6IsJJnqHZC8pT3n/U3F5dssKlY8Pj3yzZqzdJTai1Vk2pcPaeHsWlDqSrotOuxAUd2FfWU1eWoQVQ5ietWO/8ka4cFM6v+POQjhuQTSoQT1EnTt21grNwWgY219klw7hOvIZg+1UQt7TB2lijjH5ahLjS6QhDkda7XU/K1TNWeCytVpoctTizrb9sz6GM0mzcWhvuOcBPy6ccBwllY4h8PZmzkvw4Kr50Qz+p6z7T2nq9EDG4CaS IpVbveDf WtTl1t6gdHCmiUHd7vgFazKLFEb4OpF+9as9o5PCGYE3C/io82JMLmparvwT23KMeO9Anb+TJE8nyj+LlIZpnX9B44QORT/Adkj6rHNGSvMD0uXxFgOUo+Bnj/bs32dLaVMkfWWZtvS2/9uNjh9E2eaxlNHnNio1C/hQk9UK4Hb0vVeBTmw7QLR53Ri0S9sPnv7cjiir09k09v4DmEqubiUj+g1YQtygzZ0Ow7CjoGvfqG1o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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