From patchwork Thu Aug 11 05:06:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12941157 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 D140CC19F2D for ; Thu, 11 Aug 2022 05:06:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 379A58E0002; Thu, 11 Aug 2022 01:06:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3027B8E0001; Thu, 11 Aug 2022 01:06:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A4028E0002; Thu, 11 Aug 2022 01:06:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0B7CF8E0001 for ; Thu, 11 Aug 2022 01:06:36 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D1615ABB90 for ; Thu, 11 Aug 2022 05:06:35 +0000 (UTC) X-FDA: 79786126350.16.1C11D67 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) by imf04.hostedemail.com (Postfix) with ESMTP id 689894017A for ; Thu, 11 Aug 2022 05:06:35 +0000 (UTC) Received: by mail-oi1-f181.google.com with SMTP id n133so20221565oib.0 for ; Wed, 10 Aug 2022 22:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:message-id:subject:cc:to:from:date:from:to:cc; bh=quvX6z6poO5keYLoKw9+FS7nc7zJzPFptxa1p4PFcJI=; b=J3VozWdW72TUWrtZoiUsG9StCKcnf3uW3XgsbLoxPrWFIqWUQK1L8X+mKwlM3iMSmX eHaVVoo9rEGnZxajxECSwZac/cp2LkMEtWqkLG9YCU1SwYJaPstqdSn+oz9voOzxl2gR 56h/i17y0CoEZp/rX4i7/fi8kuIr7TTWjf9onouPzPTWKYVP01RmW/JNwIHL84j9qiTe H8sYzYI5Pf9wSSYlvoNq9fu7erTXBcfKN+JEmJ0z0CekMa5YBYweigdWcaLIhXQouxWq hv0BCzaFJh1mxy9mgv41kiAoTaty0KKWgRLKXf6A9nrG0lR178D/5lC6Gl0O9bR+OBgZ jjUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc; bh=quvX6z6poO5keYLoKw9+FS7nc7zJzPFptxa1p4PFcJI=; b=GQKRabiuZPfAxtHNPe6k0esC4ma5C5lWUzLcWirVGRunnaM51pf1xZBOMj3dLGwU9C F36pkLUlViSmN8Ekit6D2ZfMPWk9Pfy64k1PjykFkZ0GewEiURdrpqeZurtM4hYpE7mL L0RDAQck8M2myGFjYhRwXEyAzRk0GhQhm+AB9IrsUIPLe31upMD1z7rqXRSYUY+LBB41 7YaTOKP98gqfXW1iYYGrcnK5QBnYMBXS4IjkYIV6+IVLvB8W0EGx4ENvpffAekV2NrCu dQdXzz7d4NcEqBNUxb05HePY2u/1HhsJ7Dt1JrMgvOH8HnGKx+S98JpZDClkMCHlQaGm dEPg== X-Gm-Message-State: ACgBeo3/wdkuYtTnpsd02vFMxs+VGqrkbmGxUvyiP5YTMbv4M13ATYyR k2Hj+OseW91fprYgi/ZtSKZbOnDWro5CgQ== X-Google-Smtp-Source: AA6agR4zrYfHGR/cCGz5xRQTkDcDxPPuB6aVkKAnB3WW6LfbavZT3ojs25742RS1BdfGRBX23XKgEA== X-Received: by 2002:a05:6808:1598:b0:342:d044:2afc with SMTP id t24-20020a056808159800b00342d0442afcmr2857509oiw.235.1660194394565; Wed, 10 Aug 2022 22:06:34 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id eh23-20020a056870f59700b0010d910ffc3asm4134807oab.18.2022.08.10.22.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 22:06:34 -0700 (PDT) Date: Wed, 10 Aug 2022 22:06:33 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Andrew Morton cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm/shmem: shmem_replace_page() remember NR_SHMEM Message-ID: MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660194395; a=rsa-sha256; cv=none; b=MqHolaZ97n8UolS/w+ytjYrK2UA9X2bJGlelEb33UbJtwt7OJUShJHJ01sTF4rcZwDspHN hRxE1KwiqGafBGhPe4wAb9QNGUeT5WyxBVyqhX7IpyMFvQyPJaoIFXSpNwkPjFiehr21A1 V8ZYdxQT/0KSdSDCw4c6JAx9xYMGmSA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=J3VozWdW; spf=pass (imf04.hostedemail.com: domain of hughd@google.com designates 209.85.167.181 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660194395; 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: references:dkim-signature; bh=quvX6z6poO5keYLoKw9+FS7nc7zJzPFptxa1p4PFcJI=; b=wNli7fNG1NfQzs0V6vEa4XUkxsEXaGR46+e1C8aC5B6ptYBjQfFlaDQWfQM+uC8+NVRWCj LVoYe3KRpM45QfzW0XiD8SjKJJZraC4slxdysqcguQFFTO6n0Az/rBugY4ntlI8tijD1TS tAbzIMXjemM9d3/u9+MpXVkfHkLsdRg= X-Rspam-User: X-Stat-Signature: 519fntxcurqwcz4idbowkpocfrkh3rgc X-Rspamd-Queue-Id: 689894017A Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=J3VozWdW; spf=pass (imf04.hostedemail.com: domain of hughd@google.com designates 209.85.167.181 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam01 X-HE-Tag: 1660194395-881052 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: Elsewhere, NR_SHMEM is updated at the same time as shmem NR_FILE_PAGES; but shmem_replace_page() was forgetting to do that - so NR_SHMEM stats could grow too big or too small, in those unusual cases when it's used. Signed-off-by: Hugh Dickins Reviewed-by: Matthew Wilcox (Oracle) --- This is not terribly important, and will clash with one of Matthew's 59 for 5.21; I don't mind if this gets delayed, and we just do it again on top of his series later, or he fold the equivalent into his series; but thought I'd better send it in as another fix to shmem_replace_page() while that function is on our minds. mm/shmem.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1659,7 +1659,9 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp, new = page_folio(newpage); mem_cgroup_migrate(old, new); __inc_lruvec_page_state(newpage, NR_FILE_PAGES); + __inc_lruvec_page_state(newpage, NR_SHMEM); __dec_lruvec_page_state(oldpage, NR_FILE_PAGES); + __dec_lruvec_page_state(oldpage, NR_SHMEM); } xa_unlock_irq(&swap_mapping->i_pages);