Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1821863rdb; Sun, 19 Nov 2023 11:48:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaUaoyi73KPoRu7lBrHWMDWcAll0idDH2xy7U9qGPO/GZZhcqzpkOCM9/6rW46YokhEVCx X-Received: by 2002:a9d:6f14:0:b0:6d6:4be1:442c with SMTP id n20-20020a9d6f14000000b006d64be1442cmr7303330otq.4.1700423300561; Sun, 19 Nov 2023 11:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700423300; cv=none; d=google.com; s=arc-20160816; b=powoN4jdpDjtS4Ocv3EjGbX7zAj12HxHZf8O+J7JQZ3Yvh0IzrdUN2IE5Rj6WTfVzQ Nrdyw63xmRt2EPGmwDoYNK8LhrvkNcH2+RqKofXLpSwoMq2iTGhSOL9NMi2ySIGlSau0 19MA4X43CvSSEjvmIyPUkJYGstehtE2WvgPD/REczaOP8IQAXbxFqlHoDFfHlgd0xJSk ugLkL7/tmrETQn70PImryZJX/V7g6808EcXD8z1Faexmw+OWy5OlbEest2PYQ5bv32Ub Kge+2jMt559g8oxXqpxjbbhHfQMVYxb1POeyU0DVvvqP+xFzExecj0k/y5xB9geFmLJ+ kBIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cduqWiCMIKVDQKzalcbjrj5u/UZrGRNgI9eE9WPHu3A=; fh=4HE/piJoUCKuBTCCBiej4//zvvzywHdOLL9QM/KYjYM=; b=aIwq6O94jqbmZiUi3FG20jHWs6ciPXAm7L6zuGor7noavQdQfuvTYbteNeENU8S60A Yhh6io0kOnqpAyCOhFibbRZH39O0k/g3Jh986SN41F1FQWwjlsA1HIrJbWk3qO85tk6r vLXQjlEENMdgRODYR0+u+iOE9Mhd3B49Tw2Iam3GNO3Q1cYmYlEi3nhA7C5LexpxwIfE drYYpqTBZRzMNES6f5jhpDDp4/9WdK8c8MBYgL41KGuWkFKZtFVnTQwrScoOZ7Azzpto hbBL/OFSzG3sVzUXq/qf8rwa2bW8dlfINzB86xfnrlZLl0YO3o+1daNrLOgn9AYI0MAt KRAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y9sAFqwP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a5-20020a170902ecc500b001cc467a339esi3500827plh.389.2023.11.19.11.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 11:48:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y9sAFqwP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9B13D8056486; Sun, 19 Nov 2023 11:48:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbjKSTsP (ORCPT + 99 others); Sun, 19 Nov 2023 14:48:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjKSTsM (ORCPT ); Sun, 19 Nov 2023 14:48:12 -0500 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3749111A for ; Sun, 19 Nov 2023 11:48:09 -0800 (PST) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-5c9d850a0dbso6658997b3.2 for ; Sun, 19 Nov 2023 11:48:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700423288; x=1701028088; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=cduqWiCMIKVDQKzalcbjrj5u/UZrGRNgI9eE9WPHu3A=; b=Y9sAFqwPPdpUQXqbpYpZjJ/bJFuU5qndB3eaipJ94VTJIKWoYM50djbzA8SIXrJp0E IQB+DXITZVEmKmCwo/wFMp1N+qG6z0btZOGJVXKggy+SgcgidRpVGvdBG4xhV4FE7AkJ l4rixv+zfi2XOjZY8M7Z/7CO8AVI+XwvjCe6aBACRlKbXd72bHRyilUuKRc5lIYCDts1 8HNy+kHE3SV6ZJvDbF9sGSrswumW19xFIu7juY64z337qf3doIndP5V1a1OyCwmyU5sA PF5ITZ1VZkihNjhzdlLL6Df5ZWehP+u2rGd4pmS2P/flRVc9zWrd6aZlwiFW9dJQcnAQ +PUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700423288; x=1701028088; h=content-transfer-encoding:mime-version:reply-to: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=cduqWiCMIKVDQKzalcbjrj5u/UZrGRNgI9eE9WPHu3A=; b=Yj3eNh5jUBAYPYvV47npF8G3aojkyElxcmw0nAUeXqjHu5dzbTX2PMrdkcx8dIHSSa DQ0RoMYLhigpSvwDTto6btWVqAQu5aF1DNESgT9vPsnP+70h2E4pdZH0CJgkBE2M0WN3 ovdRVzX20sXBeKJd/zgJ95aZbOXKf2ETuzlYrNyIW1Znf8BM2T4mMSNsKpDSNDDEy874 cUNjRuizQH3mwx4GLTgWf9TgFuWRJ2BNrTTKx1W/WgTWarnrKQ0/x//JHMqXhf1eqjeb X7BHIz/pejB41bTRlSi9uKHxb+Xr95lsA9x7pvN8eYOXUqJ04jlO8a5+BEsoMzxqdtq4 itSw== X-Gm-Message-State: AOJu0YzS44t4sk1xM3JMDaCRHfjvwppsUbVPIeIer9h9MyGrUF+pRknw eq7Qc1mj36D36QQzv3rlvv0= X-Received: by 2002:a81:4841:0:b0:5be:94a6:d919 with SMTP id v62-20020a814841000000b005be94a6d919mr6198288ywa.25.1700423288412; Sun, 19 Nov 2023 11:48:08 -0800 (PST) Received: from KASONG-MB2.tencent.com ([115.171.40.79]) by smtp.gmail.com with ESMTPSA id a6-20020aa78646000000b006cb7feae74fsm1237140pfo.164.2023.11.19.11.48.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 11:48:07 -0800 (PST) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 02/24] mm/swapfile.c: add back some comment Date: Mon, 20 Nov 2023 03:47:18 +0800 Message-ID: <20231119194740.94101-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119194740.94101-1-ryncsn@gmail.com> References: <20231119194740.94101-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 19 Nov 2023 11:48:19 -0800 (PST) From: Kairui Song Some useful comments were dropped in commit b56a2d8af914 ('mm: rid swapoff of quadratic complexity'), add them back. Signed-off-by: Kairui Song --- mm/swapfile.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/swapfile.c b/mm/swapfile.c index 4bc70f459164..756104ebd585 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1879,6 +1879,17 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, folio = page_folio(page); } if (!folio) { + /* + * The entry could have been freed, and will not + * be reused since swapoff() already disabled + * allocation from here, or alloc_page() failed. + * + * We don't hold lock here, so the swap entry could be + * SWAP_MAP_BAD (when the cluster is discarding). + * Instead of fail out, We can just skip the swap + * entry because swapoff will wait for discarding + * finish anyway. + */ swp_count = READ_ONCE(si->swap_map[offset]); if (swp_count == 0 || swp_count == SWAP_MAP_BAD) continue; -- 2.42.0