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 802CBC4332F for ; Sun, 11 Dec 2022 12:15:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9450A8E0003; Sun, 11 Dec 2022 07:15:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F52B8E0001; Sun, 11 Dec 2022 07:15:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BD0A8E0003; Sun, 11 Dec 2022 07:15:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6C54F8E0001 for ; Sun, 11 Dec 2022 07:15:18 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3F8C31A0450 for ; Sun, 11 Dec 2022 12:15:18 +0000 (UTC) X-FDA: 80229920316.21.6C24486 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by imf03.hostedemail.com (Postfix) with ESMTP id 8639620015 for ; Sun, 11 Dec 2022 12:15:16 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=pFgEVlKr; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.167.46 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670760916; 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=FOhALRV4kIXQtDuec85LwjS+txHnrUdN4lz3sSZ1Kow=; b=GuLCVEv4XPh7UKTuC5TDq2YL0O4K+g8YGYhH4dVz/9Y2YZjpWk45aPeT0rneB7GZHL9/fY p4NUK+QYEWorJasDZrUhEwWNqN7rUE9jo2vaFfLgB8zn5EnSgAd80BrH+z2Nm7vfny1hp8 Hqw2kNehp16kFMB8LbjQSjKwlMhqJHo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=pFgEVlKr; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.167.46 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670760916; a=rsa-sha256; cv=none; b=qQFl0L3chnnqLtOEO+xoZyRRLHohMKg8ICZqlouKiI1SyR5PsigU+Foa4tTjEguupb/5OP U5nwevIpPYtujUKSoiarwXRIRv+zA9/3rdIp4QApOrhRrTLuwpz+rEB/tPHREdP9YeYPuk mzlcZJHZyGI9wg7X/O7L2OesAWEleZw= Received: by mail-lf1-f46.google.com with SMTP id bp15so14085015lfb.13 for ; Sun, 11 Dec 2022 04:15:16 -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=FOhALRV4kIXQtDuec85LwjS+txHnrUdN4lz3sSZ1Kow=; b=pFgEVlKrn38h185ryrDFIHm5vLdnfGxbSer3Ad9rFv8+1LjEBxqHRrXwLX0HljIQvD 2itoAYfxbsH/di3hvDqoKlAQk83H1Wz19qwRjCwHT3lSRX7IkeorbuLx6cA7yPOqIGve 3M3W3AwP70wV96U9/Us7hykA2txPuwzWlaoc47ha3eQ/NzeRrOh5DrfMZ72aFgecj3B8 znPMXE+NTyphmmttIjecMvHak2rHiqLq34g9xnghpm7x4c3fRT+T/Tid2e5h8ER80SOW esD3eLmk8XV1gZ6XqKEJafd7FGg4KXzl6nQr7XdUpxZMUqIhrE+5FPE0ppQJ4wwN/Kxt B8Tg== 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=FOhALRV4kIXQtDuec85LwjS+txHnrUdN4lz3sSZ1Kow=; b=EAi8hDPCsrKTLVILUsW/zFQZn/IeOGA1nEmL+NPxoHCpCx5xVt3DnNqa70y2ey0HQO jBtab8C4RfLS0CERQEUraHGF6g4OLNVTUVKeCTvFvmWmoMS/Y39ggwrDaKDFlZp7iYKO zHVWVCdQmQtvDUAMDMuofVIU6ZnHCsUmjFcasgAVnU396YQTZisv14VC+bPIjKuoSR4u eiMJMbrBvXNK1yTDS+NjiswknYmcfJpPeCBkP4+VxRs0dd8Uu8Imuw+FcPloH5RDB/Me I4foxo3hAXMwFDokwj2WPzWNg4FloLaxMuCZwyNegMJu4SX7s/kG4ZzcgF4k/a6/84He zDFg== X-Gm-Message-State: ANoB5pkxQ0woE4aqVUPvKD/C5CzyvbYpMA52tvR4qvdTkBoRVs47cihw qhCSe539DWMjZVNjtC9lt/4TUiE3WLXc7S86SO0= X-Google-Smtp-Source: AA0mqf5jPAFnPr2un53wnN+aLvpEv6xqjnphA9/FSw5xqMFs7A5mXyjJQc1aFBHzjE9WbxIblU1wS0qm9z1eMTrF1+k= X-Received: by 2002:a05:6512:1285:b0:4b6:e35b:3622 with SMTP id u5-20020a056512128500b004b6e35b3622mr312434lfs.325.1670760914797; Sun, 11 Dec 2022 04:15:14 -0800 (PST) MIME-Version: 1.0 References: <20221208180209.50845-1-ryncsn@gmail.com> <20221208180209.50845-6-ryncsn@gmail.com> <87edt6qhay.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: <87edt6qhay.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Kairui Song Date: Sun, 11 Dec 2022 20:15:02 +0800 Message-ID: Subject: Re: [PATCH 5/5] swap: avoid ra statistic lost when swapin races To: "Huang, Ying" Cc: Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Miaohe Lin , David Hildenbrand , Hugh Dickins Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 8639620015 X-Stat-Signature: m5eposzp49pteamdw4t571wpjn6aesh5 X-HE-Tag: 1670760916-444494 X-HE-Meta: U2FsdGVkX18XecT4i/z1NBhuTOltnLWps+8E+JWeo2Znu9hUDRi8+tpxRq9eWh7YG7BEPPysQjaNp+lNe3YFl9EHPsdLcZp6dtV7jFQAtor9lwlGXpQ/fpnb+HLTj6ef4QBHanTn38vfQ1KY7i2hYdej1VGZYJl38vmvi5a1X+M3mjpMpbAPE2JRhpt6VzJloGFAQxb0rXs1UcHUUmATEVNRFmFeHjcuzD6YYP5xax5VyeXAOgm1sXryQSsFCa2q6g5XOZN9OlJdxdV5j12x42eX2Rh8l8IRad86tyTUBXsotbtSpMI39CwLCrokBh4f6bwvJQcaQNEeS0gnrttSbyHzqxhD1WrGlflE3DS3Ecuz7CC+fUWUofVOR1Wa5sMHWKobmgoWMk3EUk4kSfO7Sz49pcGl3VG0/CVBY40BF2Bm2d4pp/MUcEw1hpOUOZH5gicQzsoxN8BfR+sBR7WCgAZKmDygDrnd7zOI7+Tb7rCyVoqj6oIykqLVyKdYGK8eVbLSpqPXHhkzTeU2IUBC2CHK+eehsyA33YfVgRAYZZiDwTuRtSsWKmmm8Gq059Yh86jO57EqVe8AaHfNXz+Wxb53GQLW0vfD9U3bTtmbhg/CkBahpZlPDWbeXArUSRQJxCvSdrF10JrH8NRJlhk7rIaOT41xwoA9mGz3G8vEw2hPwIGC76GhBhZx4gv/ho74r7EO78oDDi12lVmHXfxLuEzbZQpbeZEV5SGpw//3yEmEbwgxeLujff9/+opTTGOmBuwAi4n0JmtqvIzKMmcwMmJqC1m5duAhsrCDVRIGPb+lPLcjdZNWofk7je1Kqe9LapG75SoEs5acxsE+zW31imUr3J/DXzYYizrT0kT/CE8cNv9vpSAnRqHXotucKvLf55a/w9S2T5Llk892uRTf5J2qfpm8qg/zgA7HtdewPhwl4cMfoIbTNpCSfhP4iJiv8QSKxdj6tvzVFFHu3dG uHFiEUzR vh6T3BaxsY5muCzfIis7O9ZQs3aJib9oCsCb1witMd8MGCImxN5MiOjOAbw== 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: Huang, Ying =E4=BA=8E2022=E5=B9=B412=E6=9C=8811=E6= =97=A5=E5=91=A8=E6=97=A5 20:03=E5=86=99=E9=81=93=EF=BC=9A > > Kairui Song writes: > > > 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 tr= ying > >> > 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? > > __read_swap_cache_async() is called by readahead too > (swap_vma_readahead/__read_swap_cache_async). I don't think that it's a > good idea to do swap readahead operation in this function. Ah, I got it. Thanks for pointing out the issue, I'll drop this patch. > > Best Regards, > Huang, Ying