From mboxrd@z Thu Jan 1 00:00:00 1970 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 660EEC4332F for ; Fri, 9 Dec 2022 01:54:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC93B8E0006; Thu, 8 Dec 2022 20:54:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E52348E0001; Thu, 8 Dec 2022 20:54:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF5728E0006; Thu, 8 Dec 2022 20:54:47 -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 C05EA8E0001 for ; Thu, 8 Dec 2022 20:54:47 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8B4871C32B1 for ; Fri, 9 Dec 2022 01:54:47 +0000 (UTC) X-FDA: 80221099014.19.2CAB3F0 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf21.hostedemail.com (Postfix) with ESMTP id 027CB1C0006 for ; Fri, 9 Dec 2022 01:54:44 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=HWIrb+g3; spf=pass (imf21.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.43 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=1670550885; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dWEbjZuwz21qMAipQfSCpbrlbb3ehRFAaolDfDj6BYE=; b=gxSYB5MA2y9id3lk9+Hr3GcoQuTOLwP/pQMUpbW8iitzvIE9nC0OFtnn1Uzm6GI5s3L+lY HdquQYQFB3PzifjWd/zA4+EJUjCqBFd55P2yK7mgyeDp0BR/2jZWI8AuD3ZSRKQaAK48AS 5GQLaZXCg5Q8fC6jrYQyrh8rJibMOJw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=HWIrb+g3; spf=pass (imf21.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.43 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=1670550885; a=rsa-sha256; cv=none; b=elGRCmns0ixKPRtomwF0BB1yozdB+KN8mlnfssPyvisd4/TK5752NHbHZqBgv8a+V/CYqa xuRg0EVLfAjQkPiXy+JwlRFJUOE31fqkrO6XhWTGPJwIfL3+dYkn3mOs53HxiZqmsgZt5G fADSTo2oZNmB7LrOW0UdTAoVfDpeKdk= Received: by mail-pj1-f43.google.com with SMTP id u5so3317694pjy.5 for ; Thu, 08 Dec 2022 17:54:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dWEbjZuwz21qMAipQfSCpbrlbb3ehRFAaolDfDj6BYE=; b=HWIrb+g3Tr8iHSI08FLnXtwM1i+s4LoF5DGHrWkGkf+Jqd903i77WQVYt1WBH7Qct9 klab4063qWxSiA74HCSP0IITwFbCCyN3P8PRFEDy2xhRV/7YZ50oznUDXEwAWLwkgW8I YDILBWWtcPHtKRQOTSfuthWLM7k1bBrLZAVKOEMe4LbxfJUUf3Z6/PWEvT6i/r4O9s9d u4L+z3DmRqn38SSLNtVIiIKDPuvfPjZJP1P/vY0vHP88Lf0e5ylCy63U66UqvQhgGW0t FYw1MhLQvENAXdggUrPFaLx8+RdSNcayIslxBv9OjiMsLuYZZfuH+TrHBYpSIZqbpAji jong== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dWEbjZuwz21qMAipQfSCpbrlbb3ehRFAaolDfDj6BYE=; b=ck/nRwz4HBZRvLEPTt01z9Rxw2I4dg46meyepCM8SAH2jusoqqm2gyD19AascfTHVv ked7BJ4eXdgErp71ShAcb3zbKu96dzpmdzO6KIzDcXXwaVK+5qmvn864gZRBdtG+W6pK H8lmv3x1rxbkidjAxt0g/gPl1EIJ9/I9m9+Awp5/m01fNcOtGrGgNSTAFWhMyqAHTvbB K92Mu4Ke91iaNqF+L17dg5yl/guf4S8ZuXbH0Sp94oeJN/d1sGrU/IMuGkP6QAJ8bFHI o51JCI6VwnpEGcjnZAYtvBsnqWlYc8fOs4i/TCzl5s0lsRTLLOW1a1LKNqYatbL0L480 iiTQ== X-Gm-Message-State: ANoB5plBUyhHT1yMKtzilgr8JRuLmzxYAQCgZye2+Lc2knKIHXFx5Et4 8rOTH7Ndt7uXNX+c0egiY61TiGgpnuhIFp8qVy0= X-Google-Smtp-Source: AA0mqf5o+H2Twq4K0sRizhUqxKyhJr5qkHexPhiRcOmmbFrKC5rYQUzAqenv3kypsZUo3oYqgkuY0YV3O5aaSGMlSRM= X-Received: by 2002:a17:90a:c087:b0:21d:203f:a306 with SMTP id o7-20020a17090ac08700b0021d203fa306mr1064859pjs.148.1670550883960; Thu, 08 Dec 2022 17:54:43 -0800 (PST) MIME-Version: 1.0 References: <20221208180209.50845-1-ryncsn@gmail.com> <20221208180209.50845-6-ryncsn@gmail.com> In-Reply-To: From: Kairui Song Date: Fri, 9 Dec 2022 09:54:31 +0800 Message-ID: Subject: Re: [PATCH 5/5] swap: avoid ra statistic lost when swapin races To: Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Miaohe Lin , David Hildenbrand , "Huang, Ying" , Hugh Dickins Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 027CB1C0006 X-Rspam-User: X-Stat-Signature: mf1nwyb3qgtoexdrpuh8spg5pgtc1pde X-HE-Tag: 1670550884-566879 X-HE-Meta: U2FsdGVkX1/O6JasBaWzDMsy94OXzkJYpAHFpbPF1EvSwb6+kywdbo43aAGoBAv5AwJMtzwjhNNIQ3b92CyutoZgr7vJ1AnhUkZlyPGTalzrjirV84a/gtOHSdGzT4PjTgwaeXdXwpO1yIgDoGver1K402SZqU5wf87ioPLoyYrJQEo0gv4iZk86UfJpubTvkvuuobwqctL867nk6Q/DSGIsE4rqHU2J4jkRtWj8U+UMJViCeLlv6ZhdUEinV9yDxYRjFAdR21UUijlJpmTIW6WWleht/MXd4lvhKKJJYovudFng6hFV0rxb51vLcpAK2aDQOaPVseJBrf6o8GhgklzJObJB7RwzJRKAtEjSLyiBFR0ja0bW8DA5BlSX0Yre8PH6UeNKO/6M8peIZbpH6JxaEuEz6aUW1TYcAE6mWvHp7Nul0plgyi+nJEJmLiFh+NPbNqW21BbDGrRZCM9c3fXI3xc7gFpYcHsvXEB15tHag/FKVvYxNSCA9a1BGo6DmcfXiEFRDdJFqQgBCOIhi6Os+pbI6srG3T6I2Jpphk4+HwwntncF6fsmfyaZeUB7i/0suoU4o5sLVXyabQujlm3NvAqgaaxz2qJREwYZzez1KfFq0cKpySF7FFuIUX94ZUoXBvj+k91+FEHrz71nz9DVI4H8yicmJcQFadQJsUBaLqAZigizdvJ/VhQrXIIezdw3zXOKx66LHdYGEDHK/QAHVrhqGallLbzK6hfgNLUGbYsMcp59/LrFB7J6vN+9+MQqbebhS8YbR/alVHSokv6P9LvRIdOFToeaJuEmHLdC0f0MTd3knoywq2uVYu2YAQjuICcMQFr/RQy0fAaWfcA1xoo/x+BPER20m1zMyqeoFDfgCVr4xez4COjW1v7LNjVxA4H/WpyG6RsG9TnQfpFbz1gar7Q0SCsslHo0i81lo5bdl5N+FWbWjj8lOA6wriwS96ahRBGsCeZuDc2 a9TAl6nK TJEHtYXPJ0ZLOK4fuAKE5CQvcG6Um7edxp54kUZrCwFwDZ0dXXD22Yq5P8w== 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: Matthew Wilcox =E4=BA=8E2022=E5=B9=B412=E6=9C=889=E6= =97=A5=E5=91=A8=E4=BA=94 03:14=E5=86=99=E9=81=93=EF=BC=9A > Hi, thanks for the review. > On Fri, Dec 09, 2022 at 02:02:09AM +0800, Kairui Song wrote: > > From: Kairui Song > > > > __read_swap_cache_async should just call swap_cache_get_folio for tryin= g > > 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. > > But what about the readahead stats? > Shouldn't readahead stats be accounted here? __read_swap_cache_async is called by swap read in path, if it hits the swap cache, and the page have readahead page flag set, then accounting that readahead should be just the right thing todo. And the readahead flag is checked with folio_test_clear_readahead, so there should be no issue about repeated accounting. Only the addr info of the swap_readahead_info could be updated for multiple times by racing readers, but I think that seems fine, since we don't know which swap read comes later in case of race, just let the last reader that hits the swap cache update the address info of readahead makes sense to me. Or do you mean I should update the comment about the readahead stat instead of just drop the commnet?