From patchwork Wed Jun 12 10:01:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13694760 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 85C51C27C53 for ; Wed, 12 Jun 2024 10:01:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09EE66B0095; Wed, 12 Jun 2024 06:01:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04F226B0096; Wed, 12 Jun 2024 06:01:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E327D6B0099; Wed, 12 Jun 2024 06:01:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BDF1F6B0095 for ; Wed, 12 Jun 2024 06:01:25 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3914EC16AA for ; Wed, 12 Jun 2024 10:01:25 +0000 (UTC) X-FDA: 82221794130.19.CD127C6 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by imf22.hostedemail.com (Postfix) with ESMTP id 80EB5C002C for ; Wed, 12 Jun 2024 10:01:23 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="J3z/PSqr"; spf=pass (imf22.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718186483; 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:references:dkim-signature; bh=AhgKyJlD2vWJb9JL/Gw5nFT1XfWpW1UuHSEQpsWI+uY=; b=zBNaC72rqWnmYCt81pAl4kJmJ4UCCKmr+1Z29g0b9RNqRoGxpRrEs2OA33VGypz04qVGOB daIlm6F+3weFZmNJnyIYEu1RCFHioyvzdXSmSUq0fLD8OM3x+Jxkxl7U25pHSJcq2Mf3fc V0+aZZr4bkQeL85Fz0qQIA115f1juNU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="J3z/PSqr"; spf=pass (imf22.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718186483; a=rsa-sha256; cv=none; b=dmc7LACCffQojTri1fVm4WbqHW+5PkRDNjcU95rF1GkK3txwQaaKdjv2uF9m3yqHtucpAQ bkkwUrVdgTIUVBbekUL/VfL/7O1iS7OL4VA4lgE/XG6VXWj8Gl6h+MMQOSe8tmbwhZEpfh MHZ+H+9djvuq8X9kJuOHMU493NKMIaI= Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-627ebbefd85so76269817b3.3 for ; Wed, 12 Jun 2024 03:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718186482; x=1718791282; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AhgKyJlD2vWJb9JL/Gw5nFT1XfWpW1UuHSEQpsWI+uY=; b=J3z/PSqrbel9KY0bWyZyW1VDH8hm3nqtIyc0NJR0u5o4XIX62rZzcYP5uT99NB579N wi3kqHhRA9F3/Vkr9P7a0ekpwF+Dzddw36Y8c+Xwh4Hp8rZGKQjfpCtvhHw06yK/v77D 0jTQDmEAJzwoDVmqfQQjot6cSG8etVB01CDIJ8B6L8JUEvmMCLedMBpN/nv0u28NpluO tvyGyTcJACObAVe/Fghy3yvoNiH/JmwqHUB1tcTcxoFpkSzG5zZTJsCq4uPbvNwVRW8O DWkfYF4gJ7yMxUfrh1VZ17zDw/71bTmu8x0Rs/u65ouezYTa+tAVctVAkTJlbfBW5DRP uS7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718186482; x=1718791282; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AhgKyJlD2vWJb9JL/Gw5nFT1XfWpW1UuHSEQpsWI+uY=; b=eExU9C3BidG1icSCWdwJWT8aSwVUZ5hZRl8lxbHCBbAar0ME2peQYl0KSSYuB9NC7A F4BOuI/rGBFHxoYH1LlS9B5gkDk3TtU1PzZowyFJu4Y1l1cE5VbliqwSgTI0zsjfE/OD hvZ2B9+Y+FmR5yZaXyhgk2Ie6hGHuG8D8tDCiEMA/aZlEyc5UNTbDy9ugAbFobYB0EtH SrMFFMLHQpuOrHqy5hCRK4YNbSnTSineDvjVPztfcHanmyWdKTlCuMP5j/j/S76uRkgM wVZi0hFem2Q/PNBdgfLfQU9UqbIWjUc0VXQLpgj+URCnr8rNUrAF0SHq3+bPxMyF3riM ie6w== X-Forwarded-Encrypted: i=1; AJvYcCVvpZy8nD2B7YJnIcQkRkrkD7UIfKQBLj78YIwppCuqCxA0c/hwlld8PmflGHYBkOyrS7ivLQiHcgeVD5yFh/UtiUw= X-Gm-Message-State: AOJu0YzhD5kWMdIm/Wqsu8P/KaKGP1tGM3j87SJVQrZGIrMHtbxp2ZdQ kyXrRzWBpxuvGdB+dzHR6gnyeVcBTJTHk8/zvZgP5L0W761exD0/ X-Google-Smtp-Source: AGHT+IE4L0L47QVH3JJIqko79lJt0u2nUHCu1fn9GgPaUuT4L3KK3xB9cYvRMloLBM2cXbGS1VsgNw== X-Received: by 2002:a0d:c285:0:b0:62f:4149:760f with SMTP id 00721157ae682-62fbd79c03bmr11770277b3.33.1718186482133; Wed, 12 Jun 2024 03:01:22 -0700 (PDT) Received: from localhost (fwdproxy-ash-005.fbsv.net. [2a03:2880:20ff:5::face:b00c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06ae2266bsm45026816d6.3.2024.06.12.03.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 03:01:21 -0700 (PDT) From: Usama Arif To: akpm@linux-foundation.org Cc: shakeel.butt@linux.dev, willy@infradead.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Usama Arif Subject: [PATCH] mm: Do not start/end writeback for pages stored in zswap Date: Wed, 12 Jun 2024 11:01:09 +0100 Message-ID: <20240612100109.1616626-1-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 80EB5C002C X-Rspamd-Server: rspam01 X-Stat-Signature: zdhoajeqqfdnpgmw7h5ta8hpu8rdty5m X-HE-Tag: 1718186483-942075 X-HE-Meta: U2FsdGVkX1+W24z/3KhB8AtumTh55aPjsFvkW35KFuR6uCZgW2bLN+kfDX0inpaytGk/y+7RMAI3Vt2hgntp2NHGrk8TwhRMAASk+cYzD2VhSpAfZJCzjM7L8DWDGt1FGznLl/grximLuV5bbWmGwUnNcc1w8voRE1Ur71VvUOlaHfT4/BNXG2gWdql6lM0UGuk0Y7ePEDvrGyaqc33niEbM+ZaGAuGR5aJnZrIP30fJ1mSNc/nFna0O5lUlQ9gC4olpBkDSduGEwSbQmr8aKXBYHO6wijQPFY3fffAUyvYv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FEq7SRHdW3Spgv+PBCrOhS384D67XDwRuL5wQGs6VH8/kev3sPYBaA7P0tNT6c04Dcc X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Most of the work done in folio_start_writeback is reversed in folio_end_writeback. For e.g. NR_WRITEBACK and NR_ZONE_WRITE_PENDING are incremented in start_writeback and decremented in end_writeback. Calling end_writeback immediately after start_writeback (separated by folio_unlock) cancels the affect of most of the work done in start hence can be removed. There is some extra work done in folio_end_writeback, however it is incorrect/not applicable to zswap: - folio_end_writeback incorrectly increments NR_WRITTEN counter, eventhough the pages aren't written to disk, hence this change corrects this behaviour. - folio_end_writeback calls folio_rotate_reclaimable, but that only makes sense for async writeback pages, while for zswap pages are synchronously reclaimed. Suggested-by: Matthew Wilcox (Oracle) Acked-by: Johannes Weiner Reviewed-by: Chengming Zhou Reviewed-by: Shakeel Butt Acked-by: Yosry Ahmed Signed-off-by: Usama Arif --- mm/page_io.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index a360857cf75d..501784d79977 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -196,9 +196,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) return ret; } if (zswap_store(folio)) { - folio_start_writeback(folio); folio_unlock(folio); - folio_end_writeback(folio); return 0; } if (!mem_cgroup_zswap_writeback_enabled(folio_memcg(folio))) {