From patchwork Tue Jan 30 01:36:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13536669 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 936FDC48285 for ; Tue, 30 Jan 2024 01:42:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 452936B00AB; Mon, 29 Jan 2024 20:42:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 401256B00AD; Mon, 29 Jan 2024 20:42:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27BFA6B00AE; Mon, 29 Jan 2024 20:42:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1006E6B00AB for ; Mon, 29 Jan 2024 20:42:20 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D45521C1494 for ; Tue, 30 Jan 2024 01:42:19 +0000 (UTC) X-FDA: 81734277198.24.4B7745B Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by imf08.hostedemail.com (Postfix) with ESMTP id 4EE84160002 for ; Tue, 30 Jan 2024 01:42:18 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=NwQ7LO9I; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf08.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.179 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706578938; a=rsa-sha256; cv=none; b=fmcl+Vx5jzS3zkQjj8w+p80/hKLmnjjvB7xu7FLpsiIMu7bcNAwUvZ12Q61IPjy0GBKR7R txA5OaIVcxxLnHJTrflEnDv3ZCD0Tk2bZdoTgSoPdAY6qO8cTG3QRPlrP7HlXA6ErR8KTW trUKOJTJQh0JvGVtNAkBtiopVzcrngw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=NwQ7LO9I; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf08.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.179 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=1706578938; 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=2V/6lwbRMGjS57LQdA40055rq8F7L2NGNcAA5/p/KKk=; b=fHr73TKYxNppupOpG++ewKxaMvCToGaYWBfEuKJVyWiWRZRDU/YjuMdRLeKllK+7qed9B2 pT3njRJ5xJCcSjAnVw8z82iW2ODyXiu8Io2TNFxXu3dh9npVK6IeI66qvtzLDe38XJf/L5 2I20sA/x3vQZajQk15Js9r1jropCSYw= Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-783ced12f9bso236056785a.3 for ; Mon, 29 Jan 2024 17:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1706578937; x=1707183737; 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=2V/6lwbRMGjS57LQdA40055rq8F7L2NGNcAA5/p/KKk=; b=NwQ7LO9IyOIWVR3BVTyHlKnu79At65RNwqk8BIWjx6naFHVaSxb15AB/h6ieoMdFL0 b4NyFjChbXITgQIOOLqszgOIH2vUc1kqOJIyZxDGUZFuDZo6gf5uLR2dpXIrfbAMH9I2 9Pj/osZItMfIM9a1d2sSU4RmIQn1yBuanhc84NLVsjA6nw9Iv6ALkBksQHhQV5FvJMeN 1uzcC7hyHvFQAeDe11Ak7E+AzOj9e8gqKBEJVY+SK9SgRkiSGuU54kjmLLX+zbmxdea5 ai4JgYz6bshXDCYI/8ZApFSnAIXBJzryN5TwMa/UCnQKsCy3WHwjsC7PSqcOB/UZxlZh a34A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706578937; x=1707183737; 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=2V/6lwbRMGjS57LQdA40055rq8F7L2NGNcAA5/p/KKk=; b=fp0pP1daSvLjul1BOSTDJgMEPArc+q9BMjLphPcLX/tehwhLTDekonigWT+hMIKazG pN6vHaIyZIbHljhQVHf+YhRqrn6wi40kLWNl9IbKgqhP8d6X20XOoGdDToZQ9bLfV3U2 QstJuuPod1tafRMXE+UmYtJE6JKNMSOMkgZHJRRSqOLvy1e5xSGcxzbIzsVYaSyvdffw pFgP9xTlktyXD2DW+IdoIZa1+WD1Ee+P/nZi4yXOr2YP++xfUrvL0lZKr0f81bsjkYJ+ XNcw8ABE1FPvIkaXMj7VodBBLviR90A/amlFL8oPcIoHPKEjaU0qBX6eN1cLBSXvlsc9 olXQ== X-Gm-Message-State: AOJu0YwpV3OF7UfWnz5/QJ6afa+49GHIdsfGGh6bzPunbC515OGcNsKR NI3noLvjL5lFuSAb5lKZsvusE7g4Nt8OqblVkygnV4aiewdSC/fYlc0hOlBC0UU= X-Google-Smtp-Source: AGHT+IFtbmXej4OpvwtpOTmn5+j0+Crv33a0WDVXCIw0rfc+AKtf6Z9PD/0SvdYRbq+4bF63apG45Q== X-Received: by 2002:ad4:4ea7:0:b0:680:815a:44d8 with SMTP id ed7-20020ad44ea7000000b00680815a44d8mr7696476qvb.130.1706578937523; Mon, 29 Jan 2024 17:42:17 -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 11-20020a0562140dcb00b0068c5116af11sm1223091qvt.142.2024.01.29.17.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 17:42:17 -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 03/20] mm: zswap: move zswap_invalidate_entry() to related functions Date: Mon, 29 Jan 2024 20:36:39 -0500 Message-ID: <20240130014208.565554-4-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: rspam06 X-Rspamd-Queue-Id: 4EE84160002 X-Stat-Signature: mk358apdg7ki47uqmrqxj19c3hjapczi X-HE-Tag: 1706578938-248771 X-HE-Meta: U2FsdGVkX19pDq7qF3I+W/xOlBifrVBgumfM+vYMQXyjog14cQ4E3jB9Xg3Kqby7tuvBeRXQTcjb7ygfdfIbMpqgDhOVZaN52mgAJ4yW9igO6DwX+Rm8YxWYYb+sSaVade6NfRcFiRwxCKljuCOoT8iHkQEWXK//4uIaZ/8oyuTlDW8uksC9DIoBZ/AEw4y60DxKc+WAoFVU7+mGdxSTknjQsPBbuKqfPUDQ8b8O8f0w5n6caD8PvA/FoLLDCrxfwQkWOLFLl47mTn5g4Yb19jTLRPex+MaVxOiLUESBcCZt7adsWLb7VDjpU63auDf/ariHSy9gojL39Mbky/WdOaRApUS4uTAhCIOK3u0hDbYeJvyogmkwI5wrVYl3i9RQsTgtOtBQFhdBMMaq6aGwRDfhh98Iq+bwfw7HkBaWBYZTWXXtU5Rf3p5bnOJs+ExRXGh0i50v+rgZV0AYs20NSgUpOwysvltqE1FxRpUYaoMTruWogr7z7VP6e4XvQNeIw7ObAcUseiD3fZNzeFaorH/c4DzIoSWtaous45Y97nx1ZlXixKtdufW1SJTvyWqwzvT0XNjUi5AenyrxYnZaJJYkacSAwQ3Bc2MB5BblC8R4ATD8AxV/VLl7jHzIepU4yP7Z8wAMvPGTgEv+AX8iTTWJrJpPvKh82xkxt2Hw/qqs5J/cwIA0aCV0OSQYEeSbm5bXbNleG2CURDq5Z9WpdVl8Ip/3a1iNU5fsKpdn9ZH/1etgvZeoeSTUedhr6sbk/Vxn4OPBUSuSbWu6LhjiGwzcQygtzmR+EeIWZTGiXJDsVbbi0rFA1nLIrjVEibvpYMImI6e/P9uh8/0K1pI58fi37dJG1qcpFUZSAlLQpPVH3roQxL2tNabo90stGWivK6ny8kTK7UG+XYxDep1Zqx8w+rrrhEPuvEE0iHHA8nZG8hJEc347S2i1CyZcJaPXSxV1H24nE6X1wvDIk/E 2fo6qkBp z4Vs5WgjoHW0wpPg6UL/tPLRDtqoDIfMVswGQ9Q2CLBuTFTov5QR9UiDKt/twnjBK/BVt4nmRrRCPQsOBNEaA7bS19A3suFQnmmlDmZYsIdjjgtSCUT9Otd+jNuakwnWsXCBKHnKsxbUw7Pcq/sC2yZzjFEOPxg8Z5tVarZ86Mb9Ip94WdoMLQnLnuU84bLcLa3VpF3IZKEWL/JdLywGQptSuSYKu9XevLcAF 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: Move it up to the other tree and refcounting functions. Signed-off-by: Johannes Weiner Reviewed-by: Chengming Zhou Acked-by: Yosry Ahmed Reviewed-by: Nhat Pham --- mm/zswap.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index cf864aaa214d..9f05282efe3c 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -559,6 +559,18 @@ static void zswap_entry_put(struct zswap_entry *entry) } } +/* + * If the entry is still valid in the tree, drop the initial ref and remove it + * from the tree. This function must be called with an additional ref held, + * otherwise it may race with another invalidation freeing the entry. + */ +static void zswap_invalidate_entry(struct zswap_tree *tree, + struct zswap_entry *entry) +{ + if (zswap_rb_erase(&tree->rbroot, entry)) + zswap_entry_put(entry); +} + /********************************* * shrinker functions **********************************/ @@ -809,18 +821,6 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) return NULL; } -/* - * If the entry is still valid in the tree, drop the initial ref and remove it - * from the tree. This function must be called with an additional ref held, - * otherwise it may race with another invalidation freeing the entry. - */ -static void zswap_invalidate_entry(struct zswap_tree *tree, - struct zswap_entry *entry) -{ - if (zswap_rb_erase(&tree->rbroot, entry)) - zswap_entry_put(entry); -} - static enum lru_status shrink_memcg_cb(struct list_head *item, struct list_lru_one *l, spinlock_t *lock, void *arg) {