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 37125C43334 for ; Wed, 15 Jun 2022 18:18:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F7066B0071; Wed, 15 Jun 2022 14:18:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A66F6B0072; Wed, 15 Jun 2022 14:18:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86DF46B0074; Wed, 15 Jun 2022 14:18:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 771196B0071 for ; Wed, 15 Jun 2022 14:18:49 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 40EAB80FC9 for ; Wed, 15 Jun 2022 18:18:49 +0000 (UTC) X-FDA: 79581281178.20.C056CAD Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf20.hostedemail.com (Postfix) with ESMTP id BAF7F1C0087 for ; Wed, 15 Jun 2022 18:18:48 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id cx11so11954454pjb.1 for ; Wed, 15 Jun 2022 11:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vJXdLmcQUyrb4VKNR1Dojq9lVpq1SvOPdHlcqg6WF3s=; b=DuaOiTeN5VpIwVKopMWgQ+RG1ALSGpah21F52G7gtoz7YAIQMdyC5z3gPT+/a7n73B 5OYry0sjeIEa39VjtdjfY2UAouGqK+B9/PpSodnJ8kuId6t3feBc6yDVXDrZsQayJ3iW pXjsZW6adkWX/mxICwRjX/NkD/R3mf7SCJmKJ7hWP3+5BzaCkzPqXeyQl9zJPDjWL55L aclzC6udevrjJsjfSLm3QeavXQr3xaxFcts5rxPxJKbjyLqhmtEqNb42jUMTP2qyB/vc NJhYd7urPQ/nP/b8MewpNtLzeuB3cqwXu5XIll351C7LKGXLxPNti8EfUUTf0maD1FdM rGpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vJXdLmcQUyrb4VKNR1Dojq9lVpq1SvOPdHlcqg6WF3s=; b=RzMCwKf6Ud0f9un39d0mRrocPzXE7yxp7Yo80HQWstnLqPvXOI0hYR3OIjwX6dtH8e UJsujpobVFsaAOZy/HTcHz3Fo0YHWNMVTDXYVYqjz1C+b6zmrZJXkD+sOBp0sMtkh2MB DwTHrpghGfiP55lu9mxZcA9CXJ/yCR3UB2g7qwR6aMWbULZvaLg0rRyFe5EFZDQuIC+p 8sLNenWh6gR1+YvICYYvZWiUHu7oAgA98TsdO0EBBIcRDNiEK99x8rPWCJNqgxoYYFMq oLOZuxVOFrxAViwSyN/a6kFUS237Ol1uTlg9rCOSihKtXYTt1xC4cTw9SU2BC736lhkg BaUA== X-Gm-Message-State: AJIora9fRX22FOCoRENtqFuDSr5xtdvMFQjNXLUBv2BkdOHFvrfTg39s 6EgUKwDRhu74q0/6NcuoHs4dl7QJq1dX0uLb9Sc= X-Google-Smtp-Source: AGRyM1v5ye0uTYtqCuLoFNVZPFwTYyyNDqLVKrIuaEj0efPlh+dQdAbu4BJK0lTk0wdZiHUK+yEGvVn91sga2c0Tpss= X-Received: by 2002:a17:90a:ce84:b0:1e4:d803:fad with SMTP id g4-20020a17090ace8400b001e4d8030fadmr11878546pju.99.1655317127677; Wed, 15 Jun 2022 11:18:47 -0700 (PDT) MIME-Version: 1.0 References: <20220611084731.55155-1-linmiaohe@huawei.com> <20220611084731.55155-5-linmiaohe@huawei.com> In-Reply-To: From: Yang Shi Date: Wed, 15 Jun 2022 11:18:35 -0700 Message-ID: Subject: Re: [PATCH 4/7] mm/khugepaged: minor cleanup for collapse_file To: "Zach O'Keefe" Cc: Miaohe Lin , Andrew Morton , Andrea Arcangeli , Matthew Wilcox , Vlastimil Babka , David Howells , NeilBrown , Alistair Popple , David Hildenbrand , Suren Baghdasaryan , Peter Xu , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655317128; a=rsa-sha256; cv=none; b=GqULHyKnkcfz8QUz9ym4XoMdScqhSFaBxcjWBxecCCC8UyfT4twBdq9s6vvI1ywNhvRZ+l WFcxB/dZPCcqjpGUTPdnHDZ5yn8T/mervMgFaOIcpnOJHCkxWQoH7/G0fm2YM+NvaaT4kG oNLTcYToDXtZE1TjSzWLW6w3LxDvvOg= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=DuaOiTeN; spf=pass (imf20.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=shy828301@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=1655317128; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vJXdLmcQUyrb4VKNR1Dojq9lVpq1SvOPdHlcqg6WF3s=; b=SU0iMseWAAl/6E4B322Hu1cXxTHtAiV1zJpUT0A5geImyGhtQJCLm2owEubMku8fsBM+FL MRw1JL1uDdX/gR1dNnwU1tPPYJPvxgh/CIYd4MwAtdtPnck6vXWl+y0p/Kc+falpPtPYWt 2BMCQofpF9R4rNkEFS1rRHwqeNQQn6s= X-Stat-Signature: mzu3j3q1g3e5fyxsgmnkjexrwazh9ibc X-Rspamd-Queue-Id: BAF7F1C0087 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=DuaOiTeN; spf=pass (imf20.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1655317128-69948 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: On Wed, Jun 15, 2022 at 8:55 AM Zach O'Keefe wrote: > > On 11 Jun 16:47, Miaohe Lin wrote: > > nr_none is always 0 for non-shmem case because the page can be read from > > the backend store. So when nr_none ! = 0, it must be in is_shmem case. > > Also only adjust the nrpages and uncharge shmem when nr_none != 0 to save > > cpu cycles. > > > > Signed-off-by: Miaohe Lin > > --- > > mm/khugepaged.c | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > index 1b5dd3820eac..8e6fad7c7bd9 100644 > > --- a/mm/khugepaged.c > > +++ b/mm/khugepaged.c > > @@ -1885,8 +1885,7 @@ static void collapse_file(struct mm_struct *mm, > > > > if (nr_none) { > > __mod_lruvec_page_state(new_page, NR_FILE_PAGES, nr_none); > > - if (is_shmem) > > - __mod_lruvec_page_state(new_page, NR_SHMEM, nr_none); > > + __mod_lruvec_page_state(new_page, NR_SHMEM, nr_none); > > } > > > Might be worth a small comment here - even though folks can see in above code > that this is only incremented in shmem path, might be nice to say why it's > always 0 for non-shmem (or conversely, why it's only possible to be non 0 on > shmem). Agreed, better to have some comments in the code. > > > > > /* Join all the small entries into a single multi-index entry */ > > @@ -1950,10 +1949,10 @@ static void collapse_file(struct mm_struct *mm, > > > > /* Something went wrong: roll back page cache changes */ > > xas_lock_irq(&xas); > > - mapping->nrpages -= nr_none; > > - > > - if (is_shmem) > > + if (nr_none) { > > + mapping->nrpages -= nr_none; > > shmem_uncharge(mapping->host, nr_none); > > + } > > > > xas_set(&xas, start); > > xas_for_each(&xas, page, end - 1) { > > -- > > 2.23.0 > > > > > > Otherwise, > > Reviewed-by: Zach O'Keefe >