Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1961438rwb; Thu, 8 Dec 2022 18:07:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf4FwiRQrSLg745+7fILu+rG17hR7UxWR6OKvva0XtI2+93DK8h0z1HwVhc6NHtfZG6u1LjF X-Received: by 2002:a05:6402:5389:b0:461:fc07:b9a7 with SMTP id ew9-20020a056402538900b00461fc07b9a7mr4997433edb.2.1670551674424; Thu, 08 Dec 2022 18:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670551674; cv=none; d=google.com; s=arc-20160816; b=gDVvBAeCAXN73j2iZb4PucCLIefU+ALQCY4OSummyk6HaBzY0SKRCt0AWref6gEW4r ER2LiWC2CrjdrTraiXhbgw10UTKDw+widfrNb8n4yiBF4ZuQcaquEOuIwqsXCxEUxcrD kSZETmkxw1q9+7VYPRXEnjYWBm9Nw+DcAUXFuR/eVT3iun1td+2i/DdjeaSsXj3o4JC3 U1mUokvbLxIjq7iNbSJ8FvLKlJ4VLe46nzI+uqHS8fooSKuddCERpNyjxssaTi016mkF 0gc9TLA5+eGhhIu8EXGDf5FzMmkHkdPgPoY4Fk03KTNPVelN79ivy+/FaNwbL7Usq0SS 06HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dWEbjZuwz21qMAipQfSCpbrlbb3ehRFAaolDfDj6BYE=; b=K27q7F7DQ6rQvDmp6/SG3x318H1dWNjbyoQmqs9ZsWGMNBjonBLJinRbqZg8u+yhD9 F09wdDEc6wT8E/Xz3rqNnSdnYzoyx3vFYYv1ZG/NFZ87nSJHul8uzeHm7gNVVMty8X5A Mszi2dxlL9MG8hLdinwuTUAWXxbIjNOLF5EJU6hd6lm03xD0zU17++ZNap7obFqBtN5Q o0PazxF7i6BeiTmPPs1V6HIJjlhw9Mf5kUdziMl+K/QcJIwZO/ovSmjaPsGnlx7rdhXZ kctunzwcyNtAOPjf3uAu4mYPwOWNZSs4/uw84rt3vGHWneqT7474Kvvs1EbLY9LccEaq jCzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HWIrb+g3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a50a6d4000000b0046dc9115684si257981edc.98.2022.12.08.18.07.36; Thu, 08 Dec 2022 18:07:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HWIrb+g3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbiLIB4j (ORCPT + 73 others); Thu, 8 Dec 2022 20:56:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230085AbiLIB4D (ORCPT ); Thu, 8 Dec 2022 20:56:03 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 685F77D073 for ; Thu, 8 Dec 2022 17:54:44 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so3442649pjm.2 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=DH1Xs8eek58QWgj+l2Ib/N3GEXcMuuypvbVGfPmLj9cUIY6J6E/kVL2Q0KRV3zdZp9 HpnXRGuAFoqnBZ7oSyFJfkqDnjXilPsF7QgJJsSDLIxSHKTs4ZSl6S3Tr6o2qx0xv2HY p/uMpctDkYWlOnGD6haH2jKzVtNdCKq4BJ4ejRvakkho5IA/01lFjIKKSo8zmZNrLcie V+Ll+jum7tjSMZTW3Un5p3HZiocOjsrWxELTYJ+xq83ob/oCy1hHum38gj5sEWxgzdgC Obd8ydKShNsFzMa48n+8i2jhq7mh3iCGwdJQnBvZnVIr3Yd0QUeHQnGFzzfhKFVLVCLN X7iw== X-Gm-Message-State: ANoB5pmqFIWC6u1vk92URdUVPIIX+r9TjuGuj3AWflYvCe54AFEOvqUm 6MLiLuw3fLo4QzAqRrSN+TA9NWlo9dt/dnZXAWU= 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-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_NONE,SPF_HELO_NONE,SPF_PASS 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 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?