Message ID | 20240706022523.1104080-5-flintglass@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 39F29C3271E for <linux-mm@archiver.kernel.org>; Sat, 6 Jul 2024 02:25:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C00F96B009D; Fri, 5 Jul 2024 22:25:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBF6A6B009C; Fri, 5 Jul 2024 22:25:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A511F6B009D; Fri, 5 Jul 2024 22:25:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7FC586B009B for <linux-mm@kvack.org>; Fri, 5 Jul 2024 22:25:48 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0ECB61A04B3 for <linux-mm@kvack.org>; Sat, 6 Jul 2024 02:25:48 +0000 (UTC) X-FDA: 82307737176.26.1B3ED2E Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf21.hostedemail.com (Postfix) with ESMTP id 417D11C0010 for <linux-mm@kvack.org>; Sat, 6 Jul 2024 02:25:46 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nYkisTRq; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of flintglass@gmail.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=flintglass@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720232716; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=l6NW2XiaqgCOW2kGzuZtQVJiLTkQZp/jGPzUs3Qox2A=; b=HzlKIP5NgybcRRy4ky6IP2/BLDnGnZDP7HeRar1VcsyGbKr+s0C1gDn9JLnlj5ym6+Ko1r qksfXYreAfRLrpRxjbjrDJ6yevOfYLhgItjj77nVMIK+PWI4XooIPrubKZHcwonix6wYvm oIqc9VnRR9Hv4WLZ34OMVhL6WyqD1Mk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720232716; a=rsa-sha256; cv=none; b=u0+BItrgN88Wii4fdOef9BP8gLqwyPwXyoY5GFftEN+LL/hIWtfzglGkzo98pTmFj1fYj/ bKONqPNqEfy7ESMOKmN0toLOugo8MX+M2aE/HO0REp1OlfJV25368mzPcapYmZzJCqtgJH JWYNCeOXibgynX5f8qUpUgBs1vNTWNg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nYkisTRq; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of flintglass@gmail.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=flintglass@gmail.com Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-650cef35de3so19598757b3.1 for <linux-mm@kvack.org>; Fri, 05 Jul 2024 19:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720232745; x=1720837545; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l6NW2XiaqgCOW2kGzuZtQVJiLTkQZp/jGPzUs3Qox2A=; b=nYkisTRqE/9nXMva8jH2gaijKBJAv5pKGlO7OMdJbeNpI2QG0apu6bMY7TtiwJpROG hKoicgdK6xMvkliQKOEd87A7s71g0VKWCEoUxSO4zpuQInMoyEckS1uuNQA09yxM6SJO 0JVjyFXk4MG9wfWiGmBNV6hjWl7syhpbTXgjZ6uwZ8TiGJYtGoFR0BAvuyLhR7m/rL4N hnaeRgSlLd/c7VNaa/A0pQLrF6UbSzM/TMKGjyyf2eb/bi3YcKol64BLMwYK+k7SynIA tmgFMXypjBll2ehtBv8unmNoe3OZHb4T7I03pBE+f+EgOFelCoS5pQSzimdxcywiuWdG pcwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720232745; x=1720837545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l6NW2XiaqgCOW2kGzuZtQVJiLTkQZp/jGPzUs3Qox2A=; b=PVJxCa59kNOvGyh2BvNjDbfukhH6I1rUFduzr00PunYk1AnWpxDSdgeC2qYbSjW5/m +x4NfqwZNIubEx4VN9FqKcrshZeCwcRdrQKIOAT1QjwiovhDhgf46ZmOZuD8THdGNsyQ 0g6ly8Z39ALCjLSR3GzBhVMTSZynT3Wwkc7KsN6aEXR01b26ElPBAc4hw6+00mkXUiJZ 2IilHOGrLauzQKgr8VXaliw1iQJ2nur4NZvFs7AYfTso5zeHq2TM789220AG0lLK7Y2E 9Yjs/eh/l7Bof3P8C5t+YD1oxRVStbxUqDeNRjUkPAZ3w592wzaX7LV56lEDkAPt/d8F GI0A== X-Forwarded-Encrypted: i=1; AJvYcCXmCakak//J99COb47cAFDhZd3kZDl1IHyR/iMzQmTTxNjpAPNb/tictkhQghUT4x244u4eE2uWxTaXbrVO+w9pEM0= X-Gm-Message-State: AOJu0Yx+Xpe1PvqVxY6SzTC9kXtGBQ9iS9i9PgRRHQgJbhK1ykhYxcXb CVUxQGmkJmf0o/7sGZbtcmNXqOp30YLVMwf/j3G2q/SniMzscr/D X-Google-Smtp-Source: AGHT+IFNkqLTZT9+2L2xdRVS7Od8usyV5xtdrQiTpxoRliyeJe2Nh1WeW8XTWGwhpPrd5owlnsnLlA== X-Received: by 2002:a0d:e68b:0:b0:64b:8086:5805 with SMTP id 00721157ae682-652d5917b6bmr62075797b3.15.1720232745356; Fri, 05 Jul 2024 19:25:45 -0700 (PDT) Received: from cbuild.incus (h101-111-009-128.hikari.itscom.jp. [101.111.9.128]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b15417a7bsm971274b3a.205.2024.07.05.19.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 19:25:45 -0700 (PDT) From: Takero Funaki <flintglass@gmail.com> To: Johannes Weiner <hannes@cmpxchg.org>, Yosry Ahmed <yosryahmed@google.com>, Nhat Pham <nphamcs@gmail.com>, Chengming Zhou <chengming.zhou@linux.dev>, Jonathan Corbet <corbet@lwn.net>, Andrew Morton <akpm@linux-foundation.org>, Domenico Cerasuolo <cerasuolodomenico@gmail.com> Cc: Takero Funaki <flintglass@gmail.com>, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] mm: zswap: make writeback run in the background Date: Sat, 6 Jul 2024 02:25:20 +0000 Message-ID: <20240706022523.1104080-5-flintglass@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240706022523.1104080-1-flintglass@gmail.com> References: <20240706022523.1104080-1-flintglass@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 417D11C0010 X-Stat-Signature: g4qb4im47i5of4dbk5ga5qs5k8cr86zg X-Rspam-User: X-HE-Tag: 1720232746-425386 X-HE-Meta: U2FsdGVkX18UVhHzOzrLs+YGl+cTetU4TSfZrOIIe+5PeckHhgNg47Rr/rFOyAu1m1lYS5hSiifJdlFUiA59vnaIKfgdX2F4vynD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/a5jq/538UtNS/oKBPbqvW/b9zRk8+7RNYE7Fd7A50SKy6SX7cJJW0/t0tixQF2tOm4XpcB2BPY+qXHhV3ptfmXi4XHQbkQKpSG/rN17bj6QJaK71+6QmvYtkNihLyEqouUe2VFkpeADjErKXRnkS1kYa5tZ2X X-Bogosity: Ham, tests=bogofilter, spamicity=0.000319, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm: zswap: global shrinker fix and proactive shrink
|
expand
|
diff --git a/mm/zswap.c b/mm/zswap.c index 24acbab44e7a..76691ca7b6a7 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1806,7 +1806,7 @@ static int zswap_setup(void) goto hp_fail; shrink_wq = alloc_workqueue("zswap-shrink", - WQ_UNBOUND|WQ_MEM_RECLAIM, 1); + WQ_UNBOUND, 1); if (!shrink_wq) goto shrink_wq_fail;
Drop the WQ_MEM_RECLAIM flag from the zswap global shrinker workqueue to resolve resource contention with actual kernel memory reclaim. The current zswap global shrinker and its writeback contend with acutual memory reclaim, leading to system responsiveness issues when the zswap writeback and direct reclaim run concurrently. Unlike kernel memory shrinkers, the global shrinker works in the background behind the zswap pool, which acts as a large in-memory buffer. The zswap writeback is not urgent and is not strictly necessary to reclaim kernel memory. Even when zswap shrinker cannot evict pages, zswap_store() can reject reclaimed pages, and the rejected pages have swap space preallocated. Delaying writeback or shrinker progress do not interfere page reclaim. The visible issue in the current implementation occurs when a large amount of direct reclaim happens and zswap cannot store the incoming pages. Both the zswap global shrinker and the memory reclaimer start writing back pages concurrently. This leads the entire system responsivility issue that does not occur without zswap. The shrink_worker() running on WQ_MEM_RECLAIM blocks other important works required for memory reclamation. In this case, swp_writepage() and zswap_writeback() are consuming time and contend with each other for workqueue scheduling and I/O resources, especially on slow swap devices. Note that this issue has been masked by the global shrinker failing to evict a considerable number of pages. This patch is required to fix the shrinker to continuously reduce the pool size to the acceptable threshold. The probability of this issue can be mitigated mostly by removing the WQ_MEM_RECLAIM flag from the zswap shrinker workqueue. With this change, the invocation of shrink_worker() and its writeback will be delayed while reclamation is running on WQ_MEM_RECLAIM workqueue. Signed-off-by: Takero Funaki <flintglass@gmail.com> --- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)