From patchwork Tue Jan 30 01:36:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13536680 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 936B2C47DA9 for ; Tue, 30 Jan 2024 01:42:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF0606B00B7; Mon, 29 Jan 2024 20:42:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D9E506B00B8; Mon, 29 Jan 2024 20:42:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3FB06B00B9; Mon, 29 Jan 2024 20:42:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B16A36B00B7 for ; Mon, 29 Jan 2024 20:42:33 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8A3F9C0A8A for ; Tue, 30 Jan 2024 01:42:33 +0000 (UTC) X-FDA: 81734277786.25.9769495 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf04.hostedemail.com (Postfix) with ESMTP id C6E394000B for ; Tue, 30 Jan 2024 01:42:31 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=v9cIJeci; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf04.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.176 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706578951; 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=IOr65lcwE97/+IL040qC2nQXATF0TLQoSMjJ/TctotE=; b=xLQUvuJI0iQkd/WLwwVvUA+JECQk8gUESOkiabPTdG2smLcoDZSy5kmtHoanr1czSxI05X bKAGb37xfxy2U39ubkNOzufYy075+9w2QyHqvKJMAMjgY0V+Ga5rcH/d46/O7tTB3lboSh 1lVebWsouxwp85KsIiyyJ8MkmcMj5oI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=v9cIJeci; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf04.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.176 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706578951; a=rsa-sha256; cv=none; b=YjMvtSUqpho4FkWKV6JkRImC9UB5UZCEykWzyM6ccerElRs7LLsllJn1xkyj6fbXyc1kTQ ENUAcZo2mDL8WcFJ9l37HdhYM8N+11SAv4VXl6xp3s8hhl1R9jkbYMEnt3zJGSWGK1+jXK ZXVh4Fo5/olGWNe0w8i2utVK6i5qitg= Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-783045e88a6so349543785a.0 for ; Mon, 29 Jan 2024 17:42:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1706578951; x=1707183751; 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=IOr65lcwE97/+IL040qC2nQXATF0TLQoSMjJ/TctotE=; b=v9cIJecigJKKCTm6SOKkmZu7hSrHnwJLFaR+6kxHml0hbv4KybYsVknpqZgk87ZNJ5 VSY3W9HHOAWBBP0aSm2/l6AhXiCtmjtWeWhxzfUzxC1uWoF3gcc2TV+4jXofJtqKjz+4 sWMqX0D1TsHQ1D8Y/OAM8lid6eazKlmGGljmWC7W1OJYZ7r2lP2IWEcQLo21QC6yx9C2 ebBaiSYikAWgd3QiUbw3cKIiCkQT+ibkXcvC4+cVC7iiNtQJQnUg5UGmwUt6HK0Smhdi Gi35yAhu0ZfLqZhrwQ1fHMDi3iwQRwGmwi+bVlcB+wPDiJRiopgypA2r6wY1nbYNWCWx emnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706578951; x=1707183751; 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=IOr65lcwE97/+IL040qC2nQXATF0TLQoSMjJ/TctotE=; b=Ld5XsdUPCr/ZXMtStOYJux5UK7ny5WME+AnpgCERh8Rq6Hkl+f1AUVJYlUxzIHD+92 KgOOtLUo1860q+sDRx79nCFi1pJZbQ53XL9RNN4HomBS9fr/YdGV0laugd0RUMrcVf/U 6cZHoEHNr3Xk8zyNvbzdHZ541i9vd6nyEP6mzlplfyl/Mj732J/loqEAIt6Gn2/npBgQ YOXIn+dq4skXjgvT7vfToRMDpJsafU8YkcQxs1JyaDzDnMEAEulIhUdQL1X4rUmzba5x roR92F8/OdbdV2kf6mT9CCiFA71MOI6GkwNq5F7I6RIuQzbU+q/0LqNGEbkAfvJ18tCf OjJw== X-Gm-Message-State: AOJu0YwYKl8MJU+/bkY/3iZZyKMmV71XisxAAFQa00roUNuHF+lRAJ97 c82qRmlJFUudOPY5laLDBGf9f69OZPDqpIQl7CFENU8M0P8ozHGQ2iO3IcOInn0= X-Google-Smtp-Source: AGHT+IGBNUuoDAQL0pkLCMyHWCaO2KYdN3eRRjbq+JcAUmpZl/6o0Vki6wyVQPOrxoVvBtwDFwQh9g== X-Received: by 2002:a05:6214:20ce:b0:67a:a721:b1b5 with SMTP id 14-20020a05621420ce00b0067aa721b1b5mr9104092qve.112.1706578951030; Mon, 29 Jan 2024 17:42:31 -0800 (PST) Received: from localhost (2603-7000-0c01-2716-da5e-d3ff-fee7-26e7.res6.spectrum.com. [2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id b6-20020a05620a0f8600b007832575779esm3580991qkn.52.2024.01.29.17.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 17:42:30 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: Nhat Pham , Yosry Ahmed , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/20] mm: zswap: function ordering: public lru api Date: Mon, 29 Jan 2024 20:36:50 -0500 Message-ID: <20240130014208.565554-15-hannes@cmpxchg.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130014208.565554-1-hannes@cmpxchg.org> References: <20240130014208.565554-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C6E394000B X-Stat-Signature: bo7ebg179t9b34j447o8tha93c4eo7j1 X-HE-Tag: 1706578951-242369 X-HE-Meta: U2FsdGVkX1/me+QWp8OElBdpxM5/jHV4t2GQ6VBzYuSBcFB6x0JL0g6vpHnK9d/JbkczEf3DCKfw45ZXrbRZpjJN52ZeoZiLAoGPmhNKt2DmY0AmvC4nhkN0Oq0JrIyK+mtyyyxxcnQTXblYvje2nV5ZYHYz8rev6Ftqsh8HNAvsMW+Ozd7A904+8cLssH2DYgwVY3+YZpimbK7HNpPtCi46cBQt5iobBMjP65hHDPYgDU2I3LWVCYaEZI1gfql5ZKVD2QC5znlN1Jwyn34tWybRte8S1yhocbUuZY8i+eQhra2mdtS+NE5eBppmjWBd9C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KsYwTMHDP+z95r7d+j2dsqu1YQTcLivEpGg2jqKvRc6Ehm X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The zswap entry section sits awkwardly in the middle of LRU-related functions. Group the external LRU API functions first. Signed-off-by: Johannes Weiner Reviewed-by: Nhat Pham --- mm/zswap.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index e650fc587116..511bfafc1456 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -746,6 +746,10 @@ static int zswap_enabled_param_set(const char *val, return ret; } +/********************************* +* lru functions +**********************************/ + /* should be called under RCU */ #ifdef CONFIG_MEMCG static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry) @@ -764,6 +768,21 @@ static inline int entry_to_nid(struct zswap_entry *entry) return page_to_nid(virt_to_page(entry)); } +void zswap_lruvec_state_init(struct lruvec *lruvec) +{ + atomic_long_set(&lruvec->zswap_lruvec_state.nr_zswap_protected, 0); +} + +void zswap_folio_swapin(struct folio *folio) +{ + struct lruvec *lruvec; + + if (folio) { + lruvec = folio_lruvec(folio); + atomic_long_inc(&lruvec->zswap_lruvec_state.nr_zswap_protected); + } +} + void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg) { struct zswap_pool *pool; @@ -798,24 +817,6 @@ static void zswap_entry_cache_free(struct zswap_entry *entry) kmem_cache_free(zswap_entry_cache, entry); } -/********************************* -* zswap lruvec functions -**********************************/ -void zswap_lruvec_state_init(struct lruvec *lruvec) -{ - atomic_long_set(&lruvec->zswap_lruvec_state.nr_zswap_protected, 0); -} - -void zswap_folio_swapin(struct folio *folio) -{ - struct lruvec *lruvec; - - if (folio) { - lruvec = folio_lruvec(folio); - atomic_long_inc(&lruvec->zswap_lruvec_state.nr_zswap_protected); - } -} - /********************************* * lru functions **********************************/