From patchwork Thu Dec 8 18:02:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13068647 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 D7E3CC4332F for ; Thu, 8 Dec 2022 18:03:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77D8A8E0009; Thu, 8 Dec 2022 13:03:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 754BC8E0001; Thu, 8 Dec 2022 13:03:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F63B8E0009; Thu, 8 Dec 2022 13:03:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4B8998E0001 for ; Thu, 8 Dec 2022 13:03:41 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 14A901608B6 for ; Thu, 8 Dec 2022 18:03:41 +0000 (UTC) X-FDA: 80219911842.19.2967319 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf17.hostedemail.com (Postfix) with ESMTP id 5C4DE40003 for ; Thu, 8 Dec 2022 18:03:39 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hRgCXWOP; spf=pass (imf17.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670522619; a=rsa-sha256; cv=none; b=eouwg8R2VCSb7BFt10MNNpy7DmoWV9zx7LMAnmXf1+TusCawTnCg2OTvnNPaZmY7bJwyKq f+SzgPiXVbrhddq9Or8bLZ1NwHpjjSrn2ZUBefBtcjwW3keunIXgq+Hr6wssijyalyjTmW EcX9iK7TJVJgQMUtLcMcWmr032R9SBc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hRgCXWOP; spf=pass (imf17.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=ryncsn@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=1670522619; h=from:from:sender:reply-to: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=ltPbBrCKZDS7mJn+bR+RqAKCWGPP/Hc1SQkH2hWVmXg=; b=tti4CXfBNFhB+9cxc6gDtdWxepID5y9LU9oC0DkTofciOUOMse8ybNKFtCtzs+/TwLfQ5C cwjkt3OIyur6MYp4R/NkKpYsfZLCz5OaLGpWkcnSa8UeL+DHPPeqKZg6TJg3EOJsHOGOTW RlBD0zi4QFtAk488rUiBLm5t8SMVtJw= Received: by mail-pj1-f41.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so5460505pje.5 for ; Thu, 08 Dec 2022 10:03:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=ltPbBrCKZDS7mJn+bR+RqAKCWGPP/Hc1SQkH2hWVmXg=; b=hRgCXWOPDDo7RlbXFKoM69xuCbwt8WjzTaUsg01akGxMhNwABD12DyylexVFkD/7Mu M+qrq5HV/MDlhFQ2jxpJkr9HNBE7YMfEZaXVGRTNrwlZFE00eokpEecQWj3j6JrbPCbA 1zHxzkaBVjYkjr1s2oWBVUR/5nbzmiSc+/4+6qJl50hF8eFgPh9NnQuk0lo+FhfUqNe6 F3QleTfoMD2zNv1+SBcEq0q4ftrAofnh81ysKVSlErGBas3RbClmzj9QYTQztCMaIqID gUiM72cYqHlrpjl8RiTv3askqJOawjDqYKnOo2KlhUkvFGpDTtXyhTuqVoXIozJUmNZa Jslw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ltPbBrCKZDS7mJn+bR+RqAKCWGPP/Hc1SQkH2hWVmXg=; b=JDTAxaPx5+DePerdloiOc/AtICCCOmurbeOngXU8Qh5Gymh7fPRWsX9Lr2QJiYleBE mE5dMvMLaSsnH8vdSq8PjfZM7kcIC9RBhP9LJQdZxYiiEFQLW5AfjdPs4S866A9+22Ss 6m3r+orqJpcSzPFjc17KheKyMowOrmq8QW82g5qtwNXURmEM7R9aBKX1ebb/zJ3pMA+9 dpvoq03UwhR/YZF0SXrksVrfaEBz4UsjtoGIT1T21tSsQ9Nvzs9TtGuBCshdo8qm7KYw 0CJJ9tCiLNp7N0t4T+P4Xjhg0te9+hkAnbtouWswXUtRn7ICAMWnKGKZpfaEvgfg5BB+ N+0g== X-Gm-Message-State: ANoB5pnctF3lCcYWkL+WW8inyKU5L6FESVWwbL9BJmZX/WZNkivlEFCj UXq9+YYf27eWjy/jjKV/OZ+5YAdAT2b7f17Q X-Google-Smtp-Source: AA0mqf7l35N5CcqRRUA9kCptWivxf7XeTYnN81QwD1VXUWMNcNSdS0Hq0NDpeaJYmfVtAUqrHE18Iw== X-Received: by 2002:a17:90a:7606:b0:219:823e:6726 with SMTP id s6-20020a17090a760600b00219823e6726mr2920444pjk.19.1670522617801; Thu, 08 Dec 2022 10:03:37 -0800 (PST) Received: from localhost.localdomain ([198.13.51.166]) by smtp.gmail.com with ESMTPSA id x23-20020a63db57000000b004785e505bcdsm13377909pgi.51.2022.12.08.10.03.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 08 Dec 2022 10:03:37 -0800 (PST) From: Kairui Song To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Andrew Morton , Miaohe Lin , David Hildenbrand , "Huang, Ying" , Hugh Dickins , Kairui Song Subject: [PATCH 5/5] swap: avoid ra statistic lost when swapin races Date: Fri, 9 Dec 2022 02:02:09 +0800 Message-Id: <20221208180209.50845-6-ryncsn@gmail.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20221208180209.50845-1-ryncsn@gmail.com> References: <20221208180209.50845-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5C4DE40003 X-Stat-Signature: nae13tbpx4j8axj8wmm3oryz8aaafs8h X-HE-Tag: 1670522619-983586 X-HE-Meta: U2FsdGVkX1/10Re/8xuqAkjhQ2tq0xfveblIcYvxmca6nTC3Y25/gXLf5O3biyp7rR/dCWMzbFo0S6N0YOq8qKJLIS0ld0VgW8ejx6inJrJ8E6BQjU22ndyXXh82rY/66alrsFsvZ07qernS+pBKXutRwRpu1HiJ4ZH+PVWTQOK8CH6NHrp0khBoypkJ/44HDe/IF/1ZzI1Csqe8m3BpOfN3t5G6ek/K6UA92Q+s1uinPATxQBNhBslweNB8e49rKRpLWTlmuJGvcTy37Eej4bPeG1QuUktz9Y4WeB1uIcFVVyGMzmWWQy8LueYLX9wogcpvSgZk7O50a5wcVteugGIHcVWSmFJZHc8yae3+a3+TI+0dMMLTtAOScVo7cNQcgnHhoLfTPHyD8P8NY2DX2xJS41lwnjIjWPkXLehy+g+NzbY4WvN9ezjZE0+qDyjjGEGzNtJQqzxk8njB5jNuL1s+RbL+6haErMb44C+3lQwy71Yt7KQF0Vyx78kKe3B1BIgzYxhOPKog5RpIPpYFRheSrenhVhb4GSHTsdBtUNcxPZgPJyuM/DwNwbT9eVV4oA3cXKYqJQBHnqjmOowG4+rP/VFKtyolnm661iI0LUjoJozpzEIari9PN3ELETJRFRHHLD0olaPaQ14Mh2GI+heM9YCkSXZ/wbnDV1b1PUVSPDivXIwa0EfR3DFmPxQ6/Kp1BYCX6m1Kpz0mRvMLlpsXTm3FXKuxXBN5D9s0PasknGv2uEmyrM+DR+zXT4DlyHBMQ1mRvuSoUU1duohI8Dw9RmZbaItTkcz8MstodkBkS5opREliKUP4gmA8jBM8l0dmXIrEDaNsYKzh14pRA9bW+Eca/ceh8Ctz11+i1eyVAxCNFI91+G0z98a/vKyd/XR1HgtvUfJjqND+5q+s2z/YLmhHj1du+ufhDQfOg87y45R2B59qsEcYZtXAqStAygQFxfJW7NgKNoqBP/A RftJdBIn 8r3xcE/sgnDOMgHZIL8J86pOi8HcFPzQGLzUttKkctsfQhm/rqHX2+I753OtG7zEzZoSA6Thb5V0n3RcBjjfe7DCr/h46jtWddvawfXhYf9osmlHZJvcB/q5zxL70YAo1eMmCM8/JEVW76NMpOjWCWR3i2B17/Jarqy3SSeafMf4O02emj99hv+oLTcN7W0P6MBFhqXo1HXZ7yBLlRP6Y6Vxrn+mWdI/WJyZ21qFaHdRXuIvWfsJFgvYYnOIJqFi8QufFhU948wcDQl0Du/axYc04+g== 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: From: Kairui Song __read_swap_cache_async should just call swap_cache_get_folio for trying to look up the swap cache. Because swap_cache_get_folio handles the readahead statistic, and clears the RA flag, looking up the cache directly will skip these parts. And the comment no longer applies after commit 442701e7058b ("mm/swap: remove swap_cache_info statistics"), just remove them. Fixes: 442701e7058b ("mm/swap: remove swap_cache_info statistics") Signed-off-by: Kairui Song --- mm/swap_state.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index eba388f67741..f39cfb62551d 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -418,15 +418,12 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, for (;;) { int err; /* - * First check the swap cache. Since this is normally - * called after swap_cache_get_folio() failed, re-calling - * that would confuse statistics. + * First check the swap cache in case of race. */ si = get_swap_device(entry); if (!si) return NULL; - folio = filemap_get_folio(swap_address_space(entry), - swp_offset(entry)); + folio = swap_cache_get_folio(entry, vma, addr); put_swap_device(si); if (folio) return folio_file_page(folio, swp_offset(entry));