From patchwork Tue Jan 30 01:36:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13536675 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 F1C39C47DA9 for ; Tue, 30 Jan 2024 01:42:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D2296B00B2; Mon, 29 Jan 2024 20:42:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 95C4A6B00B3; Mon, 29 Jan 2024 20:42:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AD116B00B4; Mon, 29 Jan 2024 20:42:27 -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 65EB46B00B2 for ; Mon, 29 Jan 2024 20:42:27 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3C31080263 for ; Tue, 30 Jan 2024 01:42:27 +0000 (UTC) X-FDA: 81734277534.08.769C596 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by imf23.hostedemail.com (Postfix) with ESMTP id 789A7140019 for ; Tue, 30 Jan 2024 01:42:25 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=R36OVo0D; spf=pass (imf23.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.42 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706578945; a=rsa-sha256; cv=none; b=X27WeaCPeHm0Fo8zNWnCrdM8RsRq3f7pv14aDZUjkC2Z8h8aXCX93SoVb3cDmAiwqymAR/ SKW6qlYyhXqJ6v5c5IxkW8iRQIfpzQ7yH3f0rg6k6fIyRld5hPtuttgodRW/LvxJwBccao iV1Y6ag8Wzn1nlStnVcDUlUUH+9X0e8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=R36OVo0D; spf=pass (imf23.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.42 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706578945; 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=YF/Bz5keaw8EKm3mlmWlxcJJmelaMJ52iqxIOq55K14=; b=ZWHBOdyNP7/7jlqMV44yKGkNYLm6ogETsJUDj479WaJQfgRNLQOSw9vJkw35AQyB9TySYa W19mY/bGR1XeZAAMsbEGL+DgTUqixEWsQW9hRAlfH87nk1fs4+TjkCGCgmP+hbbU1ynh/j PFRMyfxskcxRaSZNg5y2jXRPgLDj5l4= Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-68873473ce6so27582946d6.0 for ; Mon, 29 Jan 2024 17:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1706578944; x=1707183744; 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=YF/Bz5keaw8EKm3mlmWlxcJJmelaMJ52iqxIOq55K14=; b=R36OVo0DctXCGSafskRwptguWYaVOHSVYQFxUT5TRhSAJ6WRUaf2eAqaDXlVM1Giym NPjWhYIcUUbEP0kln1H7mD8qq6uj61nRBS5K92v0e6wC4WP2fOlyLqDNKzkpcvQocdgo Wy+bGy8L7CxpmbHBOTdwGmnAdNC3qqs/C74xnBqJfzFWdeLVjhIKl9QX44hosE/0jPa+ AmmjRKLHlVVJ+dcZdqKDE27/yX4xdbXURg39hxets2x4h0MgrjcxXLnhTlly29m8XRlu efk8VzxRuUvRA2qbGPBN6r35qokGZFRcC9GpsG7TIw1MWlVtq1c/agjIkWp2Zs9MEekD Z5+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706578944; x=1707183744; 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=YF/Bz5keaw8EKm3mlmWlxcJJmelaMJ52iqxIOq55K14=; b=in2ZmJFfisNrAqfgCX1LRM9YM8g1oAGYkxmIth7auAgPYmQLb5O4Knsx2P/UYx9T7W FdG+9/xZcwZPF6/e+z25cC6KIUumJso7Jj/lx0blfKmpUbzkxexrEFRUr8HLP/JjMKs2 vF2uo/CwSpeMzAwezviBdyj/QQDsHe/nmSF/XKumLGAiehj/03h/Av2BxPg5mYigwozV hPXL4+kvZ7t58tjo6ss3WxGcBFx9x1oaqyFpzOaNmI6nrUuyUa1PUEiIoqHdDlajCRDc r/xGmWAORGndLME59oIa2wFNdNhUUhRvhUGAlbUdAYBrowj0LaO1AWNwUaOIz7URJWY0 TdEw== X-Gm-Message-State: AOJu0YxXArt54I8yM4awL3Edhl/KgycduarrnV/z6Hvvcp18KuX0aXGB bn3p8FsgFtZg5zdU216lV1124CjgasrrLMvq65IJ6xUAFN9Kl3Y6Ogt+h697nvy2UxUqiO6wMRp R X-Google-Smtp-Source: AGHT+IEJUv991aH24M+mVS5b+IJCVkoWklj7Vk7Ouj1HKmo2haOgY/W/6O3BRf6ukVaZRAeczwm31g== X-Received: by 2002:a05:6214:1804:b0:68c:623d:13d3 with SMTP id o4-20020a056214180400b0068c623d13d3mr24326qvw.68.1706578944683; Mon, 29 Jan 2024 17:42:24 -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 kf4-20020a056214524400b006837a012417sm3992019qvb.51.2024.01.29.17.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 17:42:24 -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 09/20] mm: zswap: simplify zswap_invalidate() Date: Mon, 29 Jan 2024 20:36:45 -0500 Message-ID: <20240130014208.565554-10-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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 789A7140019 X-Stat-Signature: 9tb4d13h6b4k76qeueinwgkxsgxq51dm X-Rspam-User: X-HE-Tag: 1706578945-220352 X-HE-Meta: U2FsdGVkX19ydKuwlJmeOxo/FD5WWbOxc47VJ/vQiByLgviimqaddnqeP1eFxiSpwiwTbDSbAmOGl9inL1n8hthSBH/iFhciNYvOBWRUeU46daz6dwdOu/j3LncHK1QdV9oP/Mmq2nAoxrFvK4FlB+oKFm7bXjp6pY9sxPdKQMuo63KPb/JA01NWWYNguOG0gUNDr8dhFuUMzKpbOefuUhf32peW0I4I5+ad5VaA91Iz3rhhqqPYghilOU6DE37Q2U8ipbPoG94RIOxM8qin85jC7e8Z5EW0vbrC8hDEShJj79owXMvSVt/GSQ+hNUWjFj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TKFHNNxLCtA9t4cBjbT4JeRa8tCJd/XqjSo/2dIl1WNgcSqejcLQM+NXgT2rLV8TA1ja2NrdDC+3owLLV+dbBU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000103, 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 branching is awkward and duplicates code. The comment about writeback is also misleading: yes, the entry might have been written back. Or it might have never been stored in zswap to begin with due to a rejection - zswap_invalidate() is called on all exiting swap entries. Signed-off-by: Johannes Weiner Reviewed-by: Chengming Zhou Acked-by: Yosry Ahmed Reviewed-by: Nhat Pham --- mm/zswap.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index cde309c539b3..082d076a758d 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1739,15 +1739,10 @@ void zswap_invalidate(int type, pgoff_t offset) struct zswap_tree *tree = swap_zswap_tree(swp_entry(type, offset)); struct zswap_entry *entry; - /* find */ spin_lock(&tree->lock); entry = zswap_rb_search(&tree->rbroot, offset); - if (!entry) { - /* entry was written back */ - spin_unlock(&tree->lock); - return; - } - zswap_invalidate_entry(tree, entry); + if (entry) + zswap_invalidate_entry(tree, entry); spin_unlock(&tree->lock); }